- <?php
- * @file
- * User page callbacks for the search module.
- */
-
- * Menu callback; presents the search form and/or search results.
- *
- * @param $module
- * Search module to use for the search.
- * @param $keys
- * Keywords to use for the search.
- */
- function search_view($module = NULL, $keys = '') {
- $info = FALSE;
- $keys = trim($keys);
-
-
- if (!$keys && !empty($_REQUEST['keys'])) {
- $keys = trim($_REQUEST['keys']);
- }
-
- if (!empty($module)) {
- $active_module_info = search_get_info();
- if (isset($active_module_info[$module])) {
- $info = $active_module_info[$module];
- }
- }
-
- if (empty($info)) {
-
-
-
- $info = search_get_default_module_info();
-
- $path = 'search/' . $info['path'];
- if ($keys) {
- $path .= '/' . $keys;
- }
- backdrop_goto($path);
- }
-
-
- $results = array('#markup' => '');
-
-
-
-
-
-
- if (empty($_POST['form_id']) || ($_POST['form_id'] != 'search_form' && $_POST['form_id'] != 'search_block_form')) {
- $conditions = NULL;
- if (isset($info['conditions_callback'])) {
-
- $conditions = call_user_func($info['conditions_callback'], $keys);
- }
-
- if ($keys || !empty($conditions)) {
- if (config_get('search.settings', 'search_logging')) {
-
- watchdog('search', 'Searched %type for %keys.', array('%keys' => $keys, '%type' => $info['title']), WATCHDOG_NOTICE, l(t('results'), 'search/' . $info['path'] . '/' . $keys));
- }
-
-
- $results = search_data($keys, $info['module'], $conditions);
- }
- }
-
- $build['search_form'] = backdrop_get_form('search_form', NULL, $keys, $info['module']);
- $build['search_results'] = $results;
-
- return $build;
- }
-
- * As the search form collates keys from other modules hooked in via
- * hook_form_alter, the validation takes place in _submit.
- * search_form_validate() is used solely to set the 'processed_keys' form
- * value for the basic search form.
- */
- function search_form_validate($form, &$form_state) {
- form_set_value($form['basic']['processed_keys'], trim($form_state['values']['keys']), $form_state);
- }
-
- * Process a search form submission.
- */
- function search_form_submit($form, &$form_state) {
- $keys = $form_state['values']['processed_keys'];
- if ($keys == '') {
- form_set_error('keys', t('Please enter some keywords.'));
-
- }
-
- $form_state['redirect'] = $form_state['action'] . '/' . $keys;
- }