You are here

function _custom_search_content_admin_form in Custom Search 7

Same name and namespace in other branches
  1. 6 includes/forms.inc \_custom_search_content_admin_form()

Content admin form.

2 calls to _custom_search_content_admin_form()
custom_search_blocks_block_configure in modules/custom_search_blocks/custom_search_blocks.module
Implements hook_block_configure().
custom_search_content_admin in ./custom_search.admin.inc
Content settings.

File

includes/forms.inc, line 203
Search forms

Code

function _custom_search_content_admin_form($delta = '') {
  if ($delta != '') {
    $delta = 'blocks_' . $delta . '_';
  }
  $form['content_selector'] = array(
    '#type' => 'fieldset',
    '#title' => t('Content selector'),
    '#description' => t("Select the search types to present as search options in the search block. If none is selected, no selector will be displayed. <strong>Note</strong>: if there's only one type checked, the selector won't be displayed BUT only this type will be searched."),
  );
  $form['content_selector']['custom_search_' . $delta . 'node_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content types'),
    '#default_value' => variable_get('custom_search_' . $delta . 'node_types', array()),
    '#options' => node_type_get_names(),
  );

  // Other searches.
  $options = array();
  foreach (module_implements('search_info') as $module) {
    if ($module != 'node' && ($name = module_invoke($module, 'search_info'))) {
      $options[$module] = $name['title'];
    }
  }
  if (count($options)) {
    $form['content_selector']['custom_search_' . $delta . 'other'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Other searches'),
      '#default_value' => variable_get('custom_search_' . $delta . 'other', array()),
      '#options' => $options,
    );
  }
  $form['content_selector']['custom_search_' . $delta . 'type_selector'] = array(
    '#type' => 'select',
    '#title' => t('Selector type'),
    '#options' => array(
      'select' => t('Drop-down list'),
      'selectmultiple' => t('Drop-down list with multiple choices'),
      'radios' => t('Radio buttons'),
      'checkboxes' => t('Checkboxes'),
    ),
    '#description' => t('Choose which selector type to use. Note: content types and other searches cannot be combined in a single search.'),
    '#default_value' => variable_get('custom_search_' . $delta . 'type_selector', 'select'),
  );
  $form['content_selector']['custom_search_' . $delta . 'type_selector_label_visibility'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display label'),
    '#default_value' => variable_get('custom_search_' . $delta . 'type_selector_label_visibility', TRUE),
  );
  $form['content_selector']['custom_search_' . $delta . 'type_selector_label'] = array(
    '#type' => 'textfield',
    '#title' => t('Label text'),
    '#default_value' => variable_get('custom_search_' . $delta . 'type_selector_label', CUSTOM_SEARCH_TYPE_SELECTOR_LABEL_DEFAULT),
    '#description' => t('Enter the label text for the selector. The default value is "!default".', array(
      '!default' => CUSTOM_SEARCH_TYPE_SELECTOR_LABEL_DEFAULT,
    )),
    '#states' => array(
      'visible' => array(
        ':input[name="custom_search_' . $delta . 'type_selector_label_visibility"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['content_selector']['any'] = array(
    '#type' => 'fieldset',
    '#title' => t('-Any-'),
  );
  $form['content_selector']['any']['custom_search_' . $delta . 'type_selector_all'] = array(
    '#type' => 'textfield',
    '#title' => t('-Any content type- text'),
    '#default_value' => variable_get('custom_search_' . $delta . 'type_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT),
    '#required' => TRUE,
    '#description' => t('Enter the text for "any content type" choice. The default value is "!default".', array(
      '!default' => CUSTOM_SEARCH_ALL_TEXT_DEFAULT,
    )),
  );
  $form['content_selector']['any']['custom_search_' . $delta . 'any_restricts'] = array(
    '#type' => 'checkbox',
    '#title' => t('Choosing -Any- restricts the search to the selected content types.'),
    '#default_value' => variable_get('custom_search_' . $delta . 'any_restricts', FALSE),
    '#description' => t('If not checked, choosing -Any- will search in all content types.'),
  );
  $form['content_selector']['any']['custom_search_' . $delta . 'any_force'] = array(
    '#type' => 'checkbox',
    '#title' => t('Force -Any- to be displayed.'),
    '#default_value' => variable_get('custom_search_' . $delta . 'any_force', FALSE),
    '#description' => t('When only one content type is selected, the default behaviour is to hide the selector. If you need the -Any- option to be displayed, check this.'),
  );
  $form['custom_search_' . $delta . 'node_types_excluded'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content exclusion'),
    '#description' => t("Select the content types you don't want to be displayed as results.<br/><strong>Notice</strong>: content exclusion only works with the core Search module."),
    '#default_value' => variable_get('custom_search_' . $delta . 'node_types_excluded', array()),
    '#options' => node_type_get_names(),
  );
  return $form;
}