@@ -28,8 +28,7 @@ discard block |
||
| 28 | 28 | * @subpackage dlf |
| 29 | 29 | * @access public |
| 30 | 30 | */ |
| 31 | -class Indexer |
|
| 32 | -{ |
|
| 31 | +class Indexer { |
|
| 33 | 32 | /** |
| 34 | 33 | * The extension key |
| 35 | 34 | * |
@@ -90,8 +89,7 @@ discard block |
||
| 90 | 89 | * |
| 91 | 90 | * @return bool true on success or false on failure |
| 92 | 91 | */ |
| 93 | - public static function add(Document &$doc, $core = 0) |
|
| 94 | - { |
|
| 92 | + public static function add(Document &$doc, $core = 0) { |
|
| 95 | 93 | if (in_array($doc->uid, self::$processedDocs)) { |
| 96 | 94 | return true; |
| 97 | 95 | } elseif (self::solrConnect($core, $doc->pid)) { |
@@ -211,8 +209,7 @@ discard block |
||
| 211 | 209 | * |
| 212 | 210 | * @return string The field's dynamic index name |
| 213 | 211 | */ |
| 214 | - public static function getIndexFieldName($index_name, $pid = 0) |
|
| 215 | - { |
|
| 212 | + public static function getIndexFieldName($index_name, $pid = 0) { |
|
| 216 | 213 | // Sanitize input. |
| 217 | 214 | $pid = max(intval($pid), 0); |
| 218 | 215 | if (!$pid) { |
@@ -238,8 +235,7 @@ discard block |
||
| 238 | 235 | * |
| 239 | 236 | * @return void |
| 240 | 237 | */ |
| 241 | - protected static function loadIndexConf($pid) |
|
| 242 | - { |
|
| 238 | + protected static function loadIndexConf($pid) { |
|
| 243 | 239 | if (!self::$fieldsLoaded) { |
| 244 | 240 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 245 | 241 | ->getQueryBuilderForTable('tx_dlf_metadata'); |
@@ -309,8 +305,7 @@ discard block |
||
| 309 | 305 | * |
| 310 | 306 | * @return bool true on success or false on failure |
| 311 | 307 | */ |
| 312 | - protected static function processLogical(Document &$doc, array $logicalUnit) |
|
| 313 | - { |
|
| 308 | + protected static function processLogical(Document &$doc, array $logicalUnit) { |
|
| 314 | 309 | $success = true; |
| 315 | 310 | // Get metadata for logical unit. |
| 316 | 311 | $metadata = $doc->metadataArray[$logicalUnit['id']]; |
@@ -439,8 +434,7 @@ discard block |
||
| 439 | 434 | * |
| 440 | 435 | * @return bool true on success or false on failure |
| 441 | 436 | */ |
| 442 | - protected static function processPhysical(Document &$doc, $page, array $physicalUnit) |
|
| 443 | - { |
|
| 437 | + protected static function processPhysical(Document &$doc, $page, array $physicalUnit) { |
|
| 444 | 438 | if ($doc->hasFulltext && $fullText = $doc->getFullText($physicalUnit['id'])) { |
| 445 | 439 | // Read extension configuration. |
| 446 | 440 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -524,8 +518,7 @@ discard block |
||
| 524 | 518 | * |
| 525 | 519 | * @return bool true on success or false on failure |
| 526 | 520 | */ |
| 527 | - protected static function solrConnect($core, $pid = 0) |
|
| 528 | - { |
|
| 521 | + protected static function solrConnect($core, $pid = 0) { |
|
| 529 | 522 | // Get Solr instance. |
| 530 | 523 | if (!self::$solr) { |
| 531 | 524 | // Connect to Solr server. |
@@ -548,8 +541,7 @@ discard block |
||
| 548 | 541 | * |
| 549 | 542 | * @access private |
| 550 | 543 | */ |
| 551 | - private function __construct() |
|
| 552 | - { |
|
| 544 | + private function __construct() { |
|
| 553 | 545 | // This is a static class, thus no instances should be created. |
| 554 | 546 | } |
| 555 | 547 | } |
@@ -48,8 +48,7 @@ discard block |
||
| 48 | 48 | * @property-read mixed $uid This holds the UID or the URL of the document |
| 49 | 49 | * @abstract |
| 50 | 50 | */ |
| 51 | -abstract class Document |
|
| 52 | -{ |
|
| 51 | +abstract class Document { |
|
| 53 | 52 | /** |
| 54 | 53 | * This holds the logger |
| 55 | 54 | * |
@@ -341,8 +340,7 @@ discard block |
||
| 341 | 340 | * |
| 342 | 341 | * @return void |
| 343 | 342 | */ |
| 344 | - public static function clearRegistry() |
|
| 345 | - { |
|
| 343 | + public static function clearRegistry() { |
|
| 346 | 344 | // Reset registry array. |
| 347 | 345 | self::$registry = []; |
| 348 | 346 | } |
@@ -607,8 +605,7 @@ discard block |
||
| 607 | 605 | * |
| 608 | 606 | * @return int The physical page number |
| 609 | 607 | */ |
| 610 | - public function getPhysicalPage($logicalPage) |
|
| 611 | - { |
|
| 608 | + public function getPhysicalPage($logicalPage) { |
|
| 612 | 609 | if ( |
| 613 | 610 | !empty($this->lastSearchedPhysicalPage['logicalPage']) |
| 614 | 611 | && $this->lastSearchedPhysicalPage['logicalPage'] == $logicalPage |
@@ -653,8 +650,7 @@ discard block |
||
| 653 | 650 | * |
| 654 | 651 | * @return string The OCR full text |
| 655 | 652 | */ |
| 656 | - protected function getFullTextFromXml($id) |
|
| 657 | - { |
|
| 653 | + protected function getFullTextFromXml($id) { |
|
| 658 | 654 | $fullText = ''; |
| 659 | 655 | // Load available text formats, ... |
| 660 | 656 | $this->loadFormats(); |
@@ -716,8 +712,7 @@ discard block |
||
| 716 | 712 | * |
| 717 | 713 | * @return string The format of the OCR full text |
| 718 | 714 | */ |
| 719 | - private function getTextFormat($fileContent) |
|
| 720 | - { |
|
| 715 | + private function getTextFormat($fileContent) { |
|
| 721 | 716 | // Get the root element's name as text format. |
| 722 | 717 | return strtoupper(Helper::getXmlFileAsString($fileContent)->getName()); |
| 723 | 718 | } |
@@ -734,8 +729,7 @@ discard block |
||
| 734 | 729 | * |
| 735 | 730 | * @return string The title of the document itself or a parent document |
| 736 | 731 | */ |
| 737 | - public static function getTitle($uid, $recursive = false) |
|
| 738 | - { |
|
| 732 | + public static function getTitle($uid, $recursive = false) { |
|
| 739 | 733 | $title = ''; |
| 740 | 734 | // Sanitize input. |
| 741 | 735 | $uid = max(intval($uid), 0); |
@@ -787,8 +781,7 @@ discard block |
||
| 787 | 781 | * |
| 788 | 782 | * @return array The logical structure node's / resource's parsed metadata array |
| 789 | 783 | */ |
| 790 | - public function getTitledata($cPid = 0) |
|
| 791 | - { |
|
| 784 | + public function getTitledata($cPid = 0) { |
|
| 792 | 785 | $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); |
| 793 | 786 | // Add information from METS structural map to titledata array. |
| 794 | 787 | if ($this instanceof MetsDocument) { |
@@ -821,8 +814,7 @@ discard block |
||
| 821 | 814 | * @return int|bool: false if structure with $logId is not a child of this substructure, |
| 822 | 815 | * or the actual depth. |
| 823 | 816 | */ |
| 824 | - protected function getTreeDepth($structure, $depth, $logId) |
|
| 825 | - { |
|
| 817 | + protected function getTreeDepth($structure, $depth, $logId) { |
|
| 826 | 818 | foreach ($structure as $element) { |
| 827 | 819 | if ($element['id'] == $logId) { |
| 828 | 820 | return $depth; |
@@ -844,8 +836,7 @@ discard block |
||
| 844 | 836 | * @param string $logId: The id of the logical structure element whose depth is requested |
| 845 | 837 | * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. |
| 846 | 838 | */ |
| 847 | - public function getStructureDepth($logId) |
|
| 848 | - { |
|
| 839 | + public function getStructureDepth($logId) { |
|
| 849 | 840 | return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId); |
| 850 | 841 | } |
| 851 | 842 | |
@@ -895,8 +886,7 @@ discard block |
||
| 895 | 886 | * |
| 896 | 887 | * @return bool true on success or false on failure |
| 897 | 888 | */ |
| 898 | - protected function load($location) |
|
| 899 | - { |
|
| 889 | + protected function load($location) { |
|
| 900 | 890 | // Load XML / JSON-LD file. |
| 901 | 891 | if (GeneralUtility::isValidUrl($location)) { |
| 902 | 892 | // Load extension configuration |
@@ -929,8 +919,7 @@ discard block |
||
| 929 | 919 | * |
| 930 | 920 | * @return void |
| 931 | 921 | */ |
| 932 | - protected function loadFormats() |
|
| 933 | - { |
|
| 922 | + protected function loadFormats() { |
|
| 934 | 923 | if (!$this->formatsLoaded) { |
| 935 | 924 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 936 | 925 | ->getQueryBuilderForTable('tx_dlf_formats'); |
@@ -970,8 +959,7 @@ discard block |
||
| 970 | 959 | * |
| 971 | 960 | * @return void |
| 972 | 961 | */ |
| 973 | - public function registerNamespaces(&$obj) |
|
| 974 | - { |
|
| 962 | + public function registerNamespaces(&$obj) { |
|
| 975 | 963 | // TODO Check usage. XML specific method does not seem to be used anywhere outside this class within the project, but it is public and may be used by extensions. |
| 976 | 964 | $this->loadFormats(); |
| 977 | 965 | // Do we have a \SimpleXMLElement or \DOMXPath object? |
@@ -1000,8 +988,7 @@ discard block |
||
| 1000 | 988 | * |
| 1001 | 989 | * @return bool true on success or false on failure |
| 1002 | 990 | */ |
| 1003 | - public function save($pid = 0, $core = 0, $owner = null) |
|
| 1004 | - { |
|
| 991 | + public function save($pid = 0, $core = 0, $owner = null) { |
|
| 1005 | 992 | if (\TYPO3_MODE !== 'BE') { |
| 1006 | 993 | $this->logger->error('Saving a document is only allowed in the backend'); |
| 1007 | 994 | return false; |
@@ -1329,8 +1316,7 @@ discard block |
||
| 1329 | 1316 | * |
| 1330 | 1317 | * @return int The PID of the metadata definitions |
| 1331 | 1318 | */ |
| 1332 | - protected function _getCPid() |
|
| 1333 | - { |
|
| 1319 | + protected function _getCPid() { |
|
| 1334 | 1320 | return $this->cPid; |
| 1335 | 1321 | } |
| 1336 | 1322 | |
@@ -1341,8 +1327,7 @@ discard block |
||
| 1341 | 1327 | * |
| 1342 | 1328 | * @return bool Are there any fulltext files available? |
| 1343 | 1329 | */ |
| 1344 | - protected function _getHasFulltext() |
|
| 1345 | - { |
|
| 1330 | + protected function _getHasFulltext() { |
|
| 1346 | 1331 | $this->ensureHasFulltextIsSet(); |
| 1347 | 1332 | return $this->hasFulltext; |
| 1348 | 1333 | } |
@@ -1354,8 +1339,7 @@ discard block |
||
| 1354 | 1339 | * |
| 1355 | 1340 | * @return string The location of the document |
| 1356 | 1341 | */ |
| 1357 | - protected function _getLocation() |
|
| 1358 | - { |
|
| 1342 | + protected function _getLocation() { |
|
| 1359 | 1343 | return $this->location; |
| 1360 | 1344 | } |
| 1361 | 1345 | |
@@ -1377,8 +1361,7 @@ discard block |
||
| 1377 | 1361 | * |
| 1378 | 1362 | * @return array Array of metadata with their corresponding logical structure node ID as key |
| 1379 | 1363 | */ |
| 1380 | - protected function _getMetadataArray() |
|
| 1381 | - { |
|
| 1364 | + protected function _getMetadataArray() { |
|
| 1382 | 1365 | // Set metadata definitions' PID. |
| 1383 | 1366 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
| 1384 | 1367 | if (!$cPid) { |
@@ -1403,8 +1386,7 @@ discard block |
||
| 1403 | 1386 | * |
| 1404 | 1387 | * @return int The total number of pages and/or tracks |
| 1405 | 1388 | */ |
| 1406 | - protected function _getNumPages() |
|
| 1407 | - { |
|
| 1389 | + protected function _getNumPages() { |
|
| 1408 | 1390 | $this->_getPhysicalStructure(); |
| 1409 | 1391 | return $this->numPages; |
| 1410 | 1392 | } |
@@ -1416,8 +1398,7 @@ discard block |
||
| 1416 | 1398 | * |
| 1417 | 1399 | * @return int The UID of the parent document or zero if not applicable |
| 1418 | 1400 | */ |
| 1419 | - protected function _getParentId() |
|
| 1420 | - { |
|
| 1401 | + protected function _getParentId() { |
|
| 1421 | 1402 | return $this->parentId; |
| 1422 | 1403 | } |
| 1423 | 1404 | |
@@ -1440,8 +1421,7 @@ discard block |
||
| 1440 | 1421 | * |
| 1441 | 1422 | * @return array Array of elements' type, label and file representations ordered by @ID attribute / Canvas order |
| 1442 | 1423 | */ |
| 1443 | - protected function _getPhysicalStructureInfo() |
|
| 1444 | - { |
|
| 1424 | + protected function _getPhysicalStructureInfo() { |
|
| 1445 | 1425 | // Is there no physical structure array yet? |
| 1446 | 1426 | if (!$this->physicalStructureLoaded) { |
| 1447 | 1427 | // Build physical structure array. |
@@ -1457,8 +1437,7 @@ discard block |
||
| 1457 | 1437 | * |
| 1458 | 1438 | * @return int The PID of the document or zero if not in database |
| 1459 | 1439 | */ |
| 1460 | - protected function _getPid() |
|
| 1461 | - { |
|
| 1440 | + protected function _getPid() { |
|
| 1462 | 1441 | return $this->pid; |
| 1463 | 1442 | } |
| 1464 | 1443 | |
@@ -1469,8 +1448,7 @@ discard block |
||
| 1469 | 1448 | * |
| 1470 | 1449 | * @return bool Is the document instantiated successfully? |
| 1471 | 1450 | */ |
| 1472 | - protected function _getReady() |
|
| 1473 | - { |
|
| 1451 | + protected function _getReady() { |
|
| 1474 | 1452 | return $this->ready; |
| 1475 | 1453 | } |
| 1476 | 1454 | |
@@ -1481,8 +1459,7 @@ discard block |
||
| 1481 | 1459 | * |
| 1482 | 1460 | * @return mixed The METS file's / IIIF manifest's record identifier |
| 1483 | 1461 | */ |
| 1484 | - protected function _getRecordId() |
|
| 1485 | - { |
|
| 1462 | + protected function _getRecordId() { |
|
| 1486 | 1463 | return $this->recordId; |
| 1487 | 1464 | } |
| 1488 | 1465 | |
@@ -1493,8 +1470,7 @@ discard block |
||
| 1493 | 1470 | * |
| 1494 | 1471 | * @return int The UID of the root document or zero if not applicable |
| 1495 | 1472 | */ |
| 1496 | - protected function _getRootId() |
|
| 1497 | - { |
|
| 1473 | + protected function _getRootId() { |
|
| 1498 | 1474 | if (!$this->rootIdLoaded) { |
| 1499 | 1475 | if ($this->parentId) { |
| 1500 | 1476 | $parent = self::getInstance($this->parentId, $this->pid); |
@@ -1524,8 +1500,7 @@ discard block |
||
| 1524 | 1500 | * |
| 1525 | 1501 | * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved |
| 1526 | 1502 | */ |
| 1527 | - protected function _getTableOfContents() |
|
| 1528 | - { |
|
| 1503 | + protected function _getTableOfContents() { |
|
| 1529 | 1504 | // Is there no logical structure array yet? |
| 1530 | 1505 | if (!$this->tableOfContentsLoaded) { |
| 1531 | 1506 | // Get all logical structures. |
@@ -1566,8 +1541,7 @@ discard block |
||
| 1566 | 1541 | * |
| 1567 | 1542 | * @return mixed The UID or the URL of the document |
| 1568 | 1543 | */ |
| 1569 | - protected function _getUid() |
|
| 1570 | - { |
|
| 1544 | + protected function _getUid() { |
|
| 1571 | 1545 | return $this->uid; |
| 1572 | 1546 | } |
| 1573 | 1547 | |
@@ -1580,8 +1554,7 @@ discard block |
||
| 1580 | 1554 | * |
| 1581 | 1555 | * @return void |
| 1582 | 1556 | */ |
| 1583 | - protected function _setCPid($value) |
|
| 1584 | - { |
|
| 1557 | + protected function _setCPid($value) { |
|
| 1585 | 1558 | $this->cPid = max(intval($value), 0); |
| 1586 | 1559 | } |
| 1587 | 1560 | |
@@ -1592,8 +1565,7 @@ discard block |
||
| 1592 | 1565 | * |
| 1593 | 1566 | * @return void |
| 1594 | 1567 | */ |
| 1595 | - protected function __clone() |
|
| 1596 | - { |
|
| 1568 | + protected function __clone() { |
|
| 1597 | 1569 | // This method is defined as protected because singleton objects should not be cloned. |
| 1598 | 1570 | } |
| 1599 | 1571 | |
@@ -1610,8 +1582,7 @@ discard block |
||
| 1610 | 1582 | * |
| 1611 | 1583 | * @return void |
| 1612 | 1584 | */ |
| 1613 | - protected function __construct($uid, $pid, $preloadedDocument) |
|
| 1614 | - { |
|
| 1585 | + protected function __construct($uid, $pid, $preloadedDocument) { |
|
| 1615 | 1586 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 1616 | 1587 | ->getQueryBuilderForTable('tx_dlf_documents'); |
| 1617 | 1588 | $location = ''; |
@@ -1723,8 +1694,7 @@ discard block |
||
| 1723 | 1694 | * |
| 1724 | 1695 | * @return mixed Value of $this->$var |
| 1725 | 1696 | */ |
| 1726 | - public function __get($var) |
|
| 1727 | - { |
|
| 1697 | + public function __get($var) { |
|
| 1728 | 1698 | $method = '_get' . ucfirst($var); |
| 1729 | 1699 | if ( |
| 1730 | 1700 | !property_exists($this, $var) |
@@ -1746,8 +1716,7 @@ discard block |
||
| 1746 | 1716 | * |
| 1747 | 1717 | * @return bool true if variable is set and not empty, false otherwise |
| 1748 | 1718 | */ |
| 1749 | - public function __isset($var) |
|
| 1750 | - { |
|
| 1719 | + public function __isset($var) { |
|
| 1751 | 1720 | return !empty($this->__get($var)); |
| 1752 | 1721 | } |
| 1753 | 1722 | |
@@ -1761,8 +1730,7 @@ discard block |
||
| 1761 | 1730 | * |
| 1762 | 1731 | * @return void |
| 1763 | 1732 | */ |
| 1764 | - public function __set($var, $value) |
|
| 1765 | - { |
|
| 1733 | + public function __set($var, $value) { |
|
| 1766 | 1734 | $method = '_set' . ucfirst($var); |
| 1767 | 1735 | if ( |
| 1768 | 1736 | !property_exists($this, $var) |
@@ -25,8 +25,7 @@ discard block |
||
| 25 | 25 | * @subpackage dlf |
| 26 | 26 | * @access public |
| 27 | 27 | */ |
| 28 | -class Helper |
|
| 29 | -{ |
|
| 28 | +class Helper { |
|
| 30 | 29 | /** |
| 31 | 30 | * The extension key |
| 32 | 31 | * |
@@ -74,8 +73,7 @@ discard block |
||
| 74 | 73 | * |
| 75 | 74 | * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue The queue the message was added to |
| 76 | 75 | */ |
| 77 | - public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') |
|
| 78 | - { |
|
| 76 | + public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') { |
|
| 79 | 77 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
| 80 | 78 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
| 81 | 79 | $flashMessage = GeneralUtility::makeInstance( |
@@ -100,8 +98,7 @@ discard block |
||
| 100 | 98 | * |
| 101 | 99 | * @return bool Is $id a valid GNL identifier of the given $type? |
| 102 | 100 | */ |
| 103 | - public static function checkIdentifier($id, $type) |
|
| 104 | - { |
|
| 101 | + public static function checkIdentifier($id, $type) { |
|
| 105 | 102 | $digits = substr($id, 0, 8); |
| 106 | 103 | $checksum = 0; |
| 107 | 104 | for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
@@ -165,8 +162,7 @@ discard block |
||
| 165 | 162 | * |
| 166 | 163 | * @return mixed The decrypted value or false on error |
| 167 | 164 | */ |
| 168 | - public static function decrypt($encrypted) |
|
| 169 | - { |
|
| 165 | + public static function decrypt($encrypted) { |
|
| 170 | 166 | if ( |
| 171 | 167 | !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
| 172 | 168 | || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
@@ -204,8 +200,7 @@ discard block |
||
| 204 | 200 | * |
| 205 | 201 | * @return mixed |
| 206 | 202 | */ |
| 207 | - public static function getXmlFileAsString($content) |
|
| 208 | - { |
|
| 203 | + public static function getXmlFileAsString($content) { |
|
| 209 | 204 | // Turn off libxml's error logging. |
| 210 | 205 | $libxmlErrors = libxml_use_internal_errors(true); |
| 211 | 206 | // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept |
@@ -230,8 +225,7 @@ discard block |
||
| 230 | 225 | * |
| 231 | 226 | * @return void |
| 232 | 227 | */ |
| 233 | - public static function log($message, $severity = 0) |
|
| 234 | - { |
|
| 228 | + public static function log($message, $severity = 0) { |
|
| 235 | 229 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(get_called_class()); |
| 236 | 230 | |
| 237 | 231 | switch ($severity) { |
@@ -261,8 +255,7 @@ discard block |
||
| 261 | 255 | * |
| 262 | 256 | * @return mixed Hashed string or false on error |
| 263 | 257 | */ |
| 264 | - public static function digest($string) |
|
| 265 | - { |
|
| 258 | + public static function digest($string) { |
|
| 266 | 259 | if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(true))) { |
| 267 | 260 | self::log('OpenSSL library doesn\'t support hash algorithm', LOG_SEVERITY_ERROR); |
| 268 | 261 | return false; |
@@ -281,8 +274,7 @@ discard block |
||
| 281 | 274 | * |
| 282 | 275 | * @return mixed Encrypted string or false on error |
| 283 | 276 | */ |
| 284 | - public static function encrypt($string) |
|
| 285 | - { |
|
| 277 | + public static function encrypt($string) { |
|
| 286 | 278 | if ( |
| 287 | 279 | !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
| 288 | 280 | || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
@@ -315,8 +307,7 @@ discard block |
||
| 315 | 307 | * |
| 316 | 308 | * @return string The unqualified class name |
| 317 | 309 | */ |
| 318 | - public static function getUnqualifiedClassName($qualifiedClassname) |
|
| 319 | - { |
|
| 310 | + public static function getUnqualifiedClassName($qualifiedClassname) { |
|
| 320 | 311 | $nameParts = explode('\\', $qualifiedClassname); |
| 321 | 312 | return end($nameParts); |
| 322 | 313 | } |
@@ -330,8 +321,7 @@ discard block |
||
| 330 | 321 | * |
| 331 | 322 | * @return string The cleaned up string |
| 332 | 323 | */ |
| 333 | - public static function getCleanString($string) |
|
| 334 | - { |
|
| 324 | + public static function getCleanString($string) { |
|
| 335 | 325 | // Convert to lowercase. |
| 336 | 326 | $string = strtolower($string); |
| 337 | 327 | // Remove non-alphanumeric characters. |
@@ -352,8 +342,7 @@ discard block |
||
| 352 | 342 | * |
| 353 | 343 | * @return array Array of hook objects for the class |
| 354 | 344 | */ |
| 355 | - public static function getHookObjects($scriptRelPath) |
|
| 356 | - { |
|
| 345 | + public static function getHookObjects($scriptRelPath) { |
|
| 357 | 346 | $hookObjects = []; |
| 358 | 347 | if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) { |
| 359 | 348 | foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) { |
@@ -374,8 +363,7 @@ discard block |
||
| 374 | 363 | * |
| 375 | 364 | * @return string "index_name" for the given UID |
| 376 | 365 | */ |
| 377 | - public static function getIndexNameFromUid($uid, $table, $pid = -1) |
|
| 378 | - { |
|
| 366 | + public static function getIndexNameFromUid($uid, $table, $pid = -1) { |
|
| 379 | 367 | // Sanitize input. |
| 380 | 368 | $uid = max(intval($uid), 0); |
| 381 | 369 | if ( |
@@ -427,8 +415,7 @@ discard block |
||
| 427 | 415 | * |
| 428 | 416 | * @return string "label" for the given UID |
| 429 | 417 | */ |
| 430 | - public static function getLabelFromUid($uid, $table, $pid = -1) |
|
| 431 | - { |
|
| 418 | + public static function getLabelFromUid($uid, $table, $pid = -1) { |
|
| 432 | 419 | // Sanitize input. |
| 433 | 420 | $uid = max(intval($uid), 0); |
| 434 | 421 | if ( |
@@ -478,8 +465,7 @@ discard block |
||
| 478 | 465 | * |
| 479 | 466 | * @return string Localized full name of language or unchanged input |
| 480 | 467 | */ |
| 481 | - public static function getLanguageName($code) |
|
| 482 | - { |
|
| 468 | + public static function getLanguageName($code) { |
|
| 483 | 469 | // Analyze code and set appropriate ISO table. |
| 484 | 470 | $isoCode = strtolower(trim($code)); |
| 485 | 471 | if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
@@ -524,8 +510,7 @@ discard block |
||
| 524 | 510 | * |
| 525 | 511 | * @return string The translated string or the given key on failure |
| 526 | 512 | */ |
| 527 | - public static function getMessage($key, $hsc = false, $default = '') |
|
| 528 | - { |
|
| 513 | + public static function getMessage($key, $hsc = false, $default = '') { |
|
| 529 | 514 | // Set initial output to default value. |
| 530 | 515 | $translated = (string) $default; |
| 531 | 516 | // Load common messages file. |
@@ -567,8 +552,7 @@ discard block |
||
| 567 | 552 | * |
| 568 | 553 | * @return string "uid" for the given index_name |
| 569 | 554 | */ |
| 570 | - public static function getUidFromIndexName($index_name, $table, $pid = -1) |
|
| 571 | - { |
|
| 555 | + public static function getUidFromIndexName($index_name, $table, $pid = -1) { |
|
| 572 | 556 | if ( |
| 573 | 557 | !$index_name |
| 574 | 558 | || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores']) |
@@ -619,8 +603,7 @@ discard block |
||
| 619 | 603 | * |
| 620 | 604 | * @return string Uniform Resource Name as string |
| 621 | 605 | */ |
| 622 | - public static function getURN($base, $id) |
|
| 623 | - { |
|
| 606 | + public static function getURN($base, $id) { |
|
| 624 | 607 | $concordance = [ |
| 625 | 608 | '0' => 1, |
| 626 | 609 | '1' => 2, |
@@ -687,8 +670,7 @@ discard block |
||
| 687 | 670 | * |
| 688 | 671 | * @return bool Is $id a valid PPN? |
| 689 | 672 | */ |
| 690 | - public static function isPPN($id) |
|
| 691 | - { |
|
| 673 | + public static function isPPN($id) { |
|
| 692 | 674 | return self::checkIdentifier($id, 'PPN'); |
| 693 | 675 | } |
| 694 | 676 | |
@@ -701,8 +683,7 @@ discard block |
||
| 701 | 683 | * |
| 702 | 684 | * @return mixed Session value for given key or null on failure |
| 703 | 685 | */ |
| 704 | - public static function loadFromSession($key) |
|
| 705 | - { |
|
| 686 | + public static function loadFromSession($key) { |
|
| 706 | 687 | // Cast to string for security reasons. |
| 707 | 688 | $key = (string) $key; |
| 708 | 689 | if (!$key) { |
@@ -734,8 +715,7 @@ discard block |
||
| 734 | 715 | * |
| 735 | 716 | * @return array Merged array |
| 736 | 717 | */ |
| 737 | - public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) |
|
| 738 | - { |
|
| 718 | + public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) { |
|
| 739 | 719 | \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature); |
| 740 | 720 | return $original; |
| 741 | 721 | } |
@@ -752,8 +732,7 @@ discard block |
||
| 752 | 732 | * |
| 753 | 733 | * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
| 754 | 734 | */ |
| 755 | - public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false) |
|
| 756 | - { |
|
| 735 | + public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false) { |
|
| 757 | 736 | if ( |
| 758 | 737 | \TYPO3_MODE === 'BE' |
| 759 | 738 | && $GLOBALS['BE_USER']->isAdmin() |
@@ -799,8 +778,7 @@ discard block |
||
| 799 | 778 | * |
| 800 | 779 | * @return string All flash messages in the queue rendered as HTML. |
| 801 | 780 | */ |
| 802 | - public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') |
|
| 803 | - { |
|
| 781 | + public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') { |
|
| 804 | 782 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
| 805 | 783 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
| 806 | 784 | $flashMessages = $flashMessageQueue->getAllMessagesAndFlush(); |
@@ -819,8 +797,7 @@ discard block |
||
| 819 | 797 | * |
| 820 | 798 | * @return bool true on success, false on failure |
| 821 | 799 | */ |
| 822 | - public static function saveToSession($value, $key) |
|
| 823 | - { |
|
| 800 | + public static function saveToSession($value, $key) { |
|
| 824 | 801 | // Cast to string for security reasons. |
| 825 | 802 | $key = (string) $key; |
| 826 | 803 | if (!$key) { |
@@ -852,8 +829,7 @@ discard block |
||
| 852 | 829 | * |
| 853 | 830 | * @return string Localized label for $index_name |
| 854 | 831 | */ |
| 855 | - public static function translate($index_name, $table, $pid) |
|
| 856 | - { |
|
| 832 | + public static function translate($index_name, $table, $pid) { |
|
| 857 | 833 | // Load labels into static variable for future use. |
| 858 | 834 | static $labels = []; |
| 859 | 835 | // Sanitize input. |
@@ -976,8 +952,7 @@ discard block |
||
| 976 | 952 | * |
| 977 | 953 | * @return string Additional WHERE expression |
| 978 | 954 | */ |
| 979 | - public static function whereExpression($table, $showHidden = false) |
|
| 980 | - { |
|
| 955 | + public static function whereExpression($table, $showHidden = false) { |
|
| 981 | 956 | if (\TYPO3_MODE === 'FE') { |
| 982 | 957 | // Should we ignore the record's hidden flag? |
| 983 | 958 | $ignoreHide = 0; |
@@ -1006,8 +981,7 @@ discard block |
||
| 1006 | 981 | * |
| 1007 | 982 | * @access private |
| 1008 | 983 | */ |
| 1009 | - private function __construct() |
|
| 1010 | - { |
|
| 984 | + private function __construct() { |
|
| 1011 | 985 | // This is a static class, thus no instances should be created. |
| 1012 | 986 | } |
| 1013 | 987 | } |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | * @property-read bool $ready Is the Solr service instantiated successfully? |
| 38 | 38 | * @property-read \Solarium\Client $service This holds the Solr service object |
| 39 | 39 | */ |
| 40 | -class Solr implements LoggerAwareInterface |
|
| 41 | -{ |
|
| 40 | +class Solr implements LoggerAwareInterface { |
|
| 42 | 41 | use LoggerAwareTrait; |
| 43 | 42 | |
| 44 | 43 | /** |
@@ -130,8 +129,7 @@ discard block |
||
| 130 | 129 | * |
| 131 | 130 | * @return string The name of the new core |
| 132 | 131 | */ |
| 133 | - public static function createCore($core = '') |
|
| 134 | - { |
|
| 132 | + public static function createCore($core = '') { |
|
| 135 | 133 | // Get next available core name if none given. |
| 136 | 134 | if (empty($core)) { |
| 137 | 135 | $core = 'dlfCore' . self::getNextCoreNumber(); |
@@ -178,8 +176,7 @@ discard block |
||
| 178 | 176 | * |
| 179 | 177 | * @return string The escaped query string |
| 180 | 178 | */ |
| 181 | - public static function escapeQuery($query) |
|
| 182 | - { |
|
| 179 | + public static function escapeQuery($query) { |
|
| 183 | 180 | $helper = GeneralUtility::makeInstance(\Solarium\Core\Query\Helper::class); |
| 184 | 181 | // Escape query phrase or term. |
| 185 | 182 | if (preg_match('/^".*"$/', $query)) { |
@@ -202,8 +199,7 @@ discard block |
||
| 202 | 199 | * |
| 203 | 200 | * @return string The escaped query string |
| 204 | 201 | */ |
| 205 | - public static function escapeQueryKeepField($query, $pid) |
|
| 206 | - { |
|
| 202 | + public static function escapeQueryKeepField($query, $pid) { |
|
| 207 | 203 | // Is there a field query? |
| 208 | 204 | if (preg_match('/^[[:alnum:]]+_[tu][su]i:\(?.*\)?$/', $query)) { |
| 209 | 205 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
@@ -253,8 +249,7 @@ discard block |
||
| 253 | 249 | * |
| 254 | 250 | * @return array fields |
| 255 | 251 | */ |
| 256 | - public static function getFields() |
|
| 257 | - { |
|
| 252 | + public static function getFields() { |
|
| 258 | 253 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 259 | 254 | |
| 260 | 255 | $fields = []; |
@@ -296,8 +291,7 @@ discard block |
||
| 296 | 291 | * |
| 297 | 292 | * @return \Kitodo\Dlf\Common\Solr Instance of this class |
| 298 | 293 | */ |
| 299 | - public static function getInstance($core = null) |
|
| 300 | - { |
|
| 294 | + public static function getInstance($core = null) { |
|
| 301 | 295 | // Get core name if UID is given. |
| 302 | 296 | if (MathUtility::canBeInterpretedAsInteger($core)) { |
| 303 | 297 | $core = Helper::getIndexNameFromUid($core, 'tx_dlf_solrcores'); |
@@ -337,8 +331,7 @@ discard block |
||
| 337 | 331 | * |
| 338 | 332 | * @return int First unused core number found |
| 339 | 333 | */ |
| 340 | - public static function getNextCoreNumber($number = 0) |
|
| 341 | - { |
|
| 334 | + public static function getNextCoreNumber($number = 0) { |
|
| 342 | 335 | $number = max(intval($number), 0); |
| 343 | 336 | // Check if core already exists. |
| 344 | 337 | $solr = self::getInstance('dlfCore' . $number); |
@@ -356,8 +349,7 @@ discard block |
||
| 356 | 349 | * |
| 357 | 350 | * @return void |
| 358 | 351 | */ |
| 359 | - protected function loadSolrConnectionInfo() |
|
| 360 | - { |
|
| 352 | + protected function loadSolrConnectionInfo() { |
|
| 361 | 353 | if (empty($this->config)) { |
| 362 | 354 | $config = []; |
| 363 | 355 | // Extract extension configuration. |
@@ -395,8 +387,7 @@ discard block |
||
| 395 | 387 | * |
| 396 | 388 | * @return \Kitodo\Dlf\Common\DocumentList The result list |
| 397 | 389 | */ |
| 398 | - public function search() |
|
| 399 | - { |
|
| 390 | + public function search() { |
|
| 400 | 391 | $toplevel = []; |
| 401 | 392 | // Take over query parameters. |
| 402 | 393 | $params = $this->params; |
@@ -465,8 +456,7 @@ discard block |
||
| 465 | 456 | * |
| 466 | 457 | * @return array The Apache Solr Documents that were fetched |
| 467 | 458 | */ |
| 468 | - public function search_raw($query = '', $parameters = []) |
|
| 469 | - { |
|
| 459 | + public function search_raw($query = '', $parameters = []) { |
|
| 470 | 460 | // Set additional query parameters. |
| 471 | 461 | $parameters['start'] = 0; |
| 472 | 462 | $parameters['rows'] = $this->limit; |
@@ -498,8 +488,7 @@ discard block |
||
| 498 | 488 | * |
| 499 | 489 | * @return string|null The core name of the current query endpoint or null if core admin endpoint |
| 500 | 490 | */ |
| 501 | - protected function _getCore() |
|
| 502 | - { |
|
| 491 | + protected function _getCore() { |
|
| 503 | 492 | return $this->core; |
| 504 | 493 | } |
| 505 | 494 | |
@@ -510,8 +499,7 @@ discard block |
||
| 510 | 499 | * |
| 511 | 500 | * @return int The max number of results |
| 512 | 501 | */ |
| 513 | - protected function _getLimit() |
|
| 514 | - { |
|
| 502 | + protected function _getLimit() { |
|
| 515 | 503 | return $this->limit; |
| 516 | 504 | } |
| 517 | 505 | |
@@ -522,8 +510,7 @@ discard block |
||
| 522 | 510 | * |
| 523 | 511 | * @return int Total number of hits for last search |
| 524 | 512 | */ |
| 525 | - protected function _getNumberOfHits() |
|
| 526 | - { |
|
| 513 | + protected function _getNumberOfHits() { |
|
| 527 | 514 | return $this->numberOfHits; |
| 528 | 515 | } |
| 529 | 516 | |
@@ -534,8 +521,7 @@ discard block |
||
| 534 | 521 | * |
| 535 | 522 | * @return bool Is the search instantiated successfully? |
| 536 | 523 | */ |
| 537 | - protected function _getReady() |
|
| 538 | - { |
|
| 524 | + protected function _getReady() { |
|
| 539 | 525 | return $this->ready; |
| 540 | 526 | } |
| 541 | 527 | |
@@ -546,8 +532,7 @@ discard block |
||
| 546 | 532 | * |
| 547 | 533 | * @return \Solarium\Client Apache Solr service object |
| 548 | 534 | */ |
| 549 | - protected function _getService() |
|
| 550 | - { |
|
| 535 | + protected function _getService() { |
|
| 551 | 536 | return $this->service; |
| 552 | 537 | } |
| 553 | 538 | |
@@ -560,8 +545,7 @@ discard block |
||
| 560 | 545 | * |
| 561 | 546 | * @return void |
| 562 | 547 | */ |
| 563 | - protected function _setCPid($value) |
|
| 564 | - { |
|
| 548 | + protected function _setCPid($value) { |
|
| 565 | 549 | $this->cPid = max(intval($value), 0); |
| 566 | 550 | } |
| 567 | 551 | |
@@ -574,8 +558,7 @@ discard block |
||
| 574 | 558 | * |
| 575 | 559 | * @return void |
| 576 | 560 | */ |
| 577 | - protected function _setLimit($value) |
|
| 578 | - { |
|
| 561 | + protected function _setLimit($value) { |
|
| 579 | 562 | $this->limit = max(intval($value), 0); |
| 580 | 563 | } |
| 581 | 564 | |
@@ -588,8 +571,7 @@ discard block |
||
| 588 | 571 | * |
| 589 | 572 | * @return void |
| 590 | 573 | */ |
| 591 | - protected function _setParams(array $value) |
|
| 592 | - { |
|
| 574 | + protected function _setParams(array $value) { |
|
| 593 | 575 | $this->params = $value; |
| 594 | 576 | } |
| 595 | 577 | |
@@ -602,8 +584,7 @@ discard block |
||
| 602 | 584 | * |
| 603 | 585 | * @return mixed Value of $this->$var |
| 604 | 586 | */ |
| 605 | - public function __get($var) |
|
| 606 | - { |
|
| 587 | + public function __get($var) { |
|
| 607 | 588 | $method = '_get' . ucfirst($var); |
| 608 | 589 | if ( |
| 609 | 590 | !property_exists($this, $var) |
@@ -625,8 +606,7 @@ discard block |
||
| 625 | 606 | * |
| 626 | 607 | * @return bool true if variable is set and not empty, false otherwise |
| 627 | 608 | */ |
| 628 | - public function __isset($var) |
|
| 629 | - { |
|
| 609 | + public function __isset($var) { |
|
| 630 | 610 | return !empty($this->__get($var)); |
| 631 | 611 | } |
| 632 | 612 | |
@@ -640,8 +620,7 @@ discard block |
||
| 640 | 620 | * |
| 641 | 621 | * @return void |
| 642 | 622 | */ |
| 643 | - public function __set($var, $value) |
|
| 644 | - { |
|
| 623 | + public function __set($var, $value) { |
|
| 645 | 624 | $method = '_set' . ucfirst($var); |
| 646 | 625 | if ( |
| 647 | 626 | !property_exists($this, $var) |
@@ -662,8 +641,7 @@ discard block |
||
| 662 | 641 | * |
| 663 | 642 | * @return void |
| 664 | 643 | */ |
| 665 | - protected function __construct($core) |
|
| 666 | - { |
|
| 644 | + protected function __construct($core) { |
|
| 667 | 645 | // Get Solr connection parameters from configuration. |
| 668 | 646 | $this->loadSolrConnectionInfo(); |
| 669 | 647 | // Configure connection adapter. |