@@ -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 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
740 | 734 | |
741 | 735 | $title = ''; |
@@ -789,8 +783,7 @@ discard block |
||
789 | 783 | * |
790 | 784 | * @return array The logical structure node's / resource's parsed metadata array |
791 | 785 | */ |
792 | - public function getTitledata($cPid = 0) |
|
793 | - { |
|
786 | + public function getTitledata($cPid = 0) { |
|
794 | 787 | $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); |
795 | 788 | // Add information from METS structural map to titledata array. |
796 | 789 | if ($this instanceof MetsDocument) { |
@@ -823,8 +816,7 @@ discard block |
||
823 | 816 | * @return int|bool: false if structure with $logId is not a child of this substructure, |
824 | 817 | * or the actual depth. |
825 | 818 | */ |
826 | - protected function getTreeDepth($structure, $depth, $logId) |
|
827 | - { |
|
819 | + protected function getTreeDepth($structure, $depth, $logId) { |
|
828 | 820 | foreach ($structure as $element) { |
829 | 821 | if ($element['id'] == $logId) { |
830 | 822 | return $depth; |
@@ -846,8 +838,7 @@ discard block |
||
846 | 838 | * @param string $logId: The id of the logical structure element whose depth is requested |
847 | 839 | * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. |
848 | 840 | */ |
849 | - public function getStructureDepth($logId) |
|
850 | - { |
|
841 | + public function getStructureDepth($logId) { |
|
851 | 842 | return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId); |
852 | 843 | } |
853 | 844 | |
@@ -897,8 +888,7 @@ discard block |
||
897 | 888 | * |
898 | 889 | * @return bool true on success or false on failure |
899 | 890 | */ |
900 | - protected function load($location) |
|
901 | - { |
|
891 | + protected function load($location) { |
|
902 | 892 | // Load XML / JSON-LD file. |
903 | 893 | if (GeneralUtility::isValidUrl($location)) { |
904 | 894 | // Load extension configuration |
@@ -931,8 +921,7 @@ discard block |
||
931 | 921 | * |
932 | 922 | * @return void |
933 | 923 | */ |
934 | - protected function loadFormats() |
|
935 | - { |
|
924 | + protected function loadFormats() { |
|
936 | 925 | if (!$this->formatsLoaded) { |
937 | 926 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
938 | 927 | ->getQueryBuilderForTable('tx_dlf_formats'); |
@@ -972,8 +961,7 @@ discard block |
||
972 | 961 | * |
973 | 962 | * @return void |
974 | 963 | */ |
975 | - public function registerNamespaces(&$obj) |
|
976 | - { |
|
964 | + public function registerNamespaces(&$obj) { |
|
977 | 965 | // 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. |
978 | 966 | $this->loadFormats(); |
979 | 967 | // Do we have a \SimpleXMLElement or \DOMXPath object? |
@@ -1002,8 +990,7 @@ discard block |
||
1002 | 990 | * |
1003 | 991 | * @return bool true on success or false on failure |
1004 | 992 | */ |
1005 | - public function save($pid = 0, $core = 0, $owner = null) |
|
1006 | - { |
|
993 | + public function save($pid = 0, $core = 0, $owner = null) { |
|
1007 | 994 | if (\TYPO3_MODE !== 'BE') { |
1008 | 995 | $this->logger->error('Saving a document is only allowed in the backend'); |
1009 | 996 | return false; |
@@ -1331,8 +1318,7 @@ discard block |
||
1331 | 1318 | * |
1332 | 1319 | * @return int The PID of the metadata definitions |
1333 | 1320 | */ |
1334 | - protected function _getCPid() |
|
1335 | - { |
|
1321 | + protected function _getCPid() { |
|
1336 | 1322 | return $this->cPid; |
1337 | 1323 | } |
1338 | 1324 | |
@@ -1343,8 +1329,7 @@ discard block |
||
1343 | 1329 | * |
1344 | 1330 | * @return bool Are there any fulltext files available? |
1345 | 1331 | */ |
1346 | - protected function _getHasFulltext() |
|
1347 | - { |
|
1332 | + protected function _getHasFulltext() { |
|
1348 | 1333 | $this->ensureHasFulltextIsSet(); |
1349 | 1334 | return $this->hasFulltext; |
1350 | 1335 | } |
@@ -1356,8 +1341,7 @@ discard block |
||
1356 | 1341 | * |
1357 | 1342 | * @return string The location of the document |
1358 | 1343 | */ |
1359 | - protected function _getLocation() |
|
1360 | - { |
|
1344 | + protected function _getLocation() { |
|
1361 | 1345 | return $this->location; |
1362 | 1346 | } |
1363 | 1347 | |
@@ -1379,8 +1363,7 @@ discard block |
||
1379 | 1363 | * |
1380 | 1364 | * @return array Array of metadata with their corresponding logical structure node ID as key |
1381 | 1365 | */ |
1382 | - protected function _getMetadataArray() |
|
1383 | - { |
|
1366 | + protected function _getMetadataArray() { |
|
1384 | 1367 | // Set metadata definitions' PID. |
1385 | 1368 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
1386 | 1369 | if (!$cPid) { |
@@ -1405,8 +1388,7 @@ discard block |
||
1405 | 1388 | * |
1406 | 1389 | * @return int The total number of pages and/or tracks |
1407 | 1390 | */ |
1408 | - protected function _getNumPages() |
|
1409 | - { |
|
1391 | + protected function _getNumPages() { |
|
1410 | 1392 | $this->_getPhysicalStructure(); |
1411 | 1393 | return $this->numPages; |
1412 | 1394 | } |
@@ -1418,8 +1400,7 @@ discard block |
||
1418 | 1400 | * |
1419 | 1401 | * @return int The UID of the parent document or zero if not applicable |
1420 | 1402 | */ |
1421 | - protected function _getParentId() |
|
1422 | - { |
|
1403 | + protected function _getParentId() { |
|
1423 | 1404 | return $this->parentId; |
1424 | 1405 | } |
1425 | 1406 | |
@@ -1442,8 +1423,7 @@ discard block |
||
1442 | 1423 | * |
1443 | 1424 | * @return array Array of elements' type, label and file representations ordered by @ID attribute / Canvas order |
1444 | 1425 | */ |
1445 | - protected function _getPhysicalStructureInfo() |
|
1446 | - { |
|
1426 | + protected function _getPhysicalStructureInfo() { |
|
1447 | 1427 | // Is there no physical structure array yet? |
1448 | 1428 | if (!$this->physicalStructureLoaded) { |
1449 | 1429 | // Build physical structure array. |
@@ -1459,8 +1439,7 @@ discard block |
||
1459 | 1439 | * |
1460 | 1440 | * @return int The PID of the document or zero if not in database |
1461 | 1441 | */ |
1462 | - protected function _getPid() |
|
1463 | - { |
|
1442 | + protected function _getPid() { |
|
1464 | 1443 | return $this->pid; |
1465 | 1444 | } |
1466 | 1445 | |
@@ -1471,8 +1450,7 @@ discard block |
||
1471 | 1450 | * |
1472 | 1451 | * @return bool Is the document instantiated successfully? |
1473 | 1452 | */ |
1474 | - protected function _getReady() |
|
1475 | - { |
|
1453 | + protected function _getReady() { |
|
1476 | 1454 | return $this->ready; |
1477 | 1455 | } |
1478 | 1456 | |
@@ -1483,8 +1461,7 @@ discard block |
||
1483 | 1461 | * |
1484 | 1462 | * @return mixed The METS file's / IIIF manifest's record identifier |
1485 | 1463 | */ |
1486 | - protected function _getRecordId() |
|
1487 | - { |
|
1464 | + protected function _getRecordId() { |
|
1488 | 1465 | return $this->recordId; |
1489 | 1466 | } |
1490 | 1467 | |
@@ -1495,8 +1472,7 @@ discard block |
||
1495 | 1472 | * |
1496 | 1473 | * @return int The UID of the root document or zero if not applicable |
1497 | 1474 | */ |
1498 | - protected function _getRootId() |
|
1499 | - { |
|
1475 | + protected function _getRootId() { |
|
1500 | 1476 | if (!$this->rootIdLoaded) { |
1501 | 1477 | if ($this->parentId) { |
1502 | 1478 | $parent = self::getInstance($this->parentId, $this->pid); |
@@ -1526,8 +1502,7 @@ discard block |
||
1526 | 1502 | * |
1527 | 1503 | * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved |
1528 | 1504 | */ |
1529 | - protected function _getTableOfContents() |
|
1530 | - { |
|
1505 | + protected function _getTableOfContents() { |
|
1531 | 1506 | // Is there no logical structure array yet? |
1532 | 1507 | if (!$this->tableOfContentsLoaded) { |
1533 | 1508 | // Get all logical structures. |
@@ -1568,8 +1543,7 @@ discard block |
||
1568 | 1543 | * |
1569 | 1544 | * @return mixed The UID or the URL of the document |
1570 | 1545 | */ |
1571 | - protected function _getUid() |
|
1572 | - { |
|
1546 | + protected function _getUid() { |
|
1573 | 1547 | return $this->uid; |
1574 | 1548 | } |
1575 | 1549 | |
@@ -1582,8 +1556,7 @@ discard block |
||
1582 | 1556 | * |
1583 | 1557 | * @return void |
1584 | 1558 | */ |
1585 | - protected function _setCPid($value) |
|
1586 | - { |
|
1559 | + protected function _setCPid($value) { |
|
1587 | 1560 | $this->cPid = max(intval($value), 0); |
1588 | 1561 | } |
1589 | 1562 | |
@@ -1594,8 +1567,7 @@ discard block |
||
1594 | 1567 | * |
1595 | 1568 | * @return void |
1596 | 1569 | */ |
1597 | - protected function __clone() |
|
1598 | - { |
|
1570 | + protected function __clone() { |
|
1599 | 1571 | // This method is defined as protected because singleton objects should not be cloned. |
1600 | 1572 | } |
1601 | 1573 | |
@@ -1612,8 +1584,7 @@ discard block |
||
1612 | 1584 | * |
1613 | 1585 | * @return void |
1614 | 1586 | */ |
1615 | - protected function __construct($uid, $pid, $preloadedDocument) |
|
1616 | - { |
|
1587 | + protected function __construct($uid, $pid, $preloadedDocument) { |
|
1617 | 1588 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
1618 | 1589 | ->getQueryBuilderForTable('tx_dlf_documents'); |
1619 | 1590 | $location = ''; |
@@ -1725,8 +1696,7 @@ discard block |
||
1725 | 1696 | * |
1726 | 1697 | * @return mixed Value of $this->$var |
1727 | 1698 | */ |
1728 | - public function __get($var) |
|
1729 | - { |
|
1699 | + public function __get($var) { |
|
1730 | 1700 | $method = '_get' . ucfirst($var); |
1731 | 1701 | if ( |
1732 | 1702 | !property_exists($this, $var) |
@@ -1748,8 +1718,7 @@ discard block |
||
1748 | 1718 | * |
1749 | 1719 | * @return bool true if variable is set and not empty, false otherwise |
1750 | 1720 | */ |
1751 | - public function __isset($var) |
|
1752 | - { |
|
1721 | + public function __isset($var) { |
|
1753 | 1722 | return !empty($this->__get($var)); |
1754 | 1723 | } |
1755 | 1724 | |
@@ -1763,8 +1732,7 @@ discard block |
||
1763 | 1732 | * |
1764 | 1733 | * @return void |
1765 | 1734 | */ |
1766 | - public function __set($var, $value) |
|
1767 | - { |
|
1735 | + public function __set($var, $value) { |
|
1768 | 1736 | $method = '_set' . ucfirst($var); |
1769 | 1737 | if ( |
1770 | 1738 | !property_exists($this, $var) |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @var bool |
104 | 104 | * @access protected |
105 | 105 | */ |
106 | - protected $formatsLoaded = false; |
|
106 | + protected $formatsLoaded = FALSE; |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Are there any fulltext files available? This also includes IIIF text annotations |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @var bool |
114 | 114 | * @access protected |
115 | 115 | */ |
116 | - protected $hasFulltext = false; |
|
116 | + protected $hasFulltext = FALSE; |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Last searched logical and physical page |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @var array |
122 | 122 | * @access protected |
123 | 123 | */ |
124 | - protected $lastSearchedPhysicalPage = ['logicalPage' => null, 'physicalPage' => null]; |
|
124 | + protected $lastSearchedPhysicalPage = ['logicalPage' => NULL, 'physicalPage' => NULL]; |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * This holds the documents location |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @var bool |
156 | 156 | * @access protected |
157 | 157 | */ |
158 | - protected $metadataArrayLoaded = false; |
|
158 | + protected $metadataArrayLoaded = FALSE; |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * The holds the total number of pages |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @var bool |
197 | 197 | * @access protected |
198 | 198 | */ |
199 | - protected $physicalStructureLoaded = false; |
|
199 | + protected $physicalStructureLoaded = FALSE; |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * This holds the PID of the document or zero if not in database |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @var bool |
222 | 222 | * @access protected |
223 | 223 | */ |
224 | - protected $ready = false; |
|
224 | + protected $ready = FALSE; |
|
225 | 225 | |
226 | 226 | /** |
227 | 227 | * The METS file's / IIIF manifest's record identifier |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @var bool |
256 | 256 | * @access protected |
257 | 257 | */ |
258 | - protected $rootIdLoaded = false; |
|
258 | + protected $rootIdLoaded = FALSE; |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * This holds the smLinks between logical and physical structMap |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @var bool |
273 | 273 | * @access protected |
274 | 274 | */ |
275 | - protected $smLinksLoaded = false; |
|
275 | + protected $smLinksLoaded = FALSE; |
|
276 | 276 | |
277 | 277 | /** |
278 | 278 | * This holds the logical structure |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @var bool |
290 | 290 | * @access protected |
291 | 291 | */ |
292 | - protected $tableOfContentsLoaded = false; |
|
292 | + protected $tableOfContentsLoaded = FALSE; |
|
293 | 293 | |
294 | 294 | /** |
295 | 295 | * This holds the document's thumbnail location |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @var bool |
307 | 307 | * @access protected |
308 | 308 | */ |
309 | - protected $thumbnailLoaded = false; |
|
309 | + protected $thumbnailLoaded = FALSE; |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * This holds the toplevel structure's @ID (METS) or the manifest's @id (IIIF) |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * |
424 | 424 | * @return \Kitodo\Dlf\Common\Document Instance of this class, either MetsDocument or IiifManifest |
425 | 425 | */ |
426 | - public static function &getInstance($uid, $pid = 0, $forceReload = false) |
|
426 | + public static function &getInstance($uid, $pid = 0, $forceReload = FALSE) |
|
427 | 427 | { |
428 | 428 | // Sanitize input. |
429 | 429 | $pid = max(intval($pid), 0); |
@@ -463,10 +463,10 @@ discard block |
||
463 | 463 | } |
464 | 464 | } |
465 | 465 | // Create new instance depending on format (METS or IIIF) ... |
466 | - $instance = null; |
|
467 | - $documentFormat = null; |
|
468 | - $xml = null; |
|
469 | - $iiif = null; |
|
466 | + $instance = NULL; |
|
467 | + $documentFormat = NULL; |
|
468 | + $xml = NULL; |
|
469 | + $iiif = NULL; |
|
470 | 470 | // Try to get document format from database |
471 | 471 | if (MathUtility::canBeInterpretedAsInteger($uid)) { |
472 | 472 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
@@ -515,17 +515,17 @@ discard block |
||
515 | 515 | @ini_set('user_agent', $extConf['useragent']); |
516 | 516 | } |
517 | 517 | $content = GeneralUtility::getUrl($location); |
518 | - if ($content !== false) { |
|
518 | + if ($content !== FALSE) { |
|
519 | 519 | $xml = Helper::getXmlFileAsString($content); |
520 | - if ($xml !== false) { |
|
520 | + if ($xml !== FALSE) { |
|
521 | 521 | /* @var $xml \SimpleXMLElement */ |
522 | 522 | $xml->registerXPathNamespace('mets', 'http://www.loc.gov/METS/'); |
523 | 523 | $xpathResult = $xml->xpath('//mets:mets'); |
524 | - $documentFormat = !empty($xpathResult) ? 'METS' : null; |
|
524 | + $documentFormat = !empty($xpathResult) ? 'METS' : NULL; |
|
525 | 525 | } else { |
526 | 526 | // Try to load file as IIIF resource instead. |
527 | - $contentAsJsonArray = json_decode($content, true); |
|
528 | - if ($contentAsJsonArray !== null) { |
|
527 | + $contentAsJsonArray = json_decode($content, TRUE); |
|
528 | + if ($contentAsJsonArray !== NULL) { |
|
529 | 529 | // Load plugin configuration. |
530 | 530 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
531 | 531 | IiifHelper::setUrlReader(IiifUrlReader::getInstance()); |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
582 | 582 | */ |
583 | - public abstract function getLogicalStructure($id, $recursive = false); |
|
583 | + public abstract function getLogicalStructure($id, $recursive = FALSE); |
|
584 | 584 | |
585 | 585 | /** |
586 | 586 | * This extracts all the metadata for a logical structure node |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | } else { |
618 | 618 | $physicalPage = 0; |
619 | 619 | foreach ($this->physicalStructureInfo as $page) { |
620 | - if (strpos($page['orderlabel'], $logicalPage) !== false) { |
|
620 | + if (strpos($page['orderlabel'], $logicalPage) !== FALSE) { |
|
621 | 621 | $this->lastSearchedPhysicalPage['logicalPage'] = $logicalPage; |
622 | 622 | $this->lastSearchedPhysicalPage['physicalPage'] = $physicalPage; |
623 | 623 | return $physicalPage; |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | if (!empty($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])) { |
669 | 669 | // Get full text file. |
670 | 670 | $fileContent = GeneralUtility::getUrl($this->getFileLocation($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])); |
671 | - if ($fileContent !== false) { |
|
671 | + if ($fileContent !== FALSE) { |
|
672 | 672 | $textFormat = $this->getTextFormat($fileContent); |
673 | 673 | } else { |
674 | 674 | $this->logger->warning('Couldn\'t load full text file for structure node @ID "' . $id . '"'); |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | * |
735 | 735 | * @return string The title of the document itself or a parent document |
736 | 736 | */ |
737 | - public static function getTitle($uid, $recursive = false) |
|
737 | + public static function getTitle($uid, $recursive = FALSE) |
|
738 | 738 | { |
739 | 739 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
740 | 740 | |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | && intval($partof) |
770 | 770 | && $partof != $uid |
771 | 771 | ) { |
772 | - $title = self::getTitle($partof, true); |
|
772 | + $title = self::getTitle($partof, TRUE); |
|
773 | 773 | } |
774 | 774 | } else { |
775 | 775 | $logger->warning('No document with UID ' . $uid . ' found or document not accessible'); |
@@ -830,12 +830,12 @@ discard block |
||
830 | 830 | return $depth; |
831 | 831 | } elseif (array_key_exists('children', $element)) { |
832 | 832 | $foundInChildren = $this->getTreeDepth($element['children'], $depth + 1, $logId); |
833 | - if ($foundInChildren !== false) { |
|
833 | + if ($foundInChildren !== FALSE) { |
|
834 | 834 | return $foundInChildren; |
835 | 835 | } |
836 | 836 | } |
837 | 837 | } |
838 | - return false; |
|
838 | + return FALSE; |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | /** |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | } else { |
913 | 913 | $this->logger->error('Invalid file location "' . $location . '" for document loading'); |
914 | 914 | } |
915 | - return false; |
|
915 | + return FALSE; |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | /** |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | 'class' => $resArray['class'] |
960 | 960 | ]; |
961 | 961 | } |
962 | - $this->formatsLoaded = true; |
|
962 | + $this->formatsLoaded = TRUE; |
|
963 | 963 | } |
964 | 964 | } |
965 | 965 | |
@@ -1002,11 +1002,11 @@ discard block |
||
1002 | 1002 | * |
1003 | 1003 | * @return bool true on success or false on failure |
1004 | 1004 | */ |
1005 | - public function save($pid = 0, $core = 0, $owner = null) |
|
1005 | + public function save($pid = 0, $core = 0, $owner = NULL) |
|
1006 | 1006 | { |
1007 | 1007 | if (\TYPO3_MODE !== 'BE') { |
1008 | 1008 | $this->logger->error('Saving a document is only allowed in the backend'); |
1009 | - return false; |
|
1009 | + return FALSE; |
|
1010 | 1010 | } |
1011 | 1011 | // Make sure $pid is a non-negative integer. |
1012 | 1012 | $pid = max(intval($pid), 0); |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | $pid = $this->pid; |
1022 | 1022 | } elseif (!$pid) { |
1023 | 1023 | $this->logger->error('Invalid PID ' . $pid . ' for document saving'); |
1024 | - return false; |
|
1024 | + return FALSE; |
|
1025 | 1025 | } |
1026 | 1026 | // Set PID for metadata definitions. |
1027 | 1027 | $this->cPid = $pid; |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | // Check for record identifier. |
1035 | 1035 | if (empty($metadata['record_id'][0])) { |
1036 | 1036 | $this->logger->error('No record identifier found to avoid duplication'); |
1037 | - return false; |
|
1037 | + return FALSE; |
|
1038 | 1038 | } |
1039 | 1039 | // Load plugin configuration. |
1040 | 1040 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | $structure = $resArray['uid']; |
1059 | 1059 | } else { |
1060 | 1060 | $this->logger->error('Could not identify document/structure type "' . $queryBuilder->expr()->literal($metadata['type'][0]) . '"'); |
1061 | - return false; |
|
1061 | + return FALSE; |
|
1062 | 1062 | } |
1063 | 1063 | $metadata['type'][0] = $structure; |
1064 | 1064 | |
@@ -1118,9 +1118,9 @@ discard block |
||
1118 | 1118 | if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) { |
1119 | 1119 | Helper::addMessage( |
1120 | 1120 | htmlspecialchars(sprintf(Helper::getMessage('flash.newCollection'), $collection, $substUid[$collNewUid])), |
1121 | - Helper::getMessage('flash.attention', true), |
|
1121 | + Helper::getMessage('flash.attention', TRUE), |
|
1122 | 1122 | \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
1123 | - true |
|
1123 | + TRUE |
|
1124 | 1124 | ); |
1125 | 1125 | } |
1126 | 1126 | } |
@@ -1171,9 +1171,9 @@ discard block |
||
1171 | 1171 | if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) { |
1172 | 1172 | Helper::addMessage( |
1173 | 1173 | htmlspecialchars(sprintf(Helper::getMessage('flash.newLibrary'), $owner, $ownerUid)), |
1174 | - Helper::getMessage('flash.attention', true), |
|
1174 | + Helper::getMessage('flash.attention', TRUE), |
|
1175 | 1175 | \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
1176 | - true |
|
1176 | + TRUE |
|
1177 | 1177 | ); |
1178 | 1178 | } |
1179 | 1179 | } |
@@ -1261,7 +1261,7 @@ discard block |
||
1261 | 1261 | 'author' => implode('; ', $metadata['author']), |
1262 | 1262 | 'year' => implode('; ', $metadata['year']), |
1263 | 1263 | 'place' => implode('; ', $metadata['place']), |
1264 | - 'thumbnail' => $this->_getThumbnail(true), |
|
1264 | + 'thumbnail' => $this->_getThumbnail(TRUE), |
|
1265 | 1265 | 'metadata' => serialize($listed), |
1266 | 1266 | 'metadata_sorting' => serialize($sortable), |
1267 | 1267 | 'structure' => $metadata['type'][0], |
@@ -1297,9 +1297,9 @@ discard block |
||
1297 | 1297 | if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) { |
1298 | 1298 | Helper::addMessage( |
1299 | 1299 | htmlspecialchars(sprintf(Helper::getMessage('flash.documentSaved'), $metadata['title'][0], $this->uid)), |
1300 | - Helper::getMessage('flash.done', true), |
|
1300 | + Helper::getMessage('flash.done', TRUE), |
|
1301 | 1301 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK, |
1302 | - true |
|
1302 | + TRUE |
|
1303 | 1303 | ); |
1304 | 1304 | } |
1305 | 1305 | // Add document to index. |
@@ -1307,7 +1307,7 @@ discard block |
||
1307 | 1307 | return Indexer::add($this, $core); |
1308 | 1308 | } else { |
1309 | 1309 | $this->logger->notice('Invalid UID "' . $core . '" for Solr core'); |
1310 | - return false; |
|
1310 | + return FALSE; |
|
1311 | 1311 | } |
1312 | 1312 | } |
1313 | 1313 | |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | ) { |
1394 | 1394 | $this->prepareMetadataArray($cPid); |
1395 | 1395 | $this->metadataArray[0] = $cPid; |
1396 | - $this->metadataArrayLoaded = true; |
|
1396 | + $this->metadataArrayLoaded = TRUE; |
|
1397 | 1397 | } |
1398 | 1398 | return $this->metadataArray; |
1399 | 1399 | } |
@@ -1502,7 +1502,7 @@ discard block |
||
1502 | 1502 | $parent = self::getInstance($this->parentId, $this->pid); |
1503 | 1503 | $this->rootId = $parent->rootId; |
1504 | 1504 | } |
1505 | - $this->rootIdLoaded = true; |
|
1505 | + $this->rootIdLoaded = TRUE; |
|
1506 | 1506 | } |
1507 | 1507 | return $this->rootId; |
1508 | 1508 | } |
@@ -1531,8 +1531,8 @@ discard block |
||
1531 | 1531 | // Is there no logical structure array yet? |
1532 | 1532 | if (!$this->tableOfContentsLoaded) { |
1533 | 1533 | // Get all logical structures. |
1534 | - $this->getLogicalStructure('', true); |
|
1535 | - $this->tableOfContentsLoaded = true; |
|
1534 | + $this->getLogicalStructure('', TRUE); |
|
1535 | + $this->tableOfContentsLoaded = TRUE; |
|
1536 | 1536 | } |
1537 | 1537 | return $this->tableOfContents; |
1538 | 1538 | } |
@@ -1548,7 +1548,7 @@ discard block |
||
1548 | 1548 | * |
1549 | 1549 | * @return string The document's thumbnail location |
1550 | 1550 | */ |
1551 | - protected abstract function _getThumbnail($forceReload = false); |
|
1551 | + protected abstract function _getThumbnail($forceReload = FALSE); |
|
1552 | 1552 | |
1553 | 1553 | /** |
1554 | 1554 | * This returns the ID of the toplevel logical structure node |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | && $this->load($uid))) { |
1630 | 1630 | // Initialize core METS object. |
1631 | 1631 | $this->init(); |
1632 | - if ($this->getDocument() !== null) { |
|
1632 | + if ($this->getDocument() !== NULL) { |
|
1633 | 1633 | // Cast to string for safety reasons. |
1634 | 1634 | $location = (string) $uid; |
1635 | 1635 | $this->establishRecordId($pid); |
@@ -1687,30 +1687,30 @@ discard block |
||
1687 | 1687 | $this->parentId = $resArray['partof']; |
1688 | 1688 | $this->thumbnail = $resArray['thumbnail']; |
1689 | 1689 | $this->location = $resArray['location']; |
1690 | - $this->thumbnailLoaded = true; |
|
1690 | + $this->thumbnailLoaded = TRUE; |
|
1691 | 1691 | // Load XML file if necessary... |
1692 | 1692 | if ( |
1693 | - $this->getDocument() === null |
|
1693 | + $this->getDocument() === NULL |
|
1694 | 1694 | && $this->load($this->location) |
1695 | 1695 | ) { |
1696 | 1696 | // ...and set some basic properties. |
1697 | 1697 | $this->init(); |
1698 | 1698 | } |
1699 | 1699 | // Do we have a METS / IIIF object now? |
1700 | - if ($this->getDocument() !== null) { |
|
1700 | + if ($this->getDocument() !== NULL) { |
|
1701 | 1701 | // Set new location if necessary. |
1702 | 1702 | if (!empty($location)) { |
1703 | 1703 | $this->location = $location; |
1704 | 1704 | } |
1705 | 1705 | // Document ready! |
1706 | - $this->ready = true; |
|
1706 | + $this->ready = TRUE; |
|
1707 | 1707 | } |
1708 | - } elseif ($this->getDocument() !== null) { |
|
1708 | + } elseif ($this->getDocument() !== NULL) { |
|
1709 | 1709 | // Set location as UID for documents not in database. |
1710 | 1710 | $this->uid = $location; |
1711 | 1711 | $this->location = $location; |
1712 | 1712 | // Document ready! |
1713 | - $this->ready = true; |
|
1713 | + $this->ready = TRUE; |
|
1714 | 1714 | } else { |
1715 | 1715 | $this->logger->error('No document with UID ' . $uid . ' found or document not accessible'); |
1716 | 1716 | } |
@@ -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 |
@@ -231,8 +226,7 @@ discard block |
||
231 | 226 | * @return void |
232 | 227 | */ |
233 | 228 | //TODO: find better way to handle logger in static class |
234 | - public static function log($message, $severity = 0) |
|
235 | - { |
|
229 | + public static function log($message, $severity = 0) { |
|
236 | 230 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
237 | 231 | |
238 | 232 | switch ($severity) { |
@@ -262,8 +256,7 @@ discard block |
||
262 | 256 | * |
263 | 257 | * @return mixed Hashed string or false on error |
264 | 258 | */ |
265 | - public static function digest($string) |
|
266 | - { |
|
259 | + public static function digest($string) { |
|
267 | 260 | if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(true))) { |
268 | 261 | self::log('OpenSSL library doesn\'t support hash algorithm', LOG_SEVERITY_ERROR); |
269 | 262 | return false; |
@@ -282,8 +275,7 @@ discard block |
||
282 | 275 | * |
283 | 276 | * @return mixed Encrypted string or false on error |
284 | 277 | */ |
285 | - public static function encrypt($string) |
|
286 | - { |
|
278 | + public static function encrypt($string) { |
|
287 | 279 | if ( |
288 | 280 | !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
289 | 281 | || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
@@ -316,8 +308,7 @@ discard block |
||
316 | 308 | * |
317 | 309 | * @return string The unqualified class name |
318 | 310 | */ |
319 | - public static function getUnqualifiedClassName($qualifiedClassname) |
|
320 | - { |
|
311 | + public static function getUnqualifiedClassName($qualifiedClassname) { |
|
321 | 312 | $nameParts = explode('\\', $qualifiedClassname); |
322 | 313 | return end($nameParts); |
323 | 314 | } |
@@ -331,8 +322,7 @@ discard block |
||
331 | 322 | * |
332 | 323 | * @return string The cleaned up string |
333 | 324 | */ |
334 | - public static function getCleanString($string) |
|
335 | - { |
|
325 | + public static function getCleanString($string) { |
|
336 | 326 | // Convert to lowercase. |
337 | 327 | $string = strtolower($string); |
338 | 328 | // Remove non-alphanumeric characters. |
@@ -353,8 +343,7 @@ discard block |
||
353 | 343 | * |
354 | 344 | * @return array Array of hook objects for the class |
355 | 345 | */ |
356 | - public static function getHookObjects($scriptRelPath) |
|
357 | - { |
|
346 | + public static function getHookObjects($scriptRelPath) { |
|
358 | 347 | $hookObjects = []; |
359 | 348 | if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) { |
360 | 349 | foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) { |
@@ -375,8 +364,7 @@ discard block |
||
375 | 364 | * |
376 | 365 | * @return string "index_name" for the given UID |
377 | 366 | */ |
378 | - public static function getIndexNameFromUid($uid, $table, $pid = -1) |
|
379 | - { |
|
367 | + public static function getIndexNameFromUid($uid, $table, $pid = -1) { |
|
380 | 368 | // Sanitize input. |
381 | 369 | $uid = max(intval($uid), 0); |
382 | 370 | if ( |
@@ -428,8 +416,7 @@ discard block |
||
428 | 416 | * |
429 | 417 | * @return string "label" for the given UID |
430 | 418 | */ |
431 | - public static function getLabelFromUid($uid, $table, $pid = -1) |
|
432 | - { |
|
419 | + public static function getLabelFromUid($uid, $table, $pid = -1) { |
|
433 | 420 | // Sanitize input. |
434 | 421 | $uid = max(intval($uid), 0); |
435 | 422 | if ( |
@@ -479,8 +466,7 @@ discard block |
||
479 | 466 | * |
480 | 467 | * @return string Localized full name of language or unchanged input |
481 | 468 | */ |
482 | - public static function getLanguageName($code) |
|
483 | - { |
|
469 | + public static function getLanguageName($code) { |
|
484 | 470 | // Analyze code and set appropriate ISO table. |
485 | 471 | $isoCode = strtolower(trim($code)); |
486 | 472 | if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
@@ -525,8 +511,7 @@ discard block |
||
525 | 511 | * |
526 | 512 | * @return string The translated string or the given key on failure |
527 | 513 | */ |
528 | - public static function getMessage($key, $hsc = false, $default = '') |
|
529 | - { |
|
514 | + public static function getMessage($key, $hsc = false, $default = '') { |
|
530 | 515 | // Set initial output to default value. |
531 | 516 | $translated = (string) $default; |
532 | 517 | // Load common messages file. |
@@ -568,8 +553,7 @@ discard block |
||
568 | 553 | * |
569 | 554 | * @return string "uid" for the given index_name |
570 | 555 | */ |
571 | - public static function getUidFromIndexName($index_name, $table, $pid = -1) |
|
572 | - { |
|
556 | + public static function getUidFromIndexName($index_name, $table, $pid = -1) { |
|
573 | 557 | if ( |
574 | 558 | !$index_name |
575 | 559 | || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores']) |
@@ -620,8 +604,7 @@ discard block |
||
620 | 604 | * |
621 | 605 | * @return string Uniform Resource Name as string |
622 | 606 | */ |
623 | - public static function getURN($base, $id) |
|
624 | - { |
|
607 | + public static function getURN($base, $id) { |
|
625 | 608 | $concordance = [ |
626 | 609 | '0' => 1, |
627 | 610 | '1' => 2, |
@@ -688,8 +671,7 @@ discard block |
||
688 | 671 | * |
689 | 672 | * @return bool Is $id a valid PPN? |
690 | 673 | */ |
691 | - public static function isPPN($id) |
|
692 | - { |
|
674 | + public static function isPPN($id) { |
|
693 | 675 | return self::checkIdentifier($id, 'PPN'); |
694 | 676 | } |
695 | 677 | |
@@ -702,8 +684,7 @@ discard block |
||
702 | 684 | * |
703 | 685 | * @return mixed Session value for given key or null on failure |
704 | 686 | */ |
705 | - public static function loadFromSession($key) |
|
706 | - { |
|
687 | + public static function loadFromSession($key) { |
|
707 | 688 | // Cast to string for security reasons. |
708 | 689 | $key = (string) $key; |
709 | 690 | if (!$key) { |
@@ -735,8 +716,7 @@ discard block |
||
735 | 716 | * |
736 | 717 | * @return array Merged array |
737 | 718 | */ |
738 | - public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) |
|
739 | - { |
|
719 | + public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) { |
|
740 | 720 | \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature); |
741 | 721 | return $original; |
742 | 722 | } |
@@ -753,8 +733,7 @@ discard block |
||
753 | 733 | * |
754 | 734 | * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
755 | 735 | */ |
756 | - public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false) |
|
757 | - { |
|
736 | + public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false) { |
|
758 | 737 | if ( |
759 | 738 | \TYPO3_MODE === 'BE' |
760 | 739 | && $GLOBALS['BE_USER']->isAdmin() |
@@ -800,8 +779,7 @@ discard block |
||
800 | 779 | * |
801 | 780 | * @return string All flash messages in the queue rendered as HTML. |
802 | 781 | */ |
803 | - public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') |
|
804 | - { |
|
782 | + public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') { |
|
805 | 783 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
806 | 784 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
807 | 785 | $flashMessages = $flashMessageQueue->getAllMessagesAndFlush(); |
@@ -820,8 +798,7 @@ discard block |
||
820 | 798 | * |
821 | 799 | * @return bool true on success, false on failure |
822 | 800 | */ |
823 | - public static function saveToSession($value, $key) |
|
824 | - { |
|
801 | + public static function saveToSession($value, $key) { |
|
825 | 802 | // Cast to string for security reasons. |
826 | 803 | $key = (string) $key; |
827 | 804 | if (!$key) { |
@@ -853,8 +830,7 @@ discard block |
||
853 | 830 | * |
854 | 831 | * @return string Localized label for $index_name |
855 | 832 | */ |
856 | - public static function translate($index_name, $table, $pid) |
|
857 | - { |
|
833 | + public static function translate($index_name, $table, $pid) { |
|
858 | 834 | // Load labels into static variable for future use. |
859 | 835 | static $labels = []; |
860 | 836 | // Sanitize input. |
@@ -977,8 +953,7 @@ discard block |
||
977 | 953 | * |
978 | 954 | * @return string Additional WHERE expression |
979 | 955 | */ |
980 | - public static function whereExpression($table, $showHidden = false) |
|
981 | - { |
|
956 | + public static function whereExpression($table, $showHidden = false) { |
|
982 | 957 | if (\TYPO3_MODE === 'FE') { |
983 | 958 | // Should we ignore the record's hidden flag? |
984 | 959 | $ignoreHide = 0; |
@@ -1007,8 +982,7 @@ discard block |
||
1007 | 982 | * |
1008 | 983 | * @access private |
1009 | 984 | */ |
1010 | - private function __construct() |
|
1011 | - { |
|
985 | + private function __construct() { |
|
1012 | 986 | // This is a static class, thus no instances should be created. |
1013 | 987 | } |
1014 | 988 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue The queue the message was added to |
76 | 76 | */ |
77 | - public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') |
|
77 | + public static function addMessage($message, $title, $severity, $session = FALSE, $queue = 'kitodo.default.flashMessages') |
|
78 | 78 | { |
79 | 79 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
80 | 80 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | $checksum = 'X'; |
117 | 117 | } |
118 | 118 | if (!preg_match('/[0-9]{8}[0-9X]{1}/i', $id)) { |
119 | - return false; |
|
119 | + return FALSE; |
|
120 | 120 | } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
121 | - return false; |
|
121 | + return FALSE; |
|
122 | 122 | } |
123 | 123 | break; |
124 | 124 | case 'ZDB': |
@@ -126,19 +126,19 @@ discard block |
||
126 | 126 | $checksum = 'X'; |
127 | 127 | } |
128 | 128 | if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) { |
129 | - return false; |
|
129 | + return FALSE; |
|
130 | 130 | } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
131 | - return false; |
|
131 | + return FALSE; |
|
132 | 132 | } |
133 | 133 | break; |
134 | 134 | case 'SWD': |
135 | 135 | $checksum = 11 - $checksum; |
136 | 136 | if (!preg_match('/[0-9]{8}-[0-9]{1}/i', $id)) { |
137 | - return false; |
|
137 | + return FALSE; |
|
138 | 138 | } elseif ($checksum == 10) { |
139 | 139 | return self::checkIdentifier(($digits + 1) . substr($id, -2, 2), 'SWD'); |
140 | 140 | } elseif (substr($id, -1, 1) != $checksum) { |
141 | - return false; |
|
141 | + return FALSE; |
|
142 | 142 | } |
143 | 143 | break; |
144 | 144 | case 'GKD': |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | $checksum = 'X'; |
148 | 148 | } |
149 | 149 | if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) { |
150 | - return false; |
|
150 | + return FALSE; |
|
151 | 151 | } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
152 | - return false; |
|
152 | + return FALSE; |
|
153 | 153 | } |
154 | 154 | break; |
155 | 155 | } |
156 | - return true; |
|
156 | + return TRUE; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -168,28 +168,28 @@ discard block |
||
168 | 168 | public static function decrypt($encrypted) |
169 | 169 | { |
170 | 170 | if ( |
171 | - !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
|
172 | - || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
|
171 | + !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(TRUE)) |
|
172 | + || !in_array(self::$hashAlgorithm, openssl_get_md_methods(TRUE)) |
|
173 | 173 | ) { |
174 | 174 | self::log('OpenSSL library doesn\'t support cipher and/or hash algorithm', LOG_SEVERITY_ERROR); |
175 | - return false; |
|
175 | + return FALSE; |
|
176 | 176 | } |
177 | 177 | if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
178 | 178 | self::log('No encryption key set in TYPO3 configuration', LOG_SEVERITY_ERROR); |
179 | - return false; |
|
179 | + return FALSE; |
|
180 | 180 | } |
181 | 181 | if ( |
182 | 182 | empty($encrypted) |
183 | 183 | || strlen($encrypted) < openssl_cipher_iv_length(self::$cipherAlgorithm) |
184 | 184 | ) { |
185 | 185 | self::log('Invalid parameters given for decryption', LOG_SEVERITY_ERROR); |
186 | - return false; |
|
186 | + return FALSE; |
|
187 | 187 | } |
188 | 188 | // Split initialisation vector and encrypted data. |
189 | 189 | $binary = base64_decode($encrypted); |
190 | 190 | $iv = substr($binary, 0, openssl_cipher_iv_length(self::$cipherAlgorithm)); |
191 | 191 | $data = substr($binary, openssl_cipher_iv_length(self::$cipherAlgorithm)); |
192 | - $key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, true); |
|
192 | + $key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, TRUE); |
|
193 | 193 | // Decrypt data. |
194 | 194 | $decrypted = openssl_decrypt($data, self::$cipherAlgorithm, $key, OPENSSL_RAW_DATA, $iv); |
195 | 195 | return $decrypted; |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | public static function getXmlFileAsString($content) |
208 | 208 | { |
209 | 209 | // Turn off libxml's error logging. |
210 | - $libxmlErrors = libxml_use_internal_errors(true); |
|
210 | + $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
211 | 211 | // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept |
212 | - $previousValueOfEntityLoader = libxml_disable_entity_loader(true); |
|
212 | + $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE); |
|
213 | 213 | // Try to load XML from file. |
214 | 214 | $xml = simplexml_load_string($content); |
215 | 215 | // reset entity loader setting |
@@ -264,9 +264,9 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public static function digest($string) |
266 | 266 | { |
267 | - if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(true))) { |
|
267 | + if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(TRUE))) { |
|
268 | 268 | self::log('OpenSSL library doesn\'t support hash algorithm', LOG_SEVERITY_ERROR); |
269 | - return false; |
|
269 | + return FALSE; |
|
270 | 270 | } |
271 | 271 | // Hash string. |
272 | 272 | $hashed = openssl_digest($string, self::$hashAlgorithm); |
@@ -285,23 +285,23 @@ discard block |
||
285 | 285 | public static function encrypt($string) |
286 | 286 | { |
287 | 287 | if ( |
288 | - !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
|
289 | - || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
|
288 | + !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(TRUE)) |
|
289 | + || !in_array(self::$hashAlgorithm, openssl_get_md_methods(TRUE)) |
|
290 | 290 | ) { |
291 | 291 | self::log('OpenSSL library doesn\'t support cipher and/or hash algorithm', LOG_SEVERITY_ERROR); |
292 | - return false; |
|
292 | + return FALSE; |
|
293 | 293 | } |
294 | 294 | if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
295 | 295 | self::log('No encryption key set in TYPO3 configuration', LOG_SEVERITY_ERROR); |
296 | - return false; |
|
296 | + return FALSE; |
|
297 | 297 | } |
298 | 298 | // Generate random initialisation vector. |
299 | 299 | $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::$cipherAlgorithm)); |
300 | - $key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, true); |
|
300 | + $key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, TRUE); |
|
301 | 301 | // Encrypt data. |
302 | 302 | $encrypted = openssl_encrypt($string, self::$cipherAlgorithm, $key, OPENSSL_RAW_DATA, $iv); |
303 | 303 | // Merge initialisation vector and encrypted data. |
304 | - if ($encrypted !== false) { |
|
304 | + if ($encrypted !== FALSE) { |
|
305 | 305 | $encrypted = base64_encode($iv . $encrypted); |
306 | 306 | } |
307 | 307 | return $encrypted; |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $lang = $GLOBALS['TSFE']->getLLL($isoCode, $iso639); |
499 | 499 | } |
500 | 500 | } elseif (\TYPO3_MODE === 'BE') { |
501 | - $iso639 = $GLOBALS['LANG']->includeLLFile($file, false, true); |
|
501 | + $iso639 = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); |
|
502 | 502 | if (!empty($iso639['default'][$isoCode])) { |
503 | 503 | $lang = $GLOBALS['LANG']->getLLL($isoCode, $iso639); |
504 | 504 | } |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @return string The translated string or the given key on failure |
527 | 527 | */ |
528 | - public static function getMessage($key, $hsc = false, $default = '') |
|
528 | + public static function getMessage($key, $hsc = FALSE, $default = '') |
|
529 | 529 | { |
530 | 530 | // Set initial output to default value. |
531 | 531 | $translated = (string) $default; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | if (\TYPO3_MODE === 'FE') { |
536 | 536 | self::$messages = $GLOBALS['TSFE']->readLLfile($file); |
537 | 537 | } elseif (\TYPO3_MODE === 'BE') { |
538 | - self::$messages = $GLOBALS['LANG']->includeLLFile($file, false, true); |
|
538 | + self::$messages = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); |
|
539 | 539 | } else { |
540 | 540 | self::log('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', LOG_SEVERITY_ERROR); |
541 | 541 | } |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * |
736 | 736 | * @return array Merged array |
737 | 737 | */ |
738 | - public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) |
|
738 | + public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = TRUE, $includeEmptyValues = TRUE, $enableUnsetFeature = TRUE) |
|
739 | 739 | { |
740 | 740 | \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature); |
741 | 741 | return $original; |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | * |
754 | 754 | * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
755 | 755 | */ |
756 | - public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false) |
|
756 | + public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = FALSE, $cmdFirst = FALSE) |
|
757 | 757 | { |
758 | 758 | if ( |
759 | 759 | \TYPO3_MODE === 'BE' |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | // Instantiate TYPO3 core engine. |
763 | 763 | $dataHandler = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class); |
764 | 764 | // We do not use workspaces and have to bypass restrictions in DataHandler. |
765 | - $dataHandler->bypassWorkspaceRestrictions = true; |
|
765 | + $dataHandler->bypassWorkspaceRestrictions = TRUE; |
|
766 | 766 | // Load data and command arrays. |
767 | 767 | $dataHandler->start($data, $cmd); |
768 | 768 | // Process command map first if default order is reversed. |
@@ -826,19 +826,19 @@ discard block |
||
826 | 826 | $key = (string) $key; |
827 | 827 | if (!$key) { |
828 | 828 | self::log('Invalid key "' . $key . '" for session data saving', LOG_SEVERITY_WARNING); |
829 | - return false; |
|
829 | + return FALSE; |
|
830 | 830 | } |
831 | 831 | // Save value in session data. |
832 | 832 | if (\TYPO3_MODE === 'FE') { |
833 | 833 | $GLOBALS['TSFE']->fe_user->setKey('ses', $key, $value); |
834 | 834 | $GLOBALS['TSFE']->fe_user->storeSessionData(); |
835 | - return true; |
|
835 | + return TRUE; |
|
836 | 836 | } elseif (\TYPO3_MODE === 'BE') { |
837 | 837 | $GLOBALS['BE_USER']->setAndSaveSessionData($key, $value); |
838 | - return true; |
|
838 | + return TRUE; |
|
839 | 839 | } else { |
840 | 840 | self::log('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', LOG_SEVERITY_ERROR); |
841 | - return false; |
|
841 | + return FALSE; |
|
842 | 842 | } |
843 | 843 | } |
844 | 844 | |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | ->where( |
885 | 885 | $queryBuilder->expr()->eq($table . '.pid', $pid), |
886 | 886 | $queryBuilder->expr()->eq($table . '.index_name', $queryBuilder->expr()->literal($index_name)), |
887 | - self::whereExpression($table, true) |
|
887 | + self::whereExpression($table, TRUE) |
|
888 | 888 | ) |
889 | 889 | ->setMaxResults(1) |
890 | 890 | ->execute(); |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | $queryBuilder->expr()->eq($table . '.pid', $pid), |
903 | 903 | $queryBuilder->expr()->eq($table . '.uid', $resArray['l18n_parent']), |
904 | 904 | $queryBuilder->expr()->eq($table . '.sys_language_uid', intval($GLOBALS['TSFE']->sys_language_content)), |
905 | - self::whereExpression($table, true) |
|
905 | + self::whereExpression($table, TRUE) |
|
906 | 906 | ) |
907 | 907 | ->setMaxResults(1) |
908 | 908 | ->execute(); |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | ->where( |
938 | 938 | $queryBuilder->expr()->eq($table . '.pid', $pid), |
939 | 939 | $additionalWhere, |
940 | - self::whereExpression($table, true) |
|
940 | + self::whereExpression($table, TRUE) |
|
941 | 941 | ) |
942 | 942 | ->setMaxResults(10000) |
943 | 943 | ->execute(); |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | * |
978 | 978 | * @return string Additional WHERE expression |
979 | 979 | */ |
980 | - public static function whereExpression($table, $showHidden = false) |
|
980 | + public static function whereExpression($table, $showHidden = FALSE) |
|
981 | 981 | { |
982 | 982 | if (\TYPO3_MODE === 'FE') { |
983 | 983 | // Should we ignore the record's hidden flag? |
@@ -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::getFullText() |
671 | 662 | */ |
672 | - public function getFullText($id) |
|
673 | - { |
|
663 | + public function getFullText($id) { |
|
674 | 664 | $fullText = ''; |
675 | 665 | |
676 | 666 | // Load fileGrps and check for full text files. |
@@ -685,8 +675,7 @@ discard block |
||
685 | 675 | * {@inheritDoc} |
686 | 676 | * @see Document::getStructureDepth() |
687 | 677 | */ |
688 | - public function getStructureDepth($logId) |
|
689 | - { |
|
678 | + public function getStructureDepth($logId) { |
|
690 | 679 | $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $logId . '"]/ancestor::*'); |
691 | 680 | if (!empty($ancestors)) { |
692 | 681 | return count($ancestors); |
@@ -699,8 +688,7 @@ discard block |
||
699 | 688 | * {@inheritDoc} |
700 | 689 | * @see \Kitodo\Dlf\Common\Document::init() |
701 | 690 | */ |
702 | - protected function init() |
|
703 | - { |
|
691 | + protected function init() { |
|
704 | 692 | // Get METS node from XML file. |
705 | 693 | $this->registerNamespaces($this->xml); |
706 | 694 | $mets = $this->xml->xpath('//mets:mets'); |
@@ -717,8 +705,7 @@ discard block |
||
717 | 705 | * {@inheritDoc} |
718 | 706 | * @see \Kitodo\Dlf\Common\Document::loadLocation() |
719 | 707 | */ |
720 | - protected function loadLocation($location) |
|
721 | - { |
|
708 | + protected function loadLocation($location) { |
|
722 | 709 | $fileResource = GeneralUtility::getUrl($location); |
723 | 710 | if ($fileResource !== false) { |
724 | 711 | $xml = Helper::getXmlFileAsString($fileResource); |
@@ -736,8 +723,7 @@ discard block |
||
736 | 723 | * {@inheritDoc} |
737 | 724 | * @see \Kitodo\Dlf\Common\Document::ensureHasFulltextIsSet() |
738 | 725 | */ |
739 | - protected function ensureHasFulltextIsSet() |
|
740 | - { |
|
726 | + protected function ensureHasFulltextIsSet() { |
|
741 | 727 | // Are the fileGrps already loaded? |
742 | 728 | if (!$this->fileGrpsLoaded) { |
743 | 729 | $this->_getFileGrps(); |
@@ -748,8 +734,7 @@ discard block |
||
748 | 734 | * {@inheritDoc} |
749 | 735 | * @see Document::getParentDocumentUid() |
750 | 736 | */ |
751 | - protected function getParentDocumentUidForSaving($pid, $core, $owner) |
|
752 | - { |
|
737 | + protected function getParentDocumentUidForSaving($pid, $core, $owner) { |
|
753 | 738 | $partof = 0; |
754 | 739 | // Get the closest ancestor of the current document which has a MPTR child. |
755 | 740 | $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $this->_getToplevelId() . '"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); |
@@ -772,8 +757,7 @@ discard block |
||
772 | 757 | * {@inheritDoc} |
773 | 758 | * @see Document::setPreloadedDocument() |
774 | 759 | */ |
775 | - protected function setPreloadedDocument($preloadedDocument) |
|
776 | - { |
|
760 | + protected function setPreloadedDocument($preloadedDocument) { |
|
777 | 761 | |
778 | 762 | if ($preloadedDocument instanceof \SimpleXMLElement) { |
779 | 763 | $this->xml = $preloadedDocument; |
@@ -786,8 +770,7 @@ discard block |
||
786 | 770 | * {@inheritDoc} |
787 | 771 | * @see Document::getDocument() |
788 | 772 | */ |
789 | - protected function getDocument() |
|
790 | - { |
|
773 | + protected function getDocument() { |
|
791 | 774 | return $this->mets; |
792 | 775 | } |
793 | 776 | |
@@ -798,8 +781,7 @@ discard block |
||
798 | 781 | * |
799 | 782 | * @return array Array of dmdSecs with their IDs as array key |
800 | 783 | */ |
801 | - protected function _getDmdSec() |
|
802 | - { |
|
784 | + protected function _getDmdSec() { |
|
803 | 785 | if (!$this->dmdSecLoaded) { |
804 | 786 | // Get available data formats. |
805 | 787 | $this->loadFormats(); |
@@ -837,8 +819,7 @@ discard block |
||
837 | 819 | * |
838 | 820 | * @return array Array of file use groups with file IDs |
839 | 821 | */ |
840 | - protected function _getFileGrps() |
|
841 | - { |
|
822 | + protected function _getFileGrps() { |
|
842 | 823 | if (!$this->fileGrpsLoaded) { |
843 | 824 | // Get configured USE attributes. |
844 | 825 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -883,8 +864,7 @@ discard block |
||
883 | 864 | * {@inheritDoc} |
884 | 865 | * @see \Kitodo\Dlf\Common\Document::prepareMetadataArray() |
885 | 866 | */ |
886 | - protected function prepareMetadataArray($cPid) |
|
887 | - { |
|
867 | + protected function prepareMetadataArray($cPid) { |
|
888 | 868 | $ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'); |
889 | 869 | // Get all logical structure nodes with metadata. |
890 | 870 | if (!empty($ids)) { |
@@ -902,8 +882,7 @@ discard block |
||
902 | 882 | * |
903 | 883 | * @return \SimpleXMLElement The XML's METS part as \SimpleXMLElement object |
904 | 884 | */ |
905 | - protected function _getMets() |
|
906 | - { |
|
885 | + protected function _getMets() { |
|
907 | 886 | return $this->mets; |
908 | 887 | } |
909 | 888 | |
@@ -911,8 +890,7 @@ discard block |
||
911 | 890 | * {@inheritDoc} |
912 | 891 | * @see \Kitodo\Dlf\Common\Document::_getPhysicalStructure() |
913 | 892 | */ |
914 | - protected function _getPhysicalStructure() |
|
915 | - { |
|
893 | + protected function _getPhysicalStructure() { |
|
916 | 894 | // Is there no physical structure array yet? |
917 | 895 | if (!$this->physicalStructureLoaded) { |
918 | 896 | // Does the document have a structMap node of type "PHYSICAL"? |
@@ -972,8 +950,7 @@ discard block |
||
972 | 950 | * {@inheritDoc} |
973 | 951 | * @see \Kitodo\Dlf\Common\Document::_getSmLinks() |
974 | 952 | */ |
975 | - protected function _getSmLinks() |
|
976 | - { |
|
953 | + protected function _getSmLinks() { |
|
977 | 954 | if (!$this->smLinksLoaded) { |
978 | 955 | $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink'); |
979 | 956 | if (!empty($smLinks)) { |
@@ -991,8 +968,7 @@ discard block |
||
991 | 968 | * {@inheritDoc} |
992 | 969 | * @see \Kitodo\Dlf\Common\Document::_getThumbnail() |
993 | 970 | */ |
994 | - protected function _getThumbnail($forceReload = false) |
|
995 | - { |
|
971 | + protected function _getThumbnail($forceReload = false) { |
|
996 | 972 | if ( |
997 | 973 | !$this->thumbnailLoaded |
998 | 974 | || $forceReload |
@@ -1071,8 +1047,7 @@ discard block |
||
1071 | 1047 | * {@inheritDoc} |
1072 | 1048 | * @see \Kitodo\Dlf\Common\Document::_getToplevelId() |
1073 | 1049 | */ |
1074 | - protected function _getToplevelId() |
|
1075 | - { |
|
1050 | + protected function _getToplevelId() { |
|
1076 | 1051 | if (empty($this->toplevelId)) { |
1077 | 1052 | // Get all logical structure nodes with metadata, but without associated METS-Pointers. |
1078 | 1053 | $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'); |
@@ -1104,8 +1079,7 @@ discard block |
||
1104 | 1079 | * |
1105 | 1080 | * @return array Properties to be serialized |
1106 | 1081 | */ |
1107 | - public function __sleep() |
|
1108 | - { |
|
1082 | + public function __sleep() { |
|
1109 | 1083 | // \SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization |
1110 | 1084 | $this->asXML = $this->xml->asXML(); |
1111 | 1085 | return ['uid', 'pid', 'recordId', 'parentId', 'asXML']; |
@@ -1118,8 +1092,7 @@ discard block |
||
1118 | 1092 | * |
1119 | 1093 | * @return string String representing the METS object |
1120 | 1094 | */ |
1121 | - public function __toString() |
|
1122 | - { |
|
1095 | + public function __toString() { |
|
1123 | 1096 | $xml = new \DOMDocument('1.0', 'utf-8'); |
1124 | 1097 | $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); |
1125 | 1098 | $xml->formatOutput = true; |
@@ -1134,8 +1107,7 @@ discard block |
||
1134 | 1107 | * |
1135 | 1108 | * @return void |
1136 | 1109 | */ |
1137 | - public function __wakeup() |
|
1138 | - { |
|
1110 | + public function __wakeup() { |
|
1139 | 1111 | $xml = Helper::getXmlFileAsString($this->asXML); |
1140 | 1112 | if ($xml !== false) { |
1141 | 1113 | $this->asXML = ''; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @var bool |
75 | 75 | * @access protected |
76 | 76 | */ |
77 | - protected $dmdSecLoaded = false; |
|
77 | + protected $dmdSecLoaded = FALSE; |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * The extension key |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @var bool |
101 | 101 | * @access protected |
102 | 102 | */ |
103 | - protected $fileGrpsLoaded = false; |
|
103 | + protected $fileGrpsLoaded = FALSE; |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * This holds the XML file's METS part as \SimpleXMLElement object |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']); |
176 | 176 | IiifHelper::setMaxThumbnailWidth($conf['iiifThumbnailWidth']); |
177 | 177 | $service = IiifHelper::loadIiifResource($fileLocation); |
178 | - if ($service !== null && $service instanceof AbstractImageService) { |
|
178 | + if ($service !== NULL && $service instanceof AbstractImageService) { |
|
179 | 179 | return $service->getImageUrl(); |
180 | 180 | } |
181 | 181 | } elseif ($fileMimeType === 'application/vnd.netfpx') { |
182 | - $baseURL = $fileLocation . (strpos($fileLocation, '?') === false ? '?' : ''); |
|
182 | + $baseURL = $fileLocation . (strpos($fileLocation, '?') === FALSE ? '?' : ''); |
|
183 | 183 | // TODO CVT is an optional IIP server capability; in theory, capabilities should be determined in the object request with '&obj=IIP-server' |
184 | 184 | return $baseURL . '&CVT=jpeg'; |
185 | 185 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * {@inheritDoc} |
227 | 227 | * @see \Kitodo\Dlf\Common\Document::getLogicalStructure() |
228 | 228 | */ |
229 | - public function getLogicalStructure($id, $recursive = false) |
|
229 | + public function getLogicalStructure($id, $recursive = FALSE) |
|
230 | 230 | { |
231 | 231 | $details = []; |
232 | 232 | // Is the requested logical unit already loaded? |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
269 | 269 | */ |
270 | - protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) |
|
270 | + protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = FALSE) |
|
271 | 271 | { |
272 | 272 | // Get attributes. |
273 | 273 | foreach ($structure->attributes() as $attribute => $value) { |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | && array_key_exists($details['id'], $this->smLinks['l2p']) |
313 | 313 | ) { |
314 | 314 | // Link logical structure to the first corresponding physical page/track. |
315 | - $details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, true)), 1); |
|
315 | + $details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, TRUE)), 1); |
|
316 | 316 | $fileGrpsThumb = GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']); |
317 | 317 | while ($fileGrpThumb = array_shift($fileGrpsThumb)) { |
318 | 318 | if (!empty($this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$fileGrpThumb])) { |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $details['children'] = []; |
357 | 357 | foreach ($structure->children('http://www.loc.gov/METS/')->div as $child) { |
358 | 358 | // Repeat for all children. |
359 | - $details['children'][] = $this->getLogicalStructureInfo($child, true); |
|
359 | + $details['children'][] = $this->getLogicalStructureInfo($child, TRUE); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | return $details; |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | if (!empty($dmdIds)) { |
426 | 426 | // Handle multiple DMDIDs separately. |
427 | 427 | $dmdIds = explode(' ', $dmdIds); |
428 | - $hasSupportedMetadata = false; |
|
428 | + $hasSupportedMetadata = FALSE; |
|
429 | 429 | } else { |
430 | 430 | // There is no dmdSec for this structure node. |
431 | 431 | return []; |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | $metadata['owner'][0] = $resArray['owner']; |
655 | 655 | } |
656 | 656 | // Extract metadata only from first supported dmdSec. |
657 | - $hasSupportedMetadata = true; |
|
657 | + $hasSupportedMetadata = TRUE; |
|
658 | 658 | break; |
659 | 659 | } |
660 | 660 | if ($hasSupportedMetadata) { |
@@ -720,16 +720,16 @@ discard block |
||
720 | 720 | protected function loadLocation($location) |
721 | 721 | { |
722 | 722 | $fileResource = GeneralUtility::getUrl($location); |
723 | - if ($fileResource !== false) { |
|
723 | + if ($fileResource !== FALSE) { |
|
724 | 724 | $xml = Helper::getXmlFileAsString($fileResource); |
725 | 725 | // Set some basic properties. |
726 | - if ($xml !== false) { |
|
726 | + if ($xml !== FALSE) { |
|
727 | 727 | $this->xml = $xml; |
728 | - return true; |
|
728 | + return TRUE; |
|
729 | 729 | } |
730 | 730 | } |
731 | 731 | $this->logger->error('Could not load XML file from "' . $location . '"'); |
732 | - return false; |
|
732 | + return FALSE; |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | /** |
@@ -777,9 +777,9 @@ discard block |
||
777 | 777 | |
778 | 778 | if ($preloadedDocument instanceof \SimpleXMLElement) { |
779 | 779 | $this->xml = $preloadedDocument; |
780 | - return true; |
|
780 | + return TRUE; |
|
781 | 781 | } |
782 | - return false; |
|
782 | + return FALSE; |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | /** |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | } |
826 | 826 | } |
827 | 827 | } |
828 | - $this->dmdSecLoaded = true; |
|
828 | + $this->dmdSecLoaded = TRUE; |
|
829 | 829 | } |
830 | 830 | return $this->dmdSec; |
831 | 831 | } |
@@ -872,9 +872,9 @@ discard block |
||
872 | 872 | !empty($extConf['fileGrpFulltext']) |
873 | 873 | && array_intersect(GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']), $this->fileGrps) !== [] |
874 | 874 | ) { |
875 | - $this->hasFulltext = true; |
|
875 | + $this->hasFulltext = TRUE; |
|
876 | 876 | } |
877 | - $this->fileGrpsLoaded = true; |
|
877 | + $this->fileGrpsLoaded = TRUE; |
|
878 | 878 | } |
879 | 879 | return $this->fileGrps; |
880 | 880 | } |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | $this->physicalStructure = array_merge($physSeq, $elements); |
964 | 964 | } |
965 | 965 | } |
966 | - $this->physicalStructureLoaded = true; |
|
966 | + $this->physicalStructureLoaded = TRUE; |
|
967 | 967 | } |
968 | 968 | return $this->physicalStructure; |
969 | 969 | } |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | $this->smLinks['p2l'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->to][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->from; |
983 | 983 | } |
984 | 984 | } |
985 | - $this->smLinksLoaded = true; |
|
985 | + $this->smLinksLoaded = TRUE; |
|
986 | 986 | } |
987 | 987 | return $this->smLinks; |
988 | 988 | } |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | * {@inheritDoc} |
992 | 992 | * @see \Kitodo\Dlf\Common\Document::_getThumbnail() |
993 | 993 | */ |
994 | - protected function _getThumbnail($forceReload = false) |
|
994 | + protected function _getThumbnail($forceReload = FALSE) |
|
995 | 995 | { |
996 | 996 | if ( |
997 | 997 | !$this->thumbnailLoaded |
@@ -1001,14 +1001,14 @@ discard block |
||
1001 | 1001 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
1002 | 1002 | if (!$cPid) { |
1003 | 1003 | $this->logger->error('Invalid PID ' . $cPid . ' for structure definitions'); |
1004 | - $this->thumbnailLoaded = true; |
|
1004 | + $this->thumbnailLoaded = TRUE; |
|
1005 | 1005 | return $this->thumbnail; |
1006 | 1006 | } |
1007 | 1007 | // Load extension configuration. |
1008 | 1008 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
1009 | 1009 | if (empty($extConf['fileGrpThumbs'])) { |
1010 | 1010 | $this->logger->warning('No fileGrp for thumbnails specified'); |
1011 | - $this->thumbnailLoaded = true; |
|
1011 | + $this->thumbnailLoaded = TRUE; |
|
1012 | 1012 | return $this->thumbnail; |
1013 | 1013 | } |
1014 | 1014 | $strctId = $this->_getToplevelId(); |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | } else { |
1063 | 1063 | $this->logger->error('No structure of type "' . $metadata['type'][0] . '" found in database'); |
1064 | 1064 | } |
1065 | - $this->thumbnailLoaded = true; |
|
1065 | + $this->thumbnailLoaded = TRUE; |
|
1066 | 1066 | } |
1067 | 1067 | return $this->thumbnail; |
1068 | 1068 | } |
@@ -1121,8 +1121,8 @@ discard block |
||
1121 | 1121 | public function __toString() |
1122 | 1122 | { |
1123 | 1123 | $xml = new \DOMDocument('1.0', 'utf-8'); |
1124 | - $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); |
|
1125 | - $xml->formatOutput = true; |
|
1124 | + $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), TRUE)); |
|
1125 | + $xml->formatOutput = TRUE; |
|
1126 | 1126 | return $xml->saveXML(); |
1127 | 1127 | } |
1128 | 1128 | |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | public function __wakeup() |
1138 | 1138 | { |
1139 | 1139 | $xml = Helper::getXmlFileAsString($this->asXML); |
1140 | - if ($xml !== false) { |
|
1140 | + if ($xml !== FALSE) { |
|
1141 | 1141 | $this->asXML = ''; |
1142 | 1142 | $this->xml = $xml; |
1143 | 1143 | // Rebuild the unserializable properties. |