コード例 #1
0
ファイル: Params.php プロジェクト: grharry/vufind
 /**
  * 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;
 }
コード例 #2
0
ファイル: Params.php プロジェクト: htw-pk15/vufind
 /**
  * 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;
 }
コード例 #3
0
ファイル: Params.php プロジェクト: datavoyager/vufind
 /**
  * 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;
 }