? 568350.patch
? t.patch
? sites/default/files
? sites/default/private
? sites/default/settings.php
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.533
diff -u -u -p -r1.533 theme.inc
--- includes/theme.inc	9 Oct 2009 16:33:13 -0000	1.533
+++ includes/theme.inc	10 Oct 2009 13:10:40 -0000
@@ -1996,12 +1996,13 @@ function theme_username($variables) {
  *   An associative array containing:
  *   - percent: The percentage of the progress.
  *   - message: A string containing information to be displayed.
+ *   - class:
  *
  * @return
  *   A themed HTML string representing the progress bar.
  */
 function theme_progress_bar($variables) {
-  $output = '<div id="progress" class="progress">';
+  $output = '<div id="progress" class="progress' . (empty($variables['class']) ? '' : ' ' . $variables['class']) . '">';
   $output .= '<div class="bar"><div class="filled" style="width: ' . $variables['percent'] . '%"></div></div>';
   $output .= '<div class="percentage">' . $variables['percent'] . '%</div>';
   $output .= '<div class="message">' . $variables['message'] . '</div>';
Index: modules/search/search.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.admin.inc,v
retrieving revision 1.12
diff -u -u -p -r1.12 search.admin.inc
--- modules/search/search.admin.inc	18 Sep 2009 00:12:47 -0000	1.12
+++ modules/search/search.admin.inc	10 Oct 2009 13:10:40 -0000
@@ -9,15 +9,32 @@
 /**
  * Menu callback: confirm wiping of the index.
  */
-function search_reindex_confirm() {
-  return confirm_form(array(), t('Are you sure you want to re-index the site?'),
-                  'admin/config/search/settings', t(' The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed. This action cannot be undone.'), t('Re-index site'), t('Cancel'));
+function search_reset_confirm() {
+  // Create the index status form from the status metrics.
+  $metrics = _search_get_status_metrics('@done items will be affected.');
+  $form = array();
+  $form['status'] = array(
+    '#type' => 'fieldset',
+    '#description' =>  t('Search will still work while the remaining items are indexed.'),
+    'progress' => array(
+      '#type' => 'markup',
+      '#markup' => theme('progress_bar', $metrics),
+    ),
+  );
+  return confirm_form(
+    $form,
+    t('Are you sure you want to reset the search index?'),
+    'admin/config/search/settings',
+    '',
+    t('Reset index'),
+    t('Cancel')
+  );
 }
 
 /**
- * Handler for wipe confirmation
+ * Handler for wipe confirmation.
  */
-function search_reindex_confirm_submit(&$form, &$form_state) {
+function search_reset_confirm_submit(&$form, &$form_state) {
   if ($form['confirm']) {
     search_reindex();
     drupal_set_message(t('The index will be rebuilt.'));
@@ -30,7 +47,6 @@ function search_reindex_confirm_submit(&
  * Helper function to get real module names.
  */
 function _search_get_module_names() {
-
   $search_info = search_get_info();
   $modules = db_select('system', 's')
     ->fields('s', array('name', 'info'))
@@ -48,30 +64,67 @@ function _search_get_module_names() {
 }
 
 /**
- * Menu callback; displays the search module settings page.
- *
- * @ingroup forms
- * @see system_settings_form()
- * @see search_admin_settings_submit()
- * @see search_admin_reindex_submit()
+ * Return the search status metrics, which is used by several of the search forms.
  */
-function search_admin_settings($form) {
-  // Collect some stats
+function _search_get_status_metrics($message = array()) {
+  // Collect some stats.
   $remaining = 0;
   $total = 0;
-  foreach(variable_get('search_active_modules', array('node', 'user')) as $module) {
+  foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
     if ($status = module_invoke($module, 'search_status')) {
       $remaining += $status['remaining'];
       $total += $status['total'];
     }
   }
 
-  $count = format_plural($remaining, 'There is 1 item left to index.', 'There are @count items left to index.');
-  $percentage = ((int)min(100, 100 * ($total - $remaining) / max(1, $total))) . '%';
-  $status = '<p><strong>' . t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) . ' ' . $count . '</strong></p>';
-  $form['status'] = array('#type' => 'fieldset', '#title' => t('Indexing status'));
-  $form['status']['status'] = array('#markup' => $status);
-  $form['status']['wipe'] = array('#type' => 'submit', '#value' => t('Re-index site'), '#submit' => array('search_admin_reindex_submit'));
+  // Create the count message to display.
+  if (empty($message)) {
+    $message = array(
+      'zero' => '',
+      'none' => 'No items indexed, @remaining items remaining.',
+      'partial' => '@done of @total items indexed.',
+      'all' => 'All @done items indexed.',
+    );
+  }
+  if (is_array($message)) {
+    $state = $remaining == 0 ? (($total > 0) ? 'all' : 'zero') : (($remaining == $total) ? 'none' : 'partial');
+    $message = $message[$state];
+  }
+  $count = t($message, array('@remaining' => number_format($remaining), '@total' => number_format($total), '@done' => number_format($total - $remaining)));
+
+  // Return the metrics array.
+  $percent = $total ? (int) min(100, 100 * ($total - $remaining) / $total) : 100;
+  return array('remaining' => $remaining, 'total' => $total, 'percent' => $percent, 'message' => $count, 'class' => 'inactive');
+}
+
+/**
+ * Menu callback; displays the search module settings page.
+ *
+ * @ingroup forms
+ * @see system_settings_form()
+ * @see search_admin_settings_submit()
+ * @see search_admin_reset_submit()
+ */
+function search_admin_settings() {
+  $form = array();
+  // Create the index status form from the status metrics.
+  $metrics = _search_get_status_metrics();
+  $form = array();
+  $form['status'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Index Status'),
+    'progress' => array(
+      '#type' => 'markup',
+      '#markup' => theme('progress_bar', $metrics),
+    ),
+  );
+  if ($metrics['remaining'] != $metrics['total']) {
+    $form['status']['wipe'] = array(
+      '#type' => 'submit',
+      '#value' => t('Reset index'),
+      '#submit' => array('search_admin_reset_submit'),
+    );
+  }
 
   $items = drupal_map_assoc(array(10, 20, 50, 100, 200, 500));
 
@@ -156,9 +209,9 @@ function search_admin_settings_submit($f
 }
 
 /**
- * Submit callback.
+ * Submit callback to wipe the search index.
  */
-function search_admin_reindex_submit($form, &$form_state) {
+function search_admin_reset_submit($form, &$form_state) {
   // send the user to the confirmation page
-  $form_state['redirect'] = 'admin/config/search/settings/reindex';
-}
\ No newline at end of file
+  $form_state['redirect'] = 'admin/config/search/settings/reset';
+}
Index: modules/search/search.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.install,v
retrieving revision 1.26
diff -u -u -p -r1.26 search.install
--- modules/search/search.install	29 Sep 2009 15:13:56 -0000	1.26
+++ modules/search/search.install	10 Oct 2009 13:10:40 -0000
@@ -16,6 +16,34 @@ function search_uninstall() {
 }
 
 /**
+ * Implementation of hook_requirements.
+ */
+function search_requirements($phase) {
+  $requirements = array();
+
+  if ($phase == 'runtime') {
+    $t = get_t();
+    module_load_include('inc', 'search', 'search.admin');
+    $metrics = _search_get_status_metrics();
+    $requirements['search_index'] = array(
+      'title' => $t('Search index'),
+      'value' => $metrics['message'],
+    );
+    if ($metrics['remaining'] > 0) {
+      $requirements['search_index']['description'] =
+        $metrics['remaining'] == $metrics['total']
+            ? ($t('No items have been indexed yet. You can wait for the automatic indexing process or')
+                . ' ' . l(t('run cron manually'), 'admin/reports/status/run-cron') . '.')
+            : ($t('Search results are not complete, because some content has yet to be indexed.')
+                . ' ' . l(t('run cron manually'), 'admin/reports/status/run-cron'));
+      $requirements['search_index']['severity'] = REQUIREMENT_WARNING;
+    }
+  }
+
+  return $requirements;
+}
+
+/**
  * Implement hook_schema().
  */
 function search_schema() {
Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.319
diff -u -u -p -r1.319 search.module
--- modules/search/search.module	9 Oct 2009 01:00:02 -0000	1.319
+++ modules/search/search.module	10 Oct 2009 13:10:40 -0000
@@ -198,10 +198,10 @@ function search_menu() {
     'type' => MENU_NORMAL_ITEM,
     'file' => 'search.admin.inc',
   );
-  $items['admin/config/search/settings/reindex'] = array(
-    'title' => 'Clear index',
+  $items['admin/config/search/settings/reset'] = array(
+    'title' => 'Reset index',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('search_reindex_confirm'),
+    'page arguments' => array('search_reset_confirm'),
     'access arguments' => array('administer search'),
     'type' => MENU_CALLBACK,
     'file' => 'search.admin.inc',
@@ -674,7 +674,7 @@ function search_index($sid, $type, $text
       // Unset the link to mark it as processed.
       unset($links[$nid]);
     }
-    else {
+    else if ($nid != $sid) {
       // Insert the existing link and mark the node for reindexing.
       db_insert('search_node_links')
         ->fields(array(
Index: modules/system/system.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.css,v
retrieving revision 1.63
diff -u -u -p -r1.63 system.css
--- modules/system/system.css	21 Sep 2009 08:52:41 -0000	1.63
+++ modules/system/system.css	10 Oct 2009 13:10:40 -0000
@@ -436,6 +436,9 @@ html.js .no-js {
   height: 1.5em;
   margin: 0 0.2em;
 }
+.progress.inactive .bar {
+  background: none;
+}
 .progress .filled {
   background: #0072b9;
   height: 1em;
