Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.329
diff -u -F^function -r1.329 taxonomy.module
--- modules/taxonomy/taxonomy.module	20 Dec 2006 10:32:16 -0000	1.329
+++ modules/taxonomy/taxonomy.module	23 Dec 2006 11:30:14 -0000
@@ -271,7 +271,53 @@ function taxonomy_form_vocabulary($edit 
     '#default_value' => $edit['weight'],
     '#description' => t('In listings, the heavier vocabularies will sink and the lighter vocabularies will be positioned nearer the top.'),
   );
-
+  if (module_exists('search')) {
+    $form['indexing'] = array('#type' => 'fieldset',
+      '#title' => t('Indexing options'),
+      '#description' => t("These options let you define whether this vocabulary's terms should be stored in the search index when used on a node, and if so what kind of ranking they should get relative to various html tags. Changing any of these settings will require the search index to be rebuilt."), 
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+    );
+    $rankings = array('h1' => t('Assign same ranking as <h1> text'),
+      'h2' => t('Assign same ranking as <h2> text'),
+      'h3' => t('Assign same ranking as <h3> text'),
+      'h4' => t('Assign same ranking as <h4> text'),
+      'h5' => t('Assign same ranking as <h5> text'),
+      'h6' => t('Assign same ranking as <h6> text'),
+      'a' => t('Assign same ranking as <a> text'),
+      'strong' => t('Assign same ranking as <strong> text'),
+      'p' => t('Assign same ranking as <p> text'),
+      0 => t('Do not index terms'),
+    );
+    $form['indexing']['term_ranking'] = array('#type' => 'select',
+      '#title' => t('Term ranking'),
+      '#description' => t('Defines the ranking of the terms being used.'),
+      '#default_value' => (isset($edit['term_ranking']) ? $edit['term_ranking'] : 'strong'),
+      '#options' => $rankings,
+    );
+    $rankings[0] = t('Do not index synonyms');
+    $form['indexing']['synonym_ranking'] = array('#type' => 'select',
+      '#title' => t('Synonym ranking'),
+      '#description' => t('Defines the ranking of synonyms of the terms being used.'),
+      '#default_value' => (isset($edit['synonym_ranking']) ? $edit['synonym_ranking'] : 0),
+      '#options' => $rankings,
+    );
+    $rankings[0] = t('Do not index parent terms');
+    $form['indexing']['parent_ranking'] = array('#type' => 'select',
+      '#title' => t('Parent term ranking'),
+      '#description' => t('Defines the ranking of terms that are parents of the terms being used.'),
+      '#default_value' => (isset($edit['parent_ranking']) ? $edit['parent_ranking'] : 0),
+      '#options' => $rankings,
+    );
+    $rankings[0] = t('Do not index parent synonyms');
+    $form['indexing']['parent_synonym_ranking'] = array('#type' => 'select',
+      '#title' => t('Parent synonym ranking'),
+      '#description' => t('Defines the ranking of the synonyms of parent terms. You <strong>must</strong> assign a ranking to parent terms for this option to have any effect.'),
+      '#default_value' => (isset($edit['parent_synonym_ranking']) ? $edit['parent_synonym_ranking'] : 0),
+      '#options' => $rankings,
+    );
+  }
+  
   $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
   if ($edit['vid']) {
     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
@@ -285,6 +331,18 @@ function taxonomy_form_vocabulary($edit 
  * Accept the form submission for a vocabulary and save the results.
  */
 function taxonomy_form_vocabulary_submit($form_id, $form_values) {
+  // Reset the search index, if appropriate
+  if (module_exists('search') && $form_values['vid']) {
+    $old_vocabulary = taxonomy_get_vocabulary($form_values['vid']);
+    if ($old_vocabulary->term_ranking != $form_values['term_ranking'] ||
+      $old_vocabulary->synonym_ranking != $form_values['synonym_ranking'] ||
+      $old_vocabulary->parent_ranking != $form_values['parent_ranking'] ||
+      $old_vocabulary->parent_synonym_ranking != $form_values['parent_synonym_ranking']) {
+      db_query("DELETE FROM {variable} WHERE name = 'node_cron_last'");
+      drupal_set_message(t('The search index has been marked for rebuild.'));
+    }
+  }
+
   // Fix up the nodes array to remove unchecked nodes.
   $form_values['nodes'] = array_filter($form_values['nodes']);
   switch (taxonomy_save_vocabulary($form_values)) {
@@ -302,7 +360,7 @@ function taxonomy_save_vocabulary(&$edit
   $edit['nodes'] = empty($edit['nodes']) ? array() : $edit['nodes'];
 
   if ($edit['vid'] && $edit['name']) {
-    db_query("UPDATE {vocabulary} SET name = '%s', description = '%s', help = '%s', multiple = %d, required = %d, hierarchy = %d, relations = %d, tags = %d, weight = %d, module = '%s' WHERE vid = %d", $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy', $edit['vid']);
+    db_query("UPDATE {vocabulary} SET name = '%s', description = '%s', help = '%s', multiple = %d, required = %d, hierarchy = %d, relations = %d, tags = %d, weight = %d, term_ranking = '%s', synonym_ranking = '%s', parent_ranking = '%s', parent_synonym_ranking = '%s', module = '%s' WHERE vid = %d", $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], $edit['term_ranking'], $edit['synonym_ranking'], $edit['parent_ranking'], $edit['parent_synonym_ranking'], isset($edit['module']) ? $edit['module'] : 'taxonomy', $edit['vid']);
     db_query("DELETE FROM {vocabulary_node_types} WHERE vid = %d", $edit['vid']);
     foreach ($edit['nodes'] as $type => $selected) {
       db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type);
@@ -315,7 +373,7 @@ function taxonomy_save_vocabulary(&$edit
   }
   else {
     $edit['vid'] = db_next_id('{vocabulary}_vid');
-    db_query("INSERT INTO {vocabulary} (vid, name, description, help, multiple, required, hierarchy, relations, tags, weight, module) VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s')", $edit['vid'], $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy');
+    db_query("INSERT INTO {vocabulary} (vid, name, description, help, multiple, required, hierarchy, relations, tags, weight, term_ranking, synonym_ranking, parent_ranking, parent_synonym_ranking, module) VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $edit['vid'], $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], $edit['term_ranking'], $edit['synonym_ranking'], $edit['parent_ranking'], $edit['parent_synonym_ranking'], isset($edit['module']) ? $edit['module'] : 'taxonomy');
     foreach ($edit['nodes'] as $type => $selected) {
       db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type);
     }
@@ -1303,10 +1361,46 @@ function taxonomy_nodeapi($node, $op, $a
 function taxonomy_node_update_index(&$node) {
   $output = array();
   foreach ($node->taxonomy as $term) {
-    $output[] = $term->name;
+    $vocabulary = taxonomy_get_vocabulary($term->vid);
+    if ($vocabulary->term_ranking) {
+      $output[] = '<'. $vocabulary->term_ranking .'>'. $term->name .'</'. $vocabulary->term_ranking .'>';
+    }
+    if ($vocabulary->synonym_ranking) {
+      $synonyms = taxonomy_get_synonyms($term->tid);
+      if (count($synonyms)) {
+        $output[] = '<'. $vocabulary->synonym_ranking .'>'. implode(', ', $synonyms) .'</'. $vocabulary->synonym_ranking .'>';
+      }
+    }
+    if ($vocabulary->parent_ranking) {
+      // Collect all the parents of the term in order to index them
+      $parents = array(); // Array containing the parents' names
+      $parents_synonyms = array();
+      $tids = array(); // Array of tids whose parents have to be traversed
+      $tids[] = $term->tid;
+      while (count($tids) && count($immediate_parents = taxonomy_get_parents(array_shift($tids)))) {
+        foreach ($immediate_parents as $parent) {
+          if (!isset($parents[$parent->tid])) {
+            $parents[$parent->tid] = $parent->name; // Using tid as key to avoid duplicates
+            $tids[] = $parent->tid;
+            if ($vocabulary->parent_synonym_ranking) {
+              $synonyms = taxonomy_get_synonyms($parent->tid);
+              foreach ($synonyms as $synonym) {
+                $parents_synonyms[] = $synonym;
+              }
+            }
+          }
+        }
+      }
+      if (count($parents)) {
+        $output[] = '<'. $vocabulary->parent_ranking .'>'. implode(', ', $parents) .'</'. $vocabulary->parent_ranking .'>';
+      }
+      if (count($parents_synonyms)) {
+        $output[] = '<'. $vocabulary->parent_synonym_ranking .'>'. implode(', ', $parents_synonyms) .'</'. $vocabulary->parent_synonym_ranking .'>';
+      }
+    }
   }
   if (count($output)) {
-    return '<strong>('. implode(', ', $output) .')</strong>';
+    return '('. implode(', ', $output) .')';
   }
 }
 
Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.207
diff -u -F^function -r1.207 search.module
--- modules/search/search.module	19 Dec 2006 09:44:53 -0000	1.207
+++ modules/search/search.module	23 Dec 2006 11:30:11 -0000
@@ -1112,7 +1112,7 @@ function search_excerpt($keys, $text) {
   $keys = array_merge($matches[2], $matches[3]);
 
   // Prepare text
-  $text = ' '. strip_tags(str_replace(array('<', '>'), array(' <', '> '), $text)) .' ';
+  $text = ' '. strip_tags($text) .' ';
   array_walk($keys, '_search_excerpt_replace');
   $workkeys = $keys;
 
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.61
diff -u -F^function -r1.61 system.install
--- modules/system/system.install	18 Dec 2006 21:32:10 -0000	1.61
+++ modules/system/system.install	23 Dec 2006 11:30:13 -0000
@@ -578,6 +578,10 @@ function system_install() {
         tags tinyint unsigned NOT NULL default '0',
         module varchar(255) NOT NULL default '',
         weight tinyint NOT NULL default '0',
+        term_ranking varchar(8) NOT NULL default '0',
+        synonym_ranking varchar(8) NOT NULL default '0',
+        parent_ranking varchar(8) NOT NULL default '0',
+        parent_synonym_ranking varchar(8) NOT NULL default '0',
         PRIMARY KEY (vid)
       ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
 
@@ -1044,6 +1048,10 @@ function system_install() {
         tags smallint_unsigned NOT NULL default '0',
         module varchar(255) NOT NULL default '',
         weight smallint NOT NULL default '0',
+        term_ranking varchar(8) NOT NULL default '0',
+        synonym_ranking varchar(8) NOT NULL default '0',
+        parent_ranking varchar(8) NOT NULL default '0',
+        parent_synonym_ranking varchar(8) NOT NULL default '0',
         PRIMARY KEY (vid)
       )");
 
@@ -3480,6 +3488,33 @@ function system_update_1019() {
   return array();
 }
 
+function system_update_1020() {
+  // Added taxonomy ranking for search index
+  $ret = array();
+
+  switch ($GLOBALS['db_type']) {
+    case 'mysqli':
+    case 'mysql':
+      $ret[] = update_sql("ALTER TABLE {vocabulary} ADD COLUMN term_ranking varchar(8) NOT NULL default '0'");
+      $ret[] = update_sql("ALTER TABLE {vocabulary} ADD COLUMN synonym_ranking varchar(8) NOT NULL default '0'");
+      $ret[] = update_sql("ALTER TABLE {vocabulary} ADD COLUMN parent_ranking varchar(8) NOT NULL default '0'");
+      $ret[] = update_sql("ALTER TABLE {vocabulary} ADD COLUMN parent_synonym_ranking varchar(8) NOT NULL default '0'");
+      break;
+
+    case 'pgsql':
+      db_add_column($ret, 'vocabulary', 'term_ranking', 'varchar(8)', array('default' => "'0'", 'not null' => TRUE));
+      db_add_column($ret, 'vocabulary', 'synonym_ranking', 'varchar(8)', array('default' => "'0'", 'not null' => TRUE));
+      db_add_column($ret, 'vocabulary', 'parent_ranking', 'varchar(8)', array('default' => "'0'", 'not null' => TRUE));
+      db_add_column($ret, 'vocabulary', 'parent_synonym_ranking', 'varchar(8)', array('default' => "'0'", 'not null' => TRUE));
+      break;
+  }
+
+  // Assign nice defaults
+  $ret[] = update_sql("UPDATE {vocabulary} SET term_ranking = 'strong', synonym_ranking = '0', parent_ranking = '0', parent_synonym_ranking = '0'");
+  
+  return $ret;
+}
+
 /**
  * @} End of "defgroup updates-4.7-to-5.0"
  */
