You are here

function uniqueness_settings in Uniqueness 7

Same name and namespace in other branches
  1. 6 uniqueness.admin.inc \uniqueness_settings()

Form builder for uniqueness settings page; system_settings_form().

1 string reference to 'uniqueness_settings'
uniqueness_menu in ./uniqueness.module
Implements hook_menu().

File

./uniqueness.admin.inc, line 11
Settings page for the uniqueness module.

Code

function uniqueness_settings($form, &$form_state) {
  uniqueness_module_status_check();
  $form = array();

  // Search options.
  $form['search'] = array(
    '#type' => 'fieldset',
    '#title' => t('Search'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['search']['uniqueness_search_mode'] = array(
    '#type' => 'radios',
    '#title' => t('Search mode'),
    '#description' => t('Select the mode which should be used for generating the list of related nodes.'),
    '#options' => _uniqueness_search_mode_options(),
    '#default_value' => variable_get('uniqueness_search_mode', UNIQUENESS_SEARCH_MODE_NODETITLE),
    '#required' => TRUE,
  );
  $form['search']['uniqueness_scope'] = array(
    '#type' => 'radios',
    '#title' => t('Search scope'),
    '#options' => array(
      UNIQUENESS_SCOPE_ALL => t('Search in all nodes'),
      UNIQUENESS_SCOPE_CONTENT_TYPE => t('Search only within the content type of the node being added or edited.'),
    ),
    '#default_value' => variable_get('uniqueness_scope', UNIQUENESS_SCOPE_CONTENT_TYPE),
    '#description' => t('Search all nodes or just nodes of the same content type.'),
    '#required' => TRUE,
  );
  $form['search']['uniqueness_results_max'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum number of results'),
    '#default_value' => variable_get('uniqueness_results_max', 10),
    '#size' => 5,
    '#maxlength' => 4,
    '#element_validate' => array(
      'uniqueness_form_validate_results_max',
    ),
    '#description' => t('Limit the number of search results. (For "Drupal search", must be 10 or fewer.)'),
    '#required' => TRUE,
  );
  $form['search']['uniqueness_query_min'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum length of search string'),
    '#default_value' => variable_get('uniqueness_query_min', 3),
    '#size' => 5,
    '#maxlength' => 4,
    '#element_validate' => array(
      'uniqueness_form_validate_query_min',
    ),
    '#description' => t('Enter the minimum number of characters required in the node title for triggering a search. (For "Drupal search", must be @min or more.)', array(
      '@min' => variable_get('minimum_word_size', 3),
    )),
    '#required' => TRUE,
  );

  // Appearance.
  $form['appearance'] = array(
    '#type' => 'fieldset',
    '#title' => t('Appearance'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['appearance']['uniqueness_widgets'] = array(
    '#type' => 'checkboxes',
    '#options' => array(
      UNIQUENESS_WIDGET_INLINE => t('Display related content embedded on the create or edit content form.'),
      UNIQUENESS_WIDGET_BLOCK => t('Provide a block for displaying related content.'),
    ),
    '#default_value' => variable_get('uniqueness_widgets', array(
      UNIQUENESS_WIDGET_INLINE,
    )),
  );
  $form['appearance']['uniqueness_default_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Default title'),
    '#default_value' => variable_get('uniqueness_default_title', t('Related content')),
    '#description' => t('Note: When displayed in a block, this title may be overridden by setting the block title on the <a href="@block-settings-url">uniqueness block settings</a> page.', array(
      '@block-settings-url' => url('admin/structure/block/configure/uniqueness/uniqueness'),
    )),
    '#required' => TRUE,
  );
  $form['appearance']['uniqueness_default_description'] = array(
    '#type' => 'textarea',
    '#title' => t('Default description'),
    '#default_value' => variable_get('uniqueness_default_description', t("Help us avoid duplicate content! If we find content that's related or similar to what you're posting it will be listed here.")),
    '#rows' => 2,
  );
  $form['appearance']['uniqueness_searching_string'] = array(
    '#type' => 'textfield',
    '#title' => t('Search notifier'),
    '#default_value' => variable_get('uniqueness_searching_string', t('Searching&hellip;')),
    '#description' => t('The text to display while the uniqueness search is in progress.'),
  );
  $form['appearance']['uniqueness_no_result_string'] = array(
    '#type' => 'textfield',
    '#title' => t('No related content message'),
    '#default_value' => variable_get('uniqueness_no_result_string', t('Success! No related content found.')),
    '#description' => t('The text to display if the uniqueness search no longer finds any related content.'),
  );
  $form['appearance']['uniqueness_results_prepend'] = array(
    '#type' => 'radios',
    '#title' => t('Results display'),
    '#options' => array(
      0 => t('Replace old results with new ones'),
      1 => t('Leave old results and prepend new ones'),
    ),
    '#default_value' => variable_get('uniqueness_results_prepend', 0),
    '#description' => t('Choose if new results replace or are added to existing results. Browser cache may keep this setting from taking affect right away.'),
    '#required' => TRUE,
  );
  return system_settings_form($form);
}