You are here

function lingotek_navbar in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.4 lingotek.module \lingotek_navbar()

Implements hook_navbar().

File

./lingotek.module, line 1370

Code

function lingotek_navbar() {

  //this integration with the navbar module has depencies on javascript files

  //that Responsive Theme Preview adds. Thus the integration will only show up if

  //the Responsive Theme Preview module is enabled.
  if (!module_exists('responsive_preview')) {
    return;
  }
  $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
  $links = language_negotiation_get_switch_links('language', $path);
  $buttons = array();
  if (empty($links->links)) {
    return;
  }
  foreach ($links->links as $key => $link) {
    $link['attributes']['class'] = array(
      'device',
      'icon',
      'icon-active',
    );
    $link['language'] = (object) array(
      'language' => $key,
    );
    $buttons[] = l($link['title'], $link['href'], $link);
  }
  $items['lingotek'] = array(
    '#type' => 'navbar_item',
    'tab' => array(
      'trigger' => array(
        '#theme' => 'html_tag',
        '#tag' => 'button',
        '#value' => t('Layout preview'),
        '#value_prefix' => '<span class="element-invisible">',
        '#value_suffix' => '</span>',
        '#attributes' => array(
          'title' => t('Preview page layout'),
          'class' => array(
            'icon',
            'icon-lingotek',
            'trigger',
          ),
        ),
      ),
      'device_options' => array(
        '#theme' => 'item_list',
        '#items' => $buttons,
        '#attributes' => array(
          'class' => array(
            'options',
          ),
        ),
      ),
    ),
    '#wrapper_attributes' => array(
      'id' => 'lingotek-navbar-tab',
      'class' => array(
        'navbar-tab-lingotek',
      ),
    ),
    '#attached' => array(
      'library' => array(
        array(
          'lingotek',
          'lingotek-navbar-switcher',
        ),
      ),
    ),
    '#weight' => 300,
  );
  return $items;
}