@@ -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 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | // in which case metadata of toplevel entry isn't yet filled. |
| 221 | 221 | if (empty($document['metadata'])) { |
| 222 | 222 | $document['metadata'] = $this->fetchToplevelMetadataFromSolr([ |
| 223 | - 'query' => 'uid:' . $document['uid'], |
|
| 223 | + 'query' => 'uid:'.$document['uid'], |
|
| 224 | 224 | 'start' => 0, |
| 225 | 225 | 'rows' => 1, |
| 226 | 226 | 'sort' => ['score' => 'desc'], |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | if (empty($document['title']) && $document['partOf'] > 0) { |
| 232 | 232 | $superiorTitle = AbstractDocument::getTitle($document['partOf'], true); |
| 233 | 233 | if (!empty($superiorTitle)) { |
| 234 | - $document['title'] = '[' . $superiorTitle . ']'; |
|
| 234 | + $document['title'] = '['.$superiorTitle.']'; |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -366,13 +366,13 @@ discard block |
||
| 366 | 366 | // Set search query. |
| 367 | 367 | if ( |
| 368 | 368 | (!empty($this->searchParams['fulltext'])) |
| 369 | - || preg_match('/' . $fields['fulltext'] . ':\((.*)\)/', trim($this->searchParams['query']), $matches) |
|
| 369 | + || preg_match('/'.$fields['fulltext'].':\((.*)\)/', trim($this->searchParams['query']), $matches) |
|
| 370 | 370 | ) { |
| 371 | 371 | // If the query already is a fulltext query e.g using the facets |
| 372 | 372 | $this->searchParams['query'] = empty($matches[1]) ? $this->searchParams['query'] : $matches[1]; |
| 373 | 373 | // Search in fulltext field if applicable. Query must not be empty! |
| 374 | 374 | if (!empty($this->searchParams['query'])) { |
| 375 | - $query = $fields['fulltext'] . ':(' . Solr::escapeQuery(trim($this->searchParams['query'])) . ')'; |
|
| 375 | + $query = $fields['fulltext'].':('.Solr::escapeQuery(trim($this->searchParams['query'])).')'; |
|
| 376 | 376 | } |
| 377 | 377 | $params['fulltext'] = true; |
| 378 | 378 | } else { |
@@ -395,9 +395,9 @@ discard block |
||
| 395 | 395 | in_array($this->searchParams['extOperator'][$i], $allowedOperators) |
| 396 | 396 | ) { |
| 397 | 397 | if (!empty($query)) { |
| 398 | - $query .= ' ' . $this->searchParams['extOperator'][$i] . ' '; |
|
| 398 | + $query .= ' '.$this->searchParams['extOperator'][$i].' '; |
|
| 399 | 399 | } |
| 400 | - $query .= Indexer::getIndexFieldName($this->searchParams['extField'][$i], $this->settings['storagePid']) . ':(' . Solr::escapeQuery($this->searchParams['extQuery'][$i]) . ')'; |
|
| 400 | + $query .= Indexer::getIndexFieldName($this->searchParams['extField'][$i], $this->settings['storagePid']).':('.Solr::escapeQuery($this->searchParams['extQuery'][$i]).')'; |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | // Add filter query for date search |
| 407 | 407 | if (!empty($this->searchParams['dateFrom']) && !empty($this->searchParams['dateTo'])) { |
| 408 | 408 | // combine dateFrom and dateTo into range search |
| 409 | - $params['filterquery'][]['query'] = '{!join from=' . $fields['uid'] . ' to=' . $fields['uid'] . '}'. $fields['date'] . ':[' . $this->searchParams['dateFrom'] . ' TO ' . $this->searchParams['dateTo'] . ']'; |
|
| 409 | + $params['filterquery'][]['query'] = '{!join from='.$fields['uid'].' to='.$fields['uid'].'}'.$fields['date'].':['.$this->searchParams['dateFrom'].' TO '.$this->searchParams['dateTo'].']'; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | // Add filter query for faceting. |
@@ -423,12 +423,12 @@ discard block |
||
| 423 | 423 | ) { |
| 424 | 424 | // Search in document and all subordinates (valid for up to three levels of hierarchy). |
| 425 | 425 | $params['filterquery'][]['query'] = '_query_:"{!join from=' |
| 426 | - . $fields['uid'] . ' to=' . $fields['partof'] . '}' |
|
| 427 | - . $fields['uid'] . ':{!join from=' . $fields['uid'] . ' to=' . $fields['partof'] . '}' |
|
| 428 | - . $fields['uid'] . ':' . $this->searchParams['documentId'] . '"' . ' OR {!join from=' |
|
| 429 | - . $fields['uid'] . ' to=' . $fields['partof'] . '}' |
|
| 430 | - . $fields['uid'] . ':' . $this->searchParams['documentId'] . ' OR ' |
|
| 431 | - . $fields['uid'] . ':' . $this->searchParams['documentId']; |
|
| 426 | + . $fields['uid'].' to='.$fields['partof'].'}' |
|
| 427 | + . $fields['uid'].':{!join from='.$fields['uid'].' to='.$fields['partof'].'}' |
|
| 428 | + . $fields['uid'].':'.$this->searchParams['documentId'].'"'.' OR {!join from=' |
|
| 429 | + . $fields['uid'].' to='.$fields['partof'].'}' |
|
| 430 | + . $fields['uid'].':'.$this->searchParams['documentId'].' OR ' |
|
| 431 | + . $fields['uid'].':'.$this->searchParams['documentId']; |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | // if collections are given, we prepare the collection query string |
@@ -448,8 +448,8 @@ discard block |
||
| 448 | 448 | if ($this->listedMetadata) { |
| 449 | 449 | foreach ($this->listedMetadata as $metadata) { |
| 450 | 450 | if ($metadata->getIndexStored() || $metadata->getIndexIndexed()) { |
| 451 | - $listMetadataRecord = $metadata->getIndexName() . '_' . ($metadata->getIndexTokenized() ? 't' : 'u') . ($metadata->getIndexStored() ? 's' : 'u') . ($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
| 452 | - $params['fields'] .= ',' . $listMetadataRecord; |
|
| 451 | + $listMetadataRecord = $metadata->getIndexName().'_'.($metadata->getIndexTokenized() ? 't' : 'u').($metadata->getIndexStored() ? 's' : 'u').($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
| 452 | + $params['fields'] .= ','.$listMetadataRecord; |
|
| 453 | 453 | $params['listMetadataRecords'][$metadata->getIndexName()] = $listMetadataRecord; |
| 454 | 454 | } |
| 455 | 455 | } |
@@ -524,8 +524,8 @@ discard block |
||
| 524 | 524 | if ($this->searchParams['fulltext'] == '1') { |
| 525 | 525 | $searchResult['snippet'] = $doc['snippet']; |
| 526 | 526 | $searchResult['highlight'] = $doc['highlight']; |
| 527 | - $searchResult['highlight_word'] = preg_replace('/^;|;$/', '', // remove ; at beginning or end |
|
| 528 | - preg_replace('/;+/', ';', // replace any multiple of ; with a single ; |
|
| 527 | + $searchResult['highlight_word'] = preg_replace('/^;|;$/', '', // remove ; at beginning or end |
|
| 528 | + preg_replace('/;+/', ';', // replace any multiple of ; with a single ; |
|
| 529 | 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; |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | |
| 550 | 550 | // Fetch metadata for the current batch |
| 551 | 551 | $metadataOf = $this->fetchToplevelMetadataFromSolr([ |
| 552 | - 'query' => 'partof:' . $doc['uid'], |
|
| 552 | + 'query' => 'partof:'.$doc['uid'], |
|
| 553 | 553 | 'start' => $start, |
| 554 | 554 | 'rows' => min($batchSize, $totalChildren - $start), |
| 555 | 555 | ]); |
@@ -601,8 +601,8 @@ discard block |
||
| 601 | 601 | if ($this->listedMetadata) { |
| 602 | 602 | foreach ($this->listedMetadata as $metadata) { |
| 603 | 603 | if ($metadata->getIndexStored() || $metadata->getIndexIndexed()) { |
| 604 | - $listMetadataRecord = $metadata->getIndexName() . '_' . ($metadata->getIndexTokenized() ? 't' : 'u') . ($metadata->getIndexStored() ? 's' : 'u') . ($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
| 605 | - $params['fields'] .= ',' . $listMetadataRecord; |
|
| 604 | + $listMetadataRecord = $metadata->getIndexName().'_'.($metadata->getIndexTokenized() ? 't' : 'u').($metadata->getIndexStored() ? 's' : 'u').($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
| 605 | + $params['fields'] .= ','.$listMetadataRecord; |
|
| 606 | 606 | $params['listMetadataRecords'][$metadata->getIndexName()] = $listMetadataRecord; |
| 607 | 607 | } |
| 608 | 608 | } |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | $cache = null; |
| 654 | 654 | // Calculate cache identifier. |
| 655 | 655 | if ($enableCache === true) { |
| 656 | - $cacheIdentifier = Helper::digest($solr->core . print_r($parameters, true)); |
|
| 656 | + $cacheIdentifier = Helper::digest($solr->core.print_r($parameters, true)); |
|
| 657 | 657 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_solr'); |
| 658 | 658 | } |
| 659 | 659 | $resultSet = [ |
@@ -742,24 +742,24 @@ discard block |
||
| 742 | 742 | foreach ($this->collections as $collection) { |
| 743 | 743 | // check for virtual collections query string |
| 744 | 744 | if ($collection->getIndexSearch()) { |
| 745 | - $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '(' . $collection->getIndexSearch() . ')' : ' OR (' . $collection->getIndexSearch() . ')'; |
|
| 745 | + $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '('.$collection->getIndexSearch().')' : ' OR ('.$collection->getIndexSearch().')'; |
|
| 746 | 746 | } else { |
| 747 | - $collectionsQueryString .= empty($collectionsQueryString) ? '"' . $collection->getIndexName() . '"' : ' OR "' . $collection->getIndexName() . '"'; |
|
| 747 | + $collectionsQueryString .= empty($collectionsQueryString) ? '"'.$collection->getIndexName().'"' : ' OR "'.$collection->getIndexName().'"'; |
|
| 748 | 748 | } |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | // distinguish between simple collection browsing and actual searching within the collection(s) |
| 752 | 752 | if (!empty($collectionsQueryString)) { |
| 753 | 753 | if (empty($query)) { |
| 754 | - $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . ') AND toplevel:true AND partof:0)'; |
|
| 754 | + $collectionsQueryString = '(collection_faceting:('.$collectionsQueryString.') AND toplevel:true AND partof:0)'; |
|
| 755 | 755 | } else { |
| 756 | - $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . '))'; |
|
| 756 | + $collectionsQueryString = '(collection_faceting:('.$collectionsQueryString.'))'; |
|
| 757 | 757 | } |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | // virtual collections might query documents that are neither toplevel:true nor partof:0 and need to be searched separately |
| 761 | 761 | if (!empty($virtualCollectionsQueryString)) { |
| 762 | - $virtualCollectionsQueryString = '(' . $virtualCollectionsQueryString . ')'; |
|
| 762 | + $virtualCollectionsQueryString = '('.$virtualCollectionsQueryString.')'; |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | // combine both query strings into a single filterquery via OR if both are given, otherwise pass either of those |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | private function translateLanguageCode(&$doc): void |
| 838 | 838 | { |
| 839 | 839 | if ($doc['metadata']['language']) { |
| 840 | - foreach($doc['metadata']['language'] as $indexName => $language) { |
|
| 840 | + foreach ($doc['metadata']['language'] as $indexName => $language) { |
|
| 841 | 841 | $doc['metadata']['language'][$indexName] = Helper::getLanguageName($language); |
| 842 | 842 | } |
| 843 | 843 | } |
@@ -90,8 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return void |
| 92 | 92 | */ |
| 93 | - public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = null) |
|
| 94 | - { |
|
| 93 | + public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = null) { |
|
| 95 | 94 | $this->documentRepository = $documentRepository; |
| 96 | 95 | $this->collections = $collections; |
| 97 | 96 | $this->settings = $settings; |
@@ -210,8 +209,7 @@ discard block |
||
| 210 | 209 | * @return mixed |
| 211 | 210 | */ |
| 212 | 211 | #[\ReturnTypeWillChange] |
| 213 | - public function offsetGet($offset) |
|
| 214 | - { |
|
| 212 | + public function offsetGet($offset) { |
|
| 215 | 213 | $idx = $this->result['document_keys'][$offset]; |
| 216 | 214 | $document = $this->result['documents'][$idx] ?? null; |
| 217 | 215 | |
@@ -279,8 +277,7 @@ discard block |
||
| 279 | 277 | * |
| 280 | 278 | * @return mixed |
| 281 | 279 | */ |
| 282 | - public function getSolrResults() |
|
| 283 | - { |
|
| 280 | + public function getSolrResults() { |
|
| 284 | 281 | return $this->result['solrResults']; |
| 285 | 282 | } |
| 286 | 283 | |
@@ -293,8 +290,7 @@ discard block |
||
| 293 | 290 | * |
| 294 | 291 | * @return mixed |
| 295 | 292 | */ |
| 296 | - public function getByUid($uid) |
|
| 297 | - { |
|
| 293 | + public function getByUid($uid) { |
|
| 298 | 294 | return $this->result['documents'][$uid]; |
| 299 | 295 | } |
| 300 | 296 | |
@@ -305,8 +301,7 @@ discard block |
||
| 305 | 301 | * |
| 306 | 302 | * @return SolrSearchQuery |
| 307 | 303 | */ |
| 308 | - public function getQuery() |
|
| 309 | - { |
|
| 304 | + public function getQuery() { |
|
| 310 | 305 | return new SolrSearchQuery($this); |
| 311 | 306 | } |
| 312 | 307 | |
@@ -317,8 +312,7 @@ discard block |
||
| 317 | 312 | * |
| 318 | 313 | * @return SolrSearch |
| 319 | 314 | */ |
| 320 | - public function getFirst() |
|
| 321 | - { |
|
| 315 | + public function getFirst() { |
|
| 322 | 316 | return $this[0]; |
| 323 | 317 | } |
| 324 | 318 | |
@@ -329,8 +323,7 @@ discard block |
||
| 329 | 323 | * |
| 330 | 324 | * @return array |
| 331 | 325 | */ |
| 332 | - public function toArray() |
|
| 333 | - { |
|
| 326 | + public function toArray() { |
|
| 334 | 327 | return array_values($this->result['documents']); |
| 335 | 328 | } |
| 336 | 329 | |
@@ -343,8 +336,7 @@ discard block |
||
| 343 | 336 | * |
| 344 | 337 | * @return int |
| 345 | 338 | */ |
| 346 | - public function getNumFound() |
|
| 347 | - { |
|
| 339 | + public function getNumFound() { |
|
| 348 | 340 | return $this->result['numFound']; |
| 349 | 341 | } |
| 350 | 342 | |
@@ -355,8 +347,7 @@ discard block |
||
| 355 | 347 | * |
| 356 | 348 | * @return void |
| 357 | 349 | */ |
| 358 | - public function prepare() |
|
| 359 | - { |
|
| 350 | + public function prepare() { |
|
| 360 | 351 | // Prepare query parameters. |
| 361 | 352 | $params = []; |
| 362 | 353 | $matches = []; |
@@ -472,8 +463,7 @@ discard block |
||
| 472 | 463 | * |
| 473 | 464 | * @return void |
| 474 | 465 | */ |
| 475 | - public function submit($start, $rows, $processResults = true) |
|
| 476 | - { |
|
| 466 | + public function submit($start, $rows, $processResults = true) { |
|
| 477 | 467 | $params = $this->params; |
| 478 | 468 | $params['start'] = $start; |
| 479 | 469 | $params['rows'] = $rows; |
@@ -631,8 +621,7 @@ discard block |
||
| 631 | 621 | * |
| 632 | 622 | * @return array The Apache Solr Documents that were fetched |
| 633 | 623 | */ |
| 634 | - protected function searchSolr($parameters = [], $enableCache = true) |
|
| 635 | - { |
|
| 624 | + protected function searchSolr($parameters = [], $enableCache = true) { |
|
| 636 | 625 | // Set query. |
| 637 | 626 | $parameters['query'] = isset($parameters['query']) ? $parameters['query'] : '*'; |
| 638 | 627 | $parameters['filterquery'] = isset($parameters['filterquery']) ? $parameters['filterquery'] : []; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return void |
| 92 | 92 | */ |
| 93 | - public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = null) |
|
| 93 | + public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = NULL) |
|
| 94 | 94 | { |
| 95 | 95 | $this->documentRepository = $documentRepository; |
| 96 | 96 | $this->collections = $collections; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function count(): int |
| 122 | 122 | { |
| 123 | - if ($this->result === null) { |
|
| 123 | + if ($this->result === NULL) { |
|
| 124 | 124 | return 0; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | public function offsetGet($offset) |
| 214 | 214 | { |
| 215 | 215 | $idx = $this->result['document_keys'][$offset]; |
| 216 | - $document = $this->result['documents'][$idx] ?? null; |
|
| 216 | + $document = $this->result['documents'][$idx] ?? NULL; |
|
| 217 | 217 | |
| 218 | - if ($document !== null) { |
|
| 218 | + if ($document !== NULL) { |
|
| 219 | 219 | // It may happen that a Solr group only includes non-toplevel results, |
| 220 | 220 | // in which case metadata of toplevel entry isn't yet filled. |
| 221 | 221 | if (empty($document['metadata'])) { |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | // get title of parent/grandparent/... if empty |
| 231 | 231 | if (empty($document['title']) && $document['partOf'] > 0) { |
| 232 | - $superiorTitle = AbstractDocument::getTitle($document['partOf'], true); |
|
| 232 | + $superiorTitle = AbstractDocument::getTitle($document['partOf'], TRUE); |
|
| 233 | 233 | if (!empty($superiorTitle)) { |
| 234 | 234 | $document['title'] = '[' . $superiorTitle . ']'; |
| 235 | 235 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | if (!empty($this->searchParams['query'])) { |
| 375 | 375 | $query = $fields['fulltext'] . ':(' . Solr::escapeQuery(trim($this->searchParams['query'])) . ')'; |
| 376 | 376 | } |
| 377 | - $params['fulltext'] = true; |
|
| 377 | + $params['fulltext'] = TRUE; |
|
| 378 | 378 | } else { |
| 379 | 379 | // Retain given search field if valid. |
| 380 | 380 | if (!empty($this->searchParams['query'])) { |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | $this->params = $params; |
| 459 | 459 | |
| 460 | 460 | // Send off query to get total number of search results in advance |
| 461 | - $this->submit(0, 1, false); |
|
| 461 | + $this->submit(0, 1, FALSE); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -472,14 +472,14 @@ discard block |
||
| 472 | 472 | * |
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | - public function submit($start, $rows, $processResults = true) |
|
| 475 | + public function submit($start, $rows, $processResults = TRUE) |
|
| 476 | 476 | { |
| 477 | 477 | $params = $this->params; |
| 478 | 478 | $params['start'] = $start; |
| 479 | 479 | $params['rows'] = $rows; |
| 480 | 480 | |
| 481 | 481 | // Perform search. |
| 482 | - $result = $this->searchSolr($params, true); |
|
| 482 | + $result = $this->searchSolr($params, TRUE); |
|
| 483 | 483 | |
| 484 | 484 | // Initialize values |
| 485 | 485 | $documents = []; |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | } |
| 505 | 505 | if ($documents[$doc['uid']]) { |
| 506 | 506 | $this->translateLanguageCode($doc); |
| 507 | - if ($doc['toplevel'] === false) { |
|
| 507 | + if ($doc['toplevel'] === FALSE) { |
|
| 508 | 508 | // this maybe a chapter, article, ..., year |
| 509 | 509 | if ($doc['type'] === 'year') { |
| 510 | 510 | continue; |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | } |
| 531 | 531 | $documents[$doc['uid']]['searchResults'][] = $searchResult; |
| 532 | 532 | } |
| 533 | - } else if ($doc['toplevel'] === true) { |
|
| 533 | + } else if ($doc['toplevel'] === TRUE) { |
|
| 534 | 534 | foreach ($params['listMetadataRecords'] as $indexName => $solrField) { |
| 535 | 535 | if (isset($doc['metadata'][$indexName])) { |
| 536 | 536 | $documents[$doc['uid']]['metadata'][$indexName] = $doc['metadata'][$indexName]; |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | $totalChildren = count($children); |
| 546 | 546 | |
| 547 | 547 | for ($start = 0; $start < $totalChildren; $start += $batchSize) { |
| 548 | - $batch = array_slice($children, $start, $batchSize, true); |
|
| 548 | + $batch = array_slice($children, $start, $batchSize, TRUE); |
|
| 549 | 549 | |
| 550 | 550 | // Fetch metadata for the current batch |
| 551 | 551 | $metadataOf = $this->fetchToplevelMetadataFromSolr([ |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | $params['filterquery'][] = ['query' => 'toplevel:true']; |
| 612 | 612 | |
| 613 | 613 | // Perform search. |
| 614 | - $result = $this->searchSolr($params, true); |
|
| 614 | + $result = $this->searchSolr($params, TRUE); |
|
| 615 | 615 | |
| 616 | 616 | foreach ($result['documents'] as $doc) { |
| 617 | 617 | $this->translateLanguageCode($doc); |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | * |
| 632 | 632 | * @return array The Apache Solr Documents that were fetched |
| 633 | 633 | */ |
| 634 | - protected function searchSolr($parameters = [], $enableCache = true) |
|
| 634 | + protected function searchSolr($parameters = [], $enableCache = TRUE) |
|
| 635 | 635 | { |
| 636 | 636 | // Set query. |
| 637 | 637 | $parameters['query'] = isset($parameters['query']) ? $parameters['query'] : '*'; |
@@ -650,10 +650,10 @@ discard block |
||
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | $cacheIdentifier = ''; |
| 653 | - $cache = null; |
|
| 653 | + $cache = NULL; |
|
| 654 | 654 | // Calculate cache identifier. |
| 655 | - if ($enableCache === true) { |
|
| 656 | - $cacheIdentifier = Helper::digest($solr->core . print_r($parameters, true)); |
|
| 655 | + if ($enableCache === TRUE) { |
|
| 656 | + $cacheIdentifier = Helper::digest($solr->core . print_r($parameters, TRUE)); |
|
| 657 | 657 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_solr'); |
| 658 | 658 | } |
| 659 | 659 | $resultSet = [ |
@@ -661,22 +661,22 @@ discard block |
||
| 661 | 661 | 'numberOfToplevels' => 0, |
| 662 | 662 | 'numFound' => 0, |
| 663 | 663 | ]; |
| 664 | - if ($enableCache === false || ($entry = $cache->get($cacheIdentifier)) === false) { |
|
| 664 | + if ($enableCache === FALSE || ($entry = $cache->get($cacheIdentifier)) === FALSE) { |
|
| 665 | 665 | $selectQuery = $solr->service->createSelect($parameters); |
| 666 | 666 | |
| 667 | 667 | $grouping = $selectQuery->getGrouping(); |
| 668 | 668 | $grouping->addField('uid'); |
| 669 | 669 | $grouping->setLimit(100); // Results in group (TODO: check) |
| 670 | - $grouping->setNumberOfGroups(true); |
|
| 670 | + $grouping->setNumberOfGroups(TRUE); |
|
| 671 | 671 | |
| 672 | - if ($parameters['fulltext'] === true) { |
|
| 672 | + if ($parameters['fulltext'] === TRUE) { |
|
| 673 | 673 | // get highlighting component and apply settings |
| 674 | 674 | $selectQuery->getHighlighting(); |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | $solrRequest = $solr->service->createRequest($selectQuery); |
| 678 | 678 | |
| 679 | - if ($parameters['fulltext'] === true) { |
|
| 679 | + if ($parameters['fulltext'] === TRUE) { |
|
| 680 | 680 | // If it is a fulltext search, enable highlighting. |
| 681 | 681 | // field for which highlighting is going to be performed, |
| 682 | 682 | // is required if you want to have OCR highlighting |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | $resultSet['numberOfToplevels'] = $uidGroup->getNumberOfGroups(); |
| 704 | 704 | $resultSet['numFound'] = $uidGroup->getMatches(); |
| 705 | 705 | $highlighting = []; |
| 706 | - if ($parameters['fulltext'] === true) { |
|
| 706 | + if ($parameters['fulltext'] === TRUE) { |
|
| 707 | 707 | $data = $result->getData(); |
| 708 | 708 | $highlighting = $data['ocrHighlighting']; |
| 709 | 709 | } |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | // Save value in cache. |
| 719 | - if (!empty($resultSet['documents']) && $enableCache === true) { |
|
| 719 | + if (!empty($resultSet['documents']) && $enableCache === TRUE) { |
|
| 720 | 720 | $cache->set($cacheIdentifier, $resultSet); |
| 721 | 721 | } |
| 722 | 722 | } 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 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | $file = $this->getFileInfo($id); |
| 190 | 190 | if ($file['mimeType'] === 'application/vnd.kitodo.iiif') { |
| 191 | - $file['location'] = (strrpos($file['location'], 'info.json') === strlen($file['location']) - 9) ? $file['location'] : (strrpos($file['location'], '/') === strlen($file['location']) ? $file['location'] . 'info.json' : $file['location'] . '/info.json'); |
|
| 191 | + $file['location'] = (strrpos($file['location'], 'info.json') === strlen($file['location']) - 9) ? $file['location'] : (strrpos($file['location'], '/') === strlen($file['location']) ? $file['location'].'info.json' : $file['location'].'/info.json'); |
|
| 192 | 192 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 193 | 193 | IiifHelper::setUrlReader(IiifUrlReader::getInstance()); |
| 194 | 194 | IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']); |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | return $service->getImageUrl(); |
| 199 | 199 | } |
| 200 | 200 | } elseif ($file['mimeType'] === 'application/vnd.netfpx') { |
| 201 | - $baseURL = $file['location'] . (strpos($file['location'], '?') === false ? '?' : ''); |
|
| 201 | + $baseURL = $file['location'].(strpos($file['location'], '?') === false ? '?' : ''); |
|
| 202 | 202 | // TODO CVT is an optional IIP server capability; in theory, capabilities should be determined in the object request with '&obj=IIP-server' |
| 203 | - return $baseURL . '&CVT=jpeg'; |
|
| 203 | + return $baseURL.'&CVT=jpeg'; |
|
| 204 | 204 | } |
| 205 | 205 | return $file['location']; |
| 206 | 206 | } |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function getFileLocation(string $id): string |
| 231 | 231 | { |
| 232 | - $location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/mets:FLocat[@LOCTYPE="URL"]'); |
|
| 232 | + $location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/mets:FLocat[@LOCTYPE="URL"]'); |
|
| 233 | 233 | if ( |
| 234 | 234 | !empty($id) |
| 235 | 235 | && !empty($location) |
| 236 | 236 | ) { |
| 237 | 237 | return (string) $location[0]->attributes('http://www.w3.org/1999/xlink')->href; |
| 238 | 238 | } else { |
| 239 | - $this->logger->warning('There is no file node with @ID "' . $id . '"'); |
|
| 239 | + $this->logger->warning('There is no file node with @ID "'.$id.'"'); |
|
| 240 | 240 | return ''; |
| 241 | 241 | } |
| 242 | 242 | } |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | public function getFileMimeType(string $id): string |
| 248 | 248 | { |
| 249 | - $mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/@MIMETYPE'); |
|
| 249 | + $mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/@MIMETYPE'); |
|
| 250 | 250 | if ( |
| 251 | 251 | !empty($id) |
| 252 | 252 | && !empty($mimetype) |
| 253 | 253 | ) { |
| 254 | 254 | return (string) $mimetype[0]; |
| 255 | 255 | } else { |
| 256 | - $this->logger->warning('There is no file node with @ID "' . $id . '" or no MIME type specified'); |
|
| 256 | + $this->logger->warning('There is no file node with @ID "'.$id.'" or no MIME type specified'); |
|
| 257 | 257 | return ''; |
| 258 | 258 | } |
| 259 | 259 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | return $this->logicalUnits[$id]; |
| 274 | 274 | } elseif (!empty($id)) { |
| 275 | 275 | // Get specified logical unit. |
| 276 | - $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $id . '"]'); |
|
| 276 | + $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]'); |
|
| 277 | 277 | } else { |
| 278 | 278 | // Get all logical units at top level. |
| 279 | 279 | $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]/mets:div'); |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | $cPid = max($cPid, 0); |
| 462 | 462 | if ($cPid == 0 && ($this->cPid || $this->pid)) { |
| 463 | 463 | // Retain current PID. |
| 464 | - $cPid = $this->cPid ?: $this->pid; |
|
| 464 | + $cPid = $this->cPid ? : $this->pid; |
|
| 465 | 465 | } |
| 466 | 466 | return $cPid; |
| 467 | 467 | } |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | if (isset($this->fileInfos[$id]) || isset($hasMetadataSection['dmdSec'])) { |
| 529 | 529 | return $metadata; |
| 530 | 530 | } else { |
| 531 | - $this->logger->warning('No supported descriptive metadata found for logical structure with @ID "' . $id . '"'); |
|
| 531 | + $this->logger->warning('No supported descriptive metadata found for logical structure with @ID "'.$id.'"'); |
|
| 532 | 532 | return []; |
| 533 | 533 | } |
| 534 | 534 | } |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | if (!empty($this->logicalUnits[$id])) { |
| 548 | 548 | return [$this->logicalUnits[$id]['type']]; |
| 549 | 549 | } else { |
| 550 | - $struct = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $id . '"]/@TYPE'); |
|
| 550 | + $struct = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@TYPE'); |
|
| 551 | 551 | if (!empty($struct)) { |
| 552 | 552 | return [(string) $struct[0]]; |
| 553 | 553 | } |
@@ -674,13 +674,13 @@ discard block |
||
| 674 | 674 | if ($resArray['format'] > 0 && !empty($resArray['xpath_sorting'])) { |
| 675 | 675 | $values = $domXPath->evaluate($resArray['xpath_sorting'], $domNode); |
| 676 | 676 | if ($values instanceof \DOMNodeList && $values->length > 0) { |
| 677 | - $metadata[$resArray['index_name'] . '_sorting'][0] = trim((string) $values->item(0)->nodeValue); |
|
| 677 | + $metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values->item(0)->nodeValue); |
|
| 678 | 678 | } elseif (!($values instanceof \DOMNodeList)) { |
| 679 | - $metadata[$resArray['index_name'] . '_sorting'][0] = trim((string) $values); |
|
| 679 | + $metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values); |
|
| 680 | 680 | } |
| 681 | 681 | } |
| 682 | - if (empty($metadata[$resArray['index_name'] . '_sorting'][0])) { |
|
| 683 | - $metadata[$resArray['index_name'] . '_sorting'][0] = $metadata[$resArray['index_name']][0]; |
|
| 682 | + if (empty($metadata[$resArray['index_name'].'_sorting'][0])) { |
|
| 683 | + $metadata[$resArray['index_name'].'_sorting'][0] = $metadata[$resArray['index_name']][0]; |
|
| 684 | 684 | } |
| 685 | 685 | } |
| 686 | 686 | } |
@@ -740,11 +740,11 @@ discard block |
||
| 740 | 740 | return true; |
| 741 | 741 | } |
| 742 | 742 | } else { |
| 743 | - $this->logger->warning('Invalid class/method "' . $class . '->extractMetadata()" for metadata format "' . $this->mdSec[$dmdId]['type'] . '"'); |
|
| 743 | + $this->logger->warning('Invalid class/method "'.$class.'->extractMetadata()" for metadata format "'.$this->mdSec[$dmdId]['type'].'"'); |
|
| 744 | 744 | } |
| 745 | 745 | } |
| 746 | 746 | } else { |
| 747 | - $this->logger->notice('Unsupported metadata format "' . $this->mdSec[$dmdId]['type'] . '" in ' . $mdSectionType . ' with @ID "' . $dmdId . '"'); |
|
| 747 | + $this->logger->notice('Unsupported metadata format "'.$this->mdSec[$dmdId]['type'].'" in '.$mdSectionType.' with @ID "'.$dmdId.'"'); |
|
| 748 | 748 | } |
| 749 | 749 | return false; |
| 750 | 750 | } |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | $dmdIds = $this->logicalUnits[$id]['dmdId'] ?? ''; |
| 852 | 852 | $admIds = $this->logicalUnits[$id]['admId'] ?? ''; |
| 853 | 853 | } else { |
| 854 | - $mdSec = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $id . '"]')[0]; |
|
| 854 | + $mdSec = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]')[0]; |
|
| 855 | 855 | if ($mdSec) { |
| 856 | 856 | $dmdIds = (string) $mdSec->attributes()->DMDID; |
| 857 | 857 | $admIds = (string) $mdSec->attributes()->ADMID; |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | |
| 882 | 882 | return array_filter( |
| 883 | 883 | $allMdIds, |
| 884 | - function ($element) { |
|
| 884 | + function($element) { |
|
| 885 | 885 | return !empty($element); |
| 886 | 886 | } |
| 887 | 887 | ); |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | */ |
| 908 | 908 | public function getStructureDepth(string $logId) |
| 909 | 909 | { |
| 910 | - $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $logId . '"]/ancestor::*'); |
|
| 910 | + $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$logId.'"]/ancestor::*'); |
|
| 911 | 911 | if (!empty($ancestors)) { |
| 912 | 912 | return count($ancestors); |
| 913 | 913 | } else { |
@@ -931,9 +931,9 @@ discard block |
||
| 931 | 931 | $this->registerNamespaces($this->mets); |
| 932 | 932 | } else { |
| 933 | 933 | if (!empty($location)) { |
| 934 | - $this->logger->error('No METS part found in document with location "' . $location . '".'); |
|
| 934 | + $this->logger->error('No METS part found in document with location "'.$location.'".'); |
|
| 935 | 935 | } elseif (!empty($this->recordId)) { |
| 936 | - $this->logger->error('No METS part found in document with recordId "' . $this->recordId . '".'); |
|
| 936 | + $this->logger->error('No METS part found in document with recordId "'.$this->recordId.'".'); |
|
| 937 | 937 | } else { |
| 938 | 938 | $this->logger->error('No METS part found in current document.'); |
| 939 | 939 | } |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | return true; |
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | - $this->logger->error('Could not load XML file from "' . $location . '"'); |
|
| 957 | + $this->logger->error('Could not load XML file from "'.$location.'"'); |
|
| 958 | 958 | return false; |
| 959 | 959 | } |
| 960 | 960 | |
@@ -1077,10 +1077,10 @@ discard block |
||
| 1077 | 1077 | |
| 1078 | 1078 | if (!empty($mdType) && !empty($this->formats[(string) $mdType[0]])) { |
| 1079 | 1079 | $type = (string) $mdType[0]; |
| 1080 | - $xml = $element->xpath('./mets:mdWrap[@MDTYPE="' . $type . '"]/mets:xmlData/' . strtolower($type) . ':' . $this->formats[$type]['rootElement']); |
|
| 1080 | + $xml = $element->xpath('./mets:mdWrap[@MDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']); |
|
| 1081 | 1081 | } elseif (!empty($otherMdType) && !empty($this->formats[(string) $otherMdType[0]])) { |
| 1082 | 1082 | $type = (string) $otherMdType[0]; |
| 1083 | - $xml = $element->xpath('./mets:mdWrap[@MDTYPE="OTHER"][@OTHERMDTYPE="' . $type . '"]/mets:xmlData/' . strtolower($type) . ':' . $this->formats[$type]['rootElement']); |
|
| 1083 | + $xml = $element->xpath('./mets:mdWrap[@MDTYPE="OTHER"][@OTHERMDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']); |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | if (empty($xml)) { |
@@ -1273,9 +1273,9 @@ discard block |
||
| 1273 | 1273 | || $forceReload |
| 1274 | 1274 | ) { |
| 1275 | 1275 | // Retain current PID. |
| 1276 | - $cPid = $this->cPid ?: $this->pid; |
|
| 1276 | + $cPid = $this->cPid ? : $this->pid; |
|
| 1277 | 1277 | if (!$cPid) { |
| 1278 | - $this->logger->error('Invalid PID ' . $cPid . ' for structure definitions'); |
|
| 1278 | + $this->logger->error('Invalid PID '.$cPid.' for structure definitions'); |
|
| 1279 | 1279 | $this->thumbnailLoaded = true; |
| 1280 | 1280 | return $this->thumbnail; |
| 1281 | 1281 | } |
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | if (!empty($resArray['thumbnail'])) { |
| 1313 | 1313 | $strctType = Helper::getIndexNameFromUid($resArray['thumbnail'], 'tx_dlf_structures', $cPid); |
| 1314 | 1314 | // Check if this document has a structure element of the desired type. |
| 1315 | - $strctIds = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@TYPE="' . $strctType . '"]/@ID'); |
|
| 1315 | + $strctIds = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@TYPE="'.$strctType.'"]/@ID'); |
|
| 1316 | 1316 | if (!empty($strctIds)) { |
| 1317 | 1317 | $strctId = (string) $strctIds[0]; |
| 1318 | 1318 | } |
@@ -1335,7 +1335,7 @@ discard block |
||
| 1335 | 1335 | } |
| 1336 | 1336 | } |
| 1337 | 1337 | } else { |
| 1338 | - $this->logger->error('No structure of type "' . $metadata['type'][0] . '" found in database'); |
|
| 1338 | + $this->logger->error('No structure of type "'.$metadata['type'][0].'" found in database'); |
|
| 1339 | 1339 | } |
| 1340 | 1340 | $this->thumbnailLoaded = true; |
| 1341 | 1341 | } |
@@ -1381,7 +1381,7 @@ discard block |
||
| 1381 | 1381 | { |
| 1382 | 1382 | if (empty($this->parentHref)) { |
| 1383 | 1383 | // Get the closest ancestor of the current document which has a MPTR child. |
| 1384 | - $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $this->toplevelId . '"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); |
|
| 1384 | + $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$this->toplevelId.'"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); |
|
| 1385 | 1385 | if (!empty($parentMptr)) { |
| 1386 | 1386 | $this->parentHref = (string) $parentMptr[0]->attributes('http://www.w3.org/1999/xlink')->href; |
| 1387 | 1387 | } |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | * @property-read \SimpleXMLElement $mets this holds the XML file's METS part as \SimpleXMLElement object |
| 64 | 64 | * @property-read string $parentHref URL of the parent document (determined via mptr element), or empty string if none is available |
| 65 | 65 | */ |
| 66 | -final class MetsDocument extends AbstractDocument |
|
| 67 | -{ |
|
| 66 | +final class MetsDocument extends AbstractDocument { |
|
| 68 | 67 | /** |
| 69 | 68 | * @access protected |
| 70 | 69 | * @var string[] Subsections / tags that may occur within `<mets:amdSec>` |
@@ -397,8 +396,7 @@ discard block |
||
| 397 | 396 | * |
| 398 | 397 | * @return ?string thumbnail or null if not found |
| 399 | 398 | */ |
| 400 | - private function getThumbnail(string $id = '') |
|
| 401 | - { |
|
| 399 | + private function getThumbnail(string $id = '') { |
|
| 402 | 400 | // Load plugin configuration. |
| 403 | 401 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 404 | 402 | $fileGrpsThumb = GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']); |
@@ -726,8 +724,7 @@ discard block |
||
| 726 | 724 | * |
| 727 | 725 | * @return bool true if extraction successful, false otherwise |
| 728 | 726 | */ |
| 729 | - private function extractMetadataIfTypeSupported(string $dmdId, string $mdSectionType, array &$metadata) |
|
| 730 | - { |
|
| 727 | + private function extractMetadataIfTypeSupported(string $dmdId, string $mdSectionType, array &$metadata) { |
|
| 731 | 728 | // Is this metadata format supported? |
| 732 | 729 | if (!empty($this->formats[$this->mdSec[$dmdId]['type']])) { |
| 733 | 730 | if (!empty($this->formats[$this->mdSec[$dmdId]['type']]['class'])) { |
@@ -759,8 +756,7 @@ discard block |
||
| 759 | 756 | * |
| 760 | 757 | * @return array additional metadata data queried from database |
| 761 | 758 | */ |
| 762 | - private function getAdditionalMetadataFromDatabase(int $cPid, string $dmdId) |
|
| 763 | - { |
|
| 759 | + private function getAdditionalMetadataFromDatabase(int $cPid, string $dmdId) { |
|
| 764 | 760 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 765 | 761 | ->getQueryBuilderForTable('tx_dlf_metadata'); |
| 766 | 762 | // Get hidden records, too. |
@@ -905,8 +901,7 @@ discard block |
||
| 905 | 901 | /** |
| 906 | 902 | * @see AbstractDocument::getStructureDepth() |
| 907 | 903 | */ |
| 908 | - public function getStructureDepth(string $logId) |
|
| 909 | - { |
|
| 904 | + public function getStructureDepth(string $logId) { |
|
| 910 | 905 | $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $logId . '"]/ancestor::*'); |
| 911 | 906 | if (!empty($ancestors)) { |
| 912 | 907 | return count($ancestors); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @see MetsDocument::$mdSec |
| 102 | 102 | */ |
| 103 | - protected bool $mdSecLoaded = false; |
|
| 103 | + protected bool $mdSecLoaded = FALSE; |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * @access protected |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @see $fileGrps |
| 124 | 124 | */ |
| 125 | - protected bool $fileGrpsLoaded = false; |
|
| 125 | + protected bool $fileGrpsLoaded = FALSE; |
|
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * @access protected |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | return $service->getImageUrl(); |
| 199 | 199 | } |
| 200 | 200 | } elseif ($file['mimeType'] === 'application/vnd.netfpx') { |
| 201 | - $baseURL = $file['location'] . (strpos($file['location'], '?') === false ? '?' : ''); |
|
| 201 | + $baseURL = $file['location'] . (strpos($file['location'], '?') === FALSE ? '?' : ''); |
|
| 202 | 202 | // TODO CVT is an optional IIP server capability; in theory, capabilities should be determined in the object request with '&obj=IIP-server' |
| 203 | 203 | return $baseURL . '&CVT=jpeg'; |
| 204 | 204 | } |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | /** |
| 262 | 262 | * @see AbstractDocument::getLogicalStructure() |
| 263 | 263 | */ |
| 264 | - public function getLogicalStructure(string $id, bool $recursive = false): array |
|
| 264 | + public function getLogicalStructure(string $id, bool $recursive = FALSE): array |
|
| 265 | 265 | { |
| 266 | 266 | $details = []; |
| 267 | 267 | // Is the requested logical unit already loaded? |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
| 304 | 304 | */ |
| 305 | - protected function getLogicalStructureInfo(\SimpleXMLElement $structure, bool $recursive = false): array |
|
| 305 | + protected function getLogicalStructureInfo(\SimpleXMLElement $structure, bool $recursive = FALSE): array |
|
| 306 | 306 | { |
| 307 | 307 | $attributes = $structure->attributes(); |
| 308 | 308 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | 'pagination' => '', |
| 321 | 321 | 'type' => isset($attributes['TYPE']) ? (string) $attributes['TYPE'] : '', |
| 322 | 322 | 'description' => '', |
| 323 | - 'thumbnailId' => null, |
|
| 323 | + 'thumbnailId' => NULL, |
|
| 324 | 324 | 'files' => [], |
| 325 | 325 | ]; |
| 326 | 326 | |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | && array_key_exists($details['id'], $this->smLinks['l2p']) |
| 352 | 352 | ) { |
| 353 | 353 | // Link logical structure to the first corresponding physical page/track. |
| 354 | - $details['points'] = max((int) array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, true), 1); |
|
| 354 | + $details['points'] = max((int) array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, TRUE), 1); |
|
| 355 | 355 | $details['thumbnailId'] = $this->getThumbnail(); |
| 356 | 356 | // Get page/track number of the first page/track related to this structure element. |
| 357 | 357 | $details['pagination'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['orderlabel']; |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $details['points'] = 1; |
| 361 | 361 | $details['thumbnailId'] = $this->getThumbnail(); |
| 362 | 362 | } |
| 363 | - if ($details['thumbnailId'] === null) { |
|
| 363 | + if ($details['thumbnailId'] === NULL) { |
|
| 364 | 364 | unset($details['thumbnailId']); |
| 365 | 365 | } |
| 366 | 366 | // Get the files this structure element is pointing at. |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | $details['children'] = []; |
| 383 | 383 | foreach ($structure->children('http://www.loc.gov/METS/')->div as $child) { |
| 384 | 384 | // Repeat for all children. |
| 385 | - $details['children'][] = $this->getLogicalStructureInfo($child, true); |
|
| 385 | + $details['children'][] = $this->getLogicalStructureInfo($child, TRUE); |
|
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | return $details; |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 404 | 404 | $fileGrpsThumb = GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']); |
| 405 | 405 | |
| 406 | - $thumbnail = null; |
|
| 406 | + $thumbnail = NULL; |
|
| 407 | 407 | |
| 408 | 408 | while ($fileGrpThumb = array_shift($fileGrpsThumb)) { |
| 409 | 409 | if (empty($id)) { |
| 410 | - $thumbnail = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb] ?? null; |
|
| 410 | + $thumbnail = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb] ?? NULL; |
|
| 411 | 411 | } else { |
| 412 | - $parentId = $this->smLinks['l2p'][$id][0] ?? null; |
|
| 413 | - $thumbnail = $this->physicalStructureInfo[$parentId]['files'][$fileGrpThumb] ?? null; |
|
| 412 | + $parentId = $this->smLinks['l2p'][$id][0] ?? NULL; |
|
| 413 | + $thumbnail = $this->physicalStructureInfo[$parentId]['files'][$fileGrpThumb] ?? NULL; |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | if (!empty($thumbnail)) { |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | continue; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | - $hasMetadataSection[$mdSectionType] = true; |
|
| 524 | + $hasMetadataSection[$mdSectionType] = TRUE; |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | // Files are not expected to reference a dmdSec |
@@ -571,13 +571,13 @@ discard block |
||
| 571 | 571 | private function extractAndProcessMetadata(string $dmdId, string $mdSectionType, array &$metadata, int $cPid, array $hasMetadataSection): bool |
| 572 | 572 | { |
| 573 | 573 | if ($mdSectionType === 'dmdSec' && isset($hasMetadataSection['dmdSec'])) { |
| 574 | - return true; |
|
| 574 | + return TRUE; |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | $metadataExtracted = $this->extractMetadataIfTypeSupported($dmdId, $mdSectionType, $metadata); |
| 578 | 578 | |
| 579 | 579 | if (!$metadataExtracted) { |
| 580 | - return false; |
|
| 580 | + return FALSE; |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | $additionalMetadata = $this->getAdditionalMetadataFromDatabase($cPid, $dmdId); |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | $this->processAdditionalMetadata($additionalMetadata, $domXPath, $domNode, $metadata); |
| 590 | 590 | |
| 591 | - return true; |
|
| 591 | + return TRUE; |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | $obj = GeneralUtility::makeInstance($class); |
| 738 | 738 | if ($obj instanceof MetadataInterface) { |
| 739 | 739 | $obj->extractMetadata($this->mdSec[$dmdId]['xml'], $metadata, GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey)['useExternalApisForMetadata']); |
| 740 | - return true; |
|
| 740 | + return TRUE; |
|
| 741 | 741 | } |
| 742 | 742 | } else { |
| 743 | 743 | $this->logger->warning('Invalid class/method "' . $class . '->extractMetadata()" for metadata format "' . $this->mdSec[$dmdId]['type'] . '"'); |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | } else { |
| 747 | 747 | $this->logger->notice('Unsupported metadata format "' . $this->mdSec[$dmdId]['type'] . '" in ' . $mdSectionType . ' with @ID "' . $dmdId . '"'); |
| 748 | 748 | } |
| 749 | - return false; |
|
| 749 | + return FALSE; |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /** |
@@ -946,16 +946,16 @@ discard block |
||
| 946 | 946 | protected function loadLocation(string $location): bool |
| 947 | 947 | { |
| 948 | 948 | $fileResource = Helper::getUrl($location); |
| 949 | - if ($fileResource !== false) { |
|
| 949 | + if ($fileResource !== FALSE) { |
|
| 950 | 950 | $xml = Helper::getXmlFileAsString($fileResource); |
| 951 | 951 | // Set some basic properties. |
| 952 | - if ($xml !== false) { |
|
| 952 | + if ($xml !== FALSE) { |
|
| 953 | 953 | $this->xml = $xml; |
| 954 | - return true; |
|
| 954 | + return TRUE; |
|
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | 957 | $this->logger->error('Could not load XML file from "' . $location . '"'); |
| 958 | - return false; |
|
| 958 | + return FALSE; |
|
| 959 | 959 | } |
| 960 | 960 | |
| 961 | 961 | /** |
@@ -977,9 +977,9 @@ discard block |
||
| 977 | 977 | |
| 978 | 978 | if ($preloadedDocument instanceof \SimpleXMLElement) { |
| 979 | 979 | $this->xml = $preloadedDocument; |
| 980 | - return true; |
|
| 980 | + return TRUE; |
|
| 981 | 981 | } |
| 982 | - return false; |
|
| 982 | + return FALSE; |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | /** |
@@ -1005,7 +1005,7 @@ discard block |
||
| 1005 | 1005 | foreach ($this->mets->xpath('./mets:dmdSec') as $dmdSecTag) { |
| 1006 | 1006 | $dmdSec = $this->processMdSec($dmdSecTag); |
| 1007 | 1007 | |
| 1008 | - if ($dmdSec !== null) { |
|
| 1008 | + if ($dmdSec !== NULL) { |
|
| 1009 | 1009 | $this->mdSec[$dmdSec['id']] = $dmdSec; |
| 1010 | 1010 | $this->dmdSec[$dmdSec['id']] = $dmdSec; |
| 1011 | 1011 | } |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | // TODO: Should we check that the format may occur within this type (e.g., to ignore VIDEOMD within rightsMD)? |
| 1023 | 1023 | $mdSec = $this->processMdSec($mdSecTag); |
| 1024 | 1024 | |
| 1025 | - if ($mdSec !== null) { |
|
| 1025 | + if ($mdSec !== NULL) { |
|
| 1026 | 1026 | $this->mdSec[$mdSec['id']] = $mdSec; |
| 1027 | 1027 | |
| 1028 | 1028 | $childIds[] = $mdSec['id']; |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | } |
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | - $this->mdSecLoaded = true; |
|
| 1038 | + $this->mdSecLoaded = TRUE; |
|
| 1039 | 1039 | } |
| 1040 | 1040 | return $this->mdSec; |
| 1041 | 1041 | } |
@@ -1066,7 +1066,7 @@ discard block |
||
| 1066 | 1066 | { |
| 1067 | 1067 | $mdId = (string) $element->attributes()->ID; |
| 1068 | 1068 | if (empty($mdId)) { |
| 1069 | - return null; |
|
| 1069 | + return NULL; |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | $this->registerNamespaces($element); |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | if (empty($xml)) { |
| 1087 | - return null; |
|
| 1087 | + return NULL; |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | $this->registerNamespaces($xml[0]); |
@@ -1145,9 +1145,9 @@ discard block |
||
| 1145 | 1145 | !empty($extConf['fileGrpFulltext']) |
| 1146 | 1146 | && array_intersect(GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']), $this->fileGrps) !== [] |
| 1147 | 1147 | ) { |
| 1148 | - $this->hasFulltext = true; |
|
| 1148 | + $this->hasFulltext = TRUE; |
|
| 1149 | 1149 | } |
| 1150 | - $this->fileGrpsLoaded = true; |
|
| 1150 | + $this->fileGrpsLoaded = TRUE; |
|
| 1151 | 1151 | } |
| 1152 | 1152 | return $this->fileGrps; |
| 1153 | 1153 | } |
@@ -1240,7 +1240,7 @@ discard block |
||
| 1240 | 1240 | array_unshift($elements, $id); |
| 1241 | 1241 | $this->physicalStructure = $elements; |
| 1242 | 1242 | } |
| 1243 | - $this->physicalStructureLoaded = true; |
|
| 1243 | + $this->physicalStructureLoaded = TRUE; |
|
| 1244 | 1244 | } |
| 1245 | 1245 | return $this->physicalStructure; |
| 1246 | 1246 | } |
@@ -1258,7 +1258,7 @@ discard block |
||
| 1258 | 1258 | $this->smLinks['p2l'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->to][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->from; |
| 1259 | 1259 | } |
| 1260 | 1260 | } |
| 1261 | - $this->smLinksLoaded = true; |
|
| 1261 | + $this->smLinksLoaded = TRUE; |
|
| 1262 | 1262 | } |
| 1263 | 1263 | return $this->smLinks; |
| 1264 | 1264 | } |
@@ -1266,7 +1266,7 @@ discard block |
||
| 1266 | 1266 | /** |
| 1267 | 1267 | * @see AbstractDocument::magicGetThumbnail() |
| 1268 | 1268 | */ |
| 1269 | - protected function magicGetThumbnail(bool $forceReload = false): string |
|
| 1269 | + protected function magicGetThumbnail(bool $forceReload = FALSE): string |
|
| 1270 | 1270 | { |
| 1271 | 1271 | if ( |
| 1272 | 1272 | !$this->thumbnailLoaded |
@@ -1276,14 +1276,14 @@ discard block |
||
| 1276 | 1276 | $cPid = $this->cPid ?: $this->pid; |
| 1277 | 1277 | if (!$cPid) { |
| 1278 | 1278 | $this->logger->error('Invalid PID ' . $cPid . ' for structure definitions'); |
| 1279 | - $this->thumbnailLoaded = true; |
|
| 1279 | + $this->thumbnailLoaded = TRUE; |
|
| 1280 | 1280 | return $this->thumbnail; |
| 1281 | 1281 | } |
| 1282 | 1282 | // Load extension configuration. |
| 1283 | 1283 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 1284 | 1284 | if (empty($extConf['fileGrpThumbs'])) { |
| 1285 | 1285 | $this->logger->warning('No fileGrp for thumbnails specified'); |
| 1286 | - $this->thumbnailLoaded = true; |
|
| 1286 | + $this->thumbnailLoaded = TRUE; |
|
| 1287 | 1287 | return $this->thumbnail; |
| 1288 | 1288 | } |
| 1289 | 1289 | $strctId = $this->magicGetToplevelId(); |
@@ -1337,7 +1337,7 @@ discard block |
||
| 1337 | 1337 | } else { |
| 1338 | 1338 | $this->logger->error('No structure of type "' . $metadata['type'][0] . '" found in database'); |
| 1339 | 1339 | } |
| 1340 | - $this->thumbnailLoaded = true; |
|
| 1340 | + $this->thumbnailLoaded = TRUE; |
|
| 1341 | 1341 | } |
| 1342 | 1342 | return $this->thumbnail; |
| 1343 | 1343 | } |
@@ -1415,8 +1415,8 @@ discard block |
||
| 1415 | 1415 | public function __toString(): string |
| 1416 | 1416 | { |
| 1417 | 1417 | $xml = new \DOMDocument('1.0', 'utf-8'); |
| 1418 | - $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); |
|
| 1419 | - $xml->formatOutput = true; |
|
| 1418 | + $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), TRUE)); |
|
| 1419 | + $xml->formatOutput = TRUE; |
|
| 1420 | 1420 | return $xml->saveXML(); |
| 1421 | 1421 | } |
| 1422 | 1422 | |
@@ -1431,7 +1431,7 @@ discard block |
||
| 1431 | 1431 | public function __wakeup(): void |
| 1432 | 1432 | { |
| 1433 | 1433 | $xml = Helper::getXmlFileAsString($this->asXML); |
| 1434 | - if ($xml !== false) { |
|
| 1434 | + if ($xml !== FALSE) { |
|
| 1435 | 1435 | $this->asXML = ''; |
| 1436 | 1436 | $this->xml = $xml; |
| 1437 | 1437 | // Rebuild the unserializable properties. |