You are here

function adminimal_admin_menu_page_build in Adminimal Administration Menu 7.2

Same name and namespace in other branches
  1. 7 adminimal_admin_menu.module \adminimal_admin_menu_page_build()

Implements hook_page_build().

File

./adminimal_admin_menu.module, line 46
Themes Administration menu like Adminimal theme.

Code

function adminimal_admin_menu_page_build(&$page) {
  global $theme;
  if (!_adminimal_admin_menu_access()) {
    return;
  }
  $path = drupal_get_path('module', 'adminimal_admin_menu');
  $load_slicknav = variable_get('adminimal_admin_menu_slicknav', TRUE);
  $load_jquery = variable_get('adminimal_admin_menu_jquery', TRUE);

  // Load Open Sans font if needed.
  $themes = list_themes(FALSE);
  $adminimal_active = isset($themes['adminimal']) && $themes['adminimal']->status;
  if ($adminimal_active && $theme !== 'adminimal' && !theme_get_setting('avoid_custom_font', 'adminimal')) {
    drupal_add_css('//fonts.googleapis.com/css?family=Open+Sans:400', array(
      'group' => CSS_THEME,
    ));
  }

  // Attach the CSS and JavaScript assets.
  drupal_add_css($path . '/css/adminimal_admin_menu.menu.css');
  _adminimal_admin_menu_support_environment_indicator();

  // Check if both slicknav and custom jQuery must be loaded.
  if ($load_slicknav and $load_jquery) {
    drupal_add_js($path . '/js/jquery.min.js', array(
      'type' => 'file',
      'scope' => 'header',
      'weight' => 888,
    ));
    drupal_add_js($path . '/js/slicknav/jquery-no-conflict.slicknav.js', array(
      'type' => 'file',
      'scope' => 'header',
      'weight' => 888,
    ));
    drupal_add_css($path . '/js/slicknav/slicknav.css');
  }
  elseif ($load_slicknav and !$load_jquery) {
    drupal_add_js($path . '/js/slicknav/jquery.slicknav.js', array(
      'type' => 'file',
      'scope' => 'header',
      'weight' => 888,
    ));
    drupal_add_css($path . '/js/slicknav/slicknav.css');
  }
  drupal_add_js($path . '/js/adminimal_admin_menu.js', array(
    'type' => 'file',
    'scope' => 'header',
    'weight' => 888,
  ));
  if (!isset($page['page_bottom']['admin_menu'])) {
    return;
  }
  $attached =& $page['page_bottom']['admin_menu']['#attached'];
  $options = array(
    'every_page' => TRUE,
  );

  // @todo Stop-gap fix until cached rendering is resolved (http://drupal.org/node/1567622).
  if (module_exists('shortcut')) {
    $attached['css'][drupal_get_path('module', 'shortcut') . '/shortcut.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',
  );
}