Same name and namespace in other branches
  1. 10 core/modules/toolbar/toolbar.module \toolbar_menu_navigation_links()
  2. 8.9.x core/modules/toolbar/toolbar.module \toolbar_menu_navigation_links()
  3. 9 core/modules/toolbar/toolbar.module \toolbar_menu_navigation_links()

Generates a links array from a menu tree array.

Based on menu_navigation_links(). Adds path based IDs and icon placeholders to the links.

Return value

An array of links as defined above.

1 call to toolbar_menu_navigation_links()
toolbar_view in modules/toolbar/toolbar.module
Builds the admin menu as a structured array ready for drupal_render().

File

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

Code

function toolbar_menu_navigation_links($tree) {
  $links = array();
  foreach ($tree as $item) {
    if (!$item['link']['hidden'] && $item['link']['access']) {

      // Make sure we have a path specific ID in place, so we can attach icons
      // and behaviors to the items.
      $id = str_replace(array(
        '/',
        '<',
        '>',
      ), array(
        '-',
        '',
        '',
      ), $item['link']['href']);
      $link = $item['link']['localized_options'];
      $link['href'] = $item['link']['href'];

      // Add icon placeholder.
      $link['title'] = '<span class="icon"></span>' . check_plain($item['link']['title']);

      // Add admin link ID.
      $link['attributes'] = array(
        'id' => 'toolbar-link-' . $id,
      );
      if (!empty($item['link']['description'])) {
        $link['title'] .= ' <span class="element-invisible">(' . $item['link']['description'] . ')</span>';
        $link['attributes']['title'] = $item['link']['description'];
      }
      $link['html'] = TRUE;
      $class = ' path-' . $id;
      if (toolbar_in_active_trail($item['link']['href'])) {
        $class .= ' active-trail';
      }
      $links['menu-' . $item['link']['mlid'] . $class] = $link;
    }
  }
  return $links;
}