includes/paths.php
changeset 698 40f9528b6348
parent 696 bd5069e1f19a
child 741 a216e412c439
equal deleted inserted replaced
697:8e9ba8b131fa 698:40f9528b6348
   801   function rebuild_search_index($verbose = false, $debug = false)
   801   function rebuild_search_index($verbose = false, $debug = false)
   802   {
   802   {
   803     global $db, $session, $paths, $template, $plugins; // Common objects
   803     global $db, $session, $paths, $template, $plugins; // Common objects
   804     require_once(ENANO_ROOT . '/includes/search.php');
   804     require_once(ENANO_ROOT . '/includes/search.php');
   805     
   805     
       
   806     $progress = false;
       
   807     if ( class_exists('ProgressBar') )
       
   808     {
       
   809       // CLI only.
       
   810       $progress = new ProgressBar('Rebuilding search index: [', ']', 'Initializing...', 'green', 'blue', 'white', 'yellow');
       
   811       $verbose = false;
       
   812       $debug = false;
       
   813       $progress->start();
       
   814     }
       
   815     
   806     @set_time_limit(0);
   816     @set_time_limit(0);
   807     
   817     
   808     $q = $db->sql_query('DELETE FROM ' . table_prefix . 'search_index;');
   818     $q = $db->sql_query('DELETE FROM ' . table_prefix . 'search_index;');
   809     if ( !$q )
   819     if ( !$q )
   810       $db->_die();
   820       $db->_die();
   865             $mu = memory_get_usage();
   875             $mu = memory_get_usage();
   866             echo "  Indexing page $k of $num_pages: {$row['namespace']}:{$row['page_id']}";
   876             echo "  Indexing page $k of $num_pages: {$row['namespace']}:{$row['page_id']}";
   867             if ( $debug )
   877             if ( $debug )
   868               echo ", mem = $mu...";
   878               echo ", mem = $mu...";
   869             flush();
   879             flush();
       
   880           }
       
   881           else if ( is_object($progress) )
       
   882           {
       
   883             $progress->update_text_quiet("$k/$num_pages {$row['namespace']}:{$row['page_id']}");
       
   884             $progress->set($k, $num_pages);
   870           }
   885           }
   871           
   886           
   872           // skip this page if it's not supposed to be indexed
   887           // skip this page if it's not supposed to be indexed
   873           if ( $row['visible'] == 0 )
   888           if ( $row['visible'] == 0 )
   874           {
   889           {
   941       echo "Indexing complete.";
   956       echo "Indexing complete.";
   942       if ( isset($_SERVER['REQUEST_URI']) )
   957       if ( isset($_SERVER['REQUEST_URI']) )
   943         echo '<br />';
   958         echo '<br />';
   944       echo "\n";
   959       echo "\n";
   945     }
   960     }
       
   961     else if ( is_object($progress) )
       
   962     {
       
   963       $progress->update_text('Complete.');
       
   964       $progress->end();
       
   965     }
   946     return true;
   966     return true;
   947   }
   967   }
   948   
   968   
   949   /**
   969   /**
   950    * Partially rebuilds the search index, removing/inserting entries only for the current page
   970    * Partially rebuilds the search index, removing/inserting entries only for the current page