function design_test_menu_local_tasks_alter

Implements hook_menu_local_tasks_alter().

File

drupal/core/modules/system/tests/modules/design_test/design_test.module, line 97
Support module for design, markup, JavaScript, and CSS testing.

Code

function design_test_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  if ($router_item['number_parts'] > 2 && strpos($root_path, 'design_test/') === 0) {
    $actions =& $data['actions']['output'];

    // Determine the currently selected theme, if any.
    $selected_theme = drupal_container()
      ->get('request')->query
      ->get('theme');
    $default_theme = variable_get('theme_default', 'stark');

    // Expand all enabled themes into action links.
    $themes = list_themes();
    foreach ($themes as $name => $theme) {
      $action = array(
        '#theme' => 'menu_local_action',
        '#link' => array(
          'title' => $theme->info['name'],
          'href' => $router_item['href'],
          'localized_options' => array(
            'html' => FALSE,
          ),
        ),
        '#active' => $selected_theme == $name,
      );

      // Only add the theme-switcher query parameter for all non-default themes.
      if ($name != $default_theme) {
        $action['#link']['localized_options']['query']['theme'] = $name;
      }
      $actions[] = $action;
    }
    if ($themes > 1) {
      $data['actions']['count']++;
    }
  }
}