@@ -87,7 +87,7 @@ |
||
87 | 87 | $this->xEndPosition = $highlight['lrx']; |
88 | 88 | $this->yBeginPosition = $highlight['uly']; |
89 | 89 | $this->yEndPosition = $highlight['lry']; |
90 | - $this->id = $this->xBeginPosition . '_' . $this->yBeginPosition; |
|
90 | + $this->id = $this->xBeginPosition.'_'.$this->yBeginPosition; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -20,8 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @access public |
22 | 22 | */ |
23 | -class Highlight |
|
24 | -{ |
|
23 | +class Highlight { |
|
25 | 24 | |
26 | 25 | /** |
27 | 26 | * @access private |
@@ -62,8 +61,7 @@ discard block |
||
62 | 61 | * |
63 | 62 | * @return void |
64 | 63 | */ |
65 | - public function __construct(array $highlight) |
|
66 | - { |
|
64 | + public function __construct(array $highlight) { |
|
67 | 65 | // there is also possibility to access parentRegionIdx |
68 | 66 | // $this->parentRegionId = $highlight['parentRegionIdx']; |
69 | 67 | $this->xBeginPosition = $highlight['ulx']; |
@@ -20,8 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @access public |
22 | 22 | */ |
23 | -class Region |
|
24 | -{ |
|
23 | +class Region { |
|
25 | 24 | |
26 | 25 | /** |
27 | 26 | * @access private |
@@ -87,8 +86,7 @@ discard block |
||
87 | 86 | * |
88 | 87 | * @return void |
89 | 88 | */ |
90 | - public function __construct(int $id, array $region) |
|
91 | - { |
|
89 | + public function __construct(int $id, array $region) { |
|
92 | 90 | $this->id = $id; |
93 | 91 | $this->pageId = $region['pageIdx']; |
94 | 92 | $this->xBeginPosition = $region['ulx']; |
@@ -22,8 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @access public |
24 | 24 | */ |
25 | -class ResultDocument |
|
26 | -{ |
|
25 | +class ResultDocument { |
|
27 | 26 | |
28 | 27 | /** |
29 | 28 | * @access private |
@@ -108,8 +107,7 @@ discard block |
||
108 | 107 | * |
109 | 108 | * @return void |
110 | 109 | */ |
111 | - public function __construct(Document $record, array $highlighting, array $fields) |
|
112 | - { |
|
110 | + public function __construct(Document $record, array $highlighting, array $fields) { |
|
113 | 111 | $this->id = $record[$fields['id']]; |
114 | 112 | $this->uid = $record[$fields['uid']]; |
115 | 113 | $this->page = $record[$fields['page']]; |
@@ -65,7 +65,7 @@ |
||
65 | 65 | * @access private |
66 | 66 | * @var bool It's a toplevel element? |
67 | 67 | */ |
68 | - private bool $toplevel = false; |
|
68 | + private bool $toplevel = FALSE; |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @access private |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | // Get next available core name if none given. |
129 | 129 | if (empty($core)) { |
130 | - $core = 'dlfCore' . self::getNextCoreNumber(); |
|
130 | + $core = 'dlfCore'.self::getNextCoreNumber(); |
|
131 | 131 | } |
132 | 132 | // Get Solr service instance. |
133 | 133 | $solr = self::getInstance($core); |
@@ -217,13 +217,13 @@ discard block |
||
217 | 217 | ->execute(); |
218 | 218 | |
219 | 219 | while ($resArray = $result->fetchAssociative()) { |
220 | - $fields[] = $resArray['index_name'] . '_' . ($resArray['index_tokenized'] ? 't' : 'u') . ($resArray['index_stored'] ? 's' : 'u') . 'i'; |
|
220 | + $fields[] = $resArray['index_name'].'_'.($resArray['index_tokenized'] ? 't' : 'u').($resArray['index_stored'] ? 's' : 'u').'i'; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | // Check if queried field is valid. |
224 | 224 | $splitQuery = explode(':', $query, 2); |
225 | 225 | if (in_array($splitQuery[0], $fields)) { |
226 | - $query = $splitQuery[0] . ':(' . self::escapeQuery(trim($splitQuery[1], '()')) . ')'; |
|
226 | + $query = $splitQuery[0].':('.self::escapeQuery(trim($splitQuery[1], '()')).')'; |
|
227 | 227 | } else { |
228 | 228 | $query = self::escapeQuery($query); |
229 | 229 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | { |
331 | 331 | $number = max($number, 0); |
332 | 332 | // Check if core already exists. |
333 | - $solr = self::getInstance('dlfCore' . $number); |
|
333 | + $solr = self::getInstance('dlfCore'.$number); |
|
334 | 334 | if (!$solr->ready) { |
335 | 335 | return $number; |
336 | 336 | } else { |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $parameters['start'] = 0; |
389 | 389 | $parameters['rows'] = $this->limit; |
390 | 390 | // Calculate cache identifier. |
391 | - $cacheIdentifier = Helper::digest($this->core . print_r(array_merge($this->params, $parameters), true)); |
|
391 | + $cacheIdentifier = Helper::digest($this->core.print_r(array_merge($this->params, $parameters), true)); |
|
392 | 392 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_solr'); |
393 | 393 | $resultSet = []; |
394 | 394 | $entry = $cache->get($cacheIdentifier); |
@@ -520,12 +520,12 @@ discard block |
||
520 | 520 | */ |
521 | 521 | public function __get(string $var) |
522 | 522 | { |
523 | - $method = 'magicGet' . ucfirst($var); |
|
523 | + $method = 'magicGet'.ucfirst($var); |
|
524 | 524 | if ( |
525 | 525 | !property_exists($this, $var) |
526 | 526 | || !method_exists($this, $method) |
527 | 527 | ) { |
528 | - $this->logger->warning('There is no getter function for property "' . $var . '"'); |
|
528 | + $this->logger->warning('There is no getter function for property "'.$var.'"'); |
|
529 | 529 | return null; |
530 | 530 | } else { |
531 | 531 | return $this->$method(); |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | */ |
559 | 559 | public function __set(string $var, $value): void |
560 | 560 | { |
561 | - $method = 'magicSet' . ucfirst($var); |
|
561 | + $method = 'magicSet'.ucfirst($var); |
|
562 | 562 | if ( |
563 | 563 | !property_exists($this, $var) |
564 | 564 | || !method_exists($this, $method) |
565 | 565 | ) { |
566 | - $this->logger->warning('There is no setter function for property "' . $var . '"'); |
|
566 | + $this->logger->warning('There is no setter function for property "'.$var.'"'); |
|
567 | 567 | } else { |
568 | 568 | $this->$method($value); |
569 | 569 | } |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | 'scheme' => $this->config['scheme'], |
604 | 604 | 'host' => $this->config['host'], |
605 | 605 | 'port' => $this->config['port'], |
606 | - 'path' => '/' . $this->config['path'], |
|
606 | + 'path' => '/'.$this->config['path'], |
|
607 | 607 | 'core' => $core, |
608 | 608 | 'username' => $this->config['username'], |
609 | 609 | 'password' => $this->config['password'] |
@@ -42,8 +42,7 @@ discard block |
||
42 | 42 | * @property-read bool $ready flag if the Solr service is instantiated successfully |
43 | 43 | * @property-read Client $service this holds the Solr service object |
44 | 44 | */ |
45 | -class Solr implements LoggerAwareInterface |
|
46 | -{ |
|
45 | +class Solr implements LoggerAwareInterface { |
|
47 | 46 | use LoggerAwareTrait; |
48 | 47 | |
49 | 48 | /** |
@@ -518,8 +517,7 @@ discard block |
||
518 | 517 | * |
519 | 518 | * @return mixed Value of $this->$var |
520 | 519 | */ |
521 | - public function __get(string $var) |
|
522 | - { |
|
520 | + public function __get(string $var) { |
|
523 | 521 | $method = 'magicGet' . ucfirst($var); |
524 | 522 | if ( |
525 | 523 | !property_exists($this, $var) |
@@ -578,8 +576,7 @@ discard block |
||
578 | 576 | * |
579 | 577 | * @return void |
580 | 578 | */ |
581 | - protected function __construct(?string $core) |
|
582 | - { |
|
579 | + protected function __construct(?string $core) { |
|
583 | 580 | // Solarium requires different code for version 5 and 6. |
584 | 581 | $isSolarium5 = Client::checkExact('5'); |
585 | 582 | // Get Solr connection parameters from configuration. |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @access protected |
57 | 57 | * @var string|null This holds the core name |
58 | 58 | */ |
59 | - protected ?string $core = null; |
|
59 | + protected ?string $core = NULL; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @access protected |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @access protected |
101 | 101 | * @var bool Is the search instantiated successfully? |
102 | 102 | */ |
103 | - protected bool $ready = false; |
|
103 | + protected bool $ready = FALSE; |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * @access protected |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @return Solr Instance of this class |
287 | 287 | */ |
288 | - public static function getInstance($core = null): Solr |
|
288 | + public static function getInstance($core = NULL): Solr |
|
289 | 289 | { |
290 | 290 | // Get core name if UID is given. |
291 | 291 | if (MathUtility::canBeInterpretedAsInteger($core)) { |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | // Check if core is set or null. |
295 | 295 | if ( |
296 | 296 | empty($core) |
297 | - && $core !== null |
|
297 | + && $core !== NULL |
|
298 | 298 | ) { |
299 | 299 | Helper::log('Invalid core UID or name given for Apache Solr', LOG_SEVERITY_ERROR); |
300 | 300 | } |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | $parameters['start'] = 0; |
389 | 389 | $parameters['rows'] = $this->limit; |
390 | 390 | // Calculate cache identifier. |
391 | - $cacheIdentifier = Helper::digest($this->core . print_r(array_merge($this->params, $parameters), true)); |
|
391 | + $cacheIdentifier = Helper::digest($this->core . print_r(array_merge($this->params, $parameters), TRUE)); |
|
392 | 392 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_solr'); |
393 | 393 | $resultSet = []; |
394 | 394 | $entry = $cache->get($cacheIdentifier); |
395 | - if ($entry === false) { |
|
395 | + if ($entry === FALSE) { |
|
396 | 396 | $selectQuery = $this->service->createSelect(array_merge($this->params, $parameters)); |
397 | 397 | $result = $this->service->select($selectQuery); |
398 | 398 | foreach ($result as $doc) { |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | || !method_exists($this, $method) |
527 | 527 | ) { |
528 | 528 | $this->logger->warning('There is no getter function for property "' . $var . '"'); |
529 | - return null; |
|
529 | + return NULL; |
|
530 | 530 | } else { |
531 | 531 | return $this->$method(); |
532 | 532 | } |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | $adapter->setTimeout($this->config['timeout']); |
590 | 590 | // Configure event dispatcher. |
591 | 591 | if ($isSolarium5) { |
592 | - $eventDispatcher = null; |
|
592 | + $eventDispatcher = NULL; |
|
593 | 593 | } else { |
594 | 594 | // When updating to TYPO3 >=10.x and Solarium >=6.x |
595 | 595 | // we have to provide an PSR-14 Event Dispatcher instead of |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | // Check if connection is established. |
624 | 624 | $query = $this->service->createCoreAdmin(); |
625 | 625 | $action = $query->createStatus(); |
626 | - if ($core !== null) { |
|
626 | + if ($core !== NULL) { |
|
627 | 627 | $action->setCore($core); |
628 | 628 | } |
629 | 629 | $query->setAction($action); |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | $response = $this->service->coreAdmin($query); |
632 | 632 | if ($response->getWasSuccessful()) { |
633 | 633 | // Solr is reachable, but is the core as well? |
634 | - if ($core !== null) { |
|
634 | + if ($core !== NULL) { |
|
635 | 635 | $result = $response->getStatusResult(); |
636 | 636 | if ( |
637 | 637 | $result instanceof StatusResult |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | } |
646 | 646 | } |
647 | 647 | // Instantiation successful! |
648 | - $this->ready = true; |
|
648 | + $this->ready = TRUE; |
|
649 | 649 | } |
650 | 650 | } catch (\Exception $e) { |
651 | 651 | // Nothing to do here. |
@@ -525,8 +525,8 @@ |
||
525 | 525 | $searchResult['snippet'] = $doc['snippet']; |
526 | 526 | $searchResult['highlight'] = $doc['highlight']; |
527 | 527 | $searchResult['highlight_word'] = preg_replace('/^;|;$/', '', // remove ; at beginning or end |
528 | - preg_replace('/;+/', ';', // replace any multiple of ; with a single ; |
|
529 | - preg_replace('/[{~\d*}{\s+}{^=*\d+.*\d*}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/', ';', $this->searchParams['query']))); // replace search operators and special characters with ; |
|
528 | + preg_replace('/;+/', ';', // replace any multiple of ; with a single ; |
|
529 | + preg_replace('/[{~\d*}{\s+}{^=*\d+.*\d*}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/', ';', $this->searchParams['query']))); // replace search operators and special characters with ; |
|
530 | 530 | } |
531 | 531 | $documents[$doc['uid']]['searchResults'][] = $searchResult; |
532 | 532 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | // in which case metadata of toplevel entry isn't yet filled. |
228 | 228 | if (empty($document['metadata'])) { |
229 | 229 | $document['metadata'] = $this->fetchToplevelMetadataFromSolr([ |
230 | - 'query' => 'uid:' . $document['uid'], |
|
230 | + 'query' => 'uid:'.$document['uid'], |
|
231 | 231 | 'start' => 0, |
232 | 232 | 'rows' => 1, |
233 | 233 | 'sort' => ['score' => 'desc'], |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | if (empty($document['title']) && $document['partOf'] > 0) { |
239 | 239 | $superiorTitle = AbstractDocument::getTitle($document['partOf'], true); |
240 | 240 | if (!empty($superiorTitle)) { |
241 | - $document['title'] = '[' . $superiorTitle . ']'; |
|
241 | + $document['title'] = '['.$superiorTitle.']'; |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
@@ -373,13 +373,13 @@ discard block |
||
373 | 373 | // Set search query. |
374 | 374 | if ( |
375 | 375 | !empty($this->searchParams['fulltext']) |
376 | - || preg_match('/' . $fields['fulltext'] . ':\((.*)\)/', trim($this->searchParams['query'] ?? ''), $matches) |
|
376 | + || preg_match('/'.$fields['fulltext'].':\((.*)\)/', trim($this->searchParams['query'] ?? ''), $matches) |
|
377 | 377 | ) { |
378 | 378 | // If the query already is a fulltext query e.g using the facets |
379 | 379 | $this->searchParams['query'] = empty($matches[1]) ? $this->searchParams['query'] : $matches[1]; |
380 | 380 | // Search in fulltext field if applicable. Query must not be empty! |
381 | 381 | if (!empty($this->searchParams['query'])) { |
382 | - $query = $fields['fulltext'] . ':(' . Solr::escapeQuery(trim($this->searchParams['query'])) . ')'; |
|
382 | + $query = $fields['fulltext'].':('.Solr::escapeQuery(trim($this->searchParams['query'])).')'; |
|
383 | 383 | } |
384 | 384 | $params['fulltext'] = true; |
385 | 385 | } else { |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | in_array($this->searchParams['extOperator'][$i], $allowedOperators) |
403 | 403 | ) { |
404 | 404 | if (!empty($query)) { |
405 | - $query .= ' ' . $this->searchParams['extOperator'][$i] . ' '; |
|
405 | + $query .= ' '.$this->searchParams['extOperator'][$i].' '; |
|
406 | 406 | } |
407 | - $query .= Indexer::getIndexFieldName($this->searchParams['extField'][$i], $this->settings['storagePid']) . ':(' . Solr::escapeQuery($this->searchParams['extQuery'][$i]) . ')'; |
|
407 | + $query .= Indexer::getIndexFieldName($this->searchParams['extField'][$i], $this->settings['storagePid']).':('.Solr::escapeQuery($this->searchParams['extQuery'][$i]).')'; |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | // Add filter query for date search |
414 | 414 | if (!empty($this->searchParams['dateFrom']) && !empty($this->searchParams['dateTo'])) { |
415 | 415 | // combine dateFrom and dateTo into range search |
416 | - $params['filterquery'][]['query'] = '{!join from=' . $fields['uid'] . ' to=' . $fields['uid'] . '}'. $fields['date'] . ':[' . $this->searchParams['dateFrom'] . ' TO ' . $this->searchParams['dateTo'] . ']'; |
|
416 | + $params['filterquery'][]['query'] = '{!join from='.$fields['uid'].' to='.$fields['uid'].'}'.$fields['date'].':['.$this->searchParams['dateFrom'].' TO '.$this->searchParams['dateTo'].']'; |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | // Add filter query for faceting. |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | ) { |
431 | 431 | // Search in document and all subordinates (valid for up to three levels of hierarchy). |
432 | 432 | $params['filterquery'][]['query'] = '_query_:"{!join from=' |
433 | - . $fields['uid'] . ' to=' . $fields['partof'] . '}' |
|
434 | - . $fields['uid'] . ':{!join from=' . $fields['uid'] . ' to=' . $fields['partof'] . '}' |
|
435 | - . $fields['uid'] . ':' . $this->searchParams['documentId'] . '"' . ' OR {!join from=' |
|
436 | - . $fields['uid'] . ' to=' . $fields['partof'] . '}' |
|
437 | - . $fields['uid'] . ':' . $this->searchParams['documentId'] . ' OR ' |
|
438 | - . $fields['uid'] . ':' . $this->searchParams['documentId']; |
|
433 | + . $fields['uid'].' to='.$fields['partof'].'}' |
|
434 | + . $fields['uid'].':{!join from='.$fields['uid'].' to='.$fields['partof'].'}' |
|
435 | + . $fields['uid'].':'.$this->searchParams['documentId'].'"'.' OR {!join from=' |
|
436 | + . $fields['uid'].' to='.$fields['partof'].'}' |
|
437 | + . $fields['uid'].':'.$this->searchParams['documentId'].' OR ' |
|
438 | + . $fields['uid'].':'.$this->searchParams['documentId']; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | // if collections are given, we prepare the collection query string |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | if ($this->listedMetadata) { |
456 | 456 | foreach ($this->listedMetadata as $metadata) { |
457 | 457 | if ($metadata->getIndexStored() || $metadata->getIndexIndexed()) { |
458 | - $listMetadataRecord = $metadata->getIndexName() . '_' . ($metadata->getIndexTokenized() ? 't' : 'u') . ($metadata->getIndexStored() ? 's' : 'u') . ($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
459 | - $params['fields'] .= ',' . $listMetadataRecord; |
|
458 | + $listMetadataRecord = $metadata->getIndexName().'_'.($metadata->getIndexTokenized() ? 't' : 'u').($metadata->getIndexStored() ? 's' : 'u').($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
459 | + $params['fields'] .= ','.$listMetadataRecord; |
|
460 | 460 | $params['listMetadataRecords'][$metadata->getIndexName()] = $listMetadataRecord; |
461 | 461 | } |
462 | 462 | } |
@@ -531,8 +531,8 @@ discard block |
||
531 | 531 | if ($this->searchParams['fulltext'] == '1') { |
532 | 532 | $searchResult['snippet'] = $doc['snippet']; |
533 | 533 | $searchResult['highlight'] = $doc['highlight']; |
534 | - $searchResult['highlight_word'] = preg_replace('/^;|;$/', '', // remove ; at beginning or end |
|
535 | - preg_replace('/;+/', ';', // replace any multiple of ; with a single ; |
|
534 | + $searchResult['highlight_word'] = preg_replace('/^;|;$/', '', // remove ; at beginning or end |
|
535 | + preg_replace('/;+/', ';', // replace any multiple of ; with a single ; |
|
536 | 536 | preg_replace('/[{~\d*}{\s+}{^=*\d+.*\d*}`~!@#$%\^&*()_|+-=?;:\'",.<>\{\}\[\]\\\]/', ';', $this->searchParams['query']))); // replace search operators and special characters with ; |
537 | 537 | } |
538 | 538 | $documents[$doc['uid']]['searchResults'][] = $searchResult; |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | |
557 | 557 | // Fetch metadata for the current batch |
558 | 558 | $metadataOf = $this->fetchToplevelMetadataFromSolr([ |
559 | - 'query' => 'partof:' . $doc['uid'], |
|
559 | + 'query' => 'partof:'.$doc['uid'], |
|
560 | 560 | 'start' => $start, |
561 | 561 | 'rows' => min($batchSize, $totalChildren - $start), |
562 | 562 | ]); |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | if ($this->listedMetadata) { |
609 | 609 | foreach ($this->listedMetadata as $metadata) { |
610 | 610 | if ($metadata->getIndexStored() || $metadata->getIndexIndexed()) { |
611 | - $listMetadataRecord = $metadata->getIndexName() . '_' . ($metadata->getIndexTokenized() ? 't' : 'u') . ($metadata->getIndexStored() ? 's' : 'u') . ($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
612 | - $params['fields'] .= ',' . $listMetadataRecord; |
|
611 | + $listMetadataRecord = $metadata->getIndexName().'_'.($metadata->getIndexTokenized() ? 't' : 'u').($metadata->getIndexStored() ? 's' : 'u').($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
612 | + $params['fields'] .= ','.$listMetadataRecord; |
|
613 | 613 | $params['listMetadataRecords'][$metadata->getIndexName()] = $listMetadataRecord; |
614 | 614 | } |
615 | 615 | } |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $cache = null; |
661 | 661 | // Calculate cache identifier. |
662 | 662 | if ($enableCache === true) { |
663 | - $cacheIdentifier = Helper::digest($solr->core . print_r($parameters, true)); |
|
663 | + $cacheIdentifier = Helper::digest($solr->core.print_r($parameters, true)); |
|
664 | 664 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_solr'); |
665 | 665 | } |
666 | 666 | $resultSet = [ |
@@ -678,8 +678,8 @@ discard block |
||
678 | 678 | if ($this->indexedMetadata) { |
679 | 679 | foreach ($this->indexedMetadata as $metadata) { |
680 | 680 | if ($metadata->getIndexIndexed()) { |
681 | - $listMetadataRecord = $metadata->getIndexName() . '_' . ($metadata->getIndexTokenized() ? 't' : 'u') . ($metadata->getIndexStored() ? 's' : 'u') . 'i'; |
|
682 | - $queryFields .= $listMetadataRecord . '^' . $metadata->getIndexBoost() . ' '; |
|
681 | + $listMetadataRecord = $metadata->getIndexName().'_'.($metadata->getIndexTokenized() ? 't' : 'u').($metadata->getIndexStored() ? 's' : 'u').'i'; |
|
682 | + $queryFields .= $listMetadataRecord.'^'.$metadata->getIndexBoost().' '; |
|
683 | 683 | } |
684 | 684 | } |
685 | 685 | } |
@@ -765,24 +765,24 @@ discard block |
||
765 | 765 | foreach ($this->collections as $collection) { |
766 | 766 | // check for virtual collections query string |
767 | 767 | if ($collection->getIndexSearch()) { |
768 | - $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '(' . $collection->getIndexSearch() . ')' : ' OR (' . $collection->getIndexSearch() . ')'; |
|
768 | + $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '('.$collection->getIndexSearch().')' : ' OR ('.$collection->getIndexSearch().')'; |
|
769 | 769 | } else { |
770 | - $collectionsQueryString .= empty($collectionsQueryString) ? '"' . $collection->getIndexName() . '"' : ' OR "' . $collection->getIndexName() . '"'; |
|
770 | + $collectionsQueryString .= empty($collectionsQueryString) ? '"'.$collection->getIndexName().'"' : ' OR "'.$collection->getIndexName().'"'; |
|
771 | 771 | } |
772 | 772 | } |
773 | 773 | |
774 | 774 | // distinguish between simple collection browsing and actual searching within the collection(s) |
775 | 775 | if (!empty($collectionsQueryString)) { |
776 | 776 | if (empty($query)) { |
777 | - $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . ') AND toplevel:true AND partof:0)'; |
|
777 | + $collectionsQueryString = '(collection_faceting:('.$collectionsQueryString.') AND toplevel:true AND partof:0)'; |
|
778 | 778 | } else { |
779 | - $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . '))'; |
|
779 | + $collectionsQueryString = '(collection_faceting:('.$collectionsQueryString.'))'; |
|
780 | 780 | } |
781 | 781 | } |
782 | 782 | |
783 | 783 | // virtual collections might query documents that are neither toplevel:true nor partof:0 and need to be searched separately |
784 | 784 | if (!empty($virtualCollectionsQueryString)) { |
785 | - $virtualCollectionsQueryString = '(' . $virtualCollectionsQueryString . ')'; |
|
785 | + $virtualCollectionsQueryString = '('.$virtualCollectionsQueryString.')'; |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | // combine both query strings into a single filterquery via OR if both are given, otherwise pass either of those |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | private function translateLanguageCode(&$doc): void |
861 | 861 | { |
862 | 862 | if (array_key_exists('language', $doc['metadata'])) { |
863 | - foreach($doc['metadata']['language'] as $indexName => $language) { |
|
863 | + foreach ($doc['metadata']['language'] as $indexName => $language) { |
|
864 | 864 | $doc['metadata']['language'][$indexName] = Helper::getLanguageName($language); |
865 | 865 | } |
866 | 866 | } |
@@ -96,8 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return void |
98 | 98 | */ |
99 | - public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = null, QueryResult $indexedMetadata = null) |
|
100 | - { |
|
99 | + public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = null, QueryResult $indexedMetadata = null) { |
|
101 | 100 | $this->documentRepository = $documentRepository; |
102 | 101 | $this->collections = $collections; |
103 | 102 | $this->settings = $settings; |
@@ -217,8 +216,7 @@ discard block |
||
217 | 216 | * @return mixed |
218 | 217 | */ |
219 | 218 | #[\ReturnTypeWillChange] |
220 | - public function offsetGet($offset) |
|
221 | - { |
|
219 | + public function offsetGet($offset) { |
|
222 | 220 | $idx = $this->result['document_keys'][$offset]; |
223 | 221 | $document = $this->result['documents'][$idx] ?? null; |
224 | 222 | |
@@ -286,8 +284,7 @@ discard block |
||
286 | 284 | * |
287 | 285 | * @return mixed |
288 | 286 | */ |
289 | - public function getSolrResults() |
|
290 | - { |
|
287 | + public function getSolrResults() { |
|
291 | 288 | return $this->result['solrResults']; |
292 | 289 | } |
293 | 290 | |
@@ -300,8 +297,7 @@ discard block |
||
300 | 297 | * |
301 | 298 | * @return mixed |
302 | 299 | */ |
303 | - public function getByUid($uid) |
|
304 | - { |
|
300 | + public function getByUid($uid) { |
|
305 | 301 | return $this->result['documents'][$uid]; |
306 | 302 | } |
307 | 303 | |
@@ -312,8 +308,7 @@ discard block |
||
312 | 308 | * |
313 | 309 | * @return SolrSearchQuery |
314 | 310 | */ |
315 | - public function getQuery() |
|
316 | - { |
|
311 | + public function getQuery() { |
|
317 | 312 | return new SolrSearchQuery($this); |
318 | 313 | } |
319 | 314 | |
@@ -324,8 +319,7 @@ discard block |
||
324 | 319 | * |
325 | 320 | * @return SolrSearch |
326 | 321 | */ |
327 | - public function getFirst() |
|
328 | - { |
|
322 | + public function getFirst() { |
|
329 | 323 | return $this[0]; |
330 | 324 | } |
331 | 325 | |
@@ -336,8 +330,7 @@ discard block |
||
336 | 330 | * |
337 | 331 | * @return array |
338 | 332 | */ |
339 | - public function toArray() |
|
340 | - { |
|
333 | + public function toArray() { |
|
341 | 334 | return array_values($this->result['documents']); |
342 | 335 | } |
343 | 336 | |
@@ -350,8 +343,7 @@ discard block |
||
350 | 343 | * |
351 | 344 | * @return int |
352 | 345 | */ |
353 | - public function getNumFound() |
|
354 | - { |
|
346 | + public function getNumFound() { |
|
355 | 347 | return $this->result['numFound']; |
356 | 348 | } |
357 | 349 | |
@@ -362,8 +354,7 @@ discard block |
||
362 | 354 | * |
363 | 355 | * @return void |
364 | 356 | */ |
365 | - public function prepare() |
|
366 | - { |
|
357 | + public function prepare() { |
|
367 | 358 | // Prepare query parameters. |
368 | 359 | $params = []; |
369 | 360 | $matches = []; |
@@ -479,8 +470,7 @@ discard block |
||
479 | 470 | * |
480 | 471 | * @return void |
481 | 472 | */ |
482 | - public function submit($start, $rows, $processResults = true) |
|
483 | - { |
|
473 | + public function submit($start, $rows, $processResults = true) { |
|
484 | 474 | $params = $this->params; |
485 | 475 | $params['start'] = $start; |
486 | 476 | $params['rows'] = $rows; |
@@ -638,8 +628,7 @@ discard block |
||
638 | 628 | * |
639 | 629 | * @return array The Apache Solr Documents that were fetched |
640 | 630 | */ |
641 | - protected function searchSolr($parameters = [], $enableCache = true) |
|
642 | - { |
|
631 | + protected function searchSolr($parameters = [], $enableCache = true) { |
|
643 | 632 | // Set query. |
644 | 633 | $parameters['query'] = isset($parameters['query']) ? $parameters['query'] : '*'; |
645 | 634 | $parameters['filterquery'] = isset($parameters['filterquery']) ? $parameters['filterquery'] : []; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return void |
98 | 98 | */ |
99 | - public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = null, QueryResult $indexedMetadata = null) |
|
99 | + public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = NULL, QueryResult $indexedMetadata = NULL) |
|
100 | 100 | { |
101 | 101 | $this->documentRepository = $documentRepository; |
102 | 102 | $this->collections = $collections; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function count(): int |
129 | 129 | { |
130 | - if ($this->result === null) { |
|
130 | + if ($this->result === NULL) { |
|
131 | 131 | return 0; |
132 | 132 | } |
133 | 133 | |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | public function offsetGet($offset) |
221 | 221 | { |
222 | 222 | $idx = $this->result['document_keys'][$offset]; |
223 | - $document = $this->result['documents'][$idx] ?? null; |
|
223 | + $document = $this->result['documents'][$idx] ?? NULL; |
|
224 | 224 | |
225 | - if ($document !== null) { |
|
225 | + if ($document !== NULL) { |
|
226 | 226 | // It may happen that a Solr group only includes non-toplevel results, |
227 | 227 | // in which case metadata of toplevel entry isn't yet filled. |
228 | 228 | if (empty($document['metadata'])) { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | // get title of parent/grandparent/... if empty |
238 | 238 | if (empty($document['title']) && $document['partOf'] > 0) { |
239 | - $superiorTitle = AbstractDocument::getTitle($document['partOf'], true); |
|
239 | + $superiorTitle = AbstractDocument::getTitle($document['partOf'], TRUE); |
|
240 | 240 | if (!empty($superiorTitle)) { |
241 | 241 | $document['title'] = '[' . $superiorTitle . ']'; |
242 | 242 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | if (!empty($this->searchParams['query'])) { |
382 | 382 | $query = $fields['fulltext'] . ':(' . Solr::escapeQuery(trim($this->searchParams['query'])) . ')'; |
383 | 383 | } |
384 | - $params['fulltext'] = true; |
|
384 | + $params['fulltext'] = TRUE; |
|
385 | 385 | } else { |
386 | 386 | // Retain given search field if valid. |
387 | 387 | if (!empty($this->searchParams['query'])) { |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | $this->params = $params; |
466 | 466 | |
467 | 467 | // Send off query to get total number of search results in advance |
468 | - $this->submit(0, 1, false); |
|
468 | + $this->submit(0, 1, FALSE); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -479,14 +479,14 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return void |
481 | 481 | */ |
482 | - public function submit($start, $rows, $processResults = true) |
|
482 | + public function submit($start, $rows, $processResults = TRUE) |
|
483 | 483 | { |
484 | 484 | $params = $this->params; |
485 | 485 | $params['start'] = $start; |
486 | 486 | $params['rows'] = $rows; |
487 | 487 | |
488 | 488 | // Perform search. |
489 | - $result = $this->searchSolr($params, true); |
|
489 | + $result = $this->searchSolr($params, TRUE); |
|
490 | 490 | |
491 | 491 | // Initialize values |
492 | 492 | $documents = []; |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | } |
512 | 512 | if (isset($documents[$doc['uid']])) { |
513 | 513 | $this->translateLanguageCode($doc); |
514 | - if ($doc['toplevel'] === false) { |
|
514 | + if ($doc['toplevel'] === FALSE) { |
|
515 | 515 | // this maybe a chapter, article, ..., year |
516 | 516 | if ($doc['type'] === 'year') { |
517 | 517 | continue; |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | } |
538 | 538 | $documents[$doc['uid']]['searchResults'][] = $searchResult; |
539 | 539 | } |
540 | - } else if ($doc['toplevel'] === true) { |
|
540 | + } else if ($doc['toplevel'] === TRUE) { |
|
541 | 541 | foreach ($params['listMetadataRecords'] as $indexName => $solrField) { |
542 | 542 | if (isset($doc['metadata'][$indexName])) { |
543 | 543 | $documents[$doc['uid']]['metadata'][$indexName] = $doc['metadata'][$indexName]; |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | $totalChildren = count($children); |
553 | 553 | |
554 | 554 | for ($start = 0; $start < $totalChildren; $start += $batchSize) { |
555 | - $batch = array_slice($children, $start, $batchSize, true); |
|
555 | + $batch = array_slice($children, $start, $batchSize, TRUE); |
|
556 | 556 | |
557 | 557 | // Fetch metadata for the current batch |
558 | 558 | $metadataOf = $this->fetchToplevelMetadataFromSolr([ |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | $params['filterquery'][] = ['query' => 'toplevel:true']; |
619 | 619 | |
620 | 620 | // Perform search. |
621 | - $result = $this->searchSolr($params, true); |
|
621 | + $result = $this->searchSolr($params, TRUE); |
|
622 | 622 | |
623 | 623 | foreach ($result['documents'] as $doc) { |
624 | 624 | $this->translateLanguageCode($doc); |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | * |
639 | 639 | * @return array The Apache Solr Documents that were fetched |
640 | 640 | */ |
641 | - protected function searchSolr($parameters = [], $enableCache = true) |
|
641 | + protected function searchSolr($parameters = [], $enableCache = TRUE) |
|
642 | 642 | { |
643 | 643 | // Set query. |
644 | 644 | $parameters['query'] = isset($parameters['query']) ? $parameters['query'] : '*'; |
@@ -657,10 +657,10 @@ discard block |
||
657 | 657 | } |
658 | 658 | |
659 | 659 | $cacheIdentifier = ''; |
660 | - $cache = null; |
|
660 | + $cache = NULL; |
|
661 | 661 | // Calculate cache identifier. |
662 | - if ($enableCache === true) { |
|
663 | - $cacheIdentifier = Helper::digest($solr->core . print_r($parameters, true)); |
|
662 | + if ($enableCache === TRUE) { |
|
663 | + $cacheIdentifier = Helper::digest($solr->core . print_r($parameters, TRUE)); |
|
664 | 664 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_solr'); |
665 | 665 | } |
666 | 666 | $resultSet = [ |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | 'numberOfToplevels' => 0, |
669 | 669 | 'numFound' => 0, |
670 | 670 | ]; |
671 | - if ($enableCache === false || ($entry = $cache->get($cacheIdentifier)) === false) { |
|
671 | + if ($enableCache === FALSE || ($entry = $cache->get($cacheIdentifier)) === FALSE) { |
|
672 | 672 | $selectQuery = $solr->service->createSelect($parameters); |
673 | 673 | |
674 | 674 | $edismax = $selectQuery->getEDisMax(); |
@@ -689,17 +689,17 @@ discard block |
||
689 | 689 | $grouping = $selectQuery->getGrouping(); |
690 | 690 | $grouping->addField('uid'); |
691 | 691 | $grouping->setLimit(100); // Results in group (TODO: check) |
692 | - $grouping->setNumberOfGroups(true); |
|
692 | + $grouping->setNumberOfGroups(TRUE); |
|
693 | 693 | |
694 | - $fulltextExists = $parameters['fulltext'] ?? false; |
|
695 | - if ($fulltextExists === true) { |
|
694 | + $fulltextExists = $parameters['fulltext'] ?? FALSE; |
|
695 | + if ($fulltextExists === TRUE) { |
|
696 | 696 | // get highlighting component and apply settings |
697 | 697 | $selectQuery->getHighlighting(); |
698 | 698 | } |
699 | 699 | |
700 | 700 | $solrRequest = $solr->service->createRequest($selectQuery); |
701 | 701 | |
702 | - if ($fulltextExists === true) { |
|
702 | + if ($fulltextExists === TRUE) { |
|
703 | 703 | // If it is a fulltext search, enable highlighting. |
704 | 704 | // field for which highlighting is going to be performed, |
705 | 705 | // is required if you want to have OCR highlighting |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | $resultSet['numberOfToplevels'] = $uidGroup->getNumberOfGroups(); |
727 | 727 | $resultSet['numFound'] = $uidGroup->getMatches(); |
728 | 728 | $highlighting = []; |
729 | - if ($fulltextExists === true) { |
|
729 | + if ($fulltextExists === TRUE) { |
|
730 | 730 | $data = $result->getData(); |
731 | 731 | $highlighting = $data['ocrHighlighting']; |
732 | 732 | } |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | } |
740 | 740 | |
741 | 741 | // Save value in cache. |
742 | - if (!empty($resultSet['documents']) && $enableCache === true) { |
|
742 | + if (!empty($resultSet['documents']) && $enableCache === TRUE) { |
|
743 | 743 | $cache->set($cacheIdentifier, $resultSet); |
744 | 744 | } |
745 | 745 | } else { |
@@ -38,15 +38,15 @@ |
||
38 | 38 | */ |
39 | 39 | private int $offset; |
40 | 40 | |
41 | - /** |
|
42 | - * Constructs SolrSearchQuery instance. |
|
43 | - * |
|
44 | - * @access public |
|
45 | - * |
|
46 | - * @param SolrSearch $solrSearch |
|
47 | - * |
|
48 | - * @return void |
|
49 | - */ |
|
41 | + /** |
|
42 | + * Constructs SolrSearchQuery instance. |
|
43 | + * |
|
44 | + * @access public |
|
45 | + * |
|
46 | + * @param SolrSearch $solrSearch |
|
47 | + * |
|
48 | + * @return void |
|
49 | + */ |
|
50 | 50 | public function __construct($solrSearch) |
51 | 51 | { |
52 | 52 | $this->solrSearch = $solrSearch; |
@@ -18,8 +18,7 @@ discard block |
||
18 | 18 | * @property int $limit |
19 | 19 | * @property int $offset |
20 | 20 | */ |
21 | -class SolrSearchQuery implements QueryInterface |
|
22 | -{ |
|
21 | +class SolrSearchQuery implements QueryInterface { |
|
23 | 22 | /** |
24 | 23 | * @access private |
25 | 24 | * @var SolrSearch |
@@ -47,8 +46,7 @@ discard block |
||
47 | 46 | * |
48 | 47 | * @return void |
49 | 48 | */ |
50 | - public function __construct($solrSearch) |
|
51 | - { |
|
49 | + public function __construct($solrSearch) { |
|
52 | 50 | $this->solrSearch = $solrSearch; |
53 | 51 | |
54 | 52 | $this->offset = 0; |
@@ -70,8 +68,7 @@ discard block |
||
70 | 68 | */ |
71 | 69 | // TODO: Return type (array) of method SolrSearchQuery::execute() should be compatible with return type (iterable<object>&TYPO3\CMS\Extbase\Persistence\QueryResultInterface) of method TYPO3\CMS\Extbase\Persistence\QueryInterface::execute() |
72 | 70 | // @phpstan-ignore-next-line |
73 | - public function execute($returnRawQueryResult = false) |
|
74 | - { |
|
71 | + public function execute($returnRawQueryResult = false) { |
|
75 | 72 | $this->solrSearch->submit($this->offset, $this->limit); |
76 | 73 | |
77 | 74 | // solrSearch now only contains the results in range, indexed in [0, n) |
@@ -146,8 +143,8 @@ discard block |
||
146 | 143 | // @phpstan-ignore-next-line |
147 | 144 | public function getQuerySettings() {} |
148 | 145 | |
149 | - public function count() |
|
150 | - {// @phpstan-ignore-next-line |
|
146 | + public function count() { |
|
147 | +// @phpstan-ignore-next-line |
|
151 | 148 | // TODO? |
152 | 149 | } |
153 | 150 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | // TODO: Return type (array) of method SolrSearchQuery::execute() should be compatible with return type (iterable<object>&TYPO3\CMS\Extbase\Persistence\QueryResultInterface) of method TYPO3\CMS\Extbase\Persistence\QueryInterface::execute() |
72 | 72 | // @phpstan-ignore-next-line |
73 | - public function execute($returnRawQueryResult = false) |
|
73 | + public function execute($returnRawQueryResult = FALSE) |
|
74 | 74 | { |
75 | 75 | $this->solrSearch->submit($this->offset, $this->limit); |
76 | 76 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | // @phpstan-ignore-next-line |
126 | 126 | public function logicalNot(ConstraintInterface $constraint) {} |
127 | 127 | // @phpstan-ignore-next-line |
128 | - public function equals($propertyName, $operand, $caseSensitive = true) {} |
|
128 | + public function equals($propertyName, $operand, $caseSensitive = TRUE) {} |
|
129 | 129 | // @phpstan-ignore-next-line |
130 | 130 | public function like($propertyName, $operand) {} |
131 | 131 | // @phpstan-ignore-next-line |
@@ -22,8 +22,7 @@ |
||
22 | 22 | * |
23 | 23 | * @abstract |
24 | 24 | */ |
25 | -interface FulltextInterface |
|
26 | -{ |
|
25 | +interface FulltextInterface { |
|
27 | 26 | /** |
28 | 27 | * This extracts raw fulltext data from XML |
29 | 28 | * |
@@ -33,8 +33,7 @@ |
||
33 | 33 | * |
34 | 34 | * @return void |
35 | 35 | */ |
36 | - public function emit() |
|
37 | - { |
|
36 | + public function emit() { |
|
38 | 37 | // Disable output buffering |
39 | 38 | ob_end_flush(); |
40 | 39 |
@@ -22,8 +22,7 @@ |
||
22 | 22 | * |
23 | 23 | * @abstract |
24 | 24 | */ |
25 | -interface MetadataInterface |
|
26 | -{ |
|
25 | +interface MetadataInterface { |
|
27 | 26 | /** |
28 | 27 | * This extracts metadata from XML |
29 | 28 | * |