/**
  * GetLabel
  *
  * @param Params $params Params
  *
  * @return string
  */
 public function getLabel(Params $params)
 {
     if ($params->getQuery() instanceof Query) {
         $type = strtolower($params->getQuery()->getHandler());
         if ($type !== 'allfields') {
             return 'adv_search_' . $type;
         }
     }
     return 'All_Fields';
 }
Example #2
0
 /**
  * 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)
 {
     // Turn on side facets in the search results:
     foreach ($this->facets as $name => $desc) {
         $params->addFacet($name, $desc);
     }
 }
Example #3
0
 /**
  * Add filters to the object based on values found in the request object.
  *
  * @param \Zend\StdLib\Parameters $request Parameter object representing user
  * request.
  *
  * @return void
  */
 protected function initFilters($request)
 {
     parent::initFilters($request);
     if ($set = $request->get('set', '')) {
         $this->removeAllFilters();
         $this->addFilter('metalib_set:' . $request->get('set', ''));
     }
 }
Example #4
0
 /**
  * Format a single filter for use in getFilterList().
  *
  * @param string $field     Field name
  * @param string $value     Field value
  * @param string $operator  Operator (AND/OR/NOT)
  * @param bool   $translate Should we translate the label?
  *
  * @return array
  */
 protected function formatFilterListEntry($field, $value, $operator, $translate)
 {
     $result = parent::formatFilterListEntry($field, $value, $operator, $translate);
     if (!$translate) {
         $result['displayText'] = $this->fixPrimoFacetValue($result['displayText']);
     }
     return $result;
 }
Example #5
0
 /**
  * Add filters to the object based on values found in the request object.
  *
  * @param \Zend\StdLib\Parameters $request Parameter object representing user
  * request.
  *
  * @return void
  */
 protected function initFilters($request)
 {
     // Special filter -- if the "id" parameter is set, limit to a specific list:
     $id = $request->get('id');
     if (!empty($id)) {
         $this->addFilter("lists:{$id}");
     }
     // Otherwise use standard parent behavior:
     return parent::initFilters($request);
 }
Example #6
0
 /**
  * Return HTTP parameters to render the current page with a different set
  * of search terms.
  *
  * @param string $lookfor New search terms
  * @param bool   $escape  Should we escape the string for use in the view?
  *
  * @return string
  */
 public function setSearchTerms($lookfor, $escape = true)
 {
     // If we're currently dealing with an advanced query, turn it off so
     // that it can be overridden:
     if ($this->params->getSearchType() == 'advanced') {
         $savedSuppressQuery = $this->suppressQuery;
         $this->suppressQuery = true;
     }
     // Generate the URL:
     $new = $this->updateQueryString($this->basicSearchParam, $lookfor, null, $escape, true);
     // Restore settings to their previous state:
     if (isset($savedSuppressQuery)) {
         $this->suppressQuery = $savedSuppressQuery;
     }
     return $new;
 }
Example #7
0
 /**
  * Get the tab configuration
  *
  * @param \VuFind\Search\Base\Params $params Search parameters
  *
  * @return array
  */
 public function getTabConfigForParams($params)
 {
     return $this->getTabConfig($params->getSearchClassId(), $params->getDisplayQuery(), $params->getSearchHandler(), $params->getSearchType(), $params->getHiddenFilters());
 }
Example #8
0
 /**
  * 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)
 {
     $this->issetFormat = $params->hasFilter($this->filter);
     $this->params = $request->toArray();
     // process params
     if (isset($this->params['daterange']) && is_array($this->params['daterange'])) {
         for ($i = 0; $i < count($this->params['daterange']); ++$i) {
             if ($this->params['daterange'][$i] == $this->filterName) {
                 unset($this->params['daterange'][$i]);
             }
         }
     }
     // remove daterange if it is empty
     if (empty($this->params['daterange'])) {
         unset($this->params['daterange']);
     }
     // save values
     $this->fromValue = $this->params[$this->filterName . 'from'];
     $this->toValue = $this->params[$this->filterName . 'to'];
     // remove values from params
     unset($this->params[$this->filterName . 'from']);
     unset($this->params[$this->filterName . 'to']);
 }
Example #9
0
 /**
  * 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)
 {
     // See if we can determine the label for the current search type; first
     // check for an override in the GET parameters, then look at the incoming
     // params object....
     $typeLabel = $request->get('typeLabel');
     $type = $request->get('type');
     if (empty($typeLabel) && !empty($type)) {
         $typeLabel = $params->getOptions()->getLabelForBasicHandler($type);
     }
     // Extract a search query:
     $lookfor = $request->get($this->requestParam);
     if (empty($lookfor) && is_object($params)) {
         $lookfor = $params->getQuery()->getAllTerms();
     }
     // Set up the callback to initialize the parameters:
     $limit = $this->limit;
     $callback = function ($runner, $params) use($lookfor, $limit, $typeLabel) {
         $params->setLimit($limit);
         $params->setBasicSearch($lookfor, $params->getOptions()->getHandlerForLabel($typeLabel));
     };
     // Perform the search:
     $this->results = $this->runner->run([], $this->getSearchClassId(), $callback);
 }
Example #10
0
 /**
  * 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');
         }
     }
 }
Example #11
0
 /**
  * Pull the search parameters
  *
  * @param \Zend\StdLib\Parameters $request Parameter object representing user
  * request.
  *
  * @return void
  */
 public function initFromRequest($request)
 {
     parent::initFromRequest($request);
     $this->metalibSearchSet = $request->get('set');
 }
Example #12
0
 /**
  * Format a single filter for use in getFilterList().
  *
  * @param string $field     Field name
  * @param string $value     Field value
  * @param string $operator  Operator (AND/OR/NOT)
  * @param bool   $translate Should we translate the label?
  *
  * @return array
  */
 protected function formatFilterListEntry($field, $value, $operator, $translate)
 {
     $filter = parent::formatFilterListEntry($field, $value, $operator, $translate);
     $hierarchicalFacets = $this->getOptions()->getHierarchicalFacets();
     $hierarchicalFacetSeparators = $this->getOptions()->getHierarchicalFacetSeparators();
     $facetHelper = null;
     if (!empty($hierarchicalFacets)) {
         $facetHelper = $this->getServiceLocator()->get('VuFind\\HierarchicalFacetHelper');
     }
     // Convert range queries to a language-non-specific format:
     $caseInsensitiveRegex = '/^\\(\\[(.*) TO (.*)\\] OR \\[(.*) TO (.*)\\]\\)$/';
     if (preg_match('/^\\[(.*) TO (.*)\\]$/', $value, $matches)) {
         // Simple case: [X TO Y]
         $filter['displayText'] = $matches[1] . '-' . $matches[2];
     } else {
         if (preg_match($caseInsensitiveRegex, $value, $matches)) {
             // Case insensitive case: [x TO y] OR [X TO Y]; convert
             // only if values in both ranges match up!
             if (strtolower($matches[3]) == strtolower($matches[1]) && strtolower($matches[4]) == strtolower($matches[2])) {
                 $filter['displayText'] = $matches[1] . '-' . $matches[2];
             }
         } else {
             if (in_array($field, $hierarchicalFacets)) {
                 // Display hierarchical facet levels nicely
                 $separator = isset($hierarchicalFacetSeparators[$field]) ? $hierarchicalFacetSeparators[$field] : '/';
                 $filter['displayText'] = $facetHelper->formatDisplayText($filter['displayText'], true, $separator);
             }
         }
     }
     return $filter;
 }
Example #13
0
 /**
  * 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)
 {
     // Turn on top facets in the search results:
     foreach ($this->facets as $name => $desc) {
         $params->addFacet($name, $desc, in_array($name, $this->orFacets));
     }
 }
Example #14
0
 /**
  * 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)
 {
     if ("retain" !== $this->mode) {
         $randomParams = $this->paramManager->get($params->getSearchClassId());
     } else {
         $randomParams = clone $params;
     }
     foreach ($this->filters as $filter) {
         $randomParams->addFilter($filter);
     }
     $query = $randomParams->getQuery();
     $paramBag = $randomParams->getBackendParameters();
     $this->results = $this->searchService->random($this->backend, $query, $this->limit, $paramBag)->getRecords();
 }
Example #15
0
 /**
  * Format a single filter for use in getFilterList().
  *
  * @param string $field     Field name
  * @param string $value     Field value
  * @param string $operator  Operator (AND/OR/NOT)
  * @param bool   $translate Should we translate the label?
  *
  * @return array
  */
 protected function formatFilterListEntry($field, $value, $operator, $translate)
 {
     $filter = parent::formatFilterListEntry($field, $value, $operator, $translate);
     // Convert range queries to a language-non-specific format:
     $caseInsensitiveRegex = '/^\\(\\[(.*) TO (.*)\\] OR \\[(.*) TO (.*)\\]\\)$/';
     if (preg_match('/^\\[(.*) TO (.*)\\]$/', $value, $matches)) {
         // Simple case: [X TO Y]
         $filter['displayText'] = $matches[1] . '-' . $matches[2];
     } else {
         if (preg_match($caseInsensitiveRegex, $value, $matches)) {
             // Case insensitive case: [x TO y] OR [X TO Y]; convert
             // only if values in both ranges match up!
             if (strtolower($matches[3]) == strtolower($matches[1]) && strtolower($matches[4]) == strtolower($matches[2])) {
                 $filter['displayText'] = $matches[1] . '-' . $matches[2];
             }
         }
     }
     return $filter;
 }
 /**
  * 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']);
         }
     }
 }
Example #17
0
 /**
  * Wrapper around rememberLastSettings() to extract key values from a
  * search Params object.
  *
  * @param \VuFind\Search\Base\Params $params Parameter object
  *
  * @return void
  */
 public function rememberParams(\VuFind\Search\Base\Params $params)
 {
     $settings = ['hiddenFilters' => $params->getHiddenFilters(), 'limit' => $params->getLimit(), 'sort' => $params->getSort(), 'view' => $params->getView()];
     // Special case: RSS view should not be persisted:
     if (strtolower($settings['view']) == 'rss') {
         unset($settings['view']);
     }
     $this->rememberLastSettings($params->getSearchClassId(), $settings);
 }
Example #18
0
 /**
  * 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)");
                 }
             }
         }
     }
 }
Example #19
0
 /**
  * Get information on the current state of the boolean checkbox facets.
  *
  * @return array
  */
 public function getCheckboxFacets()
 {
     // Grab checkbox facet details using the standard method:
     $facets = parent::getCheckboxFacets();
     // Special case -- if we have a "holdings only" facet, we want this to
     // always appear, even on the "no results" screen, since setting this
     // facet actually EXPANDS the result set, rather than reducing it:
     if (isset($facets['holdingsOnly'])) {
         $facets['holdingsOnly']['alwaysVisible'] = true;
     }
     // Return modified list:
     return $facets;
 }
Example #20
0
 /**
  * Add a field to facet on.
  *
  * @param string $newField Field name
  * @param string $newAlias Optional on-screen display label
  * @param bool   $ored     Should we treat this as an ORed facet?
  *
  * @return void
  */
 public function addFacet($newField, $newAlias = null, $ored = false)
 {
     // Save the full field name (which may include extra parameters);
     // we'll need these to do the proper search using the Summon class:
     if (strstr($newField, 'PublicationDate')) {
         // Special case -- we don't need to send this to the EDS API,
         // but we do need to set a flag so VuFind knows to display the
         // date facet control.
         $this->dateFacetSettings[] = 'PublicationDate';
     } else {
         $this->fullFacetSettings[] = $newField;
     }
     // Field name may have parameters attached -- remove them:
     $parts = explode(',', $newField);
     return parent::addFacet($parts[0], $newAlias, $ored);
 }
Example #21
0
 /**
  * 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)
 {
     // Turn on pivot facets:
     $params->setPivotFacets($this->facets);
 }
Example #22
0
 /**
  * Return record ids as a hidden filter list so that it is properly stored when
  * the search is represented as an URL or stored in the database.
  *
  * @return array
  */
 public function getHiddenFilters()
 {
     $filters = parent::getHiddenFilters();
     $filters['ids'] = [implode("\t", $this->recordsToRequest)];
     return $filters;
 }
Example #23
0
 /**
  * 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)
 {
     // Turn on side facets in the search results:
     foreach ($this->mainFacets as $name => $desc) {
         $params->addFacet($name, $desc, in_array($name, $this->orFacets));
     }
     foreach ($this->checkboxFacets as $name => $desc) {
         $params->addCheckboxFacet($name, $desc);
     }
 }
Example #24
0
 /**
  * Pull the search parameters
  *
  * @param \Zend\StdLib\Parameters $request Parameter object representing user
  * request.
  *
  * @return void
  */
 public function initFromRequest($request)
 {
     parent::initFromRequest($request);
     $this->fuzzy = 'true' == $request->get('fuzzy', 'false');
 }
Example #25
0
 /**
  * Add filters to the object based on values found in the request object.
  *
  * @param \Zend\StdLib\Parameters $request Parameter object representing user
  * request.
  *
  * @return void
  */
 protected function initFilters($request)
 {
     // Use the default behavior of the parent class, but add support for the
     // special illustrations filter.
     parent::initFilters($request);
     switch ($request->get('illustration', -1)) {
         case 1:
             $this->addFilter('illustrated:Illustrated');
             break;
         case 0:
             $this->addFilter('illustrated:"Not Illustrated"');
             break;
     }
     // Check for hidden filters:
     $hidden = $request->get('hiddenFilters');
     if (!empty($hidden) && is_array($hidden)) {
         foreach ($hidden as $current) {
             $this->getOptions()->addHiddenFilter($current);
         }
     }
 }