Index: modules/locale/locale.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v
retrieving revision 1.237
diff -u -u -p -r1.237 locale.module
--- modules/locale/locale.module	5 Feb 2009 00:32:46 -0000	1.237
+++ modules/locale/locale.module	8 Feb 2009 11:11:02 -0000
@@ -613,3 +613,34 @@ function theme_locale_translation_filter
   $output .= '<div id="locale-translation-buttons">' . drupal_render($form['buttons']) . '</div>';
   return $output;
 }
+
+/**
+ * Implementation of hook_searchform.
+ */
+function locale_searchform() {
+  // Languages:
+  $language_options = array();
+  foreach (language_list('language') as $key => $object) {
+    $language_options[$key] = $object->name;
+  }
+  if (count($language_options) > 1) {
+    $form['language'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Languages'),
+      '#prefix' => '<div class="criterion">',
+      '#suffix' => '</div>',
+      '#options' => $language_options,
+      '#weight' => 5,
+    );
+    return $form;
+  }
+}
+
+/**
+ * Implementation of hook_searchkeys.
+ */
+function locale_searchkeys() {
+  return array(
+    'language' => array('where' => "n.language = '%s'"),
+  );
+}
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1023
diff -u -u -p -r1.1023 node.module
--- modules/node/node.module	6 Feb 2009 16:25:08 -0000	1.1023
+++ modules/node/node.module	8 Feb 2009 11:11:02 -0000
@@ -1437,35 +1437,20 @@ function node_search($op = 'search', $ke
       $arguments1 = array();
       $conditions1 = 'n.status = 1';
 
-      if ($type = search_query_extract($keys, 'type')) {
-        $types = array();
-        foreach (explode(',', $type) as $t) {
-          $types[] = "n.type = '%s'";
-          $arguments1[] = $t;
+      // Extract the keywords from the query and add sql to the clauses.
+      foreach (module_invoke_all('searchkeys') as $term => $options) {
+        if ($type = search_query_extract($keys, $term)) {
+          $types = array();
+          foreach (explode(',', $type) as $t) {
+            $types[] = $options['where'];
+            $arguments1[] = $t;
+          }
+          $conditions1 .= ' AND (' . implode(' OR ', $types) . ')';
+          if (isset($options['join'])) {
+            $joins .= ' ' . $options['join'];
+          }
+          $keys = search_query_insert($keys, $term);
         }
-        $conditions1 .= ' AND (' . implode(' OR ', $types) . ')';
-        $keys = search_query_insert($keys, 'type');
-      }
-
-      if ($term = search_query_extract($keys, 'term')) {
-        $terms = array();
-        foreach (explode(',', $term) as $c) {
-          $terms[] = "tn.tid = %d";
-          $arguments1[] = $c;
-        }
-        $conditions1 .= ' AND (' . implode(' OR ', $terms) . ')';
-        $join1 .= ' INNER JOIN {taxonomy_term_node} tn ON n.vid = tn.vid';
-        $keys = search_query_insert($keys, 'term');
-      }
-
-      if ($languages = search_query_extract($keys, 'language')) {
-        $terms = array();
-        foreach (explode(',', $languages) as $l) {
-          $terms[] = "n.language = '%s'";
-          $arguments1[] = $l;
-        }
-        $conditions1 .= ' AND (' . implode(' OR ', $terms) . ')';
-        $keys = search_query_insert($keys, 'language');
       }
 
       // Get the ranking expressions.
@@ -2143,51 +2128,14 @@ function node_form_search_form_alter(&$f
       '#size' => 30,
       '#maxlength' => 255,
     );
-
-    // Taxonomy box:
-    if ($taxonomy = module_invoke('taxonomy', 'form_all', 1)) {
-      $form['advanced']['term'] = array(
-        '#type' => 'select',
-        '#title' => t('Only in the term(s)'),
-        '#prefix' => '<div class="criterion">',
-        '#size' => 10,
-        '#suffix' => '</div>',
-        '#options' => $taxonomy,
-        '#multiple' => TRUE,
-      );
-    }
-
-    // Node types:
-    $types = array_map('check_plain', node_get_types('names'));
-    $form['advanced']['type'] = array(
-      '#type' => 'checkboxes',
-      '#title' => t('Only of the type(s)'),
-      '#prefix' => '<div class="criterion">',
-      '#suffix' => '</div>',
-      '#options' => $types,
-    );
+    $form['advanced'] += module_invoke_all('searchform');
     $form['advanced']['submit'] = array(
       '#type' => 'submit',
       '#value' => t('Advanced search'),
       '#prefix' => '<div class="action">',
       '#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';
   }
 }
@@ -2200,20 +2148,15 @@ function node_search_validate($form, &$f
   $keys = $form_state['values']['processed_keys'];
 
   // Insert extra restrictions into the search keywords string.
-  if (isset($form_state['values']['type']) && is_array($form_state['values']['type'])) {
-    // Retrieve selected types - Forms API sets the value of unselected checkboxes to 0.
-    $form_state['values']['type'] = array_filter($form_state['values']['type']);
-    if (count($form_state['values']['type'])) {
-      $keys = search_query_insert($keys, 'type', implode(',', array_keys($form_state['values']['type'])));
+  foreach (module_invoke_all('searchkeys') as $term => $options) {
+    if (isset($form_state['values'][$term]) && is_array($form_state['values'][$term])) {
+      // Retrieve selected types - Forms API sets the value of unselected checkboxes to 0.
+      $form_state['values'][$term] = array_filter($form_state['values'][$term]);
+      if (count($form_state['values'][$term])) {
+        $keys = search_query_insert($keys, $term, implode(',', array_keys($form_state['values'][$term])));
+      }
     }
   }
-
-  if (isset($form_state['values']['term']) && is_array($form_state['values']['term'])) {
-    $keys = search_query_insert($keys, 'term', implode(',', $form_state['values']['term']));
-  }
-  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]);
@@ -3157,3 +3100,28 @@ function node_elements() {
 function theme_node_links($element) {
   return theme('links', $element['#value'],  array('class' => 'links inline'));
 }
+
+/**
+ * Implementation of hook_searchform.
+ */
+function node_searchform() {
+  // Node types:
+  $types = array_map('check_plain', node_get_types('names'));
+  $form['type'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Only of the type(s)'),
+    '#prefix' => '<div class="criterion">',
+    '#suffix' => '</div>',
+    '#options' => $types,
+  );
+  return $form;
+}
+
+/**
+ * Implementation of hook_searchkeys.
+ */
+function node_searchkeys() {
+  return array(
+    'type' => array('where' => "n.type = '%s'"),
+  );
+}
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.460
diff -u -u -p -r1.460 taxonomy.module
--- modules/taxonomy/taxonomy.module	6 Feb 2009 16:25:09 -0000	1.460
+++ modules/taxonomy/taxonomy.module	8 Feb 2009 11:11:02 -0000
@@ -1480,3 +1480,32 @@ function taxonomy_hook_info() {
     ),
   );
 }
+
+/**
+ * Implementation of hook_searchform.
+ */
+function taxonomy_searchform() {
+  // Taxonomy box:
+  if ($taxonomy = taxonomy_form_all(1)) {
+    $form['category'] = array(
+      '#type' => 'select',
+      '#title' => t('Only in the category(s)'),
+      '#prefix' => '<div class="criterion">',
+      '#size' => 10,
+      '#suffix' => '</div>',
+      '#options' => $taxonomy,
+      '#multiple' => TRUE,
+    );
+    return $form;
+  }
+}
+
+/**
+ * Implementation of hook_searchformkeys.
+ */
+function taxonomy_searchkeys() {
+  return array(
+    'category' => array('where' => "tn.cid = '%s'", 'join' => 'INNER JOIN {term_node} tn ON n.vid = tn.vid'),
+  );
+}
+
