You are here

function google_appliance_menu_alter in Google Search Appliance 6.2

Implementation of hook_menu_alter().

File

./google_appliance.module, line 192
Google Search Appliance (GSA) / Google Mini integration

Code

function google_appliance_menu_alter(&$items) {
  $settings = google_appliance_get_settings();
  $google_appliance_path = $settings['google_appliance_path'];

  // We have provided a replacement for the search.module's
  // default local task.
  if (array_key_exists('search/google_appliance/%menu_tail', $items)) {
    unset($items['search/google_appliance/%menu_tail']);
  }

  // Set the base 'google_appliance_path' for search paths.
  if ($google_appliance_path != 'google-appliance') {
    $fields = array(
      'parent',
      'tab_parent',
    );
    foreach ($items as $path => $item) {
      if (strpos($path, 'google-appliance') === 0) {
        unset($items[$path]);
        $change = array();
        $change[] =& $path;

        // modify the path...
        foreach ($fields as $field) {

          // and each of these $fields.
          if (isset($item[$field])) {
            $change[] =& $item[$field];
          }
        }
        foreach (array_keys($change) as $key) {
          $change[$key] = preg_replace('/^google-appliance/', $google_appliance_path, $change[$key]);
        }
        $items[$path] = $item;
      }
    }
  }
}