@@ -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 | } |
@@ -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 (isset($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,23 +661,23 @@ 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 | - $fulltextExists = $parameters['fulltext'] ?? false; |
|
| 673 | - if ($fulltextExists === true) { |
|
| 672 | + $fulltextExists = $parameters['fulltext'] ?? FALSE; |
|
| 673 | + if ($fulltextExists === TRUE) { |
|
| 674 | 674 | // get highlighting component and apply settings |
| 675 | 675 | $selectQuery->getHighlighting(); |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | $solrRequest = $solr->service->createRequest($selectQuery); |
| 679 | 679 | |
| 680 | - if ($fulltextExists === true) { |
|
| 680 | + if ($fulltextExists === TRUE) { |
|
| 681 | 681 | // If it is a fulltext search, enable highlighting. |
| 682 | 682 | // field for which highlighting is going to be performed, |
| 683 | 683 | // is required if you want to have OCR highlighting |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | $resultSet['numberOfToplevels'] = $uidGroup->getNumberOfGroups(); |
| 705 | 705 | $resultSet['numFound'] = $uidGroup->getMatches(); |
| 706 | 706 | $highlighting = []; |
| 707 | - if ($fulltextExists === true) { |
|
| 707 | + if ($fulltextExists === TRUE) { |
|
| 708 | 708 | $data = $result->getData(); |
| 709 | 709 | $highlighting = $data['ocrHighlighting']; |
| 710 | 710 | } |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | // Save value in cache. |
| 720 | - if (!empty($resultSet['documents']) && $enableCache === true) { |
|
| 720 | + if (!empty($resultSet['documents']) && $enableCache === TRUE) { |
|
| 721 | 721 | $cache->set($cacheIdentifier, $resultSet); |
| 722 | 722 | } |
| 723 | 723 | } else { |
@@ -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 = [ |
@@ -743,24 +743,24 @@ discard block |
||
| 743 | 743 | foreach ($this->collections as $collection) { |
| 744 | 744 | // check for virtual collections query string |
| 745 | 745 | if ($collection->getIndexSearch()) { |
| 746 | - $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '(' . $collection->getIndexSearch() . ')' : ' OR (' . $collection->getIndexSearch() . ')'; |
|
| 746 | + $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '('.$collection->getIndexSearch().')' : ' OR ('.$collection->getIndexSearch().')'; |
|
| 747 | 747 | } else { |
| 748 | - $collectionsQueryString .= empty($collectionsQueryString) ? '"' . $collection->getIndexName() . '"' : ' OR "' . $collection->getIndexName() . '"'; |
|
| 748 | + $collectionsQueryString .= empty($collectionsQueryString) ? '"'.$collection->getIndexName().'"' : ' OR "'.$collection->getIndexName().'"'; |
|
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | // distinguish between simple collection browsing and actual searching within the collection(s) |
| 753 | 753 | if (!empty($collectionsQueryString)) { |
| 754 | 754 | if (empty($query)) { |
| 755 | - $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . ') AND toplevel:true AND partof:0)'; |
|
| 755 | + $collectionsQueryString = '(collection_faceting:('.$collectionsQueryString.') AND toplevel:true AND partof:0)'; |
|
| 756 | 756 | } else { |
| 757 | - $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . '))'; |
|
| 757 | + $collectionsQueryString = '(collection_faceting:('.$collectionsQueryString.'))'; |
|
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | // virtual collections might query documents that are neither toplevel:true nor partof:0 and need to be searched separately |
| 762 | 762 | if (!empty($virtualCollectionsQueryString)) { |
| 763 | - $virtualCollectionsQueryString = '(' . $virtualCollectionsQueryString . ')'; |
|
| 763 | + $virtualCollectionsQueryString = '('.$virtualCollectionsQueryString.')'; |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | // combine both query strings into a single filterquery via OR if both are given, otherwise pass either of those |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | private function translateLanguageCode(&$doc): void |
| 839 | 839 | { |
| 840 | 840 | if (array_key_exists('language', $doc['metadata'])) { |
| 841 | - foreach($doc['metadata']['language'] as $indexName => $language) { |
|
| 841 | + foreach ($doc['metadata']['language'] as $indexName => $language) { |
|
| 842 | 842 | $doc['metadata']['language'][$indexName] = Helper::getLanguageName($language); |
| 843 | 843 | } |
| 844 | 844 | } |
@@ -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 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $parent->setCurrentDocument($doc); |
| 115 | 115 | $success = self::add($parent, $documentRepository); |
| 116 | 116 | } else { |
| 117 | - Helper::log('Could not load parent document with UID ' . $document->getCurrentDocument()->parentId, LOG_SEVERITY_ERROR); |
|
| 117 | + Helper::log('Could not load parent document with UID '.$document->getCurrentDocument()->parentId, LOG_SEVERITY_ERROR); |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -197,19 +197,19 @@ discard block |
||
| 197 | 197 | } catch (\Exception $e) { |
| 198 | 198 | if (!(Environment::isCli())) { |
| 199 | 199 | Helper::addMessage( |
| 200 | - Helper::getLanguageService()->getLL('flash.solrException') . ' ' . htmlspecialchars($e->getMessage()), |
|
| 200 | + Helper::getLanguageService()->getLL('flash.solrException').' '.htmlspecialchars($e->getMessage()), |
|
| 201 | 201 | Helper::getLanguageService()->getLL('flash.error'), |
| 202 | 202 | FlashMessage::ERROR, |
| 203 | 203 | true, |
| 204 | 204 | 'core.template.flashMessages' |
| 205 | 205 | ); |
| 206 | 206 | } |
| 207 | - Helper::log('Apache Solr threw exception: "' . $e->getMessage() . '"', LOG_SEVERITY_ERROR); |
|
| 207 | + Helper::log('Apache Solr threw exception: "'.$e->getMessage().'"', LOG_SEVERITY_ERROR); |
|
| 208 | 208 | return false; |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - Helper::log('Document not deleted from SOLR - problem with the connection to the SOLR core ' . $solrCoreUid, LOG_SEVERITY_ERROR); |
|
| 212 | + Helper::log('Document not deleted from SOLR - problem with the connection to the SOLR core '.$solrCoreUid, LOG_SEVERITY_ERROR); |
|
| 213 | 213 | return false; |
| 214 | 214 | } |
| 215 | 215 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | // Sanitize input. |
| 231 | 231 | $pid = max((int) $pid, 0); |
| 232 | 232 | if (!$pid) { |
| 233 | - Helper::log('Invalid PID ' . $pid . ' for metadata configuration', LOG_SEVERITY_ERROR); |
|
| 233 | + Helper::log('Invalid PID '.$pid.' for metadata configuration', LOG_SEVERITY_ERROR); |
|
| 234 | 234 | return ''; |
| 235 | 235 | } |
| 236 | 236 | // Load metadata configuration. |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $suffix = (in_array($indexName, self::$fields['tokenized']) ? 't' : 'u'); |
| 240 | 240 | $suffix .= (in_array($indexName, self::$fields['stored']) ? 's' : 'u'); |
| 241 | 241 | $suffix .= (in_array($indexName, self::$fields['indexed']) ? 'i' : 'u'); |
| 242 | - $indexName .= '_' . $suffix; |
|
| 242 | + $indexName .= '_'.$suffix; |
|
| 243 | 243 | return $indexName; |
| 244 | 244 | } |
| 245 | 245 | |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $solrDoc->setField('title', $metadata['title'][0], self::$fields['fieldboost']['title']); |
| 361 | 361 | $solrDoc->setField('volume', $metadata['volume'][0], self::$fields['fieldboost']['volume']); |
| 362 | 362 | // verify date formatting |
| 363 | - if(strtotime($metadata['date'][0])) { |
|
| 363 | + if (strtotime($metadata['date'][0])) { |
|
| 364 | 364 | $solrDoc->setField('date', self::getFormattedDate($metadata['date'][0])); |
| 365 | 365 | } |
| 366 | 366 | $solrDoc->setField('record_id', $metadata['record_id'][0]); |
@@ -523,11 +523,11 @@ discard block |
||
| 523 | 523 | $solrDoc->setField(self::getIndexFieldName($indexName, $document->getPid()), $data, self::$fields['fieldboost'][$indexName]); |
| 524 | 524 | if (in_array($indexName, self::$fields['sortables'])) { |
| 525 | 525 | // Add sortable fields to index. |
| 526 | - $solrDoc->setField($indexName . '_sorting', $metadata[$indexName . '_sorting'][0]); |
|
| 526 | + $solrDoc->setField($indexName.'_sorting', $metadata[$indexName.'_sorting'][0]); |
|
| 527 | 527 | } |
| 528 | 528 | if (in_array($indexName, self::$fields['facets'])) { |
| 529 | 529 | // Add facets to index. |
| 530 | - $solrDoc->setField($indexName . '_faceting', $data); |
|
| 530 | + $solrDoc->setField($indexName.'_faceting', $data); |
|
| 531 | 531 | } |
| 532 | 532 | if (in_array($indexName, self::$fields['autocomplete'])) { |
| 533 | 533 | $autocomplete = array_merge($autocomplete, $data); |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | $data = self::removeAppendsFromAuthor($data); |
| 564 | 564 | } |
| 565 | 565 | // Add facets to index. |
| 566 | - $solrDoc->setField($indexName . '_faceting', $data); |
|
| 566 | + $solrDoc->setField($indexName.'_faceting', $data); |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | // Add sorting information to physical sub-elements if applicable. |
@@ -593,9 +593,9 @@ discard block |
||
| 593 | 593 | $update = self::$solr->service->createUpdate(); |
| 594 | 594 | $query = ""; |
| 595 | 595 | if ($field == 'uid' || $field == 'partof') { |
| 596 | - $query = $field . ':' . $value; |
|
| 596 | + $query = $field.':'.$value; |
|
| 597 | 597 | } else { |
| 598 | - $query = $field . ':"' . $value . '"'; |
|
| 598 | + $query = $field.':"'.$value.'"'; |
|
| 599 | 599 | } |
| 600 | 600 | $update->addDeleteQuery($query); |
| 601 | 601 | $update->addCommit(); |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | { |
| 621 | 621 | $solrDoc = $updateQuery->createDocument(); |
| 622 | 622 | // Create unique identifier from document's UID and unit's XML ID. |
| 623 | - $solrDoc->setField('id', $document->getUid() . $unit['id']); |
|
| 623 | + $solrDoc->setField('id', $document->getUid().$unit['id']); |
|
| 624 | 624 | $solrDoc->setField('uid', $document->getUid()); |
| 625 | 625 | $solrDoc->setField('pid', $document->getPid()); |
| 626 | 626 | $solrDoc->setField('partof', $document->getPartof()); |
@@ -699,9 +699,9 @@ discard block |
||
| 699 | 699 | private static function handleException(string $errorMessage): void |
| 700 | 700 | { |
| 701 | 701 | if (!(Environment::isCli())) { |
| 702 | - self::addErrorMessage(Helper::getLanguageService()->getLL('flash.solrException') . '<br />' . htmlspecialchars($errorMessage)); |
|
| 702 | + self::addErrorMessage(Helper::getLanguageService()->getLL('flash.solrException').'<br />'.htmlspecialchars($errorMessage)); |
|
| 703 | 703 | } |
| 704 | - Helper::log('Apache Solr threw exception: "' . $errorMessage . '"', LOG_SEVERITY_ERROR); |
|
| 704 | + Helper::log('Apache Solr threw exception: "'.$errorMessage.'"', LOG_SEVERITY_ERROR); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @see $fields |
| 69 | 69 | */ |
| 70 | - protected static bool $fieldsLoaded = false; |
|
| 70 | + protected static bool $fieldsLoaded = FALSE; |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * @access protected |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | public static function add(Document $document, DocumentRepository $documentRepository): bool |
| 99 | 99 | { |
| 100 | 100 | if (in_array($document->getUid(), self::$processedDocs)) { |
| 101 | - return true; |
|
| 101 | + return TRUE; |
|
| 102 | 102 | } elseif (self::solrConnect($document->getSolrcore(), $document->getPid())) { |
| 103 | - $success = true; |
|
| 103 | + $success = TRUE; |
|
| 104 | 104 | Helper::getLanguageService()->includeLLFile('EXT:dlf/Resources/Private/Language/locallang_be.xlf'); |
| 105 | 105 | // Handle multi-volume documents. |
| 106 | 106 | $parentId = $document->getPartof(); |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | $parent = $documentRepository->findByUid($parentId); |
| 110 | 110 | if ($parent) { |
| 111 | 111 | // get XML document of parent |
| 112 | - $doc = AbstractDocument::getInstance($parent->getLocation(), ['storagePid' => $parent->getPid()], true); |
|
| 113 | - if ($doc !== null) { |
|
| 112 | + $doc = AbstractDocument::getInstance($parent->getLocation(), ['storagePid' => $parent->getPid()], TRUE); |
|
| 113 | + if ($doc !== NULL) { |
|
| 114 | 114 | $parent->setCurrentDocument($doc); |
| 115 | 115 | $success = self::add($parent, $documentRepository); |
| 116 | 116 | } else { |
| 117 | 117 | Helper::log('Could not load parent document with UID ' . $document->getCurrentDocument()->parentId, LOG_SEVERITY_ERROR); |
| 118 | - return false; |
|
| 118 | + return FALSE; |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | return $success; |
| 163 | 163 | } catch (\Exception $e) { |
| 164 | 164 | self::handleException($e->getMessage()); |
| 165 | - return false; |
|
| 165 | + return FALSE; |
|
| 166 | 166 | } |
| 167 | 167 | } else { |
| 168 | 168 | if (!(Environment::isCli())) { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | ); |
| 174 | 174 | } |
| 175 | 175 | Helper::log('Could not connect to Apache Solr server', LOG_SEVERITY_ERROR); |
| 176 | - return false; |
|
| 176 | + return FALSE; |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
@@ -193,24 +193,24 @@ discard block |
||
| 193 | 193 | if (self::solrConnect($solrCoreUid, $input->getOption('pid'))) { |
| 194 | 194 | try { |
| 195 | 195 | self::deleteDocument($field, $input->getOption('doc')); |
| 196 | - return true; |
|
| 196 | + return TRUE; |
|
| 197 | 197 | } catch (\Exception $e) { |
| 198 | 198 | if (!(Environment::isCli())) { |
| 199 | 199 | Helper::addMessage( |
| 200 | 200 | Helper::getLanguageService()->getLL('flash.solrException') . ' ' . htmlspecialchars($e->getMessage()), |
| 201 | 201 | Helper::getLanguageService()->getLL('flash.error'), |
| 202 | 202 | FlashMessage::ERROR, |
| 203 | - true, |
|
| 203 | + TRUE, |
|
| 204 | 204 | 'core.template.flashMessages' |
| 205 | 205 | ); |
| 206 | 206 | } |
| 207 | 207 | Helper::log('Apache Solr threw exception: "' . $e->getMessage() . '"', LOG_SEVERITY_ERROR); |
| 208 | - return false; |
|
| 208 | + return FALSE; |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | Helper::log('Document not deleted from SOLR - problem with the connection to the SOLR core ' . $solrCoreUid, LOG_SEVERITY_ERROR); |
| 213 | - return false; |
|
| 213 | + return FALSE; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -308,10 +308,10 @@ discard block |
||
| 308 | 308 | if ($indexing['index_boost'] > 0.0) { |
| 309 | 309 | self::$fields['fieldboost'][$indexing['index_name']] = floatval($indexing['index_boost']); |
| 310 | 310 | } else { |
| 311 | - self::$fields['fieldboost'][$indexing['index_name']] = false; |
|
| 311 | + self::$fields['fieldboost'][$indexing['index_name']] = FALSE; |
|
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | - self::$fieldsLoaded = true; |
|
| 314 | + self::$fieldsLoaded = TRUE; |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | protected static function processLogical(Document $document, array $logicalUnit): bool |
| 331 | 331 | { |
| 332 | - $success = true; |
|
| 332 | + $success = TRUE; |
|
| 333 | 333 | $doc = $document->getCurrentDocument(); |
| 334 | 334 | $doc->cPid = $document->getPid(); |
| 335 | 335 | // Get metadata for logical unit. |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $solrDoc->setField('thumbnail', $doc->getFileLocation($logicalUnit['thumbnailId'])); |
| 357 | 357 | } |
| 358 | 358 | // There can be only one toplevel unit per UID, independently of backend configuration |
| 359 | - $solrDoc->setField('toplevel', $logicalUnit['id'] == $doc->toplevelId ? true : false); |
|
| 359 | + $solrDoc->setField('toplevel', $logicalUnit['id'] == $doc->toplevelId ? TRUE : FALSE); |
|
| 360 | 360 | $solrDoc->setField('title', $metadata['title'][0], self::$fields['fieldboost']['title']); |
| 361 | 361 | $solrDoc->setField('volume', $metadata['volume'][0], self::$fields['fieldboost']['volume']); |
| 362 | 362 | // verify date formatting |
@@ -392,11 +392,11 @@ discard block |
||
| 392 | 392 | self::$solr->service->update($updateQuery); |
| 393 | 393 | } catch (\Exception $e) { |
| 394 | 394 | self::handleException($e->getMessage()); |
| 395 | - return false; |
|
| 395 | + return FALSE; |
|
| 396 | 396 | } |
| 397 | 397 | } else { |
| 398 | 398 | 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); |
| 399 | - return false; |
|
| 399 | + return FALSE; |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | // Check for child elements... |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | break; |
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | - $solrDoc->setField('toplevel', false); |
|
| 447 | + $solrDoc->setField('toplevel', FALSE); |
|
| 448 | 448 | $solrDoc->setField('type', $physicalUnit['type'], self::$fields['fieldboost']['type']); |
| 449 | 449 | $solrDoc->setField('collection', $doc->metadataArray[$doc->toplevelId]['collection']); |
| 450 | 450 | $solrDoc->setField('location', $document->getLocation()); |
@@ -465,10 +465,10 @@ discard block |
||
| 465 | 465 | self::$solr->service->update($updateQuery); |
| 466 | 466 | } catch (\Exception $e) { |
| 467 | 467 | self::handleException($e->getMessage()); |
| 468 | - return false; |
|
| 468 | + return FALSE; |
|
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | - return true; |
|
| 471 | + return TRUE; |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -494,9 +494,9 @@ discard block |
||
| 494 | 494 | if ($pid) { |
| 495 | 495 | self::loadIndexConf($pid); |
| 496 | 496 | } |
| 497 | - return true; |
|
| 497 | + return TRUE; |
|
| 498 | 498 | } |
| 499 | - return false; |
|
| 499 | + return FALSE; |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | $message, |
| 744 | 744 | Helper::getLanguageService()->getLL($type), |
| 745 | 745 | $status, |
| 746 | - true, |
|
| 746 | + TRUE, |
|
| 747 | 747 | 'core.template.flashMessages' |
| 748 | 748 | ); |
| 749 | 749 | } |
@@ -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 | } |