You are here

function fuzzysearch_admin_form in Fuzzy Search 6

Module Administration (clear index).

1 string reference to 'fuzzysearch_admin_form'
fuzzysearch_admin in ./fuzzysearch.admin.inc
Build the administration settings panel.

File

./fuzzysearch.admin.inc, line 27
Admin settings and related functions

Code

function fuzzysearch_admin_form() {
  $form['index'] = array(
    '#title' => t('Index settings'),
    '#type' => 'fieldset',
    '#description' => t('This section configures how Fuzzysearch indexes your site content. You must reindex your site for changes made in this section to take effect.'),
  );
  $form['index']['fuzzysearch_ngram_length'] = array(
    '#type' => 'textfield',
    '#title' => t('Ngram length'),
    '#size' => 1,
    '#maxlength' => 1,
    '#description' => t('Fuzzysearch breaks down words into ngrams, or pieces of text this long, for indexing and searching. Default value is 3.'),
    '#default_value' => variable_get('fuzzysearch_ngram_length', 3),
  );
  $form['index']['fuzzysearch_index_cron'] = array(
    '#type' => 'textfield',
    '#title' => t('Nodes to index per cron run'),
    '#size' => 4,
    '#maxlength' => 4,
    '#description' => t('This sets the number of nodes to index per cron run. A high number may cause PHP to timeout.'),
    '#default_value' => variable_get('fuzzysearch_index_cron', 150),
  );
  $tags = fuzzysearch_get_index_tags();
  $tag_options = array_keys(array_fill(0, 100, 1));
  $form['index']['tags'] = array(
    '#title' => t('HTML tag scoring settings'),
    '#description' => t('Search terms located within some tags can raise the score of a matching node and move it up in the results list. You can set how important the tags are here. Tags set to 0 have no influence.'),
    '#type' => 'fieldset',
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
  );
  foreach ($tags as $tag => $value) {
    $form['index']['tags']['fuzzysearch_tag_' . $tag] = array(
      '#type' => 'select',
      '#title' => '<' . $tag . '>',
      '#description' => t('Set the indexing score for words inside the @tag tag', array(
        '@tag' => $tag,
      )),
      '#options' => $tag_options,
      '#default_value' => variable_get('fuzzysearch_tag_' . $tag, $tags[$tag]),
    );
  }
  $form['index']['fuzzysearch_reindex'] = array(
    '#type' => 'checkbox',
    '#title' => t('Rebuild index'),
    '#description' => t('Check the box and click submit to re-index all nodes on the site. Re-indexing will begin with the the next cron run. This does not clear the index.'),
    '#default_value' => FALSE,
  );
  $form['index']['fuzzysearch_clear_index'] = array(
    '#type' => 'checkbox',
    '#title' => t('Clear and rebuild index'),
    '#description' => t('Check the box and click submit to clear the index and re-index all nodes on the site. Re-indexing will begin with the the next cron run. Searching will be incomplete until all nodes are indexed.'),
    '#default_value' => FALSE,
  );
  $form['search'] = array(
    '#title' => t('Search settings'),
    '#description' => t('This section configures how Fuzzysearch queries indexed content.'),
    '#type' => 'fieldset',
  );
  $form['search']['fuzzysearch_missing_letters'] = array(
    '#type' => 'textfield',
    '#title' => t('Assume missing letters in search terms'),
    '#size' => 1,
    '#maxlength' => 1,
    '#description' => t('A search term as entered by a user may be missing letters. Up to how many missing letters in the term do you want to assume? 0 means the term will not return longer words in the results. 1 means a 4 letter search term will also check 5 letters words in the index.'),
    '#default_value' => variable_get('fuzzysearch_missing_letters', 1),
  );
  $form['search']['fuzzysearch_extra_letters'] = array(
    '#type' => 'textfield',
    '#title' => t('Assume extra letters in search terms'),
    '#size' => 1,
    '#maxlength' => 1,
    '#description' => t('A search term as entered by a user may have extra letters. Up to how many extra letters in the term do you want to assume? 0 means the term will not return shorter words in the results. 1 means a 4 letter search term will also check 3 letters words in the index.'),
    '#default_value' => variable_get('fuzzysearch_extra_letters', 1),
  );
  $form['search']['fuzzysearch_completeness'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum completeness'),
    '#size' => 3,
    '#maxlength' => 3,
    '#description' => t('Enter a value between 0 and 100 to set the minimum match completeness required in the returned results.'),
    '#default_value' => variable_get('fuzzysearch_completeness', 40),
  );
  $options = node_get_types('names');
  $form['search']['fuzzysearch_nodetypes'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Check any node types you want to exclude from search results'),
    '#description' => t('This does not affect how Fuzzy Search indexes your content types.'),
    '#default_value' => variable_get('fuzzysearch_nodetypes', array(
      '',
    )),
    '#options' => $options,
  );
  $form['search']['fuzzysearch_debug_search'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display debuging information'),
    '#description' => t('If selected, various search information will be displayed that may help tune fuzzysearch settings.'),
    '#default_value' => variable_get('fuzzysearch_debug_search', FALSE),
  );
  $form['display'] = array(
    '#title' => t('Display settings'),
    '#description' => t('This section configures how Fuzzysearch displays the search results.'),
    '#type' => 'fieldset',
  );
  $form['display']['fuzzysearch_path_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Search results path'),
    '#maxlength' => 32,
    '#required' => TRUE,
    '#description' => t('Choose the search results path, for example: search/results. Do not use leading or trailing slashes.'),
    '#default_value' => variable_get('fuzzysearch_path_name', 'fuzzysearch/results'),
  );
  $form['display']['fuzzysearch_sort_score'] = array(
    '#type' => 'checkbox',
    '#title' => t('Sort by score'),
    '#description' => t('If selected, the results will be sorted by score first and completeness second, which can make tag scores even more important. The default is to sort by completeness first.'),
    '#default_value' => variable_get('fuzzysearch_sort_score', FALSE),
  );
  $form['display']['fuzzysearch_debug_score'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display scoring'),
    '#description' => t('If selected, the completeness and score of the results will be shown below each result, which may be helpful for debugging.'),
    '#default_value' => variable_get('fuzzysearch_debug_score', FALSE),
  );
  $form['display']['fuzzysearch_excerpt'] = array(
    '#type' => 'textfield',
    '#title' => t('Result excerpt length'),
    '#size' => 3,
    '#maxlength' => 3,
    '#description' => t('Set the length of the displayed text excerpt containing a found search term. Applies per found term.'),
    '#default_value' => variable_get('fuzzysearch_excerpt', 200),
  );
  $form['display']['fuzzysearch_max_result'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum result length'),
    '#size' => 4,
    '#maxlength' => 4,
    '#description' => t('Set the maximum length of the displayed result. Set to 0 for unlimited length. Applies per result.'),
    '#default_value' => variable_get('fuzzysearch_max_result', 0),
  );
  $form['display']['fuzzysearch_spelling'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum spelling score'),
    '#size' => 3,
    '#maxlength' => 3,
    '#description' => t('Fuzzysearch tries to highlight search terms that may be misspelled. You can set the minimum threshold, which is calculated as a ratio of ngram hits to misses in a term. 0 may cause a misspelling to highlight everything, and 100 will only highlight exact terms. Enter value between 0 and 100. Changing this setting does not require reindexing.'),
    '#default_value' => variable_get('fuzzysearch_spelling', 30),
  );
  $form['#submit'][] = 'fuzzysearch_admin_form_submit';
  return system_settings_form($form);
}