Ejemplo n.º 1
0
 /**
  * Support method for performAndProcessSearch -- perform a search based on the
  * parameters passed to the object.
  *
  * @return void
  */
 protected function performSearch()
 {
     $sort = $this->getParams()->getSort();
     $sortNewestAddedFirst = $sort == 'id desc';
     if ($sortNewestAddedFirst) {
         // Set sort option to 'id' (ascending), since we reverse the
         // results to a descending (newest first) order (see below).
         $this->getParams()->setSort('id');
     }
     parent::performSearch();
     // Other sort options are handled in the database, but format is language-
     // specific
     if ($sort === 'format') {
         $records = [];
         foreach ($this->results as $result) {
             $formats = $result->getFormats();
             $format = end($formats);
             $format = $this->translate($format);
             $records[$format . '_' . $result->getUniqueID()] = $result;
         }
         ksort($records);
         $this->results = array_values($records);
     } else {
         if ($sortNewestAddedFirst) {
             $this->getParams()->setSort($sort);
             $this->results = array_reverse($this->results);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Support method for performAndProcessSearch -- perform a search based on the
  * parameters passed to the object.
  *
  * @return void
  */
 protected function performSearch()
 {
     parent::performSearch();
     $sort = $this->getParams()->getSort();
     // Other sort options are handled in the database, but format is language-
     // specific
     if ($sort === 'format') {
         $records = [];
         foreach ($this->results as $result) {
             $formats = $result->getFormats();
             $format = end($formats);
             $format = $this->translate($format);
             $records[$format . '_' . $result->getUniqueID()] = $result;
         }
         ksort($records);
         $this->results = array_values($records);
     }
 }