diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index 9cf12d4..e140a70 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -731,16 +731,18 @@ function shortcut_toolbar() {
if (!empty($links) || !empty($configure_link)) {
$items['shortcuts'] = array(
'#type' => 'toolbar_item',
- '#text' => t('Shortcuts'),
- '#path' => 'admin/config/user-interface/shortcut',
- '#options' => array(
- 'html' => FALSE,
- 'attributes' => array(
- 'title' => t('Shortcuts'),
- 'class' => array('icon', 'icon-shortcut'),
+ '#tab' => array(
+ '#type' => 'link',
+ '#title' => t('Shortcuts'),
+ '#href' => 'admin/config/user-interface/shortcut',
+ '#options' => array(
+ 'attributes' => array(
+ 'title' => t('Shortcuts'),
+ 'class' => array('icon', 'icon-shortcut'),
+ ),
),
),
- 'tray' => array(
+ '#tray' => array(
'#heading' => t('User-defined shortcuts'),
'shortcuts' => $links,
'configure' => $configure_link,
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 457e2de..883f1da 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -57,7 +57,7 @@ function toolbar_theme($existing, $type, $theme, $path) {
$items['toolbar'] = array(
'render element' => 'element',
);
- $items['toolbar_tab'] = array(
+ $items['toolbar_item'] = array(
'render element' => 'element',
);
$items['toolbar_tab_wrapper'] = array(
@@ -114,20 +114,12 @@ function toolbar_element_info() {
// theme_toolbar_tab().
$elements['toolbar_item'] = array(
'#pre_render' => array('toolbar_pre_render_item'),
- // A light wrapper for the l() function.
- '#theme' => 'toolbar_tab',
+ '#theme' => 'toolbar_item',
'#theme_wrappers' => array('toolbar_tab_wrapper'),
- '#text' => NULL,
- '#path' => '',
- // Standardize element attributes on the #attributes property.
- '#attributes' => array(),
- // l() takes an #options parameter.
- '#options' => array(
- 'html' => FALSE,
- 'attributes' => array(),
- ),
- 'tray' => array(
- '#heading' => '',
+ '#tab' => array(
+ '#type' => 'link',
+ '#title' => NULL,
+ '#href' => '',
),
);
return $elements;
@@ -221,10 +213,14 @@ function ($object) {
function theme_toolbar(&$variables) {
if (!empty($variables['element']['#children'])) {
$element = $variables['element'];
+ $trays = '';
+ foreach (element_children($element) as $key) {
+ $trays .= drupal_render($element[$key]['#tray']);
+ }
return '
';
}
}
@@ -248,14 +244,14 @@ function toolbar_pre_render_item($element) {
// attributes will always be returned in the #attributes property. These
// properties will be included in the #options parameter passed to l() in
// theme_toolbar_tab().
- $element['#attributes'] = $element['#options']['attributes'];
+ $element['#attributes'] = $element['#tab']['#options']['attributes'];
// If tray content is present, markup the tray and its associated trigger.
- if (!empty($element['tray'])) {
+ if (!empty($element['#tray'])) {
// Trays are associated with their trigger by a unique ID.
$id = drupal_html_id('toolbar-tray');
- $element['#tray_id'] = $id;
+ $element['#tab']['#tray_id'] = $id;
// Provide attributes for a tray trigger.
$attributes = array(
@@ -266,8 +262,9 @@ function toolbar_pre_render_item($element) {
'aria-pressed' => 'false',
);
// Merge in module-provided attributes.
- $element['#attributes'] = array_merge($attributes, $element['#attributes']);
- $element['#attributes']['class'][] = 'trigger';
+ $element['#tab'] += array('#attributes' => array());
+ $element['#tab']['#attributes'] += $attributes;
+ $element['#tab']['#attributes']['class'][] = 'trigger';
// Provide attributes for the tray theme wrapper.
$attributes = array(
@@ -276,22 +273,22 @@ function toolbar_pre_render_item($element) {
'aria-owned-by' => 'toolbar-tab-' . $id,
);
// Merge in module-provided attributes.
- if (!isset($element['tray']['#wrapper_attributes'])) {
- $element['tray']['#wrapper_attributes'] = array();
+ if (!isset($element['#tray']['#wrapper_attributes'])) {
+ $element['#tray']['#wrapper_attributes'] = array();
}
- $element['tray']['#wrapper_attributes'] = array_merge($attributes, $element['tray']['#wrapper_attributes']);
- $element['tray']['#wrapper_attributes']['class'][] = 'tray';
- $element['tray']['#wrapper_attributes']['class'][] = 'overlay-displace-top';
+ $element['#tray']['#wrapper_attributes'] += $attributes;
+ $element['#tray']['#wrapper_attributes']['class'][] = 'tray';
+ $element['#tray']['#wrapper_attributes']['class'][] = 'overlay-displace-top';
- if (!isset($element['tray']['#theme_wrappers'])) {
- $element['tray']['#theme_wrappers'] = array();
+ if (!isset($element['#tray']['#theme_wrappers'])) {
+ $element['#tray']['#theme_wrappers'] = array();
}
// Add the standard theme_wrapper for trays.
- array_unshift($element['tray']['#theme_wrappers'], 'toolbar_tray_wrapper');
+ array_unshift($element['#tray']['#theme_wrappers'], 'toolbar_tray_wrapper');
// If a #heading is provided for the tray, provided a #theme_wrapper
// function to append it.
- if (!empty($element['tray']['#heading'])) {
- array_unshift($element['tray']['#theme_wrappers'], 'toolbar_tray_heading_wrapper');
+ if (!empty($element['#tray']['#heading'])) {
+ array_unshift($element['#tray']['#theme_wrappers'], 'toolbar_tray_heading_wrapper');
}
}
@@ -309,6 +306,24 @@ function template_preprocess_toolbar_tab_wrapper(&$variables) {
}
/**
+ * Returns HTML for a toolbar item.
+ *
+ * This theme function only renders the tab portion of the toolbar item. The
+ * tray portion will be rendered later.
+ *
+ * @param array $variables
+ * An associative array containing:
+ * - element: An associative array containing the properties and children of
+ * the tray. Property used: #tab.
+ *
+ * @see toolbar_pre_render_item().
+ * @see theme_toolbar().
+ */
+function theme_toolbar_item(&$variables) {
+ return drupal_render($variables['element']['#tab']);
+}
+
+/**
* Returns HTML for wrapping a toolbar tab.
*
* Toolbar tabs have a common styling and placement with the toolbar's bar area.
@@ -326,24 +341,6 @@ function theme_toolbar_tab_wrapper(&$variables) {
}
/**
- * Returns HTML for toolbar tab that opens and closes a tray.
- *
- * Use in combination with theme_toolbar_tray_wrapper to create an
- * association between a link tag in the administration bar and a tray.
- *
- * @param $variables
- * An associative array containing the keys 'text', 'path', and 'options'. See
- * the l() function for information about these variables.
- *
- * @see l()
- */
-function theme_toolbar_tab($variables) {
- $element = $variables['element'];
- $element['#options']['attributes'] = $element['#attributes'];
- return l($element['#text'], $element['#path'], $element['#options']) . drupal_render_children($element);
-}
-
-/**
* Returns HTML for wrapping a toolbar tray.
*
* Used in combination with theme_toolbar_tab() to create an
@@ -386,13 +383,15 @@ function toolbar_toolbar() {
// The 'Home' tab is a simple link, with no corresponding tray.
$items['home'] = array(
'#type' => 'toolbar_item',
- '#text' => t('Home'),
- '#path' => '',
- '#options' => array(
- 'html' => FALSE,
- 'attributes' => array(
- 'title' => t('Home page'),
- 'class' => array('icon', 'icon-home'),
+ '#tab' => array(
+ '#type' => 'link',
+ '#title' => t('Home'),
+ '#href' => '',
+ '#options' => array(
+ 'attributes' => array(
+ 'title' => t('Home page'),
+ 'class' => array('icon', 'icon-home'),
+ ),
),
),
'#weight' => -20,
@@ -426,16 +425,18 @@ function toolbar_toolbar() {
// a toolbar tray. The tray contains the full administrative menu of the site.
$items['administration'] = array(
'#type' => 'toolbar_item',
- '#text' => t('Menu'),
- '#path' => 'admin',
- '#options' => array(
- 'html' => FALSE,
- 'attributes' => array(
- 'title' => t('Admin menu'),
- 'class' => array('icon', 'icon-menu'),
+ '#tab' => array(
+ '#type' => 'link',
+ '#title' => t('Menu'),
+ '#href' => 'admin',
+ '#options' => array(
+ 'attributes' => array(
+ 'title' => t('Admin menu'),
+ 'class' => array('icon', 'icon-menu'),
+ ),
),
),
- 'tray' => $menu,
+ '#tray' => $menu,
'#weight' => -15,
);
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 240a277..61cb276 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -2951,22 +2951,24 @@ function user_toolbar() {
$items['user'] = array(
'#type' => 'toolbar_item',
- '#text' => user_format_name($user),
- '#path' => 'user',
- '#options' => array(
- 'html' => FALSE,
- 'attributes' => array(
- 'title' => t('My account'),
- 'class' => array('icon', 'icon-user'),
+ '#tab' => array(
+ '#type' => 'link',
+ '#title' => user_format_name($user),
+ '#href' => 'user',
+ '#options' => array(
+ 'attributes' => array(
+ 'title' => t('My account'),
+ 'class' => array('icon', 'icon-user'),
+ ),
),
),
- 'tray' => array(
+ '#tray' => array(
'#heading' => t('User account actions'),
'user_links' => array(
'#theme' => 'links__toolbar_user',
'#links' => $links,
'#attributes' => array(
- 'class' => array('menu',),
+ 'class' => array('menu'),
),
),
),