You are here

function language_hierarchy_attach_language_selector in Language Hierarchy 7

Attach libraries to replace local tasks links with hierarchical links.

4 calls to language_hierarchy_attach_language_selector()
entity_translation_hierarchy_form_alter in modules/entity_translation_hierarchy/entity_translation_hierarchy.module
Implements hook_form_alter().
i18n_menu_hierarchy_form_menu_edit_item_alter in modules/i18n_menu_hierarchy/i18n_menu_hierarchy.module
Implements hook_form_FORM_ID_alter().
i18n_menu_hierarchy_form_menu_overview_form_alter in modules/i18n_menu_hierarchy/i18n_menu_hierarchy.module
Implements hook_form_FORM_ID_alter().
node_translation_hierarchy_menu_local_tasks_alter in modules/node_translation_hierarchy/node_translation_hierarchy.module
Implements hook_menu_local_tasks_alter().

File

./language_hierarchy.module, line 541

Code

function language_hierarchy_attach_language_selector(&$element) {
  $languages = language_hierarchy_get_root_languages();
  foreach ($languages as $langcode => $language) {
    $languages[$langcode] = language_hierarchy_get_descendants($langcode, $language);
  }

  // Expose language hierarchy as JS variable, so JS code can pick it up.
  $element['#attached']['js'][] = array(
    'type' => 'setting',
    'data' => array(
      'languageHierarchy' => language_hierarchy_language_list(),
    ),
  );
  $path = drupal_get_path('module', 'language_hierarchy');
  $element['#attached']['js'][] = $path . '/language_hierarchy.js';
  $element['#attached']['css'][] = $path . '/language_hierarchy.css';
}