function toolbar_toolbar

Implements hook_toolbar().

File

drupal/core/modules/toolbar/toolbar.module, line 404
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(
    '#type' => 'toolbar_item',
    'tab' => array(
      '#type' => 'link',
      '#title' => t('Home'),
      '#href' => '<front>',
      '#options' => array(
        '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(
    '#heading' => t('Administration menu'),
    'toolbar_administration' => array(
      '#type' => 'container',
      '#attributes' => array(
        'class' => array(
          'toolbar-menu-administration',
        ),
      ),
      'administration_menu' => menu_tree_output($tree),
    ),
  );

  // 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',
  );

  // The administration element has a link that is themed to correspond to
  // a toolbar tray. The tray contains the full administrative menu of the site.
  $items['administration'] = array(
    '#type' => 'toolbar_item',
    'tab' => array(
      '#type' => 'link',
      '#title' => t('Menu'),
      '#href' => 'admin',
      '#options' => array(
        'attributes' => array(
          'title' => t('Admin menu'),
          'class' => array(
            'icon',
            'icon-menu',
          ),
        ),
      ),
    ),
    'tray' => $menu,
    '#weight' => -15,
  );
  return $items;
}