@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $startingPoint = $this->getStartingPoint($input->getOption('pid')); |
| 104 | 104 | |
| 105 | 105 | if ($startingPoint == 0) { |
| 106 | - $io->error('ERROR: No valid PID (' . $startingPoint . ') given.'); |
|
| 106 | + $io->error('ERROR: No valid PID ('.$startingPoint.') given.'); |
|
| 107 | 107 | exit(1); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | if (empty($solrCoreUid) || !in_array($solrCoreUid, $allSolrCores)) { |
| 119 | 119 | $output_solrCores = []; |
| 120 | 120 | foreach ($allSolrCores as $index_name => $uid) { |
| 121 | - $output_solrCores[] = $uid . ' : ' . $index_name; |
|
| 121 | + $output_solrCores[] = $uid.' : '.$index_name; |
|
| 122 | 122 | } |
| 123 | 123 | if (empty($output_solrCores)) { |
| 124 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. No valid cores found on PID ' . $startingPoint . ".\n"); |
|
| 124 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. No valid cores found on PID '.$startingPoint.".\n"); |
|
| 125 | 125 | exit(1); |
| 126 | 126 | } else { |
| 127 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (<uid>:<index_name>):\n" . implode("\n", $output_solrCores) . "\n"); |
|
| 127 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. '."Valid cores are (<uid>:<index_name>):\n".implode("\n", $output_solrCores)."\n"); |
|
| 128 | 128 | exit(1); |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | $doc = Document::getInstance($document, $startingPoint, true); |
| 166 | 166 | if ($doc->ready) { |
| 167 | 167 | if ($dryRun) { |
| 168 | - $io->writeln('DRY RUN: Would index ' . $id . '/' . count($documents) . ' ' . $doc->uid . ' ("' . $doc->location . '") on PID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
|
| 168 | + $io->writeln('DRY RUN: Would index '.$id.'/'.count($documents).' '.$doc->uid.' ("'.$doc->location.'") on PID '.$startingPoint.' and Solr core '.$solrCoreUid.'.'); |
|
| 169 | 169 | } else { |
| 170 | 170 | if ($io->isVerbose()) { |
| 171 | - $io->writeln(date('Y-m-d H:i:s') . ' Indexing ' . $id . '/' . count($documents) . ' ' . $doc->uid . ' ("' . $doc->location . '") on PID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
|
| 171 | + $io->writeln(date('Y-m-d H:i:s').' Indexing '.$id.'/'.count($documents).' '.$doc->uid.' ("'.$doc->location.'") on PID '.$startingPoint.' and Solr core '.$solrCoreUid.'.'); |
|
| 172 | 172 | } |
| 173 | 173 | // ...and save it to the database... |
| 174 | 174 | if (!$doc->save($startingPoint, $solrCoreUid, $owner)) { |
| 175 | - $io->error('ERROR: Document "' . $id . '" not saved and indexed.'); |
|
| 175 | + $io->error('ERROR: Document "'.$id.'" not saved and indexed.'); |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } else { |
| 179 | - $io->error('ERROR: Document "' . $id . '" could not be loaded.'); |
|
| 179 | + $io->error('ERROR: Document "'.$id.'" could not be loaded.'); |
|
| 180 | 180 | } |
| 181 | 181 | // Clear document registry to prevent memory exhaustion. |
| 182 | 182 | Document::clearRegistry(); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | ->setHelp('') |
| 47 | 47 | ->addOption( |
| 48 | 48 | 'dry-run', |
| 49 | - null, |
|
| 49 | + NULL, |
|
| 50 | 50 | InputOption::VALUE_NONE, |
| 51 | 51 | 'If this option is set, the files will not actually be processed but the location URI is shown.' |
| 52 | 52 | ) |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | // Make sure the _cli_ user is loaded |
| 96 | 96 | Bootstrap::getInstance()->initializeBackendAuthentication(); |
| 97 | 97 | |
| 98 | - $dryRun = $input->getOption('dry-run') != false ? true : false; |
|
| 98 | + $dryRun = $input->getOption('dry-run') != FALSE ? TRUE : FALSE; |
|
| 99 | 99 | |
| 100 | 100 | $io = new SymfonyStyle($input, $output); |
| 101 | 101 | $io->title($this->getDescription()); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $owner = (string) $input->getOption('owner'); |
| 141 | 141 | } |
| 142 | 142 | } else { |
| 143 | - $owner = null; |
|
| 143 | + $owner = NULL; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | if (!empty($input->getOption('all'))) { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | && !is_array($input->getOption('coll')) |
| 152 | 152 | ) { |
| 153 | 153 | // "coll" may be a single integer or a comma-separated list of integers. |
| 154 | - if (empty(array_filter(GeneralUtility::intExplode(',', $input->getOption('coll'), true)))) { |
|
| 154 | + if (empty(array_filter(GeneralUtility::intExplode(',', $input->getOption('coll'), TRUE)))) { |
|
| 155 | 155 | $io->error('ERROR: Parameter --coll|-c is not a valid comma-separated list of collection UIDs.'); |
| 156 | 156 | exit(1); |
| 157 | 157 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | foreach ($documents as $id => $document) { |
| 165 | - $doc = Document::getInstance($document, $startingPoint, true); |
|
| 165 | + $doc = Document::getInstance($document, $startingPoint, TRUE); |
|
| 166 | 166 | if ($doc->ready) { |
| 167 | 167 | if ($dryRun) { |
| 168 | 168 | $io->writeln('DRY RUN: Would index ' . $id . '/' . count($documents) . ' ' . $doc->uid . ' ("' . $doc->location . '") on PID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $queryBuilder->expr()->in( |
| 226 | 226 | 'tx_dlf_collections_join.uid', |
| 227 | 227 | $queryBuilder->createNamedParameter( |
| 228 | - GeneralUtility::intExplode(',', $collIds, true), |
|
| 228 | + GeneralUtility::intExplode(',', $collIds, TRUE), |
|
| 229 | 229 | Connection::PARAM_INT_ARRAY |
| 230 | 230 | ) |
| 231 | 231 | ), |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $startingPoint = $this->getStartingPoint($input->getOption('pid')); |
| 96 | 96 | |
| 97 | 97 | if ($startingPoint == 0) { |
| 98 | - $io->error('ERROR: No valid PID (' . $startingPoint . ') given.'); |
|
| 98 | + $io->error('ERROR: No valid PID ('.$startingPoint.') given.'); |
|
| 99 | 99 | exit(1); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | if (empty($solrCoreUid) || !in_array($solrCoreUid, $allSolrCores)) { |
| 111 | 111 | $output_solrCores = []; |
| 112 | 112 | foreach ($allSolrCores as $index_name => $uid) { |
| 113 | - $output_solrCores[] = $uid . ' : ' . $index_name; |
|
| 113 | + $output_solrCores[] = $uid.' : '.$index_name; |
|
| 114 | 114 | } |
| 115 | 115 | if (empty($output_solrCores)) { |
| 116 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. No valid cores found on PID ' . $startingPoint . ".\n"); |
|
| 116 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. No valid cores found on PID '.$startingPoint.".\n"); |
|
| 117 | 117 | exit(1); |
| 118 | 118 | } else { |
| 119 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (<uid>:<index_name>):\n" . implode("\n", $output_solrCores) . "\n"); |
|
| 119 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. '."Valid cores are (<uid>:<index_name>):\n".implode("\n", $output_solrCores)."\n"); |
|
| 120 | 120 | exit(1); |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -151,19 +151,19 @@ discard block |
||
| 151 | 151 | $doc = Document::getInstance($input->getOption('doc'), $startingPoint, true); |
| 152 | 152 | if ($doc->ready) { |
| 153 | 153 | if ($dryRun) { |
| 154 | - $io->section('DRY RUN: Would index ' . $doc->uid . ' ("' . $doc->location . '") on PID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
|
| 154 | + $io->section('DRY RUN: Would index '.$doc->uid.' ("'.$doc->location.'") on PID '.$startingPoint.' and Solr core '.$solrCoreUid.'.'); |
|
| 155 | 155 | } else { |
| 156 | 156 | if ($io->isVerbose()) { |
| 157 | - $io->section('Indexing ' . $doc->uid . ' ("' . $doc->location . '") on PID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
|
| 157 | + $io->section('Indexing '.$doc->uid.' ("'.$doc->location.'") on PID '.$startingPoint.' and Solr core '.$solrCoreUid.'.'); |
|
| 158 | 158 | } |
| 159 | 159 | // ...and save it to the database... |
| 160 | 160 | if (!$doc->save($startingPoint, $solrCoreUid, $owner)) { |
| 161 | - $io->error('ERROR: Document "' . $input->getOption('doc') . '" not saved and indexed.'); |
|
| 161 | + $io->error('ERROR: Document "'.$input->getOption('doc').'" not saved and indexed.'); |
|
| 162 | 162 | exit(1); |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | } else { |
| 166 | - $io->error('ERROR: Document "' . $input->getOption('doc') . '" could not be loaded.'); |
|
| 166 | + $io->error('ERROR: Document "'.$input->getOption('doc').'" could not be loaded.'); |
|
| 167 | 167 | exit(1); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | ->setHelp('') |
| 45 | 45 | ->addOption( |
| 46 | 46 | 'dry-run', |
| 47 | - null, |
|
| 47 | + NULL, |
|
| 48 | 48 | InputOption::VALUE_NONE, |
| 49 | 49 | 'If this option is set, the files will not actually be processed but the location URI is shown.' |
| 50 | 50 | ) |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | // Make sure the _cli_ user is loaded |
| 88 | 88 | Bootstrap::getInstance()->initializeBackendAuthentication(); |
| 89 | 89 | |
| 90 | - $dryRun = $input->getOption('dry-run') != false ? true : false; |
|
| 90 | + $dryRun = $input->getOption('dry-run') != FALSE ? TRUE : FALSE; |
|
| 91 | 91 | |
| 92 | 92 | $io = new SymfonyStyle($input, $output); |
| 93 | 93 | $io->title($this->getDescription()); |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | $owner = (string) $input->getOption('owner'); |
| 145 | 145 | } |
| 146 | 146 | } else { |
| 147 | - $owner = null; |
|
| 147 | + $owner = NULL; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Get the document... |
| 151 | - $doc = Document::getInstance($input->getOption('doc'), $startingPoint, true); |
|
| 151 | + $doc = Document::getInstance($input->getOption('doc'), $startingPoint, TRUE); |
|
| 152 | 152 | if ($doc->ready) { |
| 153 | 153 | if ($dryRun) { |
| 154 | 154 | $io->section('DRY RUN: Would index ' . $doc->uid . ' ("' . $doc->location . '") on PID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $startingPoint = MathUtility::forceIntegerInRange((int) $input->getOption('pid'), 0); |
| 114 | 114 | } |
| 115 | 115 | if ($startingPoint == 0) { |
| 116 | - $io->error('ERROR: No valid PID (' . $startingPoint . ') given.'); |
|
| 116 | + $io->error('ERROR: No valid PID ('.$startingPoint.') given.'); |
|
| 117 | 117 | exit(1); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | if (empty($solrCoreUid) || !in_array($solrCoreUid, $allSolrCores)) { |
| 132 | 132 | $output_solrCores = []; |
| 133 | 133 | foreach ($allSolrCores as $index_name => $uid) { |
| 134 | - $output_solrCores[] = $uid . ' : ' . $index_name; |
|
| 134 | + $output_solrCores[] = $uid.' : '.$index_name; |
|
| 135 | 135 | } |
| 136 | 136 | if (empty($output_solrCores)) { |
| 137 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. No valid cores found on PID ' . $startingPoint . ".\n"); |
|
| 137 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. No valid cores found on PID '.$startingPoint.".\n"); |
|
| 138 | 138 | exit(1); |
| 139 | 139 | } else { |
| 140 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (<uid>:<index_name>):\n" . implode("\n", $output_solrCores) . "\n"); |
|
| 140 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. '."Valid cores are (<uid>:<index_name>):\n".implode("\n", $output_solrCores)."\n"); |
|
| 141 | 141 | exit(1); |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | exit(1); |
| 174 | 174 | } |
| 175 | 175 | if (!GeneralUtility::isValidUrl($baseUrl)) { |
| 176 | - $io->error('ERROR: No valid OAI Base URL set for library with given UID ("' . $input->getOption('lib') . '").'); |
|
| 176 | + $io->error('ERROR: No valid OAI Base URL set for library with given UID ("'.$input->getOption('lib').'").'); |
|
| 177 | 177 | exit(1); |
| 178 | 178 | } else { |
| 179 | 179 | try { |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | if (empty($set)) { |
| 217 | - $io->error('ERROR: OAI interface does not provide a set with given setSpec ("' . $input->getOption('set') . '").'); |
|
| 217 | + $io->error('ERROR: OAI interface does not provide a set with given setSpec ("'.$input->getOption('set').'").'); |
|
| 218 | 218 | exit(1); |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // Process all identifiers. |
| 230 | - $baseLocation = $baseUrl . (parse_url($baseUrl, PHP_URL_QUERY) ? '&' : '?'); |
|
| 230 | + $baseLocation = $baseUrl.(parse_url($baseUrl, PHP_URL_QUERY) ? '&' : '?'); |
|
| 231 | 231 | foreach ($identifiers as $identifier) { |
| 232 | 232 | // Build OAI GetRecord URL... |
| 233 | 233 | $params = [ |
@@ -235,23 +235,23 @@ discard block |
||
| 235 | 235 | 'metadataPrefix' => 'mets', |
| 236 | 236 | 'identifier' => (string) $identifier->identifier |
| 237 | 237 | ]; |
| 238 | - $docLocation = $baseLocation . http_build_query($params); |
|
| 238 | + $docLocation = $baseLocation.http_build_query($params); |
|
| 239 | 239 | // ...index the document... |
| 240 | 240 | $doc = Document::getInstance($docLocation, $startingPoint, true); |
| 241 | 241 | if ($doc->ready) { |
| 242 | 242 | if ($dryRun) { |
| 243 | - $io->writeln('DRY RUN: Would index ' . $doc->uid . ' ("' . $doc->location . '") on PID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
|
| 243 | + $io->writeln('DRY RUN: Would index '.$doc->uid.' ("'.$doc->location.'") on PID '.$startingPoint.' and Solr core '.$solrCoreUid.'.'); |
|
| 244 | 244 | } else { |
| 245 | 245 | if ($io->isVerbose()) { |
| 246 | - $io->writeln(date('Y-m-d H:i:s') . ' Indexing ' . $doc->uid . ' ("' . $doc->location . '") on PID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
|
| 246 | + $io->writeln(date('Y-m-d H:i:s').' Indexing '.$doc->uid.' ("'.$doc->location.'") on PID '.$startingPoint.' and Solr core '.$solrCoreUid.'.'); |
|
| 247 | 247 | } |
| 248 | 248 | // ...and save it to the database... |
| 249 | 249 | if (!$doc->save($startingPoint, $solrCoreUid, (int) $input->getOption('lib'))) { |
| 250 | - $io->error('ERROR: Document "' . $doc->location . '" not saved and indexed.'); |
|
| 250 | + $io->error('ERROR: Document "'.$doc->location.'" not saved and indexed.'); |
|
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | } else { |
| 254 | - $io->error('ERROR: Document "' . $docLocation . '" could not be loaded.'); |
|
| 254 | + $io->error('ERROR: Document "'.$docLocation.'" could not be loaded.'); |
|
| 255 | 255 | } |
| 256 | 256 | // Clear document registry to prevent memory exhaustion. |
| 257 | 257 | Document::clearRegistry(); |
@@ -270,6 +270,6 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | protected function handleOaiError(BaseoaipmhException $exception, SymfonyStyle $io) |
| 272 | 272 | { |
| 273 | - $io->error('ERROR: Trying to retrieve data from OAI interface resulted in error:' . "\n " . $exception->getMessage()); |
|
| 273 | + $io->error('ERROR: Trying to retrieve data from OAI interface resulted in error:'."\n ".$exception->getMessage()); |
|
| 274 | 274 | } |
| 275 | 275 | } |
@@ -34,15 +34,13 @@ discard block |
||
| 34 | 34 | * @subpackage dlf |
| 35 | 35 | * @access public |
| 36 | 36 | */ |
| 37 | -class HarvestCommand extends BaseCommand |
|
| 38 | -{ |
|
| 37 | +class HarvestCommand extends BaseCommand { |
|
| 39 | 38 | /** |
| 40 | 39 | * Configure the command by defining the name, options and arguments |
| 41 | 40 | * |
| 42 | 41 | * @return void |
| 43 | 42 | */ |
| 44 | - public function configure() |
|
| 45 | - { |
|
| 43 | + public function configure() { |
|
| 46 | 44 | $this |
| 47 | 45 | ->setDescription('Harvest OAI-PMH contents into database and Solr.') |
| 48 | 46 | ->setHelp('') |
@@ -98,8 +96,7 @@ discard block |
||
| 98 | 96 | * |
| 99 | 97 | * @return void |
| 100 | 98 | */ |
| 101 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
| 102 | - { |
|
| 99 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 103 | 100 | // Make sure the _cli_ user is loaded |
| 104 | 101 | Bootstrap::getInstance()->initializeBackendAuthentication(); |
| 105 | 102 | |
@@ -268,8 +265,7 @@ discard block |
||
| 268 | 265 | * |
| 269 | 266 | * @return void |
| 270 | 267 | */ |
| 271 | - protected function handleOaiError(BaseoaipmhException $exception, SymfonyStyle $io) |
|
| 272 | - { |
|
| 268 | + protected function handleOaiError(BaseoaipmhException $exception, SymfonyStyle $io) { |
|
| 273 | 269 | $io->error('ERROR: Trying to retrieve data from OAI interface resulted in error:' . "\n " . $exception->getMessage()); |
| 274 | 270 | } |
| 275 | 271 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | ->setHelp('') |
| 49 | 49 | ->addOption( |
| 50 | 50 | 'dry-run', |
| 51 | - null, |
|
| 51 | + NULL, |
|
| 52 | 52 | InputOption::VALUE_NONE, |
| 53 | 53 | 'If this option is set, the files will not actually be processed but the location URIs are shown.' |
| 54 | 54 | ) |
@@ -72,19 +72,19 @@ discard block |
||
| 72 | 72 | ) |
| 73 | 73 | ->addOption( |
| 74 | 74 | 'from', |
| 75 | - null, |
|
| 75 | + NULL, |
|
| 76 | 76 | InputOption::VALUE_OPTIONAL, |
| 77 | 77 | 'Datestamp (YYYY-MM-DD) to begin harvesting from.' |
| 78 | 78 | ) |
| 79 | 79 | ->addOption( |
| 80 | 80 | 'until', |
| 81 | - null, |
|
| 81 | + NULL, |
|
| 82 | 82 | InputOption::VALUE_OPTIONAL, |
| 83 | 83 | 'Datestamp (YYYY-MM-DD) to end harvesting on.' |
| 84 | 84 | ) |
| 85 | 85 | ->addOption( |
| 86 | 86 | 'set', |
| 87 | - null, |
|
| 87 | + NULL, |
|
| 88 | 88 | InputOption::VALUE_OPTIONAL, |
| 89 | 89 | 'Name of the set to limit harvesting to.' |
| 90 | 90 | ); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | // Make sure the _cli_ user is loaded |
| 104 | 104 | Bootstrap::getInstance()->initializeBackendAuthentication(); |
| 105 | 105 | |
| 106 | - $dryRun = $input->getOption('dry-run') != false ? true : false; |
|
| 106 | + $dryRun = $input->getOption('dry-run') != FALSE ? TRUE : FALSE; |
|
| 107 | 107 | |
| 108 | 108 | $io = new SymfonyStyle($input, $output); |
| 109 | 109 | $io->title($this->getDescription()); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | ) { |
| 190 | 190 | $from = new \DateTime($input->getOption('from')); |
| 191 | 191 | } else { |
| 192 | - $from = null; |
|
| 192 | + $from = NULL; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | if ( |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | ) { |
| 199 | 199 | $until = new \DateTime($input->getOption('until')); |
| 200 | 200 | } else { |
| 201 | - $until = null; |
|
| 201 | + $until = NULL; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $set = null; |
|
| 204 | + $set = NULL; |
|
| 205 | 205 | if ( |
| 206 | 206 | !is_array($input->getOption('set')) |
| 207 | 207 | && !empty($input->getOption('set')) |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | ]; |
| 238 | 238 | $docLocation = $baseLocation . http_build_query($params); |
| 239 | 239 | // ...index the document... |
| 240 | - $doc = Document::getInstance($docLocation, $startingPoint, true); |
|
| 240 | + $doc = Document::getInstance($docLocation, $startingPoint, TRUE); |
|
| 241 | 241 | if ($doc->ready) { |
| 242 | 242 | if ($dryRun) { |
| 243 | 243 | $io->writeln('DRY RUN: Would index ' . $doc->uid . ' ("' . $doc->location . '") on PID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | * @property-read mixed $uid This holds the UID or the URL of the document |
| 48 | 48 | * @abstract |
| 49 | 49 | */ |
| 50 | -abstract class Document |
|
| 51 | -{ |
|
| 50 | +abstract class Document { |
|
| 52 | 51 | /** |
| 53 | 52 | * This holds the logger |
| 54 | 53 | * |
@@ -340,8 +339,7 @@ discard block |
||
| 340 | 339 | * |
| 341 | 340 | * @return void |
| 342 | 341 | */ |
| 343 | - public static function clearRegistry() |
|
| 344 | - { |
|
| 342 | + public static function clearRegistry() { |
|
| 345 | 343 | // Reset registry array. |
| 346 | 344 | self::$registry = []; |
| 347 | 345 | } |
@@ -616,8 +614,7 @@ discard block |
||
| 616 | 614 | * |
| 617 | 615 | * @return int The physical page number |
| 618 | 616 | */ |
| 619 | - public function getPhysicalPage($logicalPage) |
|
| 620 | - { |
|
| 617 | + public function getPhysicalPage($logicalPage) { |
|
| 621 | 618 | if ( |
| 622 | 619 | !empty($this->lastSearchedPhysicalPage['logicalPage']) |
| 623 | 620 | && $this->lastSearchedPhysicalPage['logicalPage'] == $logicalPage |
@@ -664,8 +661,7 @@ discard block |
||
| 664 | 661 | * |
| 665 | 662 | * @return string The physical structure node's / IIIF resource's raw text from XML |
| 666 | 663 | */ |
| 667 | - protected function getRawTextFromXml($id) |
|
| 668 | - { |
|
| 664 | + protected function getRawTextFromXml($id) { |
|
| 669 | 665 | $rawText = ''; |
| 670 | 666 | // Load available text formats, ... |
| 671 | 667 | $this->loadFormats(); |
@@ -739,8 +735,7 @@ discard block |
||
| 739 | 735 | * |
| 740 | 736 | * @return string The title of the document itself or a parent document |
| 741 | 737 | */ |
| 742 | - public static function getTitle($uid, $recursive = false) |
|
| 743 | - { |
|
| 738 | + public static function getTitle($uid, $recursive = false) { |
|
| 744 | 739 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
| 745 | 740 | |
| 746 | 741 | $title = ''; |
@@ -794,8 +789,7 @@ discard block |
||
| 794 | 789 | * |
| 795 | 790 | * @return array The logical structure node's / resource's parsed metadata array |
| 796 | 791 | */ |
| 797 | - public function getTitledata($cPid = 0) |
|
| 798 | - { |
|
| 792 | + public function getTitledata($cPid = 0) { |
|
| 799 | 793 | $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); |
| 800 | 794 | // Add information from METS structural map to titledata array. |
| 801 | 795 | if ($this instanceof MetsDocument) { |
@@ -828,8 +822,7 @@ discard block |
||
| 828 | 822 | * @return int|bool: false if structure with $logId is not a child of this substructure, |
| 829 | 823 | * or the actual depth. |
| 830 | 824 | */ |
| 831 | - protected function getTreeDepth($structure, $depth, $logId) |
|
| 832 | - { |
|
| 825 | + protected function getTreeDepth($structure, $depth, $logId) { |
|
| 833 | 826 | foreach ($structure as $element) { |
| 834 | 827 | if ($element['id'] == $logId) { |
| 835 | 828 | return $depth; |
@@ -851,8 +844,7 @@ discard block |
||
| 851 | 844 | * @param string $logId: The id of the logical structure element whose depth is requested |
| 852 | 845 | * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. |
| 853 | 846 | */ |
| 854 | - public function getStructureDepth($logId) |
|
| 855 | - { |
|
| 847 | + public function getStructureDepth($logId) { |
|
| 856 | 848 | return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId); |
| 857 | 849 | } |
| 858 | 850 | |
@@ -902,8 +894,7 @@ discard block |
||
| 902 | 894 | * |
| 903 | 895 | * @return bool true on success or false on failure |
| 904 | 896 | */ |
| 905 | - protected function load($location) |
|
| 906 | - { |
|
| 897 | + protected function load($location) { |
|
| 907 | 898 | // Load XML / JSON-LD file. |
| 908 | 899 | if (GeneralUtility::isValidUrl($location)) { |
| 909 | 900 | // Load extension configuration |
@@ -936,8 +927,7 @@ discard block |
||
| 936 | 927 | * |
| 937 | 928 | * @return void |
| 938 | 929 | */ |
| 939 | - protected function loadFormats() |
|
| 940 | - { |
|
| 930 | + protected function loadFormats() { |
|
| 941 | 931 | if (!$this->formatsLoaded) { |
| 942 | 932 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 943 | 933 | ->getQueryBuilderForTable('tx_dlf_formats'); |
@@ -977,8 +967,7 @@ discard block |
||
| 977 | 967 | * |
| 978 | 968 | * @return void |
| 979 | 969 | */ |
| 980 | - public function registerNamespaces(&$obj) |
|
| 981 | - { |
|
| 970 | + public function registerNamespaces(&$obj) { |
|
| 982 | 971 | // 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. |
| 983 | 972 | $this->loadFormats(); |
| 984 | 973 | // Do we have a \SimpleXMLElement or \DOMXPath object? |
@@ -1007,8 +996,7 @@ discard block |
||
| 1007 | 996 | * |
| 1008 | 997 | * @return bool true on success or false on failure |
| 1009 | 998 | */ |
| 1010 | - public function save($pid = 0, $core = 0, $owner = null) |
|
| 1011 | - { |
|
| 999 | + public function save($pid = 0, $core = 0, $owner = null) { |
|
| 1012 | 1000 | if (\TYPO3_MODE !== 'BE') { |
| 1013 | 1001 | $this->logger->error('Saving a document is only allowed in the backend'); |
| 1014 | 1002 | return false; |
@@ -1333,8 +1321,7 @@ discard block |
||
| 1333 | 1321 | * |
| 1334 | 1322 | * @return int The PID of the metadata definitions |
| 1335 | 1323 | */ |
| 1336 | - protected function _getCPid() |
|
| 1337 | - { |
|
| 1324 | + protected function _getCPid() { |
|
| 1338 | 1325 | return $this->cPid; |
| 1339 | 1326 | } |
| 1340 | 1327 | |
@@ -1345,8 +1332,7 @@ discard block |
||
| 1345 | 1332 | * |
| 1346 | 1333 | * @return bool Are there any fulltext files available? |
| 1347 | 1334 | */ |
| 1348 | - protected function _getHasFulltext() |
|
| 1349 | - { |
|
| 1335 | + protected function _getHasFulltext() { |
|
| 1350 | 1336 | $this->ensureHasFulltextIsSet(); |
| 1351 | 1337 | return $this->hasFulltext; |
| 1352 | 1338 | } |
@@ -1358,8 +1344,7 @@ discard block |
||
| 1358 | 1344 | * |
| 1359 | 1345 | * @return string The location of the document |
| 1360 | 1346 | */ |
| 1361 | - protected function _getLocation() |
|
| 1362 | - { |
|
| 1347 | + protected function _getLocation() { |
|
| 1363 | 1348 | return $this->location; |
| 1364 | 1349 | } |
| 1365 | 1350 | |
@@ -1381,8 +1366,7 @@ discard block |
||
| 1381 | 1366 | * |
| 1382 | 1367 | * @return array Array of metadata with their corresponding logical structure node ID as key |
| 1383 | 1368 | */ |
| 1384 | - protected function _getMetadataArray() |
|
| 1385 | - { |
|
| 1369 | + protected function _getMetadataArray() { |
|
| 1386 | 1370 | // Set metadata definitions' PID. |
| 1387 | 1371 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
| 1388 | 1372 | if (!$cPid) { |
@@ -1407,8 +1391,7 @@ discard block |
||
| 1407 | 1391 | * |
| 1408 | 1392 | * @return int The total number of pages and/or tracks |
| 1409 | 1393 | */ |
| 1410 | - protected function _getNumPages() |
|
| 1411 | - { |
|
| 1394 | + protected function _getNumPages() { |
|
| 1412 | 1395 | $this->_getPhysicalStructure(); |
| 1413 | 1396 | return $this->numPages; |
| 1414 | 1397 | } |
@@ -1420,8 +1403,7 @@ discard block |
||
| 1420 | 1403 | * |
| 1421 | 1404 | * @return int The UID of the parent document or zero if not applicable |
| 1422 | 1405 | */ |
| 1423 | - protected function _getParentId() |
|
| 1424 | - { |
|
| 1406 | + protected function _getParentId() { |
|
| 1425 | 1407 | return $this->parentId; |
| 1426 | 1408 | } |
| 1427 | 1409 | |
@@ -1444,8 +1426,7 @@ discard block |
||
| 1444 | 1426 | * |
| 1445 | 1427 | * @return array Array of elements' type, label and file representations ordered by @ID attribute / Canvas order |
| 1446 | 1428 | */ |
| 1447 | - protected function _getPhysicalStructureInfo() |
|
| 1448 | - { |
|
| 1429 | + protected function _getPhysicalStructureInfo() { |
|
| 1449 | 1430 | // Is there no physical structure array yet? |
| 1450 | 1431 | if (!$this->physicalStructureLoaded) { |
| 1451 | 1432 | // Build physical structure array. |
@@ -1461,8 +1442,7 @@ discard block |
||
| 1461 | 1442 | * |
| 1462 | 1443 | * @return int The PID of the document or zero if not in database |
| 1463 | 1444 | */ |
| 1464 | - protected function _getPid() |
|
| 1465 | - { |
|
| 1445 | + protected function _getPid() { |
|
| 1466 | 1446 | return $this->pid; |
| 1467 | 1447 | } |
| 1468 | 1448 | |
@@ -1473,8 +1453,7 @@ discard block |
||
| 1473 | 1453 | * |
| 1474 | 1454 | * @return bool Is the document instantiated successfully? |
| 1475 | 1455 | */ |
| 1476 | - protected function _getReady() |
|
| 1477 | - { |
|
| 1456 | + protected function _getReady() { |
|
| 1478 | 1457 | return $this->ready; |
| 1479 | 1458 | } |
| 1480 | 1459 | |
@@ -1485,8 +1464,7 @@ discard block |
||
| 1485 | 1464 | * |
| 1486 | 1465 | * @return mixed The METS file's / IIIF manifest's record identifier |
| 1487 | 1466 | */ |
| 1488 | - protected function _getRecordId() |
|
| 1489 | - { |
|
| 1467 | + protected function _getRecordId() { |
|
| 1490 | 1468 | return $this->recordId; |
| 1491 | 1469 | } |
| 1492 | 1470 | |
@@ -1497,8 +1475,7 @@ discard block |
||
| 1497 | 1475 | * |
| 1498 | 1476 | * @return int The UID of the root document or zero if not applicable |
| 1499 | 1477 | */ |
| 1500 | - protected function _getRootId() |
|
| 1501 | - { |
|
| 1478 | + protected function _getRootId() { |
|
| 1502 | 1479 | if (!$this->rootIdLoaded) { |
| 1503 | 1480 | if ($this->parentId) { |
| 1504 | 1481 | $parent = self::getInstance($this->parentId, $this->pid); |
@@ -1528,8 +1505,7 @@ discard block |
||
| 1528 | 1505 | * |
| 1529 | 1506 | * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved |
| 1530 | 1507 | */ |
| 1531 | - protected function _getTableOfContents() |
|
| 1532 | - { |
|
| 1508 | + protected function _getTableOfContents() { |
|
| 1533 | 1509 | // Is there no logical structure array yet? |
| 1534 | 1510 | if (!$this->tableOfContentsLoaded) { |
| 1535 | 1511 | // Get all logical structures. |
@@ -1570,8 +1546,7 @@ discard block |
||
| 1570 | 1546 | * |
| 1571 | 1547 | * @return mixed The UID or the URL of the document |
| 1572 | 1548 | */ |
| 1573 | - protected function _getUid() |
|
| 1574 | - { |
|
| 1549 | + protected function _getUid() { |
|
| 1575 | 1550 | return $this->uid; |
| 1576 | 1551 | } |
| 1577 | 1552 | |
@@ -1584,8 +1559,7 @@ discard block |
||
| 1584 | 1559 | * |
| 1585 | 1560 | * @return void |
| 1586 | 1561 | */ |
| 1587 | - protected function _setCPid($value) |
|
| 1588 | - { |
|
| 1562 | + protected function _setCPid($value) { |
|
| 1589 | 1563 | $this->cPid = max(intval($value), 0); |
| 1590 | 1564 | } |
| 1591 | 1565 | |
@@ -1596,8 +1570,7 @@ discard block |
||
| 1596 | 1570 | * |
| 1597 | 1571 | * @return void |
| 1598 | 1572 | */ |
| 1599 | - protected function __clone() |
|
| 1600 | - { |
|
| 1573 | + protected function __clone() { |
|
| 1601 | 1574 | // This method is defined as protected because singleton objects should not be cloned. |
| 1602 | 1575 | } |
| 1603 | 1576 | |
@@ -1614,8 +1587,7 @@ discard block |
||
| 1614 | 1587 | * |
| 1615 | 1588 | * @return void |
| 1616 | 1589 | */ |
| 1617 | - protected function __construct($uid, $pid, $preloadedDocument) |
|
| 1618 | - { |
|
| 1590 | + protected function __construct($uid, $pid, $preloadedDocument) { |
|
| 1619 | 1591 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 1620 | 1592 | ->getQueryBuilderForTable('tx_dlf_documents'); |
| 1621 | 1593 | $location = ''; |
@@ -1727,8 +1699,7 @@ discard block |
||
| 1727 | 1699 | * |
| 1728 | 1700 | * @return mixed Value of $this->$var |
| 1729 | 1701 | */ |
| 1730 | - public function __get($var) |
|
| 1731 | - { |
|
| 1702 | + public function __get($var) { |
|
| 1732 | 1703 | $method = '_get' . ucfirst($var); |
| 1733 | 1704 | if ( |
| 1734 | 1705 | !property_exists($this, $var) |
@@ -1750,8 +1721,7 @@ discard block |
||
| 1750 | 1721 | * |
| 1751 | 1722 | * @return bool true if variable is set and not empty, false otherwise |
| 1752 | 1723 | */ |
| 1753 | - public function __isset($var) |
|
| 1754 | - { |
|
| 1724 | + public function __isset($var) { |
|
| 1755 | 1725 | return !empty($this->__get($var)); |
| 1756 | 1726 | } |
| 1757 | 1727 | |
@@ -1765,8 +1735,7 @@ discard block |
||
| 1765 | 1735 | * |
| 1766 | 1736 | * @return void |
| 1767 | 1737 | */ |
| 1768 | - public function __set($var, $value) |
|
| 1769 | - { |
|
| 1738 | + public function __set($var, $value) { |
|
| 1770 | 1739 | $method = '_set' . ucfirst($var); |
| 1771 | 1740 | if ( |
| 1772 | 1741 | !property_exists($this, $var) |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @var bool |
| 103 | 103 | * @access protected |
| 104 | 104 | */ |
| 105 | - protected $formatsLoaded = false; |
|
| 105 | + protected $formatsLoaded = FALSE; |
|
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Are there any fulltext files available? This also includes IIIF text annotations |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @var bool |
| 113 | 113 | * @access protected |
| 114 | 114 | */ |
| 115 | - protected $hasFulltext = false; |
|
| 115 | + protected $hasFulltext = FALSE; |
|
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * Last searched logical and physical page |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @var array |
| 121 | 121 | * @access protected |
| 122 | 122 | */ |
| 123 | - protected $lastSearchedPhysicalPage = ['logicalPage' => null, 'physicalPage' => null]; |
|
| 123 | + protected $lastSearchedPhysicalPage = ['logicalPage' => NULL, 'physicalPage' => NULL]; |
|
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * This holds the documents location |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @var bool |
| 155 | 155 | * @access protected |
| 156 | 156 | */ |
| 157 | - protected $metadataArrayLoaded = false; |
|
| 157 | + protected $metadataArrayLoaded = FALSE; |
|
| 158 | 158 | |
| 159 | 159 | /** |
| 160 | 160 | * The holds the total number of pages |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @var bool |
| 196 | 196 | * @access protected |
| 197 | 197 | */ |
| 198 | - protected $physicalStructureLoaded = false; |
|
| 198 | + protected $physicalStructureLoaded = FALSE; |
|
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | 201 | * This holds the PID of the document or zero if not in database |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @var bool |
| 221 | 221 | * @access protected |
| 222 | 222 | */ |
| 223 | - protected $ready = false; |
|
| 223 | + protected $ready = FALSE; |
|
| 224 | 224 | |
| 225 | 225 | /** |
| 226 | 226 | * The METS file's / IIIF manifest's record identifier |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @var bool |
| 255 | 255 | * @access protected |
| 256 | 256 | */ |
| 257 | - protected $rootIdLoaded = false; |
|
| 257 | + protected $rootIdLoaded = FALSE; |
|
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | 260 | * This holds the smLinks between logical and physical structMap |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @var bool |
| 272 | 272 | * @access protected |
| 273 | 273 | */ |
| 274 | - protected $smLinksLoaded = false; |
|
| 274 | + protected $smLinksLoaded = FALSE; |
|
| 275 | 275 | |
| 276 | 276 | /** |
| 277 | 277 | * This holds the logical structure |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * @var bool |
| 289 | 289 | * @access protected |
| 290 | 290 | */ |
| 291 | - protected $tableOfContentsLoaded = false; |
|
| 291 | + protected $tableOfContentsLoaded = FALSE; |
|
| 292 | 292 | |
| 293 | 293 | /** |
| 294 | 294 | * This holds the document's thumbnail location |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * @var bool |
| 306 | 306 | * @access protected |
| 307 | 307 | */ |
| 308 | - protected $thumbnailLoaded = false; |
|
| 308 | + protected $thumbnailLoaded = FALSE; |
|
| 309 | 309 | |
| 310 | 310 | /** |
| 311 | 311 | * This holds the toplevel structure's @ID (METS) or the manifest's @id (IIIF) |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | * |
| 423 | 423 | * @return \Kitodo\Dlf\Common\Document Instance of this class, either MetsDocument or IiifManifest |
| 424 | 424 | */ |
| 425 | - public static function &getInstance($uid, $pid = 0, $forceReload = false) |
|
| 425 | + public static function &getInstance($uid, $pid = 0, $forceReload = FALSE) |
|
| 426 | 426 | { |
| 427 | 427 | // Sanitize input. |
| 428 | 428 | $pid = max(intval($pid), 0); |
@@ -462,10 +462,10 @@ discard block |
||
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | 464 | // Create new instance depending on format (METS or IIIF) ... |
| 465 | - $instance = null; |
|
| 466 | - $documentFormat = null; |
|
| 467 | - $xml = null; |
|
| 468 | - $iiif = null; |
|
| 465 | + $instance = NULL; |
|
| 466 | + $documentFormat = NULL; |
|
| 467 | + $xml = NULL; |
|
| 468 | + $iiif = NULL; |
|
| 469 | 469 | // Try to get document format from database |
| 470 | 470 | if (MathUtility::canBeInterpretedAsInteger($uid)) { |
| 471 | 471 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
@@ -514,27 +514,27 @@ discard block |
||
| 514 | 514 | @ini_set('user_agent', $extConf['useragent']); |
| 515 | 515 | } |
| 516 | 516 | $content = GeneralUtility::getUrl($location); |
| 517 | - if ($content !== false) { |
|
| 517 | + if ($content !== FALSE) { |
|
| 518 | 518 | // TODO use single place to load xml |
| 519 | 519 | // Turn off libxml's error logging. |
| 520 | - $libxmlErrors = libxml_use_internal_errors(true); |
|
| 520 | + $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
| 521 | 521 | // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept |
| 522 | - $previousValueOfEntityLoader = libxml_disable_entity_loader(true); |
|
| 522 | + $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE); |
|
| 523 | 523 | // Try to load XML from file. |
| 524 | 524 | $xml = simplexml_load_string($content); |
| 525 | 525 | // reset entity loader setting |
| 526 | 526 | libxml_disable_entity_loader($previousValueOfEntityLoader); |
| 527 | 527 | // Reset libxml's error logging. |
| 528 | 528 | libxml_use_internal_errors($libxmlErrors); |
| 529 | - if ($xml !== false) { |
|
| 529 | + if ($xml !== FALSE) { |
|
| 530 | 530 | /* @var $xml \SimpleXMLElement */ |
| 531 | 531 | $xml->registerXPathNamespace('mets', 'http://www.loc.gov/METS/'); |
| 532 | 532 | $xpathResult = $xml->xpath('//mets:mets'); |
| 533 | - $documentFormat = !empty($xpathResult) ? 'METS' : null; |
|
| 533 | + $documentFormat = !empty($xpathResult) ? 'METS' : NULL; |
|
| 534 | 534 | } else { |
| 535 | 535 | // Try to load file as IIIF resource instead. |
| 536 | - $contentAsJsonArray = json_decode($content, true); |
|
| 537 | - if ($contentAsJsonArray !== null) { |
|
| 536 | + $contentAsJsonArray = json_decode($content, TRUE); |
|
| 537 | + if ($contentAsJsonArray !== NULL) { |
|
| 538 | 538 | // Load plugin configuration. |
| 539 | 539 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 540 | 540 | IiifHelper::setUrlReader(IiifUrlReader::getInstance()); |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | * |
| 590 | 590 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
| 591 | 591 | */ |
| 592 | - public abstract function getLogicalStructure($id, $recursive = false); |
|
| 592 | + public abstract function getLogicalStructure($id, $recursive = FALSE); |
|
| 593 | 593 | |
| 594 | 594 | /** |
| 595 | 595 | * This extracts all the metadata for a logical structure node |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | } else { |
| 627 | 627 | $physicalPage = 0; |
| 628 | 628 | foreach ($this->physicalStructureInfo as $page) { |
| 629 | - if (strpos($page['orderlabel'], $logicalPage) !== false) { |
|
| 629 | + if (strpos($page['orderlabel'], $logicalPage) !== FALSE) { |
|
| 630 | 630 | $this->lastSearchedPhysicalPage['logicalPage'] = $logicalPage; |
| 631 | 631 | $this->lastSearchedPhysicalPage['physicalPage'] = $physicalPage; |
| 632 | 632 | return $physicalPage; |
@@ -679,11 +679,11 @@ discard block |
||
| 679 | 679 | if (!empty($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])) { |
| 680 | 680 | // Get fulltext file. |
| 681 | 681 | $file = GeneralUtility::getUrl($this->getFileLocation($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])); |
| 682 | - if ($file !== false) { |
|
| 682 | + if ($file !== FALSE) { |
|
| 683 | 683 | // Turn off libxml's error logging. |
| 684 | - $libxmlErrors = libxml_use_internal_errors(true); |
|
| 684 | + $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
| 685 | 685 | // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept. |
| 686 | - $previousValueOfEntityLoader = libxml_disable_entity_loader(true); |
|
| 686 | + $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE); |
|
| 687 | 687 | // Load XML from file. |
| 688 | 688 | $rawTextXml = simplexml_load_string($file); |
| 689 | 689 | // Reset entity loader setting. |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | * |
| 740 | 740 | * @return string The title of the document itself or a parent document |
| 741 | 741 | */ |
| 742 | - public static function getTitle($uid, $recursive = false) |
|
| 742 | + public static function getTitle($uid, $recursive = FALSE) |
|
| 743 | 743 | { |
| 744 | 744 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
| 745 | 745 | |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | && intval($partof) |
| 775 | 775 | && $partof != $uid |
| 776 | 776 | ) { |
| 777 | - $title = self::getTitle($partof, true); |
|
| 777 | + $title = self::getTitle($partof, TRUE); |
|
| 778 | 778 | } |
| 779 | 779 | } else { |
| 780 | 780 | $logger->warning('No document with UID ' . $uid . ' found or document not accessible'); |
@@ -835,12 +835,12 @@ discard block |
||
| 835 | 835 | return $depth; |
| 836 | 836 | } elseif (array_key_exists('children', $element)) { |
| 837 | 837 | $foundInChildren = $this->getTreeDepth($element['children'], $depth + 1, $logId); |
| 838 | - if ($foundInChildren !== false) { |
|
| 838 | + if ($foundInChildren !== FALSE) { |
|
| 839 | 839 | return $foundInChildren; |
| 840 | 840 | } |
| 841 | 841 | } |
| 842 | 842 | } |
| 843 | - return false; |
|
| 843 | + return FALSE; |
|
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | /** |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | } else { |
| 918 | 918 | $this->logger->error('Invalid file location "' . $location . '" for document loading'); |
| 919 | 919 | } |
| 920 | - return false; |
|
| 920 | + return FALSE; |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | 'class' => $resArray['class'] |
| 965 | 965 | ]; |
| 966 | 966 | } |
| 967 | - $this->formatsLoaded = true; |
|
| 967 | + $this->formatsLoaded = TRUE; |
|
| 968 | 968 | } |
| 969 | 969 | } |
| 970 | 970 | |
@@ -1007,11 +1007,11 @@ discard block |
||
| 1007 | 1007 | * |
| 1008 | 1008 | * @return bool true on success or false on failure |
| 1009 | 1009 | */ |
| 1010 | - public function save($pid = 0, $core = 0, $owner = null) |
|
| 1010 | + public function save($pid = 0, $core = 0, $owner = NULL) |
|
| 1011 | 1011 | { |
| 1012 | 1012 | if (\TYPO3_MODE !== 'BE') { |
| 1013 | 1013 | $this->logger->error('Saving a document is only allowed in the backend'); |
| 1014 | - return false; |
|
| 1014 | + return FALSE; |
|
| 1015 | 1015 | } |
| 1016 | 1016 | // Make sure $pid is a non-negative integer. |
| 1017 | 1017 | $pid = max(intval($pid), 0); |
@@ -1026,7 +1026,7 @@ discard block |
||
| 1026 | 1026 | $pid = $this->pid; |
| 1027 | 1027 | } elseif (!$pid) { |
| 1028 | 1028 | $this->logger->error('Invalid PID ' . $pid . ' for document saving'); |
| 1029 | - return false; |
|
| 1029 | + return FALSE; |
|
| 1030 | 1030 | } |
| 1031 | 1031 | // Set PID for metadata definitions. |
| 1032 | 1032 | $this->cPid = $pid; |
@@ -1039,7 +1039,7 @@ discard block |
||
| 1039 | 1039 | // Check for record identifier. |
| 1040 | 1040 | if (empty($metadata['record_id'][0])) { |
| 1041 | 1041 | $this->logger->error('No record identifier found to avoid duplication'); |
| 1042 | - return false; |
|
| 1042 | + return FALSE; |
|
| 1043 | 1043 | } |
| 1044 | 1044 | // Load plugin configuration. |
| 1045 | 1045 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | $structure = $resArray['uid']; |
| 1064 | 1064 | } else { |
| 1065 | 1065 | $this->logger->error('Could not identify document/structure type "' . $queryBuilder->expr()->literal($metadata['type'][0]) . '"'); |
| 1066 | - return false; |
|
| 1066 | + return FALSE; |
|
| 1067 | 1067 | } |
| 1068 | 1068 | $metadata['type'][0] = $structure; |
| 1069 | 1069 | |
@@ -1120,9 +1120,9 @@ discard block |
||
| 1120 | 1120 | if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) { |
| 1121 | 1121 | Helper::addMessage( |
| 1122 | 1122 | htmlspecialchars(sprintf(Helper::getMessage('flash.newCollection'), $collection, $substUid[$collNewUid])), |
| 1123 | - Helper::getMessage('flash.attention', true), |
|
| 1123 | + Helper::getMessage('flash.attention', TRUE), |
|
| 1124 | 1124 | \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
| 1125 | - true |
|
| 1125 | + TRUE |
|
| 1126 | 1126 | ); |
| 1127 | 1127 | } |
| 1128 | 1128 | } |
@@ -1173,9 +1173,9 @@ discard block |
||
| 1173 | 1173 | if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) { |
| 1174 | 1174 | Helper::addMessage( |
| 1175 | 1175 | htmlspecialchars(sprintf(Helper::getMessage('flash.newLibrary'), $owner, $ownerUid)), |
| 1176 | - Helper::getMessage('flash.attention', true), |
|
| 1176 | + Helper::getMessage('flash.attention', TRUE), |
|
| 1177 | 1177 | \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
| 1178 | - true |
|
| 1178 | + TRUE |
|
| 1179 | 1179 | ); |
| 1180 | 1180 | } |
| 1181 | 1181 | } |
@@ -1263,7 +1263,7 @@ discard block |
||
| 1263 | 1263 | 'author' => implode('; ', $metadata['author']), |
| 1264 | 1264 | 'year' => implode('; ', $metadata['year']), |
| 1265 | 1265 | 'place' => implode('; ', $metadata['place']), |
| 1266 | - 'thumbnail' => $this->_getThumbnail(true), |
|
| 1266 | + 'thumbnail' => $this->_getThumbnail(TRUE), |
|
| 1267 | 1267 | 'metadata' => serialize($listed), |
| 1268 | 1268 | 'metadata_sorting' => serialize($sortable), |
| 1269 | 1269 | 'structure' => $metadata['type'][0], |
@@ -1299,9 +1299,9 @@ discard block |
||
| 1299 | 1299 | if (!(\TYPO3_REQUESTTYPE & \TYPO3_REQUESTTYPE_CLI)) { |
| 1300 | 1300 | Helper::addMessage( |
| 1301 | 1301 | htmlspecialchars(sprintf(Helper::getMessage('flash.documentSaved'), $metadata['title'][0], $this->uid)), |
| 1302 | - Helper::getMessage('flash.done', true), |
|
| 1302 | + Helper::getMessage('flash.done', TRUE), |
|
| 1303 | 1303 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK, |
| 1304 | - true |
|
| 1304 | + TRUE |
|
| 1305 | 1305 | ); |
| 1306 | 1306 | } |
| 1307 | 1307 | // Add document to index. |
@@ -1310,7 +1310,7 @@ discard block |
||
| 1310 | 1310 | } else { |
| 1311 | 1311 | $this->logger->notice('Invalid UID "' . $core . '" for Solr core'); |
| 1312 | 1312 | } |
| 1313 | - return true; |
|
| 1313 | + return TRUE; |
|
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | /** |
@@ -1395,7 +1395,7 @@ discard block |
||
| 1395 | 1395 | ) { |
| 1396 | 1396 | $this->prepareMetadataArray($cPid); |
| 1397 | 1397 | $this->metadataArray[0] = $cPid; |
| 1398 | - $this->metadataArrayLoaded = true; |
|
| 1398 | + $this->metadataArrayLoaded = TRUE; |
|
| 1399 | 1399 | } |
| 1400 | 1400 | return $this->metadataArray; |
| 1401 | 1401 | } |
@@ -1504,7 +1504,7 @@ discard block |
||
| 1504 | 1504 | $parent = self::getInstance($this->parentId, $this->pid); |
| 1505 | 1505 | $this->rootId = $parent->rootId; |
| 1506 | 1506 | } |
| 1507 | - $this->rootIdLoaded = true; |
|
| 1507 | + $this->rootIdLoaded = TRUE; |
|
| 1508 | 1508 | } |
| 1509 | 1509 | return $this->rootId; |
| 1510 | 1510 | } |
@@ -1533,8 +1533,8 @@ discard block |
||
| 1533 | 1533 | // Is there no logical structure array yet? |
| 1534 | 1534 | if (!$this->tableOfContentsLoaded) { |
| 1535 | 1535 | // Get all logical structures. |
| 1536 | - $this->getLogicalStructure('', true); |
|
| 1537 | - $this->tableOfContentsLoaded = true; |
|
| 1536 | + $this->getLogicalStructure('', TRUE); |
|
| 1537 | + $this->tableOfContentsLoaded = TRUE; |
|
| 1538 | 1538 | } |
| 1539 | 1539 | return $this->tableOfContents; |
| 1540 | 1540 | } |
@@ -1550,7 +1550,7 @@ discard block |
||
| 1550 | 1550 | * |
| 1551 | 1551 | * @return string The document's thumbnail location |
| 1552 | 1552 | */ |
| 1553 | - protected abstract function _getThumbnail($forceReload = false); |
|
| 1553 | + protected abstract function _getThumbnail($forceReload = FALSE); |
|
| 1554 | 1554 | |
| 1555 | 1555 | /** |
| 1556 | 1556 | * This returns the ID of the toplevel logical structure node |
@@ -1631,7 +1631,7 @@ discard block |
||
| 1631 | 1631 | && $this->load($uid))) { |
| 1632 | 1632 | // Initialize core METS object. |
| 1633 | 1633 | $this->init(); |
| 1634 | - if ($this->getDocument() !== null) { |
|
| 1634 | + if ($this->getDocument() !== NULL) { |
|
| 1635 | 1635 | // Cast to string for safety reasons. |
| 1636 | 1636 | $location = (string) $uid; |
| 1637 | 1637 | $this->establishRecordId($pid); |
@@ -1689,30 +1689,30 @@ discard block |
||
| 1689 | 1689 | $this->parentId = $resArray['partof']; |
| 1690 | 1690 | $this->thumbnail = $resArray['thumbnail']; |
| 1691 | 1691 | $this->location = $resArray['location']; |
| 1692 | - $this->thumbnailLoaded = true; |
|
| 1692 | + $this->thumbnailLoaded = TRUE; |
|
| 1693 | 1693 | // Load XML file if necessary... |
| 1694 | 1694 | if ( |
| 1695 | - $this->getDocument() === null |
|
| 1695 | + $this->getDocument() === NULL |
|
| 1696 | 1696 | && $this->load($this->location) |
| 1697 | 1697 | ) { |
| 1698 | 1698 | // ...and set some basic properties. |
| 1699 | 1699 | $this->init(); |
| 1700 | 1700 | } |
| 1701 | 1701 | // Do we have a METS / IIIF object now? |
| 1702 | - if ($this->getDocument() !== null) { |
|
| 1702 | + if ($this->getDocument() !== NULL) { |
|
| 1703 | 1703 | // Set new location if necessary. |
| 1704 | 1704 | if (!empty($location)) { |
| 1705 | 1705 | $this->location = $location; |
| 1706 | 1706 | } |
| 1707 | 1707 | // Document ready! |
| 1708 | - $this->ready = true; |
|
| 1708 | + $this->ready = TRUE; |
|
| 1709 | 1709 | } |
| 1710 | - } elseif ($this->getDocument() !== null) { |
|
| 1710 | + } elseif ($this->getDocument() !== NULL) { |
|
| 1711 | 1711 | // Set location as UID for documents not in database. |
| 1712 | 1712 | $this->uid = $location; |
| 1713 | 1713 | $this->location = $location; |
| 1714 | 1714 | // Document ready! |
| 1715 | - $this->ready = true; |
|
| 1715 | + $this->ready = TRUE; |
|
| 1716 | 1716 | } else { |
| 1717 | 1717 | $this->logger->error('No document with UID ' . $uid . ' found or document not accessible'); |
| 1718 | 1718 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | if (!preg_match('/[0-9]{8}-[0-9]{1}/i', $id)) { |
| 137 | 137 | return false; |
| 138 | 138 | } elseif ($checksum == 10) { |
| 139 | - return self::checkIdentifier(($digits + 1) . substr($id, -2, 2), 'SWD'); |
|
| 139 | + return self::checkIdentifier(($digits + 1).substr($id, -2, 2), 'SWD'); |
|
| 140 | 140 | } elseif (substr($id, -1, 1) != $checksum) { |
| 141 | 141 | return false; |
| 142 | 142 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | $encrypted = openssl_encrypt($string, self::$cipherAlgorithm, $key, OPENSSL_RAW_DATA, $iv); |
| 279 | 279 | // Merge initialisation vector and encrypted data. |
| 280 | 280 | if ($encrypted !== false) { |
| 281 | - $encrypted = base64_encode($iv . $encrypted); |
|
| 281 | + $encrypted = base64_encode($iv.$encrypted); |
|
| 282 | 282 | } |
| 283 | 283 | return $encrypted; |
| 284 | 284 | } |
@@ -332,8 +332,8 @@ discard block |
||
| 332 | 332 | public static function getHookObjects($scriptRelPath) |
| 333 | 333 | { |
| 334 | 334 | $hookObjects = []; |
| 335 | - if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) { |
|
| 336 | - foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) { |
|
| 335 | + if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'])) { |
|
| 336 | + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'] as $classRef) { |
|
| 337 | 337 | $hookObjects[] = GeneralUtility::makeInstance($classRef); |
| 338 | 338 | } |
| 339 | 339 | } |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | !$uid |
| 360 | 360 | || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores']) |
| 361 | 361 | ) { |
| 362 | - self::log('Invalid UID "' . $uid . '" or table "' . $table . '"', LOG_SEVERITY_ERROR); |
|
| 362 | + self::log('Invalid UID "'.$uid.'" or table "'.$table.'"', LOG_SEVERITY_ERROR); |
|
| 363 | 363 | return ''; |
| 364 | 364 | } |
| 365 | 365 | |
@@ -370,15 +370,15 @@ discard block |
||
| 370 | 370 | // Should we check for a specific PID, too? |
| 371 | 371 | if ($pid !== -1) { |
| 372 | 372 | $pid = max(intval($pid), 0); |
| 373 | - $where = $queryBuilder->expr()->eq($table . '.pid', $pid); |
|
| 373 | + $where = $queryBuilder->expr()->eq($table.'.pid', $pid); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // Get index_name from database. |
| 377 | 377 | $result = $queryBuilder |
| 378 | - ->select($table . '.index_name AS index_name') |
|
| 378 | + ->select($table.'.index_name AS index_name') |
|
| 379 | 379 | ->from($table) |
| 380 | 380 | ->where( |
| 381 | - $queryBuilder->expr()->eq($table . '.uid', $uid), |
|
| 381 | + $queryBuilder->expr()->eq($table.'.uid', $uid), |
|
| 382 | 382 | $where, |
| 383 | 383 | self::whereExpression($table) |
| 384 | 384 | ) |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | if ($resArray = $result->fetch()) { |
| 389 | 389 | return $resArray['index_name']; |
| 390 | 390 | } else { |
| 391 | - self::log('No "index_name" with UID ' . $uid . ' and PID ' . $pid . ' found in table "' . $table . '"', LOG_SEVERITY_WARNING); |
|
| 391 | + self::log('No "index_name" with UID '.$uid.' and PID '.$pid.' found in table "'.$table.'"', LOG_SEVERITY_WARNING); |
|
| 392 | 392 | return ''; |
| 393 | 393 | } |
| 394 | 394 | } |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | !$uid |
| 413 | 413 | || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores']) |
| 414 | 414 | ) { |
| 415 | - self::log('Invalid UID "' . $uid . '" or table "' . $table . '"', LOG_SEVERITY_ERROR); |
|
| 415 | + self::log('Invalid UID "'.$uid.'" or table "'.$table.'"', LOG_SEVERITY_ERROR); |
|
| 416 | 416 | return ''; |
| 417 | 417 | } |
| 418 | 418 | |
@@ -423,15 +423,15 @@ discard block |
||
| 423 | 423 | // Should we check for a specific PID, too? |
| 424 | 424 | if ($pid !== -1) { |
| 425 | 425 | $pid = max(intval($pid), 0); |
| 426 | - $where = $queryBuilder->expr()->eq($table . '.pid', $pid); |
|
| 426 | + $where = $queryBuilder->expr()->eq($table.'.pid', $pid); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | // Get label from database. |
| 430 | 430 | $result = $queryBuilder |
| 431 | - ->select($table . '.label AS label') |
|
| 431 | + ->select($table.'.label AS label') |
|
| 432 | 432 | ->from($table) |
| 433 | 433 | ->where( |
| 434 | - $queryBuilder->expr()->eq($table . '.uid', $uid), |
|
| 434 | + $queryBuilder->expr()->eq($table.'.uid', $uid), |
|
| 435 | 435 | $where, |
| 436 | 436 | self::whereExpression($table) |
| 437 | 437 | ) |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | if ($resArray = $result->fetch()) { |
| 442 | 442 | return $resArray['label']; |
| 443 | 443 | } else { |
| 444 | - self::log('No "label" with UID ' . $uid . ' and PID ' . $pid . ' found in table "' . $table . '"', LOG_SEVERITY_WARNING); |
|
| 444 | + self::log('No "label" with UID '.$uid.' and PID '.$pid.' found in table "'.$table.'"', LOG_SEVERITY_WARNING); |
|
| 445 | 445 | return ''; |
| 446 | 446 | } |
| 447 | 447 | } |
@@ -460,9 +460,9 @@ discard block |
||
| 460 | 460 | // Analyze code and set appropriate ISO table. |
| 461 | 461 | $isoCode = strtolower(trim($code)); |
| 462 | 462 | if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
| 463 | - $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey) . 'Resources/Private/Data/iso-639-2b.xml'; |
|
| 463 | + $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey).'Resources/Private/Data/iso-639-2b.xml'; |
|
| 464 | 464 | } elseif (preg_match('/^[a-z]{2}$/', $isoCode)) { |
| 465 | - $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey) . 'Resources/Private/Data/iso-639-1.xml'; |
|
| 465 | + $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey).'Resources/Private/Data/iso-639-1.xml'; |
|
| 466 | 466 | } else { |
| 467 | 467 | // No ISO code, return unchanged. |
| 468 | 468 | return $code; |
@@ -479,13 +479,13 @@ discard block |
||
| 479 | 479 | $lang = $GLOBALS['LANG']->getLLL($isoCode, $iso639); |
| 480 | 480 | } |
| 481 | 481 | } else { |
| 482 | - self::log('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', LOG_SEVERITY_ERROR); |
|
| 482 | + self::log('Unexpected TYPO3_MODE "'.\TYPO3_MODE.'"', LOG_SEVERITY_ERROR); |
|
| 483 | 483 | return $code; |
| 484 | 484 | } |
| 485 | 485 | if (!empty($lang)) { |
| 486 | 486 | return $lang; |
| 487 | 487 | } else { |
| 488 | - self::log('Language code "' . $code . '" not found in ISO-639 table', LOG_SEVERITY_NOTICE); |
|
| 488 | + self::log('Language code "'.$code.'" not found in ISO-639 table', LOG_SEVERITY_NOTICE); |
|
| 489 | 489 | return $code; |
| 490 | 490 | } |
| 491 | 491 | } |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | } elseif (\TYPO3_MODE === 'BE') { |
| 514 | 514 | self::$messages = $GLOBALS['LANG']->includeLLFile($file, false, true); |
| 515 | 515 | } else { |
| 516 | - self::log('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', LOG_SEVERITY_ERROR); |
|
| 516 | + self::log('Unexpected TYPO3_MODE "'.\TYPO3_MODE.'"', LOG_SEVERITY_ERROR); |
|
| 517 | 517 | } |
| 518 | 518 | } |
| 519 | 519 | // Get translation. |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | } elseif (\TYPO3_MODE === 'BE') { |
| 524 | 524 | $translated = $GLOBALS['LANG']->getLLL($key, self::$messages); |
| 525 | 525 | } else { |
| 526 | - self::log('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', LOG_SEVERITY_ERROR); |
|
| 526 | + self::log('Unexpected TYPO3_MODE "'.\TYPO3_MODE.'"', LOG_SEVERITY_ERROR); |
|
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | 529 | // Escape HTML characters if applicable. |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | !$index_name |
| 551 | 551 | || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores']) |
| 552 | 552 | ) { |
| 553 | - self::log('Invalid UID ' . $index_name . ' or table "' . $table . '"', LOG_SEVERITY_ERROR); |
|
| 553 | + self::log('Invalid UID '.$index_name.' or table "'.$table.'"', LOG_SEVERITY_ERROR); |
|
| 554 | 554 | return ''; |
| 555 | 555 | } |
| 556 | 556 | |
@@ -561,14 +561,14 @@ discard block |
||
| 561 | 561 | // Should we check for a specific PID, too? |
| 562 | 562 | if ($pid !== -1) { |
| 563 | 563 | $pid = max(intval($pid), 0); |
| 564 | - $where = $queryBuilder->expr()->eq($table . '.pid', $pid); |
|
| 564 | + $where = $queryBuilder->expr()->eq($table.'.pid', $pid); |
|
| 565 | 565 | } |
| 566 | 566 | // Get index_name from database. |
| 567 | 567 | $result = $queryBuilder |
| 568 | - ->select($table . '.uid AS uid') |
|
| 568 | + ->select($table.'.uid AS uid') |
|
| 569 | 569 | ->from($table) |
| 570 | 570 | ->where( |
| 571 | - $queryBuilder->expr()->eq($table . '.index_name', $queryBuilder->expr()->literal($index_name)), |
|
| 571 | + $queryBuilder->expr()->eq($table.'.index_name', $queryBuilder->expr()->literal($index_name)), |
|
| 572 | 572 | $where, |
| 573 | 573 | self::whereExpression($table) |
| 574 | 574 | ) |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | if (count($allResults) == 1) { |
| 581 | 581 | return $allResults[0]['uid']; |
| 582 | 582 | } else { |
| 583 | - self::log('No UID for given index_name "' . $index_name . '" and PID ' . $pid . ' found in table "' . $table . '"', LOG_SEVERITY_WARNING); |
|
| 583 | + self::log('No UID for given index_name "'.$index_name.'" and PID '.$pid.' found in table "'.$table.'"', LOG_SEVERITY_WARNING); |
|
| 584 | 584 | return ''; |
| 585 | 585 | } |
| 586 | 586 | } |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | '-' => 39, |
| 639 | 639 | ':' => 17, |
| 640 | 640 | ]; |
| 641 | - $urn = strtolower($base . $id); |
|
| 641 | + $urn = strtolower($base.$id); |
|
| 642 | 642 | if (preg_match('/[^a-z0-9:-]/', $urn)) { |
| 643 | 643 | self::log('Invalid chars in given parameters', LOG_SEVERITY_WARNING); |
| 644 | 644 | return ''; |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | $checksum += ($i + 1) * intval(substr($digits, $i, 1)); |
| 653 | 653 | } |
| 654 | 654 | $checksum = substr(intval($checksum / intval(substr($digits, -1, 1))), -1, 1); |
| 655 | - return $base . $id . $checksum; |
|
| 655 | + return $base.$id.$checksum; |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | /** |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | // Cast to string for security reasons. |
| 684 | 684 | $key = (string) $key; |
| 685 | 685 | if (!$key) { |
| 686 | - self::log('Invalid key "' . $key . '" for session data retrieval', LOG_SEVERITY_WARNING); |
|
| 686 | + self::log('Invalid key "'.$key.'" for session data retrieval', LOG_SEVERITY_WARNING); |
|
| 687 | 687 | return; |
| 688 | 688 | } |
| 689 | 689 | // Get the session data. |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | } elseif (\TYPO3_MODE === 'BE') { |
| 693 | 693 | return $GLOBALS['BE_USER']->getSessionData($key); |
| 694 | 694 | } else { |
| 695 | - self::log('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', LOG_SEVERITY_ERROR); |
|
| 695 | + self::log('Unexpected TYPO3_MODE "'.\TYPO3_MODE.'"', LOG_SEVERITY_ERROR); |
|
| 696 | 696 | return; |
| 697 | 697 | } |
| 698 | 698 | } |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | // Cast to string for security reasons. |
| 802 | 802 | $key = (string) $key; |
| 803 | 803 | if (!$key) { |
| 804 | - self::log('Invalid key "' . $key . '" for session data saving', LOG_SEVERITY_WARNING); |
|
| 804 | + self::log('Invalid key "'.$key.'" for session data saving', LOG_SEVERITY_WARNING); |
|
| 805 | 805 | return false; |
| 806 | 806 | } |
| 807 | 807 | // Save value in session data. |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | $GLOBALS['BE_USER']->setAndSaveSessionData($key, $value); |
| 814 | 814 | return true; |
| 815 | 815 | } else { |
| 816 | - self::log('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', LOG_SEVERITY_ERROR); |
|
| 816 | + self::log('Unexpected TYPO3_MODE "'.\TYPO3_MODE.'"', LOG_SEVERITY_ERROR); |
|
| 817 | 817 | return false; |
| 818 | 818 | } |
| 819 | 819 | } |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | // Sanitize input. |
| 837 | 837 | $pid = max(intval($pid), 0); |
| 838 | 838 | if (!$pid) { |
| 839 | - self::log('Invalid PID ' . $pid . ' for translation', LOG_SEVERITY_WARNING); |
|
| 839 | + self::log('Invalid PID '.$pid.' for translation', LOG_SEVERITY_WARNING); |
|
| 840 | 840 | return $index_name; |
| 841 | 841 | } |
| 842 | 842 | // Check if "index_name" is an UID. |
@@ -853,13 +853,13 @@ discard block |
||
| 853 | 853 | // First fetch the uid of the received index_name |
| 854 | 854 | $result = $queryBuilder |
| 855 | 855 | ->select( |
| 856 | - $table . '.uid AS uid', |
|
| 857 | - $table . '.l18n_parent AS l18n_parent' |
|
| 856 | + $table.'.uid AS uid', |
|
| 857 | + $table.'.l18n_parent AS l18n_parent' |
|
| 858 | 858 | ) |
| 859 | 859 | ->from($table) |
| 860 | 860 | ->where( |
| 861 | - $queryBuilder->expr()->eq($table . '.pid', $pid), |
|
| 862 | - $queryBuilder->expr()->eq($table . '.index_name', $queryBuilder->expr()->literal($index_name)), |
|
| 861 | + $queryBuilder->expr()->eq($table.'.pid', $pid), |
|
| 862 | + $queryBuilder->expr()->eq($table.'.index_name', $queryBuilder->expr()->literal($index_name)), |
|
| 863 | 863 | self::whereExpression($table, true) |
| 864 | 864 | ) |
| 865 | 865 | ->setMaxResults(1) |
@@ -872,12 +872,12 @@ discard block |
||
| 872 | 872 | $resArray = $allResults[0]; |
| 873 | 873 | |
| 874 | 874 | $result = $queryBuilder |
| 875 | - ->select($table . '.index_name AS index_name') |
|
| 875 | + ->select($table.'.index_name AS index_name') |
|
| 876 | 876 | ->from($table) |
| 877 | 877 | ->where( |
| 878 | - $queryBuilder->expr()->eq($table . '.pid', $pid), |
|
| 879 | - $queryBuilder->expr()->eq($table . '.uid', $resArray['l18n_parent']), |
|
| 880 | - $queryBuilder->expr()->eq($table . '.sys_language_uid', intval($GLOBALS['TSFE']->sys_language_content)), |
|
| 878 | + $queryBuilder->expr()->eq($table.'.pid', $pid), |
|
| 879 | + $queryBuilder->expr()->eq($table.'.uid', $resArray['l18n_parent']), |
|
| 880 | + $queryBuilder->expr()->eq($table.'.sys_language_uid', intval($GLOBALS['TSFE']->sys_language_content)), |
|
| 881 | 881 | self::whereExpression($table, true) |
| 882 | 882 | ) |
| 883 | 883 | ->setMaxResults(1) |
@@ -895,14 +895,14 @@ discard block |
||
| 895 | 895 | if (empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { |
| 896 | 896 | // Check if this table is allowed for translation. |
| 897 | 897 | if (in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'])) { |
| 898 | - $additionalWhere = $queryBuilder->expr()->in($table . '.sys_language_uid', [-1, 0]); |
|
| 898 | + $additionalWhere = $queryBuilder->expr()->in($table.'.sys_language_uid', [-1, 0]); |
|
| 899 | 899 | if ($GLOBALS['TSFE']->sys_language_content > 0) { |
| 900 | 900 | $additionalWhere = $queryBuilder->expr()->andX( |
| 901 | 901 | $queryBuilder->expr()->orX( |
| 902 | - $queryBuilder->expr()->in($table . '.sys_language_uid', [-1, 0]), |
|
| 903 | - $queryBuilder->expr()->eq($table . '.sys_language_uid', intval($GLOBALS['TSFE']->sys_language_content)) |
|
| 902 | + $queryBuilder->expr()->in($table.'.sys_language_uid', [-1, 0]), |
|
| 903 | + $queryBuilder->expr()->eq($table.'.sys_language_uid', intval($GLOBALS['TSFE']->sys_language_content)) |
|
| 904 | 904 | ), |
| 905 | - $queryBuilder->expr()->eq($table . '.l18n_parent', 0) |
|
| 905 | + $queryBuilder->expr()->eq($table.'.l18n_parent', 0) |
|
| 906 | 906 | ); |
| 907 | 907 | } |
| 908 | 908 | |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | ->select('*') |
| 912 | 912 | ->from($table) |
| 913 | 913 | ->where( |
| 914 | - $queryBuilder->expr()->eq($table . '.pid', $pid), |
|
| 914 | + $queryBuilder->expr()->eq($table.'.pid', $pid), |
|
| 915 | 915 | $additionalWhere, |
| 916 | 916 | self::whereExpression($table, true) |
| 917 | 917 | ) |
@@ -929,10 +929,10 @@ discard block |
||
| 929 | 929 | } |
| 930 | 930 | } |
| 931 | 931 | } else { |
| 932 | - self::log('No translation with PID ' . $pid . ' available in table "' . $table . '" or translation not accessible', LOG_SEVERITY_NOTICE); |
|
| 932 | + self::log('No translation with PID '.$pid.' available in table "'.$table.'" or translation not accessible', LOG_SEVERITY_NOTICE); |
|
| 933 | 933 | } |
| 934 | 934 | } else { |
| 935 | - self::log('No translations available for table "' . $table . '"', LOG_SEVERITY_WARNING); |
|
| 935 | + self::log('No translations available for table "'.$table.'"', LOG_SEVERITY_WARNING); |
|
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | |
@@ -971,9 +971,9 @@ discard block |
||
| 971 | 971 | return GeneralUtility::makeInstance(ConnectionPool::class) |
| 972 | 972 | ->getQueryBuilderForTable($table) |
| 973 | 973 | ->expr() |
| 974 | - ->eq($table . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete'], 0); |
|
| 974 | + ->eq($table.'.'.$GLOBALS['TCA'][$table]['ctrl']['delete'], 0); |
|
| 975 | 975 | } else { |
| 976 | - self::log('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', LOG_SEVERITY_ERROR); |
|
| 976 | + self::log('Unexpected TYPO3_MODE "'.\TYPO3_MODE.'"', LOG_SEVERITY_ERROR); |
|
| 977 | 977 | return '1=-1'; |
| 978 | 978 | } |
| 979 | 979 | } |
@@ -25,8 +25,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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)) |
@@ -207,8 +203,7 @@ discard block |
||
| 207 | 203 | * @return void |
| 208 | 204 | */ |
| 209 | 205 | //TODO: find better way to handle logger in static class |
| 210 | - public static function log($message, $severity = 0) |
|
| 211 | - { |
|
| 206 | + public static function log($message, $severity = 0) { |
|
| 212 | 207 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); |
| 213 | 208 | |
| 214 | 209 | switch ($severity) { |
@@ -238,8 +233,7 @@ discard block |
||
| 238 | 233 | * |
| 239 | 234 | * @return mixed Hashed string or false on error |
| 240 | 235 | */ |
| 241 | - public static function digest($string) |
|
| 242 | - { |
|
| 236 | + public static function digest($string) { |
|
| 243 | 237 | if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(true))) { |
| 244 | 238 | self::log('OpenSSL library doesn\'t support hash algorithm', LOG_SEVERITY_ERROR); |
| 245 | 239 | return false; |
@@ -258,8 +252,7 @@ discard block |
||
| 258 | 252 | * |
| 259 | 253 | * @return mixed Encrypted string or false on error |
| 260 | 254 | */ |
| 261 | - public static function encrypt($string) |
|
| 262 | - { |
|
| 255 | + public static function encrypt($string) { |
|
| 263 | 256 | if ( |
| 264 | 257 | !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
| 265 | 258 | || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
@@ -292,8 +285,7 @@ discard block |
||
| 292 | 285 | * |
| 293 | 286 | * @return string The unqualified class name |
| 294 | 287 | */ |
| 295 | - public static function getUnqualifiedClassName($qualifiedClassname) |
|
| 296 | - { |
|
| 288 | + public static function getUnqualifiedClassName($qualifiedClassname) { |
|
| 297 | 289 | $nameParts = explode('\\', $qualifiedClassname); |
| 298 | 290 | return end($nameParts); |
| 299 | 291 | } |
@@ -307,8 +299,7 @@ discard block |
||
| 307 | 299 | * |
| 308 | 300 | * @return string The cleaned up string |
| 309 | 301 | */ |
| 310 | - public static function getCleanString($string) |
|
| 311 | - { |
|
| 302 | + public static function getCleanString($string) { |
|
| 312 | 303 | // Convert to lowercase. |
| 313 | 304 | $string = strtolower($string); |
| 314 | 305 | // Remove non-alphanumeric characters. |
@@ -329,8 +320,7 @@ discard block |
||
| 329 | 320 | * |
| 330 | 321 | * @return array Array of hook objects for the class |
| 331 | 322 | */ |
| 332 | - public static function getHookObjects($scriptRelPath) |
|
| 333 | - { |
|
| 323 | + public static function getHookObjects($scriptRelPath) { |
|
| 334 | 324 | $hookObjects = []; |
| 335 | 325 | if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) { |
| 336 | 326 | foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) { |
@@ -351,8 +341,7 @@ discard block |
||
| 351 | 341 | * |
| 352 | 342 | * @return string "index_name" for the given UID |
| 353 | 343 | */ |
| 354 | - public static function getIndexNameFromUid($uid, $table, $pid = -1) |
|
| 355 | - { |
|
| 344 | + public static function getIndexNameFromUid($uid, $table, $pid = -1) { |
|
| 356 | 345 | // Sanitize input. |
| 357 | 346 | $uid = max(intval($uid), 0); |
| 358 | 347 | if ( |
@@ -404,8 +393,7 @@ discard block |
||
| 404 | 393 | * |
| 405 | 394 | * @return string "label" for the given UID |
| 406 | 395 | */ |
| 407 | - public static function getLabelFromUid($uid, $table, $pid = -1) |
|
| 408 | - { |
|
| 396 | + public static function getLabelFromUid($uid, $table, $pid = -1) { |
|
| 409 | 397 | // Sanitize input. |
| 410 | 398 | $uid = max(intval($uid), 0); |
| 411 | 399 | if ( |
@@ -455,8 +443,7 @@ discard block |
||
| 455 | 443 | * |
| 456 | 444 | * @return string Localized full name of language or unchanged input |
| 457 | 445 | */ |
| 458 | - public static function getLanguageName($code) |
|
| 459 | - { |
|
| 446 | + public static function getLanguageName($code) { |
|
| 460 | 447 | // Analyze code and set appropriate ISO table. |
| 461 | 448 | $isoCode = strtolower(trim($code)); |
| 462 | 449 | if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
@@ -501,8 +488,7 @@ discard block |
||
| 501 | 488 | * |
| 502 | 489 | * @return string The translated string or the given key on failure |
| 503 | 490 | */ |
| 504 | - public static function getMessage($key, $hsc = false, $default = '') |
|
| 505 | - { |
|
| 491 | + public static function getMessage($key, $hsc = false, $default = '') { |
|
| 506 | 492 | // Set initial output to default value. |
| 507 | 493 | $translated = (string) $default; |
| 508 | 494 | // Load common messages file. |
@@ -544,8 +530,7 @@ discard block |
||
| 544 | 530 | * |
| 545 | 531 | * @return string "uid" for the given index_name |
| 546 | 532 | */ |
| 547 | - public static function getUidFromIndexName($index_name, $table, $pid = -1) |
|
| 548 | - { |
|
| 533 | + public static function getUidFromIndexName($index_name, $table, $pid = -1) { |
|
| 549 | 534 | if ( |
| 550 | 535 | !$index_name |
| 551 | 536 | || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores']) |
@@ -596,8 +581,7 @@ discard block |
||
| 596 | 581 | * |
| 597 | 582 | * @return string Uniform Resource Name as string |
| 598 | 583 | */ |
| 599 | - public static function getURN($base, $id) |
|
| 600 | - { |
|
| 584 | + public static function getURN($base, $id) { |
|
| 601 | 585 | $concordance = [ |
| 602 | 586 | '0' => 1, |
| 603 | 587 | '1' => 2, |
@@ -664,8 +648,7 @@ discard block |
||
| 664 | 648 | * |
| 665 | 649 | * @return bool Is $id a valid PPN? |
| 666 | 650 | */ |
| 667 | - public static function isPPN($id) |
|
| 668 | - { |
|
| 651 | + public static function isPPN($id) { |
|
| 669 | 652 | return self::checkIdentifier($id, 'PPN'); |
| 670 | 653 | } |
| 671 | 654 | |
@@ -678,8 +661,7 @@ discard block |
||
| 678 | 661 | * |
| 679 | 662 | * @return mixed Session value for given key or null on failure |
| 680 | 663 | */ |
| 681 | - public static function loadFromSession($key) |
|
| 682 | - { |
|
| 664 | + public static function loadFromSession($key) { |
|
| 683 | 665 | // Cast to string for security reasons. |
| 684 | 666 | $key = (string) $key; |
| 685 | 667 | if (!$key) { |
@@ -711,8 +693,7 @@ discard block |
||
| 711 | 693 | * |
| 712 | 694 | * @return array Merged array |
| 713 | 695 | */ |
| 714 | - public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) |
|
| 715 | - { |
|
| 696 | + public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) { |
|
| 716 | 697 | \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature); |
| 717 | 698 | return $original; |
| 718 | 699 | } |
@@ -729,8 +710,7 @@ discard block |
||
| 729 | 710 | * |
| 730 | 711 | * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
| 731 | 712 | */ |
| 732 | - public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false) |
|
| 733 | - { |
|
| 713 | + public static function processDBasAdmin(array $data = [], array $cmd = [], $reverseOrder = false, $cmdFirst = false) { |
|
| 734 | 714 | if ( |
| 735 | 715 | \TYPO3_MODE === 'BE' |
| 736 | 716 | && $GLOBALS['BE_USER']->isAdmin() |
@@ -776,8 +756,7 @@ discard block |
||
| 776 | 756 | * |
| 777 | 757 | * @return string All flash messages in the queue rendered as HTML. |
| 778 | 758 | */ |
| 779 | - public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') |
|
| 780 | - { |
|
| 759 | + public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') { |
|
| 781 | 760 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
| 782 | 761 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
| 783 | 762 | $flashMessages = $flashMessageQueue->getAllMessagesAndFlush(); |
@@ -796,8 +775,7 @@ discard block |
||
| 796 | 775 | * |
| 797 | 776 | * @return bool true on success, false on failure |
| 798 | 777 | */ |
| 799 | - public static function saveToSession($value, $key) |
|
| 800 | - { |
|
| 778 | + public static function saveToSession($value, $key) { |
|
| 801 | 779 | // Cast to string for security reasons. |
| 802 | 780 | $key = (string) $key; |
| 803 | 781 | if (!$key) { |
@@ -829,8 +807,7 @@ discard block |
||
| 829 | 807 | * |
| 830 | 808 | * @return string Localized label for $index_name |
| 831 | 809 | */ |
| 832 | - public static function translate($index_name, $table, $pid) |
|
| 833 | - { |
|
| 810 | + public static function translate($index_name, $table, $pid) { |
|
| 834 | 811 | // Load labels into static variable for future use. |
| 835 | 812 | static $labels = []; |
| 836 | 813 | // Sanitize input. |
@@ -953,8 +930,7 @@ discard block |
||
| 953 | 930 | * |
| 954 | 931 | * @return string Additional WHERE expression |
| 955 | 932 | */ |
| 956 | - public static function whereExpression($table, $showHidden = false) |
|
| 957 | - { |
|
| 933 | + public static function whereExpression($table, $showHidden = false) { |
|
| 958 | 934 | if (\TYPO3_MODE === 'FE') { |
| 959 | 935 | // Should we ignore the record's hidden flag? |
| 960 | 936 | $ignoreHide = 0; |
@@ -983,8 +959,7 @@ discard block |
||
| 983 | 959 | * |
| 984 | 960 | * @access private |
| 985 | 961 | */ |
| 986 | - private function __construct() |
|
| 987 | - { |
|
| 962 | + private function __construct() { |
|
| 988 | 963 | // This is a static class, thus no instances should be created. |
| 989 | 964 | } |
| 990 | 965 | } |
@@ -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 | |
@@ -788,8 +771,7 @@ discard block |
||
| 788 | 771 | * {@inheritDoc} |
| 789 | 772 | * @see Document::getRawText() |
| 790 | 773 | */ |
| 791 | - public function getRawText($id) |
|
| 792 | - { |
|
| 774 | + public function getRawText($id) { |
|
| 793 | 775 | $rawText = ''; |
| 794 | 776 | // Get text from raw text array if available. |
| 795 | 777 | if (!empty($this->rawTextArray[$id])) { |
@@ -846,8 +828,7 @@ discard block |
||
| 846 | 828 | * |
| 847 | 829 | * @return IiifResourceInterface |
| 848 | 830 | */ |
| 849 | - public function getIiif() |
|
| 850 | - { |
|
| 831 | + public function getIiif() { |
|
| 851 | 832 | return $this->iiif; |
| 852 | 833 | } |
| 853 | 834 | |
@@ -855,8 +836,7 @@ discard block |
||
| 855 | 836 | * {@inheritDoc} |
| 856 | 837 | * @see Document::init() |
| 857 | 838 | */ |
| 858 | - protected function init() |
|
| 859 | - { |
|
| 839 | + protected function init() { |
|
| 860 | 840 | // Nothing to do here, at the moment |
| 861 | 841 | } |
| 862 | 842 | |
@@ -864,8 +844,7 @@ discard block |
||
| 864 | 844 | * {@inheritDoc} |
| 865 | 845 | * @see Document::loadLocation() |
| 866 | 846 | */ |
| 867 | - protected function loadLocation($location) |
|
| 868 | - { |
|
| 847 | + protected function loadLocation($location) { |
|
| 869 | 848 | $fileResource = GeneralUtility::getUrl($location); |
| 870 | 849 | if ($fileResource !== false) { |
| 871 | 850 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -888,8 +867,7 @@ discard block |
||
| 888 | 867 | * {@inheritDoc} |
| 889 | 868 | * @see \Kitodo\Dlf\Common\Document::prepareMetadataArray() |
| 890 | 869 | */ |
| 891 | - protected function prepareMetadataArray($cPid) |
|
| 892 | - { |
|
| 870 | + protected function prepareMetadataArray($cPid) { |
|
| 893 | 871 | $id = $this->iiif->getId(); |
| 894 | 872 | $this->metadataArray[(string) $id] = $this->getMetadata((string) $id, $cPid); |
| 895 | 873 | } |
@@ -898,8 +876,7 @@ discard block |
||
| 898 | 876 | * {@inheritDoc} |
| 899 | 877 | * @see Document::setPreloadedDocument() |
| 900 | 878 | */ |
| 901 | - protected function setPreloadedDocument($preloadedDocument) |
|
| 902 | - { |
|
| 879 | + protected function setPreloadedDocument($preloadedDocument) { |
|
| 903 | 880 | if ($preloadedDocument instanceof ManifestInterface) { |
| 904 | 881 | $this->iiif = $preloadedDocument; |
| 905 | 882 | return true; |
@@ -911,8 +888,7 @@ discard block |
||
| 911 | 888 | * {@inheritDoc} |
| 912 | 889 | * @see Document::ensureHasFulltextIsSet() |
| 913 | 890 | */ |
| 914 | - protected function ensureHasFulltextIsSet() |
|
| 915 | - { |
|
| 891 | + protected function ensureHasFulltextIsSet() { |
|
| 916 | 892 | /* |
| 917 | 893 | * TODO Check annotations and annotation lists of canvas for ALTO documents. |
| 918 | 894 | * Example: |
@@ -958,8 +934,7 @@ discard block |
||
| 958 | 934 | * {@inheritDoc} |
| 959 | 935 | * @see \Kitodo\Dlf\Common\Document::_getThumbnail() |
| 960 | 936 | */ |
| 961 | - protected function _getThumbnail($forceReload = false) |
|
| 962 | - { |
|
| 937 | + protected function _getThumbnail($forceReload = false) { |
|
| 963 | 938 | return $this->iiif->getThumbnailUrl(); |
| 964 | 939 | } |
| 965 | 940 | |
@@ -967,8 +942,7 @@ discard block |
||
| 967 | 942 | * {@inheritDoc} |
| 968 | 943 | * @see \Kitodo\Dlf\Common\Document::_getToplevelId() |
| 969 | 944 | */ |
| 970 | - protected function _getToplevelId() |
|
| 971 | - { |
|
| 945 | + protected function _getToplevelId() { |
|
| 972 | 946 | if (empty($this->toplevelId)) { |
| 973 | 947 | if (isset($this->iiif)) { |
| 974 | 948 | $this->toplevelId = $this->iiif->getId(); |
@@ -985,8 +959,7 @@ discard block |
||
| 985 | 959 | * |
| 986 | 960 | * @return void |
| 987 | 961 | */ |
| 988 | - public function __wakeup() |
|
| 989 | - { |
|
| 962 | + public function __wakeup() { |
|
| 990 | 963 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 991 | 964 | IiifHelper::setUrlReader(IiifUrlReader::getInstance()); |
| 992 | 965 | IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']); |
@@ -1005,8 +978,7 @@ discard block |
||
| 1005 | 978 | * |
| 1006 | 979 | * @return string[] |
| 1007 | 980 | */ |
| 1008 | - public function __sleep() |
|
| 1009 | - { |
|
| 981 | + public function __sleep() { |
|
| 1010 | 982 | // TODO implement serializiation in IIIF library |
| 1011 | 983 | $jsonArray = $this->iiif->getOriginalJsonArray(); |
| 1012 | 984 | $this->asJson = json_encode($jsonArray); |
@@ -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::getRawText() |
| 671 | 662 | */ |
| 672 | - public function getRawText($id) |
|
| 673 | - { |
|
| 663 | + public function getRawText($id) { |
|
| 674 | 664 | $rawText = ''; |
| 675 | 665 | // Get text from raw text array if available. |
| 676 | 666 | if (!empty($this->rawTextArray[$id])) { |
@@ -688,8 +678,7 @@ discard block |
||
| 688 | 678 | * {@inheritDoc} |
| 689 | 679 | * @see Document::getStructureDepth() |
| 690 | 680 | */ |
| 691 | - public function getStructureDepth($logId) |
|
| 692 | - { |
|
| 681 | + public function getStructureDepth($logId) { |
|
| 693 | 682 | $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $logId . '"]/ancestor::*'); |
| 694 | 683 | if (!empty($ancestors)) { |
| 695 | 684 | return count($ancestors); |
@@ -702,8 +691,7 @@ discard block |
||
| 702 | 691 | * {@inheritDoc} |
| 703 | 692 | * @see \Kitodo\Dlf\Common\Document::init() |
| 704 | 693 | */ |
| 705 | - protected function init() |
|
| 706 | - { |
|
| 694 | + protected function init() { |
|
| 707 | 695 | // Get METS node from XML file. |
| 708 | 696 | $this->registerNamespaces($this->xml); |
| 709 | 697 | $mets = $this->xml->xpath('//mets:mets'); |
@@ -720,8 +708,7 @@ discard block |
||
| 720 | 708 | * {@inheritDoc} |
| 721 | 709 | * @see \Kitodo\Dlf\Common\Document::loadLocation() |
| 722 | 710 | */ |
| 723 | - protected function loadLocation($location) |
|
| 724 | - { |
|
| 711 | + protected function loadLocation($location) { |
|
| 725 | 712 | $fileResource = GeneralUtility::getUrl($location); |
| 726 | 713 | if ($fileResource !== false) { |
| 727 | 714 | // Turn off libxml's error logging. |
@@ -748,8 +735,7 @@ discard block |
||
| 748 | 735 | * {@inheritDoc} |
| 749 | 736 | * @see \Kitodo\Dlf\Common\Document::ensureHasFulltextIsSet() |
| 750 | 737 | */ |
| 751 | - protected function ensureHasFulltextIsSet() |
|
| 752 | - { |
|
| 738 | + protected function ensureHasFulltextIsSet() { |
|
| 753 | 739 | // Are the fileGrps already loaded? |
| 754 | 740 | if (!$this->fileGrpsLoaded) { |
| 755 | 741 | $this->_getFileGrps(); |
@@ -760,8 +746,7 @@ discard block |
||
| 760 | 746 | * {@inheritDoc} |
| 761 | 747 | * @see Document::getParentDocumentUid() |
| 762 | 748 | */ |
| 763 | - protected function getParentDocumentUidForSaving($pid, $core, $owner) |
|
| 764 | - { |
|
| 749 | + protected function getParentDocumentUidForSaving($pid, $core, $owner) { |
|
| 765 | 750 | $partof = 0; |
| 766 | 751 | // Get the closest ancestor of the current document which has a MPTR child. |
| 767 | 752 | $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $this->_getToplevelId() . '"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); |
@@ -784,8 +769,7 @@ discard block |
||
| 784 | 769 | * {@inheritDoc} |
| 785 | 770 | * @see Document::setPreloadedDocument() |
| 786 | 771 | */ |
| 787 | - protected function setPreloadedDocument($preloadedDocument) |
|
| 788 | - { |
|
| 772 | + protected function setPreloadedDocument($preloadedDocument) { |
|
| 789 | 773 | |
| 790 | 774 | if ($preloadedDocument instanceof \SimpleXMLElement) { |
| 791 | 775 | $this->xml = $preloadedDocument; |
@@ -798,8 +782,7 @@ discard block |
||
| 798 | 782 | * {@inheritDoc} |
| 799 | 783 | * @see Document::getDocument() |
| 800 | 784 | */ |
| 801 | - protected function getDocument() |
|
| 802 | - { |
|
| 785 | + protected function getDocument() { |
|
| 803 | 786 | return $this->mets; |
| 804 | 787 | } |
| 805 | 788 | |
@@ -810,8 +793,7 @@ discard block |
||
| 810 | 793 | * |
| 811 | 794 | * @return array Array of dmdSecs with their IDs as array key |
| 812 | 795 | */ |
| 813 | - protected function _getDmdSec() |
|
| 814 | - { |
|
| 796 | + protected function _getDmdSec() { |
|
| 815 | 797 | if (!$this->dmdSecLoaded) { |
| 816 | 798 | // Get available data formats. |
| 817 | 799 | $this->loadFormats(); |
@@ -849,8 +831,7 @@ discard block |
||
| 849 | 831 | * |
| 850 | 832 | * @return array Array of file use groups with file IDs |
| 851 | 833 | */ |
| 852 | - protected function _getFileGrps() |
|
| 853 | - { |
|
| 834 | + protected function _getFileGrps() { |
|
| 854 | 835 | if (!$this->fileGrpsLoaded) { |
| 855 | 836 | // Get configured USE attributes. |
| 856 | 837 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -895,8 +876,7 @@ discard block |
||
| 895 | 876 | * {@inheritDoc} |
| 896 | 877 | * @see \Kitodo\Dlf\Common\Document::prepareMetadataArray() |
| 897 | 878 | */ |
| 898 | - protected function prepareMetadataArray($cPid) |
|
| 899 | - { |
|
| 879 | + protected function prepareMetadataArray($cPid) { |
|
| 900 | 880 | $ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'); |
| 901 | 881 | // Get all logical structure nodes with metadata. |
| 902 | 882 | if (!empty($ids)) { |
@@ -914,8 +894,7 @@ discard block |
||
| 914 | 894 | * |
| 915 | 895 | * @return \SimpleXMLElement The XML's METS part as \SimpleXMLElement object |
| 916 | 896 | */ |
| 917 | - protected function _getMets() |
|
| 918 | - { |
|
| 897 | + protected function _getMets() { |
|
| 919 | 898 | return $this->mets; |
| 920 | 899 | } |
| 921 | 900 | |
@@ -923,8 +902,7 @@ discard block |
||
| 923 | 902 | * {@inheritDoc} |
| 924 | 903 | * @see \Kitodo\Dlf\Common\Document::_getPhysicalStructure() |
| 925 | 904 | */ |
| 926 | - protected function _getPhysicalStructure() |
|
| 927 | - { |
|
| 905 | + protected function _getPhysicalStructure() { |
|
| 928 | 906 | // Is there no physical structure array yet? |
| 929 | 907 | if (!$this->physicalStructureLoaded) { |
| 930 | 908 | // Does the document have a structMap node of type "PHYSICAL"? |
@@ -984,8 +962,7 @@ discard block |
||
| 984 | 962 | * {@inheritDoc} |
| 985 | 963 | * @see \Kitodo\Dlf\Common\Document::_getSmLinks() |
| 986 | 964 | */ |
| 987 | - protected function _getSmLinks() |
|
| 988 | - { |
|
| 965 | + protected function _getSmLinks() { |
|
| 989 | 966 | if (!$this->smLinksLoaded) { |
| 990 | 967 | $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink'); |
| 991 | 968 | if (!empty($smLinks)) { |
@@ -1003,8 +980,7 @@ discard block |
||
| 1003 | 980 | * {@inheritDoc} |
| 1004 | 981 | * @see \Kitodo\Dlf\Common\Document::_getThumbnail() |
| 1005 | 982 | */ |
| 1006 | - protected function _getThumbnail($forceReload = false) |
|
| 1007 | - { |
|
| 983 | + protected function _getThumbnail($forceReload = false) { |
|
| 1008 | 984 | if ( |
| 1009 | 985 | !$this->thumbnailLoaded |
| 1010 | 986 | || $forceReload |
@@ -1083,8 +1059,7 @@ discard block |
||
| 1083 | 1059 | * {@inheritDoc} |
| 1084 | 1060 | * @see \Kitodo\Dlf\Common\Document::_getToplevelId() |
| 1085 | 1061 | */ |
| 1086 | - protected function _getToplevelId() |
|
| 1087 | - { |
|
| 1062 | + protected function _getToplevelId() { |
|
| 1088 | 1063 | if (empty($this->toplevelId)) { |
| 1089 | 1064 | // Get all logical structure nodes with metadata, but without associated METS-Pointers. |
| 1090 | 1065 | $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'); |
@@ -1116,8 +1091,7 @@ discard block |
||
| 1116 | 1091 | * |
| 1117 | 1092 | * @return array Properties to be serialized |
| 1118 | 1093 | */ |
| 1119 | - public function __sleep() |
|
| 1120 | - { |
|
| 1094 | + public function __sleep() { |
|
| 1121 | 1095 | // \SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization |
| 1122 | 1096 | $this->asXML = $this->xml->asXML(); |
| 1123 | 1097 | return ['uid', 'pid', 'recordId', 'parentId', 'asXML']; |
@@ -1130,8 +1104,7 @@ discard block |
||
| 1130 | 1104 | * |
| 1131 | 1105 | * @return string String representing the METS object |
| 1132 | 1106 | */ |
| 1133 | - public function __toString() |
|
| 1134 | - { |
|
| 1107 | + public function __toString() { |
|
| 1135 | 1108 | $xml = new \DOMDocument('1.0', 'utf-8'); |
| 1136 | 1109 | $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); |
| 1137 | 1110 | $xml->formatOutput = true; |
@@ -1146,8 +1119,7 @@ discard block |
||
| 1146 | 1119 | * |
| 1147 | 1120 | * @return void |
| 1148 | 1121 | */ |
| 1149 | - public function __wakeup() |
|
| 1150 | - { |
|
| 1122 | + public function __wakeup() { |
|
| 1151 | 1123 | // Turn off libxml's error logging. |
| 1152 | 1124 | $libxmlErrors = libxml_use_internal_errors(true); |
| 1153 | 1125 | // Reload XML from string. |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @var bool |
| 75 | 75 | * @access protected |
| 76 | 76 | */ |
| 77 | - protected $dmdSecLoaded = false; |
|
| 77 | + protected $dmdSecLoaded = FALSE; |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * The extension key |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @var bool |
| 101 | 101 | * @access protected |
| 102 | 102 | */ |
| 103 | - protected $fileGrpsLoaded = false; |
|
| 103 | + protected $fileGrpsLoaded = FALSE; |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * This holds the XML file's METS part as \SimpleXMLElement object |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']); |
| 176 | 176 | IiifHelper::setMaxThumbnailWidth($conf['iiifThumbnailWidth']); |
| 177 | 177 | $service = IiifHelper::loadIiifResource($fileLocation); |
| 178 | - if ($service !== null && $service instanceof AbstractImageService) { |
|
| 178 | + if ($service !== NULL && $service instanceof AbstractImageService) { |
|
| 179 | 179 | return $service->getImageUrl(); |
| 180 | 180 | } |
| 181 | 181 | } elseif ($fileMimeType === 'application/vnd.netfpx') { |
| 182 | - $baseURL = $fileLocation . (strpos($fileLocation, '?') === false ? '?' : ''); |
|
| 182 | + $baseURL = $fileLocation . (strpos($fileLocation, '?') === FALSE ? '?' : ''); |
|
| 183 | 183 | // TODO CVT is an optional IIP server capability; in theory, capabilities should be determined in the object request with '&obj=IIP-server' |
| 184 | 184 | return $baseURL . '&CVT=jpeg'; |
| 185 | 185 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * {@inheritDoc} |
| 227 | 227 | * @see \Kitodo\Dlf\Common\Document::getLogicalStructure() |
| 228 | 228 | */ |
| 229 | - public function getLogicalStructure($id, $recursive = false) |
|
| 229 | + public function getLogicalStructure($id, $recursive = FALSE) |
|
| 230 | 230 | { |
| 231 | 231 | $details = []; |
| 232 | 232 | // Is the requested logical unit already loaded? |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
| 269 | 269 | */ |
| 270 | - protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) |
|
| 270 | + protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = FALSE) |
|
| 271 | 271 | { |
| 272 | 272 | // Get attributes. |
| 273 | 273 | foreach ($structure->attributes() as $attribute => $value) { |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | && array_key_exists($details['id'], $this->smLinks['l2p']) |
| 313 | 313 | ) { |
| 314 | 314 | // Link logical structure to the first corresponding physical page/track. |
| 315 | - $details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, true)), 1); |
|
| 315 | + $details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, TRUE)), 1); |
|
| 316 | 316 | $fileGrpsThumb = GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']); |
| 317 | 317 | while ($fileGrpThumb = array_shift($fileGrpsThumb)) { |
| 318 | 318 | if (!empty($this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$fileGrpThumb])) { |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $details['children'] = []; |
| 357 | 357 | foreach ($structure->children('http://www.loc.gov/METS/')->div as $child) { |
| 358 | 358 | // Repeat for all children. |
| 359 | - $details['children'][] = $this->getLogicalStructureInfo($child, true); |
|
| 359 | + $details['children'][] = $this->getLogicalStructureInfo($child, TRUE); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | return $details; |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | if (!empty($dmdIds)) { |
| 426 | 426 | // Handle multiple DMDIDs separately. |
| 427 | 427 | $dmdIds = explode(' ', $dmdIds); |
| 428 | - $hasSupportedMetadata = false; |
|
| 428 | + $hasSupportedMetadata = FALSE; |
|
| 429 | 429 | } else { |
| 430 | 430 | // There is no dmdSec for this structure node. |
| 431 | 431 | return []; |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | $metadata['owner'][0] = $resArray['owner']; |
| 655 | 655 | } |
| 656 | 656 | // Extract metadata only from first supported dmdSec. |
| 657 | - $hasSupportedMetadata = true; |
|
| 657 | + $hasSupportedMetadata = TRUE; |
|
| 658 | 658 | break; |
| 659 | 659 | } |
| 660 | 660 | if ($hasSupportedMetadata) { |
@@ -723,11 +723,11 @@ discard block |
||
| 723 | 723 | protected function loadLocation($location) |
| 724 | 724 | { |
| 725 | 725 | $fileResource = GeneralUtility::getUrl($location); |
| 726 | - if ($fileResource !== false) { |
|
| 726 | + if ($fileResource !== FALSE) { |
|
| 727 | 727 | // Turn off libxml's error logging. |
| 728 | - $libxmlErrors = libxml_use_internal_errors(true); |
|
| 728 | + $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
| 729 | 729 | // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept |
| 730 | - $previousValueOfEntityLoader = libxml_disable_entity_loader(true); |
|
| 730 | + $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE); |
|
| 731 | 731 | // Load XML from file. |
| 732 | 732 | $xml = simplexml_load_string($fileResource); |
| 733 | 733 | // reset entity loader setting |
@@ -735,13 +735,13 @@ discard block |
||
| 735 | 735 | // Reset libxml's error logging. |
| 736 | 736 | libxml_use_internal_errors($libxmlErrors); |
| 737 | 737 | // Set some basic properties. |
| 738 | - if ($xml !== false) { |
|
| 738 | + if ($xml !== FALSE) { |
|
| 739 | 739 | $this->xml = $xml; |
| 740 | - return true; |
|
| 740 | + return TRUE; |
|
| 741 | 741 | } |
| 742 | 742 | } |
| 743 | 743 | $this->logger->error('Could not load XML file from "' . $location . '"'); |
| 744 | - return false; |
|
| 744 | + return FALSE; |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | /** |
@@ -789,9 +789,9 @@ discard block |
||
| 789 | 789 | |
| 790 | 790 | if ($preloadedDocument instanceof \SimpleXMLElement) { |
| 791 | 791 | $this->xml = $preloadedDocument; |
| 792 | - return true; |
|
| 792 | + return TRUE; |
|
| 793 | 793 | } |
| 794 | - return false; |
|
| 794 | + return FALSE; |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | /** |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | } |
| 839 | 839 | } |
| 840 | - $this->dmdSecLoaded = true; |
|
| 840 | + $this->dmdSecLoaded = TRUE; |
|
| 841 | 841 | } |
| 842 | 842 | return $this->dmdSec; |
| 843 | 843 | } |
@@ -884,9 +884,9 @@ discard block |
||
| 884 | 884 | !empty($extConf['fileGrpFulltext']) |
| 885 | 885 | && array_intersect(GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']), $this->fileGrps) !== [] |
| 886 | 886 | ) { |
| 887 | - $this->hasFulltext = true; |
|
| 887 | + $this->hasFulltext = TRUE; |
|
| 888 | 888 | } |
| 889 | - $this->fileGrpsLoaded = true; |
|
| 889 | + $this->fileGrpsLoaded = TRUE; |
|
| 890 | 890 | } |
| 891 | 891 | return $this->fileGrps; |
| 892 | 892 | } |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | $this->physicalStructure = array_merge($physSeq, $elements); |
| 976 | 976 | } |
| 977 | 977 | } |
| 978 | - $this->physicalStructureLoaded = true; |
|
| 978 | + $this->physicalStructureLoaded = TRUE; |
|
| 979 | 979 | } |
| 980 | 980 | return $this->physicalStructure; |
| 981 | 981 | } |
@@ -994,7 +994,7 @@ discard block |
||
| 994 | 994 | $this->smLinks['p2l'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->to][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->from; |
| 995 | 995 | } |
| 996 | 996 | } |
| 997 | - $this->smLinksLoaded = true; |
|
| 997 | + $this->smLinksLoaded = TRUE; |
|
| 998 | 998 | } |
| 999 | 999 | return $this->smLinks; |
| 1000 | 1000 | } |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | * {@inheritDoc} |
| 1004 | 1004 | * @see \Kitodo\Dlf\Common\Document::_getThumbnail() |
| 1005 | 1005 | */ |
| 1006 | - protected function _getThumbnail($forceReload = false) |
|
| 1006 | + protected function _getThumbnail($forceReload = FALSE) |
|
| 1007 | 1007 | { |
| 1008 | 1008 | if ( |
| 1009 | 1009 | !$this->thumbnailLoaded |
@@ -1013,14 +1013,14 @@ discard block |
||
| 1013 | 1013 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
| 1014 | 1014 | if (!$cPid) { |
| 1015 | 1015 | $this->logger->error('Invalid PID ' . $cPid . ' for structure definitions'); |
| 1016 | - $this->thumbnailLoaded = true; |
|
| 1016 | + $this->thumbnailLoaded = TRUE; |
|
| 1017 | 1017 | return $this->thumbnail; |
| 1018 | 1018 | } |
| 1019 | 1019 | // Load extension configuration. |
| 1020 | 1020 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
| 1021 | 1021 | if (empty($extConf['fileGrpThumbs'])) { |
| 1022 | 1022 | $this->logger->warning('No fileGrp for thumbnails specified'); |
| 1023 | - $this->thumbnailLoaded = true; |
|
| 1023 | + $this->thumbnailLoaded = TRUE; |
|
| 1024 | 1024 | return $this->thumbnail; |
| 1025 | 1025 | } |
| 1026 | 1026 | $strctId = $this->_getToplevelId(); |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | } else { |
| 1075 | 1075 | $this->logger->error('No structure of type "' . $metadata['type'][0] . '" found in database'); |
| 1076 | 1076 | } |
| 1077 | - $this->thumbnailLoaded = true; |
|
| 1077 | + $this->thumbnailLoaded = TRUE; |
|
| 1078 | 1078 | } |
| 1079 | 1079 | return $this->thumbnail; |
| 1080 | 1080 | } |
@@ -1133,8 +1133,8 @@ discard block |
||
| 1133 | 1133 | public function __toString() |
| 1134 | 1134 | { |
| 1135 | 1135 | $xml = new \DOMDocument('1.0', 'utf-8'); |
| 1136 | - $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); |
|
| 1137 | - $xml->formatOutput = true; |
|
| 1136 | + $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), TRUE)); |
|
| 1137 | + $xml->formatOutput = TRUE; |
|
| 1138 | 1138 | return $xml->saveXML(); |
| 1139 | 1139 | } |
| 1140 | 1140 | |
@@ -1149,12 +1149,12 @@ discard block |
||
| 1149 | 1149 | public function __wakeup() |
| 1150 | 1150 | { |
| 1151 | 1151 | // Turn off libxml's error logging. |
| 1152 | - $libxmlErrors = libxml_use_internal_errors(true); |
|
| 1152 | + $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
| 1153 | 1153 | // Reload XML from string. |
| 1154 | 1154 | $xml = @simplexml_load_string($this->asXML); |
| 1155 | 1155 | // Reset libxml's error logging. |
| 1156 | 1156 | libxml_use_internal_errors($libxmlErrors); |
| 1157 | - if ($xml !== false) { |
|
| 1157 | + if ($xml !== FALSE) { |
|
| 1158 | 1158 | $this->asXML = ''; |
| 1159 | 1159 | $this->xml = $xml; |
| 1160 | 1160 | // Rebuild the unserializable properties. |