Пример #1
0
 /**
  * Return filters for a saved search.
  *
  * @param int $id Search hash
  *
  * @return mixed array of filters or false if the given search has no filters.
  */
 protected function getSearchSettings($id)
 {
     $search = $this->table->get('Search')->select(['finna_search_id' => $id])->current();
     if (empty($search)) {
         return false;
     }
     $sessId = $this->session->getId();
     if ($search->session_id == $sessId) {
         $minSO = $search->getSearchObject();
         $savedSearch = $minSO->deminify($this->results);
         $params = $savedSearch->getUrlQuery()->getParamArray();
         $settings = [];
         if (isset($params['filter'])) {
             $settings['filters'] = $params['filter'];
             $params = $savedSearch->getParams();
             if ($daterange = $params->getSpatialDateRangeFilter()) {
                 $daterangeField = $params->getSpatialDateRangeField();
                 foreach ($settings['filters'] as $filter) {
                     list($field, $val) = explode(':', $filter, 2);
                     if ($field == $daterangeField) {
                         $type = $daterange['type'];
                         $settings['params'] = ["{$daterangeField}_type" => $type];
                         break;
                     }
                 }
             }
         }
         $params = $savedSearch->getParams();
         if ($set = $params->getMetaLibSearchSet()) {
             $settings['params'] = ['set' => $set];
         }
         return $settings;
     }
     return false;
 }
Пример #2
0
 /**
  * Return filters for a saved search.
  *
  * @param int $id Search hash
  *
  * @return mixed array of filters or false if the given search has no filters.
  */
 protected function getSearchSettings($id)
 {
     $search = $this->table->get('Search')->select(['id' => $id])->current();
     if (empty($search)) {
         return false;
     }
     $sessId = $this->session->getId();
     if ($search->session_id == $sessId) {
         $minSO = $search->getSearchObject();
         $savedSearch = $minSO->deminify($this->results);
         $params = $savedSearch->getUrlQuery()->getParamArray();
         $settings = [];
         if (isset($params['filter'])) {
             $settings['filters'] = $params['filter'];
         }
         return $settings;
     }
     return false;
 }