@@ -34,15 +34,13 @@ discard block |
||
| 34 | 34 | * @subpackage dlf |
| 35 | 35 | * @access public |
| 36 | 36 | */ |
| 37 | -class HarvestCommand extends BaseCommand |
|
| 38 | -{ |
|
| 37 | +class HarvestCommand extends BaseCommand { |
|
| 39 | 38 | /** |
| 40 | 39 | * Configure the command by defining the name, options and arguments |
| 41 | 40 | * |
| 42 | 41 | * @return void |
| 43 | 42 | */ |
| 44 | - public function configure() |
|
| 45 | - { |
|
| 43 | + public function configure() { |
|
| 46 | 44 | $this |
| 47 | 45 | ->setDescription('Harvest OAI-PMH contents into database and Solr.') |
| 48 | 46 | ->setHelp('') |
@@ -98,8 +96,7 @@ discard block |
||
| 98 | 96 | * |
| 99 | 97 | * @return void |
| 100 | 98 | */ |
| 101 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
| 102 | - { |
|
| 99 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 103 | 100 | // Make sure the _cli_ user is loaded |
| 104 | 101 | Bootstrap::getInstance()->initializeBackendAuthentication(); |
| 105 | 102 | |
@@ -268,8 +265,7 @@ discard block |
||
| 268 | 265 | * |
| 269 | 266 | * @return void |
| 270 | 267 | */ |
| 271 | - protected function handleOaiError(BaseoaipmhException $exception, SymfonyStyle $io) |
|
| 272 | - { |
|
| 268 | + protected function handleOaiError(BaseoaipmhException $exception, SymfonyStyle $io) { |
|
| 273 | 269 | $io->error('ERROR: Trying to retrieve data from OAI interface resulted in error:' . "\n " . $exception->getMessage()); |
| 274 | 270 | } |
| 275 | 271 | } |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | * @property-read mixed $uid This holds the UID or the URL of the document |
| 48 | 48 | * @abstract |
| 49 | 49 | */ |
| 50 | -abstract class Document |
|
| 51 | -{ |
|
| 50 | +abstract class Document { |
|
| 52 | 51 | /** |
| 53 | 52 | * This holds the logger |
| 54 | 53 | * |
@@ -340,8 +339,7 @@ discard block |
||
| 340 | 339 | * |
| 341 | 340 | * @return void |
| 342 | 341 | */ |
| 343 | - public static function clearRegistry() |
|
| 344 | - { |
|
| 342 | + public static function clearRegistry() { |
|
| 345 | 343 | // Reset registry array. |
| 346 | 344 | self::$registry = []; |
| 347 | 345 | } |
@@ -616,8 +614,7 @@ discard block |
||
| 616 | 614 | * |
| 617 | 615 | * @return int The physical page number |
| 618 | 616 | */ |
| 619 | - public function getPhysicalPage($logicalPage) |
|
| 620 | - { |
|
| 617 | + public function getPhysicalPage($logicalPage) { |
|
| 621 | 618 | if ( |
| 622 | 619 | !empty($this->lastSearchedPhysicalPage['logicalPage']) |
| 623 | 620 | && $this->lastSearchedPhysicalPage['logicalPage'] == $logicalPage |
@@ -664,8 +661,7 @@ discard block |
||
| 664 | 661 | * |
| 665 | 662 | * @return string The physical structure node's / IIIF resource's raw text from XML |
| 666 | 663 | */ |
| 667 | - protected function getRawTextFromXml($id) |
|
| 668 | - { |
|
| 664 | + protected function getRawTextFromXml($id) { |
|
| 669 | 665 | $rawText = ''; |
| 670 | 666 | // Load available text formats, ... |
| 671 | 667 | $this->loadFormats(); |
@@ -739,8 +735,7 @@ discard block |
||
| 739 | 735 | * |
| 740 | 736 | * @return string The title of the document itself or a parent document |
| 741 | 737 | */ |
| 742 | - public static function getTitle($uid, $recursive = false) |
|
| 743 | - { |
|
| 738 | + public static function getTitle($uid, $recursive = false) { |
|
| 744 | 739 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
| 745 | 740 | |
| 746 | 741 | $title = ''; |
@@ -794,8 +789,7 @@ discard block |
||
| 794 | 789 | * |
| 795 | 790 | * @return array The logical structure node's / resource's parsed metadata array |
| 796 | 791 | */ |
| 797 | - public function getTitledata($cPid = 0) |
|
| 798 | - { |
|
| 792 | + public function getTitledata($cPid = 0) { |
|
| 799 | 793 | $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); |
| 800 | 794 | // Add information from METS structural map to titledata array. |
| 801 | 795 | if ($this instanceof MetsDocument) { |
@@ -828,8 +822,7 @@ discard block |
||
| 828 | 822 | * @return int|bool: false if structure with $logId is not a child of this substructure, |
| 829 | 823 | * or the actual depth. |
| 830 | 824 | */ |
| 831 | - protected function getTreeDepth($structure, $depth, $logId) |
|
| 832 | - { |
|
| 825 | + protected function getTreeDepth($structure, $depth, $logId) { |
|
| 833 | 826 | foreach ($structure as $element) { |
| 834 | 827 | if ($element['id'] == $logId) { |
| 835 | 828 | return $depth; |
@@ -851,8 +844,7 @@ discard block |
||
| 851 | 844 | * @param string $logId: The id of the logical structure element whose depth is requested |
| 852 | 845 | * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. |
| 853 | 846 | */ |
| 854 | - public function getStructureDepth($logId) |
|
| 855 | - { |
|
| 847 | + public function getStructureDepth($logId) { |
|
| 856 | 848 | return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId); |
| 857 | 849 | } |
| 858 | 850 | |
@@ -902,8 +894,7 @@ discard block |
||
| 902 | 894 | * |
| 903 | 895 | * @return bool true on success or false on failure |
| 904 | 896 | */ |
| 905 | - protected function load($location) |
|
| 906 | - { |
|
| 897 | + protected function load($location) { |
|
| 907 | 898 | // Load XML / JSON-LD file. |
| 908 | 899 | if (GeneralUtility::isValidUrl($location)) { |
| 909 | 900 | // Load extension configuration |
@@ -936,8 +927,7 @@ discard block |
||
| 936 | 927 | * |
| 937 | 928 | * @return void |
| 938 | 929 | */ |
| 939 | - protected function loadFormats() |
|
| 940 | - { |
|
| 930 | + protected function loadFormats() { |
|
| 941 | 931 | if (!$this->formatsLoaded) { |
| 942 | 932 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 943 | 933 | ->getQueryBuilderForTable('tx_dlf_formats'); |
@@ -977,8 +967,7 @@ discard block |
||
| 977 | 967 | * |
| 978 | 968 | * @return void |
| 979 | 969 | */ |
| 980 | - public function registerNamespaces(&$obj) |
|
| 981 | - { |
|
| 970 | + public function registerNamespaces(&$obj) { |
|
| 982 | 971 | // 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. |
| 983 | 972 | $this->loadFormats(); |
| 984 | 973 | // Do we have a \SimpleXMLElement or \DOMXPath object? |
@@ -1007,8 +996,7 @@ discard block |
||
| 1007 | 996 | * |
| 1008 | 997 | * @return bool true on success or false on failure |
| 1009 | 998 | */ |
| 1010 | - public function save($pid = 0, $core = 0, $owner = null) |
|
| 1011 | - { |
|
| 999 | + public function save($pid = 0, $core = 0, $owner = null) { |
|
| 1012 | 1000 | if (\TYPO3_MODE !== 'BE') { |
| 1013 | 1001 | $this->logger->error('Saving a document is only allowed in the backend'); |
| 1014 | 1002 | return false; |
@@ -1333,8 +1321,7 @@ discard block |
||
| 1333 | 1321 | * |
| 1334 | 1322 | * @return int The PID of the metadata definitions |
| 1335 | 1323 | */ |
| 1336 | - protected function _getCPid() |
|
| 1337 | - { |
|
| 1324 | + protected function _getCPid() { |
|
| 1338 | 1325 | return $this->cPid; |
| 1339 | 1326 | } |
| 1340 | 1327 | |
@@ -1345,8 +1332,7 @@ discard block |
||
| 1345 | 1332 | * |
| 1346 | 1333 | * @return bool Are there any fulltext files available? |
| 1347 | 1334 | */ |
| 1348 | - protected function _getHasFulltext() |
|
| 1349 | - { |
|
| 1335 | + protected function _getHasFulltext() { |
|
| 1350 | 1336 | $this->ensureHasFulltextIsSet(); |
| 1351 | 1337 | return $this->hasFulltext; |
| 1352 | 1338 | } |
@@ -1358,8 +1344,7 @@ discard block |
||
| 1358 | 1344 | * |
| 1359 | 1345 | * @return string The location of the document |
| 1360 | 1346 | */ |
| 1361 | - protected function _getLocation() |
|
| 1362 | - { |
|
| 1347 | + protected function _getLocation() { |
|
| 1363 | 1348 | return $this->location; |
| 1364 | 1349 | } |
| 1365 | 1350 | |
@@ -1381,8 +1366,7 @@ discard block |
||
| 1381 | 1366 | * |
| 1382 | 1367 | * @return array Array of metadata with their corresponding logical structure node ID as key |
| 1383 | 1368 | */ |
| 1384 | - protected function _getMetadataArray() |
|
| 1385 | - { |
|
| 1369 | + protected function _getMetadataArray() { |
|
| 1386 | 1370 | // Set metadata definitions' PID. |
| 1387 | 1371 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
| 1388 | 1372 | if (!$cPid) { |
@@ -1407,8 +1391,7 @@ discard block |
||
| 1407 | 1391 | * |
| 1408 | 1392 | * @return int The total number of pages and/or tracks |
| 1409 | 1393 | */ |
| 1410 | - protected function _getNumPages() |
|
| 1411 | - { |
|
| 1394 | + protected function _getNumPages() { |
|
| 1412 | 1395 | $this->_getPhysicalStructure(); |
| 1413 | 1396 | return $this->numPages; |
| 1414 | 1397 | } |
@@ -1420,8 +1403,7 @@ discard block |
||
| 1420 | 1403 | * |
| 1421 | 1404 | * @return int The UID of the parent document or zero if not applicable |
| 1422 | 1405 | */ |
| 1423 | - protected function _getParentId() |
|
| 1424 | - { |
|
| 1406 | + protected function _getParentId() { |
|
| 1425 | 1407 | return $this->parentId; |
| 1426 | 1408 | } |
| 1427 | 1409 | |
@@ -1444,8 +1426,7 @@ discard block |
||
| 1444 | 1426 | * |
| 1445 | 1427 | * @return array Array of elements' type, label and file representations ordered by @ID attribute / Canvas order |
| 1446 | 1428 | */ |
| 1447 | - protected function _getPhysicalStructureInfo() |
|
| 1448 | - { |
|
| 1429 | + protected function _getPhysicalStructureInfo() { |
|
| 1449 | 1430 | // Is there no physical structure array yet? |
| 1450 | 1431 | if (!$this->physicalStructureLoaded) { |
| 1451 | 1432 | // Build physical structure array. |
@@ -1461,8 +1442,7 @@ discard block |
||
| 1461 | 1442 | * |
| 1462 | 1443 | * @return int The PID of the document or zero if not in database |
| 1463 | 1444 | */ |
| 1464 | - protected function _getPid() |
|
| 1465 | - { |
|
| 1445 | + protected function _getPid() { |
|
| 1466 | 1446 | return $this->pid; |
| 1467 | 1447 | } |
| 1468 | 1448 | |
@@ -1473,8 +1453,7 @@ discard block |
||
| 1473 | 1453 | * |
| 1474 | 1454 | * @return bool Is the document instantiated successfully? |
| 1475 | 1455 | */ |
| 1476 | - protected function _getReady() |
|
| 1477 | - { |
|
| 1456 | + protected function _getReady() { |
|
| 1478 | 1457 | return $this->ready; |
| 1479 | 1458 | } |
| 1480 | 1459 | |
@@ -1485,8 +1464,7 @@ discard block |
||
| 1485 | 1464 | * |
| 1486 | 1465 | * @return mixed The METS file's / IIIF manifest's record identifier |
| 1487 | 1466 | */ |
| 1488 | - protected function _getRecordId() |
|
| 1489 | - { |
|
| 1467 | + protected function _getRecordId() { |
|
| 1490 | 1468 | return $this->recordId; |
| 1491 | 1469 | } |
| 1492 | 1470 | |
@@ -1497,8 +1475,7 @@ discard block |
||
| 1497 | 1475 | * |
| 1498 | 1476 | * @return int The UID of the root document or zero if not applicable |
| 1499 | 1477 | */ |
| 1500 | - protected function _getRootId() |
|
| 1501 | - { |
|
| 1478 | + protected function _getRootId() { |
|
| 1502 | 1479 | if (!$this->rootIdLoaded) { |
| 1503 | 1480 | if ($this->parentId) { |
| 1504 | 1481 | $parent = self::getInstance($this->parentId, $this->pid); |
@@ -1528,8 +1505,7 @@ discard block |
||
| 1528 | 1505 | * |
| 1529 | 1506 | * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved |
| 1530 | 1507 | */ |
| 1531 | - protected function _getTableOfContents() |
|
| 1532 | - { |
|
| 1508 | + protected function _getTableOfContents() { |
|
| 1533 | 1509 | // Is there no logical structure array yet? |
| 1534 | 1510 | if (!$this->tableOfContentsLoaded) { |
| 1535 | 1511 | // Get all logical structures. |
@@ -1570,8 +1546,7 @@ discard block |
||
| 1570 | 1546 | * |
| 1571 | 1547 | * @return mixed The UID or the URL of the document |
| 1572 | 1548 | */ |
| 1573 | - protected function _getUid() |
|
| 1574 | - { |
|
| 1549 | + protected function _getUid() { |
|
| 1575 | 1550 | return $this->uid; |
| 1576 | 1551 | } |
| 1577 | 1552 | |
@@ -1584,8 +1559,7 @@ discard block |
||
| 1584 | 1559 | * |
| 1585 | 1560 | * @return void |
| 1586 | 1561 | */ |
| 1587 | - protected function _setCPid($value) |
|
| 1588 | - { |
|
| 1562 | + protected function _setCPid($value) { |
|
| 1589 | 1563 | $this->cPid = max(intval($value), 0); |
| 1590 | 1564 | } |
| 1591 | 1565 | |
@@ -1596,8 +1570,7 @@ discard block |
||
| 1596 | 1570 | * |
| 1597 | 1571 | * @return void |
| 1598 | 1572 | */ |
| 1599 | - protected function __clone() |
|
| 1600 | - { |
|
| 1573 | + protected function __clone() { |
|
| 1601 | 1574 | // This method is defined as protected because singleton objects should not be cloned. |
| 1602 | 1575 | } |
| 1603 | 1576 | |
@@ -1614,8 +1587,7 @@ discard block |
||
| 1614 | 1587 | * |
| 1615 | 1588 | * @return void |
| 1616 | 1589 | */ |
| 1617 | - protected function __construct($uid, $pid, $preloadedDocument) |
|
| 1618 | - { |
|
| 1590 | + protected function __construct($uid, $pid, $preloadedDocument) { |
|
| 1619 | 1591 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 1620 | 1592 | ->getQueryBuilderForTable('tx_dlf_documents'); |
| 1621 | 1593 | $location = ''; |
@@ -1727,8 +1699,7 @@ discard block |
||
| 1727 | 1699 | * |
| 1728 | 1700 | * @return mixed Value of $this->$var |
| 1729 | 1701 | */ |
| 1730 | - public function __get($var) |
|
| 1731 | - { |
|
| 1702 | + public function __get($var) { |
|
| 1732 | 1703 | $method = '_get' . ucfirst($var); |
| 1733 | 1704 | if ( |
| 1734 | 1705 | !property_exists($this, $var) |
@@ -1750,8 +1721,7 @@ discard block |
||
| 1750 | 1721 | * |
| 1751 | 1722 | * @return bool true if variable is set and not empty, false otherwise |
| 1752 | 1723 | */ |
| 1753 | - public function __isset($var) |
|
| 1754 | - { |
|
| 1724 | + public function __isset($var) { |
|
| 1755 | 1725 | return !empty($this->__get($var)); |
| 1756 | 1726 | } |
| 1757 | 1727 | |
@@ -1765,8 +1735,7 @@ discard block |
||
| 1765 | 1735 | * |
| 1766 | 1736 | * @return void |
| 1767 | 1737 | */ |
| 1768 | - public function __set($var, $value) |
|
| 1769 | - { |
|
| 1738 | + public function __set($var, $value) { |
|
| 1770 | 1739 | $method = '_set' . ucfirst($var); |
| 1771 | 1740 | if ( |
| 1772 | 1741 | !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)) |
@@ -207,8 +203,7 @@ discard block |
||
| 207 | 203 | * @return void |
| 208 | 204 | */ |
| 209 | 205 | //TODO: find better way to handle logger in static class |
| 210 | - public static function log($message, $severity = 0) |
|
| 211 | - { |
|
| 206 | + public static function log($message, $severity = 0) { |
|
| 212 | 207 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
| 213 | 208 | |
| 214 | 209 | switch ($severity) { |
@@ -238,8 +233,7 @@ discard block |
||
| 238 | 233 | * |
| 239 | 234 | * @return mixed Hashed string or false on error |
| 240 | 235 | */ |
| 241 | - public static function digest($string) |
|
| 242 | - { |
|
| 236 | + public static function digest($string) { |
|
| 243 | 237 | if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(true))) { |
| 244 | 238 | self::log('OpenSSL library doesn\'t support hash algorithm', LOG_SEVERITY_ERROR); |
| 245 | 239 | return false; |
@@ -258,8 +252,7 @@ discard block |
||
| 258 | 252 | * |
| 259 | 253 | * @return mixed Encrypted string or false on error |
| 260 | 254 | */ |
| 261 | - public static function encrypt($string) |
|
| 262 | - { |
|
| 255 | + public static function encrypt($string) { |
|
| 263 | 256 | if ( |
| 264 | 257 | !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
| 265 | 258 | || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
@@ -292,8 +285,7 @@ discard block |
||
| 292 | 285 | * |
| 293 | 286 | * @return string The unqualified class name |
| 294 | 287 | */ |
| 295 | - public static function getUnqualifiedClassName($qualifiedClassname) |
|
| 296 | - { |
|
| 288 | + public static function getUnqualifiedClassName($qualifiedClassname) { |
|
| 297 | 289 | $nameParts = explode('\\', $qualifiedClassname); |
| 298 | 290 | return end($nameParts); |
| 299 | 291 | } |
@@ -307,8 +299,7 @@ discard block |
||
| 307 | 299 | * |
| 308 | 300 | * @return string The cleaned up string |
| 309 | 301 | */ |
| 310 | - public static function getCleanString($string) |
|
| 311 | - { |
|
| 302 | + public static function getCleanString($string) { |
|
| 312 | 303 | // Convert to lowercase. |
| 313 | 304 | $string = strtolower($string); |
| 314 | 305 | // Remove non-alphanumeric characters. |
@@ -329,8 +320,7 @@ discard block |
||
| 329 | 320 | * |
| 330 | 321 | * @return array Array of hook objects for the class |
| 331 | 322 | */ |
| 332 | - public static function getHookObjects($scriptRelPath) |
|
| 333 | - { |
|
| 323 | + public static function getHookObjects($scriptRelPath) { |
|
| 334 | 324 | $hookObjects = []; |
| 335 | 325 | if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) { |
| 336 | 326 | foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) { |
@@ -351,8 +341,7 @@ discard block |
||
| 351 | 341 | * |
| 352 | 342 | * @return string "index_name" for the given UID |
| 353 | 343 | */ |
| 354 | - public static function getIndexNameFromUid($uid, $table, $pid = -1) |
|
| 355 | - { |
|
| 344 | + public static function getIndexNameFromUid($uid, $table, $pid = -1) { |
|
| 356 | 345 | // Sanitize input. |
| 357 | 346 | $uid = max(intval($uid), 0); |
| 358 | 347 | if ( |
@@ -404,8 +393,7 @@ discard block |
||
| 404 | 393 | * |
| 405 | 394 | * @return string "label" for the given UID |
| 406 | 395 | */ |
| 407 | - public static function getLabelFromUid($uid, $table, $pid = -1) |
|
| 408 | - { |
|
| 396 | + public static function getLabelFromUid($uid, $table, $pid = -1) { |
|
| 409 | 397 | // Sanitize input. |
| 410 | 398 | $uid = max(intval($uid), 0); |
| 411 | 399 | if ( |
@@ -455,8 +443,7 @@ discard block |
||
| 455 | 443 | * |
| 456 | 444 | * @return string Localized full name of language or unchanged input |
| 457 | 445 | */ |
| 458 | - public static function getLanguageName($code) |
|
| 459 | - { |
|
| 446 | + public static function getLanguageName($code) { |
|
| 460 | 447 | // Analyze code and set appropriate ISO table. |
| 461 | 448 | $isoCode = strtolower(trim($code)); |
| 462 | 449 | if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
@@ -501,8 +488,7 @@ discard block |
||
| 501 | 488 | * |
| 502 | 489 | * @return string The translated string or the given key on failure |
| 503 | 490 | */ |
| 504 | - public static function getMessage($key, $hsc = false, $default = '') |
|
| 505 | - { |
|
| 491 | + public static function getMessage($key, $hsc = false, $default = '') { |
|
| 506 | 492 | // Set initial output to default value. |
| 507 | 493 | $translated = (string) $default; |
| 508 | 494 | // Load common messages file. |
@@ -544,8 +530,7 @@ discard block |
||
| 544 | 530 | * |
| 545 | 531 | * @return string "uid" for the given index_name |
| 546 | 532 | */ |
| 547 | - public static function getUidFromIndexName($index_name, $table, $pid = -1) |
|
| 548 | - { |
|
| 533 | + public static function getUidFromIndexName($index_name, $table, $pid = -1) { |
|
| 549 | 534 | if ( |
| 550 | 535 | !$index_name |
| 551 | 536 | || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores']) |
@@ -596,8 +581,7 @@ discard block |
||
| 596 | 581 | * |
| 597 | 582 | * @return string Uniform Resource Name as string |
| 598 | 583 | */ |
| 599 | - public static function getURN($base, $id) |
|
| 600 | - { |
|
| 584 | + public static function getURN($base, $id) { |
|
| 601 | 585 | $concordance = [ |
| 602 | 586 | '0' => 1, |
| 603 | 587 | '1' => 2, |
@@ -664,8 +648,7 @@ discard block |
||
| 664 | 648 | * |
| 665 | 649 | * @return bool Is $id a valid PPN? |
| 666 | 650 | */ |
| 667 | - public static function isPPN($id) |
|
| 668 | - { |
|
| 651 | + public static function isPPN($id) { |
|
| 669 | 652 | return self::checkIdentifier($id, 'PPN'); |
| 670 | 653 | } |
| 671 | 654 | |
@@ -678,8 +661,7 @@ discard block |
||
| 678 | 661 | * |
| 679 | 662 | * @return mixed Session value for given key or null on failure |
| 680 | 663 | */ |
| 681 | - public static function loadFromSession($key) |
|
| 682 | - { |
|
| 664 | + public static function loadFromSession($key) { |
|
| 683 | 665 | // Cast to string for security reasons. |
| 684 | 666 | $key = (string) $key; |
| 685 | 667 | if (!$key) { |
@@ -711,8 +693,7 @@ discard block |
||
| 711 | 693 | * |
| 712 | 694 | * @return array Merged array |
| 713 | 695 | */ |
| 714 | - public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) |
|
| 715 | - { |
|
| 696 | + public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) { |
|
| 716 | 697 | \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature); |
| 717 | 698 | return $original; |
| 718 | 699 | } |
@@ -729,8 +710,7 @@ discard block |
||
| 729 | 710 | * |
| 730 | 711 | * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
| 731 | 712 | */ |
| 732 | - public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false) |
|
| 733 | - { |
|
| 713 | + public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false) { |
|
| 734 | 714 | if ( |
| 735 | 715 | \TYPO3_MODE === 'BE' |
| 736 | 716 | && $GLOBALS['BE_USER']->isAdmin() |
@@ -776,8 +756,7 @@ discard block |
||
| 776 | 756 | * |
| 777 | 757 | * @return string All flash messages in the queue rendered as HTML. |
| 778 | 758 | */ |
| 779 | - public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') |
|
| 780 | - { |
|
| 759 | + public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') { |
|
| 781 | 760 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
| 782 | 761 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
| 783 | 762 | $flashMessages = $flashMessageQueue->getAllMessagesAndFlush(); |
@@ -796,8 +775,7 @@ discard block |
||
| 796 | 775 | * |
| 797 | 776 | * @return bool true on success, false on failure |
| 798 | 777 | */ |
| 799 | - public static function saveToSession($value, $key) |
|
| 800 | - { |
|
| 778 | + public static function saveToSession($value, $key) { |
|
| 801 | 779 | // Cast to string for security reasons. |
| 802 | 780 | $key = (string) $key; |
| 803 | 781 | if (!$key) { |
@@ -829,8 +807,7 @@ discard block |
||
| 829 | 807 | * |
| 830 | 808 | * @return string Localized label for $index_name |
| 831 | 809 | */ |
| 832 | - public static function translate($index_name, $table, $pid) |
|
| 833 | - { |
|
| 810 | + public static function translate($index_name, $table, $pid) { |
|
| 834 | 811 | // Load labels into static variable for future use. |
| 835 | 812 | static $labels = []; |
| 836 | 813 | // Sanitize input. |
@@ -953,8 +930,7 @@ discard block |
||
| 953 | 930 | * |
| 954 | 931 | * @return string Additional WHERE expression |
| 955 | 932 | */ |
| 956 | - public static function whereExpression($table, $showHidden = false) |
|
| 957 | - { |
|
| 933 | + public static function whereExpression($table, $showHidden = false) { |
|
| 958 | 934 | if (\TYPO3_MODE === 'FE') { |
| 959 | 935 | // Should we ignore the record's hidden flag? |
| 960 | 936 | $ignoreHide = 0; |
@@ -983,8 +959,7 @@ discard block |
||
| 983 | 959 | * |
| 984 | 960 | * @access private |
| 985 | 961 | */ |
| 986 | - private function __construct() |
|
| 987 | - { |
|
| 962 | + private function __construct() { |
|
| 988 | 963 | // This is a static class, thus no instances should be created. |
| 989 | 964 | } |
| 990 | 965 | } |
@@ -56,8 +56,7 @@ discard block |
||
| 56 | 56 | * @property-read string $toplevelId This holds the toplevel manifest's @id |
| 57 | 57 | * @property-read mixed $uid This holds the UID or the URL of the document |
| 58 | 58 | */ |
| 59 | -final class IiifManifest extends Document |
|
| 60 | -{ |
|
| 59 | +final class IiifManifest extends Document { |
|
| 61 | 60 | /** |
| 62 | 61 | * This holds the manifest file as string for serialization purposes |
| 63 | 62 | * @see __sleep() / __wakeup() |
@@ -118,8 +117,7 @@ discard block |
||
| 118 | 117 | * {@inheritDoc} |
| 119 | 118 | * @see Document::establishRecordId() |
| 120 | 119 | */ |
| 121 | - protected function establishRecordId($pid) |
|
| 122 | - { |
|
| 120 | + protected function establishRecordId($pid) { |
|
| 123 | 121 | if ($this->iiif !== null) { |
| 124 | 122 | /* |
| 125 | 123 | * FIXME This will not consistently work because we can not be sure to have the pid at hand. It may miss |
@@ -170,8 +168,7 @@ discard block |
||
| 170 | 168 | * {@inheritDoc} |
| 171 | 169 | * @see Document::getDocument() |
| 172 | 170 | */ |
| 173 | - protected function getDocument() |
|
| 174 | - { |
|
| 171 | + protected function getDocument() { |
|
| 175 | 172 | return $this->iiif; |
| 176 | 173 | } |
| 177 | 174 | |
@@ -184,8 +181,7 @@ discard block |
||
| 184 | 181 | * @return string 'IIIF1' if the resource is a Metadata API 1 resource, 'IIIF2' / 'IIIF3' if |
| 185 | 182 | * the resource is a Presentation API 2 / 3 resource |
| 186 | 183 | */ |
| 187 | - public function getIiifVersion() |
|
| 188 | - { |
|
| 184 | + public function getIiifVersion() { |
|
| 189 | 185 | if (!isset($this->iiifVersion)) { |
| 190 | 186 | if ($this->iiif instanceof AbstractIiifResource1) { |
| 191 | 187 | $this->iiifVersion = 'IIIF1'; |
@@ -226,8 +222,7 @@ discard block |
||
| 226 | 222 | * |
| 227 | 223 | * @return array|string |
| 228 | 224 | */ |
| 229 | - protected function getUseGroups($use) |
|
| 230 | - { |
|
| 225 | + protected function getUseGroups($use) { |
|
| 231 | 226 | if (!$this->useGrpsLoaded) { |
| 232 | 227 | // Get configured USE attributes. |
| 233 | 228 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -255,8 +250,7 @@ discard block |
||
| 255 | 250 | * {@inheritDoc} |
| 256 | 251 | * @see Document::_getPhysicalStructure() |
| 257 | 252 | */ |
| 258 | - protected function _getPhysicalStructure() |
|
| 259 | - { |
|
| 253 | + protected function _getPhysicalStructure() { |
|
| 260 | 254 | // Is there no physical structure array yet? |
| 261 | 255 | if (!$this->physicalStructureLoaded) { |
| 262 | 256 | if ($this->iiif == null || !($this->iiif instanceof ManifestInterface)) { |
@@ -369,8 +363,7 @@ discard block |
||
| 369 | 363 | * {@inheritDoc} |
| 370 | 364 | * @see Document::getDownloadLocation() |
| 371 | 365 | */ |
| 372 | - public function getDownloadLocation($id) |
|
| 373 | - { |
|
| 366 | + public function getDownloadLocation($id) { |
|
| 374 | 367 | $fileLocation = $this->getFileLocation($id); |
| 375 | 368 | $resource = $this->iiif->getContainedResourceById($fileLocation); |
| 376 | 369 | if ($resource instanceof AbstractImageService) { |
@@ -383,8 +376,7 @@ discard block |
||
| 383 | 376 | * {@inheritDoc} |
| 384 | 377 | * @see Document::getFileLocation() |
| 385 | 378 | */ |
| 386 | - public function getFileLocation($id) |
|
| 387 | - { |
|
| 379 | + public function getFileLocation($id) { |
|
| 388 | 380 | if ($id == null) { |
| 389 | 381 | return null; |
| 390 | 382 | } |
@@ -408,8 +400,7 @@ discard block |
||
| 408 | 400 | * {@inheritDoc} |
| 409 | 401 | * @see Document::getFileMimeType() |
| 410 | 402 | */ |
| 411 | - public function getFileMimeType($id) |
|
| 412 | - { |
|
| 403 | + public function getFileMimeType($id) { |
|
| 413 | 404 | $fileResource = $this->iiif->getContainedResourceById($id); |
| 414 | 405 | if ($fileResource instanceof CanvasInterface) { |
| 415 | 406 | $format = "application/vnd.kitodo.iiif"; |
@@ -434,8 +425,7 @@ discard block |
||
| 434 | 425 | * {@inheritDoc} |
| 435 | 426 | * @see Document::getLogicalStructure() |
| 436 | 427 | */ |
| 437 | - public function getLogicalStructure($id, $recursive = false) |
|
| 438 | - { |
|
| 428 | + public function getLogicalStructure($id, $recursive = false) { |
|
| 439 | 429 | $details = []; |
| 440 | 430 | if (!$recursive && !empty($this->logicalUnits[$id])) { |
| 441 | 431 | return $this->logicalUnits[$id]; |
@@ -470,8 +460,7 @@ discard block |
||
| 470 | 460 | * @param array $processedStructures: IIIF resources that already have been processed |
| 471 | 461 | * @return array Logical structure array |
| 472 | 462 | */ |
| 473 | - protected function getLogicalStructureInfo(IiifResourceInterface $resource, $recursive = false, &$processedStructures = []) |
|
| 474 | - { |
|
| 463 | + protected function getLogicalStructureInfo(IiifResourceInterface $resource, $recursive = false, &$processedStructures = []) { |
|
| 475 | 464 | $details = []; |
| 476 | 465 | $details['id'] = $resource->getId(); |
| 477 | 466 | $details['dmdId'] = ''; |
@@ -563,8 +552,7 @@ discard block |
||
| 563 | 552 | * |
| 564 | 553 | * @todo This method is still in experimental; the method signature may change. |
| 565 | 554 | */ |
| 566 | - public function getManifestMetadata($id, $cPid = 0, $withDescription = true, $withRights = true, $withRelated = true) |
|
| 567 | - { |
|
| 555 | + public function getManifestMetadata($id, $cPid = 0, $withDescription = true, $withRights = true, $withRelated = true) { |
|
| 568 | 556 | if (!empty($this->originalMetadataArray[$id])) { |
| 569 | 557 | return $this->originalMetadataArray[$id]; |
| 570 | 558 | } |
@@ -606,8 +594,7 @@ discard block |
||
| 606 | 594 | * {@inheritDoc} |
| 607 | 595 | * @see Document::getMetadata() |
| 608 | 596 | */ |
| 609 | - public function getMetadata($id, $cPid = 0) |
|
| 610 | - { |
|
| 597 | + public function getMetadata($id, $cPid = 0) { |
|
| 611 | 598 | if (!empty($this->metadataArray[$id]) && $this->metadataArray[0] == $cPid) { |
| 612 | 599 | return $this->metadataArray[$id]; |
| 613 | 600 | } |
@@ -714,8 +701,7 @@ discard block |
||
| 714 | 701 | * {@inheritDoc} |
| 715 | 702 | * @see Document::_getSmLinks() |
| 716 | 703 | */ |
| 717 | - protected function _getSmLinks() |
|
| 718 | - { |
|
| 704 | + protected function _getSmLinks() { |
|
| 719 | 705 | if (!$this->smLinksLoaded && isset($this->iiif) && $this->iiif instanceof ManifestInterface) { |
| 720 | 706 | if (!empty($this->iiif->getDefaultCanvases())) { |
| 721 | 707 | foreach ($this->iiif->getDefaultCanvases() as $canvas) { |
@@ -739,8 +725,7 @@ discard block |
||
| 739 | 725 | * |
| 740 | 726 | * @param RangeInterface $range: Current range whose canvases shall be linked |
| 741 | 727 | */ |
| 742 | - private function smLinkRangeCanvasesRecursively(RangeInterface $range) |
|
| 743 | - { |
|
| 728 | + private function smLinkRangeCanvasesRecursively(RangeInterface $range) { |
|
| 744 | 729 | // map range's canvases including all child ranges' canvases |
| 745 | 730 | if (!$range->isTopRange()) { |
| 746 | 731 | foreach ($range->getAllCanvasesRecursively() as $canvas) { |
@@ -763,8 +748,7 @@ discard block |
||
| 763 | 748 | * @param CanvasInterface $canvas |
| 764 | 749 | * @param IiifResourceInterface $resource |
| 765 | 750 | */ |
| 766 | - private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInterface $resource) |
|
| 767 | - { |
|
| 751 | + private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInterface $resource) { |
|
| 768 | 752 | $this->smLinks['l2p'][$resource->getId()][] = $canvas->getId(); |
| 769 | 753 | if (!is_array($this->smLinks['p2l'][$canvas->getId()]) || !in_array($resource->getId(), $this->smLinks['p2l'][$canvas->getId()])) { |
| 770 | 754 | $this->smLinks['p2l'][$canvas->getId()][] = $resource->getId(); |
@@ -779,8 +763,7 @@ discard block |
||
| 779 | 763 | * |
| 780 | 764 | * @see Document::getParentDocumentUidForSaving() |
| 781 | 765 | */ |
| 782 | - protected function getParentDocumentUidForSaving($pid, $core, $owner) |
|
| 783 | - { |
|
| 766 | + protected function getParentDocumentUidForSaving($pid, $core, $owner) { |
|
| 784 | 767 | // Do nothing. |
| 785 | 768 | } |
| 786 | 769 | |
@@ -788,8 +771,7 @@ discard block |
||
| 788 | 771 | * {@inheritDoc} |
| 789 | 772 | * @see Document::getRawText() |
| 790 | 773 | */ |
| 791 | - public function getRawText($id) |
|
| 792 | - { |
|
| 774 | + public function getRawText($id) { |
|
| 793 | 775 | $rawText = ''; |
| 794 | 776 | // Get text from raw text array if available. |
| 795 | 777 | if (!empty($this->rawTextArray[$id])) { |
@@ -846,8 +828,7 @@ discard block |
||
| 846 | 828 | * |
| 847 | 829 | * @return IiifResourceInterface |
| 848 | 830 | */ |
| 849 | - public function getIiif() |
|
| 850 | - { |
|
| 831 | + public function getIiif() { |
|
| 851 | 832 | return $this->iiif; |
| 852 | 833 | } |
| 853 | 834 | |
@@ -855,8 +836,7 @@ discard block |
||
| 855 | 836 | * {@inheritDoc} |
| 856 | 837 | * @see Document::init() |
| 857 | 838 | */ |
| 858 | - protected function init() |
|
| 859 | - { |
|
| 839 | + protected function init() { |
|
| 860 | 840 | // Nothing to do here, at the moment |
| 861 | 841 | } |
| 862 | 842 | |
@@ -864,8 +844,7 @@ discard block |
||
| 864 | 844 | * {@inheritDoc} |
| 865 | 845 | * @see Document::loadLocation() |
| 866 | 846 | */ |
| 867 | - protected function loadLocation($location) |
|
| 868 | - { |
|
| 847 | + protected function loadLocation($location) { |
|
| 869 | 848 | $fileResource = GeneralUtility::getUrl($location); |
| 870 | 849 | if ($fileResource !== false) { |
| 871 | 850 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -888,8 +867,7 @@ discard block |
||
| 888 | 867 | * {@inheritDoc} |
| 889 | 868 | * @see \Kitodo\Dlf\Common\Document::prepareMetadataArray() |
| 890 | 869 | */ |
| 891 | - protected function prepareMetadataArray($cPid) |
|
| 892 | - { |
|
| 870 | + protected function prepareMetadataArray($cPid) { |
|
| 893 | 871 | $id = $this->iiif->getId(); |
| 894 | 872 | $this->metadataArray[(string) $id] = $this->getMetadata((string) $id, $cPid); |
| 895 | 873 | } |
@@ -898,8 +876,7 @@ discard block |
||
| 898 | 876 | * {@inheritDoc} |
| 899 | 877 | * @see Document::setPreloadedDocument() |
| 900 | 878 | */ |
| 901 | - protected function setPreloadedDocument($preloadedDocument) |
|
| 902 | - { |
|
| 879 | + protected function setPreloadedDocument($preloadedDocument) { |
|
| 903 | 880 | if ($preloadedDocument instanceof ManifestInterface) { |
| 904 | 881 | $this->iiif = $preloadedDocument; |
| 905 | 882 | return true; |
@@ -911,8 +888,7 @@ discard block |
||
| 911 | 888 | * {@inheritDoc} |
| 912 | 889 | * @see Document::ensureHasFulltextIsSet() |
| 913 | 890 | */ |
| 914 | - protected function ensureHasFulltextIsSet() |
|
| 915 | - { |
|
| 891 | + protected function ensureHasFulltextIsSet() { |
|
| 916 | 892 | /* |
| 917 | 893 | * TODO Check annotations and annotation lists of canvas for ALTO documents. |
| 918 | 894 | * Example: |
@@ -958,8 +934,7 @@ discard block |
||
| 958 | 934 | * {@inheritDoc} |
| 959 | 935 | * @see \Kitodo\Dlf\Common\Document::_getThumbnail() |
| 960 | 936 | */ |
| 961 | - protected function _getThumbnail($forceReload = false) |
|
| 962 | - { |
|
| 937 | + protected function _getThumbnail($forceReload = false) { |
|
| 963 | 938 | return $this->iiif->getThumbnailUrl(); |
| 964 | 939 | } |
| 965 | 940 | |
@@ -967,8 +942,7 @@ discard block |
||
| 967 | 942 | * {@inheritDoc} |
| 968 | 943 | * @see \Kitodo\Dlf\Common\Document::_getToplevelId() |
| 969 | 944 | */ |
| 970 | - protected function _getToplevelId() |
|
| 971 | - { |
|
| 945 | + protected function _getToplevelId() { |
|
| 972 | 946 | if (empty($this->toplevelId)) { |
| 973 | 947 | if (isset($this->iiif)) { |
| 974 | 948 | $this->toplevelId = $this->iiif->getId(); |
@@ -985,8 +959,7 @@ discard block |
||
| 985 | 959 | * |
| 986 | 960 | * @return void |
| 987 | 961 | */ |
| 988 | - public function __wakeup() |
|
| 989 | - { |
|
| 962 | + public function __wakeup() { |
|
| 990 | 963 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 991 | 964 | IiifHelper::setUrlReader(IiifUrlReader::getInstance()); |
| 992 | 965 | IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']); |
@@ -1005,8 +978,7 @@ discard block |
||
| 1005 | 978 | * |
| 1006 | 979 | * @return string[] |
| 1007 | 980 | */ |
| 1008 | - public function __sleep() |
|
| 1009 | - { |
|
| 981 | + public function __sleep() { |
|
| 1010 | 982 | // TODO implement serializiation in IIIF library |
| 1011 | 983 | $jsonArray = $this->iiif->getOriginalJsonArray(); |
| 1012 | 984 | $this->asJson = json_encode($jsonArray); |
@@ -48,8 +48,7 @@ discard block |
||
| 48 | 48 | * @property-read string $toplevelId This holds the toplevel structure's @ID (METS) or the manifest's @id (IIIF) |
| 49 | 49 | * @property-read mixed $uid This holds the UID or the URL of the document |
| 50 | 50 | */ |
| 51 | -final class MetsDocument extends Document |
|
| 52 | -{ |
|
| 51 | +final class MetsDocument extends Document { |
|
| 53 | 52 | /** |
| 54 | 53 | * This holds the whole XML file as string for serialization purposes |
| 55 | 54 | * @see __sleep() / __wakeup() |
@@ -128,8 +127,7 @@ discard block |
||
| 128 | 127 | * |
| 129 | 128 | * @return void |
| 130 | 129 | */ |
| 131 | - public function addMetadataFromMets(&$metadata, $id) |
|
| 132 | - { |
|
| 130 | + public function addMetadataFromMets(&$metadata, $id) { |
|
| 133 | 131 | $details = $this->getLogicalStructure($id); |
| 134 | 132 | if (!empty($details)) { |
| 135 | 133 | $metadata['mets_order'][0] = $details['order']; |
@@ -143,8 +141,7 @@ discard block |
||
| 143 | 141 | * {@inheritDoc} |
| 144 | 142 | * @see \Kitodo\Dlf\Common\Document::establishRecordId() |
| 145 | 143 | */ |
| 146 | - protected function establishRecordId($pid) |
|
| 147 | - { |
|
| 144 | + protected function establishRecordId($pid) { |
|
| 148 | 145 | // Check for METS object @ID. |
| 149 | 146 | if (!empty($this->mets['OBJID'])) { |
| 150 | 147 | $this->recordId = (string) $this->mets['OBJID']; |
@@ -164,8 +161,7 @@ discard block |
||
| 164 | 161 | * {@inheritDoc} |
| 165 | 162 | * @see \Kitodo\Dlf\Common\Document::getDownloadLocation() |
| 166 | 163 | */ |
| 167 | - public function getDownloadLocation($id) |
|
| 168 | - { |
|
| 164 | + public function getDownloadLocation($id) { |
|
| 169 | 165 | $fileMimeType = $this->getFileMimeType($id); |
| 170 | 166 | $fileLocation = $this->getFileLocation($id); |
| 171 | 167 | if ($fileMimeType === 'application/vnd.kitodo.iiif') { |
@@ -190,8 +186,7 @@ discard block |
||
| 190 | 186 | * {@inheritDoc} |
| 191 | 187 | * @see \Kitodo\Dlf\Common\Document::getFileLocation() |
| 192 | 188 | */ |
| 193 | - public function getFileLocation($id) |
|
| 194 | - { |
|
| 189 | + public function getFileLocation($id) { |
|
| 195 | 190 | $location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/mets:FLocat[@LOCTYPE="URL"]'); |
| 196 | 191 | if ( |
| 197 | 192 | !empty($id) |
@@ -208,8 +203,7 @@ discard block |
||
| 208 | 203 | * {@inheritDoc} |
| 209 | 204 | * @see \Kitodo\Dlf\Common\Document::getFileMimeType() |
| 210 | 205 | */ |
| 211 | - public function getFileMimeType($id) |
|
| 212 | - { |
|
| 206 | + public function getFileMimeType($id) { |
|
| 213 | 207 | $mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/@MIMETYPE'); |
| 214 | 208 | if ( |
| 215 | 209 | !empty($id) |
@@ -226,8 +220,7 @@ discard block |
||
| 226 | 220 | * {@inheritDoc} |
| 227 | 221 | * @see \Kitodo\Dlf\Common\Document::getLogicalStructure() |
| 228 | 222 | */ |
| 229 | - public function getLogicalStructure($id, $recursive = false) |
|
| 230 | - { |
|
| 223 | + public function getLogicalStructure($id, $recursive = false) { |
|
| 231 | 224 | $details = []; |
| 232 | 225 | // Is the requested logical unit already loaded? |
| 233 | 226 | if ( |
@@ -267,8 +260,7 @@ discard block |
||
| 267 | 260 | * |
| 268 | 261 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
| 269 | 262 | */ |
| 270 | - protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) |
|
| 271 | - { |
|
| 263 | + protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) { |
|
| 272 | 264 | // Get attributes. |
| 273 | 265 | foreach ($structure->attributes() as $attribute => $value) { |
| 274 | 266 | $attributes[$attribute] = (string) $value; |
@@ -366,8 +358,7 @@ discard block |
||
| 366 | 358 | * {@inheritDoc} |
| 367 | 359 | * @see \Kitodo\Dlf\Common\Document::getMetadata() |
| 368 | 360 | */ |
| 369 | - public function getMetadata($id, $cPid = 0) |
|
| 370 | - { |
|
| 361 | + public function getMetadata($id, $cPid = 0) { |
|
| 371 | 362 | // Make sure $cPid is a non-negative integer. |
| 372 | 363 | $cPid = max(intval($cPid), 0); |
| 373 | 364 | // If $cPid is not given, try to get it elsewhere. |
@@ -669,8 +660,7 @@ discard block |
||
| 669 | 660 | * {@inheritDoc} |
| 670 | 661 | * @see \Kitodo\Dlf\Common\Document::getRawText() |
| 671 | 662 | */ |
| 672 | - public function getRawText($id) |
|
| 673 | - { |
|
| 663 | + public function getRawText($id) { |
|
| 674 | 664 | $rawText = ''; |
| 675 | 665 | // Get text from raw text array if available. |
| 676 | 666 | if (!empty($this->rawTextArray[$id])) { |
@@ -688,8 +678,7 @@ discard block |
||
| 688 | 678 | * {@inheritDoc} |
| 689 | 679 | * @see Document::getStructureDepth() |
| 690 | 680 | */ |
| 691 | - public function getStructureDepth($logId) |
|
| 692 | - { |
|
| 681 | + public function getStructureDepth($logId) { |
|
| 693 | 682 | $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $logId . '"]/ancestor::*'); |
| 694 | 683 | if (!empty($ancestors)) { |
| 695 | 684 | return count($ancestors); |
@@ -702,8 +691,7 @@ discard block |
||
| 702 | 691 | * {@inheritDoc} |
| 703 | 692 | * @see \Kitodo\Dlf\Common\Document::init() |
| 704 | 693 | */ |
| 705 | - protected function init() |
|
| 706 | - { |
|
| 694 | + protected function init() { |
|
| 707 | 695 | // Get METS node from XML file. |
| 708 | 696 | $this->registerNamespaces($this->xml); |
| 709 | 697 | $mets = $this->xml->xpath('//mets:mets'); |
@@ -720,8 +708,7 @@ discard block |
||
| 720 | 708 | * {@inheritDoc} |
| 721 | 709 | * @see \Kitodo\Dlf\Common\Document::loadLocation() |
| 722 | 710 | */ |
| 723 | - protected function loadLocation($location) |
|
| 724 | - { |
|
| 711 | + protected function loadLocation($location) { |
|
| 725 | 712 | $fileResource = GeneralUtility::getUrl($location); |
| 726 | 713 | if ($fileResource !== false) { |
| 727 | 714 | // Turn off libxml's error logging. |
@@ -748,8 +735,7 @@ discard block |
||
| 748 | 735 | * {@inheritDoc} |
| 749 | 736 | * @see \Kitodo\Dlf\Common\Document::ensureHasFulltextIsSet() |
| 750 | 737 | */ |
| 751 | - protected function ensureHasFulltextIsSet() |
|
| 752 | - { |
|
| 738 | + protected function ensureHasFulltextIsSet() { |
|
| 753 | 739 | // Are the fileGrps already loaded? |
| 754 | 740 | if (!$this->fileGrpsLoaded) { |
| 755 | 741 | $this->_getFileGrps(); |
@@ -760,8 +746,7 @@ discard block |
||
| 760 | 746 | * {@inheritDoc} |
| 761 | 747 | * @see Document::getParentDocumentUid() |
| 762 | 748 | */ |
| 763 | - protected function getParentDocumentUidForSaving($pid, $core, $owner) |
|
| 764 | - { |
|
| 749 | + protected function getParentDocumentUidForSaving($pid, $core, $owner) { |
|
| 765 | 750 | $partof = 0; |
| 766 | 751 | // Get the closest ancestor of the current document which has a MPTR child. |
| 767 | 752 | $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $this->_getToplevelId() . '"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); |
@@ -784,8 +769,7 @@ discard block |
||
| 784 | 769 | * {@inheritDoc} |
| 785 | 770 | * @see Document::setPreloadedDocument() |
| 786 | 771 | */ |
| 787 | - protected function setPreloadedDocument($preloadedDocument) |
|
| 788 | - { |
|
| 772 | + protected function setPreloadedDocument($preloadedDocument) { |
|
| 789 | 773 | |
| 790 | 774 | if ($preloadedDocument instanceof \SimpleXMLElement) { |
| 791 | 775 | $this->xml = $preloadedDocument; |
@@ -798,8 +782,7 @@ discard block |
||
| 798 | 782 | * {@inheritDoc} |
| 799 | 783 | * @see Document::getDocument() |
| 800 | 784 | */ |
| 801 | - protected function getDocument() |
|
| 802 | - { |
|
| 785 | + protected function getDocument() { |
|
| 803 | 786 | return $this->mets; |
| 804 | 787 | } |
| 805 | 788 | |
@@ -810,8 +793,7 @@ discard block |
||
| 810 | 793 | * |
| 811 | 794 | * @return array Array of dmdSecs with their IDs as array key |
| 812 | 795 | */ |
| 813 | - protected function _getDmdSec() |
|
| 814 | - { |
|
| 796 | + protected function _getDmdSec() { |
|
| 815 | 797 | if (!$this->dmdSecLoaded) { |
| 816 | 798 | // Get available data formats. |
| 817 | 799 | $this->loadFormats(); |
@@ -849,8 +831,7 @@ discard block |
||
| 849 | 831 | * |
| 850 | 832 | * @return array Array of file use groups with file IDs |
| 851 | 833 | */ |
| 852 | - protected function _getFileGrps() |
|
| 853 | - { |
|
| 834 | + protected function _getFileGrps() { |
|
| 854 | 835 | if (!$this->fileGrpsLoaded) { |
| 855 | 836 | // Get configured USE attributes. |
| 856 | 837 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -895,8 +876,7 @@ discard block |
||
| 895 | 876 | * {@inheritDoc} |
| 896 | 877 | * @see \Kitodo\Dlf\Common\Document::prepareMetadataArray() |
| 897 | 878 | */ |
| 898 | - protected function prepareMetadataArray($cPid) |
|
| 899 | - { |
|
| 879 | + protected function prepareMetadataArray($cPid) { |
|
| 900 | 880 | $ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'); |
| 901 | 881 | // Get all logical structure nodes with metadata. |
| 902 | 882 | if (!empty($ids)) { |
@@ -914,8 +894,7 @@ discard block |
||
| 914 | 894 | * |
| 915 | 895 | * @return \SimpleXMLElement The XML's METS part as \SimpleXMLElement object |
| 916 | 896 | */ |
| 917 | - protected function _getMets() |
|
| 918 | - { |
|
| 897 | + protected function _getMets() { |
|
| 919 | 898 | return $this->mets; |
| 920 | 899 | } |
| 921 | 900 | |
@@ -923,8 +902,7 @@ discard block |
||
| 923 | 902 | * {@inheritDoc} |
| 924 | 903 | * @see \Kitodo\Dlf\Common\Document::_getPhysicalStructure() |
| 925 | 904 | */ |
| 926 | - protected function _getPhysicalStructure() |
|
| 927 | - { |
|
| 905 | + protected function _getPhysicalStructure() { |
|
| 928 | 906 | // Is there no physical structure array yet? |
| 929 | 907 | if (!$this->physicalStructureLoaded) { |
| 930 | 908 | // Does the document have a structMap node of type "PHYSICAL"? |
@@ -984,8 +962,7 @@ discard block |
||
| 984 | 962 | * {@inheritDoc} |
| 985 | 963 | * @see \Kitodo\Dlf\Common\Document::_getSmLinks() |
| 986 | 964 | */ |
| 987 | - protected function _getSmLinks() |
|
| 988 | - { |
|
| 965 | + protected function _getSmLinks() { |
|
| 989 | 966 | if (!$this->smLinksLoaded) { |
| 990 | 967 | $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink'); |
| 991 | 968 | if (!empty($smLinks)) { |
@@ -1003,8 +980,7 @@ discard block |
||
| 1003 | 980 | * {@inheritDoc} |
| 1004 | 981 | * @see \Kitodo\Dlf\Common\Document::_getThumbnail() |
| 1005 | 982 | */ |
| 1006 | - protected function _getThumbnail($forceReload = false) |
|
| 1007 | - { |
|
| 983 | + protected function _getThumbnail($forceReload = false) { |
|
| 1008 | 984 | if ( |
| 1009 | 985 | !$this->thumbnailLoaded |
| 1010 | 986 | || $forceReload |
@@ -1083,8 +1059,7 @@ discard block |
||
| 1083 | 1059 | * {@inheritDoc} |
| 1084 | 1060 | * @see \Kitodo\Dlf\Common\Document::_getToplevelId() |
| 1085 | 1061 | */ |
| 1086 | - protected function _getToplevelId() |
|
| 1087 | - { |
|
| 1062 | + protected function _getToplevelId() { |
|
| 1088 | 1063 | if (empty($this->toplevelId)) { |
| 1089 | 1064 | // Get all logical structure nodes with metadata, but without associated METS-Pointers. |
| 1090 | 1065 | $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'); |
@@ -1116,8 +1091,7 @@ discard block |
||
| 1116 | 1091 | * |
| 1117 | 1092 | * @return array Properties to be serialized |
| 1118 | 1093 | */ |
| 1119 | - public function __sleep() |
|
| 1120 | - { |
|
| 1094 | + public function __sleep() { |
|
| 1121 | 1095 | // \SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization |
| 1122 | 1096 | $this->asXML = $this->xml->asXML(); |
| 1123 | 1097 | return ['uid', 'pid', 'recordId', 'parentId', 'asXML']; |
@@ -1130,8 +1104,7 @@ discard block |
||
| 1130 | 1104 | * |
| 1131 | 1105 | * @return string String representing the METS object |
| 1132 | 1106 | */ |
| 1133 | - public function __toString() |
|
| 1134 | - { |
|
| 1107 | + public function __toString() { |
|
| 1135 | 1108 | $xml = new \DOMDocument('1.0', 'utf-8'); |
| 1136 | 1109 | $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); |
| 1137 | 1110 | $xml->formatOutput = true; |
@@ -1146,8 +1119,7 @@ discard block |
||
| 1146 | 1119 | * |
| 1147 | 1120 | * @return void |
| 1148 | 1121 | */ |
| 1149 | - public function __wakeup() |
|
| 1150 | - { |
|
| 1122 | + public function __wakeup() { |
|
| 1151 | 1123 | // Turn off libxml's error logging. |
| 1152 | 1124 | $libxmlErrors = libxml_use_internal_errors(true); |
| 1153 | 1125 | // Reload XML from string. |