diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-31 19:50:18 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-31 19:50:18 +0000 |
commit | ce52f41a29a0803aff54c37bc3d48aef4d6e7c50 (patch) | |
tree | c391baf4b313f5165de7fc94f92be7c905278adc | |
parent | 35225694a871eec6de3379b71d3ec113b133827e (diff) | |
download | brdo-ce52f41a29a0803aff54c37bc3d48aef4d6e7c50.tar.gz brdo-ce52f41a29a0803aff54c37bc3d48aef4d6e7c50.tar.bz2 |
#364219 follow-up by TheRec: One last API nicety to theme_links() for the accessibility header stuff.
-rw-r--r-- | includes/theme.inc | 22 | ||||
-rw-r--r-- | modules/system/page.tpl.php | 4 |
2 files changed, 19 insertions, 7 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index c549544ac..9f0a74db8 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1386,13 +1386,16 @@ function theme_status_messages($display = NULL) { * @param $attributes * A keyed array of attributes. * @param $heading - * An optional keyed array for a heading to precede the links: + * 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 class => 'element-invisible'. Do not use 'display:none', which + * 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 @@ -1409,10 +1412,19 @@ function theme_links($links, $attributes = array('class' => array('links')), $he // Treat the heading first if it is present to prepend it to the // list of links. - if (!empty($heading['text']) && !empty($heading['level'])) { + if (!empty($heading)) { + if (is_string($heading)) { + // Prepare the array that will be used when the passed heading + // is a string. + $heading = array( + 'text' => $heading, + // Set the default level of the heading. + 'level' => 'h2', + ); + } $output .= '<' . $heading['level']; if (!empty($heading['class'])) { - $output .= ' ' . drupal_attributes(array('class' => $heading['class'])); + $output .= drupal_attributes(array('class' => $heading['class'])); } $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>'; } @@ -2279,4 +2291,4 @@ function template_preprocess_maintenance_page(&$variables) { if (isset($variables['db_is_active']) && !$variables['db_is_active']) { $variables['template_file'] = 'maintenance-page-offline'; } -}
\ No newline at end of file +} diff --git a/modules/system/page.tpl.php b/modules/system/page.tpl.php index 5f0a96fdb..a6092204e 100644 --- a/modules/system/page.tpl.php +++ b/modules/system/page.tpl.php @@ -156,7 +156,7 @@ <?php if ($main_menu): ?> <div id="navigation"><div class="section"> - <?php print theme('links', $main_menu, array('id' => 'main-menu', 'class' => array('links', 'clearfix')), array('text' => t('Main menu'), 'level' => 'h2')); ?> + <?php print theme('links', $main_menu, array('id' => 'main-menu', 'class' => array('links', 'clearfix')), t('Main menu')); ?> </div></div> <!-- /.section, /#navigation --> <?php endif; ?> @@ -195,7 +195,7 @@ </div></div> <!-- /#main, /#main-wrapper --> <div id="footer"><div class="section"> - <?php print theme('links', $secondary_menu, array('id' => 'secondary-menu', 'class' => array('links', 'clearfix')), array('text' => t('Secondary menu'), 'level' => 'h2')); ?> + <?php print theme('links', $secondary_menu, array('id' => 'secondary-menu', 'class' => array('links', 'clearfix')), t('Secondary menu')); ?> <?php if ($footer): ?><div id="footer-region" class="region"><?php print $footer; ?></div><?php endif; ?> </div></div> <!-- /.section, /#footer --> |