You are here

function search_by_page_admin_overview in Search by Page 6

Same name and namespace in other branches
  1. 8 search_by_page.module \search_by_page_admin_overview()
  2. 7 search_by_page.module \search_by_page_admin_overview()

Returns the admin overview page for module configuration.

This page lets you choose and configure search environments.

1 string reference to 'search_by_page_admin_overview'
search_by_page_menu in ./search_by_page.module
Implementation of hook_menu().

File

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

Code

function search_by_page_admin_overview(&$form_state) {
  $form = array();
  $form['general_sbp'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => -20,
    '#title' => t('Additional actions'),
  );
  $form['general_sbp']['info'] = array(
    '#type' => 'markup',
    '#weight' => 20,
    '#value' => '<p>' . l(t('Configure general search settings and see indexing status'), 'admin/settings/search') . '</p>',
  );
  $form['general_sbp']['cron'] = array(
    '#type' => 'markup',
    '#weight' => 21,
    '#value' => '<p>' . l(t('Visit the Status Report page to check cron status and run cron'), 'admin/reports/status') . '</p>',
  );
  $form['general_sbp']['reset_blank'] = array(
    '#type' => 'markup',
    '#weight' => 22,
    '#value' => '<p>' . l(t('Click to reset pages that are blank in the search index, so they will reindex at next cron run.'), 'admin/settings/search_by_page/resetblank') . '</p>',
  );

  // Make a table of existing environments.
  $options = array();
  $output = '<h3>' . t('Search environments') . '</h3>';
  $output .= '<p>' . l(t('Add new search environment'), 'admin/settings/search_by_page/add') . '</p>';
  $headers = array(
    t('Environment'),
    t('URL path'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $rows = array();
  $envs = search_by_page_list_environments();
  foreach ($envs as $envid) {
    $path = search_by_page_setting_get('page_path', $envid, 'search_pages');
    $envname = search_by_page_setting_get('environment_name', $envid, t('new'));
    if (module_exists('i18nstrings')) {
      $envname = i18nstrings('search_by_page:environment:name' . $envid, $envname);
    }
    $options[$envid] = $envname;
    $rows[] = array(
      $envname,
      l($path, $path),
      l('edit', 'admin/settings/search_by_page/edit/' . $envid),
      l('delete', 'admin/settings/search_by_page/delete/' . $envid),
    );
  }
  if (!count($rows)) {
    $rows[] = array(
      t('No environments defined'),
      '',
      '',
      '',
    );
  }
  $output .= theme('table', $headers, $rows);
  $form['environment_table'] = array(
    '#type' => 'markup',
    '#weight' => -5,
    '#value' => $output,
  );

  // Form section to choose default environment, name for it in Search, and
  // cron limit.
  $items = drupal_map_assoc(array(
    10,
    20,
    50,
    100,
    200,
    500,
  ));
  $core_limit = (int) variable_get('search_cron_limit', 100);
  $limit = (int) variable_get('sbp_cron_limit', $core_limit);
  $form['sbp_cron_limit'] = array(
    '#type' => 'select',
    '#weight' => -3,
    '#default_value' => $limit,
    '#options' => $items,
    '#title' => t('Number of items to index per cron run'),
    '#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a> by Search by Page.', array(
      '@cron' => url('admin/reports/status'),
    )),
  );
  $form['search_by_page_default_environment'] = array(
    '#type' => 'select',
    '#weight' => -2,
    '#default_value' => variable_get('search_by_page_default_environment', 1),
    '#options' => $options,
    '#title' => t('Default environment'),
    '#description' => t('The default environment is used for the Search by Page tab when using the core Search page.'),
  );
  $form['search_by_page_tabname'] = array(
    '#type' => 'textfield',
    '#weight' => -1,
    '#default_value' => variable_get('search_by_page_tabname', t('Pages')),
    '#title' => t('Search tab name'),
    '#description' => t('If using Search by Page with the core Search module, the name of the tab where Search by Page results are shown.'),
  );
  return system_settings_form($form);
}