diff --git a/template.php b/template.php index fc92380..d4d4ce8 100644 --- a/template.php +++ b/template.php @@ -452,3 +452,86 @@ function zen_form_node_form_alter(&$form, &$form_state, $form_id) { } } } + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function zen_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-fieldset'] = array( + '#type' => 'fieldset', + '#title' => t('Keywords'), + '#collapsible' => FALSE, + ); + $form['advanced']['keywords-fieldset']['keywords'] = array( + '#prefix' => '
', + '#suffix' => '
', + ); + $form['advanced']['keywords-fieldset']['keywords']['or'] = array( + '#type' => 'textfield', + '#title' => t('Containing any of the words'), + '#size' => 30, + '#maxlength' => 255, + ); + $form['advanced']['keywords-fieldset']['keywords']['phrase'] = array( + '#type' => 'textfield', + '#title' => t('Containing the phrase'), + '#size' => 30, + '#maxlength' => 255, + ); + $form['advanced']['keywords-fieldset']['keywords']['negative'] = array( + '#type' => 'textfield', + '#title' => t('Containing none of the words'), + '#size' => 30, + '#maxlength' => 255, + ); + // Node types: + $types = array_map('check_plain', node_type_get_names()); + $form['advanced']['types-fieldset'] = array( + '#type' => 'fieldset', + '#title' => t('Types'), + '#collapsible' => FALSE, + ); + $form['advanced']['types-fieldset']['type'] = array( + '#type' => 'checkboxes', + '#prefix' => '
', + '#suffix' => '
', + '#options' => $types, + ); + $form['advanced']['submit'] = array( + '#type' => 'submit', + '#value' => t('Advanced search'), + '#prefix' => '
', + '#suffix' => '
', + '#weight' => 99, + ); + // Languages: + $language_options = array(); + foreach (language_list('language') as $key => $entity) { + $language_options[$key] = $entity->name; + } + if (count($language_options) > 1) { + $form['advanced']['lang-fieldset'] = array( + '#type' => 'fieldset', + '#title' => t('Languages'), + '#collapsible' => FALSE, + '#collapsed' => FALSE, + ); + $form['advanced']['lang-fieldset']['language'] = array( + '#type' => 'checkboxes', + '#prefix' => '
', + '#suffix' => '
', + '#options' => $language_options, + ); + } + $form['#validate'][] = 'node_search_validate'; + } +}