Exemplo n.º 1
0
 /**
  * Process the index queue
  *
  * @museDescription  Processes the index queue
  *
  * @return  void
  **/
 public function processQueue()
 {
     require_once PATH_CORE . DS . 'components' . DS . 'com_search' . DS . 'models' . DS . 'indexqueue.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_search' . DS . 'models' . DS . 'blacklist.php';
     // Get the type needed to be indexed;
     $items = \Components\Search\Models\QueueDB::all()->where('status', '=', 0)->limit(100)->rows();
     // Refresh indexed material if no work to do
     if ($items->count() <= 0) {
         $items = \Components\Search\Models\QueueDB::all()->where('status', '=', 1)->where('action', '=', 'index')->order('modified', 'ASC')->limit(100)->rows();
     }
     // Get the blacklist
     $sql = "SELECT doc_id FROM #__search_blacklist;";
     $db = App::get('db');
     $db->setQuery($sql);
     $blacklist = $db->query()->loadColumn();
     foreach ($items as $item) {
         $format = Event::trigger('search.onIndex', array($item->type, $item->type_id, true));
         if (isset($format[0])) {
             $this->processRows($format[0], $item->action, $blacklist);
             $timestamp = \Hubzero\Utility\Date::of()->toSql();
             $item->set('modified', $timestamp);
             $item->set('status', 1);
         } else {
             $item->set('status', '2');
         }
         $item->save();
     }
 }
Exemplo n.º 2
0
 /**
  * searchIndexTask - displays all indexed hubtypes and the number of records
  * 
  * @access public
  * @return void
  */
 public function searchIndexTask()
 {
     // Display CMS errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     $config = Component::params('com_search');
     $hubtypes = Event::trigger('search.onGetTypes');
     $queue = QueueDB::all()->rows();
     $stats = array();
     try {
         foreach ($hubtypes as $type) {
             $query = new \Hubzero\Search\Query($config);
             $result = $query->query('*:*')->addFilter('hubtype', array('hubtype', '=', $type))->run()->getNumFound();
             $stats[$type] = $result;
         }
     } catch (\Solarium\Exception\HttpException $e) {
         App::redirect(Route::url('index.php?option=com_search&task=display', false));
     }
     // Display the view
     $this->view->types = $hubtypes;
     $this->view->stats = $stats;
     $this->view->queue = $queue;
     $this->view->display();
 }