You are here

function search_log_admin_settings in Search Log 6

Same name and namespace in other branches
  1. 7 search_log.admin.inc \search_log_admin_settings()

Display admin settings.

Return value

array of form content.

1 string reference to 'search_log_admin_settings'
search_log_menu in ./search_log.module
Implementation of hook_menu().

File

./search_log.admin.inc, line 14
Admin page callbacks file for the search_log module.

Code

function search_log_admin_settings() {
  $form = array();
  $form['logging'] = array(
    '#type' => 'fieldset',
    '#title' => t('Search log settings'),
  );
  $terms_options = array(
    SEARCH_LOG_TERMS_LOWERCASE => t('lowercase (%1 stored as %2)', array(
      '%1' => 'Apple iPod',
      '%2' => 'apple ipod',
    )),
    SEARCH_LOG_TERMS_UPPERCASE_FIRST => t('uppercase first word (%1 stored as %2)', array(
      '%1' => 'Apple iPod',
      '%2' => 'Apple ipod',
    )),
    SEARCH_LOG_TERMS_UPPERCASE_WORDS => t('uppercase all words (%1 stored as %2)', array(
      '%1' => 'Apple iPod',
      '%2' => 'Apple Ipod',
    )),
  );
  $form['logging']['search_log_terms'] = array(
    '#type' => 'radios',
    '#title' => t('Search term normalization'),
    '#description' => t('Search terms are normalized before they are stored in Search log.'),
    '#options' => $terms_options,
    '#default_value' => variable_get('search_log_terms', SEARCH_LOG_TERMS_LOWERCASE),
  );
  foreach (module_list() as $name) {
    if (module_hook($name, 'search') && ($title = module_invoke($name, 'search', 'name'))) {
      $module_options[$name] = $name;
    }
  }
  $form['logging']['search_log_modules_enabled'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Modules'),
    '#description' => t('Select modules to record in Search log. If no modules are checked, all modules which implement !hook_search() will be included.', array(
      '!hook_search()' => l('hook_search()', 'http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_search/6'),
    )),
    '#options' => $module_options,
    '#default_value' => variable_get('search_log_modules_enabled', array()),
  );
  $form['logging']['search_log_preprocess'] = array(
    '#type' => 'checkbox',
    '#title' => t('!warning Collect search status with preprocess_search_results()', array(
      '!warning' => '<span class="error">[Experimental]</span>',
    )),
    '#description' => t('Search does not have a hook to obtain the number of search results. This theme function will work in certain circumstances. If enabled, the function will add one extra DB write for each search result page.'),
    '#default_value' => variable_get('search_log_preprocess', FALSE),
  );
  $form['status'] = array(
    '#type' => 'fieldset',
    '#title' => t('Search log status'),
  );
  $count = db_result(db_query('SELECT COUNT(qid) FROM {search_log}'));
  $form['status']['search_log_count']['#value'] = '<p>' . t('There are %count entries in the Search log table. !clear', array(
    '%count' => number_format($count),
    '!clear' => l(t('Clear log'), 'admin/settings/search/search_log/clear'),
  )) . '</p>';
  $form['status']['search_log_cron'] = array(
    '#type' => 'textfield',
    '#title' => t('Days to keep search log'),
    '#description' => t('Search log table can be automatically truncated by cron. Set to 0 to never truncate Search log table.'),
    '#size' => 4,
    '#default_value' => variable_get('search_log_cron', 0),
  );
  $form['#validate'][] = 'search_log_admin_settings_validate';
  return system_settings_form($form);
}