Passed
Pull Request — master (#123)
by Sebastian
09:16
created
Classes/Controller/SearchController.php 3 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
         }
109 109
 
110 110
         // sanitize date search input
111
-        if(empty($this->searchParams['dateFrom']) && !empty($this->searchParams['dateTo'])) {
111
+        if (empty($this->searchParams['dateFrom']) && !empty($this->searchParams['dateTo'])) {
112 112
             $this->searchParams['dateFrom'] = '*';
113 113
         }
114
-        if(empty($this->searchParams['dateTo']) && !empty($this->searchParams['dateFrom'])) {
114
+        if (empty($this->searchParams['dateTo']) && !empty($this->searchParams['dateFrom'])) {
115 115
             $this->searchParams['dateTo'] = 'NOW';
116 116
         }
117
-        if($this->searchParams['dateFrom'] > $this->searchParams['dateTo']) {
117
+        if ($this->searchParams['dateFrom'] > $this->searchParams['dateTo']) {
118 118
             $tmpDate = $this->searchParams['dateFrom'];
119 119
             $this->searchParams['dateFrom'] = $this->searchParams['dateTo'];
120 120
             $this->searchParams['dateTo'] = $tmpDate;
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
         // Add uHash parameter to suggest parameter to make a basic protection of this form.
177 177
         if ($this->settings['suggest']) {
178
-            $this->view->assign('uHash', GeneralUtility::hmac((string) (new Typo3Version()) . Environment::getExtensionsPath(), 'SearchSuggest'));
178
+            $this->view->assign('uHash', GeneralUtility::hmac((string) (new Typo3Version()).Environment::getExtensionsPath(), 'SearchSuggest'));
179 179
         }
180 180
 
181 181
         $this->view->assign('viewData', $this->viewData);
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         // Get facets from plugin configuration.
199 199
         $facets = [];
200 200
         foreach (GeneralUtility::trimExplode(',', $this->settings['facets'], true) as $facet) {
201
-            $facets[$facet . '_faceting'] = Helper::translate($facet, 'tx_dlf_metadata', $this->settings['storagePid']);
201
+            $facets[$facet.'_faceting'] = Helper::translate($facet, 'tx_dlf_metadata', $this->settings['storagePid']);
202 202
         }
203 203
 
204 204
         $this->view->assign('facetsMenu', $this->makeFacetsMenuArray($facets));
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
         $searchParams = $this->searchParams;
241 241
         if (
242 242
             (!empty($searchParams['fulltext']))
243
-            || preg_match('/' . $fields['fulltext'] . ':\((.*)\)/', trim($searchParams['query']), $matches)
243
+            || preg_match('/'.$fields['fulltext'].':\((.*)\)/', trim($searchParams['query']), $matches)
244 244
         ) {
245 245
             // If the query already is a fulltext query e.g using the facets
246 246
             $searchParams['query'] = empty($matches[1]) ? $searchParams['query'] : $matches[1];
247 247
             // Search in fulltext field if applicable. Query must not be empty!
248 248
             if (!empty($this->searchParams['query'])) {
249
-                $search['query'] = $fields['fulltext'] . ':(' . Solr::escapeQuery(trim($searchParams['query'])) . ')';
249
+                $search['query'] = $fields['fulltext'].':('.Solr::escapeQuery(trim($searchParams['query'])).')';
250 250
             }
251 251
         } else {
252 252
             // Retain given search field if valid.
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         // extract collections from collection parameter
260 260
         $collection = null;
261 261
         if ($this->searchParams['collection']) {
262
-            foreach(explode(',', $this->searchParams['collection']) as $collectionEntry) {
262
+            foreach (explode(',', $this->searchParams['collection']) as $collectionEntry) {
263 263
                 $collection[] = $this->collectionRepository->findByUid($collectionEntry);
264 264
             }
265 265
             
@@ -269,26 +269,26 @@  discard block
 block discarded – undo
269 269
             $virtualCollectionsQueryString = '';
270 270
             foreach ($collection as $collectionEntry) {
271 271
                 // check for virtual collections query string
272
-                if($collectionEntry->getIndexSearch()) {
273
-                    $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '(' . $collectionEntry->getIndexSearch() . ')' : ' OR ('. $collectionEntry->getIndexSearch() . ')' ;
272
+                if ($collectionEntry->getIndexSearch()) {
273
+                    $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '('.$collectionEntry->getIndexSearch().')' : ' OR ('.$collectionEntry->getIndexSearch().')';
274 274
                 }
275 275
                 else {
276
-                    $collectionsQueryString .= empty($collectionsQueryString) ? '"' . $collectionEntry->getIndexName() . '"' : ' OR "' . $collectionEntry->getIndexName() . '"';
276
+                    $collectionsQueryString .= empty($collectionsQueryString) ? '"'.$collectionEntry->getIndexName().'"' : ' OR "'.$collectionEntry->getIndexName().'"';
277 277
                 }
278 278
             }
279 279
             
280 280
             // distinguish between simple collection browsing and actual searching within the collection(s)
281
-            if(!empty($collectionsQueryString)) {
282
-                if(empty($searchParams['query'])) {
283
-                    $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . ') AND toplevel:true AND partof:0)';
281
+            if (!empty($collectionsQueryString)) {
282
+                if (empty($searchParams['query'])) {
283
+                    $collectionsQueryString = '(collection_faceting:('.$collectionsQueryString.') AND toplevel:true AND partof:0)';
284 284
                 } else {
285
-                    $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . '))';
285
+                    $collectionsQueryString = '(collection_faceting:('.$collectionsQueryString.'))';
286 286
                 }
287 287
             }
288 288
 
289 289
             // virtual collections might query documents that are neither toplevel:true nor partof:0 and need to be searched separatly
290
-            if(!empty($virtualCollectionsQueryString)) {
291
-                $virtualCollectionsQueryString = '(' . $virtualCollectionsQueryString . ')';
290
+            if (!empty($virtualCollectionsQueryString)) {
291
+                $virtualCollectionsQueryString = '('.$virtualCollectionsQueryString.')';
292 292
             }
293 293
 
294 294
             // combine both querystrings into a single filterquery via OR if both are given, otherwise pass either of those
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         // add filter query for date search
299 299
         if (!empty($this->searchParams['dateFrom']) && !empty($this->searchParams['dateTo'])) {
300 300
             // combine dateFrom and dateTo into filterquery as range search
301
-            $search['params']['filterquery'][]['query'] = '{!join from=' . $fields['uid'] . ' to=' . $fields['uid'] . '}' . $fields['date'] . ':[' . $this->searchParams['dateFrom'] . ' TO ' . $this->searchParams['dateTo'] . ']';
301
+            $search['params']['filterquery'][]['query'] = '{!join from='.$fields['uid'].' to='.$fields['uid'].'}'.$fields['date'].':['.$this->searchParams['dateFrom'].' TO '.$this->searchParams['dateTo'].']';
302 302
         }
303 303
 
304 304
         // Add extended search query.
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
316 316
                         in_array($searchParams['extOperator'][$i], $allowedOperators)
317 317
                     ) {
318 318
                         if (!empty($search['query'])) {
319
-                            $search['query'] .= ' ' . $searchParams['extOperator'][$i] . ' ';
319
+                            $search['query'] .= ' '.$searchParams['extOperator'][$i].' ';
320 320
                         }
321
-                        $search['query'] .= Indexer::getIndexFieldName($searchParams['extField'][$i], $this->settings['storagePid']) . ':(' . Solr::escapeQuery($searchParams['extQuery'][$i]) . ')';
321
+                        $search['query'] .= Indexer::getIndexFieldName($searchParams['extField'][$i], $this->settings['storagePid']).':('.Solr::escapeQuery($searchParams['extQuery'][$i]).')';
322 322
                     }
323 323
                 }
324 324
             }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
         $entryArray['doNotLinkIt'] = 0;
445 445
         // Check if facet is already selected.
446 446
         $queryColumn = array_column($search['params']['filterquery'], 'query');
447
-        $index = array_search($field . ':("' . Solr::escapeQuery($value) . '")', $queryColumn);
447
+        $index = array_search($field.':("'.Solr::escapeQuery($value).'")', $queryColumn);
448 448
         if ($index !== false) {
449 449
             // Facet is selected, thus remove it from filter.
450 450
             unset($queryColumn[$index]);
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             }
459 459
         } else {
460 460
             // Facet is not selected, thus add it to filter.
461
-            $queryColumn[] = $field . ':("' . Solr::escapeQuery($value) . '")';
461
+            $queryColumn[] = $field.':("'.Solr::escapeQuery($value).'")';
462 462
             $entryArray['ITEM_STATE'] = 'NO';
463 463
         }
464 464
         $entryArray['queryColumn'] = $queryColumn;
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@  discard block
 block discarded – undo
32 32
  * @subpackage dlf
33 33
  * @access public
34 34
  */
35
-class SearchController extends AbstractController
36
-{
35
+class SearchController extends AbstractController {
37 36
     /**
38 37
      * @var CollectionRepository
39 38
      */
@@ -42,8 +41,7 @@  discard block
 block discarded – undo
42 41
     /**
43 42
      * @param CollectionRepository $collectionRepository
44 43
      */
45
-    public function injectCollectionRepository(CollectionRepository $collectionRepository)
46
-    {
44
+    public function injectCollectionRepository(CollectionRepository $collectionRepository) {
47 45
         $this->collectionRepository = $collectionRepository;
48 46
     }
49 47
 
@@ -55,8 +53,7 @@  discard block
 block discarded – undo
55 53
     /**
56 54
      * @param MetadataRepository $metadataRepository
57 55
      */
58
-    public function injectMetadataRepository(MetadataRepository $metadataRepository)
59
-    {
56
+    public function injectMetadataRepository(MetadataRepository $metadataRepository) {
60 57
         $this->metadataRepository = $metadataRepository;
61 58
     }
62 59
 
@@ -71,8 +68,7 @@  discard block
 block discarded – undo
71 68
      *
72 69
      * @return void
73 70
      */
74
-    public function searchAction()
75
-    {
71
+    public function searchAction() {
76 72
         // if search was triggered, get search parameters from POST variables
77 73
         $this->searchParams = $this->getParametersSafely('searchParameter');
78 74
 
@@ -87,8 +83,7 @@  discard block
 block discarded – undo
87 83
      *
88 84
      * @return void
89 85
      */
90
-    public function mainAction()
91
-    {
86
+    public function mainAction() {
92 87
         $listViewSearch = false;
93 88
         // Quit without doing anything if required variables are not set.
94 89
         if (empty($this->settings['solrcore'])) {
@@ -188,8 +183,7 @@  discard block
 block discarded – undo
188 183
      *
189 184
      * @return string HTML output of facets menu
190 185
      */
191
-    protected function addFacetsMenu()
192
-    {
186
+    protected function addFacetsMenu() {
193 187
         // Quit without doing anything if no facets are configured.
194 188
         if (empty($this->settings['facets']) && empty($this->settings['facetCollections'])) {
195 189
             return '';
@@ -214,8 +208,7 @@  discard block
 block discarded – undo
214 208
      *
215 209
      * @return array HMENU array
216 210
      */
217
-    public function makeFacetsMenuArray($facets)
218
-    {
211
+    public function makeFacetsMenuArray($facets) {
219 212
         $menuArray = [];
220 213
         // Set default value for facet search.
221 214
         $search = [
@@ -271,8 +264,7 @@  discard block
 block discarded – undo
271 264
                 // check for virtual collections query string
272 265
                 if($collectionEntry->getIndexSearch()) {
273 266
                     $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '(' . $collectionEntry->getIndexSearch() . ')' : ' OR ('. $collectionEntry->getIndexSearch() . ')' ;
274
-                }
275
-                else {
267
+                } else {
276 268
                     $collectionsQueryString .= empty($collectionsQueryString) ? '"' . $collectionEntry->getIndexName() . '"' : ' OR "' . $collectionEntry->getIndexName() . '"';
277 269
                 }
278 270
             }
@@ -421,8 +413,7 @@  discard block
 block discarded – undo
421 413
      *
422 414
      * @return array The array for the facet's menu entry
423 415
      */
424
-    protected function getFacetsMenuEntry($field, $value, $count, $search, &$state)
425
-    {
416
+    protected function getFacetsMenuEntry($field, $value, $count, $search, &$state) {
426 417
         $entryArray = [];
427 418
         // Translate value.
428 419
         if ($field == 'owner_faceting') {
@@ -473,8 +464,7 @@  discard block
 block discarded – undo
473 464
      *
474 465
      * @return string The extended search form or an empty string
475 466
      */
476
-    protected function addExtendedSearch()
477
-    {
467
+    protected function addExtendedSearch() {
478 468
         // Quit without doing anything if no fields for extended search are selected.
479 469
         if (
480 470
             empty($this->settings['extendedSlotCount'])
Please login to merge, or discard this patch.
Upper-Lower-Casing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         $this->searchParams = $this->getParametersSafely('searchParameter');
78 78
 
79 79
         // output is done by main action
80
-        $this->forward('main', null, null, ['searchParameter' => $this->searchParams]);
80
+        $this->forward('main', NULL, NULL, ['searchParameter' => $this->searchParams]);
81 81
     }
82 82
 
83 83
     /**
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function mainAction()
91 91
     {
92
-        $listViewSearch = false;
92
+        $listViewSearch = FALSE;
93 93
         // Quit without doing anything if required variables are not set.
94 94
         if (empty($this->settings['solrcore'])) {
95 95
             $this->logger->warning('Incomplete plugin configuration');
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
         if (isset($listRequestData['searchParameter']) && is_array($listRequestData['searchParameter'])) {
105 105
             $this->searchParams = array_merge($this->searchParams ? : [], $listRequestData['searchParameter']);
106
-            $listViewSearch = true;
106
+            $listViewSearch = TRUE;
107 107
             $GLOBALS['TSFE']->fe_user->setKey('ses', 'search', $this->searchParams);
108 108
         }
109 109
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
         // If a targetPid is given, the results will be shown by ListView on the target page.
130 130
         if (!empty($this->settings['targetPid']) && !empty($this->searchParams) && !$listViewSearch) {
131
-            $this->redirect('main', 'ListView', null,
131
+            $this->redirect('main', 'ListView', NULL,
132 132
                 [
133 133
                     'searchParameter' => $this->searchParams,
134 134
                     'widgetPage' => $widgetPage
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
         // If no search has been executed, no variables habe to be prepared. An empty form will be shown.
140 140
         if (is_array($this->searchParams) && !empty($this->searchParams)) {
141 141
             // get all sortable metadata records
142
-            $sortableMetadata = $this->metadataRepository->findByIsSortable(true);
142
+            $sortableMetadata = $this->metadataRepository->findByIsSortable(TRUE);
143 143
 
144 144
             // get all metadata records to be shown in results
145
-            $listedMetadata = $this->metadataRepository->findByIsListed(true);
145
+            $listedMetadata = $this->metadataRepository->findByIsListed(TRUE);
146 146
 
147 147
             $solrResults = [];
148 148
             $numResults = 0;
149 149
             // Do not execute the Solr search if used together with ListView plugin.
150 150
             if (!$listViewSearch) {
151
-                $solrResults = $this->documentRepository->findSolrByCollection(null, $this->settings, $this->searchParams, $listedMetadata);
151
+                $solrResults = $this->documentRepository->findSolrByCollection(NULL, $this->settings, $this->searchParams, $listedMetadata);
152 152
                 $numResults = $solrResults->getNumFound();
153 153
             }
154 154
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
         // Get facets from plugin configuration.
199 199
         $facets = [];
200
-        foreach (GeneralUtility::trimExplode(',', $this->settings['facets'], true) as $facet) {
200
+        foreach (GeneralUtility::trimExplode(',', $this->settings['facets'], TRUE) as $facet) {
201 201
             $facets[$facet . '_faceting'] = Helper::translate($facet, 'tx_dlf_metadata', $this->settings['storagePid']);
202 202
         }
203 203
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
         // if collections are given, we prepare the collection query string
259 259
         // extract collections from collection parameter
260
-        $collection = null;
260
+        $collection = NULL;
261 261
         if ($this->searchParams['collection']) {
262 262
             foreach(explode(',', $this->searchParams['collection']) as $collectionEntry) {
263 263
                 $collection[] = $this->collectionRepository->findByUid($collectionEntry);
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         // Check if facet is already selected.
446 446
         $queryColumn = array_column($search['params']['filterquery'], 'query');
447 447
         $index = array_search($field . ':("' . Solr::escapeQuery($value) . '")', $queryColumn);
448
-        if ($index !== false) {
448
+        if ($index !== FALSE) {
449 449
             // Facet is selected, thus remove it from filter.
450 450
             unset($queryColumn[$index]);
451 451
             $queryColumn = array_values($queryColumn);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
             $state = 'ACTIFSUB';
454 454
             // Reset facets
455 455
             if ($this->settings['resetFacets']) {
456
-                $entryArray['resetFacet'] = true;
456
+                $entryArray['resetFacet'] = TRUE;
457 457
                 $entryArray['queryColumn'] = $queryColumn;
458 458
             }
459 459
         } else {
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
         }
485 485
 
486 486
         // Get field selector options.
487
-        $searchFields = GeneralUtility::trimExplode(',', $this->settings['extendedFields'], true);
487
+        $searchFields = GeneralUtility::trimExplode(',', $this->settings['extendedFields'], TRUE);
488 488
 
489 489
         $slotCountArray = [];
490 490
         for ($i = 0; $i < $this->settings['extendedSlotCount']; $i++) {
Please login to merge, or discard this patch.
Classes/Controller/ListViewController.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
         // extract collection(s) from collection parameter
76 76
         $collection = null;
77 77
         if ($this->searchParams['collection']) {
78
-            foreach(explode(',', $this->searchParams['collection']) as $collectionEntry) {
78
+            foreach (explode(',', $this->searchParams['collection']) as $collectionEntry) {
79 79
                 $collection[] = $this->collectionRepository->findByUid($collectionEntry);
80 80
             }
81 81
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
  * @subpackage dlf
30 30
  * @access public
31 31
  */
32
-class ListViewController extends AbstractController
33
-{
32
+class ListViewController extends AbstractController {
34 33
     /**
35 34
      * @var CollectionRepository
36 35
      */
@@ -39,8 +38,7 @@  discard block
 block discarded – undo
39 38
     /**
40 39
      * @param CollectionRepository $collectionRepository
41 40
      */
42
-    public function injectCollectionRepository(CollectionRepository $collectionRepository)
43
-    {
41
+    public function injectCollectionRepository(CollectionRepository $collectionRepository) {
44 42
         $this->collectionRepository = $collectionRepository;
45 43
     }
46 44
 
@@ -52,8 +50,7 @@  discard block
 block discarded – undo
52 50
     /**
53 51
      * @param MetadataRepository $metadataRepository
54 52
      */
55
-    public function injectMetadataRepository(MetadataRepository $metadataRepository)
56
-    {
53
+    public function injectMetadataRepository(MetadataRepository $metadataRepository) {
57 54
         $this->metadataRepository = $metadataRepository;
58 55
     }
59 56
 
@@ -68,8 +65,7 @@  discard block
 block discarded – undo
68 65
      *
69 66
      * @return void
70 67
      */
71
-    public function mainAction()
72
-    {
68
+    public function mainAction() {
73 69
         $this->searchParams = $this->getParametersSafely('searchParameter');
74 70
 
75 71
         // extract collection(s) from collection parameter
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $this->searchParams = $this->getParametersSafely('searchParameter');
74 74
 
75 75
         // extract collection(s) from collection parameter
76
-        $collection = null;
76
+        $collection = NULL;
77 77
         if ($this->searchParams['collection']) {
78 78
             foreach(explode(',', $this->searchParams['collection']) as $collectionEntry) {
79 79
                 $collection[] = $this->collectionRepository->findByUid($collectionEntry);
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
         $GLOBALS['TSFE']->fe_user->setKey('ses', 'widgetPage', $widgetPage);
88 88
 
89 89
         // get all sortable metadata records
90
-        $sortableMetadata = $this->metadataRepository->findByIsSortable(true);
90
+        $sortableMetadata = $this->metadataRepository->findByIsSortable(TRUE);
91 91
 
92 92
         // get all metadata records to be shown in results
93
-        $listedMetadata = $this->metadataRepository->findByIsListed(true);
93
+        $listedMetadata = $this->metadataRepository->findByIsListed(TRUE);
94 94
 
95 95
         $solrResults = [];
96 96
         $numResults = 0;
97 97
         if (is_array($this->searchParams) && !empty($this->searchParams)) {
98
-            $solrResults = $this->documentRepository->findSolrByCollection($collection ? : null, $this->settings, $this->searchParams, $listedMetadata);
98
+            $solrResults = $this->documentRepository->findSolrByCollection($collection ? : NULL, $this->settings, $this->searchParams, $listedMetadata);
99 99
             $numResults = $solrResults->getNumFound();
100 100
         }
101 101
 
Please login to merge, or discard this patch.