diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-10-09 01:00:08 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-10-09 01:00:08 +0000 |
commit | c05f2181dc8556cb6700e8c6bb6e6ded43273192 (patch) | |
tree | 5446facb7f5f18dfaac48aade56c0d86f1477fff /includes | |
parent | 48dd14a898420ae98984c951f59e8d299080bee8 (diff) | |
download | brdo-c05f2181dc8556cb6700e8c6bb6e6ded43273192.tar.gz brdo-c05f2181dc8556cb6700e8c6bb6e6ded43273192.tar.bz2 |
- Patch #572618 by effulgentsia, pwolanin, sun: all theme functions should take a single argument. Code clean-up and performance improvement. Woot.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/batch.inc | 4 | ||||
-rw-r--r-- | includes/common.inc | 14 | ||||
-rw-r--r-- | includes/file.inc | 2 | ||||
-rw-r--r-- | includes/form.inc | 267 | ||||
-rw-r--r-- | includes/locale.inc | 18 | ||||
-rw-r--r-- | includes/menu.inc | 57 | ||||
-rw-r--r-- | includes/pager.inc | 159 | ||||
-rw-r--r-- | includes/tablesort.inc | 2 | ||||
-rw-r--r-- | includes/theme.inc | 686 | ||||
-rw-r--r-- | includes/theme.maintenance.inc | 37 |
10 files changed, 689 insertions, 557 deletions
diff --git a/includes/batch.inc b/includes/batch.inc index 095b9e78b..c0833208f 100644 --- a/includes/batch.inc +++ b/includes/batch.inc @@ -170,7 +170,7 @@ function _batch_progress_page_nojs() { // the error message. ob_start(); $fallback = $current_set['error_message'] . '<br />' . $batch['error_message']; - $fallback = theme('maintenance_page', $fallback, FALSE); + $fallback = theme('maintenance_page', array('content' => $fallback, 'show_messages' => FALSE)); // We strip the end of the page using a marker in the template, so any // additional HTML output by PHP shows up inside the page rather than below @@ -192,7 +192,7 @@ function _batch_progress_page_nojs() { $url = url($batch['url'], array('query' => array('id' => $batch['id'], 'op' => $new_op))); drupal_add_html_head('<meta http-equiv="Refresh" content="0; URL=' . $url . '">'); - return theme('progress_bar', $percentage, $message); + return theme('progress_bar', array('percent' => $percentage, 'message' => $message)); } /** diff --git a/includes/common.inc b/includes/common.inc index 450777f3d..74e437e8f 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -320,7 +320,7 @@ function drupal_add_feed($url = NULL, $title = '') { $stored_feed_links = &drupal_static(__FUNCTION__, array()); if (!is_null($url) && !isset($stored_feed_links[$url])) { - $stored_feed_links[$url] = theme('feed_icon', $url, $title); + $stored_feed_links[$url] = theme('feed_icon', array('url' => $url, 'title' => $title)); drupal_add_link(array('rel' => 'alternate', 'type' => 'application/rss+xml', @@ -650,8 +650,8 @@ function drupal_site_offline() { drupal_maintenance_theme(); drupal_add_http_header('503 Service unavailable'); drupal_set_title(t('Site under maintenance')); - print theme('maintenance_page', filter_xss_admin(variable_get('maintenance_mode_message', - t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))))); + print theme('maintenance_page', array('content' => filter_xss_admin(variable_get('maintenance_mode_message', + t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal'))))))); } /** @@ -1174,7 +1174,7 @@ function _drupal_log_error($error, $fatal = FALSE) { drupal_set_title(t('Error')); // We fallback to a maintenance page at this point, because the page generation // itself can generate errors. - print theme('maintenance_page', t('The website encountered an unexpected error. Please try again later.')); + print theme('maintenance_page', array('content' => t('The website encountered an unexpected error. Please try again later.'))); exit; } } @@ -1499,7 +1499,7 @@ function t($string, array $args = array(), array $options = array()) { case '%': default: // Escaped and placeholder. - $args[$key] = theme('placeholder', $value); + $args[$key] = theme('placeholder', array('text' => $value)); break; case '!': @@ -3683,7 +3683,7 @@ function drupal_get_library($module, $name) { * themed into a table. The table must have an id attribute set. If using * theme_table(), the id may be set as such: * @code - * $output = theme('table', $header, $rows, array('id' => 'my-module-table')); + * $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'my-module-table'))); * return $output; * @endcode * @@ -4860,7 +4860,7 @@ function drupal_common_theme() { 'arguments' => array('region' => NULL), ), 'username' => array( - 'arguments' => array('object' => NULL), + 'arguments' => array('account' => NULL), ), 'progress_bar' => array( 'arguments' => array('percent' => NULL, 'message' => NULL), diff --git a/includes/file.inc b/includes/file.inc index 0a69859ec..7729544f1 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -1162,7 +1162,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE, if (!empty($errors)) { $message = t('The specified file %name could not be uploaded.', array('%name' => $file->filename)); if (count($errors) > 1) { - $message .= theme('item_list', $errors); + $message .= theme('item_list', array('items' => $errors)); } else { $message .= ' ' . array_pop($errors); diff --git a/includes/form.inc b/includes/form.inc index 21813389d..31e200b80 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -1549,10 +1549,12 @@ function form_options_flatten($array, $reset = TRUE) { /** * Theme select form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #title, #value, #options, #description, #extra, #multiple, - * #required, #name, #attributes, #size. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #title, #value, #options, #description, #extra, + * #multiple, #required, #name, #attributes, #size. + * * @return * A themed HTML string representing the form element. * @@ -1562,7 +1564,8 @@ function form_options_flatten($array, $reset = TRUE) { * $options to an associative array in which the keys are group labels, and the * values are associative arrays in the normal $options format. */ -function theme_select($element) { +function theme_select($variables) { + $element = $variables['element']; $select = ''; $size = $element['#size'] ? ' size="' . $element['#size'] . '"' : ''; _form_set_class($element, array('form-select')); @@ -1667,16 +1670,19 @@ function form_get_options($element, $key) { /** * Theme a fieldset form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #attributes, #children, #collapsed, #collapsible, - * #description, #id, #title, #value. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #attributes, #children, #collapsed, #collapsible, + * #description, #id, #title, #value. + * * @return * A themed HTML string representing the group of items. * * @ingroup themeable */ -function theme_fieldset($element) { +function theme_fieldset($variables) { + $element = $variables['element']; if (!empty($element['#collapsible'])) { if (!isset($element['#attributes']['class'])) { @@ -1696,16 +1702,19 @@ function theme_fieldset($element) { /** * Theme a radio button form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #required, #return_value, #value, #attributes, #title, - * #description + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #required, #return_value, #value, #attributes, #title, + * #description + * * @return * A themed HTML string representing the form item group. * * @ingroup themeable */ -function theme_radio($element) { +function theme_radio($variables) { + $element = $variables['element']; _form_set_class($element, array('form-radio')); $output = '<input type="radio" '; $output .= 'id="' . $element['#id'] . '" '; @@ -1723,16 +1732,19 @@ function theme_radio($element) { /** * Theme a set of radio button form elements. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #title, #value, #options, #description, #required, - * #attributes, #children. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #title, #value, #options, #description, #required, + * #attributes, #children. + * * @return * A themed HTML string representing the radio button set. * * @ingroup themeable */ -function theme_radios($element) { +function theme_radios($variables) { + $element = $variables['element']; $class = 'form-radios'; if (!empty($element['#attributes']['class'])) { $class .= ' ' . implode(' ', $element['#attributes']['class']); @@ -1798,16 +1810,19 @@ function password_confirm_validate($element, &$element_state) { /** * Theme a date selection form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #title, #value, #options, #description, #required, - * #attributes. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #title, #value, #options, #description, #required, + * #attributes. + * * @return * A themed HTML string representing the date selection boxes. * * @ingroup themeable */ -function theme_date($element) { +function theme_date($variables) { + $element = $variables['element']; return '<div class="container-inline">' . drupal_render_children($element) . '</div>'; } @@ -2007,15 +2022,18 @@ function form_process_text_format($element) { /** * Theme a text format form element. * - * @param element - * An associative array containing the properties of the element. - * Properties used: #children, #description + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #children, #description + * * @return * A string representing the form element. * * @ingroup themeable */ -function theme_text_format_wrapper($element) { +function theme_text_format_wrapper($variables) { + $element = $variables['element']; $output = '<div class="text-format-wrapper">' . "\n"; $output .= $element['#children'] . "\n"; @@ -2032,16 +2050,19 @@ function theme_text_format_wrapper($element) { /** * Theme a checkbox form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #title, #value, #return_value, #description, #required, - * #attributes. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #title, #value, #return_value, #description, #required, + * #attributes. + * * @return * A themed HTML string representing the checkbox. * * @ingroup themeable */ -function theme_checkbox($element) { +function theme_checkbox($variables) { + $element = $variables['element']; _form_set_class($element, array('form-checkbox')); $checkbox = '<input '; $checkbox .= 'type="checkbox" '; @@ -2061,15 +2082,18 @@ function theme_checkbox($element) { /** * Theme a set of checkbox form elements. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #children, #attributes. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #children, #attributes. + * * @return * A themed HTML string representing the checkbox set. * * @ingroup themeable */ -function theme_checkboxes($element) { +function theme_checkboxes($variables) { + $element = $variables['element']; $class = 'form-checkboxes'; if (!empty($element['#attributes']['class'])) { $class .= ' ' . implode(' ', $element['#attributes']['class']); @@ -2119,13 +2143,15 @@ function form_process_checkboxes($element) { /** * Format a table with radio buttons or checkboxes. * - * @param $element - * An associative array containing the properties and children of the - * tableselect element. - * Each option in $element['#options'] can contain an array keyed by - * '#attributes' which is added to the row's HTML attributes. - * @see theme_table - * Properties used: header, options, empty, js_select. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties and children of + * the tableselect element. + * Each option in $variables['element']['#options'] can contain an array + * keyed by '#attributes' which is added to the row's HTML attributes. + * @see theme_table + * Properties used: header, options, empty, js_select. + * * @return * A themed HTML string representing the table. * @@ -2145,7 +2171,8 @@ function form_process_checkboxes($element) { * ); * @ingroup themeable */ -function theme_tableselect($element) { +function theme_tableselect($variables) { + $element = $variables['element']; $rows = array(); if (!empty($element['#options'])) { // Generate a table row for each selectable item in #options. @@ -2177,7 +2204,7 @@ function theme_tableselect($element) { $header = $element['#header']; $rows[] = array(array('data' => $element['#empty'], 'colspan' => count($header))); } - return theme('table', $header, $rows); + return theme('table', array('header' => $header, 'rows' => $rows)); } /** @@ -2375,16 +2402,21 @@ function form_process_vertical_tabs($element, &$form_state) { /** * Makes the element's children fieldsets be vertical tabs. * - * @param $element - * An associative array containing the properties and children of the - * fieldset. - * Properties used: #children. + * @param $variables + * An associative array containing: + * + * - element + * An associative array containing the properties and children of the + * fieldset. + * Properties used: #children. + * * @return * A themed HTML string representing the form element. * * @ingroup themeable */ -function theme_vertical_tabs($element) { +function theme_vertical_tabs($variables) { + $element = $variables['element']; // Add required JavaScript and Stylesheet. drupal_add_library('system', 'vertical-tabs'); @@ -2394,30 +2426,36 @@ function theme_vertical_tabs($element) { /** * Theme a submit button form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #attributes, #button_type, #name, #value. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #attributes, #button_type, #name, #value. + * * @return * A themed HTML string representing the form element. * * @ingroup themeable */ -function theme_submit($element) { +function theme_submit($variables) { + $element = $variables['element']; return theme('button', $element); } /** * Theme a button form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #attributes, #button_type, #name, #value. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #attributes, #button_type, #name, #value. + * * @return * A themed HTML string representing the form element. * * @ingroup themeable */ -function theme_button($element) { +function theme_button($variables) { + $element = $variables['element']; $element['#attributes']['class'][] = 'form-' . $element['#button_type']; return '<input type="submit" ' . (empty($element['#name']) ? '' : 'name="' . $element['#name'] . '" ') . 'id="' . $element['#id'] . '" value="' . check_plain($element['#value']) . '" ' . drupal_attributes($element['#attributes']) . " />\n"; @@ -2426,14 +2464,17 @@ function theme_button($element) { /** * Theme a image button form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #attributes, #button_type, #name, #value, #title, #src. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #attributes, #button_type, #name, #value, #title, #src. + * * @return * A themed HTML string representing the form element. * @ingroup themeable */ -function theme_image_button($element) { +function theme_image_button($variables) { + $element = $variables['element']; $element['#attributes']['class'][] = 'form-' . $element['#button_type']; return '<input type="image" name="' . $element['#name'] . '" ' . @@ -2448,31 +2489,37 @@ function theme_image_button($element) { /** * Theme a hidden form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #name, #value, #attributes. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #name, #value, #attributes. + * * @return * A themed HTML string representing the form element. * * @ingroup themeable */ -function theme_hidden($element) { +function theme_hidden($variables) { + $element = $variables['element']; return '<input type="hidden" name="' . $element['#name'] . '" id="' . $element['#id'] . '" value="' . check_plain($element['#value']) . "\" " . drupal_attributes($element['#attributes']) . " />\n"; } /** * Theme a textfield form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #title, #value, #description, #size, #maxlength, - * #required, #attributes, #autocomplete_path. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #title, #value, #description, #size, #maxlength, + * #required, #attributes, #autocomplete_path. + * * @return * A themed HTML string representing the textfield. * * @ingroup themeable */ -function theme_textfield($element) { +function theme_textfield($variables) { + $element = $variables['element']; $size = empty($element['#size']) ? '' : ' size="' . $element['#size'] . '"'; $maxlength = empty($element['#maxlength']) ? '' : ' maxlength="' . $element['#maxlength'] . '"'; $class = array('form-text'); @@ -2501,15 +2548,18 @@ function theme_textfield($element) { /** * Theme a form. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #action, #method, #attributes, #children + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #action, #method, #attributes, #children + * * @return * A themed HTML string representing the form. * * @ingroup themeable */ -function theme_form($element) { +function theme_form($variables) { + $element = $variables['element']; // Anonymous div to satisfy XHTML compliance. $action = $element['#action'] ? 'action="' . check_url($element['#action']) . '" ' : ''; return '<form ' . $action . ' accept-charset="UTF-8" method="' . $element['#method'] . '" id="' . $element['#id'] . '"' . drupal_attributes($element['#attributes']) . ">\n<div>" . $element['#children'] . "\n</div></form>\n"; @@ -2518,16 +2568,19 @@ function theme_form($element) { /** * Theme a textarea form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #title, #value, #description, #rows, #cols, #required, - * #attributes + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #title, #value, #description, #rows, #cols, #required, + * #attributes + * * @return * A themed HTML string representing the textarea. * * @ingroup themeable */ -function theme_textarea($element) { +function theme_textarea($variables) { + $element = $variables['element']; $class = array('form-textarea'); // Add resizable behavior @@ -2543,32 +2596,37 @@ function theme_textarea($element) { /** * Theme HTML markup for use in forms. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #markup, #children. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #markup, #children. + * * @return * A themed HTML string representing the HTML markup. * * @ingroup themeable */ - -function theme_markup($element) { +function theme_markup($variables) { + $element = $variables['element']; return (!empty($element['#markup']) ? $element['#markup'] : '') . drupal_render_children($element); } /** * Theme a password form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #title, #value, #description, #size, #maxlength, - * #required, #attributes. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #title, #value, #description, #size, #maxlength, + * #required, #attributes. + * * @return - * A themed HTML string representing the form. + * A themed HTML string representing the form element. * * @ingroup themeable */ -function theme_password($element) { +function theme_password($variables) { + $element = $variables['element']; $size = $element['#size'] ? ' size="' . $element['#size'] . '" ' : ''; $maxlength = $element['#maxlength'] ? ' maxlength="' . $element['#maxlength'] . '" ' : ''; @@ -2594,9 +2652,12 @@ function form_process_weight($element) { /** * Theme a file upload form element. * - * @param $element - * An associative array containing the properties of the element. - * Properties used: #title, #name, #size, #description, #required, $attributes. + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #title, #name, #size, #description, #required, + * #attributes. + * * @return * A themed HTML string representing the field. * @@ -2605,7 +2666,8 @@ function form_process_weight($element) { * For assistance with handling the uploaded file correctly, see the API * provided by file.inc. */ -function theme_file($element) { +function theme_file($variables) { + $element = $variables['element']; _form_set_class($element, array('form-file')); return '<input type="file" name="' . $element['#name'] . '"' . ($element['#attributes'] ? ' ' . drupal_attributes($element['#attributes']) : '') . ' id="' . $element['#id'] . '" size="' . $element['#size'] . "\" />\n"; } @@ -2613,15 +2675,18 @@ function theme_file($element) { /** * Theme a form element. * - * @param element - * An associative array containing the properties of the element. - * Properties used: #title, #description, #id, #required, #children + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #title, #description, #id, #required, #children + * * @return * A string representing the form element. * * @ingroup themeable */ -function theme_form_element($element) { +function theme_form_element($variables) { + $element = $variables['element']; // This is also used in the installer, pre-database setup. $t = get_t(); diff --git a/includes/locale.inc b/includes/locale.inc index 8e7cc3cd4..85e056ce1 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -69,9 +69,17 @@ function locale_languages_overview_form() { /** * Theme the language overview form. * + * @param $variables + * An associative array containing: + * - form: @todo: document + * + * @return + * A themed HTML string representing the form. + * * @ingroup themeable */ -function theme_locale_languages_overview_form($form) { +function theme_locale_languages_overview_form($variables) { + $form = $variables['form']; $default = language_default(); foreach ($form['name'] as $key => $element) { // Do not take form control structures. @@ -96,7 +104,7 @@ function theme_locale_languages_overview_form($form) { } } $header = array(array('data' => t('English name')), array('data' => t('Native name')), array('data' => t('Code')), array('data' => t('Direction')), array('data' => t('Enabled')), array('data' => t('Default')), array('data' => t('Weight')), array('data' => t('Operations'))); - $output = theme('table', $header, $rows, array('id' => 'language-order')); + $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'language-order'))); $output .= drupal_render_children($form); drupal_add_tabledrag('language-order', 'order', 'sibling', 'language-order-weight'); @@ -543,7 +551,7 @@ function locale_translate_overview_screen() { $rows[$data->language][$data->textgroup] = $data->translation . '/' . $groupsums[$data->textgroup] . " ($ratio%)"; } - return theme('table', $headers, $rows); + return theme('table', array('header' => $headers, 'rows' => $rows)); } /** * @} End of "locale-translate-overview" @@ -2305,8 +2313,8 @@ function _locale_translate_seek() { } if (count($rows)) { - $output .= theme('table', $header, $rows); - if ($pager = theme('pager', NULL)) { + $output .= theme('table', array('header' => $header, 'rows' => $rows)); + if ($pager = theme('pager', array('tags' => NULL))) { $output .= $pager; } } diff --git a/includes/menu.inc b/includes/menu.inc index 590715f23..a9511af97 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -1308,21 +1308,33 @@ function template_preprocess_menu_tree(&$variables) { /** * Theme wrapper for the HTML output for a menu sub-tree. * + * @param $variables + * An associative array containing: + * - tree: @todo: document + * + * @return + * A themed HTML string. + * * @ingroup themeable */ -function theme_menu_tree($tree) { - return '<ul class="menu">' . $tree . '</ul>'; +function theme_menu_tree($variables) { + return '<ul class="menu">' . $variables['tree'] . '</ul>'; } /** * Generate the HTML output for a menu link and submenu. * - * @param $element - * Structured array data for a menu link. + * @param $variables + * An associative array containing: + * - element: Structured array data for a menu link. + * + * @return + * A themed HTML string. * * @ingroup themeable */ -function theme_menu_link(array $element) { +function theme_menu_link(array $variables) { + $element = $variables['element']; $sub_menu = ''; if ($element['#below']) { @@ -1335,26 +1347,31 @@ function theme_menu_link(array $element) { /** * Generate the HTML output for a single local task link. * - * @param $link - * A menu link array with 'title', 'href', and 'localized_options' keys. - * @param $active - * A boolean indicating whether the local task is active. + * @param $variables + * An associative array containing: + * - link: A menu link array with 'title', 'href', and 'localized_options' + * keys. + * - active: A boolean indicating whether the local task is active. * * @ingroup themeable */ -function theme_menu_local_task($link, $active = FALSE) { - return '<li ' . ($active ? 'class="active" ' : '') . '>' . l($link['title'], $link['href'], $link['localized_options']) . "</li>\n"; +function theme_menu_local_task($variables) { + $link = $variables['link']; + return '<li ' . ($variables['active'] ? 'class="active" ' : '') . '>' . l($link['title'], $link['href'], $link['localized_options']) . "</li>\n"; } /** * Generate the HTML output for a single local action link. * - * @param $link - * A menu link array with 'title', 'href', and 'localized_options' keys. + * @param $variables + * An associative array containing: + * - link: A menu link array with 'title', 'href', and 'localized_options' + * keys. * * @ingroup themeable */ -function theme_menu_local_action($link) { +function theme_menu_local_action($variables) { + $link = $variables['link']; return '<li>' . l($link['title'], $link['href'], $link['localized_options']) . "</li>\n"; } @@ -1389,7 +1406,7 @@ function menu_get_active_help() { // Add "more help" link on admin pages if the module provides a // standalone help page. if ($arg[0] == "admin" && user_access('access administration pages') && module_exists('help') && $function('admin/help#' . $arg[2], $empty_arg) && $help) { - $output .= theme("more_help_link", url('admin/help/' . $arg[2])); + $output .= theme("more_help_link", array('url' => url('admin/help/' . $arg[2]))); } } return $output; @@ -1597,17 +1614,17 @@ function menu_local_tasks($level = 0) { for ($p = $item['tab_parent']; $tasks[$p]['type'] == MENU_DEFAULT_LOCAL_TASK; $p = $tasks[$p]['tab_parent']); // Use the path of the parent instead. $link['href'] = $tasks[$p]['href']; - $tabs_current .= theme('menu_local_task', $link, TRUE); + $tabs_current .= theme('menu_local_task', array('link' => $link, 'active' => TRUE)); $next_path = $item['path']; $tab_count++; } else { if ($item['type'] == MENU_LOCAL_TASK) { - $tabs_current .= theme('menu_local_task', $link); + $tabs_current .= theme('menu_local_task', array('link' => $link)); $tab_count++; } else { - $actions_current .= theme('menu_local_action', $link); + $actions_current .= theme('menu_local_action', array('link' => $link)); $action_count++; } } @@ -1649,14 +1666,14 @@ function menu_local_tasks($level = 0) { } // We check for the active tab. if ($item['path'] == $path) { - $tabs_current .= theme('menu_local_task', $link, TRUE); + $tabs_current .= theme('menu_local_task', array('link' => $link, 'active' => TRUE)); $next_path = $item['tab_parent']; if (isset($tasks[$next_path])) { $next_parent = $tasks[$next_path]['tab_parent']; } } else { - $tabs_current .= theme('menu_local_task', $link); + $tabs_current .= theme('menu_local_task', array('link' => $link)); } } } diff --git a/includes/pager.inc b/includes/pager.inc index 0bee418df..f9c477a08 100644 --- a/includes/pager.inc +++ b/includes/pager.inc @@ -192,20 +192,25 @@ function pager_get_query_parameters() { * retrieve a pager control so that users can view other results. * Format a list of nearby pages with additional query results. * - * @param $tags - * An array of labels for the controls in the pager. - * @param $element - * An optional integer to distinguish between multiple pagers on one page. - * @param $parameters - * An associative array of query string parameters to append to the pager links. - * @param $quantity - * The number of pages in the list. + * @param $variables + * An associative array containing: + * - tags: An array of labels for the controls in the pager. + * - element: An optional integer to distinguish between multiple pagers on + * one page. + * - parameters: An associative array of query string parameters to append to + * the pager links. + * - quantity: The number of pages in the list. + * * @return * An HTML string that generates the query pager. * * @ingroup themeable */ -function theme_pager($tags = array(), $element = 0, $parameters = array(), $quantity = 9) { +function theme_pager($variables) { + $tags = $variables['tags']; + $element = $variables['element']; + $parameters = $variables['parameters']; + $quantity = $variables['quantity']; global $pager_page_array, $pager_total; // Calculate various markers within this pager piece: @@ -235,10 +240,10 @@ function theme_pager($tags = array(), $element = 0, $parameters = array(), $quan } // End of generation loop preparation. - $li_first = theme('pager_first', (isset($tags[0]) ? $tags[0] : t('« first')), $element, $parameters); - $li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : t('‹ previous')), $element, 1, $parameters); - $li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('next ›')), $element, 1, $parameters); - $li_last = theme('pager_last', (isset($tags[4]) ? $tags[4] : t('last »')), $element, $parameters); + $li_first = theme('pager_first', array('text' => (isset($tags[0]) ? $tags[0] : t('« first')), 'element' => $element, 'parameters' => $parameters)); + $li_previous = theme('pager_previous', array('text' => (isset($tags[1]) ? $tags[1] : t('‹ previous')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters)); + $li_next = theme('pager_next', array('text' => (isset($tags[3]) ? $tags[3] : t('next ›')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters)); + $li_last = theme('pager_last', array('text' => (isset($tags[4]) ? $tags[4] : t('last »')), 'element' => $element, 'parameters' => $parameters)); if ($pager_total[$element] > 1) { if ($li_first) { @@ -267,7 +272,7 @@ function theme_pager($tags = array(), $element = 0, $parameters = array(), $quan if ($i < $pager_current) { $items[] = array( 'class' => array('pager-item'), - 'data' => theme('pager_previous', $i, $element, ($pager_current - $i), $parameters), + 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($pager_current - $i), 'parameters' => $parameters)), ); } if ($i == $pager_current) { @@ -279,7 +284,7 @@ function theme_pager($tags = array(), $element = 0, $parameters = array(), $quan if ($i > $pager_current) { $items[] = array( 'class' => array('pager-item'), - 'data' => theme('pager_next', $i, $element, ($i - $pager_current), $parameters), + 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $pager_current), 'parameters' => $parameters)), ); } } @@ -303,7 +308,7 @@ function theme_pager($tags = array(), $element = 0, $parameters = array(), $quan 'data' => $li_last, ); } - return theme('item_list', $items, NULL, 'ul', array('class' => array('pager'))); + return theme('item_list', array('items' => $items, 'title' => NULL, 'type' => 'ul', 'attributes' => array('class' => array('pager')))); } } @@ -318,24 +323,29 @@ function theme_pager($tags = array(), $element = 0, $parameters = array(), $quan /** * Format a "first page" link. * - * @param $text - * The name (or image) of the link. - * @param $element - * An optional integer to distinguish between multiple pagers on one page. - * @param $parameters - * An associative array of query string parameters to append to the pager links. + * @param $variables + * An associative array containing: + * - text: The name (or image) of the link. + * - element: An optional integer to distinguish between multiple pagers on + * one page. + * - parameters: An associative array of query string parameters to append to + * the pager links. + * * @return * An HTML string that generates this piece of the query pager. * * @ingroup themeable */ -function theme_pager_first($text, $element = 0, $parameters = array()) { +function theme_pager_first($variables) { + $text = $variables['text']; + $element = $variables['element']; + $parameters = $variables['parameters']; global $pager_page_array; $output = ''; // If we are anywhere but the first page if ($pager_page_array[$element] > 0) { - $output = theme('pager_link', $text, pager_load_array(0, $element, $pager_page_array), $element, $parameters); + $output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array(0, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters)); } return $output; @@ -344,20 +354,25 @@ function theme_pager_first($text, $element = 0, $parameters = array()) { /** * Format a "previous page" link. * - * @param $text - * The name (or image) of the link. - * @param $element - * An optional integer to distinguish between multiple pagers on one page. - * @param $interval - * The number of pages to move backward when the link is clicked. - * @param $parameters - * An associative array of query string parameters to append to the pager links. + * @param $variables + * An associative array containing: + * - text: The name (or image) of the link. + * - element: An optional integer to distinguish between multiple pagers on + * one page. + * - interval: The number of pages to move backward when the link is clicked. + * - parameters: An associative array of query string parameters to append to + * the pager links. + * * @return * An HTML string that generates this piece of the query pager. * * @ingroup themeable */ -function theme_pager_previous($text, $element = 0, $interval = 1, $parameters = array()) { +function theme_pager_previous($variables) { + $text = $variables['text']; + $element = $variables['element']; + $interval = $variables['interval']; + $parameters = $variables['parameters']; global $pager_page_array; $output = ''; @@ -367,11 +382,11 @@ function theme_pager_previous($text, $element = 0, $interval = 1, $parameters = // If the previous page is the first page, mark the link as such. if ($page_new[$element] == 0) { - $output = theme('pager_first', $text, $element, $parameters); + $output = theme('pager_first', array('text' => $text, 'element' => $element, 'parameters' => $parameters)); } // The previous page is not the first page. else { - $output = theme('pager_link', $text, $page_new, $element, $parameters); + $output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters)); } } @@ -381,20 +396,25 @@ function theme_pager_previous($text, $element = 0, $interval = 1, $parameters = /** * Format a "next page" link. * - * @param $text - * The name (or image) of the link. - * @param $element - * An optional integer to distinguish between multiple pagers on one page. - * @param $interval - * The number of pages to move forward when the link is clicked. - * @param $parameters - * An associative array of query string parameters to append to the pager links. + * @param $variables + * An associative array containing: + * - text: The name (or image) of the link. + * - element: An optional integer to distinguish between multiple pagers on + * one page. + * - interval: The number of pages to move forward when the link is clicked. + * - parameters: An associative array of query string parameters to append to + * the pager links. + * * @return * An HTML string that generates this piece of the query pager. * * @ingroup themeable */ -function theme_pager_next($text, $element = 0, $interval = 1, $parameters = array()) { +function theme_pager_next($variables) { + $text = $variables['text']; + $element = $variables['element']; + $interval = $variables['interval']; + $parameters = $variables['parameters']; global $pager_page_array, $pager_total; $output = ''; @@ -403,11 +423,11 @@ function theme_pager_next($text, $element = 0, $interval = 1, $parameters = arra $page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array); // If the next page is the last page, mark the link as such. if ($page_new[$element] == ($pager_total[$element] - 1)) { - $output = theme('pager_last', $text, $element, $parameters); + $output = theme('pager_last', array('text' => $text, 'element' => $element, 'parameters' => $parameters)); } // The next page is not the last page. else { - $output = theme('pager_link', $text, $page_new, $element, $parameters); + $output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters)); } } @@ -417,24 +437,29 @@ function theme_pager_next($text, $element = 0, $interval = 1, $parameters = arra /** * Format a "last page" link. * - * @param $text - * The name (or image) of the link. - * @param $element - * An optional integer to distinguish between multiple pagers on one page. - * @param $parameters - * An associative array of query string parameters to append to the pager links. + * @param $variables + * An associative array containing: + * - text: The name (or image) of the link. + * - element: An optional integer to distinguish between multiple pagers on + * one page. + * - parameters: An associative array of query string parameters to append to + * the pager links. + * * @return * An HTML string that generates this piece of the query pager. * * @ingroup themeable */ -function theme_pager_last($text, $element = 0, $parameters = array()) { +function theme_pager_last($variables) { + $text = $variables['text']; + $element = $variables['element']; + $parameters = $variables['parameters']; global $pager_page_array, $pager_total; $output = ''; // If we are anywhere but the last page if ($pager_page_array[$element] < ($pager_total[$element] - 1)) { - $output = theme('pager_link', $text, pager_load_array($pager_total[$element] - 1, $element, $pager_page_array), $element, $parameters); + $output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array($pager_total[$element] - 1, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters)); } return $output; @@ -444,20 +469,28 @@ function theme_pager_last($text, $element = 0, $parameters = array()) { /** * Format a link to a specific query result page. * - * @param $page_new - * The first result to display on the linked page. - * @param $element - * An optional integer to distinguish between multiple pagers on one page. - * @param $parameters - * An associative array of query string parameters to append to the pager link. - * @param $attributes - * An associative array of HTML attributes to apply to a pager anchor tag. + * @param $variables + * An associative array containing: + * - page_new: The first result to display on the linked page. + * - element: An optional integer to distinguish between multiple pagers on + * one page. + * - parameters: An associative array of query string parameters to append to + * the pager link. + * - attributes: An associative array of HTML attributes to apply to a pager + * anchor tag. + * * @return * An HTML string that generates the link. * * @ingroup themeable */ -function theme_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) { +function theme_pager_link($variables) { + $text = $variables['text']; + $page_new = $variables['page_new']; + $element = $variables['element']; + $parameters = $variables['parameters']; + $attributes = $variables['attributes']; + $page = isset($_GET['page']) ? $_GET['page'] : ''; if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) { $parameters['page'] = $new_page; diff --git a/includes/tablesort.inc b/includes/tablesort.inc index 6c005977c..d83e575a0 100644 --- a/includes/tablesort.inc +++ b/includes/tablesort.inc @@ -169,7 +169,7 @@ function tablesort_header($cell, $header, $ts) { if ($cell['data'] == $ts['name']) { $ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc'); $cell['class'][] = 'active'; - $image = theme('tablesort_indicator', $ts['sort']); + $image = theme('tablesort_indicator', array('style' => $ts['sort'])); } else { // If the user clicks a different header, we want to sort ascending initially. diff --git a/includes/theme.inc b/includes/theme.inc index 20571c178..b06f62c32 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -609,12 +609,10 @@ function list_themes($refresh = FALSE) { * registry is checked to determine which implementation to use, which may * be a function or a template. * - * If the implementation is a template, the arguments are converted to a - * $variables array. This array is then modified by the module implementing - * the hook, theme engine (if applicable) and the theme. The following - * functions may be used to modify the $variables array. They are processed in - * two distinct phases; "preprocess" and "process" functions. The order it is - * listed here is the order in which it will execute. + * If the implementation is a template, the following functions may be used to + * modify the $variables array. They are processed in two distinct phases; + * "preprocess" and "process" functions. The order listed here is the order in + * which they execute. * * - template_preprocess(&$variables) * This sets a default set of variables for all template implementations. @@ -705,21 +703,9 @@ function list_themes($refresh = FALSE) { * * If the implementation is a function, only the hook-specific preprocess * and process functions (the ones ending in _HOOK) are called from the - * above list. There are two reasons why the non-hook-specific preprocess - * and process functions (the ones not ending in _HOOK) are not called for - * function-implemented theme hooks: - * - * - Function-implemented theme hooks need to be fast, and calling the - * non-hook-specific preprocess and process functions on them would incur - * a noticeable performance penalty. - * - * - Function-implemented theme hooks can only make use of variables - * declared as arguments within the hook_theme() function that registers - * the theme hook, and cannot make use of additional generic variables. - * For the most part, non-hook-specific preprocess and process functions - * add/modify variables other than the theme hook's arguments, variables - * that are potentially useful in template files, but unavailable to - * function implementations. + * above list. This is because theme hooks with function implementations + * need to be fast, and calling the non-hook-specific preprocess and process + * functions for them would incur a noticeable performance penalty. * * For template-implemented theme hooks, there are two special variables that * these preprocess and process functions can set: @@ -746,21 +732,26 @@ function list_themes($refresh = FALSE) { * so that if the specific theme hook isn't implemented anywhere, a more * generic one will be used. This can allow themes to create specific theme * implementations for named objects. - * @param ... - * Additional arguments to pass along to the theme function. + * + * @param $variables + * An associative array of variables to merge with defaults from the theme + * registry, pass to preprocess and process functions for modification, and + * finally, pass to the function or template implementing the theme hook. + * Alternatively, this can be a renderable array, in which case, its properties + * are mapped to variables expected by the theme hook implementations. + * * @return * An HTML string that generates the themed output. */ -function theme() { - $args = func_get_args(); - $hook = array_shift($args); - +function theme($hook, $variables = array()) { static $hooks = NULL; if (!isset($hooks)) { drupal_theme_initialize(); $hooks = theme_get_registry(); } + // If an array of hook candidates were passed, use the first one that has an + // implementation. if (is_array($hook)) { foreach ($hook as $candidate) { if (isset($hooks[$candidate])) { @@ -786,99 +777,78 @@ function theme() { include_once DRUPAL_ROOT . '/' . $include_file; } } - if (isset($info['function'])) { - // The theme call is a function. - - // If a theme function that does not expect a renderable array is called - // with a renderable array as the only argument (via drupal_render), then - // we take the arguments from the properties of the renderable array. If - // missing, use hook_theme() defaults. - if (isset($args[0]) && is_array($args[0]) && isset($args[0]['#theme']) && count($info['arguments']) > 1) { - $new_args = array(); + + // If a renderable array is passed as $variables, then set $variables to + // what's expected by the theme hook. If the theme hook expects a single + // argument, set the renderable array as that argument. If the theme hook + // expects multiple arguments, set the properties of the renderable array as + // those arguments. + if (isset($variables['#theme']) || isset($variables['#theme_wrappers'])) { + $element = $variables; + $variables = array(); + $n = count($info['arguments']); + if ($n == 1) { + $arg_keys = array_keys($info['arguments']); + $variables[$arg_keys[0]] = $element; + } + elseif ($n > 1) { foreach ($info['arguments'] as $name => $default) { - $new_args[] = isset($args[0]["#$name"]) ? $args[0]["#$name"] : $default; + if (isset($element["#$name"])) { + $variables[$name] = $element["#$name"]; + } } - $args = $new_args; } + } - // Invoke the variable processors, if any. - // We minimize the overhead for theming hooks that have no processors and - // are called many times per page request by caching '_no_processors'. If - // we do have processors, then the overhead of calling them overshadows the - // overhead of calling empty(). - if (!isset($info['_no_processors'])) { - if (!empty($info['preprocess functions']) || !empty($info['process functions'])) { - $variables = array( - 'theme_functions' => array(), - ); - if (!empty($info['arguments'])) { - $count = 0; - foreach ($info['arguments'] as $name => $default) { - $variables[$name] = isset($args[$count]) ? $args[$count] : $default; - $count++; - } - } - // We don't want a poorly behaved process function changing $hook. - $hook_clone = $hook; - foreach (array('preprocess functions', 'process functions') as $phase) { - if (!empty($info[$phase])) { - foreach ($info[$phase] as $processor_function) { - if (function_exists($processor_function)) { - $processor_function($variables, $hook_clone); - } - } - } - } - if (!empty($info['arguments'])) { - $count = 0; - foreach ($info['arguments'] as $name => $default) { - $args[$count] = $variables[$name]; - $count++; - } - } + // Merge in argument defaults. + if (!empty($info['arguments'])) { + $variables += $info['arguments']; + } - // Get suggestions for alternate functions out of the variables that - // were set. This lets us dynamically choose a function from a list. - // The order is FILO, so this array is ordered from least appropriate - // functions to most appropriate last. - $suggestions = array(); - if (isset($variables['theme_functions'])) { - $suggestions = $variables['theme_functions']; - } - if (isset($variables['theme_function'])) { - $suggestions[] = $variables['theme_function']; - } - foreach (array_reverse($suggestions) as $suggestion) { - if (function_exists($suggestion)) { - $info['function'] = $suggestion; - break; + // Invoke the variable processors, if any. The processors may specify + // alternate suggestions for which function/template should be used. + if (isset($info['preprocess functions']) || isset($info['process functions'])) { + $variables['theme_functions'] = array(); + $variables['template_files'] = array(); + foreach (array('preprocess functions', 'process functions') as $phase) { + if (!empty($info[$phase])) { + foreach ($info[$phase] as $processor_function) { + if (function_exists($processor_function)) { + // We don't want a poorly behaved process function changing $hook. + $hook_clone = $hook; + $processor_function($variables, $hook_clone); } } } - else { - $hooks[$hook]['_no_processors'] = TRUE; + } + // Function suggestion takes priority over template suggestion. + // theme_function takes priority over theme_functions. + // theme_functions are in FILO order (least appropriate to most appropriate). + // Here, just look for function suggestions. Deal with template + // suggestions only after determining that the theme call is a template. + $suggestions = array(); + if (!empty($variables['theme_functions'])) { + $suggestions = $variables['theme_functions']; + } + if (!empty($variables['theme_function'])) { + $suggestions[] = $variables['theme_function']; + } + foreach (array_reverse($suggestions) as $suggestion) { + if (function_exists($suggestion)) { + $info['function'] = $suggestion; + break; } } + } - // Call the function. + // Generate the output using either a function or a template. + if (isset($info['function'])) { if (function_exists($info['function'])) { - $output = call_user_func_array($info['function'], $args); + $output = $info['function']($variables); } } else { - // The theme call is a template. - $variables = array( - 'template_files' => array() - ); - if (!empty($info['arguments'])) { - $count = 0; - foreach ($info['arguments'] as $name => $default) { - $variables[$name] = isset($args[$count]) ? $args[$count] : $default; - $count++; - } - } - - // default render function and extension. + // Default render function and extension. $render_function = 'theme_render_template'; $extension = '.tpl.php'; @@ -898,44 +868,32 @@ function theme() { } } - // This construct ensures that we can keep a reference through - // call_user_func_array. - $args = array(&$variables, $hook); - foreach (array('preprocess functions', 'process functions') as $phase) { - if (!empty($info[$phase])) { - foreach ($info[$phase] as $processor_function) { - if (function_exists($processor_function)) { - call_user_func_array($processor_function, $args); - } - } - } - } - - // Get suggestions for alternate templates out of the variables - // that were set. This lets us dynamically choose a template - // from a list. The order is FILO, so this array is ordered from - // least appropriate first to most appropriate last. + // Find which template file exists and can be used. Priority order is: + // 1. $variables['template_file']. + // 2. $variables['template_files'] in FILO order (later in array is higher + // priority). + // 3. $info['template']. $suggestions = array(); - if (isset($variables['template_files'])) { $suggestions = $variables['template_files']; } if (isset($variables['template_file'])) { $suggestions[] = $variables['template_file']; } - if ($suggestions) { $template_file = drupal_discover_template($info['theme paths'], $suggestions, $extension); } - if (empty($template_file)) { $template_file = $info['template'] . $extension; if (isset($info['path'])) { $template_file = $info['path'] . '/' . $template_file; } } + + // Render the output using the found template file. $output = $render_function($template_file, $variables); } + // restore path_to_theme() $theme_path = $temp; return $output; @@ -1288,11 +1246,12 @@ function theme_render_template($template_file, $variables) { * * Inside Drupal, the theme layer is utilized by the use of the theme() * function, which is passed the name of a component (the theme hook) - * and several arguments. For example, theme('table', $header, $rows); + * and an array of variables. For example, + * theme('table', array('header' => $header, 'rows' => $rows)); * Additionally, the theme() function can take an array of theme * hooks, which can be used to provide 'fallback' implementations to * allow for more specific control of output. For example, the function: - * theme(array('table__foo', 'table'), $header, $rows) would look to see if + * theme(array('table__foo', 'table'), $variables) would look to see if * 'table__foo' is registered anywhere; if it is not, it would 'fall back' * to the generic 'table' implementation. This can be used to attach specific * theme functions to named objects, allowing the themer more control over @@ -1344,30 +1303,37 @@ function theme_render_template($template_file, $variables) { * Formats text for emphasized display in a placeholder inside a sentence. * Used automatically by t(). * - * @param $text - * The text to format (plain-text). + * @param $variables + * An associative array containing: + * - text: The text to format (plain-text). + * * @return * The formatted text (html). */ -function theme_placeholder($text) { - return '<em>' . check_plain($text) . '</em>'; +function theme_placeholder($variables) { + return '<em>' . check_plain($variables['text']) . '</em>'; } /** * Return a themed set of status and/or error messages. The messages are grouped * by type. * - * An invisible heading identifies the messages for assistive technology. Sighted - * users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html for info. + * An invisible heading identifies the messages for assistive technology. + * Sighted users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html + * for info. * - * @param $display - * (optional) Set to 'status' or 'error' to display only messages of that type. + * @param $variables + * An associative array containing: + * - display: (optional) Set to 'status' or 'error' to display only messages + * of that type. * * @return * A string containing the messages. */ -function theme_status_messages($display = NULL) { +function theme_status_messages($variables) { + $display = $variables['display']; $output = ''; + $status_heading = array( 'status' => t('Status message'), 'error' => t('Error message'), @@ -1396,34 +1362,41 @@ function theme_status_messages($display = NULL) { /** * Return a themed set of links. * - * @param $links - * A keyed array of links to be themed. The key for each link is used as its css class. - * Each link should be itself an array, with the following keys: - * - title: the link text - * - href: the link URL. If omitted, the 'title' is shown as a plain text item in the links list. - * - html: (optional) set this to TRUE if 'title' is HTML so it will be escaped. - * Array items are passed on to the l() function's $options parameter when creating the link. - * @param $attributes - * A keyed array of attributes. - * @param $heading - * An optional keyed array or a string for a heading to precede the links. - * When using an array the following keys can be used: - * - text: the heading text - * - level: the heading level (e.g. 'h2', 'h3') - * - class: (optional) an array of the CSS classes for the heading - * When using a string it will be used as the text of the heading and the - * level will default to 'h2'. - * Headings should be used on navigation menus and any list of links that - * consistently appears on multiple pages. To make the heading invisible - * use the 'element-invisible' CSS class. Do not use 'display:none', which - * removes it from screen-readers and assistive technology. Headings allow - * screen-reader and keyboard only users to navigate to or skip the links. - * See http://juicystudio.com/article/screen-readers-display-none.php - * and http://www.w3.org/TR/WCAG-TECHS/H42.html for more information. + * @param $variables + * An associative array containing: + * - links: A keyed array of links to be themed. The key for each link is used + * as its css class. Each link should be itself an array, with the following + * keys: + * - title: the link text + * - href: the link URL. If omitted, the 'title' is shown as a plain text + * item in the links list. + * - html: (optional) set this to TRUE if 'title' is HTML so it will be + * escaped. + * Array items are passed on to the l() function's $options parameter when + * creating the link. + * - attributes: A keyed array of attributes. + * - heading: An optional keyed array or a string for a heading to precede the + * links. When using an array the following keys can be used: + * - text: the heading text + * - level: the heading level (e.g. 'h2', 'h3') + * - class: (optional) an array of the CSS classes for the heading + * When using a string it will be used as the text of the heading and the + * level will default to 'h2'. + * Headings should be used on navigation menus and any list of links that + * consistently appears on multiple pages. To make the heading invisible + * use the 'element-invisible' CSS class. Do not use 'display:none', which + * removes it from screen-readers and assistive technology. Headings allow + * screen-reader and keyboard only users to navigate to or skip the links. + * See http://juicystudio.com/article/screen-readers-display-none.php + * and http://www.w3.org/TR/WCAG-TECHS/H42.html for more information. + * * @return * A string containing an unordered list of links. */ -function theme_links($links, $attributes = array('class' => array('links')), $heading = array()) { +function theme_links($variables) { + $links = $variables['links']; + $attributes = $variables['attributes']; + $heading = $variables['heading']; global $language; $output = ''; @@ -1499,20 +1472,27 @@ function theme_links($links, $attributes = array('class' => array('links')), $he /** * Return a themed image. * - * @param $path - * Either the path of the image file (relative to base_path()) or a full URL. - * @param $alt - * The alternative text for text-based browsers. - * @param $title - * The title text is displayed when the image is hovered in some popular browsers. - * @param $attributes - * Associative array of attributes to be placed in the img tag. - * @param $getsize - * If set to TRUE, the image's dimension are fetched and added as width/height attributes. + * @param $variables + * An associative array containing: + * - path: Either the path of the image file (relative to base_path()) or a + * full URL. + * - alt: The alternative text for text-based browsers. + * - title: The title text is displayed when the image is hovered in some + * popular browsers. + * - attributes: Associative array of attributes to be placed in the img tag. + * - getsize: If set to TRUE, the image's dimension are fetched and added as + * width/height attributes. + * * @return * A string containing the image tag. */ -function theme_image($path, $alt = '', $title = '', $attributes = array(), $getsize = TRUE) { +function theme_image($variables) { + $path = $variables['path']; + $alt = $variables['alt']; + $title = $variables['title']; + $attributes = $variables['attributes']; + $getsize = $variables['getsize']; + if (!$getsize || (is_file($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) { $attributes = drupal_attributes($attributes); $url = file_create_url($path); @@ -1523,11 +1503,16 @@ function theme_image($path, $alt = '', $title = '', $attributes = array(), $gets /** * Return a themed breadcrumb trail. * - * @param $breadcrumb - * An array containing the breadcrumb links. - * @return a string containing the breadcrumb output. + * @param $variables + * An associative array containing: + * - breadcrumb: An array containing the breadcrumb links. + * + * @return + * A string containing the breadcrumb output. */ -function theme_breadcrumb($breadcrumb) { +function theme_breadcrumb($variables) { + $breadcrumb = $variables['breadcrumb']; + if (!empty($breadcrumb)) { // Provide a navigational heading to give context for breadcrumb links to // screen-reader users. Make the heading invisible with .element-invisible. @@ -1541,89 +1526,97 @@ function theme_breadcrumb($breadcrumb) { /** * Return a themed submenu, typically displayed under the tabs. * - * @param $links - * An array of links. + * @param $variables + * An associative array containing: + * - links: An array of links. */ -function theme_submenu($links) { +function theme_submenu($variables) { + $links = $variables['links']; + return '<div class="submenu">' . implode(' | ', $links) . '</div>'; } /** * Return a themed table. * - * @param $header - * An array containing the table headers. Each element of the array can be - * either a localized string or an associative array with the following keys: - * - "data": The localized title of the table column. - * - "field": The database field represented in the table column (required if - * user is to be able to sort on this column). - * - "sort": A default sort order for this column ("asc" or "desc"). - * - Any HTML attributes, such as "colspan", to apply to the column header cell. - * @param $rows - * An array of table rows. Every row is an array of cells, or an associative - * array with the following keys: - * - "data": an array of cells - * - Any HTML attributes, such as "class", to apply to the table row. - * - * Each cell can be either a string or an associative array with the following keys: - * - "data": The string to display in the table cell. - * - "header": Indicates this cell is a header. - * - Any HTML attributes, such as "colspan", to apply to the table cell. - * - * Here's an example for $rows: - * @verbatim - * $rows = array( - * // Simple row - * array( - * 'Cell 1', 'Cell 2', 'Cell 3' - * ), - * // Row with attributes on the row and some of its cells. - * array( - * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => array('funky') - * ) - * ); - * @endverbatim - * - * @param $attributes - * An array of HTML attributes to apply to the table tag. - * @param $caption - * A localized string to use for the <caption> tag. - * @param $colgroups - * An array of column groups. Each element of the array can be either: - * - An array of columns, each of which is an associative array of HTML attributes - * applied to the COL element. - * - An array of attributes applied to the COLGROUP element, which must include a - * "data" attribute. To add attributes to COL elements, set the "data" attribute - * with an array of columns, each of which is an associative array of HTML attributes. - * Here's an example for $colgroup: - * @verbatim - * $colgroup = array( - * // COLGROUP with one COL element. - * array( + * @param $variables + * An associative array containing: + * - header: An array containing the table headers. Each element of the array + * can be either a localized string or an associative array with the + * following keys: + * - "data": The localized title of the table column. + * - "field": The database field represented in the table column (required + * if user is to be able to sort on this column). + * - "sort": A default sort order for this column ("asc" or "desc"). + * - Any HTML attributes, such as "colspan", to apply to the column header + * cell. + * - rows: An array of table rows. Every row is an array of cells, or an + * associative array with the following keys: + * - "data": an array of cells + * - Any HTML attributes, such as "class", to apply to the table row. + * Each cell can be either a string or an associative array with the + * following keys: + * - "data": The string to display in the table cell. + * - "header": Indicates this cell is a header. + * - Any HTML attributes, such as "colspan", to apply to the table cell. + * Here's an example for $rows: + * @verbatim + * $rows = array( + * // Simple row * array( - * 'class' => array('funky'), // Attribute for the COL element. + * 'Cell 1', 'Cell 2', 'Cell 3' * ), - * ), - * // Colgroup with attributes and inner COL elements. - * array( - * 'data' => array( + * // Row with attributes on the row and some of its cells. + * array( + * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => array('funky') + * ) + * ); + * @endverbatim + * - attributes: An array of HTML attributes to apply to the table tag. + * - caption: A localized string to use for the <caption> tag. + * - colgroups: An array of column groups. Each element of the array can be + * either: + * - An array of columns, each of which is an associative array of HTML + * attributes applied to the COL element. + * - An array of attributes applied to the COLGROUP element, which must + * include a "data" attribute. To add attributes to COL elements, set the + * "data" attribute with an array of columns, each of which is an + * associative array of HTML attributes. + * Here's an example for $colgroup: + * @verbatim + * $colgroup = array( + * // COLGROUP with one COL element. + * array( * array( * 'class' => array('funky'), // Attribute for the COL element. * ), * ), - * 'class' => array('jazzy'), // Attribute for the COLGROUP element. - * ), - * ); - * @endverbatim - * These optional tags are used to group and set properties on columns - * within a table. For example, one may easily group three columns and - * apply same background style to all. - * @param $sticky - * Use a "sticky" table header. + * // Colgroup with attributes and inner COL elements. + * array( + * 'data' => array( + * array( + * 'class' => array('funky'), // Attribute for the COL element. + * ), + * ), + * 'class' => array('jazzy'), // Attribute for the COLGROUP element. + * ), + * ); + * @endverbatim + * These optional tags are used to group and set properties on columns + * within a table. For example, one may easily group three columns and + * apply same background style to all. + * - sticky: Use a "sticky" table header. + * * @return * An HTML string representing the table. */ -function theme_table($header, $rows, $attributes = array(), $caption = NULL, $colgroups = array(), $sticky = TRUE) { +function theme_table($variables) { + $header = $variables['header']; + $rows = $variables['rows']; + $attributes = $variables['attributes']; + $caption = $variables['caption']; + $colgroups = $variables['colgroups']; + $sticky = $variables['sticky']; // Add sticky headers, if applicable. if (count($header) && $sticky) { @@ -1747,17 +1740,19 @@ function theme_table_select_header_cell() { /** * Return a themed sort icon. * - * @param $style - * Set to either asc or desc. This sets which icon to show. + * @param $variables + * An associative array containing: + * - style: Set to either asc or desc. This sets which icon to show. + * * @return * A themed sort icon. */ -function theme_tablesort_indicator($style) { - if ($style == "asc") { - return theme('image', 'misc/arrow-asc.png', t('sort icon'), t('sort ascending')); +function theme_tablesort_indicator($variables) { + if ($variables['style'] == "asc") { + return theme('image', array('path' => 'misc/arrow-asc.png', 'alt' => t('sort icon'), 'title' => t('sort ascending'))); } else { - return theme('image', 'misc/arrow-desc.png', t('sort icon'), t('sort descending')); + return theme('image', array('path' => 'misc/arrow-desc.png', 'alt' => t('sort icon'), 'title' => t('sort descending'))); } } @@ -1765,13 +1760,16 @@ function theme_tablesort_indicator($style) { * Return a themed marker, useful for marking new or updated * content. * - * @param $type - * Number representing the marker type to display - * @see MARK_NEW, MARK_UPDATED, MARK_READ + * @param $variables + * An associative array containing: + * - type: Number representing the marker type to display. + * @see MARK_NEW, MARK_UPDATED, MARK_READ + * * @return * A string containing the marker. */ -function theme_mark($type = MARK_NEW) { +function theme_mark($variables) { + $type = $variables['type']; global $user; if ($user->uid) { if ($type == MARK_NEW) { @@ -1786,22 +1784,27 @@ function theme_mark($type = MARK_NEW) { /** * Return a themed list of items. * - * @param $items - * An array of items to be displayed in the list. If an item is a string, - * then it is used as is. If an item is an array, then the "data" element of - * the array is used as the contents of the list item. If an item is an array - * with a "children" element, those children are displayed in a nested list. - * All other elements are treated as attributes of the list item element. - * @param $title - * The title of the list. - * @param $type - * The type of list to return (e.g. "ul", "ol") - * @param $attributes - * The attributes applied to the list element. + * @param $variables + * An associative array containing: + * - items: An array of items to be displayed in the list. If an item is a + * string, then it is used as is. If an item is an array, then the "data" + * element of the array is used as the contents of the list item. If an item + * is an array with a "children" element, those children are displayed in a + * nested list. All other elements are treated as attributes of the list + * item element. + * - title: The title of the list. + * - type: The type of list to return (e.g. "ul", "ol"). + * - attributes: The attributes applied to the list element. + * * @return * A string containing the list output. */ -function theme_item_list($items = array(), $title = NULL, $type = 'ul', $attributes = array()) { +function theme_item_list($variables) { + $items = $variables['items']; + $title = $variables['title']; + $type = $variables['type']; + $attributes = $variables['attributes']; + $output = '<div class="item-list">'; if (isset($title)) { $output .= '<h3>' . $title . '</h3>'; @@ -1849,92 +1852,89 @@ function theme_item_list($items = array(), $title = NULL, $type = 'ul', $attribu /** * Returns code that emits the 'more help'-link. */ -function theme_more_help_link($url) { - return '<div class="more-help-link">' . t('<a href="@link">More help</a>', array('@link' => check_url($url))) . '</div>'; +function theme_more_help_link($variables) { + return '<div class="more-help-link">' . t('<a href="@link">More help</a>', array('@link' => check_url($variables['url']))) . '</div>'; } /** * Return code that emits an feed icon. * - * @param $url - * The url of the feed. - * @param $title - * A descriptive title of the feed. + * @param $variables + * An associative array containing: + * - url: The url of the feed. + * - title: A descriptive title of the feed. */ -function theme_feed_icon($url, $title) { - $text = t('Subscribe to @feed-title', array('@feed-title' => $title)); - if ($image = theme('image', 'misc/feed.png', $text)) { - return '<a href="' . check_url($url) . '" title="' . $text . '" class="feed-icon">' . $image . '</a>'; +function theme_feed_icon($variables) { + $text = t('Subscribe to @feed-title', array('@feed-title' => $variables['title'])); + if ($image = theme('image', array('path' => 'misc/feed.png', 'alt' => $text))) { + return '<a href="' . check_url($variables['url']) . '" title="' . $text . '" class="feed-icon">' . $image . '</a>'; } } /** * Returns code that emits the 'more' link used on blocks. * - * @param $url - * The url of the main page - * @param $title - * A descriptive verb for the link, like 'Read more' + * @param $variables + * An associative array containing: + * - url: The url of the main page + * - title: A descriptive verb for the link, like 'Read more' */ -function theme_more_link($url, $title) { - return '<div class="more-link">' . t('<a href="@link" title="@title">more</a>', array('@link' => check_url($url), '@title' => $title)) . '</div>'; +function theme_more_link($variables) { + return '<div class="more-link">' . t('<a href="@link" title="@title">more</a>', array('@link' => check_url($variables['url']), '@title' => $variables['title'])) . '</div>'; } /** * Preprocess variables for theme_username(). * - * Modules that make any changes to the $variables['object'] properties like - * 'name' or 'extra' must insure that the final string is safe to include - * directly in the ouput by using check_plain() or filter_xss(). + * Modules that make any changes to variables like 'name' or 'extra' must insure + * that the final string is safe to include directly in the ouput by using + * check_plain() or filter_xss(). * * @see theme_username(). */ function template_preprocess_username(&$variables) { - $account = $variables['object']; - // Create a new empty object to populate with standardized data. - $variables['object'] = new stdClass; - // Keep a reference to the original data. - $variables['object']->account = $account; - $variables['object']->extra = ''; + $account = $variables['account']; + + $variables['extra'] = ''; if (empty($account->uid)) { - $variables['object']->uid = 0; - if (theme_get_setting('toggle_comment_user_verification')) { - $variables['object']->extra = ' (' . t('not verified') . ')'; - } + $variables['uid'] = 0; + if (theme_get_setting('toggle_comment_user_verification')) { + $variables['extra'] = ' (' . t('not verified') . ')'; + } } else { - $variables['object']->uid = (int)$account->uid; + $variables['uid'] = (int)$account->uid; } if (empty($account->name)) { - $variables['object']->name = variable_get('anonymous', t('Anonymous')); + $variables['name'] = variable_get('anonymous', t('Anonymous')); } else { - $variables['object']->name = $account->name; + $variables['name'] = $account->name; } - $variables['object']->profile_access = user_access('access user profiles'); - $variables['object']->link_attributes = array(); + $variables['profile_access'] = user_access('access user profiles'); + $variables['link_attributes'] = array(); // Populate link path and attributes if appropriate. - if ($variables['object']->uid && $variables['object']->profile_access) { + if ($variables['uid'] && $variables['profile_access']) { // We are linking to a local user. - $variables['object']->link_attributes = array('title' => t('View user profile.')); - $variables['object']->link_path = 'user/' . $variables['object']->uid; + $variables['link_attributes'] = array('title' => t('View user profile.')); + $variables['link_path'] = 'user/' . $variables['uid']; } elseif (!empty($account->homepage)) { - $variables['object']->link_attributes = array('rel' => 'nofollow'); - $variables['object']->link_path = $account->homepage; - $variables['object']->homepage = $account->homepage; + $variables['link_attributes'] = array('rel' => 'nofollow'); + $variables['link_path'] = $account->homepage; + $variables['homepage'] = $account->homepage; } // We do not want the l() function to check_plain() a second time. - $variables['object']->link_options['html'] = TRUE; + $variables['link_options']['html'] = TRUE; // Set a default class. - $variables['object']->attributes = array('class' => array('username')); + $variables['attributes_array'] = array('class' => array('username')); // Shorten the name when it is too long or it will break many tables. - if (drupal_strlen($variables['object']->name) > 20) { - $variables['object']->name = drupal_substr($variables['object']->name, 0, 15) . '...'; + if (drupal_strlen($variables['name']) > 20) { + $variables['name'] = drupal_substr($variables['name'], 0, 15) . '...'; } // Make sure name is safe for use in the theme function. - $variables['object']->name = check_plain($variables['object']->name); + $variables['name'] = check_plain($variables['name']); } /** @@ -1946,38 +1946,45 @@ function template_process_username(&$variables) { // Finalize the link_options array for passing to the l() function. // This is done in the process phase so that attributes may be added by // modules or the theme during the preprocess phase. - if (isset($variables['object']->link_path)) { - $variables['object']->link_options['attributes'] = $variables['object']->link_attributes + $variables['object']->attributes; + if (isset($variables['link_path'])) { + $variables['link_options']['attributes'] = $variables['link_attributes'] + $variables['attributes_array']; } } /** * Format a username. * - * @param $object - * The user object to format, which has been processed to provide safe and - * standarized elements. The object keys 'name', and 'extra' are safe strings - * that can be used directly. + * @param $variables + * An associative array containing: + * - account: The user object to format. + * - name: The user's name, sanitized. + * - extra: Additional text to append to the user's name, sanitized. + * - link_path: The path or URL of the user's profile page, home page, or + * other desired page to link to for more information about the user. + * - link_options: An array of options to pass to the l() function's $options + * parameter if linking the user's name to the user's page. + * - attributes_array: An array of attributes to pass to the + * drupal_attributes() function if not linking to the user's page. * * @return - * A string containing an HTML link to the user's page if the passed object - * suggests that this is a site user. Otherwise, only the username is returned. + * A themed HTML string containing the user's name, potentially linked to the + * user's page. * * @see template_preprocess_username() * @see template_process_username() */ -function theme_username($object) { - if (isset($object->link_path)) { +function theme_username($variables) { + if (isset($variables['link_path'])) { // We have a link path, so we should generate a link using l(). // Additional classes may be added as array elements like - // $object->link_options['attributes']['class'][] = 'myclass'; - $output = l($object->name . $object->extra, $object->link_path, $object->link_options); + // $variables['link_options']['attributes']['class'][] = 'myclass'; + $output = l($variables['name'] . $variables['extra'], $variables['link_path'], $variables['link_options']); } else { // Modules may have added important attributes so they must be included // in the output. Additional classes may be added as array elements like - // $object->attributes['class'][] = 'myclass'; - $output = '<span' . drupal_attributes($object->attributes) . '>' . $object->name . $object->extra . '</span>'; + // $variables['attributes_array']['class'][] = 'myclass'; + $output = '<span' . drupal_attributes($variables['attributes_array']) . '>' . $variables['name'] . $variables['extra'] . '</span>'; } return $output; } @@ -1985,18 +1992,19 @@ function theme_username($object) { /** * Return a themed progress bar. * - * @param $percent - * The percentage of the progress. - * @param $message - * A string containing information to be displayed. + * @param $variables + * An associative array containing: + * - percent: The percentage of the progress. + * - message: A string containing information to be displayed. + * * @return * A themed HTML string representing the progress bar. */ -function theme_progress_bar($percent, $message) { +function theme_progress_bar($variables) { $output = '<div id="progress" class="progress">'; - $output .= '<div class="bar"><div class="filled" style="width: ' . $percent . '%"></div></div>'; - $output .= '<div class="percentage">' . $percent . '%</div>'; - $output .= '<div class="message">' . $message . '</div>'; + $output .= '<div class="bar"><div class="filled" style="width: ' . $variables['percent'] . '%"></div></div>'; + $output .= '<div class="percentage">' . $variables['percent'] . '%</div>'; + $output .= '<div class="message">' . $variables['message'] . '</div>'; $output .= '</div>'; return $output; @@ -2005,14 +2013,16 @@ function theme_progress_bar($percent, $message) { /** * Create a standard indentation div. Used for drag and drop tables. * - * @param $size - * Optional. The number of indentations to create. + * @param $variables + * An associative array containing: + * - size: Optional. The number of indentations to create. + * * @return * A string containing indentations. */ -function theme_indentation($size = 1) { +function theme_indentation($variables) { $output = ''; - for ($n = 0; $n < $size; $n++) { + for ($n = 0; $n < $variables['size']; $n++) { $output .= '<div class="indentation"> </div>'; } return $output; @@ -2217,7 +2227,7 @@ function template_preprocess_page(&$variables) { $variables['base_path'] = base_path(); $variables['front_page'] = url(); - $variables['breadcrumb'] = theme('breadcrumb', drupal_get_breadcrumb()); + $variables['breadcrumb'] = theme('breadcrumb', array('breadcrumb' => drupal_get_breadcrumb())); $variables['feed_icons'] = drupal_get_feeds(); $variables['language'] = $GLOBALS['language']; $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr'; diff --git a/includes/theme.maintenance.inc b/includes/theme.maintenance.inc index 1695acef3..e2ebc9342 100644 --- a/includes/theme.maintenance.inc +++ b/includes/theme.maintenance.inc @@ -85,7 +85,10 @@ function _theme_load_offline_registry($theme, $base_theme = NULL, $theme_engine * * @ingroup themeable */ -function theme_task_list($items, $active = NULL) { +function theme_task_list($variables) { + $items = $variables['items']; + $active = $variables['active']; + $done = isset($items[$active]) || $active == NULL; $output = '<h2 class="element-invisible">Installation tasks</h2>'; $output .= '<ol class="task-list">'; @@ -115,14 +118,13 @@ function theme_task_list($items, $active = NULL) { * * Note: this function is not themeable. * - * @param $content - * The page content to show. + * @param $variables + * An associative array containing: + * - content: The page content to show. */ -function theme_install_page($content) { +function theme_install_page($variables) { drupal_add_http_header('Content-Type', 'text/html; charset=utf-8'); - // Assign content. - $variables['content'] = $content; // Delay setting the message variable so it can be processed below. $variables['show_messages'] = FALSE; // Variable processors invoked manually since this function and theme_update_page() @@ -136,7 +138,7 @@ function theme_install_page($content) { if (isset($messages['error'])) { $title = count($messages['error']) > 1 ? st('The following errors must be resolved before you can continue the installation process') : st('The following error must be resolved before you can continue the installation process'); $variables['messages'] .= '<h3>' . $title . ':</h3>'; - $variables['messages'] .= theme('status_messages', 'error'); + $variables['messages'] .= theme('status_messages', array('display' => 'error')); $variables['content'] .= '<p>' . st('Please check the error messages and <a href="!url">try again</a>.', array('!url' => request_uri())) . '</p>'; } @@ -144,14 +146,14 @@ function theme_install_page($content) { if (isset($messages['warning'])) { $title = count($messages['warning']) > 1 ? st('The following installation warnings should be carefully reviewed') : st('The following installation warning should be carefully reviewed'); $variables['messages'] .= '<h4>' . $title . ':</h4>'; - $variables['messages'] .= theme('status_messages', 'warning'); + $variables['messages'] .= theme('status_messages', array('display' => 'warning')); } // Special handling of status messages if (isset($messages['status'])) { $title = count($messages['status']) > 1 ? st('The following installation warnings should be carefully reviewed, but in most cases may be safely ignored') : st('The following installation warning should be carefully reviewed, but in most cases may be safely ignored'); $variables['messages'] .= '<h4>' . $title . ':</h4>'; - $variables['messages'] .= theme('status_messages', 'status'); + $variables['messages'] .= theme('status_messages', array('display' => 'status')); } // This was called as a theme hook (not template), so we need to @@ -168,19 +170,16 @@ function theme_install_page($content) { * * Note: this function is not themeable. * - * @param $content - * The page content to show. - * @param $show_messages - * Whether to output status and error messages. - * FALSE can be useful to postpone the messages to a subsequent page. + * @param $variables + * An associative array containing: + * - content: The page content to show. + * - show_messages: Whether to output status and error messages. + * FALSE can be useful to postpone the messages to a subsequent page. */ -function theme_update_page($content, $show_messages = TRUE) { +function theme_update_page($variables) { // Set required headers. drupal_add_http_header('Content-Type', 'text/html; charset=utf-8'); - // Assign content and show message flag. - $variables['content'] = $content; - $variables['show_messages'] = $show_messages; // Variable processors invoked manually since this function and theme_install_page() // are exceptions in how it works within the theme system. template_preprocess($variables, 'update_page'); @@ -192,7 +191,7 @@ function theme_update_page($content, $show_messages = TRUE) { if (isset($messages['warning'])) { $title = count($messages['warning']) > 1 ? 'The following update warnings should be carefully reviewed before continuing' : 'The following update warning should be carefully reviewed before continuing'; $variables['messages'] .= '<h4>' . $title . ':</h4>'; - $variables['messages'] .= theme('status_messages', 'warning'); + $variables['messages'] .= theme('status_messages', array('display' => 'warning')); } // This was called as a theme hook (not template), so we need to |