1 admin_bar.module admin_bar_admin_bar_replacements($complete)

Implements hook_admin_bar_replacements().

See also

admin_bar_links_page()

File

core/modules/admin_bar/admin_bar.module, line 413
Render an administrative bar as a dropdown menu at the top of the window.

Code

function admin_bar_admin_bar_replacements($complete) {
  $items = array();

  // If the complete menu is output, then it is uncached and will contain the
  // current counts already.
  if (!$complete) {
    // Check whether the users count component is enabled.
    $components = config_get('admin_bar.settings', 'components');
    if (in_array('admin_bar.users', $components) && ($user_count = admin_bar_get_user_count())) {
      // Replace the counters in the cached menu output with current counts.
      $items['.admin-bar-users a'] = $user_count;
    }
    // Check whether the page links component is enabled.
    if (in_array('admin_bar.page', $components)) {
      $query = array('query' => array(
        'destination' => current_path(),
      ));

      if (user_access('administer layouts')) {
        $layout = layout_get_layout_by_path();
        $items['#admin-bar-page-layout'] = l(t('Layout (@layout)', array('@layout' => $layout->title)), 'admin/structure/layouts/manage/' . $layout->name, $query);
        $items['#admin-bar-page-layout'] .= theme('admin_bar_links', array('elements' => array(
          array(
            '#title' => t('Configure'),
            '#href' => 'admin/structure/layouts/manage/' . $layout->name . '/configure',
            '#options' => $query,
          ),
        )));
      }
      if (user_access('administer themes')) {
        global $theme;
        $theme_data = list_themes();
        $theme_object = $theme_data[$theme];
        $items['#admin-bar-page-theme'] = l(t('Theme (@theme)', array('@theme' => $theme_object->info['name'])), 'admin/appearance/settings/' . $theme_object->name, $query);
      }
    }
    // Check whether the page links component is enabled.
    if (in_array('admin_bar.locale', $components)) {
      if (module_exists('locale') && language_multilingual()) {
        if ($locale_links = admin_bar_locale_links()) {
          // Theme the locale links but remove the <ul> element
          // so we can swap out the list items for the current <ul> element.
          $theme_locale_links = theme('admin_bar_links', array(
            'elements' => $locale_links,
          ));
          $items['.admin-bar-locale-links>ul.dropdown'] = strip_tags($theme_locale_links, '<li><a><span>');
        }
      }
    }
  }

  return $items;
}