Example #1
0
 /** 
  * Reindexes the search engine.
  */
 public function reindexAll($fullReindex = false)
 {
     Cache::disableLocalCache();
     $db = Loader::db();
     Loader::model('collection_attributes');
     if ($fullReindex) {
         $db->Execute("truncate table PageSearchIndex");
     }
     $pl = new PageList();
     $pl->ignoreAliases();
     $pl->ignorePermissions();
     $pl->sortByCollectionIDAscending();
     $pl->filter(false, '(c.cDateModified > psi.cDateLastIndexed or UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(psi.cDateLastIndexed) > ' . $this->searchReindexTimeout . ' or psi.cID is null or psi.cDateLastIndexed is null)');
     $pl->filter(false, '(ak_exclude_search_index is null or ak_exclude_search_index = 0)');
     $pages = $pl->get($this->searchBatchSize);
     $num = 0;
     foreach ($pages as $c) {
         // make sure something is approved
         $cv = $c->getVersionObject();
         if (!$cv->cvIsApproved) {
             continue;
         }
         $c->reindex($this, true);
         $num++;
         unset($c);
     }
     $pnum = Collection::reindexPendingPages();
     $num = $num + $pnum;
     Cache::enableLocalCache();
     $result = new stdClass();
     $result->count = $num;
     return $result;
 }
<?php

session_write_close();
defined('C5_EXECUTE') or die("Access Denied.");
if (Loader::helper('validation/token')->validate()) {
    Collection::reindexPendingPages();
} else {
    print "Access Denied.";
}