You are here

function search_by_page_search in Search by Page 6

Implementation of hook_search().

Defines how to search by page. During op 'search', calls module implementations of hook_sbp_details() to find out how to display the search results.

File

./search_by_page.module, line 471
Main module file for Drupal module Search by Page.

Code

function search_by_page_search($op = 'search', $keys = NULL) {
  switch ($op) {
    case 'name':
      $name = variable_get('search_by_page_tabname', t('Pages'));
      if (module_exists('i18nstrings')) {
        $name = i18nstrings('search_by_page:search_page:tab_name', $name);
      }
      return $name;
    case 'reset':

      // Mark all items as not yet indexed
      db_query('UPDATE {sbp_path} SET last_index_time=0');
      return;
    case 'admin':

      // Add a link to the Search by Page settings form
      $form = array();
      $form['search_by_page'] = array(
        '#type' => 'fieldset',
        '#title' => t('Search by Page settings'),
      );
      $form['search_by_page']['info'] = array(
        '#value' => '<p>' . l(t('Configure Search by Page settings'), 'admin/settings/search_by_page') . '</p>',
      );
      $form['search_by_page']['status'] = _search_by_page_status_details();
      return $form;
    case 'status':

      // Tell Search module how many items have been indexed, and how many not
      $total = db_result(db_query('SELECT COUNT(*) FROM {sbp_path}'));
      $remain = db_result(db_query('SELECT COUNT(*) FROM {sbp_path} p WHERE p.last_index_time = 0'));
      return array(
        'remaining' => $remain,
        'total' => $total,
      );
    case 'search':
      return _search_by_page_do_search($keys);
  }
}