@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * @property-read string $toplevelId This holds the toplevel structure's @ID (METS) or the manifest's @id (IIIF) |
51 | 51 | * @property-read string $parentHref URL of the parent document (determined via mptr element), or empty string if none is available |
52 | 52 | */ |
53 | -final class MetsDocument extends Doc |
|
54 | -{ |
|
53 | +final class MetsDocument extends Doc { |
|
55 | 54 | /** |
56 | 55 | * Subsections / tags that may occur within `<mets:amdSec>`. |
57 | 56 | * |
@@ -176,8 +175,7 @@ discard block |
||
176 | 175 | * |
177 | 176 | * @return void |
178 | 177 | */ |
179 | - public function addMetadataFromMets(&$metadata, $id) |
|
180 | - { |
|
178 | + public function addMetadataFromMets(&$metadata, $id) { |
|
181 | 179 | $details = $this->getLogicalStructure($id); |
182 | 180 | if (!empty($details)) { |
183 | 181 | $metadata['mets_order'][0] = $details['order']; |
@@ -191,8 +189,7 @@ discard block |
||
191 | 189 | * {@inheritDoc} |
192 | 190 | * @see \Kitodo\Dlf\Common\Doc::establishRecordId() |
193 | 191 | */ |
194 | - protected function establishRecordId($pid) |
|
195 | - { |
|
192 | + protected function establishRecordId($pid) { |
|
196 | 193 | // Check for METS object @ID. |
197 | 194 | if (!empty($this->mets['OBJID'])) { |
198 | 195 | $this->recordId = (string) $this->mets['OBJID']; |
@@ -212,8 +209,7 @@ discard block |
||
212 | 209 | * {@inheritDoc} |
213 | 210 | * @see \Kitodo\Dlf\Common\Doc::getDownloadLocation() |
214 | 211 | */ |
215 | - public function getDownloadLocation($id) |
|
216 | - { |
|
212 | + public function getDownloadLocation($id) { |
|
217 | 213 | $fileMimeType = $this->getFileMimeType($id); |
218 | 214 | $fileLocation = $this->getFileLocation($id); |
219 | 215 | if ($fileMimeType === 'application/vnd.kitodo.iiif') { |
@@ -238,8 +234,7 @@ discard block |
||
238 | 234 | * {@inheritDoc} |
239 | 235 | * @see \Kitodo\Dlf\Common\Doc::getFileLocation() |
240 | 236 | */ |
241 | - public function getFileLocation($id) |
|
242 | - { |
|
237 | + public function getFileLocation($id) { |
|
243 | 238 | $location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/mets:FLocat[@LOCTYPE="URL"]'); |
244 | 239 | if ( |
245 | 240 | !empty($id) |
@@ -256,8 +251,7 @@ discard block |
||
256 | 251 | * {@inheritDoc} |
257 | 252 | * @see \Kitodo\Dlf\Common\Doc::getFileMimeType() |
258 | 253 | */ |
259 | - public function getFileMimeType($id) |
|
260 | - { |
|
254 | + public function getFileMimeType($id) { |
|
261 | 255 | $mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/@MIMETYPE'); |
262 | 256 | if ( |
263 | 257 | !empty($id) |
@@ -274,8 +268,7 @@ discard block |
||
274 | 268 | * {@inheritDoc} |
275 | 269 | * @see \Kitodo\Dlf\Common\Doc::getLogicalStructure() |
276 | 270 | */ |
277 | - public function getLogicalStructure($id, $recursive = false) |
|
278 | - { |
|
271 | + public function getLogicalStructure($id, $recursive = false) { |
|
279 | 272 | $details = []; |
280 | 273 | // Is the requested logical unit already loaded? |
281 | 274 | if ( |
@@ -315,8 +308,7 @@ discard block |
||
315 | 308 | * |
316 | 309 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
317 | 310 | */ |
318 | - protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) |
|
319 | - { |
|
311 | + protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) { |
|
320 | 312 | // Get attributes. |
321 | 313 | foreach ($structure->attributes() as $attribute => $value) { |
322 | 314 | $attributes[$attribute] = (string) $value; |
@@ -420,8 +412,7 @@ discard block |
||
420 | 412 | * {@inheritDoc} |
421 | 413 | * @see \Kitodo\Dlf\Common\Doc::getMetadata() |
422 | 414 | */ |
423 | - public function getMetadata($id, $cPid = 0) |
|
424 | - { |
|
415 | + public function getMetadata($id, $cPid = 0) { |
|
425 | 416 | // Make sure $cPid is a non-negative integer. |
426 | 417 | $cPid = max(intval($cPid), 0); |
427 | 418 | // If $cPid is not given, try to get it elsewhere. |
@@ -675,8 +666,7 @@ discard block |
||
675 | 666 | * @param string $id: The "@ID" attribute of the file node |
676 | 667 | * @return void |
677 | 668 | */ |
678 | - protected function getMetadataIds($id) |
|
679 | - { |
|
669 | + protected function getMetadataIds($id) { |
|
680 | 670 | // Load amdSecChildIds concordance |
681 | 671 | $this->_getMdSec(); |
682 | 672 | $this->_getFileInfos(); |
@@ -723,8 +713,7 @@ discard block |
||
723 | 713 | * {@inheritDoc} |
724 | 714 | * @see \Kitodo\Dlf\Common\Doc::getFullText() |
725 | 715 | */ |
726 | - public function getFullText($id) |
|
727 | - { |
|
716 | + public function getFullText($id) { |
|
728 | 717 | $fullText = ''; |
729 | 718 | |
730 | 719 | // Load fileGrps and check for full text files. |
@@ -739,8 +728,7 @@ discard block |
||
739 | 728 | * {@inheritDoc} |
740 | 729 | * @see Doc::getStructureDepth() |
741 | 730 | */ |
742 | - public function getStructureDepth($logId) |
|
743 | - { |
|
731 | + public function getStructureDepth($logId) { |
|
744 | 732 | $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $logId . '"]/ancestor::*'); |
745 | 733 | if (!empty($ancestors)) { |
746 | 734 | return count($ancestors); |
@@ -753,8 +741,7 @@ discard block |
||
753 | 741 | * {@inheritDoc} |
754 | 742 | * @see \Kitodo\Dlf\Common\Doc::init() |
755 | 743 | */ |
756 | - protected function init($location) |
|
757 | - { |
|
744 | + protected function init($location) { |
|
758 | 745 | $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(get_class($this)); |
759 | 746 | // Get METS node from XML file. |
760 | 747 | $this->registerNamespaces($this->xml); |
@@ -778,8 +765,7 @@ discard block |
||
778 | 765 | * {@inheritDoc} |
779 | 766 | * @see \Kitodo\Dlf\Common\Doc::loadLocation() |
780 | 767 | */ |
781 | - protected function loadLocation($location) |
|
782 | - { |
|
768 | + protected function loadLocation($location) { |
|
783 | 769 | $fileResource = Helper::getUrl($location); |
784 | 770 | if ($fileResource !== false) { |
785 | 771 | $xml = Helper::getXmlFileAsString($fileResource); |
@@ -797,8 +783,7 @@ discard block |
||
797 | 783 | * {@inheritDoc} |
798 | 784 | * @see \Kitodo\Dlf\Common\Doc::ensureHasFulltextIsSet() |
799 | 785 | */ |
800 | - protected function ensureHasFulltextIsSet() |
|
801 | - { |
|
786 | + protected function ensureHasFulltextIsSet() { |
|
802 | 787 | // Are the fileGrps already loaded? |
803 | 788 | if (!$this->fileGrpsLoaded) { |
804 | 789 | $this->_getFileGrps(); |
@@ -809,8 +794,7 @@ discard block |
||
809 | 794 | * {@inheritDoc} |
810 | 795 | * @see Doc::setPreloadedDocument() |
811 | 796 | */ |
812 | - protected function setPreloadedDocument($preloadedDocument) |
|
813 | - { |
|
797 | + protected function setPreloadedDocument($preloadedDocument) { |
|
814 | 798 | |
815 | 799 | if ($preloadedDocument instanceof \SimpleXMLElement) { |
816 | 800 | $this->xml = $preloadedDocument; |
@@ -823,8 +807,7 @@ discard block |
||
823 | 807 | * {@inheritDoc} |
824 | 808 | * @see Doc::getDocument() |
825 | 809 | */ |
826 | - protected function getDocument() |
|
827 | - { |
|
810 | + protected function getDocument() { |
|
828 | 811 | return $this->mets; |
829 | 812 | } |
830 | 813 | |
@@ -835,8 +818,7 @@ discard block |
||
835 | 818 | * |
836 | 819 | * @return array Array of metadata sections with their IDs as array key |
837 | 820 | */ |
838 | - protected function _getMdSec() |
|
839 | - { |
|
821 | + protected function _getMdSec() { |
|
840 | 822 | if (!$this->mdSecLoaded) { |
841 | 823 | $this->loadFormats(); |
842 | 824 | |
@@ -878,8 +860,7 @@ discard block |
||
878 | 860 | return $this->mdSec; |
879 | 861 | } |
880 | 862 | |
881 | - protected function _getDmdSec() |
|
882 | - { |
|
863 | + protected function _getDmdSec() { |
|
883 | 864 | $this->_getMdSec(); |
884 | 865 | return $this->dmdSec; |
885 | 866 | } |
@@ -893,8 +874,7 @@ discard block |
||
893 | 874 | * |
894 | 875 | * @return array|null The processed metadata section |
895 | 876 | */ |
896 | - protected function processMdSec($element) |
|
897 | - { |
|
877 | + protected function processMdSec($element) { |
|
898 | 878 | $mdId = (string) $element->attributes()->ID; |
899 | 879 | if (empty($mdId)) { |
900 | 880 | return null; |
@@ -934,8 +914,7 @@ discard block |
||
934 | 914 | * |
935 | 915 | * @return array Array of file use groups with file IDs |
936 | 916 | */ |
937 | - protected function _getFileGrps() |
|
938 | - { |
|
917 | + protected function _getFileGrps() { |
|
939 | 918 | if (!$this->fileGrpsLoaded) { |
940 | 919 | // Get configured USE attributes. |
941 | 920 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -987,8 +966,7 @@ discard block |
||
987 | 966 | * @access protected |
988 | 967 | * @return array |
989 | 968 | */ |
990 | - protected function _getFileInfos() |
|
991 | - { |
|
969 | + protected function _getFileInfos() { |
|
992 | 970 | $this->_getFileGrps(); |
993 | 971 | return $this->fileInfos; |
994 | 972 | } |
@@ -997,8 +975,7 @@ discard block |
||
997 | 975 | * {@inheritDoc} |
998 | 976 | * @see \Kitodo\Dlf\Common\Doc::prepareMetadataArray() |
999 | 977 | */ |
1000 | - protected function prepareMetadataArray($cPid) |
|
1001 | - { |
|
978 | + protected function prepareMetadataArray($cPid) { |
|
1002 | 979 | $ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'); |
1003 | 980 | // Get all logical structure nodes with metadata. |
1004 | 981 | if (!empty($ids)) { |
@@ -1016,8 +993,7 @@ discard block |
||
1016 | 993 | * |
1017 | 994 | * @return \SimpleXMLElement The XML's METS part as \SimpleXMLElement object |
1018 | 995 | */ |
1019 | - protected function _getMets() |
|
1020 | - { |
|
996 | + protected function _getMets() { |
|
1021 | 997 | return $this->mets; |
1022 | 998 | } |
1023 | 999 | |
@@ -1025,8 +1001,7 @@ discard block |
||
1025 | 1001 | * {@inheritDoc} |
1026 | 1002 | * @see \Kitodo\Dlf\Common\Doc::_getPhysicalStructure() |
1027 | 1003 | */ |
1028 | - protected function _getPhysicalStructure() |
|
1029 | - { |
|
1004 | + protected function _getPhysicalStructure() { |
|
1030 | 1005 | // Is there no physical structure array yet? |
1031 | 1006 | if (!$this->physicalStructureLoaded) { |
1032 | 1007 | // Does the document have a structMap node of type "PHYSICAL"? |
@@ -1088,8 +1063,7 @@ discard block |
||
1088 | 1063 | * {@inheritDoc} |
1089 | 1064 | * @see \Kitodo\Dlf\Common\Doc::_getSmLinks() |
1090 | 1065 | */ |
1091 | - protected function _getSmLinks() |
|
1092 | - { |
|
1066 | + protected function _getSmLinks() { |
|
1093 | 1067 | if (!$this->smLinksLoaded) { |
1094 | 1068 | $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink'); |
1095 | 1069 | if (!empty($smLinks)) { |
@@ -1107,8 +1081,7 @@ discard block |
||
1107 | 1081 | * {@inheritDoc} |
1108 | 1082 | * @see \Kitodo\Dlf\Common\Doc::_getThumbnail() |
1109 | 1083 | */ |
1110 | - protected function _getThumbnail($forceReload = false) |
|
1111 | - { |
|
1084 | + protected function _getThumbnail($forceReload = false) { |
|
1112 | 1085 | if ( |
1113 | 1086 | !$this->thumbnailLoaded |
1114 | 1087 | || $forceReload |
@@ -1187,8 +1160,7 @@ discard block |
||
1187 | 1160 | * {@inheritDoc} |
1188 | 1161 | * @see \Kitodo\Dlf\Common\Doc::_getToplevelId() |
1189 | 1162 | */ |
1190 | - protected function _getToplevelId() |
|
1191 | - { |
|
1163 | + protected function _getToplevelId() { |
|
1192 | 1164 | if (empty($this->toplevelId)) { |
1193 | 1165 | // Get all logical structure nodes with metadata, but without associated METS-Pointers. |
1194 | 1166 | $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'); |
@@ -1217,8 +1189,7 @@ discard block |
||
1217 | 1189 | * |
1218 | 1190 | * @return string|null |
1219 | 1191 | */ |
1220 | - public function _getParentHref() |
|
1221 | - { |
|
1192 | + public function _getParentHref() { |
|
1222 | 1193 | if ($this->parentHref === null) { |
1223 | 1194 | $this->parentHref = ''; |
1224 | 1195 | |
@@ -1240,8 +1211,7 @@ discard block |
||
1240 | 1211 | * |
1241 | 1212 | * @return array Properties to be serialized |
1242 | 1213 | */ |
1243 | - public function __sleep() |
|
1244 | - { |
|
1214 | + public function __sleep() { |
|
1245 | 1215 | // \SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization |
1246 | 1216 | $this->asXML = $this->xml->asXML(); |
1247 | 1217 | return ['uid', 'pid', 'recordId', 'parentId', 'asXML']; |
@@ -1254,8 +1224,7 @@ discard block |
||
1254 | 1224 | * |
1255 | 1225 | * @return string String representing the METS object |
1256 | 1226 | */ |
1257 | - public function __toString() |
|
1258 | - { |
|
1227 | + public function __toString() { |
|
1259 | 1228 | $xml = new \DOMDocument('1.0', 'utf-8'); |
1260 | 1229 | $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); |
1261 | 1230 | $xml->formatOutput = true; |
@@ -1270,8 +1239,7 @@ discard block |
||
1270 | 1239 | * |
1271 | 1240 | * @return void |
1272 | 1241 | */ |
1273 | - public function __wakeup() |
|
1274 | - { |
|
1242 | + public function __wakeup() { |
|
1275 | 1243 | $xml = Helper::getXmlFileAsString($this->asXML); |
1276 | 1244 | if ($xml !== false) { |
1277 | 1245 | $this->asXML = ''; |