@@ -26,8 +26,7 @@ discard block |
||
| 26 | 26 | * @subpackage dlf |
| 27 | 27 | * @access public |
| 28 | 28 | */ |
| 29 | -class SearchInDocumentTool extends \Kitodo\Dlf\Common\AbstractPlugin |
|
| 30 | -{ |
|
| 29 | +class SearchInDocumentTool extends \Kitodo\Dlf\Common\AbstractPlugin { |
|
| 31 | 30 | public $scriptRelPath = 'Classes/Plugin/Tools/SearchInDocumentTool.php'; |
| 32 | 31 | |
| 33 | 32 | /** |
@@ -40,8 +39,7 @@ discard block |
||
| 40 | 39 | * |
| 41 | 40 | * @return string The content that is displayed on the website |
| 42 | 41 | */ |
| 43 | - public function main($content, $conf) |
|
| 44 | - { |
|
| 42 | + public function main($content, $conf) { |
|
| 45 | 43 | |
| 46 | 44 | $this->init($conf); |
| 47 | 45 | |
@@ -126,8 +124,7 @@ discard block |
||
| 126 | 124 | * |
| 127 | 125 | * @return string with action url for search form |
| 128 | 126 | */ |
| 129 | - protected function getActionUrl() |
|
| 130 | - { |
|
| 127 | + protected function getActionUrl() { |
|
| 131 | 128 | // Configure @action URL for form. |
| 132 | 129 | $linkConf = [ |
| 133 | 130 | 'parameter' => $GLOBALS['TSFE']->id, |
@@ -152,8 +149,7 @@ discard block |
||
| 152 | 149 | * |
| 153 | 150 | * @return string with current document id |
| 154 | 151 | */ |
| 155 | - protected function getCurrentDocumentId() |
|
| 156 | - { |
|
| 152 | + protected function getCurrentDocumentId() { |
|
| 157 | 153 | $id = $this->doc->uid; |
| 158 | 154 | |
| 159 | 155 | // example: https://host.de/items/*id*/record |
@@ -177,8 +173,7 @@ discard block |
||
| 177 | 173 | * |
| 178 | 174 | * @return string with encrypted core name |
| 179 | 175 | */ |
| 180 | - protected function getEncryptedCoreName() |
|
| 181 | - { |
|
| 176 | + protected function getEncryptedCoreName() { |
|
| 182 | 177 | // Get core name. |
| 183 | 178 | $name = Helper::getIndexNameFromUid($this->conf['solrcore'], 'tx_dlf_solrcores'); |
| 184 | 179 | // Encrypt core name. |
@@ -84,14 +84,14 @@ |
||
| 84 | 84 | } |
| 85 | 85 | if (!empty($fullTextFile)) { |
| 86 | 86 | $markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="' |
| 87 | - . 'fulltext:' . htmlspecialchars($this->pi_getLL('fulltext', '')) |
|
| 88 | - . ';fulltext-on:' . htmlspecialchars($this->pi_getLL('fulltext-on', '')) |
|
| 89 | - . ';fulltext-off:' . htmlspecialchars($this->pi_getLL('fulltext-off', '')) |
|
| 90 | - . ';activate-full-text-initially:' . MathUtility::forceIntegerInRange($this->conf['activateFullTextInitially'], 0, 1, 0) |
|
| 91 | - . ';full-text-scroll-element:' . $this->conf['fullTextScrollElement'] |
|
| 87 | + . 'fulltext:'.htmlspecialchars($this->pi_getLL('fulltext', '')) |
|
| 88 | + . ';fulltext-on:'.htmlspecialchars($this->pi_getLL('fulltext-on', '')) |
|
| 89 | + . ';fulltext-off:'.htmlspecialchars($this->pi_getLL('fulltext-off', '')) |
|
| 90 | + . ';activate-full-text-initially:'.MathUtility::forceIntegerInRange($this->conf['activateFullTextInitially'], 0, 1, 0) |
|
| 91 | + . ';full-text-scroll-element:'.$this->conf['fullTextScrollElement'] |
|
| 92 | 92 | . '"> </a>'; |
| 93 | 93 | } else { |
| 94 | - $markerArray['###FULLTEXT_SELECT###'] = '<span class="no-fulltext">' . htmlspecialchars($this->pi_getLL('fulltext-not-available', '')) . '</span>'; |
|
| 94 | + $markerArray['###FULLTEXT_SELECT###'] = '<span class="no-fulltext">'.htmlspecialchars($this->pi_getLL('fulltext-not-available', '')).'</span>'; |
|
| 95 | 95 | } |
| 96 | 96 | $content .= $this->templateService->substituteMarkerArray($this->template, $markerArray); |
| 97 | 97 | return $this->pi_wrapInBaseClass($content); |
@@ -120,7 +120,7 @@ |
||
| 120 | 120 | */ |
| 121 | 121 | private function getQuery($fields, $parameters) |
| 122 | 122 | { |
| 123 | - return $fields['fulltext'] . ':(' . Solr::escapeQuery((string) $parameters['q']) . ') AND ' . $fields['uid'] . ':' . $this->getUid($parameters['uid']); |
|
| 123 | + return $fields['fulltext'].':('.Solr::escapeQuery((string) $parameters['q']).') AND '.$fields['uid'].':'.$this->getUid($parameters['uid']); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -28,16 +28,14 @@ discard block |
||
| 28 | 28 | * @subpackage dlf |
| 29 | 29 | * @access public |
| 30 | 30 | */ |
| 31 | -class SearchInDocument |
|
| 32 | -{ |
|
| 31 | +class SearchInDocument { |
|
| 33 | 32 | /** |
| 34 | 33 | * The main method of the eID script |
| 35 | 34 | * |
| 36 | 35 | * @param ServerRequestInterface $request |
| 37 | 36 | * @return ResponseInterface JSON response of search suggestions |
| 38 | 37 | */ |
| 39 | - public function main(ServerRequestInterface $request) |
|
| 40 | - { |
|
| 38 | + public function main(ServerRequestInterface $request) { |
|
| 41 | 39 | $output = [ |
| 42 | 40 | 'documents' => [], |
| 43 | 41 | 'numFound' => 0 |
@@ -118,8 +116,7 @@ discard block |
||
| 118 | 116 | * |
| 119 | 117 | * @return string SOLR query |
| 120 | 118 | */ |
| 121 | - private function getQuery($fields, $parameters) |
|
| 122 | - { |
|
| 119 | + private function getQuery($fields, $parameters) { |
|
| 123 | 120 | return $fields['fulltext'] . ':(' . Solr::escapeQuery((string) $parameters['q']) . ') AND ' . $fields['uid'] . ':' . $this->getUid($parameters['uid']); |
| 124 | 121 | } |
| 125 | 122 | |
@@ -133,8 +130,7 @@ discard block |
||
| 133 | 130 | * |
| 134 | 131 | * @return int|string uid of the document |
| 135 | 132 | */ |
| 136 | - private function getUid($uid) |
|
| 137 | - { |
|
| 133 | + private function getUid($uid) { |
|
| 138 | 134 | return is_numeric($uid) ? intval($uid) : $uid; |
| 139 | 135 | } |
| 140 | 136 | } |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | ]; |
| 45 | 45 | // Get input parameters and decrypt core name. |
| 46 | 46 | $parameters = $request->getParsedBody(); |
| 47 | - if ($parameters === null) { |
|
| 47 | + if ($parameters === NULL) { |
|
| 48 | 48 | throw new \InvalidArgumentException('No parameters passed!', 1632322297); |
| 49 | 49 | } |
| 50 | 50 | $encrypted = (string) $parameters['encrypted']; |
@@ -681,14 +681,14 @@ discard block |
||
| 681 | 681 | if ($fileContent !== false) { |
| 682 | 682 | $textFormat = $this->getTextFormat($fileContent); |
| 683 | 683 | } else { |
| 684 | - $this->logger->warning('Couldn\'t load full text file for structure node @ID "' . $id . '"'); |
|
| 684 | + $this->logger->warning('Couldn\'t load full text file for structure node @ID "'.$id.'"'); |
|
| 685 | 685 | return $fullText; |
| 686 | 686 | } |
| 687 | 687 | break; |
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | } else { |
| 691 | - $this->logger->warning('Invalid structure node @ID "' . $id . '"'); |
|
| 691 | + $this->logger->warning('Invalid structure node @ID "'.$id.'"'); |
|
| 692 | 692 | return $fullText; |
| 693 | 693 | } |
| 694 | 694 | // Is this text format supported? |
@@ -707,12 +707,12 @@ discard block |
||
| 707 | 707 | $textMiniOcr = $obj->getTextAsMiniOcr($ocrTextXml); |
| 708 | 708 | $this->rawTextArray[$id] = $textMiniOcr; |
| 709 | 709 | } else { |
| 710 | - $this->logger->warning('Invalid class/method "' . $class . '->getRawText()" for text format "' . $textFormat . '"'); |
|
| 710 | + $this->logger->warning('Invalid class/method "'.$class.'->getRawText()" for text format "'.$textFormat.'"'); |
|
| 711 | 711 | } |
| 712 | 712 | } |
| 713 | 713 | $fullText = $textMiniOcr; |
| 714 | 714 | } else { |
| 715 | - $this->logger->warning('Unsupported text format "' . $textFormat . '" in physical node with @ID "' . $id . '"'); |
|
| 715 | + $this->logger->warning('Unsupported text format "'.$textFormat.'" in physical node with @ID "'.$id.'"'); |
|
| 716 | 716 | } |
| 717 | 717 | return $fullText; |
| 718 | 718 | } |
@@ -807,10 +807,10 @@ discard block |
||
| 807 | 807 | $title = self::getTitle($partof, true); |
| 808 | 808 | } |
| 809 | 809 | } else { |
| 810 | - $logger->warning('No document with UID ' . $uid . ' found or document not accessible'); |
|
| 810 | + $logger->warning('No document with UID '.$uid.' found or document not accessible'); |
|
| 811 | 811 | } |
| 812 | 812 | } else { |
| 813 | - $logger->error('Invalid UID ' . $uid . ' for document'); |
|
| 813 | + $logger->error('Invalid UID '.$uid.' for document'); |
|
| 814 | 814 | } |
| 815 | 815 | return $title; |
| 816 | 816 | } |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | // the actual loading is format specific |
| 946 | 946 | return $this->loadLocation($location); |
| 947 | 947 | } else { |
| 948 | - $this->logger->error('Invalid file location "' . $location . '" for document loading'); |
|
| 948 | + $this->logger->error('Invalid file location "'.$location.'" for document loading'); |
|
| 949 | 949 | } |
| 950 | 950 | return false; |
| 951 | 951 | } |
@@ -1055,7 +1055,7 @@ discard block |
||
| 1055 | 1055 | // Retain current PID. |
| 1056 | 1056 | $pid = $this->pid; |
| 1057 | 1057 | } elseif (!$pid) { |
| 1058 | - $this->logger->error('Invalid PID ' . $pid . ' for document saving'); |
|
| 1058 | + $this->logger->error('Invalid PID '.$pid.' for document saving'); |
|
| 1059 | 1059 | return false; |
| 1060 | 1060 | } |
| 1061 | 1061 | // Set PID for metadata definitions. |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | if ($resArray = $result->fetch()) { |
| 1093 | 1093 | $structure = $resArray['uid']; |
| 1094 | 1094 | } else { |
| 1095 | - $this->logger->error('Could not identify document/structure type "' . $queryBuilder->expr()->literal($metadata['type'][0]) . '"'); |
|
| 1095 | + $this->logger->error('Could not identify document/structure type "'.$queryBuilder->expr()->literal($metadata['type'][0]).'"'); |
|
| 1096 | 1096 | return false; |
| 1097 | 1097 | } |
| 1098 | 1098 | $metadata['type'][0] = $structure; |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | if ($core) { |
| 1342 | 1342 | return Indexer::add($this, $core); |
| 1343 | 1343 | } else { |
| 1344 | - $this->logger->notice('Invalid UID "' . $core . '" for Solr core'); |
|
| 1344 | + $this->logger->notice('Invalid UID "'.$core.'" for Solr core'); |
|
| 1345 | 1345 | return false; |
| 1346 | 1346 | } |
| 1347 | 1347 | } |
@@ -1419,7 +1419,7 @@ discard block |
||
| 1419 | 1419 | // Set metadata definitions' PID. |
| 1420 | 1420 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
| 1421 | 1421 | if (!$cPid) { |
| 1422 | - $this->logger->error('Invalid PID ' . $cPid . ' for metadata definitions'); |
|
| 1422 | + $this->logger->error('Invalid PID '.$cPid.' for metadata definitions'); |
|
| 1423 | 1423 | return []; |
| 1424 | 1424 | } |
| 1425 | 1425 | if ( |
@@ -1747,7 +1747,7 @@ discard block |
||
| 1747 | 1747 | // Document ready! |
| 1748 | 1748 | $this->ready = true; |
| 1749 | 1749 | } else { |
| 1750 | - $this->logger->error('No document with UID ' . $uid . ' found or document not accessible'); |
|
| 1750 | + $this->logger->error('No document with UID '.$uid.' found or document not accessible'); |
|
| 1751 | 1751 | } |
| 1752 | 1752 | } |
| 1753 | 1753 | |
@@ -1762,12 +1762,12 @@ discard block |
||
| 1762 | 1762 | */ |
| 1763 | 1763 | public function __get($var) |
| 1764 | 1764 | { |
| 1765 | - $method = '_get' . ucfirst($var); |
|
| 1765 | + $method = '_get'.ucfirst($var); |
|
| 1766 | 1766 | if ( |
| 1767 | 1767 | !property_exists($this, $var) |
| 1768 | 1768 | || !method_exists($this, $method) |
| 1769 | 1769 | ) { |
| 1770 | - $this->logger->warning('There is no getter function for property "' . $var . '"'); |
|
| 1770 | + $this->logger->warning('There is no getter function for property "'.$var.'"'); |
|
| 1771 | 1771 | return; |
| 1772 | 1772 | } else { |
| 1773 | 1773 | return $this->$method(); |
@@ -1800,12 +1800,12 @@ discard block |
||
| 1800 | 1800 | */ |
| 1801 | 1801 | public function __set($var, $value) |
| 1802 | 1802 | { |
| 1803 | - $method = '_set' . ucfirst($var); |
|
| 1803 | + $method = '_set'.ucfirst($var); |
|
| 1804 | 1804 | if ( |
| 1805 | 1805 | !property_exists($this, $var) |
| 1806 | 1806 | || !method_exists($this, $method) |
| 1807 | 1807 | ) { |
| 1808 | - $this->logger->warning('There is no setter function for property "' . $var . '"'); |
|
| 1808 | + $this->logger->warning('There is no setter function for property "'.$var.'"'); |
|
| 1809 | 1809 | } else { |
| 1810 | 1810 | $this->$method($value); |
| 1811 | 1811 | } |
@@ -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 | } |
@@ -617,8 +615,7 @@ discard block |
||
| 617 | 615 | * |
| 618 | 616 | * @return int The physical page number |
| 619 | 617 | */ |
| 620 | - public function getPhysicalPage($logicalPage) |
|
| 621 | - { |
|
| 618 | + public function getPhysicalPage($logicalPage) { |
|
| 622 | 619 | if ( |
| 623 | 620 | !empty($this->lastSearchedPhysicalPage['logicalPage']) |
| 624 | 621 | && $this->lastSearchedPhysicalPage['logicalPage'] == $logicalPage |
@@ -663,8 +660,7 @@ discard block |
||
| 663 | 660 | * |
| 664 | 661 | * @return string The OCR full text |
| 665 | 662 | */ |
| 666 | - protected function getFullTextFromXml($id) |
|
| 667 | - { |
|
| 663 | + protected function getFullTextFromXml($id) { |
|
| 668 | 664 | $fullText = ''; |
| 669 | 665 | // Load available text formats, ... |
| 670 | 666 | $this->loadFormats(); |
@@ -726,8 +722,7 @@ discard block |
||
| 726 | 722 | * |
| 727 | 723 | * @return string The format of the OCR full text |
| 728 | 724 | */ |
| 729 | - private function getTextFormat($fileContent) |
|
| 730 | - { |
|
| 725 | + private function getTextFormat($fileContent) { |
|
| 731 | 726 | // Get the root element's name as text format. |
| 732 | 727 | return strtoupper($this->getXmlObject($fileContent)->getName()); |
| 733 | 728 | } |
@@ -741,8 +736,7 @@ discard block |
||
| 741 | 736 | * |
| 742 | 737 | * @return \SimpleXMLElement The OCR full text as object |
| 743 | 738 | */ |
| 744 | - private function getXmlObject($fileContent) |
|
| 745 | - { |
|
| 739 | + private function getXmlObject($fileContent) { |
|
| 746 | 740 | // Turn off libxml's error logging. |
| 747 | 741 | $libxmlErrors = libxml_use_internal_errors(true); |
| 748 | 742 | // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept. |
@@ -769,8 +763,7 @@ discard block |
||
| 769 | 763 | * |
| 770 | 764 | * @return string The title of the document itself or a parent document |
| 771 | 765 | */ |
| 772 | - public static function getTitle($uid, $recursive = false) |
|
| 773 | - { |
|
| 766 | + public static function getTitle($uid, $recursive = false) { |
|
| 774 | 767 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
| 775 | 768 | |
| 776 | 769 | $title = ''; |
@@ -824,8 +817,7 @@ discard block |
||
| 824 | 817 | * |
| 825 | 818 | * @return array The logical structure node's / resource's parsed metadata array |
| 826 | 819 | */ |
| 827 | - public function getTitledata($cPid = 0) |
|
| 828 | - { |
|
| 820 | + public function getTitledata($cPid = 0) { |
|
| 829 | 821 | $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); |
| 830 | 822 | // Add information from METS structural map to titledata array. |
| 831 | 823 | if ($this instanceof MetsDocument) { |
@@ -858,8 +850,7 @@ discard block |
||
| 858 | 850 | * @return int|bool: false if structure with $logId is not a child of this substructure, |
| 859 | 851 | * or the actual depth. |
| 860 | 852 | */ |
| 861 | - protected function getTreeDepth($structure, $depth, $logId) |
|
| 862 | - { |
|
| 853 | + protected function getTreeDepth($structure, $depth, $logId) { |
|
| 863 | 854 | foreach ($structure as $element) { |
| 864 | 855 | if ($element['id'] == $logId) { |
| 865 | 856 | return $depth; |
@@ -881,8 +872,7 @@ discard block |
||
| 881 | 872 | * @param string $logId: The id of the logical structure element whose depth is requested |
| 882 | 873 | * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. |
| 883 | 874 | */ |
| 884 | - public function getStructureDepth($logId) |
|
| 885 | - { |
|
| 875 | + public function getStructureDepth($logId) { |
|
| 886 | 876 | return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId); |
| 887 | 877 | } |
| 888 | 878 | |
@@ -932,8 +922,7 @@ discard block |
||
| 932 | 922 | * |
| 933 | 923 | * @return bool true on success or false on failure |
| 934 | 924 | */ |
| 935 | - protected function load($location) |
|
| 936 | - { |
|
| 925 | + protected function load($location) { |
|
| 937 | 926 | // Load XML / JSON-LD file. |
| 938 | 927 | if (GeneralUtility::isValidUrl($location)) { |
| 939 | 928 | // Load extension configuration |
@@ -966,8 +955,7 @@ discard block |
||
| 966 | 955 | * |
| 967 | 956 | * @return void |
| 968 | 957 | */ |
| 969 | - protected function loadFormats() |
|
| 970 | - { |
|
| 958 | + protected function loadFormats() { |
|
| 971 | 959 | if (!$this->formatsLoaded) { |
| 972 | 960 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 973 | 961 | ->getQueryBuilderForTable('tx_dlf_formats'); |
@@ -1007,8 +995,7 @@ discard block |
||
| 1007 | 995 | * |
| 1008 | 996 | * @return void |
| 1009 | 997 | */ |
| 1010 | - public function registerNamespaces(&$obj) |
|
| 1011 | - { |
|
| 998 | + public function registerNamespaces(&$obj) { |
|
| 1012 | 999 | // 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. |
| 1013 | 1000 | $this->loadFormats(); |
| 1014 | 1001 | // Do we have a \SimpleXMLElement or \DOMXPath object? |
@@ -1037,8 +1024,7 @@ discard block |
||
| 1037 | 1024 | * |
| 1038 | 1025 | * @return bool true on success or false on failure |
| 1039 | 1026 | */ |
| 1040 | - public function save($pid = 0, $core = 0, $owner = null) |
|
| 1041 | - { |
|
| 1027 | + public function save($pid = 0, $core = 0, $owner = null) { |
|
| 1042 | 1028 | if (\TYPO3_MODE !== 'BE') { |
| 1043 | 1029 | $this->logger->error('Saving a document is only allowed in the backend'); |
| 1044 | 1030 | return false; |
@@ -1366,8 +1352,7 @@ discard block |
||
| 1366 | 1352 | * |
| 1367 | 1353 | * @return int The PID of the metadata definitions |
| 1368 | 1354 | */ |
| 1369 | - protected function _getCPid() |
|
| 1370 | - { |
|
| 1355 | + protected function _getCPid() { |
|
| 1371 | 1356 | return $this->cPid; |
| 1372 | 1357 | } |
| 1373 | 1358 | |
@@ -1378,8 +1363,7 @@ discard block |
||
| 1378 | 1363 | * |
| 1379 | 1364 | * @return bool Are there any fulltext files available? |
| 1380 | 1365 | */ |
| 1381 | - protected function _getHasFulltext() |
|
| 1382 | - { |
|
| 1366 | + protected function _getHasFulltext() { |
|
| 1383 | 1367 | $this->ensureHasFulltextIsSet(); |
| 1384 | 1368 | return $this->hasFulltext; |
| 1385 | 1369 | } |
@@ -1391,8 +1375,7 @@ discard block |
||
| 1391 | 1375 | * |
| 1392 | 1376 | * @return string The location of the document |
| 1393 | 1377 | */ |
| 1394 | - protected function _getLocation() |
|
| 1395 | - { |
|
| 1378 | + protected function _getLocation() { |
|
| 1396 | 1379 | return $this->location; |
| 1397 | 1380 | } |
| 1398 | 1381 | |
@@ -1414,8 +1397,7 @@ discard block |
||
| 1414 | 1397 | * |
| 1415 | 1398 | * @return array Array of metadata with their corresponding logical structure node ID as key |
| 1416 | 1399 | */ |
| 1417 | - protected function _getMetadataArray() |
|
| 1418 | - { |
|
| 1400 | + protected function _getMetadataArray() { |
|
| 1419 | 1401 | // Set metadata definitions' PID. |
| 1420 | 1402 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
| 1421 | 1403 | if (!$cPid) { |
@@ -1440,8 +1422,7 @@ discard block |
||
| 1440 | 1422 | * |
| 1441 | 1423 | * @return int The total number of pages and/or tracks |
| 1442 | 1424 | */ |
| 1443 | - protected function _getNumPages() |
|
| 1444 | - { |
|
| 1425 | + protected function _getNumPages() { |
|
| 1445 | 1426 | $this->_getPhysicalStructure(); |
| 1446 | 1427 | return $this->numPages; |
| 1447 | 1428 | } |
@@ -1453,8 +1434,7 @@ discard block |
||
| 1453 | 1434 | * |
| 1454 | 1435 | * @return int The UID of the parent document or zero if not applicable |
| 1455 | 1436 | */ |
| 1456 | - protected function _getParentId() |
|
| 1457 | - { |
|
| 1437 | + protected function _getParentId() { |
|
| 1458 | 1438 | return $this->parentId; |
| 1459 | 1439 | } |
| 1460 | 1440 | |
@@ -1477,8 +1457,7 @@ discard block |
||
| 1477 | 1457 | * |
| 1478 | 1458 | * @return array Array of elements' type, label and file representations ordered by @ID attribute / Canvas order |
| 1479 | 1459 | */ |
| 1480 | - protected function _getPhysicalStructureInfo() |
|
| 1481 | - { |
|
| 1460 | + protected function _getPhysicalStructureInfo() { |
|
| 1482 | 1461 | // Is there no physical structure array yet? |
| 1483 | 1462 | if (!$this->physicalStructureLoaded) { |
| 1484 | 1463 | // Build physical structure array. |
@@ -1494,8 +1473,7 @@ discard block |
||
| 1494 | 1473 | * |
| 1495 | 1474 | * @return int The PID of the document or zero if not in database |
| 1496 | 1475 | */ |
| 1497 | - protected function _getPid() |
|
| 1498 | - { |
|
| 1476 | + protected function _getPid() { |
|
| 1499 | 1477 | return $this->pid; |
| 1500 | 1478 | } |
| 1501 | 1479 | |
@@ -1506,8 +1484,7 @@ discard block |
||
| 1506 | 1484 | * |
| 1507 | 1485 | * @return bool Is the document instantiated successfully? |
| 1508 | 1486 | */ |
| 1509 | - protected function _getReady() |
|
| 1510 | - { |
|
| 1487 | + protected function _getReady() { |
|
| 1511 | 1488 | return $this->ready; |
| 1512 | 1489 | } |
| 1513 | 1490 | |
@@ -1518,8 +1495,7 @@ discard block |
||
| 1518 | 1495 | * |
| 1519 | 1496 | * @return mixed The METS file's / IIIF manifest's record identifier |
| 1520 | 1497 | */ |
| 1521 | - protected function _getRecordId() |
|
| 1522 | - { |
|
| 1498 | + protected function _getRecordId() { |
|
| 1523 | 1499 | return $this->recordId; |
| 1524 | 1500 | } |
| 1525 | 1501 | |
@@ -1530,8 +1506,7 @@ discard block |
||
| 1530 | 1506 | * |
| 1531 | 1507 | * @return int The UID of the root document or zero if not applicable |
| 1532 | 1508 | */ |
| 1533 | - protected function _getRootId() |
|
| 1534 | - { |
|
| 1509 | + protected function _getRootId() { |
|
| 1535 | 1510 | if (!$this->rootIdLoaded) { |
| 1536 | 1511 | if ($this->parentId) { |
| 1537 | 1512 | $parent = self::getInstance($this->parentId, $this->pid); |
@@ -1561,8 +1536,7 @@ discard block |
||
| 1561 | 1536 | * |
| 1562 | 1537 | * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved |
| 1563 | 1538 | */ |
| 1564 | - protected function _getTableOfContents() |
|
| 1565 | - { |
|
| 1539 | + protected function _getTableOfContents() { |
|
| 1566 | 1540 | // Is there no logical structure array yet? |
| 1567 | 1541 | if (!$this->tableOfContentsLoaded) { |
| 1568 | 1542 | // Get all logical structures. |
@@ -1603,8 +1577,7 @@ discard block |
||
| 1603 | 1577 | * |
| 1604 | 1578 | * @return mixed The UID or the URL of the document |
| 1605 | 1579 | */ |
| 1606 | - protected function _getUid() |
|
| 1607 | - { |
|
| 1580 | + protected function _getUid() { |
|
| 1608 | 1581 | return $this->uid; |
| 1609 | 1582 | } |
| 1610 | 1583 | |
@@ -1617,8 +1590,7 @@ discard block |
||
| 1617 | 1590 | * |
| 1618 | 1591 | * @return void |
| 1619 | 1592 | */ |
| 1620 | - protected function _setCPid($value) |
|
| 1621 | - { |
|
| 1593 | + protected function _setCPid($value) { |
|
| 1622 | 1594 | $this->cPid = max(intval($value), 0); |
| 1623 | 1595 | } |
| 1624 | 1596 | |
@@ -1629,8 +1601,7 @@ discard block |
||
| 1629 | 1601 | * |
| 1630 | 1602 | * @return void |
| 1631 | 1603 | */ |
| 1632 | - protected function __clone() |
|
| 1633 | - { |
|
| 1604 | + protected function __clone() { |
|
| 1634 | 1605 | // This method is defined as protected because singleton objects should not be cloned. |
| 1635 | 1606 | } |
| 1636 | 1607 | |
@@ -1647,8 +1618,7 @@ discard block |
||
| 1647 | 1618 | * |
| 1648 | 1619 | * @return void |
| 1649 | 1620 | */ |
| 1650 | - protected function __construct($uid, $pid, $preloadedDocument) |
|
| 1651 | - { |
|
| 1621 | + protected function __construct($uid, $pid, $preloadedDocument) { |
|
| 1652 | 1622 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 1653 | 1623 | ->getQueryBuilderForTable('tx_dlf_documents'); |
| 1654 | 1624 | $location = ''; |
@@ -1760,8 +1730,7 @@ discard block |
||
| 1760 | 1730 | * |
| 1761 | 1731 | * @return mixed Value of $this->$var |
| 1762 | 1732 | */ |
| 1763 | - public function __get($var) |
|
| 1764 | - { |
|
| 1733 | + public function __get($var) { |
|
| 1765 | 1734 | $method = '_get' . ucfirst($var); |
| 1766 | 1735 | if ( |
| 1767 | 1736 | !property_exists($this, $var) |
@@ -1783,8 +1752,7 @@ discard block |
||
| 1783 | 1752 | * |
| 1784 | 1753 | * @return bool true if variable is set and not empty, false otherwise |
| 1785 | 1754 | */ |
| 1786 | - public function __isset($var) |
|
| 1787 | - { |
|
| 1755 | + public function __isset($var) { |
|
| 1788 | 1756 | return !empty($this->__get($var)); |
| 1789 | 1757 | } |
| 1790 | 1758 | |
@@ -1798,8 +1766,7 @@ discard block |
||
| 1798 | 1766 | * |
| 1799 | 1767 | * @return void |
| 1800 | 1768 | */ |
| 1801 | - public function __set($var, $value) |
|
| 1802 | - { |
|
| 1769 | + public function __set($var, $value) { |
|
| 1803 | 1770 | $method = '_set' . ucfirst($var); |
| 1804 | 1771 | if ( |
| 1805 | 1772 | !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,27 +515,27 @@ 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 | // TODO use single place to load xml |
| 520 | 520 | // Turn off libxml's error logging. |
| 521 | - $libxmlErrors = libxml_use_internal_errors(true); |
|
| 521 | + $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
| 522 | 522 | // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept |
| 523 | - $previousValueOfEntityLoader = libxml_disable_entity_loader(true); |
|
| 523 | + $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE); |
|
| 524 | 524 | // Try to load XML from file. |
| 525 | 525 | $xml = simplexml_load_string($content); |
| 526 | 526 | // reset entity loader setting |
| 527 | 527 | libxml_disable_entity_loader($previousValueOfEntityLoader); |
| 528 | 528 | // Reset libxml's error logging. |
| 529 | 529 | libxml_use_internal_errors($libxmlErrors); |
| 530 | - if ($xml !== false) { |
|
| 530 | + if ($xml !== FALSE) { |
|
| 531 | 531 | /* @var $xml \SimpleXMLElement */ |
| 532 | 532 | $xml->registerXPathNamespace('mets', 'http://www.loc.gov/METS/'); |
| 533 | 533 | $xpathResult = $xml->xpath('//mets:mets'); |
| 534 | - $documentFormat = !empty($xpathResult) ? 'METS' : null; |
|
| 534 | + $documentFormat = !empty($xpathResult) ? 'METS' : NULL; |
|
| 535 | 535 | } else { |
| 536 | 536 | // Try to load file as IIIF resource instead. |
| 537 | - $contentAsJsonArray = json_decode($content, true); |
|
| 538 | - if ($contentAsJsonArray !== null) { |
|
| 537 | + $contentAsJsonArray = json_decode($content, TRUE); |
|
| 538 | + if ($contentAsJsonArray !== NULL) { |
|
| 539 | 539 | // Load plugin configuration. |
| 540 | 540 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 541 | 541 | IiifHelper::setUrlReader(IiifUrlReader::getInstance()); |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * |
| 591 | 591 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
| 592 | 592 | */ |
| 593 | - public abstract function getLogicalStructure($id, $recursive = false); |
|
| 593 | + public abstract function getLogicalStructure($id, $recursive = FALSE); |
|
| 594 | 594 | |
| 595 | 595 | /** |
| 596 | 596 | * This extracts all the metadata for a logical structure node |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | } else { |
| 628 | 628 | $physicalPage = 0; |
| 629 | 629 | foreach ($this->physicalStructureInfo as $page) { |
| 630 | - if (strpos($page['orderlabel'], $logicalPage) !== false) { |
|
| 630 | + if (strpos($page['orderlabel'], $logicalPage) !== FALSE) { |
|
| 631 | 631 | $this->lastSearchedPhysicalPage['logicalPage'] = $logicalPage; |
| 632 | 632 | $this->lastSearchedPhysicalPage['physicalPage'] = $physicalPage; |
| 633 | 633 | return $physicalPage; |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | if (!empty($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])) { |
| 679 | 679 | // Get full text file. |
| 680 | 680 | $fileContent = GeneralUtility::getUrl($this->getFileLocation($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])); |
| 681 | - if ($fileContent !== false) { |
|
| 681 | + if ($fileContent !== FALSE) { |
|
| 682 | 682 | $textFormat = $this->getTextFormat($fileContent); |
| 683 | 683 | } else { |
| 684 | 684 | $this->logger->warning('Couldn\'t load full text file for structure node @ID "' . $id . '"'); |
@@ -744,9 +744,9 @@ discard block |
||
| 744 | 744 | private function getXmlObject($fileContent) |
| 745 | 745 | { |
| 746 | 746 | // Turn off libxml's error logging. |
| 747 | - $libxmlErrors = libxml_use_internal_errors(true); |
|
| 747 | + $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
| 748 | 748 | // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept. |
| 749 | - $previousValueOfEntityLoader = libxml_disable_entity_loader(true); |
|
| 749 | + $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE); |
|
| 750 | 750 | // Load XML from file. |
| 751 | 751 | $ocrTextXml = simplexml_load_string($fileContent); |
| 752 | 752 | // Reset entity loader setting. |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | * |
| 770 | 770 | * @return string The title of the document itself or a parent document |
| 771 | 771 | */ |
| 772 | - public static function getTitle($uid, $recursive = false) |
|
| 772 | + public static function getTitle($uid, $recursive = FALSE) |
|
| 773 | 773 | { |
| 774 | 774 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
| 775 | 775 | |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | && intval($partof) |
| 805 | 805 | && $partof != $uid |
| 806 | 806 | ) { |
| 807 | - $title = self::getTitle($partof, true); |
|
| 807 | + $title = self::getTitle($partof, TRUE); |
|
| 808 | 808 | } |
| 809 | 809 | } else { |
| 810 | 810 | $logger->warning('No document with UID ' . $uid . ' found or document not accessible'); |
@@ -865,12 +865,12 @@ discard block |
||
| 865 | 865 | return $depth; |
| 866 | 866 | } elseif (array_key_exists('children', $element)) { |
| 867 | 867 | $foundInChildren = $this->getTreeDepth($element['children'], $depth + 1, $logId); |
| 868 | - if ($foundInChildren !== false) { |
|
| 868 | + if ($foundInChildren !== FALSE) { |
|
| 869 | 869 | return $foundInChildren; |
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | 872 | } |
| 873 | - return false; |
|
| 873 | + return FALSE; |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | /** |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | } else { |
| 948 | 948 | $this->logger->error('Invalid file location "' . $location . '" for document loading'); |
| 949 | 949 | } |
| 950 | - return false; |
|
| 950 | + return FALSE; |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | /** |
@@ -994,7 +994,7 @@ discard block |
||
| 994 | 994 | 'class' => $resArray['class'] |
| 995 | 995 | ]; |
| 996 | 996 | } |
| 997 | - $this->formatsLoaded = true; |
|
| 997 | + $this->formatsLoaded = TRUE; |
|
| 998 | 998 | } |
| 999 | 999 | } |
| 1000 | 1000 | |
@@ -1037,11 +1037,11 @@ discard block |
||
| 1037 | 1037 | * |
| 1038 | 1038 | * @return bool true on success or false on failure |
| 1039 | 1039 | */ |
| 1040 | - public function save($pid = 0, $core = 0, $owner = null) |
|
| 1040 | + public function save($pid = 0, $core = 0, $owner = NULL) |
|
| 1041 | 1041 | { |
| 1042 | 1042 | if (\TYPO3_MODE !== 'BE') { |
| 1043 | 1043 | $this->logger->error('Saving a document is only allowed in the backend'); |
| 1044 | - return false; |
|
| 1044 | + return FALSE; |
|
| 1045 | 1045 | } |
| 1046 | 1046 | // Make sure $pid is a non-negative integer. |
| 1047 | 1047 | $pid = max(intval($pid), 0); |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | $pid = $this->pid; |
| 1057 | 1057 | } elseif (!$pid) { |
| 1058 | 1058 | $this->logger->error('Invalid PID ' . $pid . ' for document saving'); |
| 1059 | - return false; |
|
| 1059 | + return FALSE; |
|
| 1060 | 1060 | } |
| 1061 | 1061 | // Set PID for metadata definitions. |
| 1062 | 1062 | $this->cPid = $pid; |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | // Check for record identifier. |
| 1070 | 1070 | if (empty($metadata['record_id'][0])) { |
| 1071 | 1071 | $this->logger->error('No record identifier found to avoid duplication'); |
| 1072 | - return false; |
|
| 1072 | + return FALSE; |
|
| 1073 | 1073 | } |
| 1074 | 1074 | // Load plugin configuration. |
| 1075 | 1075 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -1093,7 +1093,7 @@ discard block |
||
| 1093 | 1093 | $structure = $resArray['uid']; |
| 1094 | 1094 | } else { |
| 1095 | 1095 | $this->logger->error('Could not identify document/structure type "' . $queryBuilder->expr()->literal($metadata['type'][0]) . '"'); |
| 1096 | - return false; |
|
| 1096 | + return FALSE; |
|
| 1097 | 1097 | } |
| 1098 | 1098 | $metadata['type'][0] = $structure; |
| 1099 | 1099 | |
@@ -1153,9 +1153,9 @@ discard block |
||
| 1153 | 1153 | if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) { |
| 1154 | 1154 | Helper::addMessage( |
| 1155 | 1155 | htmlspecialchars(sprintf(Helper::getMessage('flash.newCollection'), $collection, $substUid[$collNewUid])), |
| 1156 | - Helper::getMessage('flash.attention', true), |
|
| 1156 | + Helper::getMessage('flash.attention', TRUE), |
|
| 1157 | 1157 | \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
| 1158 | - true |
|
| 1158 | + TRUE |
|
| 1159 | 1159 | ); |
| 1160 | 1160 | } |
| 1161 | 1161 | } |
@@ -1206,9 +1206,9 @@ discard block |
||
| 1206 | 1206 | if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) { |
| 1207 | 1207 | Helper::addMessage( |
| 1208 | 1208 | htmlspecialchars(sprintf(Helper::getMessage('flash.newLibrary'), $owner, $ownerUid)), |
| 1209 | - Helper::getMessage('flash.attention', true), |
|
| 1209 | + Helper::getMessage('flash.attention', TRUE), |
|
| 1210 | 1210 | \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
| 1211 | - true |
|
| 1211 | + TRUE |
|
| 1212 | 1212 | ); |
| 1213 | 1213 | } |
| 1214 | 1214 | } |
@@ -1296,7 +1296,7 @@ discard block |
||
| 1296 | 1296 | 'author' => implode('; ', $metadata['author']), |
| 1297 | 1297 | 'year' => implode('; ', $metadata['year']), |
| 1298 | 1298 | 'place' => implode('; ', $metadata['place']), |
| 1299 | - 'thumbnail' => $this->_getThumbnail(true), |
|
| 1299 | + 'thumbnail' => $this->_getThumbnail(TRUE), |
|
| 1300 | 1300 | 'metadata' => serialize($listed), |
| 1301 | 1301 | 'metadata_sorting' => serialize($sortable), |
| 1302 | 1302 | 'structure' => $metadata['type'][0], |
@@ -1332,9 +1332,9 @@ discard block |
||
| 1332 | 1332 | if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) { |
| 1333 | 1333 | Helper::addMessage( |
| 1334 | 1334 | htmlspecialchars(sprintf(Helper::getMessage('flash.documentSaved'), $metadata['title'][0], $this->uid)), |
| 1335 | - Helper::getMessage('flash.done', true), |
|
| 1335 | + Helper::getMessage('flash.done', TRUE), |
|
| 1336 | 1336 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK, |
| 1337 | - true |
|
| 1337 | + TRUE |
|
| 1338 | 1338 | ); |
| 1339 | 1339 | } |
| 1340 | 1340 | // Add document to index. |
@@ -1342,7 +1342,7 @@ discard block |
||
| 1342 | 1342 | return Indexer::add($this, $core); |
| 1343 | 1343 | } else { |
| 1344 | 1344 | $this->logger->notice('Invalid UID "' . $core . '" for Solr core'); |
| 1345 | - return false; |
|
| 1345 | + return FALSE; |
|
| 1346 | 1346 | } |
| 1347 | 1347 | } |
| 1348 | 1348 | |
@@ -1428,7 +1428,7 @@ discard block |
||
| 1428 | 1428 | ) { |
| 1429 | 1429 | $this->prepareMetadataArray($cPid); |
| 1430 | 1430 | $this->metadataArray[0] = $cPid; |
| 1431 | - $this->metadataArrayLoaded = true; |
|
| 1431 | + $this->metadataArrayLoaded = TRUE; |
|
| 1432 | 1432 | } |
| 1433 | 1433 | return $this->metadataArray; |
| 1434 | 1434 | } |
@@ -1537,7 +1537,7 @@ discard block |
||
| 1537 | 1537 | $parent = self::getInstance($this->parentId, $this->pid); |
| 1538 | 1538 | $this->rootId = $parent->rootId; |
| 1539 | 1539 | } |
| 1540 | - $this->rootIdLoaded = true; |
|
| 1540 | + $this->rootIdLoaded = TRUE; |
|
| 1541 | 1541 | } |
| 1542 | 1542 | return $this->rootId; |
| 1543 | 1543 | } |
@@ -1566,8 +1566,8 @@ discard block |
||
| 1566 | 1566 | // Is there no logical structure array yet? |
| 1567 | 1567 | if (!$this->tableOfContentsLoaded) { |
| 1568 | 1568 | // Get all logical structures. |
| 1569 | - $this->getLogicalStructure('', true); |
|
| 1570 | - $this->tableOfContentsLoaded = true; |
|
| 1569 | + $this->getLogicalStructure('', TRUE); |
|
| 1570 | + $this->tableOfContentsLoaded = TRUE; |
|
| 1571 | 1571 | } |
| 1572 | 1572 | return $this->tableOfContents; |
| 1573 | 1573 | } |
@@ -1583,7 +1583,7 @@ discard block |
||
| 1583 | 1583 | * |
| 1584 | 1584 | * @return string The document's thumbnail location |
| 1585 | 1585 | */ |
| 1586 | - protected abstract function _getThumbnail($forceReload = false); |
|
| 1586 | + protected abstract function _getThumbnail($forceReload = FALSE); |
|
| 1587 | 1587 | |
| 1588 | 1588 | /** |
| 1589 | 1589 | * This returns the ID of the toplevel logical structure node |
@@ -1664,7 +1664,7 @@ discard block |
||
| 1664 | 1664 | && $this->load($uid))) { |
| 1665 | 1665 | // Initialize core METS object. |
| 1666 | 1666 | $this->init(); |
| 1667 | - if ($this->getDocument() !== null) { |
|
| 1667 | + if ($this->getDocument() !== NULL) { |
|
| 1668 | 1668 | // Cast to string for safety reasons. |
| 1669 | 1669 | $location = (string) $uid; |
| 1670 | 1670 | $this->establishRecordId($pid); |
@@ -1722,30 +1722,30 @@ discard block |
||
| 1722 | 1722 | $this->parentId = $resArray['partof']; |
| 1723 | 1723 | $this->thumbnail = $resArray['thumbnail']; |
| 1724 | 1724 | $this->location = $resArray['location']; |
| 1725 | - $this->thumbnailLoaded = true; |
|
| 1725 | + $this->thumbnailLoaded = TRUE; |
|
| 1726 | 1726 | // Load XML file if necessary... |
| 1727 | 1727 | if ( |
| 1728 | - $this->getDocument() === null |
|
| 1728 | + $this->getDocument() === NULL |
|
| 1729 | 1729 | && $this->load($this->location) |
| 1730 | 1730 | ) { |
| 1731 | 1731 | // ...and set some basic properties. |
| 1732 | 1732 | $this->init(); |
| 1733 | 1733 | } |
| 1734 | 1734 | // Do we have a METS / IIIF object now? |
| 1735 | - if ($this->getDocument() !== null) { |
|
| 1735 | + if ($this->getDocument() !== NULL) { |
|
| 1736 | 1736 | // Set new location if necessary. |
| 1737 | 1737 | if (!empty($location)) { |
| 1738 | 1738 | $this->location = $location; |
| 1739 | 1739 | } |
| 1740 | 1740 | // Document ready! |
| 1741 | - $this->ready = true; |
|
| 1741 | + $this->ready = TRUE; |
|
| 1742 | 1742 | } |
| 1743 | - } elseif ($this->getDocument() !== null) { |
|
| 1743 | + } elseif ($this->getDocument() !== NULL) { |
|
| 1744 | 1744 | // Set location as UID for documents not in database. |
| 1745 | 1745 | $this->uid = $location; |
| 1746 | 1746 | $this->location = $location; |
| 1747 | 1747 | // Document ready! |
| 1748 | - $this->ready = true; |
|
| 1748 | + $this->ready = TRUE; |
|
| 1749 | 1749 | } else { |
| 1750 | 1750 | $this->logger->error('No document with UID ' . $uid . ' found or document not accessible'); |
| 1751 | 1751 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | if ($this->valid()) { |
| 140 | 140 | return $this->getRecord($this->elements[$this->position]); |
| 141 | 141 | } else { |
| 142 | - $this->logger->notice('Invalid position "' . $this->position . '" for list element'); |
|
| 142 | + $this->logger->notice('Invalid position "'.$this->position.'" for list element'); |
|
| 143 | 143 | return; |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | |
| 268 | 268 | $query = $this->solr->service->createSelect(); |
| 269 | 269 | // Restrict the fields to the required ones |
| 270 | - $query->setFields($fields['uid'] . ',' . $fields['id'] . ',' . $fields['toplevel'] . ',' . $fields['thumbnail'] . ',' . $fields['page']); |
|
| 270 | + $query->setFields($fields['uid'].','.$fields['id'].','.$fields['toplevel'].','.$fields['thumbnail'].','.$fields['page']); |
|
| 271 | 271 | foreach ($this->solrConfig as $solr_name) { |
| 272 | 272 | $query->addField($solr_name); |
| 273 | 273 | } |
@@ -280,16 +280,16 @@ discard block |
||
| 280 | 280 | // Extend filter query to get all documents with the same UID. |
| 281 | 281 | foreach ($filterQueries as $key => $value) { |
| 282 | 282 | if (isset($value['query'])) { |
| 283 | - $filterQuery[$key] = $value['query'] . ' OR ' . $fields['toplevel'] . ':true'; |
|
| 283 | + $filterQuery[$key] = $value['query'].' OR '.$fields['toplevel'].':true'; |
|
| 284 | 284 | $filterQuery = [ |
| 285 | 285 | 'key' => $key, |
| 286 | - 'query' => $value['query'] . ' OR ' . $fields['toplevel'] . ':true' |
|
| 286 | + 'query' => $value['query'].' OR '.$fields['toplevel'].':true' |
|
| 287 | 287 | ]; |
| 288 | 288 | $query->addFilterQuery($filterQuery); |
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | // Add filter query to get all documents with the required uid. |
| 292 | - $query->createFilterQuery('uid')->setQuery($fields['uid'] . ':' . Solr::escapeQuery($record['uid'])); |
|
| 292 | + $query->createFilterQuery('uid')->setQuery($fields['uid'].':'.Solr::escapeQuery($record['uid'])); |
|
| 293 | 293 | // Add sorting. |
| 294 | 294 | if (is_array($this->metadata['options']['params']['sort'])) { |
| 295 | 295 | foreach ($this->metadata['options']['params']['sort'] as $key => $direction) { |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | // Set query. |
| 300 | - $query->setQuery($this->metadata['options']['select'] . ' OR ' . $fields['toplevel'] . ':true'); |
|
| 300 | + $query->setQuery($this->metadata['options']['select'].' OR '.$fields['toplevel'].':true'); |
|
| 301 | 301 | |
| 302 | 302 | // If it is a fulltext search, enable highlighting. |
| 303 | 303 | if ($this->metadata['fulltextSearch']) { |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | $position < 0 |
| 406 | 406 | || $position >= $this->count |
| 407 | 407 | ) { |
| 408 | - $this->logger->warning('Invalid position "' . $position . '" for element moving'); |
|
| 408 | + $this->logger->warning('Invalid position "'.$position.'" for element moving'); |
|
| 409 | 409 | return; |
| 410 | 410 | } |
| 411 | 411 | $steps = intval($steps); |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | if (($position + $steps) < 0 |
| 414 | 414 | || ($position + $steps) >= $this->count |
| 415 | 415 | ) { |
| 416 | - $this->logger->warning('Invalid steps "' . $steps . '" for moving element at position "' . $position . '"'); |
|
| 416 | + $this->logger->warning('Invalid steps "'.$steps.'" for moving element at position "'.$position.'"'); |
|
| 417 | 417 | return; |
| 418 | 418 | } |
| 419 | 419 | $element = $this->remove($position); |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | if ($this->offsetExists($offset)) { |
| 492 | 492 | return $this->getRecord($this->elements[$offset]); |
| 493 | 493 | } else { |
| 494 | - $this->logger->notice('Invalid offset "' . $offset . '" for list element'); |
|
| 494 | + $this->logger->notice('Invalid offset "'.$offset.'" for list element'); |
|
| 495 | 495 | return; |
| 496 | 496 | } |
| 497 | 497 | } |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | $position < 0 |
| 536 | 536 | || $position >= $this->count |
| 537 | 537 | ) { |
| 538 | - $this->logger->warning('Invalid position "' . $position . '" for element removing'); |
|
| 538 | + $this->logger->warning('Invalid position "'.$position.'" for element removing'); |
|
| 539 | 539 | return; |
| 540 | 540 | } |
| 541 | 541 | $removed = array_splice($this->elements, $position, 1); |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | $position < 0 |
| 561 | 561 | || $position >= $this->count |
| 562 | 562 | ) { |
| 563 | - $this->logger->warning('Invalid position "' . $position . '" for element removing'); |
|
| 563 | + $this->logger->warning('Invalid position "'.$position.'" for element removing'); |
|
| 564 | 564 | return; |
| 565 | 565 | } |
| 566 | 566 | $removed = array_splice($this->elements, $position, $length); |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | ->execute(); |
| 654 | 654 | |
| 655 | 655 | while ($resArray = $result->fetch()) { |
| 656 | - $this->solrConfig[$resArray['index_name']] = $resArray['index_name'] . '_' . ($resArray['index_tokenized'] ? 't' : 'u') . 's' . ($resArray['index_indexed'] ? 'i' : 'u'); |
|
| 656 | + $this->solrConfig[$resArray['index_name']] = $resArray['index_name'].'_'.($resArray['index_tokenized'] ? 't' : 'u').'s'.($resArray['index_indexed'] ? 'i' : 'u'); |
|
| 657 | 657 | } |
| 658 | 658 | // Add static fields. |
| 659 | 659 | $this->solrConfig['type'] = 'type'; |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | foreach ($this->elements as $num => $element) { |
| 682 | 682 | // Is this element sortable? |
| 683 | 683 | if (!empty($element['s'][$by])) { |
| 684 | - $newOrder[$element['s'][$by] . str_pad($num, 6, '0', STR_PAD_LEFT)] = $element; |
|
| 684 | + $newOrder[$element['s'][$by].str_pad($num, 6, '0', STR_PAD_LEFT)] = $element; |
|
| 685 | 685 | } else { |
| 686 | 686 | $nonSortable[] = $element; |
| 687 | 687 | } |
@@ -819,12 +819,12 @@ discard block |
||
| 819 | 819 | */ |
| 820 | 820 | public function __get($var) |
| 821 | 821 | { |
| 822 | - $method = '_get' . ucfirst($var); |
|
| 822 | + $method = '_get'.ucfirst($var); |
|
| 823 | 823 | if ( |
| 824 | 824 | !property_exists($this, $var) |
| 825 | 825 | || !method_exists($this, $method) |
| 826 | 826 | ) { |
| 827 | - $this->logger->warning('There is no getter function for property "' . $var . '"'); |
|
| 827 | + $this->logger->warning('There is no getter function for property "'.$var.'"'); |
|
| 828 | 828 | return; |
| 829 | 829 | } else { |
| 830 | 830 | return $this->$method(); |
@@ -857,12 +857,12 @@ discard block |
||
| 857 | 857 | */ |
| 858 | 858 | public function __set($var, $value) |
| 859 | 859 | { |
| 860 | - $method = '_set' . ucfirst($var); |
|
| 860 | + $method = '_set'.ucfirst($var); |
|
| 861 | 861 | if ( |
| 862 | 862 | !property_exists($this, $var) |
| 863 | 863 | || !method_exists($this, $method) |
| 864 | 864 | ) { |
| 865 | - $this->logger->warning('There is no setter function for property "' . $var . '"'); |
|
| 865 | + $this->logger->warning('There is no setter function for property "'.$var.'"'); |
|
| 866 | 866 | } else { |
| 867 | 867 | $this->$method($value); |
| 868 | 868 | } |
@@ -104,8 +104,7 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return void |
| 106 | 106 | */ |
| 107 | - public function add(array $elements, $position = -1) |
|
| 108 | - { |
|
| 107 | + public function add(array $elements, $position = -1) { |
|
| 109 | 108 | $position = MathUtility::forceIntegerInRange($position, 0, $this->count, $this->count); |
| 110 | 109 | if (!empty($elements)) { |
| 111 | 110 | array_splice($this->elements, $position, 0, $elements); |
@@ -121,8 +120,7 @@ discard block |
||
| 121 | 120 | * |
| 122 | 121 | * @return int The number of elements in the list |
| 123 | 122 | */ |
| 124 | - public function count() |
|
| 125 | - { |
|
| 123 | + public function count() { |
|
| 126 | 124 | return $this->count; |
| 127 | 125 | } |
| 128 | 126 | |
@@ -134,8 +132,7 @@ discard block |
||
| 134 | 132 | * |
| 135 | 133 | * @return array The current element |
| 136 | 134 | */ |
| 137 | - public function current() |
|
| 138 | - { |
|
| 135 | + public function current() { |
|
| 139 | 136 | if ($this->valid()) { |
| 140 | 137 | return $this->getRecord($this->elements[$this->position]); |
| 141 | 138 | } else { |
@@ -153,8 +150,7 @@ discard block |
||
| 153 | 150 | * |
| 154 | 151 | * @return mixed The element's full record |
| 155 | 152 | */ |
| 156 | - protected function getRecord($element) |
|
| 157 | - { |
|
| 153 | + protected function getRecord($element) { |
|
| 158 | 154 | if ( |
| 159 | 155 | is_array($element) |
| 160 | 156 | && array_keys($element) == ['u', 'h', 's', 'p'] |
@@ -261,8 +257,7 @@ discard block |
||
| 261 | 257 | * |
| 262 | 258 | * @return Result |
| 263 | 259 | */ |
| 264 | - private function getSolrResult($record) |
|
| 265 | - { |
|
| 260 | + private function getSolrResult($record) { |
|
| 266 | 261 | $fields = Solr::getFields(); |
| 267 | 262 | |
| 268 | 263 | $query = $this->solr->service->createSelect(); |
@@ -334,8 +329,7 @@ discard block |
||
| 334 | 329 | * |
| 335 | 330 | * @return array |
| 336 | 331 | */ |
| 337 | - private function getSolrRecord($record, $result) |
|
| 338 | - { |
|
| 332 | + private function getSolrRecord($record, $result) { |
|
| 339 | 333 | // If it is a fulltext search, fetch the highlighting results. |
| 340 | 334 | if ($this->metadata['fulltextSearch']) { |
| 341 | 335 | $data = $result->getData(); |
@@ -382,8 +376,7 @@ discard block |
||
| 382 | 376 | * |
| 383 | 377 | * @return int The current position |
| 384 | 378 | */ |
| 385 | - public function key() |
|
| 386 | - { |
|
| 379 | + public function key() { |
|
| 387 | 380 | return $this->position; |
| 388 | 381 | } |
| 389 | 382 | |
@@ -397,8 +390,7 @@ discard block |
||
| 397 | 390 | * |
| 398 | 391 | * @return void |
| 399 | 392 | */ |
| 400 | - public function move($position, $steps) |
|
| 401 | - { |
|
| 393 | + public function move($position, $steps) { |
|
| 402 | 394 | $position = intval($position); |
| 403 | 395 | // Check if list position is valid. |
| 404 | 396 | if ( |
@@ -429,8 +421,7 @@ discard block |
||
| 429 | 421 | * |
| 430 | 422 | * @return void |
| 431 | 423 | */ |
| 432 | - public function moveUp($position) |
|
| 433 | - { |
|
| 424 | + public function moveUp($position) { |
|
| 434 | 425 | $this->move($position, -1); |
| 435 | 426 | } |
| 436 | 427 | |
@@ -443,8 +434,7 @@ discard block |
||
| 443 | 434 | * |
| 444 | 435 | * @return void |
| 445 | 436 | */ |
| 446 | - public function moveDown($position) |
|
| 447 | - { |
|
| 437 | + public function moveDown($position) { |
|
| 448 | 438 | $this->move($position, 1); |
| 449 | 439 | } |
| 450 | 440 | |
@@ -456,8 +446,7 @@ discard block |
||
| 456 | 446 | * |
| 457 | 447 | * @return void |
| 458 | 448 | */ |
| 459 | - public function next() |
|
| 460 | - { |
|
| 449 | + public function next() { |
|
| 461 | 450 | $this->position++; |
| 462 | 451 | } |
| 463 | 452 | |
@@ -471,8 +460,7 @@ discard block |
||
| 471 | 460 | * |
| 472 | 461 | * @return bool Does the given offset exist? |
| 473 | 462 | */ |
| 474 | - public function offsetExists($offset) |
|
| 475 | - { |
|
| 463 | + public function offsetExists($offset) { |
|
| 476 | 464 | return isset($this->elements[$offset]); |
| 477 | 465 | } |
| 478 | 466 | |
@@ -486,8 +474,7 @@ discard block |
||
| 486 | 474 | * |
| 487 | 475 | * @return array The element at the given offset |
| 488 | 476 | */ |
| 489 | - public function offsetGet($offset) |
|
| 490 | - { |
|
| 477 | + public function offsetGet($offset) { |
|
| 491 | 478 | if ($this->offsetExists($offset)) { |
| 492 | 479 | return $this->getRecord($this->elements[$offset]); |
| 493 | 480 | } else { |
@@ -507,8 +494,7 @@ discard block |
||
| 507 | 494 | * |
| 508 | 495 | * @return void |
| 509 | 496 | */ |
| 510 | - public function offsetSet($offset, $value) |
|
| 511 | - { |
|
| 497 | + public function offsetSet($offset, $value) { |
|
| 512 | 498 | if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($offset)) { |
| 513 | 499 | $this->elements[$offset] = $value; |
| 514 | 500 | } else { |
@@ -528,8 +514,7 @@ discard block |
||
| 528 | 514 | * |
| 529 | 515 | * @return array The removed element |
| 530 | 516 | */ |
| 531 | - public function remove($position) |
|
| 532 | - { |
|
| 517 | + public function remove($position) { |
|
| 533 | 518 | $position = intval($position); |
| 534 | 519 | if ( |
| 535 | 520 | $position < 0 |
@@ -553,8 +538,7 @@ discard block |
||
| 553 | 538 | * |
| 554 | 539 | * @return array The indizes of the removed elements |
| 555 | 540 | */ |
| 556 | - public function removeRange($position, $length) |
|
| 557 | - { |
|
| 541 | + public function removeRange($position, $length) { |
|
| 558 | 542 | $position = intval($position); |
| 559 | 543 | if ( |
| 560 | 544 | $position < 0 |
@@ -575,8 +559,7 @@ discard block |
||
| 575 | 559 | * |
| 576 | 560 | * @return void |
| 577 | 561 | */ |
| 578 | - public function reset() |
|
| 579 | - { |
|
| 562 | + public function reset() { |
|
| 580 | 563 | $this->elements = []; |
| 581 | 564 | $this->records = []; |
| 582 | 565 | $this->metadata = []; |
@@ -592,8 +575,7 @@ discard block |
||
| 592 | 575 | * |
| 593 | 576 | * @return void |
| 594 | 577 | */ |
| 595 | - public function rewind() |
|
| 596 | - { |
|
| 578 | + public function rewind() { |
|
| 597 | 579 | $this->position = 0; |
| 598 | 580 | } |
| 599 | 581 | |
@@ -606,8 +588,7 @@ discard block |
||
| 606 | 588 | * |
| 607 | 589 | * @return void |
| 608 | 590 | */ |
| 609 | - public function save($pid = 0) |
|
| 610 | - { |
|
| 591 | + public function save($pid = 0) { |
|
| 611 | 592 | $pid = max(intval($pid), 0); |
| 612 | 593 | // If no PID is given, save to the user's session instead |
| 613 | 594 | if ($pid > 0) { |
@@ -624,8 +605,7 @@ discard block |
||
| 624 | 605 | * |
| 625 | 606 | * @return bool true on success or false on failure |
| 626 | 607 | */ |
| 627 | - protected function solrConnect() |
|
| 628 | - { |
|
| 608 | + protected function solrConnect() { |
|
| 629 | 609 | // Get Solr instance. |
| 630 | 610 | if (!$this->solr) { |
| 631 | 611 | // Connect to Solr server. |
@@ -674,8 +654,7 @@ discard block |
||
| 674 | 654 | * |
| 675 | 655 | * @return void |
| 676 | 656 | */ |
| 677 | - public function sort($by, $asc = true) |
|
| 678 | - { |
|
| 657 | + public function sort($by, $asc = true) { |
|
| 679 | 658 | $newOrder = []; |
| 680 | 659 | $nonSortable = []; |
| 681 | 660 | foreach ($this->elements as $num => $element) { |
@@ -712,8 +691,7 @@ discard block |
||
| 712 | 691 | * |
| 713 | 692 | * @return void |
| 714 | 693 | */ |
| 715 | - public function offsetUnset($offset) |
|
| 716 | - { |
|
| 694 | + public function offsetUnset($offset) { |
|
| 717 | 695 | unset($this->elements[$offset]); |
| 718 | 696 | // Re-number the elements. |
| 719 | 697 | $this->elements = array_values($this->elements); |
@@ -728,8 +706,7 @@ discard block |
||
| 728 | 706 | * |
| 729 | 707 | * @return bool Is the current list position valid? |
| 730 | 708 | */ |
| 731 | - public function valid() |
|
| 732 | - { |
|
| 709 | + public function valid() { |
|
| 733 | 710 | return isset($this->elements[$this->position]); |
| 734 | 711 | } |
| 735 | 712 | |
@@ -740,8 +717,7 @@ discard block |
||
| 740 | 717 | * |
| 741 | 718 | * @return array The list's metadata |
| 742 | 719 | */ |
| 743 | - protected function _getMetadata() |
|
| 744 | - { |
|
| 720 | + protected function _getMetadata() { |
|
| 745 | 721 | return $this->metadata; |
| 746 | 722 | } |
| 747 | 723 | |
@@ -754,8 +730,7 @@ discard block |
||
| 754 | 730 | * |
| 755 | 731 | * @return void |
| 756 | 732 | */ |
| 757 | - protected function _setMetadata(array $metadata = []) |
|
| 758 | - { |
|
| 733 | + protected function _setMetadata(array $metadata = []) { |
|
| 759 | 734 | $this->metadata = $metadata; |
| 760 | 735 | } |
| 761 | 736 | |
@@ -769,8 +744,7 @@ discard block |
||
| 769 | 744 | * |
| 770 | 745 | * @return void |
| 771 | 746 | */ |
| 772 | - public function __construct(array $elements = [], array $metadata = []) |
|
| 773 | - { |
|
| 747 | + public function __construct(array $elements = [], array $metadata = []) { |
|
| 774 | 748 | if ( |
| 775 | 749 | empty($elements) |
| 776 | 750 | && empty($metadata) |
@@ -803,8 +777,7 @@ discard block |
||
| 803 | 777 | * |
| 804 | 778 | * @return void |
| 805 | 779 | */ |
| 806 | - protected function __clone() |
|
| 807 | - { |
|
| 780 | + protected function __clone() { |
|
| 808 | 781 | // This method is defined as protected because singleton objects should not be cloned. |
| 809 | 782 | } |
| 810 | 783 | |
@@ -817,8 +790,7 @@ discard block |
||
| 817 | 790 | * |
| 818 | 791 | * @return mixed Value of $this->$var |
| 819 | 792 | */ |
| 820 | - public function __get($var) |
|
| 821 | - { |
|
| 793 | + public function __get($var) { |
|
| 822 | 794 | $method = '_get' . ucfirst($var); |
| 823 | 795 | if ( |
| 824 | 796 | !property_exists($this, $var) |
@@ -840,8 +812,7 @@ discard block |
||
| 840 | 812 | * |
| 841 | 813 | * @return bool true if variable is set and not empty, false otherwise |
| 842 | 814 | */ |
| 843 | - public function __isset($var) |
|
| 844 | - { |
|
| 815 | + public function __isset($var) { |
|
| 845 | 816 | return !empty($this->__get($var)); |
| 846 | 817 | } |
| 847 | 818 | |
@@ -855,8 +826,7 @@ discard block |
||
| 855 | 826 | * |
| 856 | 827 | * @return void |
| 857 | 828 | */ |
| 858 | - public function __set($var, $value) |
|
| 859 | - { |
|
| 829 | + public function __set($var, $value) { |
|
| 860 | 830 | $method = '_set' . ucfirst($var); |
| 861 | 831 | if ( |
| 862 | 832 | !property_exists($this, $var) |
@@ -876,8 +846,7 @@ discard block |
||
| 876 | 846 | * |
| 877 | 847 | * @return array Properties to be serialized |
| 878 | 848 | */ |
| 879 | - public function __sleep() |
|
| 880 | - { |
|
| 849 | + public function __sleep() { |
|
| 881 | 850 | return ['elements', 'metadata']; |
| 882 | 851 | } |
| 883 | 852 | |
@@ -889,8 +858,7 @@ discard block |
||
| 889 | 858 | * |
| 890 | 859 | * @return void |
| 891 | 860 | */ |
| 892 | - public function __wakeup() |
|
| 893 | - { |
|
| 861 | + public function __wakeup() { |
|
| 894 | 862 | $this->count = count($this->elements); |
| 895 | 863 | } |
| 896 | 864 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | if ($resArray['uid'] == $record['uid']) { |
| 225 | 225 | $record['thumbnail'] = $resArray['thumbnail']; |
| 226 | 226 | $record['metadata'] = $metadata; |
| 227 | - } elseif (($key = array_search(['u' => $resArray['uid']], $record['subparts'], true)) !== false) { |
|
| 227 | + } elseif (($key = array_search(['u' => $resArray['uid']], $record['subparts'], TRUE)) !== FALSE) { |
|
| 228 | 228 | $record['subparts'][$key] = [ |
| 229 | 229 | 'uid' => $resArray['uid'], |
| 230 | 230 | 'page' => 1, |
@@ -658,10 +658,10 @@ discard block |
||
| 658 | 658 | // Add static fields. |
| 659 | 659 | $this->solrConfig['type'] = 'type'; |
| 660 | 660 | } else { |
| 661 | - return false; |
|
| 661 | + return FALSE; |
|
| 662 | 662 | } |
| 663 | 663 | } |
| 664 | - return true; |
|
| 664 | + return TRUE; |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | * |
| 675 | 675 | * @return void |
| 676 | 676 | */ |
| 677 | - public function sort($by, $asc = true) |
|
| 677 | + public function sort($by, $asc = TRUE) |
|
| 678 | 678 | { |
| 679 | 679 | $newOrder = []; |
| 680 | 680 | $nonSortable = []; |
@@ -56,8 +56,7 @@ discard block |
||
| 56 | 56 | * @property-read string $toplevelId This holds the toplevel manifest's @id |
| 57 | 57 | * @property-read mixed $uid This holds the UID or the URL of the document |
| 58 | 58 | */ |
| 59 | -final class IiifManifest extends Document |
|
| 60 | -{ |
|
| 59 | +final class IiifManifest extends Document { |
|
| 61 | 60 | /** |
| 62 | 61 | * This holds the manifest file as string for serialization purposes |
| 63 | 62 | * @see __sleep() / __wakeup() |
@@ -118,8 +117,7 @@ discard block |
||
| 118 | 117 | * {@inheritDoc} |
| 119 | 118 | * @see Document::establishRecordId() |
| 120 | 119 | */ |
| 121 | - protected function establishRecordId($pid) |
|
| 122 | - { |
|
| 120 | + protected function establishRecordId($pid) { |
|
| 123 | 121 | if ($this->iiif !== null) { |
| 124 | 122 | /* |
| 125 | 123 | * FIXME This will not consistently work because we can not be sure to have the pid at hand. It may miss |
@@ -170,8 +168,7 @@ discard block |
||
| 170 | 168 | * {@inheritDoc} |
| 171 | 169 | * @see Document::getDocument() |
| 172 | 170 | */ |
| 173 | - protected function getDocument() |
|
| 174 | - { |
|
| 171 | + protected function getDocument() { |
|
| 175 | 172 | return $this->iiif; |
| 176 | 173 | } |
| 177 | 174 | |
@@ -184,8 +181,7 @@ discard block |
||
| 184 | 181 | * @return string 'IIIF1' if the resource is a Metadata API 1 resource, 'IIIF2' / 'IIIF3' if |
| 185 | 182 | * the resource is a Presentation API 2 / 3 resource |
| 186 | 183 | */ |
| 187 | - public function getIiifVersion() |
|
| 188 | - { |
|
| 184 | + public function getIiifVersion() { |
|
| 189 | 185 | if (!isset($this->iiifVersion)) { |
| 190 | 186 | if ($this->iiif instanceof AbstractIiifResource1) { |
| 191 | 187 | $this->iiifVersion = 'IIIF1'; |
@@ -226,8 +222,7 @@ discard block |
||
| 226 | 222 | * |
| 227 | 223 | * @return array|string |
| 228 | 224 | */ |
| 229 | - protected function getUseGroups($use) |
|
| 230 | - { |
|
| 225 | + protected function getUseGroups($use) { |
|
| 231 | 226 | if (!$this->useGrpsLoaded) { |
| 232 | 227 | // Get configured USE attributes. |
| 233 | 228 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -255,8 +250,7 @@ discard block |
||
| 255 | 250 | * {@inheritDoc} |
| 256 | 251 | * @see Document::_getPhysicalStructure() |
| 257 | 252 | */ |
| 258 | - protected function _getPhysicalStructure() |
|
| 259 | - { |
|
| 253 | + protected function _getPhysicalStructure() { |
|
| 260 | 254 | // Is there no physical structure array yet? |
| 261 | 255 | if (!$this->physicalStructureLoaded) { |
| 262 | 256 | if ($this->iiif == null || !($this->iiif instanceof ManifestInterface)) { |
@@ -369,8 +363,7 @@ discard block |
||
| 369 | 363 | * {@inheritDoc} |
| 370 | 364 | * @see Document::getDownloadLocation() |
| 371 | 365 | */ |
| 372 | - public function getDownloadLocation($id) |
|
| 373 | - { |
|
| 366 | + public function getDownloadLocation($id) { |
|
| 374 | 367 | $fileLocation = $this->getFileLocation($id); |
| 375 | 368 | $resource = $this->iiif->getContainedResourceById($fileLocation); |
| 376 | 369 | if ($resource instanceof AbstractImageService) { |
@@ -383,8 +376,7 @@ discard block |
||
| 383 | 376 | * {@inheritDoc} |
| 384 | 377 | * @see Document::getFileLocation() |
| 385 | 378 | */ |
| 386 | - public function getFileLocation($id) |
|
| 387 | - { |
|
| 379 | + public function getFileLocation($id) { |
|
| 388 | 380 | if ($id == null) { |
| 389 | 381 | return null; |
| 390 | 382 | } |
@@ -408,8 +400,7 @@ discard block |
||
| 408 | 400 | * {@inheritDoc} |
| 409 | 401 | * @see Document::getFileMimeType() |
| 410 | 402 | */ |
| 411 | - public function getFileMimeType($id) |
|
| 412 | - { |
|
| 403 | + public function getFileMimeType($id) { |
|
| 413 | 404 | $fileResource = $this->iiif->getContainedResourceById($id); |
| 414 | 405 | if ($fileResource instanceof CanvasInterface) { |
| 415 | 406 | $format = "application/vnd.kitodo.iiif"; |
@@ -434,8 +425,7 @@ discard block |
||
| 434 | 425 | * {@inheritDoc} |
| 435 | 426 | * @see Document::getLogicalStructure() |
| 436 | 427 | */ |
| 437 | - public function getLogicalStructure($id, $recursive = false) |
|
| 438 | - { |
|
| 428 | + public function getLogicalStructure($id, $recursive = false) { |
|
| 439 | 429 | $details = []; |
| 440 | 430 | if (!$recursive && !empty($this->logicalUnits[$id])) { |
| 441 | 431 | return $this->logicalUnits[$id]; |
@@ -470,8 +460,7 @@ discard block |
||
| 470 | 460 | * @param array $processedStructures: IIIF resources that already have been processed |
| 471 | 461 | * @return array Logical structure array |
| 472 | 462 | */ |
| 473 | - protected function getLogicalStructureInfo(IiifResourceInterface $resource, $recursive = false, &$processedStructures = []) |
|
| 474 | - { |
|
| 463 | + protected function getLogicalStructureInfo(IiifResourceInterface $resource, $recursive = false, &$processedStructures = []) { |
|
| 475 | 464 | $details = []; |
| 476 | 465 | $details['id'] = $resource->getId(); |
| 477 | 466 | $details['dmdId'] = ''; |
@@ -563,8 +552,7 @@ discard block |
||
| 563 | 552 | * |
| 564 | 553 | * @todo This method is still in experimental; the method signature may change. |
| 565 | 554 | */ |
| 566 | - public function getManifestMetadata($id, $cPid = 0, $withDescription = true, $withRights = true, $withRelated = true) |
|
| 567 | - { |
|
| 555 | + public function getManifestMetadata($id, $cPid = 0, $withDescription = true, $withRights = true, $withRelated = true) { |
|
| 568 | 556 | if (!empty($this->originalMetadataArray[$id])) { |
| 569 | 557 | return $this->originalMetadataArray[$id]; |
| 570 | 558 | } |
@@ -606,8 +594,7 @@ discard block |
||
| 606 | 594 | * {@inheritDoc} |
| 607 | 595 | * @see Document::getMetadata() |
| 608 | 596 | */ |
| 609 | - public function getMetadata($id, $cPid = 0) |
|
| 610 | - { |
|
| 597 | + public function getMetadata($id, $cPid = 0) { |
|
| 611 | 598 | if (!empty($this->metadataArray[$id]) && $this->metadataArray[0] == $cPid) { |
| 612 | 599 | return $this->metadataArray[$id]; |
| 613 | 600 | } |
@@ -714,8 +701,7 @@ discard block |
||
| 714 | 701 | * {@inheritDoc} |
| 715 | 702 | * @see Document::_getSmLinks() |
| 716 | 703 | */ |
| 717 | - protected function _getSmLinks() |
|
| 718 | - { |
|
| 704 | + protected function _getSmLinks() { |
|
| 719 | 705 | if (!$this->smLinksLoaded && isset($this->iiif) && $this->iiif instanceof ManifestInterface) { |
| 720 | 706 | if (!empty($this->iiif->getDefaultCanvases())) { |
| 721 | 707 | foreach ($this->iiif->getDefaultCanvases() as $canvas) { |
@@ -739,8 +725,7 @@ discard block |
||
| 739 | 725 | * |
| 740 | 726 | * @param RangeInterface $range: Current range whose canvases shall be linked |
| 741 | 727 | */ |
| 742 | - private function smLinkRangeCanvasesRecursively(RangeInterface $range) |
|
| 743 | - { |
|
| 728 | + private function smLinkRangeCanvasesRecursively(RangeInterface $range) { |
|
| 744 | 729 | // map range's canvases including all child ranges' canvases |
| 745 | 730 | if (!$range->isTopRange()) { |
| 746 | 731 | foreach ($range->getAllCanvasesRecursively() as $canvas) { |
@@ -763,8 +748,7 @@ discard block |
||
| 763 | 748 | * @param CanvasInterface $canvas |
| 764 | 749 | * @param IiifResourceInterface $resource |
| 765 | 750 | */ |
| 766 | - private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInterface $resource) |
|
| 767 | - { |
|
| 751 | + private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInterface $resource) { |
|
| 768 | 752 | $this->smLinks['l2p'][$resource->getId()][] = $canvas->getId(); |
| 769 | 753 | if (!is_array($this->smLinks['p2l'][$canvas->getId()]) || !in_array($resource->getId(), $this->smLinks['p2l'][$canvas->getId()])) { |
| 770 | 754 | $this->smLinks['p2l'][$canvas->getId()][] = $resource->getId(); |
@@ -779,8 +763,7 @@ discard block |
||
| 779 | 763 | * |
| 780 | 764 | * @see Document::getParentDocumentUidForSaving() |
| 781 | 765 | */ |
| 782 | - protected function getParentDocumentUidForSaving($pid, $core, $owner) |
|
| 783 | - { |
|
| 766 | + protected function getParentDocumentUidForSaving($pid, $core, $owner) { |
|
| 784 | 767 | // Do nothing. |
| 785 | 768 | } |
| 786 | 769 | |
@@ -789,8 +772,7 @@ discard block |
||
| 789 | 772 | * @see Document::getFullText() |
| 790 | 773 | */ |
| 791 | 774 | //TODO: rewrite it to get full OCR |
| 792 | - public function getFullText($id) |
|
| 793 | - { |
|
| 775 | + public function getFullText($id) { |
|
| 794 | 776 | $rawText = ''; |
| 795 | 777 | // Get text from raw text array if available. |
| 796 | 778 | if (!empty($this->rawTextArray[$id])) { |
@@ -847,8 +829,7 @@ discard block |
||
| 847 | 829 | * |
| 848 | 830 | * @return IiifResourceInterface |
| 849 | 831 | */ |
| 850 | - public function getIiif() |
|
| 851 | - { |
|
| 832 | + public function getIiif() { |
|
| 852 | 833 | return $this->iiif; |
| 853 | 834 | } |
| 854 | 835 | |
@@ -856,8 +837,7 @@ discard block |
||
| 856 | 837 | * {@inheritDoc} |
| 857 | 838 | * @see Document::init() |
| 858 | 839 | */ |
| 859 | - protected function init() |
|
| 860 | - { |
|
| 840 | + protected function init() { |
|
| 861 | 841 | // Nothing to do here, at the moment |
| 862 | 842 | } |
| 863 | 843 | |
@@ -865,8 +845,7 @@ discard block |
||
| 865 | 845 | * {@inheritDoc} |
| 866 | 846 | * @see Document::loadLocation() |
| 867 | 847 | */ |
| 868 | - protected function loadLocation($location) |
|
| 869 | - { |
|
| 848 | + protected function loadLocation($location) { |
|
| 870 | 849 | $fileResource = GeneralUtility::getUrl($location); |
| 871 | 850 | if ($fileResource !== false) { |
| 872 | 851 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -889,8 +868,7 @@ discard block |
||
| 889 | 868 | * {@inheritDoc} |
| 890 | 869 | * @see \Kitodo\Dlf\Common\Document::prepareMetadataArray() |
| 891 | 870 | */ |
| 892 | - protected function prepareMetadataArray($cPid) |
|
| 893 | - { |
|
| 871 | + protected function prepareMetadataArray($cPid) { |
|
| 894 | 872 | $id = $this->iiif->getId(); |
| 895 | 873 | $this->metadataArray[(string) $id] = $this->getMetadata((string) $id, $cPid); |
| 896 | 874 | } |
@@ -899,8 +877,7 @@ discard block |
||
| 899 | 877 | * {@inheritDoc} |
| 900 | 878 | * @see Document::setPreloadedDocument() |
| 901 | 879 | */ |
| 902 | - protected function setPreloadedDocument($preloadedDocument) |
|
| 903 | - { |
|
| 880 | + protected function setPreloadedDocument($preloadedDocument) { |
|
| 904 | 881 | if ($preloadedDocument instanceof ManifestInterface) { |
| 905 | 882 | $this->iiif = $preloadedDocument; |
| 906 | 883 | return true; |
@@ -912,8 +889,7 @@ discard block |
||
| 912 | 889 | * {@inheritDoc} |
| 913 | 890 | * @see Document::ensureHasFulltextIsSet() |
| 914 | 891 | */ |
| 915 | - protected function ensureHasFulltextIsSet() |
|
| 916 | - { |
|
| 892 | + protected function ensureHasFulltextIsSet() { |
|
| 917 | 893 | /* |
| 918 | 894 | * TODO Check annotations and annotation lists of canvas for ALTO documents. |
| 919 | 895 | * Example: |
@@ -959,8 +935,7 @@ discard block |
||
| 959 | 935 | * {@inheritDoc} |
| 960 | 936 | * @see \Kitodo\Dlf\Common\Document::_getThumbnail() |
| 961 | 937 | */ |
| 962 | - protected function _getThumbnail($forceReload = false) |
|
| 963 | - { |
|
| 938 | + protected function _getThumbnail($forceReload = false) { |
|
| 964 | 939 | return $this->iiif->getThumbnailUrl(); |
| 965 | 940 | } |
| 966 | 941 | |
@@ -968,8 +943,7 @@ discard block |
||
| 968 | 943 | * {@inheritDoc} |
| 969 | 944 | * @see \Kitodo\Dlf\Common\Document::_getToplevelId() |
| 970 | 945 | */ |
| 971 | - protected function _getToplevelId() |
|
| 972 | - { |
|
| 946 | + protected function _getToplevelId() { |
|
| 973 | 947 | if (empty($this->toplevelId)) { |
| 974 | 948 | if (isset($this->iiif)) { |
| 975 | 949 | $this->toplevelId = $this->iiif->getId(); |
@@ -986,8 +960,7 @@ discard block |
||
| 986 | 960 | * |
| 987 | 961 | * @return void |
| 988 | 962 | */ |
| 989 | - public function __wakeup() |
|
| 990 | - { |
|
| 963 | + public function __wakeup() { |
|
| 991 | 964 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 992 | 965 | IiifHelper::setUrlReader(IiifUrlReader::getInstance()); |
| 993 | 966 | IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']); |
@@ -1006,8 +979,7 @@ discard block |
||
| 1006 | 979 | * |
| 1007 | 980 | * @return string[] |
| 1008 | 981 | */ |
| 1009 | - public function __sleep() |
|
| 1010 | - { |
|
| 982 | + public function __sleep() { |
|
| 1011 | 983 | // TODO implement serializiation in IIIF library |
| 1012 | 984 | $jsonArray = $this->iiif->getOriginalJsonArray(); |
| 1013 | 985 | $this->asJson = json_encode($jsonArray); |
@@ -24,8 +24,7 @@ discard block |
||
| 24 | 24 | * @subpackage dlf |
| 25 | 25 | * @access public |
| 26 | 26 | */ |
| 27 | -class ResultDocument |
|
| 28 | -{ |
|
| 27 | +class ResultDocument { |
|
| 29 | 28 | |
| 30 | 29 | /** |
| 31 | 30 | * The identifier |
@@ -102,8 +101,7 @@ discard block |
||
| 102 | 101 | * |
| 103 | 102 | * @return void |
| 104 | 103 | */ |
| 105 | - public function __construct($record, $highlighting, $fields) |
|
| 106 | - { |
|
| 104 | + public function __construct($record, $highlighting, $fields) { |
|
| 107 | 105 | $this->id = $record[$fields['id']]; |
| 108 | 106 | $this->uid = $record[$fields['uid']]; |
| 109 | 107 | $this->page = $record[$fields['page']]; |
@@ -124,8 +122,7 @@ discard block |
||
| 124 | 122 | * |
| 125 | 123 | * @return string The result's record identifier |
| 126 | 124 | */ |
| 127 | - public function getId() |
|
| 128 | - { |
|
| 125 | + public function getId() { |
|
| 129 | 126 | return $this->id; |
| 130 | 127 | } |
| 131 | 128 | |
@@ -136,8 +133,7 @@ discard block |
||
| 136 | 133 | * |
| 137 | 134 | * @return string|null The result's record unified identifier |
| 138 | 135 | */ |
| 139 | - public function getUid() |
|
| 140 | - { |
|
| 136 | + public function getUid() { |
|
| 141 | 137 | return $this->uid; |
| 142 | 138 | } |
| 143 | 139 | |
@@ -148,8 +144,7 @@ discard block |
||
| 148 | 144 | * |
| 149 | 145 | * @return int The result's record page |
| 150 | 146 | */ |
| 151 | - public function getPage() |
|
| 152 | - { |
|
| 147 | + public function getPage() { |
|
| 153 | 148 | return $this->page; |
| 154 | 149 | } |
| 155 | 150 | |
@@ -160,8 +155,7 @@ discard block |
||
| 160 | 155 | * |
| 161 | 156 | * @return string All result's record snippets imploded to one string |
| 162 | 157 | */ |
| 163 | - public function getSnippets() |
|
| 164 | - { |
|
| 158 | + public function getSnippets() { |
|
| 165 | 159 | return $this->snippets; |
| 166 | 160 | } |
| 167 | 161 | |
@@ -172,8 +166,7 @@ discard block |
||
| 172 | 166 | * |
| 173 | 167 | * @return array(Page) All result's pages which contain search phrase |
| 174 | 168 | */ |
| 175 | - public function getPages() |
|
| 176 | - { |
|
| 169 | + public function getPages() { |
|
| 177 | 170 | return $this->pages; |
| 178 | 171 | } |
| 179 | 172 | |
@@ -184,8 +177,7 @@ discard block |
||
| 184 | 177 | * |
| 185 | 178 | * @return array(Region) All result's regions which contain search phrase |
| 186 | 179 | */ |
| 187 | - public function getRegions() |
|
| 188 | - { |
|
| 180 | + public function getRegions() { |
|
| 189 | 181 | return $this->regions; |
| 190 | 182 | } |
| 191 | 183 | |
@@ -196,8 +188,7 @@ discard block |
||
| 196 | 188 | * |
| 197 | 189 | * @return array(Highlight) All result's highlights of search phrase |
| 198 | 190 | */ |
| 199 | - public function getHighlights() |
|
| 200 | - { |
|
| 191 | + public function getHighlights() { |
|
| 201 | 192 | return $this->highlights; |
| 202 | 193 | } |
| 203 | 194 | |
@@ -208,8 +199,7 @@ discard block |
||
| 208 | 199 | * |
| 209 | 200 | * @return array(string) All result's highlights of search phrase |
| 210 | 201 | */ |
| 211 | - public function getHighlightsIds() |
|
| 212 | - { |
|
| 202 | + public function getHighlightsIds() { |
|
| 213 | 203 | $highlightsIds = []; |
| 214 | 204 | foreach ($this->highlights as $highlight) { |
| 215 | 205 | array_push($highlightsIds, $highlight->getId()); |
@@ -225,8 +215,7 @@ discard block |
||
| 225 | 215 | * |
| 226 | 216 | * @return void |
| 227 | 217 | */ |
| 228 | - private function parseSnippets() |
|
| 229 | - { |
|
| 218 | + private function parseSnippets() { |
|
| 230 | 219 | $snippetArray = $this->getArrayByIndex('text'); |
| 231 | 220 | |
| 232 | 221 | $this->snippets = !empty($snippetArray) ? implode(' [...] ', $snippetArray) : ''; |
@@ -240,8 +229,7 @@ discard block |
||
| 240 | 229 | * |
| 241 | 230 | * @return void |
| 242 | 231 | */ |
| 243 | - private function parsePages() |
|
| 244 | - { |
|
| 232 | + private function parsePages() { |
|
| 245 | 233 | $pageArray = $this->getArrayByIndex('pages'); |
| 246 | 234 | |
| 247 | 235 | $i = 0; |
@@ -261,8 +249,7 @@ discard block |
||
| 261 | 249 | * |
| 262 | 250 | * @return void |
| 263 | 251 | */ |
| 264 | - private function parseRegions() |
|
| 265 | - { |
|
| 252 | + private function parseRegions() { |
|
| 266 | 253 | $regionArray = $this->getArrayByIndex('regions'); |
| 267 | 254 | |
| 268 | 255 | $i = 0; |
@@ -282,8 +269,7 @@ discard block |
||
| 282 | 269 | * |
| 283 | 270 | * @return void |
| 284 | 271 | */ |
| 285 | - private function parseHighlights() |
|
| 286 | - { |
|
| 272 | + private function parseHighlights() { |
|
| 287 | 273 | $highlightArray = $this->getArrayByIndex('highlights'); |
| 288 | 274 | |
| 289 | 275 | foreach ($highlightArray as $highlights) { |
@@ -304,8 +290,7 @@ discard block |
||
| 304 | 290 | * |
| 305 | 291 | * @return array |
| 306 | 292 | */ |
| 307 | - private function getArrayByIndex($index) |
|
| 308 | - { |
|
| 293 | + private function getArrayByIndex($index) { |
|
| 309 | 294 | $objectArray = []; |
| 310 | 295 | foreach ($this->snippetsForRecord as $snippet) { |
| 311 | 296 | if (!empty($snippet[$index])) { |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | $this->xEndPosition = $highlight['lrx']; |
| 88 | 88 | $this->yBeginPosition = $highlight['uly']; |
| 89 | 89 | $this->yEndPosition = $highlight['lry']; |
| 90 | - $this->id = $this->xBeginPosition . '_' . $this->yBeginPosition; |
|
| 90 | + $this->id = $this->xBeginPosition.'_'.$this->yBeginPosition; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -20,8 +20,7 @@ discard block |
||
| 20 | 20 | * @subpackage dlf |
| 21 | 21 | * @access public |
| 22 | 22 | */ |
| 23 | -class Highlight |
|
| 24 | -{ |
|
| 23 | +class Highlight { |
|
| 25 | 24 | |
| 26 | 25 | /** |
| 27 | 26 | * The identifier in form 'w_h_x_y' |
@@ -80,8 +79,7 @@ discard block |
||
| 80 | 79 | * |
| 81 | 80 | * @return void |
| 82 | 81 | */ |
| 83 | - public function __construct($highlight) |
|
| 84 | - { |
|
| 82 | + public function __construct($highlight) { |
|
| 85 | 83 | $this->parentRegionId = $highlight['parentRegionIdx']; |
| 86 | 84 | $this->xBeginPosition = $highlight['ulx']; |
| 87 | 85 | $this->xEndPosition = $highlight['lrx']; |
@@ -97,8 +95,7 @@ discard block |
||
| 97 | 95 | * |
| 98 | 96 | * @return string The highlight's identifier |
| 99 | 97 | */ |
| 100 | - public function getId() |
|
| 101 | - { |
|
| 98 | + public function getId() { |
|
| 102 | 99 | return $this->id; |
| 103 | 100 | } |
| 104 | 101 | |
@@ -109,8 +106,7 @@ discard block |
||
| 109 | 106 | * |
| 110 | 107 | * @return int The highlight's horizontal beginning position |
| 111 | 108 | */ |
| 112 | - public function getXBeginPosition() |
|
| 113 | - { |
|
| 109 | + public function getXBeginPosition() { |
|
| 114 | 110 | return $this->xBeginPosition; |
| 115 | 111 | } |
| 116 | 112 | |
@@ -121,8 +117,7 @@ discard block |
||
| 121 | 117 | * |
| 122 | 118 | * @return int The highlight's horizontal ending position |
| 123 | 119 | */ |
| 124 | - public function getXEndPosition() |
|
| 125 | - { |
|
| 120 | + public function getXEndPosition() { |
|
| 126 | 121 | return $this->xEndPosition; |
| 127 | 122 | } |
| 128 | 123 | |
@@ -133,8 +128,7 @@ discard block |
||
| 133 | 128 | * |
| 134 | 129 | * @return int The highlight's vertical beginning position |
| 135 | 130 | */ |
| 136 | - public function getYBeginPosition() |
|
| 137 | - { |
|
| 131 | + public function getYBeginPosition() { |
|
| 138 | 132 | return $this->yBeginPosition; |
| 139 | 133 | } |
| 140 | 134 | |
@@ -145,8 +139,7 @@ discard block |
||
| 145 | 139 | * |
| 146 | 140 | * @return int The highlight's vertical ending position |
| 147 | 141 | */ |
| 148 | - public function getYEndPosition() |
|
| 149 | - { |
|
| 142 | + public function getYEndPosition() { |
|
| 150 | 143 | return $this->yEndPosition; |
| 151 | 144 | } |
| 152 | 145 | } |
@@ -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 | // Turn off libxml's error logging. |
@@ -745,8 +732,7 @@ discard block |
||
| 745 | 732 | * {@inheritDoc} |
| 746 | 733 | * @see \Kitodo\Dlf\Common\Document::ensureHasFulltextIsSet() |
| 747 | 734 | */ |
| 748 | - protected function ensureHasFulltextIsSet() |
|
| 749 | - { |
|
| 735 | + protected function ensureHasFulltextIsSet() { |
|
| 750 | 736 | // Are the fileGrps already loaded? |
| 751 | 737 | if (!$this->fileGrpsLoaded) { |
| 752 | 738 | $this->_getFileGrps(); |
@@ -757,8 +743,7 @@ discard block |
||
| 757 | 743 | * {@inheritDoc} |
| 758 | 744 | * @see Document::getParentDocumentUid() |
| 759 | 745 | */ |
| 760 | - protected function getParentDocumentUidForSaving($pid, $core, $owner) |
|
| 761 | - { |
|
| 746 | + protected function getParentDocumentUidForSaving($pid, $core, $owner) { |
|
| 762 | 747 | $partof = 0; |
| 763 | 748 | // Get the closest ancestor of the current document which has a MPTR child. |
| 764 | 749 | $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $this->_getToplevelId() . '"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); |
@@ -781,8 +766,7 @@ discard block |
||
| 781 | 766 | * {@inheritDoc} |
| 782 | 767 | * @see Document::setPreloadedDocument() |
| 783 | 768 | */ |
| 784 | - protected function setPreloadedDocument($preloadedDocument) |
|
| 785 | - { |
|
| 769 | + protected function setPreloadedDocument($preloadedDocument) { |
|
| 786 | 770 | |
| 787 | 771 | if ($preloadedDocument instanceof \SimpleXMLElement) { |
| 788 | 772 | $this->xml = $preloadedDocument; |
@@ -795,8 +779,7 @@ discard block |
||
| 795 | 779 | * {@inheritDoc} |
| 796 | 780 | * @see Document::getDocument() |
| 797 | 781 | */ |
| 798 | - protected function getDocument() |
|
| 799 | - { |
|
| 782 | + protected function getDocument() { |
|
| 800 | 783 | return $this->mets; |
| 801 | 784 | } |
| 802 | 785 | |
@@ -807,8 +790,7 @@ discard block |
||
| 807 | 790 | * |
| 808 | 791 | * @return array Array of dmdSecs with their IDs as array key |
| 809 | 792 | */ |
| 810 | - protected function _getDmdSec() |
|
| 811 | - { |
|
| 793 | + protected function _getDmdSec() { |
|
| 812 | 794 | if (!$this->dmdSecLoaded) { |
| 813 | 795 | // Get available data formats. |
| 814 | 796 | $this->loadFormats(); |
@@ -846,8 +828,7 @@ discard block |
||
| 846 | 828 | * |
| 847 | 829 | * @return array Array of file use groups with file IDs |
| 848 | 830 | */ |
| 849 | - protected function _getFileGrps() |
|
| 850 | - { |
|
| 831 | + protected function _getFileGrps() { |
|
| 851 | 832 | if (!$this->fileGrpsLoaded) { |
| 852 | 833 | // Get configured USE attributes. |
| 853 | 834 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -892,8 +873,7 @@ discard block |
||
| 892 | 873 | * {@inheritDoc} |
| 893 | 874 | * @see \Kitodo\Dlf\Common\Document::prepareMetadataArray() |
| 894 | 875 | */ |
| 895 | - protected function prepareMetadataArray($cPid) |
|
| 896 | - { |
|
| 876 | + protected function prepareMetadataArray($cPid) { |
|
| 897 | 877 | $ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'); |
| 898 | 878 | // Get all logical structure nodes with metadata. |
| 899 | 879 | if (!empty($ids)) { |
@@ -911,8 +891,7 @@ discard block |
||
| 911 | 891 | * |
| 912 | 892 | * @return \SimpleXMLElement The XML's METS part as \SimpleXMLElement object |
| 913 | 893 | */ |
| 914 | - protected function _getMets() |
|
| 915 | - { |
|
| 894 | + protected function _getMets() { |
|
| 916 | 895 | return $this->mets; |
| 917 | 896 | } |
| 918 | 897 | |
@@ -920,8 +899,7 @@ discard block |
||
| 920 | 899 | * {@inheritDoc} |
| 921 | 900 | * @see \Kitodo\Dlf\Common\Document::_getPhysicalStructure() |
| 922 | 901 | */ |
| 923 | - protected function _getPhysicalStructure() |
|
| 924 | - { |
|
| 902 | + protected function _getPhysicalStructure() { |
|
| 925 | 903 | // Is there no physical structure array yet? |
| 926 | 904 | if (!$this->physicalStructureLoaded) { |
| 927 | 905 | // Does the document have a structMap node of type "PHYSICAL"? |
@@ -981,8 +959,7 @@ discard block |
||
| 981 | 959 | * {@inheritDoc} |
| 982 | 960 | * @see \Kitodo\Dlf\Common\Document::_getSmLinks() |
| 983 | 961 | */ |
| 984 | - protected function _getSmLinks() |
|
| 985 | - { |
|
| 962 | + protected function _getSmLinks() { |
|
| 986 | 963 | if (!$this->smLinksLoaded) { |
| 987 | 964 | $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink'); |
| 988 | 965 | if (!empty($smLinks)) { |
@@ -1000,8 +977,7 @@ discard block |
||
| 1000 | 977 | * {@inheritDoc} |
| 1001 | 978 | * @see \Kitodo\Dlf\Common\Document::_getThumbnail() |
| 1002 | 979 | */ |
| 1003 | - protected function _getThumbnail($forceReload = false) |
|
| 1004 | - { |
|
| 980 | + protected function _getThumbnail($forceReload = false) { |
|
| 1005 | 981 | if ( |
| 1006 | 982 | !$this->thumbnailLoaded |
| 1007 | 983 | || $forceReload |
@@ -1080,8 +1056,7 @@ discard block |
||
| 1080 | 1056 | * {@inheritDoc} |
| 1081 | 1057 | * @see \Kitodo\Dlf\Common\Document::_getToplevelId() |
| 1082 | 1058 | */ |
| 1083 | - protected function _getToplevelId() |
|
| 1084 | - { |
|
| 1059 | + protected function _getToplevelId() { |
|
| 1085 | 1060 | if (empty($this->toplevelId)) { |
| 1086 | 1061 | // Get all logical structure nodes with metadata, but without associated METS-Pointers. |
| 1087 | 1062 | $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'); |
@@ -1113,8 +1088,7 @@ discard block |
||
| 1113 | 1088 | * |
| 1114 | 1089 | * @return array Properties to be serialized |
| 1115 | 1090 | */ |
| 1116 | - public function __sleep() |
|
| 1117 | - { |
|
| 1091 | + public function __sleep() { |
|
| 1118 | 1092 | // \SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization |
| 1119 | 1093 | $this->asXML = $this->xml->asXML(); |
| 1120 | 1094 | return ['uid', 'pid', 'recordId', 'parentId', 'asXML']; |
@@ -1127,8 +1101,7 @@ discard block |
||
| 1127 | 1101 | * |
| 1128 | 1102 | * @return string String representing the METS object |
| 1129 | 1103 | */ |
| 1130 | - public function __toString() |
|
| 1131 | - { |
|
| 1104 | + public function __toString() { |
|
| 1132 | 1105 | $xml = new \DOMDocument('1.0', 'utf-8'); |
| 1133 | 1106 | $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); |
| 1134 | 1107 | $xml->formatOutput = true; |
@@ -1143,8 +1116,7 @@ discard block |
||
| 1143 | 1116 | * |
| 1144 | 1117 | * @return void |
| 1145 | 1118 | */ |
| 1146 | - public function __wakeup() |
|
| 1147 | - { |
|
| 1119 | + public function __wakeup() { |
|
| 1148 | 1120 | // Turn off libxml's error logging. |
| 1149 | 1121 | $libxmlErrors = libxml_use_internal_errors(true); |
| 1150 | 1122 | // Reload XML from string. |