diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 863bc7a20b8db3a276dcc7dea32cbac284a0ce8f..e76bb1b198a083e8b8dd9ee4a8b862da7c03e329 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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. diff --git a/modules/node/node.module b/modules/node/node.module index ba10ea17162f4bbea44c8326ee83b4ad85f0d893..73d5f334ca1a023efb741de19cb5af7120b291e6 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -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]);