From 3bfa294985001c2c6ebb58fbf87b2f795e055ca5 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 11 Nov 2010 01:36:23 +0000 Subject: Fixes #2640 - elgg_view_layout now uses a parameter array like all the other elgg_view* functions git-svn-id: http://code.elgg.org/elgg/trunk@7288 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 2 +- engine/lib/tags.php | 3 ++- engine/lib/users.php | 12 ++++------- engine/lib/views.php | 57 ++++++++++++++++++++++++++++------------------------ 4 files changed, 38 insertions(+), 36 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 5a9e14498..2e2003bc8 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -211,7 +211,7 @@ function admin_settings_page_handler($page) { $content = "
$notices_html
$content"; } - $body = elgg_view_layout('administration', $content); + $body = elgg_view_layout('administration', array('content' => $content)); echo elgg_view_page($title, $body, 'page_shells/admin'); } diff --git a/engine/lib/tags.php b/engine/lib/tags.php index 68cfee940..d5010118a 100644 --- a/engine/lib/tags.php +++ b/engine/lib/tags.php @@ -439,7 +439,8 @@ function elgg_tagcloud_page_handler($page) { default: $title = elgg_view_title(elgg_echo('tags:site_cloud')); $tags = display_tagcloud(0, 100, 'tags'); - $body = elgg_view_layout('one_column_with_sidebar', $title . $tags); + $content = $title . $tags; + $body = elgg_view_layout('one_column_with_sidebar', array('content' => $content)); echo elgg_view_page(elgg_echo('tags:site_cloud'), $body); break; diff --git a/engine/lib/users.php b/engine/lib/users.php index b3c21a0b5..b116e1083 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -984,7 +984,7 @@ function elgg_user_resetpassword_page_handler($page) { $title = elgg_echo('resetpassword'); $content = elgg_view_title(elgg_echo('resetpassword')) . $form; - echo elgg_view_page($title, elgg_view_layout('one_column', $content)); + echo elgg_view_page($title, elgg_view_layout('one_column', array('content' => $content))); } /** @@ -1332,13 +1332,9 @@ function registration_page_handler($page_elements) { * @todo finish */ function elgg_user_login_page_handler() { - $content = elgg_view_layout('one_column', elgg_view('account/login_box')); - $content = ' -
- ' . elgg_view('account/login_box') . ' -
- '; - echo elgg_view_page('test', $content); + $login_box = elgg_view('account/login_box'); + $content = elgg_view_layout('one_column', array('content' => $login_box)); + echo elgg_view_page(elgg_echo('login'), $content); } /** diff --git a/engine/lib/views.php b/engine/lib/views.php index 459f84b69..24b25ffd0 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -916,38 +916,43 @@ function elgg_view_entity_annotations(ElggEntity $entity, $full = true) { /** * Displays a layout with optional parameters. * - * Layouts control the static elements in Elgg's appearance. + * Layouts provide consistent organization of pages and other blocks of content. * There are a few default layouts in core: - * - administration A special layout for the admin area. - * - one_column A single column page with a header and footer. - * - one_column_with_sidebar A single column page with a header, footer, and sidebar. - * - widgets A widget canvas. - * - * Arguments to this function are passed to the layouts as $area1, $area2, - * ... $areaN. See the individual layouts for what options are supported. - * - * Layouts are stored in canvas/layouts/$layout_name. - * - * @tip When calling this function, be sure to name the variable argument - * names as something meaningful. Avoid the habit of using $areaN as the - * argument names. - * - * @param string $layout The name of the views in canvas/layouts/. + * - administration A special layout for the admin area. + * - one_column A single content column. + * - one_column_with_sidebar A content column with sidebar. + * - widgets A widget canvas. + * + * The layout views take the form canvas/layouts/$layout_name + * See the individual layouts for what options are supported. The two most + * common layouts have these parameters: + * one_column + * content => string + * one_column_with_sidebar + * content => string + * sidebar => string (optional) + * + * @param string $layout The name of the view in canvas/layouts/. + * @param array $vars Associative array of parameters for the layout view * * @return string The layout - * @todo Make this consistent with the rest of the view functions by passing - * an array instead of "$areaN". */ -function elgg_view_layout($layout) { - $arg = 1; - $param_array = array(); - while ($arg < func_num_args()) { - $param_array['area' . $arg] = func_get_arg($arg); - $arg++; +function elgg_view_layout($layout_name, $vars = array()) { + + if (is_string($vars)) { + elgg_deprecated_notice("The use of unlimited optional string arguments in elgg_view_layout() was deprecated in favor of an options array", 1.8); + $arg = 1; + $param_array = array(); + while ($arg < func_num_args()) { + $param_array['area' . $arg] = func_get_arg($arg); + $arg++; + } + } else { + $param_array = $vars; } - if (elgg_view_exists("canvas/layouts/{$layout}")) { - return elgg_view("canvas/layouts/{$layout}", $param_array); + if (elgg_view_exists("canvas/layouts/{$layout_name}")) { + return elgg_view("canvas/layouts/{$layout_name}", $param_array); } else { return elgg_view("canvas/default", $param_array); } -- cgit v1.2.3