Commit 88600018 authored by Dries's avatar Dries
Browse files

- Patch #154151 by Robert Douglass: made it possible to do language-aware searches.

parent 3ad38dbb
......@@ -12,6 +12,8 @@ Drupal 7.0, xxxx-xx-xx (development version)
- Usability:
* Implemented drag-and-drop positioning for input format listings.
* Provide descriptions for permissions on the administration page.
- Search:
* Made it possible to language-aware searches.
- Removed ping module:
* This module has been removed from the core download. Contributed
alternatives are available.
......
......@@ -1215,6 +1215,16 @@ function node_search($op = 'search', $keys = NULL) {
$keys = search_query_insert($keys, 'category');
}
if ($languages = search_query_extract($keys, 'language')) {
$categories = array();
foreach (explode(',', $languages) as $l) {
$categories[] = "n.language = '%s'";
$arguments1[] = $l;
}
$conditions1 .= ' AND (' . implode(' OR ', $categories) . ')';
$keys = search_query_insert($keys, 'language');
}
// Build ranking expression (we try to map each parameter to a
// uniform distribution in the range 0..1).
$ranking = array();
......@@ -1871,6 +1881,22 @@ function node_form_alter(&$form, $form_state, $form_id) {
'#suffix' => '</div>',
);
// Languages:
$language_options = array();
foreach (language_list('language') as $key => $object) {
$language_options[$key] = $object->name;
}
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';
}
}
......@@ -1894,6 +1920,9 @@ function node_search_validate($form, &$form_state) {
if (isset($form_state['values']['category']) && is_array($form_state['values']['category'])) {
$keys = search_query_insert($keys, 'category', implode(',', $form_state['values']['category']));
}
if (isset($form_state['values']['language']) && is_array($form_state['values']['language'])) {
$keys = search_query_insert($keys, 'language', implode(',', array_filter($form_state['values']['language'])));
}
if ($form_state['values']['or'] != '') {
if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' ' . $form_state['values']['or'], $matches)) {
$keys .= ' ' . implode(' OR ', $matches[1]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment