@@ -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 | * |
@@ -32,8 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @access public |
34 | 34 | */ |
35 | -class Indexer |
|
36 | -{ |
|
35 | +class Indexer { |
|
37 | 36 | /** |
38 | 37 | * @access public |
39 | 38 | * @static |
@@ -604,8 +603,7 @@ discard block |
||
604 | 603 | * |
605 | 604 | * @return array|string |
606 | 605 | */ |
607 | - private static function removeAppendsFromAuthor($authors) |
|
608 | - { |
|
606 | + private static function removeAppendsFromAuthor($authors) { |
|
609 | 607 | if (is_array($authors)) { |
610 | 608 | foreach ($authors as $i => $author) { |
611 | 609 | $splitName = explode(pack('C', 31), $author); |
@@ -685,7 +683,6 @@ discard block |
||
685 | 683 | * |
686 | 684 | * @return void |
687 | 685 | */ |
688 | - private function __construct() |
|
689 | - { |
|
686 | + private function __construct() { |
|
690 | 687 | } |
691 | 688 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $parent->setCurrentDocument($doc); |
114 | 114 | $success = self::add($parent, $documentRepository); |
115 | 115 | } else { |
116 | - Helper::log('Could not load parent document with UID ' . $document->getCurrentDocument()->parentId, LOG_SEVERITY_ERROR); |
|
116 | + Helper::log('Could not load parent document with UID '.$document->getCurrentDocument()->parentId, LOG_SEVERITY_ERROR); |
|
117 | 117 | return false; |
118 | 118 | } |
119 | 119 | } |
@@ -196,19 +196,19 @@ discard block |
||
196 | 196 | } catch (\Exception $e) { |
197 | 197 | if (!(Environment::isCli())) { |
198 | 198 | Helper::addMessage( |
199 | - Helper::getLanguageService()->getLL('flash.solrException') . ' ' . htmlspecialchars($e->getMessage()), |
|
199 | + Helper::getLanguageService()->getLL('flash.solrException').' '.htmlspecialchars($e->getMessage()), |
|
200 | 200 | Helper::getLanguageService()->getLL('flash.error'), |
201 | 201 | FlashMessage::ERROR, |
202 | 202 | true, |
203 | 203 | 'core.template.flashMessages' |
204 | 204 | ); |
205 | 205 | } |
206 | - Helper::log('Apache Solr threw exception: "' . $e->getMessage() . '"', LOG_SEVERITY_ERROR); |
|
206 | + Helper::log('Apache Solr threw exception: "'.$e->getMessage().'"', LOG_SEVERITY_ERROR); |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | - Helper::log('Document not deleted from SOLR - problem with the connection to the SOLR core ' . $solrCoreUid, LOG_SEVERITY_ERROR); |
|
211 | + Helper::log('Document not deleted from SOLR - problem with the connection to the SOLR core '.$solrCoreUid, LOG_SEVERITY_ERROR); |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | // Sanitize input. |
230 | 230 | $pid = max((int) $pid, 0); |
231 | 231 | if (!$pid) { |
232 | - Helper::log('Invalid PID ' . $pid . ' for metadata configuration', LOG_SEVERITY_ERROR); |
|
232 | + Helper::log('Invalid PID '.$pid.' for metadata configuration', LOG_SEVERITY_ERROR); |
|
233 | 233 | return ''; |
234 | 234 | } |
235 | 235 | // Load metadata configuration. |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $suffix = (in_array($indexName, self::$fields['tokenized']) ? 't' : 'u'); |
239 | 239 | $suffix .= (in_array($indexName, self::$fields['stored']) ? 's' : 'u'); |
240 | 240 | $suffix .= (in_array($indexName, self::$fields['indexed']) ? 'i' : 'u'); |
241 | - $indexName .= '_' . $suffix; |
|
241 | + $indexName .= '_'.$suffix; |
|
242 | 242 | return $indexName; |
243 | 243 | } |
244 | 244 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $solrDoc->setField('title', $metadata['title'][0]); |
355 | 355 | $solrDoc->setField('volume', $metadata['volume'][0]); |
356 | 356 | // verify date formatting |
357 | - if(strtotime($metadata['date'][0])) { |
|
357 | + if (strtotime($metadata['date'][0])) { |
|
358 | 358 | $solrDoc->setField('date', self::getFormattedDate($metadata['date'][0])); |
359 | 359 | } |
360 | 360 | $solrDoc->setField('record_id', $metadata['record_id'][0]); |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | $solrDoc->setField(self::getIndexFieldName($indexName, $document->getPid()), $data); |
518 | 518 | if (in_array($indexName, self::$fields['sortables'])) { |
519 | 519 | // Add sortable fields to index. |
520 | - $solrDoc->setField($indexName . '_sorting', $metadata[$indexName . '_sorting'][0]); |
|
520 | + $solrDoc->setField($indexName.'_sorting', $metadata[$indexName.'_sorting'][0]); |
|
521 | 521 | } |
522 | 522 | if (in_array($indexName, self::$fields['facets'])) { |
523 | 523 | // Add facets to index. |
524 | - $solrDoc->setField($indexName . '_faceting', $data); |
|
524 | + $solrDoc->setField($indexName.'_faceting', $data); |
|
525 | 525 | } |
526 | 526 | if (in_array($indexName, self::$fields['autocomplete'])) { |
527 | 527 | $autocomplete = array_merge($autocomplete, $data); |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | $data = self::removeAppendsFromAuthor($data); |
558 | 558 | } |
559 | 559 | // Add facets to index. |
560 | - $solrDoc->setField($indexName . '_faceting', $data); |
|
560 | + $solrDoc->setField($indexName.'_faceting', $data); |
|
561 | 561 | } |
562 | 562 | } |
563 | 563 | // Add sorting information to physical sub-elements if applicable. |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | $update = self::$solr->service->createUpdate(); |
588 | 588 | $query = ""; |
589 | 589 | if ($field == 'uid' || $field == 'partof') { |
590 | - $query = $field . ':' . $value; |
|
590 | + $query = $field.':'.$value; |
|
591 | 591 | } else { |
592 | - $query = $field . ':"' . $value . '"'; |
|
592 | + $query = $field.':"'.$value.'"'; |
|
593 | 593 | } |
594 | 594 | $update->addDeleteQuery($query); |
595 | 595 | $update->addCommit(); |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | { |
615 | 615 | $solrDoc = $updateQuery->createDocument(); |
616 | 616 | // Create unique identifier from document's UID and unit's XML ID. |
617 | - $solrDoc->setField('id', $document->getUid() . $unit['id']); |
|
617 | + $solrDoc->setField('id', $document->getUid().$unit['id']); |
|
618 | 618 | $solrDoc->setField('uid', $document->getUid()); |
619 | 619 | $solrDoc->setField('pid', $document->getPid()); |
620 | 620 | $solrDoc->setField('partof', $document->getPartof()); |
@@ -693,9 +693,9 @@ discard block |
||
693 | 693 | private static function handleException(string $errorMessage): void |
694 | 694 | { |
695 | 695 | if (!(Environment::isCli())) { |
696 | - self::addErrorMessage(Helper::getLanguageService()->getLL('flash.solrException') . '<br />' . htmlspecialchars($errorMessage)); |
|
696 | + self::addErrorMessage(Helper::getLanguageService()->getLL('flash.solrException').'<br />'.htmlspecialchars($errorMessage)); |
|
697 | 697 | } |
698 | - Helper::log('Apache Solr threw exception: "' . $errorMessage . '"', LOG_SEVERITY_ERROR); |
|
698 | + Helper::log('Apache Solr threw exception: "'.$errorMessage.'"', LOG_SEVERITY_ERROR); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @see $fields |
68 | 68 | */ |
69 | - protected static bool $fieldsLoaded = false; |
|
69 | + protected static bool $fieldsLoaded = FALSE; |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @access protected |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | public static function add(Document $document, DocumentRepository $documentRepository): bool |
98 | 98 | { |
99 | 99 | if (in_array($document->getUid(), self::$processedDocs)) { |
100 | - return true; |
|
100 | + return TRUE; |
|
101 | 101 | } elseif (self::solrConnect($document->getSolrcore(), $document->getPid())) { |
102 | - $success = true; |
|
102 | + $success = TRUE; |
|
103 | 103 | Helper::getLanguageService()->includeLLFile('EXT:dlf/Resources/Private/Language/locallang_be.xlf'); |
104 | 104 | // Handle multi-volume documents. |
105 | 105 | $parentId = $document->getPartof(); |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | $parent = $documentRepository->findByUid($parentId); |
109 | 109 | if ($parent) { |
110 | 110 | // get XML document of parent |
111 | - $doc = AbstractDocument::getInstance($parent->getLocation(), ['storagePid' => $parent->getPid()], true); |
|
112 | - if ($doc !== null) { |
|
111 | + $doc = AbstractDocument::getInstance($parent->getLocation(), ['storagePid' => $parent->getPid()], TRUE); |
|
112 | + if ($doc !== NULL) { |
|
113 | 113 | $parent->setCurrentDocument($doc); |
114 | 114 | $success = self::add($parent, $documentRepository); |
115 | 115 | } else { |
116 | 116 | Helper::log('Could not load parent document with UID ' . $document->getCurrentDocument()->parentId, LOG_SEVERITY_ERROR); |
117 | - return false; |
|
117 | + return FALSE; |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | return $success; |
162 | 162 | } catch (\Exception $e) { |
163 | 163 | self::handleException($e->getMessage()); |
164 | - return false; |
|
164 | + return FALSE; |
|
165 | 165 | } |
166 | 166 | } else { |
167 | 167 | if (!(Environment::isCli())) { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | ); |
173 | 173 | } |
174 | 174 | Helper::log('Could not connect to Apache Solr server', LOG_SEVERITY_ERROR); |
175 | - return false; |
|
175 | + return FALSE; |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -192,24 +192,24 @@ discard block |
||
192 | 192 | if (self::solrConnect($solrCoreUid, $input->getOption('pid'))) { |
193 | 193 | try { |
194 | 194 | self::deleteDocument($field, $input->getOption('doc')); |
195 | - return true; |
|
195 | + return TRUE; |
|
196 | 196 | } catch (\Exception $e) { |
197 | 197 | if (!(Environment::isCli())) { |
198 | 198 | Helper::addMessage( |
199 | 199 | Helper::getLanguageService()->getLL('flash.solrException') . ' ' . htmlspecialchars($e->getMessage()), |
200 | 200 | Helper::getLanguageService()->getLL('flash.error'), |
201 | 201 | FlashMessage::ERROR, |
202 | - true, |
|
202 | + TRUE, |
|
203 | 203 | 'core.template.flashMessages' |
204 | 204 | ); |
205 | 205 | } |
206 | 206 | Helper::log('Apache Solr threw exception: "' . $e->getMessage() . '"', LOG_SEVERITY_ERROR); |
207 | - return false; |
|
207 | + return FALSE; |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | 211 | Helper::log('Document not deleted from SOLR - problem with the connection to the SOLR core ' . $solrCoreUid, LOG_SEVERITY_ERROR); |
212 | - return false; |
|
212 | + return FALSE; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | self::$fields['autocomplete'][] = $indexing['index_name']; |
306 | 306 | } |
307 | 307 | } |
308 | - self::$fieldsLoaded = true; |
|
308 | + self::$fieldsLoaded = TRUE; |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | */ |
324 | 324 | protected static function processLogical(Document $document, array $logicalUnit): bool |
325 | 325 | { |
326 | - $success = true; |
|
326 | + $success = TRUE; |
|
327 | 327 | $doc = $document->getCurrentDocument(); |
328 | 328 | $doc->cPid = $document->getPid(); |
329 | 329 | // Get metadata for logical unit. |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | $solrDoc->setField('thumbnail', $doc->getFileLocation($logicalUnit['thumbnailId'])); |
351 | 351 | } |
352 | 352 | // There can be only one toplevel unit per UID, independently of backend configuration |
353 | - $solrDoc->setField('toplevel', $logicalUnit['id'] == $doc->toplevelId ? true : false); |
|
353 | + $solrDoc->setField('toplevel', $logicalUnit['id'] == $doc->toplevelId ? TRUE : FALSE); |
|
354 | 354 | $solrDoc->setField('title', $metadata['title'][0]); |
355 | 355 | $solrDoc->setField('volume', $metadata['volume'][0]); |
356 | 356 | // verify date formatting |
@@ -386,11 +386,11 @@ discard block |
||
386 | 386 | self::$solr->service->update($updateQuery); |
387 | 387 | } catch (\Exception $e) { |
388 | 388 | self::handleException($e->getMessage()); |
389 | - return false; |
|
389 | + return FALSE; |
|
390 | 390 | } |
391 | 391 | } else { |
392 | 392 | Helper::log('Tip: If "record_id" field is missing then there is possibility that METS file still contains it but with the wrong source type attribute in "recordIdentifier" element', LOG_SEVERITY_NOTICE); |
393 | - return false; |
|
393 | + return FALSE; |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | // Check for child elements... |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | break; |
439 | 439 | } |
440 | 440 | } |
441 | - $solrDoc->setField('toplevel', false); |
|
441 | + $solrDoc->setField('toplevel', FALSE); |
|
442 | 442 | $solrDoc->setField('type', $physicalUnit['type']); |
443 | 443 | $solrDoc->setField('collection', $doc->metadataArray[$doc->toplevelId]['collection']); |
444 | 444 | $solrDoc->setField('location', $document->getLocation()); |
@@ -459,10 +459,10 @@ discard block |
||
459 | 459 | self::$solr->service->update($updateQuery); |
460 | 460 | } catch (\Exception $e) { |
461 | 461 | self::handleException($e->getMessage()); |
462 | - return false; |
|
462 | + return FALSE; |
|
463 | 463 | } |
464 | 464 | } |
465 | - return true; |
|
465 | + return TRUE; |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | if ($pid) { |
489 | 489 | self::loadIndexConf($pid); |
490 | 490 | } |
491 | - return true; |
|
491 | + return TRUE; |
|
492 | 492 | } |
493 | - return false; |
|
493 | + return FALSE; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | $message, |
738 | 738 | Helper::getLanguageService()->getLL($type), |
739 | 739 | $status, |
740 | - true, |
|
740 | + TRUE, |
|
741 | 741 | 'core.template.flashMessages' |
742 | 742 | ); |
743 | 743 | } |
@@ -664,14 +664,14 @@ discard block |
||
664 | 664 | if ($fileContent !== false) { |
665 | 665 | $textFormat = $this->getTextFormat($fileContent); |
666 | 666 | } else { |
667 | - $this->logger->warning('Couldn\'t load full text file for structure node @ID "' . $id . '"'); |
|
667 | + $this->logger->warning('Couldn\'t load full text file for structure node @ID "'.$id.'"'); |
|
668 | 668 | return $fullText; |
669 | 669 | } |
670 | 670 | break; |
671 | 671 | } |
672 | 672 | } |
673 | 673 | } else { |
674 | - $this->logger->warning('Invalid structure node @ID "' . $id . '"'); |
|
674 | + $this->logger->warning('Invalid structure node @ID "'.$id.'"'); |
|
675 | 675 | return $fullText; |
676 | 676 | } |
677 | 677 | // Is this text format supported? |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | } |
684 | 684 | $fullText = $textMiniOcr; |
685 | 685 | } else { |
686 | - $this->logger->warning('Unsupported text format "' . $textFormat . '" in physical node with @ID "' . $id . '"'); |
|
686 | + $this->logger->warning('Unsupported text format "'.$textFormat.'" in physical node with @ID "'.$id.'"'); |
|
687 | 687 | } |
688 | 688 | return $fullText; |
689 | 689 | } |
@@ -712,10 +712,10 @@ discard block |
||
712 | 712 | $textMiniOcr = $obj->getTextAsMiniOcr($ocrTextXml); |
713 | 713 | $this->rawTextArray[$id] = $textMiniOcr; |
714 | 714 | } else { |
715 | - $this->logger->warning('Invalid class/method "' . $class . '->getRawText()" for text format "' . $textFormat . '"'); |
|
715 | + $this->logger->warning('Invalid class/method "'.$class.'->getRawText()" for text format "'.$textFormat.'"'); |
|
716 | 716 | } |
717 | 717 | } else { |
718 | - $this->logger->warning('Class "' . $class . ' does not exists for "' . $textFormat . ' text format"'); |
|
718 | + $this->logger->warning('Class "'.$class.' does not exists for "'.$textFormat.' text format"'); |
|
719 | 719 | } |
720 | 720 | return $textMiniOcr; |
721 | 721 | } |
@@ -790,10 +790,10 @@ discard block |
||
790 | 790 | $title = self::getTitle($partof, true); |
791 | 791 | } |
792 | 792 | } else { |
793 | - Helper::log('No document with UID ' . $uid . ' found or document not accessible', LOG_SEVERITY_WARNING); |
|
793 | + Helper::log('No document with UID '.$uid.' found or document not accessible', LOG_SEVERITY_WARNING); |
|
794 | 794 | } |
795 | 795 | } else { |
796 | - Helper::log('Invalid UID ' . $uid . ' for document', LOG_SEVERITY_ERROR); |
|
796 | + Helper::log('Invalid UID '.$uid.' for document', LOG_SEVERITY_ERROR); |
|
797 | 797 | } |
798 | 798 | return $title; |
799 | 799 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | // the actual loading is format specific |
884 | 884 | return $this->loadLocation($location); |
885 | 885 | } else { |
886 | - $this->logger->error('Invalid file location "' . $location . '" for document loading'); |
|
886 | + $this->logger->error('Invalid file location "'.$location.'" for document loading'); |
|
887 | 887 | } |
888 | 888 | return false; |
889 | 889 | } |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | // Set metadata definitions' PID. |
1036 | 1036 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
1037 | 1037 | if (!$cPid) { |
1038 | - $this->logger->error('Invalid PID ' . $cPid . ' for metadata definitions'); |
|
1038 | + $this->logger->error('Invalid PID '.$cPid.' for metadata definitions'); |
|
1039 | 1039 | return []; |
1040 | 1040 | } |
1041 | 1041 | if ( |
@@ -1212,12 +1212,12 @@ discard block |
||
1212 | 1212 | */ |
1213 | 1213 | public function __get(string $var) |
1214 | 1214 | { |
1215 | - $method = 'magicGet' . ucfirst($var); |
|
1215 | + $method = 'magicGet'.ucfirst($var); |
|
1216 | 1216 | if ( |
1217 | 1217 | !property_exists($this, $var) |
1218 | 1218 | || !method_exists($this, $method) |
1219 | 1219 | ) { |
1220 | - $this->logger->warning('There is no getter function for property "' . $var . '"'); |
|
1220 | + $this->logger->warning('There is no getter function for property "'.$var.'"'); |
|
1221 | 1221 | return null; |
1222 | 1222 | } else { |
1223 | 1223 | return $this->$method(); |
@@ -1250,12 +1250,12 @@ discard block |
||
1250 | 1250 | */ |
1251 | 1251 | public function __set(string $var, $value): void |
1252 | 1252 | { |
1253 | - $method = '_set' . ucfirst($var); |
|
1253 | + $method = '_set'.ucfirst($var); |
|
1254 | 1254 | if ( |
1255 | 1255 | !property_exists($this, $var) |
1256 | 1256 | || !method_exists($this, $method) |
1257 | 1257 | ) { |
1258 | - $this->logger->warning('There is no setter function for property "' . $var . '"'); |
|
1258 | + $this->logger->warning('There is no setter function for property "'.$var.'"'); |
|
1259 | 1259 | } else { |
1260 | 1260 | $this->$method($value); |
1261 | 1261 | } |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * @property-read string $toplevelId this holds the toplevel structure's "@ID" (METS) or the manifest's "@id" (IIIF) |
58 | 58 | * @property \SimpleXMLElement $xml this holds the whole XML file as \SimpleXMLElement object |
59 | 59 | */ |
60 | -abstract class AbstractDocument |
|
61 | -{ |
|
60 | +abstract class AbstractDocument { |
|
62 | 61 | /** |
63 | 62 | * @access protected |
64 | 63 | * @var Logger This holds the logger |
@@ -838,8 +837,7 @@ discard block |
||
838 | 837 | * @return int|bool false if structure with $logId is not a child of this substructure, |
839 | 838 | * or the actual depth. |
840 | 839 | */ |
841 | - protected function getTreeDepth(array $structure, int $depth, string $logId) |
|
842 | - { |
|
840 | + protected function getTreeDepth(array $structure, int $depth, string $logId) { |
|
843 | 841 | foreach ($structure as $element) { |
844 | 842 | if ($element['id'] == $logId) { |
845 | 843 | return $depth; |
@@ -862,8 +860,7 @@ discard block |
||
862 | 860 | * |
863 | 861 | * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. |
864 | 862 | */ |
865 | - public function getStructureDepth(string $logId) |
|
866 | - { |
|
863 | + public function getStructureDepth(string $logId) { |
|
867 | 864 | return $this->getTreeDepth($this->magicGetTableOfContents(), 1, $logId); |
868 | 865 | } |
869 | 866 | |
@@ -1122,8 +1119,7 @@ discard block |
||
1122 | 1119 | * |
1123 | 1120 | * @return mixed The METS file's / IIIF manifest's record identifier |
1124 | 1121 | */ |
1125 | - protected function magicGetRecordId() |
|
1126 | - { |
|
1122 | + protected function magicGetRecordId() { |
|
1127 | 1123 | return $this->recordId; |
1128 | 1124 | } |
1129 | 1125 | |
@@ -1193,8 +1189,7 @@ discard block |
||
1193 | 1189 | * |
1194 | 1190 | * @return void |
1195 | 1191 | */ |
1196 | - protected function __construct(int $pid, string $location, $preloadedDocument, array $settings = []) |
|
1197 | - { |
|
1192 | + protected function __construct(int $pid, string $location, $preloadedDocument, array $settings = []) { |
|
1198 | 1193 | $this->pid = $pid; |
1199 | 1194 | $this->setPreloadedDocument($preloadedDocument); |
1200 | 1195 | $this->init($location, $settings); |
@@ -1210,8 +1205,7 @@ discard block |
||
1210 | 1205 | * |
1211 | 1206 | * @return mixed Value of $this->$var |
1212 | 1207 | */ |
1213 | - public function __get(string $var) |
|
1214 | - { |
|
1208 | + public function __get(string $var) { |
|
1215 | 1209 | $method = 'magicGet' . ucfirst($var); |
1216 | 1210 | if ( |
1217 | 1211 | !property_exists($this, $var) |
@@ -1272,8 +1266,7 @@ discard block |
||
1272 | 1266 | * |
1273 | 1267 | * @return AbstractDocument|false |
1274 | 1268 | */ |
1275 | - private static function getDocumentCache(string $location) |
|
1276 | - { |
|
1269 | + private static function getDocumentCache(string $location) { |
|
1277 | 1270 | $cacheIdentifier = hash('md5', $location); |
1278 | 1271 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_doc'); |
1279 | 1272 | $cacheHit = $cache->get($cacheIdentifier); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @see $formats |
113 | 113 | */ |
114 | - protected bool $formatsLoaded = false; |
|
114 | + protected bool $formatsLoaded = FALSE; |
|
115 | 115 | |
116 | 116 | /** |
117 | 117 | * Are there any fulltext files available? This also includes IIIF text annotations |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | * @access protected |
122 | 122 | * @var bool |
123 | 123 | */ |
124 | - protected bool $hasFulltext = false; |
|
124 | + protected bool $hasFulltext = FALSE; |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * @access protected |
128 | 128 | * @var array Last searched logical and physical page |
129 | 129 | */ |
130 | - protected array $lastSearchedPhysicalPage = ['logicalPage' => null, 'physicalPage' => null]; |
|
130 | + protected array $lastSearchedPhysicalPage = ['logicalPage' => NULL, 'physicalPage' => NULL]; |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * @access protected |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @see $metadataArray |
152 | 152 | */ |
153 | - protected bool $metadataArrayLoaded = false; |
|
153 | + protected bool $metadataArrayLoaded = FALSE; |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * @access protected |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @see $physicalStructure |
184 | 184 | */ |
185 | - protected bool $physicalStructureLoaded = false; |
|
185 | + protected bool $physicalStructureLoaded = FALSE; |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * @access protected |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @access protected |
204 | 204 | * @var bool Is the document instantiated successfully? |
205 | 205 | */ |
206 | - protected bool $ready = false; |
|
206 | + protected bool $ready = FALSE; |
|
207 | 207 | |
208 | 208 | /** |
209 | 209 | * @access protected |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @see $rootId |
225 | 225 | */ |
226 | - protected bool $rootIdLoaded = false; |
|
226 | + protected bool $rootIdLoaded = FALSE; |
|
227 | 227 | |
228 | 228 | /** |
229 | 229 | * @access protected |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @see $smLinks |
239 | 239 | */ |
240 | - protected bool $smLinksLoaded = false; |
|
240 | + protected bool $smLinksLoaded = FALSE; |
|
241 | 241 | |
242 | 242 | /** |
243 | 243 | * This holds the logical structure |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @see $tableOfContents |
255 | 255 | */ |
256 | - protected bool $tableOfContentsLoaded = false; |
|
256 | + protected bool $tableOfContentsLoaded = FALSE; |
|
257 | 257 | |
258 | 258 | /** |
259 | 259 | * @access protected |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @see $thumbnail |
269 | 269 | */ |
270 | - protected bool $thumbnailLoaded = false; |
|
270 | + protected bool $thumbnailLoaded = FALSE; |
|
271 | 271 | |
272 | 272 | /** |
273 | 273 | * @access protected |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
363 | 363 | */ |
364 | - abstract public function getLogicalStructure(string $id, bool $recursive = false): array; |
|
364 | + abstract public function getLogicalStructure(string $id, bool $recursive = FALSE): array; |
|
365 | 365 | |
366 | 366 | /** |
367 | 367 | * This extracts all the metadata for a logical structure node |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | * |
450 | 450 | * @return string The document's thumbnail location |
451 | 451 | */ |
452 | - abstract protected function magicGetThumbnail(bool $forceReload = false): string; |
|
452 | + abstract protected function magicGetThumbnail(bool $forceReload = FALSE): string; |
|
453 | 453 | |
454 | 454 | /** |
455 | 455 | * This returns the ID of the toplevel logical structure node |
@@ -528,21 +528,21 @@ discard block |
||
528 | 528 | * |
529 | 529 | * @return AbstractDocument|null Instance of this class, either MetsDocument or IiifManifest |
530 | 530 | */ |
531 | - public static function &getInstance(string $location, array $settings = [], bool $forceReload = false) |
|
531 | + public static function &getInstance(string $location, array $settings = [], bool $forceReload = FALSE) |
|
532 | 532 | { |
533 | 533 | // Create new instance depending on format (METS or IIIF) ... |
534 | - $documentFormat = null; |
|
535 | - $xml = null; |
|
536 | - $iiif = null; |
|
534 | + $documentFormat = NULL; |
|
535 | + $xml = NULL; |
|
536 | + $iiif = NULL; |
|
537 | 537 | |
538 | 538 | if (!$forceReload) { |
539 | 539 | $instance = self::getDocumentCache($location); |
540 | - if ($instance !== false) { |
|
540 | + if ($instance !== FALSE) { |
|
541 | 541 | return $instance; |
542 | 542 | } |
543 | 543 | } |
544 | 544 | |
545 | - $instance = null; |
|
545 | + $instance = NULL; |
|
546 | 546 | |
547 | 547 | // Try to load a file from the url |
548 | 548 | if (GeneralUtility::isValidUrl($location)) { |
@@ -550,17 +550,17 @@ discard block |
||
550 | 550 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
551 | 551 | |
552 | 552 | $content = Helper::getUrl($location); |
553 | - if ($content !== false) { |
|
553 | + if ($content !== FALSE) { |
|
554 | 554 | $xml = Helper::getXmlFileAsString($content); |
555 | - if ($xml !== false) { |
|
555 | + if ($xml !== FALSE) { |
|
556 | 556 | /* @var $xml \SimpleXMLElement */ |
557 | 557 | $xml->registerXPathNamespace('mets', 'http://www.loc.gov/METS/'); |
558 | 558 | $xpathResult = $xml->xpath('//mets:mets'); |
559 | - $documentFormat = !empty($xpathResult) ? 'METS' : null; |
|
559 | + $documentFormat = !empty($xpathResult) ? 'METS' : NULL; |
|
560 | 560 | } else { |
561 | 561 | // Try to load file as IIIF resource instead. |
562 | - $contentAsJsonArray = json_decode($content, true); |
|
563 | - if ($contentAsJsonArray !== null) { |
|
562 | + $contentAsJsonArray = json_decode($content, TRUE); |
|
563 | + if ($contentAsJsonArray !== NULL) { |
|
564 | 564 | IiifHelper::setUrlReader(IiifUrlReader::getInstance()); |
565 | 565 | IiifHelper::setMaxThumbnailHeight($extConf['iiif']['thumbnailHeight']); |
566 | 566 | IiifHelper::setMaxThumbnailWidth($extConf['iiif']['thumbnailWidth']); |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | $instance = new IiifManifest($pid, $location, $iiif); |
584 | 584 | } |
585 | 585 | |
586 | - if ($instance !== null) { |
|
586 | + if ($instance !== NULL) { |
|
587 | 587 | self::setDocumentCache($location, $instance); |
588 | 588 | } |
589 | 589 | |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | } else { |
625 | 625 | $physicalPage = 0; |
626 | 626 | foreach ($this->physicalStructureInfo as $page) { |
627 | - if (strpos($page['orderlabel'], $logicalPage) !== false) { |
|
627 | + if (strpos($page['orderlabel'], $logicalPage) !== FALSE) { |
|
628 | 628 | $this->lastSearchedPhysicalPage['logicalPage'] = $logicalPage; |
629 | 629 | $this->lastSearchedPhysicalPage['physicalPage'] = $physicalPage; |
630 | 630 | return $physicalPage; |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | if (!empty($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])) { |
662 | 662 | // Get full text file. |
663 | 663 | $fileContent = GeneralUtility::getUrl($this->getFileLocation($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])); |
664 | - if ($fileContent !== false) { |
|
664 | + if ($fileContent !== FALSE) { |
|
665 | 665 | $textFormat = $this->getTextFormat($fileContent); |
666 | 666 | } else { |
667 | 667 | $this->logger->warning('Couldn\'t load full text file for structure node @ID "' . $id . '"'); |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | { |
734 | 734 | $xml = Helper::getXmlFileAsString($fileContent); |
735 | 735 | |
736 | - if ($xml !== false) { |
|
736 | + if ($xml !== FALSE) { |
|
737 | 737 | // Get the root element's name as text format. |
738 | 738 | return strtoupper($xml->getName()); |
739 | 739 | } else { |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | * |
754 | 754 | * @return string The title of the document itself or a parent document |
755 | 755 | */ |
756 | - public static function getTitle(int $uid, bool $recursive = false): string |
|
756 | + public static function getTitle(int $uid, bool $recursive = FALSE): string |
|
757 | 757 | { |
758 | 758 | $title = ''; |
759 | 759 | // Sanitize input. |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | && (int) $partof |
788 | 788 | && $partof != $uid |
789 | 789 | ) { |
790 | - $title = self::getTitle($partof, true); |
|
790 | + $title = self::getTitle($partof, TRUE); |
|
791 | 791 | } |
792 | 792 | } else { |
793 | 793 | Helper::log('No document with UID ' . $uid . ' found or document not accessible', LOG_SEVERITY_WARNING); |
@@ -845,12 +845,12 @@ discard block |
||
845 | 845 | return $depth; |
846 | 846 | } elseif (array_key_exists('children', $element)) { |
847 | 847 | $foundInChildren = $this->getTreeDepth($element['children'], $depth + 1, $logId); |
848 | - if ($foundInChildren !== false) { |
|
848 | + if ($foundInChildren !== FALSE) { |
|
849 | 849 | return $foundInChildren; |
850 | 850 | } |
851 | 851 | } |
852 | 852 | } |
853 | - return false; |
|
853 | + return FALSE; |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | /** |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | } else { |
886 | 886 | $this->logger->error('Invalid file location "' . $location . '" for document loading'); |
887 | 887 | } |
888 | - return false; |
|
888 | + return FALSE; |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | 'class' => $resArray['class'] |
924 | 924 | ]; |
925 | 925 | } |
926 | - $this->formatsLoaded = true; |
|
926 | + $this->formatsLoaded = TRUE; |
|
927 | 927 | } |
928 | 928 | } |
929 | 929 | |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | ) { |
1045 | 1045 | $this->prepareMetadataArray($cPid); |
1046 | 1046 | $this->metadataArray[0] = $cPid; |
1047 | - $this->metadataArrayLoaded = true; |
|
1047 | + $this->metadataArrayLoaded = TRUE; |
|
1048 | 1048 | } |
1049 | 1049 | return $this->metadataArray; |
1050 | 1050 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | $parent = self::getInstance($this->parentId, ['storagePid' => $this->pid]); |
1144 | 1144 | $this->rootId = $parent->rootId; |
1145 | 1145 | } |
1146 | - $this->rootIdLoaded = true; |
|
1146 | + $this->rootIdLoaded = TRUE; |
|
1147 | 1147 | } |
1148 | 1148 | return $this->rootId; |
1149 | 1149 | } |
@@ -1160,8 +1160,8 @@ discard block |
||
1160 | 1160 | // Is there no logical structure array yet? |
1161 | 1161 | if (!$this->tableOfContentsLoaded) { |
1162 | 1162 | // Get all logical structures. |
1163 | - $this->getLogicalStructure('', true); |
|
1164 | - $this->tableOfContentsLoaded = true; |
|
1163 | + $this->getLogicalStructure('', TRUE); |
|
1164 | + $this->tableOfContentsLoaded = TRUE; |
|
1165 | 1165 | } |
1166 | 1166 | return $this->tableOfContents; |
1167 | 1167 | } |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | || !method_exists($this, $method) |
1219 | 1219 | ) { |
1220 | 1220 | $this->logger->warning('There is no getter function for property "' . $var . '"'); |
1221 | - return null; |
|
1221 | + return NULL; |
|
1222 | 1222 | } else { |
1223 | 1223 | return $this->$method(); |
1224 | 1224 | } |
@@ -30,8 +30,7 @@ |
||
30 | 30 | * |
31 | 31 | * @access public |
32 | 32 | */ |
33 | -class ReindexCommand extends BaseCommand |
|
34 | -{ |
|
33 | +class ReindexCommand extends BaseCommand { |
|
35 | 34 | /** |
36 | 35 | * Configure the command by defining the name, options and arguments |
37 | 36 | * |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | ->setHelp('') |
47 | 47 | ->addOption( |
48 | 48 | 'dry-run', |
49 | - null, |
|
49 | + NULL, |
|
50 | 50 | InputOption::VALUE_NONE, |
51 | 51 | 'If this option is set, the files will not actually be processed but the location URI is shown.' |
52 | 52 | ) |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function execute(InputInterface $input, OutputInterface $output): int |
108 | 108 | { |
109 | - $dryRun = $input->getOption('dry-run') != false ? true : false; |
|
109 | + $dryRun = $input->getOption('dry-run') != FALSE ? TRUE : FALSE; |
|
110 | 110 | |
111 | 111 | $io = new SymfonyStyle($input, $output); |
112 | 112 | $io->title($this->getDescription()); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $this->owner = $this->libraryRepository->findOneByIndexName((string) $input->getOption('owner')); |
152 | 152 | } |
153 | 153 | } else { |
154 | - $this->owner = null; |
|
154 | + $this->owner = NULL; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | if (!empty($input->getOption('all'))) { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | !empty($input->getOption('coll')) |
175 | 175 | && !is_array($input->getOption('coll')) |
176 | 176 | ) { |
177 | - $collections = GeneralUtility::intExplode(',', $input->getOption('coll'), true); |
|
177 | + $collections = GeneralUtility::intExplode(',', $input->getOption('coll'), TRUE); |
|
178 | 178 | // "coll" may be a single integer or a comma-separated list of integers. |
179 | 179 | if (empty(array_filter($collections))) { |
180 | 180 | $io->error('ERROR: Parameter --coll|-c is not a valid comma-separated list of collection UIDs.'); |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | foreach ($documents as $id => $document) { |
201 | - $doc = AbstractDocument::getInstance($document->getLocation(), ['storagePid' => $this->storagePid], true); |
|
201 | + $doc = AbstractDocument::getInstance($document->getLocation(), ['storagePid' => $this->storagePid], TRUE); |
|
202 | 202 | |
203 | - if ($doc === null) { |
|
203 | + if ($doc === NULL) { |
|
204 | 204 | $io->warning('WARNING: Document "' . $document->getLocation() . '" could not be loaded. Skip to next document.'); |
205 | 205 | continue; |
206 | 206 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $this->initializeRepositories((int) $input->getOption('pid')); |
115 | 115 | |
116 | 116 | if ($this->storagePid == 0) { |
117 | - $io->error('ERROR: No valid PID (' . $this->storagePid . ') given.'); |
|
117 | + $io->error('ERROR: No valid PID ('.$this->storagePid.') given.'); |
|
118 | 118 | return BaseCommand::FAILURE; |
119 | 119 | } |
120 | 120 | |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | if (empty($solrCoreUid) || !in_array($solrCoreUid, $allSolrCores)) { |
130 | 130 | $outputSolrCores = []; |
131 | 131 | foreach ($allSolrCores as $indexName => $uid) { |
132 | - $outputSolrCores[] = $uid . ' : ' . $indexName; |
|
132 | + $outputSolrCores[] = $uid.' : '.$indexName; |
|
133 | 133 | } |
134 | 134 | if (empty($outputSolrCores)) { |
135 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. No valid cores found on PID ' . $this->storagePid . ".\n"); |
|
135 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. No valid cores found on PID '.$this->storagePid.".\n"); |
|
136 | 136 | return BaseCommand::FAILURE; |
137 | 137 | } else { |
138 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (<uid>:<index_name>):\n" . implode("\n", $outputSolrCores) . "\n"); |
|
138 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. '."Valid cores are (<uid>:<index_name>):\n".implode("\n", $outputSolrCores)."\n"); |
|
139 | 139 | return BaseCommand::FAILURE; |
140 | 140 | } |
141 | 141 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | ->setLimit((int) $input->getOption('index-limit')) |
166 | 166 | ->setOffset((int) $input->getOption('index-begin')) |
167 | 167 | ->execute(); |
168 | - $io->writeln($input->getOption('index-limit') . ' documents starting from ' . $input->getOption('index-begin') . ' will be indexed.'); |
|
168 | + $io->writeln($input->getOption('index-limit').' documents starting from '.$input->getOption('index-begin').' will be indexed.'); |
|
169 | 169 | } else { |
170 | 170 | // Get all documents. |
171 | 171 | $documents = $this->documentRepository->findAll(); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | ) { |
188 | 188 | $documents = $this->documentRepository->findAllByCollectionsLimited($collections, (int) $input->getOption('index-limit'), (int) $input->getOption('index-begin')); |
189 | 189 | |
190 | - $io->writeln($input->getOption('index-limit') . ' documents starting from ' . $input->getOption('index-begin') . ' will be indexed.'); |
|
190 | + $io->writeln($input->getOption('index-limit').' documents starting from '.$input->getOption('index-begin').' will be indexed.'); |
|
191 | 191 | } else { |
192 | 192 | // Get all documents of given collections. |
193 | 193 | $documents = $this->documentRepository->findAllByCollectionsLimited($collections, 0); |
@@ -201,15 +201,15 @@ discard block |
||
201 | 201 | $doc = AbstractDocument::getInstance($document->getLocation(), ['storagePid' => $this->storagePid], true); |
202 | 202 | |
203 | 203 | if ($doc === null) { |
204 | - $io->warning('WARNING: Document "' . $document->getLocation() . '" could not be loaded. Skip to next document.'); |
|
204 | + $io->warning('WARNING: Document "'.$document->getLocation().'" could not be loaded. Skip to next document.'); |
|
205 | 205 | continue; |
206 | 206 | } |
207 | 207 | |
208 | 208 | if ($dryRun) { |
209 | - $io->writeln('DRY RUN: Would index ' . ($id + 1) . '/' . count($documents) . ' with UID "' . $document->getUid() . '" ("' . $document->getLocation() . '") on PID ' . $this->storagePid . ' and Solr core ' . $solrCoreUid . '.'); |
|
209 | + $io->writeln('DRY RUN: Would index '.($id + 1).'/'.count($documents).' with UID "'.$document->getUid().'" ("'.$document->getLocation().'") on PID '.$this->storagePid.' and Solr core '.$solrCoreUid.'.'); |
|
210 | 210 | } else { |
211 | 211 | if ($io->isVerbose()) { |
212 | - $io->writeln(date('Y-m-d H:i:s') . ' Indexing ' . ($id + 1) . '/' . count($documents) . ' with UID "' . $document->getUid() . '" ("' . $document->getLocation() . '") on PID ' . $this->storagePid . ' and Solr core ' . $solrCoreUid . '.'); |
|
212 | + $io->writeln(date('Y-m-d H:i:s').' Indexing '.($id + 1).'/'.count($documents).' with UID "'.$document->getUid().'" ("'.$document->getLocation().'") on PID '.$this->storagePid.' and Solr core '.$solrCoreUid.'.'); |
|
213 | 213 | } |
214 | 214 | $document->setCurrentDocument($doc); |
215 | 215 | // save to database |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return void |
336 | 336 | */ |
337 | - private function addCollections(Document &$document, array $collections): void |
|
337 | + private function addCollections(Document & $document, array $collections): void |
|
338 | 338 | { |
339 | 339 | foreach ($collections as $collection) { |
340 | 340 | $documentCollection = $this->collectionRepository->findOneByIndexName($collection); |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | |
377 | 377 | for ($i = 0; $i < $count; $i++) { |
378 | 378 | // Build the next part to add |
379 | - $nextPart = ($i === 0 ? '' : $delimiter) . $metadataAuthor[$i]; |
|
379 | + $nextPart = ($i === 0 ? '' : $delimiter).$metadataAuthor[$i]; |
|
380 | 380 | // Check if adding this part and ellipsis in future would exceed the character limit |
381 | - if (strlen($authors . $nextPart . $delimiter . $ellipsis) > 255) { |
|
381 | + if (strlen($authors.$nextPart.$delimiter.$ellipsis) > 255) { |
|
382 | 382 | // Add ellipsis and stop adding more authors |
383 | - $authors .= $delimiter . $ellipsis; |
|
383 | + $authors .= $delimiter.$ellipsis; |
|
384 | 384 | break; |
385 | 385 | } |
386 | 386 | // Add the part to the main string |
@@ -40,8 +40,7 @@ |
||
40 | 40 | * |
41 | 41 | * @access public |
42 | 42 | */ |
43 | -class BaseCommand extends Command |
|
44 | -{ |
|
43 | +class BaseCommand extends Command { |
|
45 | 44 | /** |
46 | 45 | * @access protected |
47 | 46 | * @var CollectionRepository |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | protected function saveToDatabase(Document $document): bool |
202 | 202 | { |
203 | 203 | $doc = $document->getCurrentDocument(); |
204 | - if ($doc === null) { |
|
205 | - return false; |
|
204 | + if ($doc === NULL) { |
|
205 | + return FALSE; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | $doc->cPid = $this->storagePid; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | $document->setPartof($this->getParentDocumentUidForSaving($document)); |
259 | 259 | } |
260 | 260 | |
261 | - if ($document->getUid() === null) { |
|
261 | + if ($document->getUid() === NULL) { |
|
262 | 262 | // new document |
263 | 263 | $this->documentRepository->add($document); |
264 | 264 | } else { |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | |
269 | 269 | $this->persistenceManager->persistAll(); |
270 | 270 | |
271 | - return true; |
|
271 | + return TRUE; |
|
272 | 272 | } |
273 | 273 | |
274 | - return false; |
|
274 | + return FALSE; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | { |
289 | 289 | $doc = $document->getCurrentDocument(); |
290 | 290 | |
291 | - if ($doc !== null && !empty($doc->parentHref)) { |
|
291 | + if ($doc !== NULL && !empty($doc->parentHref)) { |
|
292 | 292 | // find document object by record_id of parent |
293 | 293 | $parent = AbstractDocument::getInstance($doc->parentHref, ['storagePid' => $this->storagePid]); |
294 | 294 | |
295 | 295 | if ($parent->recordId) { |
296 | 296 | $parentDocument = $this->documentRepository->findOneByRecordId($parent->recordId); |
297 | 297 | |
298 | - if ($parentDocument === null) { |
|
298 | + if ($parentDocument === NULL) { |
|
299 | 299 | // create new Document object |
300 | 300 | $parentDocument = GeneralUtility::makeInstance(Document::class); |
301 | 301 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | $success = $this->saveToDatabase($parentDocument); |
309 | 309 | |
310 | - if ($success === true) { |
|
310 | + if ($success === TRUE) { |
|
311 | 311 | // add to index |
312 | 312 | Indexer::add($parentDocument, $this->documentRepository); |
313 | 313 | return $parentDocument->getUid(); |