| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | namespace ApacheSolrForTypo3\Solr\Query\Modifier; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | /*************************************************************** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  *  Copyright notice | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  *  (c) 2009-2015 Ingo Renner <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  *  All rights reserved | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  *  This script is part of the TYPO3 project. The TYPO3 project is | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  *  free software; you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  *  it under the terms of the GNU General Public License as published by | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  *  the Free Software Foundation; either version 2 of the License, or | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  *  (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  *  The GNU General Public License can be found at | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  *  http://www.gnu.org/copyleft/gpl.html. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  *  This script is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  *  but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  *  GNU General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  *  This copyright notice MUST APPEAR in all copies of the script! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  ***************************************************************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\FacetRegistry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequestAware; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use ApacheSolrForTypo3\Solr\Query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use TYPO3\CMS\Core\Utility\GeneralUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use TYPO3\CMS\Extbase\Object\ObjectManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * Modifies a query to add faceting parameters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  * @author Ingo Renner <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  * @author Daniel Poetzinger <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  * @author Sebastian Kurfuerst <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | class Faceting implements Modifier, SearchRequestAware | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @var FacetRegistry | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     protected $facetRegistry = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * @var SearchRequest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     protected $searchRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * @param FacetRegistry $facetRegistry | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     public function __construct(FacetRegistry $facetRegistry = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $objectManager = GeneralUtility::makeInstance(ObjectManager::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->facetRegistry = is_null($facetRegistry) ? $objectManager->get(FacetRegistry::class) : $facetRegistry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @param SearchRequest $searchRequest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     public function setSearchRequest(SearchRequest $searchRequest) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 29 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->searchRequest = $searchRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 29 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 7 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 22 |  |      * Modifies the given query and adds the parameters necessary for faceted | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      * search. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 29 |  |      * @param Query $query The query to modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 29 |  |      * @return Query The modified query with faceting parameters | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 78 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 79 | 29 |  |     public function modifyQuery(Query $query) | 
            
                                                                        
                            
            
                                    
            
            
                | 80 | 29 |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |         $query->getFaceting()->setIsEnabled(true); | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |         $typoScriptConfiguration = $this->searchRequest->getContextTypoScriptConfiguration(); | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |         $allFacets = $typoScriptConfiguration->getSearchFacetingFacets(); | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |         $facetParameters = $this->buildFacetingParameters($allFacets, $typoScriptConfiguration); | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |         foreach ($facetParameters as $facetParameter => $value) { | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |             if(strtolower($facetParameter) === 'facet.field') { | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |                 $query->getFaceting()->setFields($value); | 
            
                                                                        
                            
            
                                    
            
            
                | 89 | 29 |  |             } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |                 $query->getFaceting()->addAdditionalParameter($facetParameter, $value); | 
            
                                                                        
                            
            
                                    
            
            
                | 91 | 29 |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 92 | 29 |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 93 | 29 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |         $searchArguments = $this->searchRequest->getArguments(); | 
            
                                                                        
                            
            
                                    
            
            
                | 95 | 29 |  |         if (!is_array($searchArguments)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 96 | 29 |  |             return $query; | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 99 | 29 |  |         $keepAllOptionsOnSelection = $typoScriptConfiguration->getSearchFacetingKeepAllFacetsOnSelection(); | 
            
                                                                        
                            
            
                                    
            
            
                | 100 | 3 |  |         $facetFilters = $this->addFacetQueryFilters($searchArguments, $allFacets, $keepAllOptionsOnSelection); | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |         foreach ($facetFilters as $filter) { | 
            
                                                                        
                            
            
                                    
            
            
                | 103 | 29 |  |             $query->getFilters()->add($filter); | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |         return $query; | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * Delegates the parameter building to specialized functions depending on | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 | 29 |  |      * the type of facet to add. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 29 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 29 |  |     protected function buildFacetingParameters($allFacets, TypoScriptConfiguration $typoScriptConfiguration) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 29 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 29 |  |         $facetParameters = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 29 |  |         foreach ($allFacets as $facetName => $facetConfiguration) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             $facetName = substr($facetName, 0, -1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |             $type = isset($facetConfiguration['type']) ? $facetConfiguration['type'] : 'options'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             $facetParameterBuilder = $this->facetRegistry->getPackage($type)->getQueryBuilder(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 29 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 29 |  |             if (is_null($facetParameterBuilder)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                 throw new \InvalidArgumentException('No query build configured for facet ' . htmlspecialchars($facetName)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 29 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |             $facetParameters = array_merge_recursive($facetParameters, $facetParameterBuilder->build($facetName, $typoScriptConfiguration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         return $facetParameters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 29 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * Adds filters specified through HTTP GET as filter query parameters to | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 | 29 |  |      * the Solr query. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      * @param array $resultParameters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      * @param array $allFacets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 29 |  |      * @param bool $keepAllOptionsOnSelection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 | 3 |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 3 |  |     protected function addFacetQueryFilters($resultParameters, $allFacets, $keepAllOptionsOnSelection) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         $facetFilters = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         if (!is_array($resultParameters['filter'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 | 3 |  |             return $facetFilters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 | 3 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 3 |  |         $filtersByFacetName = $this->getFiltersByFacetName($resultParameters, $allFacets); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 | 3 |  |         foreach ($filtersByFacetName as $facetName => $filterValues) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 | 3 |  |             $facetConfiguration = $allFacets[$facetName . '.']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |             $type = isset($facetConfiguration['type']) ? $facetConfiguration['type'] : 'options'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |             $filterEncoder = $this->facetRegistry->getPackage($type)->getUrlDecoder(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 | 3 |  |             if (is_null($filterEncoder)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 | 3 |  |                 throw new \InvalidArgumentException('No encoder configured for facet ' . htmlspecialchars($facetName)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 | 3 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 | 3 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             $tag = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 | 3 |  |             if ($facetConfiguration['keepAllOptionsOnSelection'] == 1 || $keepAllOptionsOnSelection) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |                 $tag = '{!tag=' . addslashes($facetConfiguration['field']) . '}'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 | 3 |  |             $filterParts = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 | 3 |  |             foreach ($filterValues as $filterValue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 | 2 |  |                 $filterOptions = $facetConfiguration[$facetConfiguration['type'] . '.']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |                 if (empty($filterOptions)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |                     $filterOptions = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 | 3 |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 | 3 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 3 |  |                 $filterValue = $filterEncoder->decode($filterValue, $filterOptions); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 | 3 |  |                 $filterParts[] = $facetConfiguration['field'] . ':' . $filterValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 3 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             $operator = ($facetConfiguration['operator'] == 'OR') ? ' OR ' : ' AND '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 | 3 |  |             $facetFilters[] = $tag . '(' . implode($operator, $filterParts) . ')'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 | 3 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         return $facetFilters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 | 3 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 | 3 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      * Groups facet values by facet name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 | 29 |  |      * @param array $resultParameters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |      * @param array $allFacets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     protected function getFiltersByFacetName($resultParameters, $allFacets) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         // format for filter URL parameter: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 | 3 |  |         // tx_solr[filter]=$facetName0:$facetValue0,$facetName1:$facetValue1,$facetName2:$facetValue2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         $filters = array_map('urldecode', $resultParameters['filter']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 | 3 |  |         // $filters look like ['name:value1','name:value2','fieldname2:foo'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         $configuredFacets = $this->getFacetNamesWithConfiguredField($allFacets); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 | 3 |  |         // first group the filters by facetName - so that we can | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 | 3 |  |         // decide later whether we need to do AND or OR for multiple | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         // filters for a certain facet/field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 | 3 |  |         // $filtersByFacetName look like ['name' =>  ['value1', 'value2'], 'fieldname2' => ['foo']] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         $filtersByFacetName = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         foreach ($filters as $filter) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |             // only split by the first colon to allow using colons in the filter value itself | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |             list($filterFacetName, $filterValue) = explode(':', $filter, 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 | 3 |  |             if (in_array($filterFacetName, $configuredFacets)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |                 $filtersByFacetName[$filterFacetName][] = $filterValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 | 3 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         return $filtersByFacetName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * Gets the facets as configured through TypoScript | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      * @param array $allFacets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |      * @return array An array of facet names as specified in TypoScript | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |     protected function getFacetNamesWithConfiguredField(array $allFacets) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         $facets = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         foreach ($allFacets as $facetName => $facetConfiguration) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             $facetName = substr($facetName, 0, -1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             if (empty($facetConfiguration['field'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |                 // TODO later check for query and date, too | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |                 continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |             $facets[] = $facetName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         return $facets; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 235 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 236 |  |  |  |