Example #1
0
 /**
  * Convert a single Query object to an eds api query array
  *
  * @param Query  $query    Query to convert
  * @param string $operator Operator to apply
  *
  * @return string
  */
 protected function queryToEdsQuery(Query $query, $operator = 'AND')
 {
     $expression = str_replace('"', '', $query->getString());
     $expression = SearchRequestModel::escapeSpecialCharacters($expression);
     $fieldCode = $query->getHandler() == 'AllFields' ? '' : $query->getHandler();
     //fieldcode
     if (!empty($fieldCode)) {
         $expression = $fieldCode . ':' . $expression;
     }
     if (!empty($operator)) {
         $expression = $operator . ',' . $expression;
     }
     return $expression;
 }
Example #2
0
 /**
  * Set up limiter based on VuFind settings.
  *
  * @param ParamBag $params Parameter collection to update
  *
  * @return void
  */
 public function createBackendLimiterParameters(ParamBag $params)
 {
     //group limiters with same id together
     $edsLimiters = [];
     foreach ($this->limiters as $limiter) {
         if (isset($limiter) && !empty($limiter)) {
             // split the id/value
             list($key, $value) = explode(':', $limiter, 2);
             $value = SearchRequestModel::escapeSpecialCharacters($value);
             $edsLimiters[$key] = !isset($edsLimiters[$key]) ? $value : $edsLimiters[$key] . ',' . $value;
         }
     }
     if (!empty($edsLimiters)) {
         foreach ($edsLimiters as $key => $value) {
             $params->add('limiters', $key . ':' . $value);
         }
     }
 }