| 38 |
if (!empty($extensions) && preg_match("/\.($extensions)$/", $_REQUEST['destination'])) { |
if (!empty($extensions) && preg_match("/\.($extensions)$/", $_REQUEST['destination'])) { |
| 39 |
return false; |
return false; |
| 40 |
} |
} |
| 41 |
$keys = $_REQUEST['destination']; |
$keys = $_REQUEST['destination'] ? $_REQUEST['destination'] : $_REQUEST['q']; |
| 42 |
$regex_filter = variable_get('search404_regex', ''); |
$regex_filter = variable_get('search404_regex', ''); |
| 43 |
$keys_array[] = $keys; |
$keys_array[] = $keys; |
| 44 |
if (!empty($regex_filter)) { |
if (!empty($regex_filter)) { |
| 102 |
drupal_set_title(t('Page not found')); |
drupal_set_title(t('Page not found')); |
| 103 |
if (module_exists('search') && user_access('search content')) { |
if (module_exists('search') && user_access('search content')) { |
| 104 |
$keys = ""; |
$keys = ""; |
| 105 |
|
// if apachesolr_search is installed use apachesolr_search instead default node search |
| 106 |
|
$type_search = (module_exists('apachesolr_search')) ? 'apachesolr_search' : 'node'; |
| 107 |
if (variable_get('search404_use_search_engine', false)) { |
if (variable_get('search404_use_search_engine', false)) { |
| 108 |
$keys = search404_search_engine_query(); |
$keys = search404_search_engine_query(); |
| 109 |
} |
} |
| 112 |
} |
} |
| 113 |
if ($keys) { |
if ($keys) { |
| 114 |
// TODO: watchdog? |
// TODO: watchdog? |
| 115 |
$results = module_invoke('node', 'search', 'search', $keys); |
$results = module_invoke($type_search, 'search', 'search', $keys); |
| 116 |
if (isset($results) && is_array($results) && count($results) == 1 && variable_get('search404_jump', false)) { |
if (isset($results) && is_array($results) && count($results) == 1 && variable_get('search404_jump', false)) { |
| 117 |
// First, check to see if there is exactly 1 result |
// First, check to see if there is exactly 1 result |
| 118 |
drupal_set_message(t('The page you requested does not exist. A search for %keys resulted in this page.', array('%keys' => check_plain($keys))), 'status'); |
drupal_set_message(t('The page you requested does not exist. A search for %keys resulted in this page.', array('%keys' => check_plain($keys))), 'status'); |
| 134 |
$oldgetq = $_GET['q']; |
$oldgetq = $_GET['q']; |
| 135 |
$olddestination = $_REQUEST['destination']; |
$olddestination = $_REQUEST['destination']; |
| 136 |
unset($_REQUEST['destination']); |
unset($_REQUEST['destination']); |
| 137 |
$_GET['q'] = "search/node/$keys"; |
$_GET['q'] = "search/$type_search/$keys"; |
| 138 |
$results = theme('search_results', $results, 'node'); |
$results = theme('search_results', $results, 'node'); |
| 139 |
$_GET['q'] = $oldgetq; |
$_GET['q'] = $oldgetq; |
| 140 |
$_REQUEST['destination'] = $olddestination; |
$_REQUEST['destination'] = $olddestination; |
| 147 |
} |
} |
| 148 |
} |
} |
| 149 |
// Construct the search form. |
// Construct the search form. |
| 150 |
$output = drupal_get_form('search_form', NULL, $keys, 'node') . $results; |
$output = drupal_get_form('search_form', NULL, $keys, $type_search) . $results; |
| 151 |
} |
} |
| 152 |
|
|
| 153 |
/* |
/* |