1 node.module | node_form_search_form_alter(&$form, $form_state) |
Implements hook_form_FORM_ID_alter().
See also
File
- core/
modules/ node/ node.module, line 2444 - The core module that allows content to be submitted to the site.
Code
function node_form_search_form_alter(&$form, $form_state) {
if (isset($form['module']) && $form['module']['#value'] == 'node' && user_access('use advanced search')) {
// Keyword boxes:
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced search'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attributes' => array('class' => array('search-advanced')),
);
$form['advanced']['keywords'] = array(
'#prefix' => '<div class="criterion">',
'#suffix' => '</div>',
);
$form['advanced']['keywords']['or'] = array(
'#type' => 'textfield',
'#title' => t('Containing any of the words'),
'#size' => 30,
'#maxlength' => 255,
);
$form['advanced']['keywords']['phrase'] = array(
'#type' => 'textfield',
'#title' => t('Containing the phrase'),
'#size' => 30,
'#maxlength' => 255,
);
$form['advanced']['keywords']['negative'] = array(
'#type' => 'textfield',
'#title' => t('Containing none of the words'),
'#size' => 30,
'#maxlength' => 255,
);
// Node types:
$types = array();
$search_content_types = _node_search_get_types();
foreach (node_type_get_types() as $type => $detail) {
if (in_array($type, $search_content_types)) {
if (!$detail->settings['hidden_path'] || user_access('view hidden paths')) {
$types[$type] = $detail->name;
}
}
}
$form['advanced']['type'] = array(
'#type' => 'checkboxes',
'#title' => t('Only of the type(s)'),
'#prefix' => '<div class="criterion">',
'#suffix' => '</div>',
'#options' => $types,
);
$form['advanced']['actions'] = array('#type' => 'actions');
$form['advanced']['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Advanced search'),
'#prefix' => '<div class="action">',
'#suffix' => '</div>',
'#weight' => 100,
);
// Languages:
$language_options = language_list(TRUE, TRUE);
if (count($language_options) > 1) {
$form['advanced']['language'] = array(
'#type' => 'checkboxes',
'#title' => t('Languages'),
'#prefix' => '<div class="criterion">',
'#suffix' => '</div>',
'#options' => $language_options,
);
}
$form['#validate'][] = 'node_search_validate';
}
}