You are here

function acquia_lift_navbar in Acquia Lift Connector 7.2

Same name and namespace in other branches
  1. 7 acquia_lift.module \acquia_lift_navbar()

Implements hook_navbar().

1 call to acquia_lift_navbar()
acquia_lift_navbar_ui_pre_render in ./acquia_lift.ui.inc
Builds the unified navbar as a structured array ready for drupal_render().
1 string reference to 'acquia_lift_navbar'
_acquia_lift_navigation_attach_assets in ./acquia_lift.module
Create and attach the assets for Acquia Lift navigation to an element on the page.

File

./acquia_lift.module, line 2456
acquia_lift.module Provides Acquia Lift-specific personalization functionality.

Code

function acquia_lift_navbar() {
  $items = array();
  $menu = menu_tree_all_data('acquia-lift-controls');
  $usingUnifiedNavbar = _acquia_lift_using_unified_navbar();
  if (personalize_debug_mode_enabled()) {
    $debugger_running = acquia_lift_debug_mode_enabled();
    $debugger_link = current_path();
    $link_title = $debugger_running ? t('End Acquia Lift Inspector session') : t('Start Acquia Lift Inspector');

    // Add in a link to enable/disable the debugger.
    $menu[] = array(
      'link' => array(
        'mlid' => 'acquia_lift_debugger_id',
        'link_title' => $link_title,
        'title' => $link_title,
        'menu_name' => 'acquia-lift-controls',
        'link_path' => $debugger_link,
        'href' => $debugger_link,
        'has_children' => '0',
        'expanded' => '1',
        'depth' => '1',
        'weight' => '50',
        'hidden' => '0',
        'access' => '1',
        'in_active_trail' => FALSE,
        'localized_options' => array(
          'attributes' => array(
            'class' => array(
              'visitor-actions-ui-ignore',
              'acquia-lift-menu-link',
              'acquia-lift-debugger',
              'acquia-lift-navbar-secondary',
            ),
            'data-acquia-lift-debugger-running' => $debugger_running ? 'true' : 'false',
          ),
        ),
      ),
      'below' => array(),
    );
  }
  if (!empty($menu)) {
    $items['acquia_lift'] = array(
      '#access' => user_access('manage personalized content'),
      '#type' => $usingUnifiedNavbar ? 'acquia_lift_navbar_item' : 'navbar_item',
      'tray' => array(
        '#heading' => t('Personalization controls'),
        'navbar_personalization' => array(
          '#type' => 'container',
          '#attributes' => array(
            'class' => array(
              'navbar-menu-acquia-lift-controls',
              'acquia-lift-controls',
            ),
          ),
          'personalization' => menu_tree_output($menu),
        ),
        '#wrapper_attributes' => array(
          'class' => array(
            'navbar-tray-acquia-lift',
          ),
        ),
      ),
      '#weight' => 20,
    );
    if (!$usingUnifiedNavbar) {

      // Add the tab trigger for the tray.
      $items['acquia_lift']['tab'] = array(
        '#type' => 'link',
        '#title' => t('Acquia Lift'),
        '#href' => 'admin/structure/personalize',
        '#options' => array(
          'attributes' => array(
            'title' => t('Personalization settings'),
            // @todo, the .navbar-tab class is provided here because Demo
            // Framework is on an older version of Navbar (dd542e1). Once
            // DF is updated to the latest Navbar release, the .navbar-tab
            // class can be removed here. The class should be added in
            // template_preprocess_navbar_tab_wrapper, which only add a class
            // .tab in older versions.
            'class' => array(
              'navbar-icon',
              'navbar-icon-acquia-lift',
              'navbar-tab',
            ),
          ),
        ),
      );

      // Add the library for the navbar integration.
      $items['acquia_lift']['#attached'] = array(
        'library' => array(
          array(
            'acquia_lift',
            'acquia_lift.navbar',
          ),
        ),
      );
    }
  }
  return $items;
}