@@ -48,8 +48,7 @@ discard block |
||
| 48 | 48 | * @property-read mixed $uid This holds the UID or the URL of the document |
| 49 | 49 | * @abstract |
| 50 | 50 | */ |
| 51 | -abstract class Document |
|
| 52 | -{ |
|
| 51 | +abstract class Document { |
|
| 53 | 52 | /** |
| 54 | 53 | * This holds the logger |
| 55 | 54 | * |
@@ -341,8 +340,7 @@ discard block |
||
| 341 | 340 | * |
| 342 | 341 | * @return void |
| 343 | 342 | */ |
| 344 | - public static function clearRegistry() |
|
| 345 | - { |
|
| 343 | + public static function clearRegistry() { |
|
| 346 | 344 | // Reset registry array. |
| 347 | 345 | self::$registry = []; |
| 348 | 346 | } |
@@ -607,8 +605,7 @@ discard block |
||
| 607 | 605 | * |
| 608 | 606 | * @return int The physical page number |
| 609 | 607 | */ |
| 610 | - public function getPhysicalPage($logicalPage) |
|
| 611 | - { |
|
| 608 | + public function getPhysicalPage($logicalPage) { |
|
| 612 | 609 | if ( |
| 613 | 610 | !empty($this->lastSearchedPhysicalPage['logicalPage']) |
| 614 | 611 | && $this->lastSearchedPhysicalPage['logicalPage'] == $logicalPage |
@@ -653,8 +650,7 @@ discard block |
||
| 653 | 650 | * |
| 654 | 651 | * @return string The OCR full text |
| 655 | 652 | */ |
| 656 | - protected function getFullTextFromXml($id) |
|
| 657 | - { |
|
| 653 | + protected function getFullTextFromXml($id) { |
|
| 658 | 654 | $fullText = ''; |
| 659 | 655 | // Load available text formats, ... |
| 660 | 656 | $this->loadFormats(); |
@@ -716,8 +712,7 @@ discard block |
||
| 716 | 712 | * |
| 717 | 713 | * @return string The format of the OCR full text |
| 718 | 714 | */ |
| 719 | - private function getTextFormat($fileContent) |
|
| 720 | - { |
|
| 715 | + private function getTextFormat($fileContent) { |
|
| 721 | 716 | // Get the root element's name as text format. |
| 722 | 717 | return strtoupper(Helper::getXmlFileAsString($fileContent)->getName()); |
| 723 | 718 | } |
@@ -734,8 +729,7 @@ discard block |
||
| 734 | 729 | * |
| 735 | 730 | * @return string The title of the document itself or a parent document |
| 736 | 731 | */ |
| 737 | - public static function getTitle($uid, $recursive = false) |
|
| 738 | - { |
|
| 732 | + public static function getTitle($uid, $recursive = false) { |
|
| 739 | 733 | $title = ''; |
| 740 | 734 | // Sanitize input. |
| 741 | 735 | $uid = max(intval($uid), 0); |
@@ -787,8 +781,7 @@ discard block |
||
| 787 | 781 | * |
| 788 | 782 | * @return array The logical structure node's / resource's parsed metadata array |
| 789 | 783 | */ |
| 790 | - public function getTitledata($cPid = 0) |
|
| 791 | - { |
|
| 784 | + public function getTitledata($cPid = 0) { |
|
| 792 | 785 | $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); |
| 793 | 786 | // Add information from METS structural map to titledata array. |
| 794 | 787 | if ($this instanceof MetsDocument) { |
@@ -821,8 +814,7 @@ discard block |
||
| 821 | 814 | * @return int|bool: false if structure with $logId is not a child of this substructure, |
| 822 | 815 | * or the actual depth. |
| 823 | 816 | */ |
| 824 | - protected function getTreeDepth($structure, $depth, $logId) |
|
| 825 | - { |
|
| 817 | + protected function getTreeDepth($structure, $depth, $logId) { |
|
| 826 | 818 | foreach ($structure as $element) { |
| 827 | 819 | if ($element['id'] == $logId) { |
| 828 | 820 | return $depth; |
@@ -844,8 +836,7 @@ discard block |
||
| 844 | 836 | * @param string $logId: The id of the logical structure element whose depth is requested |
| 845 | 837 | * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. |
| 846 | 838 | */ |
| 847 | - public function getStructureDepth($logId) |
|
| 848 | - { |
|
| 839 | + public function getStructureDepth($logId) { |
|
| 849 | 840 | return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId); |
| 850 | 841 | } |
| 851 | 842 | |
@@ -895,8 +886,7 @@ discard block |
||
| 895 | 886 | * |
| 896 | 887 | * @return bool true on success or false on failure |
| 897 | 888 | */ |
| 898 | - protected function load($location) |
|
| 899 | - { |
|
| 889 | + protected function load($location) { |
|
| 900 | 890 | // Load XML / JSON-LD file. |
| 901 | 891 | if (GeneralUtility::isValidUrl($location)) { |
| 902 | 892 | // Load extension configuration |
@@ -929,8 +919,7 @@ discard block |
||
| 929 | 919 | * |
| 930 | 920 | * @return void |
| 931 | 921 | */ |
| 932 | - protected function loadFormats() |
|
| 933 | - { |
|
| 922 | + protected function loadFormats() { |
|
| 934 | 923 | if (!$this->formatsLoaded) { |
| 935 | 924 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 936 | 925 | ->getQueryBuilderForTable('tx_dlf_formats'); |
@@ -970,8 +959,7 @@ discard block |
||
| 970 | 959 | * |
| 971 | 960 | * @return void |
| 972 | 961 | */ |
| 973 | - public function registerNamespaces(&$obj) |
|
| 974 | - { |
|
| 962 | + public function registerNamespaces(&$obj) { |
|
| 975 | 963 | // TODO Check usage. XML specific method does not seem to be used anywhere outside this class within the project, but it is public and may be used by extensions. |
| 976 | 964 | $this->loadFormats(); |
| 977 | 965 | // Do we have a \SimpleXMLElement or \DOMXPath object? |
@@ -1000,8 +988,7 @@ discard block |
||
| 1000 | 988 | * |
| 1001 | 989 | * @return bool true on success or false on failure |
| 1002 | 990 | */ |
| 1003 | - public function save($pid = 0, $core = 0, $owner = null) |
|
| 1004 | - { |
|
| 991 | + public function save($pid = 0, $core = 0, $owner = null) { |
|
| 1005 | 992 | if (\TYPO3_MODE !== 'BE') { |
| 1006 | 993 | $this->logger->error('Saving a document is only allowed in the backend'); |
| 1007 | 994 | return false; |
@@ -1329,8 +1316,7 @@ discard block |
||
| 1329 | 1316 | * |
| 1330 | 1317 | * @return int The PID of the metadata definitions |
| 1331 | 1318 | */ |
| 1332 | - protected function _getCPid() |
|
| 1333 | - { |
|
| 1319 | + protected function _getCPid() { |
|
| 1334 | 1320 | return $this->cPid; |
| 1335 | 1321 | } |
| 1336 | 1322 | |
@@ -1341,8 +1327,7 @@ discard block |
||
| 1341 | 1327 | * |
| 1342 | 1328 | * @return bool Are there any fulltext files available? |
| 1343 | 1329 | */ |
| 1344 | - protected function _getHasFulltext() |
|
| 1345 | - { |
|
| 1330 | + protected function _getHasFulltext() { |
|
| 1346 | 1331 | $this->ensureHasFulltextIsSet(); |
| 1347 | 1332 | return $this->hasFulltext; |
| 1348 | 1333 | } |
@@ -1354,8 +1339,7 @@ discard block |
||
| 1354 | 1339 | * |
| 1355 | 1340 | * @return string The location of the document |
| 1356 | 1341 | */ |
| 1357 | - protected function _getLocation() |
|
| 1358 | - { |
|
| 1342 | + protected function _getLocation() { |
|
| 1359 | 1343 | return $this->location; |
| 1360 | 1344 | } |
| 1361 | 1345 | |
@@ -1377,8 +1361,7 @@ discard block |
||
| 1377 | 1361 | * |
| 1378 | 1362 | * @return array Array of metadata with their corresponding logical structure node ID as key |
| 1379 | 1363 | */ |
| 1380 | - protected function _getMetadataArray() |
|
| 1381 | - { |
|
| 1364 | + protected function _getMetadataArray() { |
|
| 1382 | 1365 | // Set metadata definitions' PID. |
| 1383 | 1366 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
| 1384 | 1367 | if (!$cPid) { |
@@ -1403,8 +1386,7 @@ discard block |
||
| 1403 | 1386 | * |
| 1404 | 1387 | * @return int The total number of pages and/or tracks |
| 1405 | 1388 | */ |
| 1406 | - protected function _getNumPages() |
|
| 1407 | - { |
|
| 1389 | + protected function _getNumPages() { |
|
| 1408 | 1390 | $this->_getPhysicalStructure(); |
| 1409 | 1391 | return $this->numPages; |
| 1410 | 1392 | } |
@@ -1416,8 +1398,7 @@ discard block |
||
| 1416 | 1398 | * |
| 1417 | 1399 | * @return int The UID of the parent document or zero if not applicable |
| 1418 | 1400 | */ |
| 1419 | - protected function _getParentId() |
|
| 1420 | - { |
|
| 1401 | + protected function _getParentId() { |
|
| 1421 | 1402 | return $this->parentId; |
| 1422 | 1403 | } |
| 1423 | 1404 | |
@@ -1440,8 +1421,7 @@ discard block |
||
| 1440 | 1421 | * |
| 1441 | 1422 | * @return array Array of elements' type, label and file representations ordered by @ID attribute / Canvas order |
| 1442 | 1423 | */ |
| 1443 | - protected function _getPhysicalStructureInfo() |
|
| 1444 | - { |
|
| 1424 | + protected function _getPhysicalStructureInfo() { |
|
| 1445 | 1425 | // Is there no physical structure array yet? |
| 1446 | 1426 | if (!$this->physicalStructureLoaded) { |
| 1447 | 1427 | // Build physical structure array. |
@@ -1457,8 +1437,7 @@ discard block |
||
| 1457 | 1437 | * |
| 1458 | 1438 | * @return int The PID of the document or zero if not in database |
| 1459 | 1439 | */ |
| 1460 | - protected function _getPid() |
|
| 1461 | - { |
|
| 1440 | + protected function _getPid() { |
|
| 1462 | 1441 | return $this->pid; |
| 1463 | 1442 | } |
| 1464 | 1443 | |
@@ -1469,8 +1448,7 @@ discard block |
||
| 1469 | 1448 | * |
| 1470 | 1449 | * @return bool Is the document instantiated successfully? |
| 1471 | 1450 | */ |
| 1472 | - protected function _getReady() |
|
| 1473 | - { |
|
| 1451 | + protected function _getReady() { |
|
| 1474 | 1452 | return $this->ready; |
| 1475 | 1453 | } |
| 1476 | 1454 | |
@@ -1481,8 +1459,7 @@ discard block |
||
| 1481 | 1459 | * |
| 1482 | 1460 | * @return mixed The METS file's / IIIF manifest's record identifier |
| 1483 | 1461 | */ |
| 1484 | - protected function _getRecordId() |
|
| 1485 | - { |
|
| 1462 | + protected function _getRecordId() { |
|
| 1486 | 1463 | return $this->recordId; |
| 1487 | 1464 | } |
| 1488 | 1465 | |
@@ -1493,8 +1470,7 @@ discard block |
||
| 1493 | 1470 | * |
| 1494 | 1471 | * @return int The UID of the root document or zero if not applicable |
| 1495 | 1472 | */ |
| 1496 | - protected function _getRootId() |
|
| 1497 | - { |
|
| 1473 | + protected function _getRootId() { |
|
| 1498 | 1474 | if (!$this->rootIdLoaded) { |
| 1499 | 1475 | if ($this->parentId) { |
| 1500 | 1476 | $parent = self::getInstance($this->parentId, $this->pid); |
@@ -1524,8 +1500,7 @@ discard block |
||
| 1524 | 1500 | * |
| 1525 | 1501 | * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved |
| 1526 | 1502 | */ |
| 1527 | - protected function _getTableOfContents() |
|
| 1528 | - { |
|
| 1503 | + protected function _getTableOfContents() { |
|
| 1529 | 1504 | // Is there no logical structure array yet? |
| 1530 | 1505 | if (!$this->tableOfContentsLoaded) { |
| 1531 | 1506 | // Get all logical structures. |
@@ -1566,8 +1541,7 @@ discard block |
||
| 1566 | 1541 | * |
| 1567 | 1542 | * @return mixed The UID or the URL of the document |
| 1568 | 1543 | */ |
| 1569 | - protected function _getUid() |
|
| 1570 | - { |
|
| 1544 | + protected function _getUid() { |
|
| 1571 | 1545 | return $this->uid; |
| 1572 | 1546 | } |
| 1573 | 1547 | |
@@ -1580,8 +1554,7 @@ discard block |
||
| 1580 | 1554 | * |
| 1581 | 1555 | * @return void |
| 1582 | 1556 | */ |
| 1583 | - protected function _setCPid($value) |
|
| 1584 | - { |
|
| 1557 | + protected function _setCPid($value) { |
|
| 1585 | 1558 | $this->cPid = max(intval($value), 0); |
| 1586 | 1559 | } |
| 1587 | 1560 | |
@@ -1592,8 +1565,7 @@ discard block |
||
| 1592 | 1565 | * |
| 1593 | 1566 | * @return void |
| 1594 | 1567 | */ |
| 1595 | - protected function __clone() |
|
| 1596 | - { |
|
| 1568 | + protected function __clone() { |
|
| 1597 | 1569 | // This method is defined as protected because singleton objects should not be cloned. |
| 1598 | 1570 | } |
| 1599 | 1571 | |
@@ -1610,8 +1582,7 @@ discard block |
||
| 1610 | 1582 | * |
| 1611 | 1583 | * @return void |
| 1612 | 1584 | */ |
| 1613 | - protected function __construct($uid, $pid, $preloadedDocument) |
|
| 1614 | - { |
|
| 1585 | + protected function __construct($uid, $pid, $preloadedDocument) { |
|
| 1615 | 1586 | $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(); |
| 1616 | 1587 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 1617 | 1588 | ->getQueryBuilderForTable('tx_dlf_documents'); |
@@ -1724,8 +1695,7 @@ discard block |
||
| 1724 | 1695 | * |
| 1725 | 1696 | * @return mixed Value of $this->$var |
| 1726 | 1697 | */ |
| 1727 | - public function __get($var) |
|
| 1728 | - { |
|
| 1698 | + public function __get($var) { |
|
| 1729 | 1699 | $method = '_get' . ucfirst($var); |
| 1730 | 1700 | if ( |
| 1731 | 1701 | !property_exists($this, $var) |
@@ -1747,8 +1717,7 @@ discard block |
||
| 1747 | 1717 | * |
| 1748 | 1718 | * @return bool true if variable is set and not empty, false otherwise |
| 1749 | 1719 | */ |
| 1750 | - public function __isset($var) |
|
| 1751 | - { |
|
| 1720 | + public function __isset($var) { |
|
| 1752 | 1721 | return !empty($this->__get($var)); |
| 1753 | 1722 | } |
| 1754 | 1723 | |
@@ -1762,8 +1731,7 @@ discard block |
||
| 1762 | 1731 | * |
| 1763 | 1732 | * @return void |
| 1764 | 1733 | */ |
| 1765 | - public function __set($var, $value) |
|
| 1766 | - { |
|
| 1734 | + public function __set($var, $value) { |
|
| 1767 | 1735 | $method = '_set' . ucfirst($var); |
| 1768 | 1736 | if ( |
| 1769 | 1737 | !property_exists($this, $var) |