You are here

function admin_menu_toolbar_page_build in Administration menu 7.3

Same name and namespace in other branches
  1. 8.3 admin_menu_toolbar/admin_menu_toolbar.module \admin_menu_toolbar_page_build()

Implementation of hook_page_build().

File

admin_menu_toolbar/admin_menu_toolbar.module, line 24
Renders Administration menu like Toolbar (core) module.

Code

function admin_menu_toolbar_page_build(&$page) {
  if (!isset($page['page_bottom']['admin_menu'])) {
    return;
  }
  $path = drupal_get_path('module', 'admin_menu_toolbar');
  $attached =& $page['page_bottom']['admin_menu']['#attached'];
  $options = array(
    'every_page' => TRUE,
  );
  $attached['css'][$path . '/admin_menu_toolbar.css'] = $options;
  $attached['js'][$path . '/admin_menu_toolbar.js'] = $options;

  // @todo Stop-gap fix until cached rendering is resolved.
  // @see http://drupal.org/node/1567622
  if (module_exists('shortcut')) {
    $attached['css'][drupal_get_path('module', 'shortcut') . '/shortcut.css'] = $options;
  }
  if (variable_get('admin_menu_theme', 'default') !== 'default') {
    $attached['css'][$path . '/admin_menu_toolbar-light.css'] = $options;
  }
  $settings = array();

  // Add current path to support menu item highlighting.
  // @todo Compile real active trail here?
  $args = explode('/', $_GET['q']);
  if ($args[0] == 'admin' && !empty($args[1])) {
    $settings['activeTrail'] = url($args[0] . '/' . $args[1]);
  }
  elseif (drupal_is_front_page()) {
    $settings['activeTrail'] = url('<front>');
  }
  $attached['js'][] = array(
    'data' => array(
      'admin_menu' => array(
        'toolbar' => $settings,
      ),
    ),
    'type' => 'setting',
  );
}