Пример #1
0
 /**
  * documentByTypeTask - view a type's records
  * 
  * @access public
  * @return void
  */
 public function documentByTypeTask()
 {
     $type = Request::getVar('type', '');
     $filter = Request::getVar('filter', '');
     $limitstart = Request::getInt('limitstart', 0);
     $limit = Request::getInt('limit', 10);
     // Display CMS errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Get the blacklist to indidicate marked for removal
     $blacklistEntries = Blacklist::all()->select('doc_id')->where('doc_id', 'LIKE', $type . '%')->rows()->toObject();
     // @TODO: PHP 5.5+ supports array_column()
     $blacklist = array();
     foreach ($blacklistEntries as $entry) {
         array_push($blacklist, $entry->doc_id);
     }
     // Temporary override to get all matching documents
     if ($filter == '') {
         $filter = '*:*';
     }
     // Instantitate and get all results for a particular document type
     try {
         $config = Component::params('com_search');
         $query = new \Hubzero\Search\Query($config);
         $results = $query->query($filter)->addFilter('hubtype', array('hubtype', '=', $type))->limit($limit)->start($limitstart)->run()->getResults();
         // Get the total number of records
         $total = $query->getNumFound();
     } catch (\Solarium\Exception\HttpException $e) {
         App::redirect(Route::url('index.php?option=com_search&task=display', false));
     }
     // Pass the type the view
     $this->view->type = $type;
     // Create the pagination
     $pagination = new \Hubzero\Pagination\Paginator($total, $limitstart, $limit);
     $pagination->setLimits(array('5', '10', '15', '20', '50', '100', '200'));
     $this->view->pagination = $pagination;
     // Pass the filters and documents to the display
     $this->view->filter = !isset($filter) || ($filter = '*:*' ? '' : $filter);
     $this->view->documents = isset($results) ? $results : array();
     $this->view->blacklist = $blacklist;
     // Display the view
     $this->view->display();
 }