includes/paths.php
changeset 696 bd5069e1f19a
parent 692 78473351a6c9
child 741 a216e412c439
--- a/includes/paths.php	Sun Aug 17 23:24:18 2008 -0400
+++ b/includes/paths.php	Sun Aug 17 23:24:41 2008 -0400
@@ -803,6 +803,16 @@
     global $db, $session, $paths, $template, $plugins; // Common objects
     require_once(ENANO_ROOT . '/includes/search.php');
     
+    $progress = false;
+    if ( class_exists('ProgressBar') )
+    {
+      // CLI only.
+      $progress = new ProgressBar('Rebuilding search index: [', ']', 'Initializing...', 'green', 'blue', 'white', 'yellow');
+      $verbose = false;
+      $debug = false;
+      $progress->start();
+    }
+    
     @set_time_limit(0);
     
     $q = $db->sql_query('DELETE FROM ' . table_prefix . 'search_index;');
@@ -868,6 +878,11 @@
               echo ", mem = $mu...";
             flush();
           }
+          else if ( is_object($progress) )
+          {
+            $progress->update_text_quiet("$k/$num_pages {$row['namespace']}:{$row['page_id']}");
+            $progress->set($k, $num_pages);
+          }
           
           // skip this page if it's not supposed to be indexed
           if ( $row['visible'] == 0 )
@@ -943,6 +958,11 @@
         echo '<br />';
       echo "\n";
     }
+    else if ( is_object($progress) )
+    {
+      $progress->update_text('Complete.');
+      $progress->end();
+    }
     return true;
   }