function toolbar_toolbar

Implements hook_toolbar().

File

drupal/core/modules/toolbar/toolbar.module, line 209
Administration toolbar for quick access to top level administration items.

Code

function toolbar_toolbar() {
  $items = array();

  // The 'Home' tab is a simple link, with no corresponding tray.
  $items['home'] = array(
    'tab' => array(
      'title' => t('Home'),
      'href' => '<front>',
      'html' => FALSE,
      'attributes' => array(
        'title' => t('Home page'),
        'class' => array(
          'icon',
          'icon-home',
        ),
      ),
    ),
    'weight' => -20,
  );

  // Retrieve the administration menu from the database.
  $tree = toolbar_get_menu_tree();

  // Add attributes to the links before rendering.
  toolbar_menu_navigation_links($tree);
  $menu = array(
    'toolbar_administration' => array(
      '#type' => 'container',
      '#attributes' => array(
        'class' => array(
          'toolbar-menu',
        ),
      ),
      'administration_menu' => menu_tree_output($tree),
    ),
    '#heading' => t('Administration menu'),
  );

  // To conserve bandwidth, we only include the top-level links in the HTML.
  // The subtrees are included in a JSONP script, cached by the browser. Here we
  // add that JSONP script. We add it as an external script, because it's a
  // Drupal path, not a file available via a stream wrapper.
  // @see toolbar_subtrees_jsonp()
  $menu['toolbar_administration']['#attached']['js'][url('toolbar/subtrees/' . _toolbar_get_subtree_hash())] = array(
    'type' => 'external',
  );
  $items['administration'] = array(
    'tab' => array(
      'title' => t('Menu'),
      'href' => 'admin',
      'html' => FALSE,
      'attributes' => array(
        'title' => t('Admin menu'),
        'class' => array(
          'icon',
          'icon-menu',
        ),
      ),
    ),
    'tray' => $menu,
    'weight' => -15,
  );
  return $items;
}