Passed
Pull Request — master (#123)
by Sebastian
03:10
created
Classes/Common/Indexer.php 3 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                         $parent->setDoc($doc);
116 116
                         $success = self::add($parent);
117 117
                     } else {
118
-                        Helper::log('Could not load parent document with UID ' . $document->getDoc()->parentId, LOG_SEVERITY_ERROR);
118
+                        Helper::log('Could not load parent document with UID '.$document->getDoc()->parentId, LOG_SEVERITY_ERROR);
119 119
                         return false;
120 120
                     }
121 121
                 }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                 self::$processedDocs[] = $document->getUid();
126 126
                 // Delete old Solr documents.
127 127
                 $updateQuery = self::$solr->service->createUpdate();
128
-                $updateQuery->addDeleteQuery('uid:' . $document->getUid());
128
+                $updateQuery->addDeleteQuery('uid:'.$document->getUid());
129 129
                 self::$solr->service->update($updateQuery);
130 130
 
131 131
                 // Index every logical unit as separate Solr document.
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
             } catch (\Exception $e) {
175 175
                 if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) {
176 176
                     Helper::addMessage(
177
-                        Helper::getLanguageService()->getLL('flash.solrException') . ' ' . htmlspecialchars($e->getMessage()),
177
+                        Helper::getLanguageService()->getLL('flash.solrException').' '.htmlspecialchars($e->getMessage()),
178 178
                         Helper::getLanguageService()->getLL('flash.error'),
179 179
                         FlashMessage::ERROR,
180 180
                         true,
181 181
                         'core.template.flashMessages'
182 182
                     );
183 183
                 }
184
-                Helper::log('Apache Solr threw exception: "' . $e->getMessage() . '"', LOG_SEVERITY_ERROR);
184
+                Helper::log('Apache Solr threw exception: "'.$e->getMessage().'"', LOG_SEVERITY_ERROR);
185 185
                 return false;
186 186
             }
187 187
         } else {
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         // Sanitize input.
215 215
         $pid = max(intval($pid), 0);
216 216
         if (!$pid) {
217
-            Helper::log('Invalid PID ' . $pid . ' for metadata configuration', LOG_SEVERITY_ERROR);
217
+            Helper::log('Invalid PID '.$pid.' for metadata configuration', LOG_SEVERITY_ERROR);
218 218
             return '';
219 219
         }
220 220
         // Load metadata configuration.
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
         $suffix = (in_array($index_name, self::$fields['tokenized']) ? 't' : 'u');
224 224
         $suffix .= (in_array($index_name, self::$fields['stored']) ? 's' : 'u');
225 225
         $suffix .= (in_array($index_name, self::$fields['indexed']) ? 'i' : 'u');
226
-        $index_name .= '_' . $suffix;
226
+        $index_name .= '_'.$suffix;
227 227
         return $index_name;
228 228
     }
229 229
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
             $solrDoc->setField('title', $metadata['title'][0], self::$fields['fieldboost']['title']);
338 338
             $solrDoc->setField('volume', $metadata['volume'][0], self::$fields['fieldboost']['volume']);
339 339
             // verify date formatting
340
-            if(strtotime($metadata['date'][0])) {
340
+            if (strtotime($metadata['date'][0])) {
341 341
                 // do not alter dates YYYY or YYYY-MM or YYYY-MM-DD
342 342
                 if (
343 343
                     preg_match("/^[0-9]{4}$/", $metadata['date'][0]) 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
                 ) {
347 347
                     $solrDoc->setField('date', $metadata['date'][0]);
348 348
                 // change date YYYYMMDD to YYYY-MM-DD
349
-                } elseif (preg_match("/^[0-9]{8}$/", $metadata['date'][0])){
349
+                } elseif (preg_match("/^[0-9]{8}$/", $metadata['date'][0])) {
350 350
                     $solrDoc->setField('date', date("Y-m-d", strtotime($metadata['date'][0])));
351 351
                 // convert any datetime to proper ISO extended datetime format and timezone for SOLR
352 352
                 } else {
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
                     $solrDoc->setField(self::getIndexFieldName($index_name, $document->getPid()), $data, self::$fields['fieldboost'][$index_name]);
375 375
                     if (in_array($index_name, self::$fields['sortables'])) {
376 376
                         // Add sortable fields to index.
377
-                        $solrDoc->setField($index_name . '_sorting', $metadata[$index_name . '_sorting'][0]);
377
+                        $solrDoc->setField($index_name.'_sorting', $metadata[$index_name.'_sorting'][0]);
378 378
                     }
379 379
                     if (in_array($index_name, self::$fields['facets'])) {
380 380
                         // Add facets to index.
381
-                        $solrDoc->setField($index_name . '_faceting', $data);
381
+                        $solrDoc->setField($index_name.'_faceting', $data);
382 382
                     }
383 383
                     if (in_array($index_name, self::$fields['autocomplete'])) {
384 384
                         $autocomplete = array_merge($autocomplete, $data);
@@ -403,14 +403,14 @@  discard block
 block discarded – undo
403 403
             } catch (\Exception $e) {
404 404
                 if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) {
405 405
                     Helper::addMessage(
406
-                        Helper::getLanguageService()->getLL('flash.solrException') . '<br />' . htmlspecialchars($e->getMessage()),
406
+                        Helper::getLanguageService()->getLL('flash.solrException').'<br />'.htmlspecialchars($e->getMessage()),
407 407
                         Helper::getLanguageService()->getLL('flash.error'),
408 408
                         FlashMessage::ERROR,
409 409
                         true,
410 410
                         'core.template.flashMessages'
411 411
                     );
412 412
                 }
413
-                Helper::log('Apache Solr threw exception: "' . $e->getMessage() . '"', LOG_SEVERITY_ERROR);
413
+                Helper::log('Apache Solr threw exception: "'.$e->getMessage().'"', LOG_SEVERITY_ERROR);
414 414
                 return false;
415 415
             }
416 416
         }
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
                                 $data = self::removeAppendsFromAuthor($data);
477 477
                             }
478 478
                             // Add facets to index.
479
-                            $solrDoc->setField($index_name . '_faceting', $data);
479
+                            $solrDoc->setField($index_name.'_faceting', $data);
480 480
                         }
481 481
                     }
482 482
                 }
@@ -494,14 +494,14 @@  discard block
 block discarded – undo
494 494
             } catch (\Exception $e) {
495 495
                 if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) {
496 496
                     Helper::addMessage(
497
-                        Helper::getLanguageService()->getLL('flash.solrException') . '<br />' . htmlspecialchars($e->getMessage()),
497
+                        Helper::getLanguageService()->getLL('flash.solrException').'<br />'.htmlspecialchars($e->getMessage()),
498 498
                         Helper::getLanguageService()->getLL('flash.error'),
499 499
                         FlashMessage::ERROR,
500 500
                         true,
501 501
                         'core.template.flashMessages'
502 502
                     );
503 503
                 }
504
-                Helper::log('Apache Solr threw exception: "' . $e->getMessage() . '"', LOG_SEVERITY_ERROR);
504
+                Helper::log('Apache Solr threw exception: "'.$e->getMessage().'"', LOG_SEVERITY_ERROR);
505 505
                 return false;
506 506
             }
507 507
         }
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
     private static function getSolrDocument($updateQuery, $document, $unit, $fullText = '') {
553 553
         $solrDoc = $updateQuery->createDocument();
554 554
         // Create unique identifier from document's UID and unit's XML ID.
555
-        $solrDoc->setField('id', $document->getUid() . $unit['id']);
555
+        $solrDoc->setField('id', $document->getUid().$unit['id']);
556 556
         $solrDoc->setField('uid', $document->getUid());
557 557
         $solrDoc->setField('pid', $document->getPid());
558 558
         $solrDoc->setField('partof', $document->getPartof());
Please login to merge, or discard this patch.
Braces   +9 added lines, -17 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 Indexer
36
-{
35
+class Indexer {
37 36
     /**
38 37
      * The extension key
39 38
      *
@@ -93,8 +92,7 @@  discard block
 block discarded – undo
93 92
      *
94 93
      * @return bool true on success or false on failure
95 94
      */
96
-    public static function add(Document $document)
97
-    {
95
+    public static function add(Document $document) {
98 96
         if (in_array($document->getUid(), self::$processedDocs)) {
99 97
             return true;
100 98
         } elseif (self::solrConnect($document->getSolrcore(), $document->getPid())) {
@@ -209,8 +207,7 @@  discard block
 block discarded – undo
209 207
      *
210 208
      * @return string The field's dynamic index name
211 209
      */
212
-    public static function getIndexFieldName($index_name, $pid = 0)
213
-    {
210
+    public static function getIndexFieldName($index_name, $pid = 0) {
214 211
         // Sanitize input.
215 212
         $pid = max(intval($pid), 0);
216 213
         if (!$pid) {
@@ -236,8 +233,7 @@  discard block
 block discarded – undo
236 233
      *
237 234
      * @return void
238 235
      */
239
-    protected static function loadIndexConf($pid)
240
-    {
236
+    protected static function loadIndexConf($pid) {
241 237
         if (!self::$fieldsLoaded) {
242 238
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
243 239
                 ->getQueryBuilderForTable('tx_dlf_metadata');
@@ -307,8 +303,7 @@  discard block
 block discarded – undo
307 303
      *
308 304
      * @return bool true on success or false on failure
309 305
      */
310
-    protected static function processLogical(Document $document, array $logicalUnit)
311
-    {
306
+    protected static function processLogical(Document $document, array $logicalUnit) {
312 307
         $success = true;
313 308
         $doc = $document->getDoc();
314 309
         $doc->cPid = $document->getPid();
@@ -346,7 +341,7 @@  discard block
 block discarded – undo
346 341
                 ) {
347 342
                     $solrDoc->setField('date', $metadata['date'][0]);
348 343
                 // change date YYYYMMDD to YYYY-MM-DD
349
-                } elseif (preg_match("/^[0-9]{8}$/", $metadata['date'][0])){
344
+                } elseif (preg_match("/^[0-9]{8}$/", $metadata['date'][0])) {
350 345
                     $solrDoc->setField('date', date("Y-m-d", strtotime($metadata['date'][0])));
351 346
                 // convert any datetime to proper ISO extended datetime format and timezone for SOLR
352 347
                 } else {
@@ -439,8 +434,7 @@  discard block
 block discarded – undo
439 434
      *
440 435
      * @return bool true on success or false on failure
441 436
      */
442
-    protected static function processPhysical(Document $document, $page, array $physicalUnit)
443
-    {
437
+    protected static function processPhysical(Document $document, $page, array $physicalUnit) {
444 438
         $doc = $document->getDoc();
445 439
         $doc->cPid = $document->getPid();
446 440
         if ($doc->hasFulltext && $fullText = $doc->getFullText($physicalUnit['id'])) {
@@ -518,8 +512,7 @@  discard block
 block discarded – undo
518 512
      *
519 513
      * @return bool true on success or false on failure
520 514
      */
521
-    protected static function solrConnect($core, $pid = 0)
522
-    {
515
+    protected static function solrConnect($core, $pid = 0) {
523 516
         // Get Solr instance.
524 517
         if (!self::$solr) {
525 518
             // Connect to Solr server.
@@ -588,8 +581,7 @@  discard block
 block discarded – undo
588 581
      *
589 582
      * @access private
590 583
      */
591
-    private function __construct()
592
-    {
584
+    private function __construct() {
593 585
         // This is a static class, thus no instances should be created.
594 586
     }
595 587
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @var bool
67 67
      * @access protected
68 68
      */
69
-    protected static $fieldsLoaded = false;
69
+    protected static $fieldsLoaded = FALSE;
70 70
 
71 71
     /**
72 72
      * List of already processed documents
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
     public static function add(Document $document)
97 97
     {
98 98
         if (in_array($document->getUid(), self::$processedDocs)) {
99
-            return true;
99
+            return TRUE;
100 100
         } elseif (self::solrConnect($document->getSolrcore(), $document->getPid())) {
101
-            $success = true;
101
+            $success = TRUE;
102 102
             Helper::getLanguageService()->includeLLFile('EXT:dlf/Resources/Private/Language/locallang_be.xlf');
103 103
             // Handle multi-volume documents.
104 104
             if ($parentId = $document->getPartof()) {
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
                 $parent = $documentRepository->findByUid($parentId);
111 111
                 if ($parent) {
112 112
                     // get XML document of parent
113
-                    $doc = Doc::getInstance($parent->getLocation(), ['storagePid' => $parent->getPid()], true);
114
-                    if ($doc !== null) {
113
+                    $doc = Doc::getInstance($parent->getLocation(), ['storagePid' => $parent->getPid()], TRUE);
114
+                    if ($doc !== NULL) {
115 115
                         $parent->setDoc($doc);
116 116
                         $success = self::add($parent);
117 117
                     } else {
118 118
                         Helper::log('Could not load parent document with UID ' . $document->getDoc()->parentId, LOG_SEVERITY_ERROR);
119
-                        return false;
119
+                        return FALSE;
120 120
                     }
121 121
                 }
122 122
             }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                             sprintf(Helper::getLanguageService()->getLL('flash.documentIndexed'), $document->getTitle(), $document->getUid()),
158 158
                             Helper::getLanguageService()->getLL('flash.done'),
159 159
                             FlashMessage::OK,
160
-                            true,
160
+                            TRUE,
161 161
                             'core.template.flashMessages'
162 162
                         );
163 163
                     } else {
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                             sprintf(Helper::getLanguageService()->getLL('flash.documentNotIndexed'), $document->getTitle(), $document->getUid()),
166 166
                             Helper::getLanguageService()->getLL('flash.error'),
167 167
                             FlashMessage::ERROR,
168
-                            true,
168
+                            TRUE,
169 169
                             'core.template.flashMessages'
170 170
                         );
171 171
                     }
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
                         Helper::getLanguageService()->getLL('flash.solrException') . ' ' . htmlspecialchars($e->getMessage()),
178 178
                         Helper::getLanguageService()->getLL('flash.error'),
179 179
                         FlashMessage::ERROR,
180
-                        true,
180
+                        TRUE,
181 181
                         'core.template.flashMessages'
182 182
                     );
183 183
                 }
184 184
                 Helper::log('Apache Solr threw exception: "' . $e->getMessage() . '"', LOG_SEVERITY_ERROR);
185
-                return false;
185
+                return FALSE;
186 186
             }
187 187
         } else {
188 188
             if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) {
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
                     Helper::getLanguageService()->getLL('flash.solrNoConnection'),
191 191
                     Helper::getLanguageService()->getLL('flash.warning'),
192 192
                     FlashMessage::WARNING,
193
-                    true,
193
+                    TRUE,
194 194
                     'core.template.flashMessages'
195 195
                 );
196 196
             }
197 197
             Helper::log('Could not connect to Apache Solr server', LOG_SEVERITY_ERROR);
198
-            return false;
198
+            return FALSE;
199 199
         }
200 200
     }
201 201
 
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
                 if ($indexing['index_boost'] > 0.0) {
291 291
                     self::$fields['fieldboost'][$indexing['index_name']] = floatval($indexing['index_boost']);
292 292
                 } else {
293
-                    self::$fields['fieldboost'][$indexing['index_name']] = false;
293
+                    self::$fields['fieldboost'][$indexing['index_name']] = FALSE;
294 294
                 }
295 295
             }
296
-            self::$fieldsLoaded = true;
296
+            self::$fieldsLoaded = TRUE;
297 297
         }
298 298
     }
299 299
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
      */
310 310
     protected static function processLogical(Document $document, array $logicalUnit)
311 311
     {
312
-        $success = true;
312
+        $success = TRUE;
313 313
         $doc = $document->getDoc();
314 314
         $doc->cPid = $document->getPid();
315 315
         // Get metadata for logical unit.
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                 $solrDoc->setField('thumbnail', $doc->getFileLocation($logicalUnit['thumbnailId']));
334 334
             }
335 335
             // There can be only one toplevel unit per UID, independently of backend configuration
336
-            $solrDoc->setField('toplevel', $logicalUnit['id'] == $doc->toplevelId ? true : false);
336
+            $solrDoc->setField('toplevel', $logicalUnit['id'] == $doc->toplevelId ? TRUE : FALSE);
337 337
             $solrDoc->setField('title', $metadata['title'][0], self::$fields['fieldboost']['title']);
338 338
             $solrDoc->setField('volume', $metadata['volume'][0], self::$fields['fieldboost']['volume']);
339 339
             // verify date formatting
@@ -406,12 +406,12 @@  discard block
 block discarded – undo
406 406
                         Helper::getLanguageService()->getLL('flash.solrException') . '<br />' . htmlspecialchars($e->getMessage()),
407 407
                         Helper::getLanguageService()->getLL('flash.error'),
408 408
                         FlashMessage::ERROR,
409
-                        true,
409
+                        TRUE,
410 410
                         'core.template.flashMessages'
411 411
                     );
412 412
                 }
413 413
                 Helper::log('Apache Solr threw exception: "' . $e->getMessage() . '"', LOG_SEVERITY_ERROR);
414
-                return false;
414
+                return FALSE;
415 415
             }
416 416
         }
417 417
         // Check for child elements...
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
                     break;
458 458
                 }
459 459
             }
460
-            $solrDoc->setField('toplevel', false);
460
+            $solrDoc->setField('toplevel', FALSE);
461 461
             $solrDoc->setField('type', $physicalUnit['type'], self::$fields['fieldboost']['type']);
462 462
             $solrDoc->setField('collection', $doc->metadataArray[$doc->toplevelId]['collection']);
463 463
 
@@ -497,15 +497,15 @@  discard block
 block discarded – undo
497 497
                         Helper::getLanguageService()->getLL('flash.solrException') . '<br />' . htmlspecialchars($e->getMessage()),
498 498
                         Helper::getLanguageService()->getLL('flash.error'),
499 499
                         FlashMessage::ERROR,
500
-                        true,
500
+                        TRUE,
501 501
                         'core.template.flashMessages'
502 502
                     );
503 503
                 }
504 504
                 Helper::log('Apache Solr threw exception: "' . $e->getMessage() . '"', LOG_SEVERITY_ERROR);
505
-                return false;
505
+                return FALSE;
506 506
             }
507 507
         }
508
-        return true;
508
+        return TRUE;
509 509
     }
510 510
 
511 511
     /**
@@ -531,10 +531,10 @@  discard block
 block discarded – undo
531 531
                     self::loadIndexConf($pid);
532 532
                 }
533 533
             } else {
534
-                return false;
534
+                return FALSE;
535 535
             }
536 536
         }
537
-        return true;
537
+        return TRUE;
538 538
     }
539 539
 
540 540
     /**
Please login to merge, or discard this patch.
Classes/Controller/NavigationController.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@  discard block
 block discarded – undo
23 23
  * @subpackage dlf
24 24
  * @access public
25 25
  */
26
-class NavigationController extends AbstractController
27
-{
26
+class NavigationController extends AbstractController {
28 27
     /**
29 28
      * Method to get the page select values and use them with chash
30 29
      * @param \Kitodo\Dlf\Domain\Model\PageSelectForm|NULL $pageSelectForm
@@ -53,8 +52,7 @@  discard block
 block discarded – undo
53 52
      *
54 53
      * @return void
55 54
      */
56
-    public function mainAction()
57
-    {
55
+    public function mainAction() {
58 56
         // Load current document.
59 57
         $this->loadDocument($this->requestData);
60 58
         if (
Please login to merge, or discard this patch.
Classes/Controller/ListViewController.php 1 patch
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $this->searchParams = $this->getParametersSafely('searchParameter');
74 74
 
75
-        $collection = null;
75
+        $collection = NULL;
76 76
         if ($this->searchParams['collection'] && MathUtility::canBeInterpretedAsInteger($this->searchParams['collection'])) {
77 77
             $collection = $this->collectionRepository->findByUid($this->searchParams['collection']);
78 78
         }
@@ -84,15 +84,15 @@  discard block
 block discarded – undo
84 84
         $GLOBALS['TSFE']->fe_user->setKey('ses', 'widgetPage', $widgetPage);
85 85
 
86 86
         // get all sortable metadata records
87
-        $sortableMetadata = $this->metadataRepository->findByIsSortable(true);
87
+        $sortableMetadata = $this->metadataRepository->findByIsSortable(TRUE);
88 88
 
89 89
         // get all metadata records to be shown in results
90
-        $listedMetadata = $this->metadataRepository->findByIsListed(true);
90
+        $listedMetadata = $this->metadataRepository->findByIsListed(TRUE);
91 91
 
92 92
         $solrResults = [];
93 93
         $numResults = 0;
94 94
         if (is_array($this->searchParams) && !empty($this->searchParams)) {
95
-            $solrResults = $this->documentRepository->findSolrByCollection($collection ? : null, $this->settings, $this->searchParams, $listedMetadata);
95
+            $solrResults = $this->documentRepository->findSolrByCollection($collection ? : NULL, $this->settings, $this->searchParams, $listedMetadata);
96 96
             $numResults = $solrResults->getNumFound();
97 97
         }
98 98
 
Please login to merge, or discard this patch.