function search_config_search in Search configuration 6
Same name and namespace in other branches
- 5 search_config.module \search_config_search()
Implementation of hook_search()
File
- ./
search_config.module, line 173 - Used to configure the advanced search form and other search behaviour.
Code
function search_config_search($op) {
switch ($op) {
case 'admin':
$form['search_config'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced search configuration'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Search results default tab
$description = t('Which tab on the search results will be presented by default. The standard Drupal installation defaults to node_search ("Content" tab). This option allows you to default to the "User" tab or any other tab from contributed search modules, e.g. Apachesolr which implements a tab called "Search" to display its results');
$searches = drupal_map_assoc(module_implements('search', false, false));
unset($searches['search_config']);
$form['search_config']['search_config_default_search'] = array(
'#type' => 'radios',
'#title' => t('Default Search'),
'#options' => $searches,
'#multiple' => FALSE,
'#default_value' => variable_get('search_config_default_search', 'node'),
'#description' => t($description),
);
// Keyword boxes:
$form['search_config']['keywords'] = array(
'#type' => 'fieldset',
'#title' => t('Keywords'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('Configuration for which keyword search fields should not be displayed.'),
);
$form['search_config']['keywords']['search_config_disable_or'] = array(
'#type' => 'checkbox',
'#title' => t('Containing any of the words'),
'#default_value' => variable_get('search_config_disable_or', 0),
);
$form['search_config']['keywords']['search_config_disable_phrase'] = array(
'#type' => 'checkbox',
'#title' => t('Containing the phrase'),
'#default_value' => variable_get('search_config_disable_phrase', 0),
);
$form['search_config']['keywords']['search_config_disable_negative'] = array(
'#type' => 'checkbox',
'#title' => t('Containing none of the words'),
'#default_value' => variable_get('search_config_disable_negative', 0),
);
// Taxonomy box
if ($taxonomy = module_invoke('taxonomy', 'form_all', 1)) {
$form['search_config']['category'] = array(
'#type' => 'fieldset',
'#title' => t('Categories'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('Categories to display'),
);
$form['search_config']['category']['search_config_disable_category_all'] = array(
'#type' => 'checkbox',
'#title' => t('Disable category search'),
'#default_value' => variable_get('search_config_disable_category_all', 0),
);
$form['search_config']['category']['search_config_disable_category'] = array(
'#type' => 'select',
'#title' => t('Categories'),
'#options' => $taxonomy,
'#size' => 10,
'#multiple' => TRUE,
'#default_value' => variable_get('search_config_disable_category', array()),
'#description' => t('Disable searching by the selected categories'),
);
}
// Node types
$types = node_get_types('names');
$types = array_merge(array(
'all' => 'Disable all',
), $types);
$form['search_config']['type'] = array(
'#type' => 'fieldset',
'#title' => t('Node types'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['search_config']['type']['form'] = array(
'#type' => 'fieldset',
'#title' => t('Search Form'),
'#collapsible' => FALSE,
'#description' => t('Node types that users shouldn\'t be allowed to search by using the the advanced search form.'),
);
$form['search_config']['type']['form']['search_config_disable_type'] = array(
'#type' => 'checkboxes',
'#options' => $types,
'#default_value' => variable_get('search_config_disable_type', array()),
);
$form['search_config']['type']['index'] = array(
'#type' => 'fieldset',
'#title' => t('Search Index'),
'#collapsible' => FALSE,
'#description' => t('Node types that should not be index by the search module. Any node type set to not be indexed will also be removed from the search form. If you select all available node types to not be index then the search module will be rendered unusable as no nodes will be indexed.'),
);
// If all node types are disabled then the search module is useless.
unset($types['all']);
reset($types);
$form['search_config']['type']['index']['search_config_disable_index_type'] = array(
'#type' => 'checkboxes',
'#options' => $types,
'#default_value' => variable_get('search_config_disable_index_type', array()),
);
return $form;
}
}