Completed
Push — master ( 85f5d2...3daaa3 )
by
unknown
17s queued 14s
created
Classes/Common/Document.php 1 patch
Braces   +32 added lines, -64 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
341 340
      *
342 341
      * @return void
343 342
      */
344
-    public static function clearRegistry()
345
-    {
343
+    public static function clearRegistry() {
346 344
         // Reset registry array.
347 345
         self::$registry = [];
348 346
     }
@@ -607,8 +605,7 @@  discard block
 block discarded – undo
607 605
      *
608 606
      * @return int The physical page number
609 607
      */
610
-    public function getPhysicalPage($logicalPage)
611
-    {
608
+    public function getPhysicalPage($logicalPage) {
612 609
         if (
613 610
             !empty($this->lastSearchedPhysicalPage['logicalPage'])
614 611
             && $this->lastSearchedPhysicalPage['logicalPage'] == $logicalPage
@@ -653,8 +650,7 @@  discard block
 block discarded – undo
653 650
      *
654 651
      * @return string The OCR full text
655 652
      */
656
-    protected function getFullTextFromXml($id)
657
-    {
653
+    protected function getFullTextFromXml($id) {
658 654
         $fullText = '';
659 655
         // Load available text formats, ...
660 656
         $this->loadFormats();
@@ -716,8 +712,7 @@  discard block
 block discarded – undo
716 712
      *
717 713
      * @return string The format of the OCR full text
718 714
      */
719
-    private function getTextFormat($fileContent)
720
-    {
715
+    private function getTextFormat($fileContent) {
721 716
         // Get the root element's name as text format.
722 717
         return strtoupper(Helper::getXmlFileAsString($fileContent)->getName());
723 718
     }
@@ -734,8 +729,7 @@  discard block
 block discarded – undo
734 729
      *
735 730
      * @return string The title of the document itself or a parent document
736 731
      */
737
-    public static function getTitle($uid, $recursive = false)
738
-    {
732
+    public static function getTitle($uid, $recursive = false) {
739 733
         $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
740 734
 
741 735
         $title = '';
@@ -789,8 +783,7 @@  discard block
 block discarded – undo
789 783
      *
790 784
      * @return array The logical structure node's / resource's parsed metadata array
791 785
      */
792
-    public function getTitledata($cPid = 0)
793
-    {
786
+    public function getTitledata($cPid = 0) {
794 787
         $titledata = $this->getMetadata($this->_getToplevelId(), $cPid);
795 788
         // Add information from METS structural map to titledata array.
796 789
         if ($this instanceof MetsDocument) {
@@ -823,8 +816,7 @@  discard block
 block discarded – undo
823 816
      * @return int|bool: false if structure with $logId is not a child of this substructure,
824 817
      * or the actual depth.
825 818
      */
826
-    protected function getTreeDepth($structure, $depth, $logId)
827
-    {
819
+    protected function getTreeDepth($structure, $depth, $logId) {
828 820
         foreach ($structure as $element) {
829 821
             if ($element['id'] == $logId) {
830 822
                 return $depth;
@@ -846,8 +838,7 @@  discard block
 block discarded – undo
846 838
      * @param string $logId: The id of the logical structure element whose depth is requested
847 839
      * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC.
848 840
      */
849
-    public function getStructureDepth($logId)
850
-    {
841
+    public function getStructureDepth($logId) {
851 842
         return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId);
852 843
     }
853 844
 
@@ -897,8 +888,7 @@  discard block
 block discarded – undo
897 888
      *
898 889
      * @return bool true on success or false on failure
899 890
      */
900
-    protected function load($location)
901
-    {
891
+    protected function load($location) {
902 892
         // Load XML / JSON-LD file.
903 893
         if (GeneralUtility::isValidUrl($location)) {
904 894
             // Load extension configuration
@@ -931,8 +921,7 @@  discard block
 block discarded – undo
931 921
      *
932 922
      * @return void
933 923
      */
934
-    protected function loadFormats()
935
-    {
924
+    protected function loadFormats() {
936 925
         if (!$this->formatsLoaded) {
937 926
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
938 927
                 ->getQueryBuilderForTable('tx_dlf_formats');
@@ -972,8 +961,7 @@  discard block
 block discarded – undo
972 961
      *
973 962
      * @return void
974 963
      */
975
-    public function registerNamespaces(&$obj)
976
-    {
964
+    public function registerNamespaces(&$obj) {
977 965
         // TODO Check usage. XML specific method does not seem to be used anywhere outside this class within the project, but it is public and may be used by extensions.
978 966
         $this->loadFormats();
979 967
         // Do we have a \SimpleXMLElement or \DOMXPath object?
@@ -1002,8 +990,7 @@  discard block
 block discarded – undo
1002 990
      *
1003 991
      * @return bool true on success or false on failure
1004 992
      */
1005
-    public function save($pid = 0, $core = 0, $owner = null)
1006
-    {
993
+    public function save($pid = 0, $core = 0, $owner = null) {
1007 994
         if (\TYPO3_MODE !== 'BE') {
1008 995
             $this->logger->error('Saving a document is only allowed in the backend');
1009 996
             return false;
@@ -1331,8 +1318,7 @@  discard block
 block discarded – undo
1331 1318
      *
1332 1319
      * @return int The PID of the metadata definitions
1333 1320
      */
1334
-    protected function _getCPid()
1335
-    {
1321
+    protected function _getCPid() {
1336 1322
         return $this->cPid;
1337 1323
     }
1338 1324
 
@@ -1343,8 +1329,7 @@  discard block
 block discarded – undo
1343 1329
      *
1344 1330
      * @return bool Are there any fulltext files available?
1345 1331
      */
1346
-    protected function _getHasFulltext()
1347
-    {
1332
+    protected function _getHasFulltext() {
1348 1333
         $this->ensureHasFulltextIsSet();
1349 1334
         return $this->hasFulltext;
1350 1335
     }
@@ -1356,8 +1341,7 @@  discard block
 block discarded – undo
1356 1341
      *
1357 1342
      * @return string The location of the document
1358 1343
      */
1359
-    protected function _getLocation()
1360
-    {
1344
+    protected function _getLocation() {
1361 1345
         return $this->location;
1362 1346
     }
1363 1347
 
@@ -1379,8 +1363,7 @@  discard block
 block discarded – undo
1379 1363
      *
1380 1364
      * @return array Array of metadata with their corresponding logical structure node ID as key
1381 1365
      */
1382
-    protected function _getMetadataArray()
1383
-    {
1366
+    protected function _getMetadataArray() {
1384 1367
         // Set metadata definitions' PID.
1385 1368
         $cPid = ($this->cPid ? $this->cPid : $this->pid);
1386 1369
         if (!$cPid) {
@@ -1405,8 +1388,7 @@  discard block
 block discarded – undo
1405 1388
      *
1406 1389
      * @return int The total number of pages and/or tracks
1407 1390
      */
1408
-    protected function _getNumPages()
1409
-    {
1391
+    protected function _getNumPages() {
1410 1392
         $this->_getPhysicalStructure();
1411 1393
         return $this->numPages;
1412 1394
     }
@@ -1418,8 +1400,7 @@  discard block
 block discarded – undo
1418 1400
      *
1419 1401
      * @return int The UID of the parent document or zero if not applicable
1420 1402
      */
1421
-    protected function _getParentId()
1422
-    {
1403
+    protected function _getParentId() {
1423 1404
         return $this->parentId;
1424 1405
     }
1425 1406
 
@@ -1442,8 +1423,7 @@  discard block
 block discarded – undo
1442 1423
      *
1443 1424
      * @return array Array of elements' type, label and file representations ordered by @ID attribute / Canvas order
1444 1425
      */
1445
-    protected function _getPhysicalStructureInfo()
1446
-    {
1426
+    protected function _getPhysicalStructureInfo() {
1447 1427
         // Is there no physical structure array yet?
1448 1428
         if (!$this->physicalStructureLoaded) {
1449 1429
             // Build physical structure array.
@@ -1459,8 +1439,7 @@  discard block
 block discarded – undo
1459 1439
      *
1460 1440
      * @return int The PID of the document or zero if not in database
1461 1441
      */
1462
-    protected function _getPid()
1463
-    {
1442
+    protected function _getPid() {
1464 1443
         return $this->pid;
1465 1444
     }
1466 1445
 
@@ -1471,8 +1450,7 @@  discard block
 block discarded – undo
1471 1450
      *
1472 1451
      * @return bool Is the document instantiated successfully?
1473 1452
      */
1474
-    protected function _getReady()
1475
-    {
1453
+    protected function _getReady() {
1476 1454
         return $this->ready;
1477 1455
     }
1478 1456
 
@@ -1483,8 +1461,7 @@  discard block
 block discarded – undo
1483 1461
      *
1484 1462
      * @return mixed The METS file's / IIIF manifest's record identifier
1485 1463
      */
1486
-    protected function _getRecordId()
1487
-    {
1464
+    protected function _getRecordId() {
1488 1465
         return $this->recordId;
1489 1466
     }
1490 1467
 
@@ -1495,8 +1472,7 @@  discard block
 block discarded – undo
1495 1472
      *
1496 1473
      * @return int The UID of the root document or zero if not applicable
1497 1474
      */
1498
-    protected function _getRootId()
1499
-    {
1475
+    protected function _getRootId() {
1500 1476
         if (!$this->rootIdLoaded) {
1501 1477
             if ($this->parentId) {
1502 1478
                 $parent = self::getInstance($this->parentId, $this->pid);
@@ -1526,8 +1502,7 @@  discard block
 block discarded – undo
1526 1502
      *
1527 1503
      * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved
1528 1504
      */
1529
-    protected function _getTableOfContents()
1530
-    {
1505
+    protected function _getTableOfContents() {
1531 1506
         // Is there no logical structure array yet?
1532 1507
         if (!$this->tableOfContentsLoaded) {
1533 1508
             // Get all logical structures.
@@ -1568,8 +1543,7 @@  discard block
 block discarded – undo
1568 1543
      *
1569 1544
      * @return mixed The UID or the URL of the document
1570 1545
      */
1571
-    protected function _getUid()
1572
-    {
1546
+    protected function _getUid() {
1573 1547
         return $this->uid;
1574 1548
     }
1575 1549
 
@@ -1582,8 +1556,7 @@  discard block
 block discarded – undo
1582 1556
      *
1583 1557
      * @return void
1584 1558
      */
1585
-    protected function _setCPid($value)
1586
-    {
1559
+    protected function _setCPid($value) {
1587 1560
         $this->cPid = max(intval($value), 0);
1588 1561
     }
1589 1562
 
@@ -1594,8 +1567,7 @@  discard block
 block discarded – undo
1594 1567
      *
1595 1568
      * @return void
1596 1569
      */
1597
-    protected function __clone()
1598
-    {
1570
+    protected function __clone() {
1599 1571
         // This method is defined as protected because singleton objects should not be cloned.
1600 1572
     }
1601 1573
 
@@ -1612,8 +1584,7 @@  discard block
 block discarded – undo
1612 1584
      *
1613 1585
      * @return void
1614 1586
      */
1615
-    protected function __construct($uid, $pid, $preloadedDocument)
1616
-    {
1587
+    protected function __construct($uid, $pid, $preloadedDocument) {
1617 1588
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
1618 1589
             ->getQueryBuilderForTable('tx_dlf_documents');
1619 1590
         $location = '';
@@ -1725,8 +1696,7 @@  discard block
 block discarded – undo
1725 1696
      *
1726 1697
      * @return mixed Value of $this->$var
1727 1698
      */
1728
-    public function __get($var)
1729
-    {
1699
+    public function __get($var) {
1730 1700
         $method = '_get' . ucfirst($var);
1731 1701
         if (
1732 1702
             !property_exists($this, $var)
@@ -1748,8 +1718,7 @@  discard block
 block discarded – undo
1748 1718
      *
1749 1719
      * @return bool true if variable is set and not empty, false otherwise
1750 1720
      */
1751
-    public function __isset($var)
1752
-    {
1721
+    public function __isset($var) {
1753 1722
         return !empty($this->__get($var));
1754 1723
     }
1755 1724
 
@@ -1763,8 +1732,7 @@  discard block
 block discarded – undo
1763 1732
      *
1764 1733
      * @return void
1765 1734
      */
1766
-    public function __set($var, $value)
1767
-    {
1735
+    public function __set($var, $value) {
1768 1736
         $method = '_set' . ucfirst($var);
1769 1737
         if (
1770 1738
             !property_exists($this, $var)
Please login to merge, or discard this patch.
Classes/Common/Helper.php 1 patch
Braces   +26 added lines, -52 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
  * @subpackage dlf
26 26
  * @access public
27 27
  */
28
-class Helper
29
-{
28
+class Helper {
30 29
     /**
31 30
      * The extension key
32 31
      *
@@ -74,8 +73,7 @@  discard block
 block discarded – undo
74 73
      *
75 74
      * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue The queue the message was added to
76 75
      */
77
-    public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages')
78
-    {
76
+    public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') {
79 77
         $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
80 78
         $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue);
81 79
         $flashMessage = GeneralUtility::makeInstance(
@@ -100,8 +98,7 @@  discard block
 block discarded – undo
100 98
      *
101 99
      * @return bool Is $id a valid GNL identifier of the given $type?
102 100
      */
103
-    public static function checkIdentifier($id, $type)
104
-    {
101
+    public static function checkIdentifier($id, $type) {
105 102
         $digits = substr($id, 0, 8);
106 103
         $checksum = 0;
107 104
         for ($i = 0, $j = strlen($digits); $i < $j; $i++) {
@@ -165,8 +162,7 @@  discard block
 block discarded – undo
165 162
      *
166 163
      * @return mixed The decrypted value or false on error
167 164
      */
168
-    public static function decrypt($encrypted)
169
-    {
165
+    public static function decrypt($encrypted) {
170 166
         if (
171 167
             !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true))
172 168
             || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true))
@@ -204,8 +200,7 @@  discard block
 block discarded – undo
204 200
      *
205 201
      * @return mixed
206 202
      */
207
-    public static function getXmlFileAsString($content)
208
-    {
203
+    public static function getXmlFileAsString($content) {
209 204
         // Turn off libxml's error logging.
210 205
         $libxmlErrors = libxml_use_internal_errors(true);
211 206
         // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
@@ -231,8 +226,7 @@  discard block
 block discarded – undo
231 226
      * @return void
232 227
      */
233 228
     //TODO: find better way to handle logger in static class
234
-    public static function log($message, $severity = 0)
235
-    {
229
+    public static function log($message, $severity = 0) {
236 230
         $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
237 231
 
238 232
         switch ($severity) {
@@ -262,8 +256,7 @@  discard block
 block discarded – undo
262 256
      *
263 257
      * @return mixed Hashed string or false on error
264 258
      */
265
-    public static function digest($string)
266
-    {
259
+    public static function digest($string) {
267 260
         if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(true))) {
268 261
             self::log('OpenSSL library doesn\'t support hash algorithm', LOG_SEVERITY_ERROR);
269 262
             return false;
@@ -282,8 +275,7 @@  discard block
 block discarded – undo
282 275
      *
283 276
      * @return mixed Encrypted string or false on error
284 277
      */
285
-    public static function encrypt($string)
286
-    {
278
+    public static function encrypt($string) {
287 279
         if (
288 280
             !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true))
289 281
             || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true))
@@ -316,8 +308,7 @@  discard block
 block discarded – undo
316 308
      *
317 309
      * @return string The unqualified class name
318 310
      */
319
-    public static function getUnqualifiedClassName($qualifiedClassname)
320
-    {
311
+    public static function getUnqualifiedClassName($qualifiedClassname) {
321 312
         $nameParts = explode('\\', $qualifiedClassname);
322 313
         return end($nameParts);
323 314
     }
@@ -331,8 +322,7 @@  discard block
 block discarded – undo
331 322
      *
332 323
      * @return string The cleaned up string
333 324
      */
334
-    public static function getCleanString($string)
335
-    {
325
+    public static function getCleanString($string) {
336 326
         // Convert to lowercase.
337 327
         $string = strtolower($string);
338 328
         // Remove non-alphanumeric characters.
@@ -353,8 +343,7 @@  discard block
 block discarded – undo
353 343
      *
354 344
      * @return array Array of hook objects for the class
355 345
      */
356
-    public static function getHookObjects($scriptRelPath)
357
-    {
346
+    public static function getHookObjects($scriptRelPath) {
358 347
         $hookObjects = [];
359 348
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) {
360 349
             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) {
@@ -375,8 +364,7 @@  discard block
 block discarded – undo
375 364
      *
376 365
      * @return string "index_name" for the given UID
377 366
      */
378
-    public static function getIndexNameFromUid($uid, $table, $pid = -1)
379
-    {
367
+    public static function getIndexNameFromUid($uid, $table, $pid = -1) {
380 368
         // Sanitize input.
381 369
         $uid = max(intval($uid), 0);
382 370
         if (
@@ -428,8 +416,7 @@  discard block
 block discarded – undo
428 416
      *
429 417
      * @return string "label" for the given UID
430 418
      */
431
-    public static function getLabelFromUid($uid, $table, $pid = -1)
432
-    {
419
+    public static function getLabelFromUid($uid, $table, $pid = -1) {
433 420
         // Sanitize input.
434 421
         $uid = max(intval($uid), 0);
435 422
         if (
@@ -479,8 +466,7 @@  discard block
 block discarded – undo
479 466
      *
480 467
      * @return string Localized full name of language or unchanged input
481 468
      */
482
-    public static function getLanguageName($code)
483
-    {
469
+    public static function getLanguageName($code) {
484 470
         // Analyze code and set appropriate ISO table.
485 471
         $isoCode = strtolower(trim($code));
486 472
         if (preg_match('/^[a-z]{3}$/', $isoCode)) {
@@ -525,8 +511,7 @@  discard block
 block discarded – undo
525 511
      *
526 512
      * @return string The translated string or the given key on failure
527 513
      */
528
-    public static function getMessage($key, $hsc = false, $default = '')
529
-    {
514
+    public static function getMessage($key, $hsc = false, $default = '') {
530 515
         // Set initial output to default value.
531 516
         $translated = (string) $default;
532 517
         // Load common messages file.
@@ -568,8 +553,7 @@  discard block
 block discarded – undo
568 553
      *
569 554
      * @return string "uid" for the given index_name
570 555
      */
571
-    public static function getUidFromIndexName($index_name, $table, $pid = -1)
572
-    {
556
+    public static function getUidFromIndexName($index_name, $table, $pid = -1) {
573 557
         if (
574 558
             !$index_name
575 559
             || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'])
@@ -620,8 +604,7 @@  discard block
 block discarded – undo
620 604
      *
621 605
      * @return string Uniform Resource Name as string
622 606
      */
623
-    public static function getURN($base, $id)
624
-    {
607
+    public static function getURN($base, $id) {
625 608
         $concordance = [
626 609
             '0' => 1,
627 610
             '1' => 2,
@@ -688,8 +671,7 @@  discard block
 block discarded – undo
688 671
      *
689 672
      * @return bool Is $id a valid PPN?
690 673
      */
691
-    public static function isPPN($id)
692
-    {
674
+    public static function isPPN($id) {
693 675
         return self::checkIdentifier($id, 'PPN');
694 676
     }
695 677
 
@@ -702,8 +684,7 @@  discard block
 block discarded – undo
702 684
      *
703 685
      * @return mixed Session value for given key or null on failure
704 686
      */
705
-    public static function loadFromSession($key)
706
-    {
687
+    public static function loadFromSession($key) {
707 688
         // Cast to string for security reasons.
708 689
         $key = (string) $key;
709 690
         if (!$key) {
@@ -735,8 +716,7 @@  discard block
 block discarded – undo
735 716
      *
736 717
      * @return array Merged array
737 718
      */
738
-    public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true)
739
-    {
719
+    public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) {
740 720
         \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature);
741 721
         return $original;
742 722
     }
@@ -753,8 +733,7 @@  discard block
 block discarded – undo
753 733
      *
754 734
      * @return array Array of substituted "NEW..." identifiers and their actual UIDs.
755 735
      */
756
-    public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false)
757
-    {
736
+    public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false) {
758 737
         if (
759 738
             \TYPO3_MODE === 'BE'
760 739
             && $GLOBALS['BE_USER']->isAdmin()
@@ -800,8 +779,7 @@  discard block
 block discarded – undo
800 779
      *
801 780
      * @return string All flash messages in the queue rendered as HTML.
802 781
      */
803
-    public static function renderFlashMessages($queue = 'kitodo.default.flashMessages')
804
-    {
782
+    public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') {
805 783
         $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
806 784
         $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue);
807 785
         $flashMessages = $flashMessageQueue->getAllMessagesAndFlush();
@@ -820,8 +798,7 @@  discard block
 block discarded – undo
820 798
      *
821 799
      * @return bool true on success, false on failure
822 800
      */
823
-    public static function saveToSession($value, $key)
824
-    {
801
+    public static function saveToSession($value, $key) {
825 802
         // Cast to string for security reasons.
826 803
         $key = (string) $key;
827 804
         if (!$key) {
@@ -853,8 +830,7 @@  discard block
 block discarded – undo
853 830
      *
854 831
      * @return string Localized label for $index_name
855 832
      */
856
-    public static function translate($index_name, $table, $pid)
857
-    {
833
+    public static function translate($index_name, $table, $pid) {
858 834
         // Load labels into static variable for future use.
859 835
         static $labels = [];
860 836
         // Sanitize input.
@@ -977,8 +953,7 @@  discard block
 block discarded – undo
977 953
      *
978 954
      * @return string Additional WHERE expression
979 955
      */
980
-    public static function whereExpression($table, $showHidden = false)
981
-    {
956
+    public static function whereExpression($table, $showHidden = false) {
982 957
         if (\TYPO3_MODE === 'FE') {
983 958
             // Should we ignore the record's hidden flag?
984 959
             $ignoreHide = 0;
@@ -1007,8 +982,7 @@  discard block
 block discarded – undo
1007 982
      *
1008 983
      * @access private
1009 984
      */
1010
-    private function __construct()
1011
-    {
985
+    private function __construct() {
1012 986
         // This is a static class, thus no instances should be created.
1013 987
     }
1014 988
 }
Please login to merge, or discard this patch.
Classes/Common/MetsDocument.php 1 patch
Braces   +28 added lines, -56 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
717 705
      * {@inheritDoc}
718 706
      * @see \Kitodo\Dlf\Common\Document::loadLocation()
719 707
      */
720
-    protected function loadLocation($location)
721
-    {
708
+    protected function loadLocation($location) {
722 709
         $fileResource = GeneralUtility::getUrl($location);
723 710
         if ($fileResource !== false) {
724 711
             $xml = Helper::getXmlFileAsString($fileResource);
@@ -736,8 +723,7 @@  discard block
 block discarded – undo
736 723
      * {@inheritDoc}
737 724
      * @see \Kitodo\Dlf\Common\Document::ensureHasFulltextIsSet()
738 725
      */
739
-    protected function ensureHasFulltextIsSet()
740
-    {
726
+    protected function ensureHasFulltextIsSet() {
741 727
         // Are the fileGrps already loaded?
742 728
         if (!$this->fileGrpsLoaded) {
743 729
             $this->_getFileGrps();
@@ -748,8 +734,7 @@  discard block
 block discarded – undo
748 734
      * {@inheritDoc}
749 735
      * @see Document::getParentDocumentUid()
750 736
      */
751
-    protected function getParentDocumentUidForSaving($pid, $core, $owner)
752
-    {
737
+    protected function getParentDocumentUidForSaving($pid, $core, $owner) {
753 738
         $partof = 0;
754 739
         // Get the closest ancestor of the current document which has a MPTR child.
755 740
         $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $this->_getToplevelId() . '"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr');
@@ -772,8 +757,7 @@  discard block
 block discarded – undo
772 757
      * {@inheritDoc}
773 758
      * @see Document::setPreloadedDocument()
774 759
      */
775
-    protected function setPreloadedDocument($preloadedDocument)
776
-    {
760
+    protected function setPreloadedDocument($preloadedDocument) {
777 761
 
778 762
         if ($preloadedDocument instanceof \SimpleXMLElement) {
779 763
             $this->xml = $preloadedDocument;
@@ -786,8 +770,7 @@  discard block
 block discarded – undo
786 770
      * {@inheritDoc}
787 771
      * @see Document::getDocument()
788 772
      */
789
-    protected function getDocument()
790
-    {
773
+    protected function getDocument() {
791 774
         return $this->mets;
792 775
     }
793 776
 
@@ -798,8 +781,7 @@  discard block
 block discarded – undo
798 781
      *
799 782
      * @return array Array of dmdSecs with their IDs as array key
800 783
      */
801
-    protected function _getDmdSec()
802
-    {
784
+    protected function _getDmdSec() {
803 785
         if (!$this->dmdSecLoaded) {
804 786
             // Get available data formats.
805 787
             $this->loadFormats();
@@ -837,8 +819,7 @@  discard block
 block discarded – undo
837 819
      *
838 820
      * @return array Array of file use groups with file IDs
839 821
      */
840
-    protected function _getFileGrps()
841
-    {
822
+    protected function _getFileGrps() {
842 823
         if (!$this->fileGrpsLoaded) {
843 824
             // Get configured USE attributes.
844 825
             $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey);
@@ -883,8 +864,7 @@  discard block
 block discarded – undo
883 864
      * {@inheritDoc}
884 865
      * @see \Kitodo\Dlf\Common\Document::prepareMetadataArray()
885 866
      */
886
-    protected function prepareMetadataArray($cPid)
887
-    {
867
+    protected function prepareMetadataArray($cPid) {
888 868
         $ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID');
889 869
         // Get all logical structure nodes with metadata.
890 870
         if (!empty($ids)) {
@@ -902,8 +882,7 @@  discard block
 block discarded – undo
902 882
      *
903 883
      * @return \SimpleXMLElement The XML's METS part as \SimpleXMLElement object
904 884
      */
905
-    protected function _getMets()
906
-    {
885
+    protected function _getMets() {
907 886
         return $this->mets;
908 887
     }
909 888
 
@@ -911,8 +890,7 @@  discard block
 block discarded – undo
911 890
      * {@inheritDoc}
912 891
      * @see \Kitodo\Dlf\Common\Document::_getPhysicalStructure()
913 892
      */
914
-    protected function _getPhysicalStructure()
915
-    {
893
+    protected function _getPhysicalStructure() {
916 894
         // Is there no physical structure array yet?
917 895
         if (!$this->physicalStructureLoaded) {
918 896
             // Does the document have a structMap node of type "PHYSICAL"?
@@ -972,8 +950,7 @@  discard block
 block discarded – undo
972 950
      * {@inheritDoc}
973 951
      * @see \Kitodo\Dlf\Common\Document::_getSmLinks()
974 952
      */
975
-    protected function _getSmLinks()
976
-    {
953
+    protected function _getSmLinks() {
977 954
         if (!$this->smLinksLoaded) {
978 955
             $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink');
979 956
             if (!empty($smLinks)) {
@@ -991,8 +968,7 @@  discard block
 block discarded – undo
991 968
      * {@inheritDoc}
992 969
      * @see \Kitodo\Dlf\Common\Document::_getThumbnail()
993 970
      */
994
-    protected function _getThumbnail($forceReload = false)
995
-    {
971
+    protected function _getThumbnail($forceReload = false) {
996 972
         if (
997 973
             !$this->thumbnailLoaded
998 974
             || $forceReload
@@ -1071,8 +1047,7 @@  discard block
 block discarded – undo
1071 1047
      * {@inheritDoc}
1072 1048
      * @see \Kitodo\Dlf\Common\Document::_getToplevelId()
1073 1049
      */
1074
-    protected function _getToplevelId()
1075
-    {
1050
+    protected function _getToplevelId() {
1076 1051
         if (empty($this->toplevelId)) {
1077 1052
             // Get all logical structure nodes with metadata, but without associated METS-Pointers.
1078 1053
             $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]');
@@ -1104,8 +1079,7 @@  discard block
 block discarded – undo
1104 1079
      *
1105 1080
      * @return array Properties to be serialized
1106 1081
      */
1107
-    public function __sleep()
1108
-    {
1082
+    public function __sleep() {
1109 1083
         // \SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization
1110 1084
         $this->asXML = $this->xml->asXML();
1111 1085
         return ['uid', 'pid', 'recordId', 'parentId', 'asXML'];
@@ -1118,8 +1092,7 @@  discard block
 block discarded – undo
1118 1092
      *
1119 1093
      * @return string String representing the METS object
1120 1094
      */
1121
-    public function __toString()
1122
-    {
1095
+    public function __toString() {
1123 1096
         $xml = new \DOMDocument('1.0', 'utf-8');
1124 1097
         $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true));
1125 1098
         $xml->formatOutput = true;
@@ -1134,8 +1107,7 @@  discard block
 block discarded – undo
1134 1107
      *
1135 1108
      * @return void
1136 1109
      */
1137
-    public function __wakeup()
1138
-    {
1110
+    public function __wakeup() {
1139 1111
         $xml = Helper::getXmlFileAsString($this->asXML);
1140 1112
         if ($xml !== false) {
1141 1113
             $this->asXML = '';
Please login to merge, or discard this patch.