@@ -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 | $xml = Helper::getXmlFileAsString($fileContent); |
| 722 | 717 | |
| 723 | 718 | if ($xml !== false) { |
@@ -740,8 +735,7 @@ discard block |
||
| 740 | 735 | * |
| 741 | 736 | * @return string The title of the document itself or a parent document |
| 742 | 737 | */ |
| 743 | - public static function getTitle($uid, $recursive = false) |
|
| 744 | - { |
|
| 738 | + public static function getTitle($uid, $recursive = false) { |
|
| 745 | 739 | $title = ''; |
| 746 | 740 | // Sanitize input. |
| 747 | 741 | $uid = max(intval($uid), 0); |
@@ -793,8 +787,7 @@ discard block |
||
| 793 | 787 | * |
| 794 | 788 | * @return array The logical structure node's / resource's parsed metadata array |
| 795 | 789 | */ |
| 796 | - public function getTitledata($cPid = 0) |
|
| 797 | - { |
|
| 790 | + public function getTitledata($cPid = 0) { |
|
| 798 | 791 | $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); |
| 799 | 792 | // Add information from METS structural map to titledata array. |
| 800 | 793 | if ($this instanceof MetsDocument) { |
@@ -827,8 +820,7 @@ discard block |
||
| 827 | 820 | * @return int|bool: false if structure with $logId is not a child of this substructure, |
| 828 | 821 | * or the actual depth. |
| 829 | 822 | */ |
| 830 | - protected function getTreeDepth($structure, $depth, $logId) |
|
| 831 | - { |
|
| 823 | + protected function getTreeDepth($structure, $depth, $logId) { |
|
| 832 | 824 | foreach ($structure as $element) { |
| 833 | 825 | if ($element['id'] == $logId) { |
| 834 | 826 | return $depth; |
@@ -850,8 +842,7 @@ discard block |
||
| 850 | 842 | * @param string $logId: The id of the logical structure element whose depth is requested |
| 851 | 843 | * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. |
| 852 | 844 | */ |
| 853 | - public function getStructureDepth($logId) |
|
| 854 | - { |
|
| 845 | + public function getStructureDepth($logId) { |
|
| 855 | 846 | return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId); |
| 856 | 847 | } |
| 857 | 848 | |
@@ -901,8 +892,7 @@ discard block |
||
| 901 | 892 | * |
| 902 | 893 | * @return bool true on success or false on failure |
| 903 | 894 | */ |
| 904 | - protected function load($location) |
|
| 905 | - { |
|
| 895 | + protected function load($location) { |
|
| 906 | 896 | // Load XML / JSON-LD file. |
| 907 | 897 | if (GeneralUtility::isValidUrl($location)) { |
| 908 | 898 | // Load extension configuration |
@@ -935,8 +925,7 @@ discard block |
||
| 935 | 925 | * |
| 936 | 926 | * @return void |
| 937 | 927 | */ |
| 938 | - protected function loadFormats() |
|
| 939 | - { |
|
| 928 | + protected function loadFormats() { |
|
| 940 | 929 | if (!$this->formatsLoaded) { |
| 941 | 930 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 942 | 931 | ->getQueryBuilderForTable('tx_dlf_formats'); |
@@ -976,8 +965,7 @@ discard block |
||
| 976 | 965 | * |
| 977 | 966 | * @return void |
| 978 | 967 | */ |
| 979 | - public function registerNamespaces(&$obj) |
|
| 980 | - { |
|
| 968 | + public function registerNamespaces(&$obj) { |
|
| 981 | 969 | // 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. |
| 982 | 970 | $this->loadFormats(); |
| 983 | 971 | // Do we have a \SimpleXMLElement or \DOMXPath object? |
@@ -1006,8 +994,7 @@ discard block |
||
| 1006 | 994 | * |
| 1007 | 995 | * @return bool true on success or false on failure |
| 1008 | 996 | */ |
| 1009 | - public function save($pid = 0, $core = 0, $owner = null) |
|
| 1010 | - { |
|
| 997 | + public function save($pid = 0, $core = 0, $owner = null) { |
|
| 1011 | 998 | if (\TYPO3_MODE !== 'BE') { |
| 1012 | 999 | $this->logger->error('Saving a document is only allowed in the backend'); |
| 1013 | 1000 | return false; |
@@ -1335,8 +1322,7 @@ discard block |
||
| 1335 | 1322 | * |
| 1336 | 1323 | * @return int The PID of the metadata definitions |
| 1337 | 1324 | */ |
| 1338 | - protected function _getCPid() |
|
| 1339 | - { |
|
| 1325 | + protected function _getCPid() { |
|
| 1340 | 1326 | return $this->cPid; |
| 1341 | 1327 | } |
| 1342 | 1328 | |
@@ -1347,8 +1333,7 @@ discard block |
||
| 1347 | 1333 | * |
| 1348 | 1334 | * @return bool Are there any fulltext files available? |
| 1349 | 1335 | */ |
| 1350 | - protected function _getHasFulltext() |
|
| 1351 | - { |
|
| 1336 | + protected function _getHasFulltext() { |
|
| 1352 | 1337 | $this->ensureHasFulltextIsSet(); |
| 1353 | 1338 | return $this->hasFulltext; |
| 1354 | 1339 | } |
@@ -1360,8 +1345,7 @@ discard block |
||
| 1360 | 1345 | * |
| 1361 | 1346 | * @return string The location of the document |
| 1362 | 1347 | */ |
| 1363 | - protected function _getLocation() |
|
| 1364 | - { |
|
| 1348 | + protected function _getLocation() { |
|
| 1365 | 1349 | return $this->location; |
| 1366 | 1350 | } |
| 1367 | 1351 | |
@@ -1383,8 +1367,7 @@ discard block |
||
| 1383 | 1367 | * |
| 1384 | 1368 | * @return array Array of metadata with their corresponding logical structure node ID as key |
| 1385 | 1369 | */ |
| 1386 | - protected function _getMetadataArray() |
|
| 1387 | - { |
|
| 1370 | + protected function _getMetadataArray() { |
|
| 1388 | 1371 | // Set metadata definitions' PID. |
| 1389 | 1372 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
| 1390 | 1373 | if (!$cPid) { |
@@ -1409,8 +1392,7 @@ discard block |
||
| 1409 | 1392 | * |
| 1410 | 1393 | * @return int The total number of pages and/or tracks |
| 1411 | 1394 | */ |
| 1412 | - protected function _getNumPages() |
|
| 1413 | - { |
|
| 1395 | + protected function _getNumPages() { |
|
| 1414 | 1396 | $this->_getPhysicalStructure(); |
| 1415 | 1397 | return $this->numPages; |
| 1416 | 1398 | } |
@@ -1422,8 +1404,7 @@ discard block |
||
| 1422 | 1404 | * |
| 1423 | 1405 | * @return int The UID of the parent document or zero if not applicable |
| 1424 | 1406 | */ |
| 1425 | - protected function _getParentId() |
|
| 1426 | - { |
|
| 1407 | + protected function _getParentId() { |
|
| 1427 | 1408 | return $this->parentId; |
| 1428 | 1409 | } |
| 1429 | 1410 | |
@@ -1446,8 +1427,7 @@ discard block |
||
| 1446 | 1427 | * |
| 1447 | 1428 | * @return array Array of elements' type, label and file representations ordered by @ID attribute / Canvas order |
| 1448 | 1429 | */ |
| 1449 | - protected function _getPhysicalStructureInfo() |
|
| 1450 | - { |
|
| 1430 | + protected function _getPhysicalStructureInfo() { |
|
| 1451 | 1431 | // Is there no physical structure array yet? |
| 1452 | 1432 | if (!$this->physicalStructureLoaded) { |
| 1453 | 1433 | // Build physical structure array. |
@@ -1463,8 +1443,7 @@ discard block |
||
| 1463 | 1443 | * |
| 1464 | 1444 | * @return int The PID of the document or zero if not in database |
| 1465 | 1445 | */ |
| 1466 | - protected function _getPid() |
|
| 1467 | - { |
|
| 1446 | + protected function _getPid() { |
|
| 1468 | 1447 | return $this->pid; |
| 1469 | 1448 | } |
| 1470 | 1449 | |
@@ -1475,8 +1454,7 @@ discard block |
||
| 1475 | 1454 | * |
| 1476 | 1455 | * @return bool Is the document instantiated successfully? |
| 1477 | 1456 | */ |
| 1478 | - protected function _getReady() |
|
| 1479 | - { |
|
| 1457 | + protected function _getReady() { |
|
| 1480 | 1458 | return $this->ready; |
| 1481 | 1459 | } |
| 1482 | 1460 | |
@@ -1487,8 +1465,7 @@ discard block |
||
| 1487 | 1465 | * |
| 1488 | 1466 | * @return mixed The METS file's / IIIF manifest's record identifier |
| 1489 | 1467 | */ |
| 1490 | - protected function _getRecordId() |
|
| 1491 | - { |
|
| 1468 | + protected function _getRecordId() { |
|
| 1492 | 1469 | return $this->recordId; |
| 1493 | 1470 | } |
| 1494 | 1471 | |
@@ -1499,8 +1476,7 @@ discard block |
||
| 1499 | 1476 | * |
| 1500 | 1477 | * @return int The UID of the root document or zero if not applicable |
| 1501 | 1478 | */ |
| 1502 | - protected function _getRootId() |
|
| 1503 | - { |
|
| 1479 | + protected function _getRootId() { |
|
| 1504 | 1480 | if (!$this->rootIdLoaded) { |
| 1505 | 1481 | if ($this->parentId) { |
| 1506 | 1482 | $parent = self::getInstance($this->parentId, $this->pid); |
@@ -1530,8 +1506,7 @@ discard block |
||
| 1530 | 1506 | * |
| 1531 | 1507 | * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved |
| 1532 | 1508 | */ |
| 1533 | - protected function _getTableOfContents() |
|
| 1534 | - { |
|
| 1509 | + protected function _getTableOfContents() { |
|
| 1535 | 1510 | // Is there no logical structure array yet? |
| 1536 | 1511 | if (!$this->tableOfContentsLoaded) { |
| 1537 | 1512 | // Get all logical structures. |
@@ -1572,8 +1547,7 @@ discard block |
||
| 1572 | 1547 | * |
| 1573 | 1548 | * @return mixed The UID or the URL of the document |
| 1574 | 1549 | */ |
| 1575 | - protected function _getUid() |
|
| 1576 | - { |
|
| 1550 | + protected function _getUid() { |
|
| 1577 | 1551 | return $this->uid; |
| 1578 | 1552 | } |
| 1579 | 1553 | |
@@ -1586,8 +1560,7 @@ discard block |
||
| 1586 | 1560 | * |
| 1587 | 1561 | * @return void |
| 1588 | 1562 | */ |
| 1589 | - protected function _setCPid($value) |
|
| 1590 | - { |
|
| 1563 | + protected function _setCPid($value) { |
|
| 1591 | 1564 | $this->cPid = max(intval($value), 0); |
| 1592 | 1565 | } |
| 1593 | 1566 | |
@@ -1598,8 +1571,7 @@ discard block |
||
| 1598 | 1571 | * |
| 1599 | 1572 | * @return void |
| 1600 | 1573 | */ |
| 1601 | - protected function __clone() |
|
| 1602 | - { |
|
| 1574 | + protected function __clone() { |
|
| 1603 | 1575 | // This method is defined as protected because singleton objects should not be cloned. |
| 1604 | 1576 | } |
| 1605 | 1577 | |
@@ -1616,8 +1588,7 @@ discard block |
||
| 1616 | 1588 | * |
| 1617 | 1589 | * @return void |
| 1618 | 1590 | */ |
| 1619 | - protected function __construct($uid, $pid, $preloadedDocument) |
|
| 1620 | - { |
|
| 1591 | + protected function __construct($uid, $pid, $preloadedDocument) { |
|
| 1621 | 1592 | $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(); |
| 1622 | 1593 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 1623 | 1594 | ->getQueryBuilderForTable('tx_dlf_documents'); |
@@ -1730,8 +1701,7 @@ discard block |
||
| 1730 | 1701 | * |
| 1731 | 1702 | * @return mixed Value of $this->$var |
| 1732 | 1703 | */ |
| 1733 | - public function __get($var) |
|
| 1734 | - { |
|
| 1704 | + public function __get($var) { |
|
| 1735 | 1705 | $method = '_get' . ucfirst($var); |
| 1736 | 1706 | if ( |
| 1737 | 1707 | !property_exists($this, $var) |
@@ -1753,8 +1723,7 @@ discard block |
||
| 1753 | 1723 | * |
| 1754 | 1724 | * @return bool true if variable is set and not empty, false otherwise |
| 1755 | 1725 | */ |
| 1756 | - public function __isset($var) |
|
| 1757 | - { |
|
| 1726 | + public function __isset($var) { |
|
| 1758 | 1727 | return !empty($this->__get($var)); |
| 1759 | 1728 | } |
| 1760 | 1729 | |
@@ -1768,8 +1737,7 @@ discard block |
||
| 1768 | 1737 | * |
| 1769 | 1738 | * @return void |
| 1770 | 1739 | */ |
| 1771 | - public function __set($var, $value) |
|
| 1772 | - { |
|
| 1740 | + public function __set($var, $value) { |
|
| 1773 | 1741 | $method = '_set' . ucfirst($var); |
| 1774 | 1742 | if ( |
| 1775 | 1743 | !property_exists($this, $var) |