You are here

function search_menu in Drupal 4

Same name and namespace in other branches
  1. 5 modules/search/search.module \search_menu()
  2. 6 modules/search/search.module \search_menu()
  3. 7 modules/search/search.module \search_menu()

Implementation of hook_menu().

File

modules/search.module, line 149
Enables site-wide keyword searching.

Code

function search_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'search',
      'title' => t('search'),
      'callback' => 'search_view',
      'access' => user_access('search content'),
      'type' => MENU_SUGGESTED_ITEM,
    );
    $items[] = array(
      'path' => 'admin/settings/search/wipe',
      'title' => t('Clear index'),
      'callback' => 'search_wipe_confirm',
      'access' => user_access('administer search'),
      'type' => MENU_CALLBACK,
    );
  }
  else {
    if (arg(0) == 'search') {

      // To remember the user's search keywords when switching across tabs,
      // we dynamically add the keywords to the search tabs' paths.
      $keys = search_get_keys();
      $keys = strlen($keys) ? '/' . $keys : '';
      foreach (module_list() as $name) {
        if (module_hook($name, 'search') && ($title = module_invoke($name, 'search', 'name'))) {
          $items[] = array(
            'path' => 'search/' . $name . $keys,
            'title' => $title,
            'callback' => 'search_view',
            'access' => user_access('search content'),
            'type' => MENU_LOCAL_TASK,
          );
        }
      }
    }
  }
  return $items;
}