/** * init * * Called at the end of the Search Params objects' initFromRequest() method. * This method is responsible for setting search parameters needed by the * recommendation module and for reading any existing search parameters that may * be needed. * * @param \VuFind\Search\Base\Params $params Search parameter object * @param \Zend\StdLib\Parameters $request Parameter object representing user * request. * * @return void */ public function init($params, $request) { $filters = $params->getFilters(); foreach ($filters as $key => $value) { if ($key == $this->geoField) { $match = array(); if (preg_match('/Intersects\\(([0-9 \\-\\.]+)\\)/', $value[0], $match)) { $this->selectedCoordinates = explode(' ', $match[1]); $coords = $match[1]; $params->addBoostFunction("geo_overlap('{$coords}', bbox_geo_str)"); } else { if (preg_match($this->polygonMatch, $value[0], $match)) { $this->selectedCoordinates = [$match[1], $match[2], $match[3], $match[4]]; $coords = $match[1] . ' ' . $match[2] . ' ' . $match[3] . ' ' . $match[4]; $params->addBoostFunction("geo_overlap('{$coords}', bbox_geo_str)"); } } } } }
/** * Get an array of URL parameters. * * @return array */ public function getParamArray() { $params = $this->defaultParams; // Build all the URL parameters based on search object settings: if (!$this->suppressQuery) { if ($this->params->getSearchType() == 'advanced') { $query = $this->params->getQuery(); if ($query instanceof QueryGroup) { $params['join'] = $query->getOperator(); foreach ($query->getQueries() as $i => $current) { if ($current instanceof QueryGroup) { $operator = $current->isNegated() ? 'NOT' : $current->getOperator(); $params['bool' . $i] = [$operator]; foreach ($current->getQueries() as $inner) { if (!isset($params['lookfor' . $i])) { $params['lookfor' . $i] = []; } if (!isset($params['type' . $i])) { $params['type' . $i] = []; } $params['lookfor' . $i][] = $inner->getString(); $params['type' . $i][] = $inner->getHandler(); if (null !== ($op = $inner->getOperator())) { $params['op' . $i][] = $op; } } } else { throw new \Exception('Unexpected Query object.'); } } } else { throw new \Exception('Unexpected Query object.'); } } else { $search = $this->params->getDisplayQuery(); if (!empty($search)) { $params[$this->basicSearchParam] = $search; } $type = $this->params->getSearchHandler(); if (!empty($type)) { $params['type'] = $type; } } } $sort = $this->params->getSort(); if (!is_null($sort) && $sort != $this->params->getDefaultSort()) { $params['sort'] = $sort; } $limit = $this->params->getLimit(); if (!is_null($limit) && $limit != $this->options->getDefaultLimit()) { $params['limit'] = $limit; } $view = $this->params->getView(); if (!is_null($view) && $view != $this->options->getDefaultView()) { $params['view'] = $view; } if ($this->params->getPage() != 1) { $params['page'] = $this->params->getPage(); } $filters = $this->params->getFilters(); if (!empty($filters)) { $params['filter'] = []; foreach ($filters as $field => $values) { foreach ($values as $current) { $params['filter'][] = $field . ':"' . $current . '"'; } } } $hiddenFilters = $this->params->getHiddenFilters(); if (!empty($hiddenFilters)) { foreach ($hiddenFilters as $field => $values) { foreach ($values as $current) { $params['hiddenFilters'][] = $field . ':"' . $current . '"'; } } } $shards = $this->params->getSelectedShards(); if (!empty($shards)) { sort($shards); $defaultShards = $this->options->getDefaultSelectedShards(); sort($defaultShards); if (implode(':::', $shards) != implode(':::', $defaultShards)) { $params['shard'] = $shards; } } if ($this->params->hasDefaultsApplied()) { $params['dfApplied'] = 1; } return $params; }
/** * init * * Called at the end of the Search Params objects' initFromRequest() method. * This method is responsible for setting search parameters needed by the * recommendation module and for reading any existing search parameters that may * be needed. * * @param \VuFind\Search\Base\Params $params Search parameter object * @param \Zend\StdLib\Parameters $request Parameter object representing user * request. * * @return void */ public function init($params, $request) { $filters = $params->getFilters(); foreach ($filters as $key => $value) { if ($key == $this->dateField) { $this->selectedDateRange = $value[0]; $params->addFacet($this->dateField, 'New acquisitions since'); } } }
/** * init * * Called at the end of the Search Params objects' initFromRequest() method. * This method is responsible for setting search parameters needed by the * recommendation module and for reading any existing search parameters that may * be needed. * * @param \VuFind\Search\Base\Params $params Search parameter object * @param \Zend\StdLib\Parameters $request Parameter object representing user * request. * * @return void */ public function init($params, $request) { $filters = $params->getFilters(); foreach ($filters as $key => $value) { if (isset($this->config[$key])) { $expFacet = $this->config[$key]; $params->addFacet($expFacet['field'], $expFacet['label']); } } }