You are here

function suggestion_admin_settings_form in Autocomplete Search Suggestions 7

Menu callback to configure suggestion settings.

1 string reference to 'suggestion_admin_settings_form'
suggestion_menu in ./suggestion.module
Implements hook_menu().

File

./suggestion.admin.inc, line 263
Administration form for suggestion module.

Code

function suggestion_admin_settings_form($form) {
  _suggestion_admin_stopword_init();
  $form['#submit'][] = 'suggestion_admin_settings_form_submit';
  $form['#validate'][] = 'suggestion_admin_settings_form_validate';
  $form['suggestion_entry_style'] = array(
    '#title' => t('Entry Choices'),
    '#description' => t('Simple supports one autocomplete suggestion box, Advanced supports unlimited instances of autocomplete'),
    '#type' => 'radios',
    '#options' => array(
      'simple' => t('Simple'),
      'advanced' => t('Advanced'),
    ),
    'advanced' => array(
      '#description' => t('Advanced supports unlimited instances of autocomplete.'),
    ),
    'simple' => array(
      '#description' => t('Simple supports one autocomplete suggestion box.'),
    ),
    '#default_value' => variable_get('suggestion_entry_style', 'simple'),
    '#weight' => 0,
  );
  $form['suggestion_autocomplete'] = array(
    '#title' => t('Form ID, field name K/V pairs'),
    '#description' => t('A list of colon delimited form_id and field name pairs. One pre line, (search_form:keys).'),
    '#type' => 'textarea',
    '#default_value' => _suggestion_admin_get_autocomplete(),
    '#states' => array(
      'visible' => array(
        'input[name="suggestion_entry_style"]' => array(
          'value' => 'advanced',
        ),
      ),
    ),
    '#weight' => 10,
  );
  $form['simple'] = array(
    '#type' => 'container',
    '#tree' => FALSE,
    '#states' => array(
      'visible' => array(
        'input[name="suggestion_entry_style"]' => array(
          'value' => 'simple',
        ),
      ),
    ),
    '#weight' => 20,
  );
  $form['simple']['suggestion_form_id'] = array(
    '#title' => t('Form ID'),
    '#type' => 'textfield',
    '#default_value' => variable_get('suggestion_form_id', ''),
  );
  $form['simple']['suggestion_field_name'] = array(
    '#title' => t('Field Name'),
    '#type' => 'textfield',
    '#default_value' => variable_get('suggestion_field_name', ''),
  );
  $form['suggestion_min'] = array(
    '#title' => t('Minimum Characters'),
    '#type' => 'select',
    '#options' => array_combine(range(3, 10), range(3, 10)),
    '#default_value' => variable_get('suggestion_min', 4),
    '#required' => TRUE,
    '#weight' => 30,
  );
  $form['suggestion_max'] = array(
    '#title' => t('Maximum Characters in a Suggestion'),
    '#type' => 'select',
    '#options' => array_combine(range(20, 60), range(20, 60)),
    '#default_value' => variable_get('suggestion_max', 45),
    '#required' => TRUE,
    '#weight' => 40,
  );
  $form['suggestion_atoms_min'] = array(
    '#title' => t('Minimum Words in a Suggestion'),
    '#type' => 'select',
    '#options' => array_combine(range(1, 10), range(1, 10)),
    '#default_value' => variable_get('suggestion_atoms_min', 3),
    '#required' => TRUE,
    '#weight' => 50,
  );
  $form['suggestion_atoms_max'] = array(
    '#title' => t('Maximum Words in a Suggestion'),
    '#type' => 'select',
    '#options' => array_combine(range(1, 10), range(1, 10)),
    '#default_value' => variable_get('suggestion_atoms_max', 6),
    '#required' => TRUE,
    '#weight' => 60,
  );
  $form['suggestion_limit'] = array(
    '#title' => t('Maximum Suggestions Returned'),
    '#type' => 'select',
    '#options' => array_combine(range(10, 100), range(10, 100)),
    '#default_value' => variable_get('suggestion_limit', 20),
    '#required' => TRUE,
    '#weight' => 70,
  );
  $form['suggestion_types'] = array(
    '#title' => t('Content Types'),
    '#type' => 'checkboxes',
    '#options' => SuggestionStorage::getContentTypes(),
    '#default_value' => variable_get('suggestion_types', array()),
    '#required' => TRUE,
    '#weight' => 80,
  );
  $form['suggestion_keywords'] = array(
    '#title' => t('Priority Suggestions'),
    '#description' => t('Suggestions entered here take priority.'),
    '#type' => 'textarea',
    '#default_value' => implode("\n", SuggestionStorage::getKeywords()),
    '#rows' => 10,
    '#required' => FALSE,
    '#weight' => 90,
  );
  $form['suggestion_stopwords'] = array(
    '#title' => t('Stopwords'),
    '#description' => t('Stopwords are not indexed.'),
    '#type' => 'textarea',
    '#default_value' => implode("\n", array_keys(SuggestionHelper::getStops())),
    '#rows' => 10,
    '#required' => FALSE,
    '#weight' => 100,
  );
  $form['stopwords'] = array(
    '#title' => t('Stopword File Location'),
    '#description' => t('Set the location of the stopword file, (advanced users only).'),
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 110,
  );
  $form['stopwords']['suggestion_stopword_uri'] = array(
    '#title' => t('Stopword file'),
    '#type' => 'textfield',
    '#description' => t('You must use PHP stream wrappers.'),
    '#default_value' => variable_get('suggestion_stopword_uri', file_default_scheme() . '://suggestion/suggestion_stopword.txt'),
    '#required' => TRUE,
  );
  return system_settings_form($form);
}