You are here

function webmaster_menu_output in Webmaster menu 7

Create the webmaster menu.

If it turns out not to include any items besides Home and Logout, an empty string is returned.

1 call to webmaster_menu_output()
webmaster_menu_page_alter in ./webmaster_menu.module
Implements hook_page_alter().

File

./webmaster_menu.module, line 152
Display a dropdown menu at the top of the window.

Code

function webmaster_menu_output() {
  $menu_name = variable_get('webmaster_menu_menu', '');
  $tree = webmaster_menu_get_tree($menu_name);
  $extra_menu_name = variable_get('webmaster_menu_extra_menu', '_no_extra_menu_');
  if ($extra_menu_name != '_no_extra_menu_') {
    $extra_tree = webmaster_menu_get_tree($extra_menu_name);
    foreach ($extra_tree as $subtree) {
      array_push($tree, $subtree);
    }
  }
  if (count($tree) == 0) {

    // Don't show any menu if there are no links (besides Home and Logout).
    // (this behaviour was decided here: http://drupal.org/node/1464194)
    return '';
  }
  if (variable_get('webmaster_menu_add_home', TRUE)) {
    $home = webmaster_menu_create_menu_item(t('Home'), '<front>', array(
      'home',
    ));
    $home_menu_name = variable_get('webmaster_menu_home_menu', '_no_menu_');
    if ($home_menu_name != '_no_menu_') {
      $home['children'] = webmaster_menu_get_tree($home_menu_name);
    }
    array_unshift($tree, $home);
  }
  if (variable_get('webmaster_menu_add_logout', TRUE) && user_is_logged_in()) {
    $logout = webmaster_menu_create_menu_item(t('Log out'), 'user/logout', array(
      'logout',
    ));

    // allow other modules to alter the logout link
    drupal_alter('webmaster_menu_logout', $logout);
    array_push($tree, $logout);
  }
  return theme('webmaster_menu_toolbar', array(
    'tree' => $tree,
  ));
}