We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -20,8 +20,7 @@ discard block |
||
20 | 20 | * @subpackage dlf |
21 | 21 | * @access public |
22 | 22 | */ |
23 | -class Alto implements \Kitodo\Dlf\Common\FulltextInterface |
|
24 | -{ |
|
23 | +class Alto implements \Kitodo\Dlf\Common\FulltextInterface { |
|
25 | 24 | /** |
26 | 25 | * This extracts the fulltext data from ALTO XML |
27 | 26 | * |
@@ -31,8 +30,7 @@ discard block |
||
31 | 30 | * |
32 | 31 | * @return string The raw unformatted fulltext |
33 | 32 | */ |
34 | - public function getRawText(\SimpleXMLElement $xml) |
|
35 | - { |
|
33 | + public function getRawText(\SimpleXMLElement $xml) { |
|
36 | 34 | $xml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#'); |
37 | 35 | // Get all (presumed) words of the text. |
38 | 36 | $words = $xml->xpath('./alto:Layout/alto:Page/alto:PrintSpace//alto:TextBlock/alto:TextLine/alto:String/@CONTENT'); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $startingPoint = MathUtility::forceIntegerInRange((int) $input->getOption('pid'), 0); |
84 | 84 | } |
85 | 85 | if ($startingPoint == 0) { |
86 | - $io->error('ERROR: No valid PID (' . $startingPoint . ') given.'); |
|
86 | + $io->error('ERROR: No valid PID ('.$startingPoint.') given.'); |
|
87 | 87 | exit(1); |
88 | 88 | } |
89 | 89 | |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | if (empty($solrCoreUid) || !in_array($solrCoreUid, $allSolrCores)) { |
100 | 100 | $output_solrCores = []; |
101 | 101 | foreach ($allSolrCores as $index_name => $uid) { |
102 | - $output_solrCores[] = $uid . ' : ' . $index_name; |
|
102 | + $output_solrCores[] = $uid.' : '.$index_name; |
|
103 | 103 | } |
104 | 104 | if (empty($output_solrCores)) { |
105 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. No valid cores found on PID ' . $startingPoint . ".\n"); |
|
105 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. No valid cores found on PID '.$startingPoint.".\n"); |
|
106 | 106 | exit(1); |
107 | 107 | } else { |
108 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (<uid>:<index_name>):\n" . implode("\n", $output_solrCores) . "\n"); |
|
108 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. '."Valid cores are (<uid>:<index_name>):\n".implode("\n", $output_solrCores)."\n"); |
|
109 | 109 | exit(1); |
110 | 110 | } |
111 | 111 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | !MathUtility::canBeInterpretedAsInteger($input->getOption('doc')) |
119 | 119 | && !GeneralUtility::isValidUrl($input->getOption('doc')) |
120 | 120 | ) { |
121 | - $io->error('ERROR: "' . $input->getOption('doc') . '" is not a valid document UID or URL for --doc|-d.'); |
|
121 | + $io->error('ERROR: "'.$input->getOption('doc').'" is not a valid document UID or URL for --doc|-d.'); |
|
122 | 122 | exit(1); |
123 | 123 | } |
124 | 124 | |
@@ -126,19 +126,19 @@ discard block |
||
126 | 126 | $doc = Document::getInstance($input->getOption('doc'), $startingPoint, TRUE); |
127 | 127 | if ($doc->ready) { |
128 | 128 | if ($dryRun) { |
129 | - $io->section('DRY RUN: Would index ' . $doc->uid . ' ("' . $doc->location . '") on UID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
|
129 | + $io->section('DRY RUN: Would index '.$doc->uid.' ("'.$doc->location.'") on UID '.$startingPoint.' and Solr core '.$solrCoreUid.'.'); |
|
130 | 130 | } else { |
131 | 131 | if ($io->isVerbose()) { |
132 | - $io->section('Indexing ' . $doc->uid . ' ("' . $doc->location . '") on UID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
|
132 | + $io->section('Indexing '.$doc->uid.' ("'.$doc->location.'") on UID '.$startingPoint.' and Solr core '.$solrCoreUid.'.'); |
|
133 | 133 | } |
134 | 134 | // ...and save it to the database... |
135 | 135 | if (!$doc->save($startingPoint, $solrCoreUid)) { |
136 | - $io->error('ERROR: Document "' . $input->getOption('doc') . '" not saved and indexed.'); |
|
136 | + $io->error('ERROR: Document "'.$input->getOption('doc').'" not saved and indexed.'); |
|
137 | 137 | exit(1); |
138 | 138 | } |
139 | 139 | } |
140 | 140 | } else { |
141 | - $io->error('ERROR: Document "' . $input->getOption('doc') . '" could not be loaded.'); |
|
141 | + $io->error('ERROR: Document "'.$input->getOption('doc').'" could not be loaded.'); |
|
142 | 142 | exit(1); |
143 | 143 | } |
144 | 144 |
@@ -26,13 +26,11 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * Index single document into database and Solr. |
28 | 28 | */ |
29 | -class IndexCommand extends Command |
|
30 | -{ |
|
29 | +class IndexCommand extends Command { |
|
31 | 30 | /** |
32 | 31 | * Configure the command by defining the name, options and arguments |
33 | 32 | */ |
34 | - public function configure() |
|
35 | - { |
|
33 | + public function configure() { |
|
36 | 34 | $this |
37 | 35 | ->setDescription('Index single document into database and Solr.') |
38 | 36 | ->setHelp('') |
@@ -68,8 +66,7 @@ discard block |
||
68 | 66 | * @param InputInterface $input |
69 | 67 | * @param OutputInterface $output |
70 | 68 | */ |
71 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
72 | - { |
|
69 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
73 | 70 | // Make sure the _cli_ user is loaded |
74 | 71 | Bootstrap::getInstance()->initializeBackendAuthentication(); |
75 | 72 |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $startingPoint = MathUtility::forceIntegerInRange((int) $input->getOption('pid'), 0); |
91 | 91 | } |
92 | 92 | if ($startingPoint == 0) { |
93 | - $io->error('ERROR: No valid PID (' . $startingPoint . ') given.'); |
|
93 | + $io->error('ERROR: No valid PID ('.$startingPoint.') given.'); |
|
94 | 94 | exit(1); |
95 | 95 | } |
96 | 96 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | if (empty($solrCoreUid) || !in_array($solrCoreUid, $allSolrCores)) { |
107 | 107 | $output_solrCores = []; |
108 | 108 | foreach ($allSolrCores as $index_name => $uid) { |
109 | - $output_solrCores[] = $uid . ' : ' . $index_name; |
|
109 | + $output_solrCores[] = $uid.' : '.$index_name; |
|
110 | 110 | } |
111 | 111 | if (empty($output_solrCores)) { |
112 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. No valid cores found on PID ' . $startingPoint . ".\n"); |
|
112 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. No valid cores found on PID '.$startingPoint.".\n"); |
|
113 | 113 | exit(1); |
114 | 114 | } else { |
115 | - $io->error('ERROR: No valid Solr core ("' . $input->getOption('solr') . '") given. ' . "Valid cores are (<uid>:<index_name>):\n" . implode("\n", $output_solrCores) . "\n"); |
|
115 | + $io->error('ERROR: No valid Solr core ("'.$input->getOption('solr').'") given. '."Valid cores are (<uid>:<index_name>):\n".implode("\n", $output_solrCores)."\n"); |
|
116 | 116 | exit(1); |
117 | 117 | } |
118 | 118 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } else { |
128 | 128 | // coll may be a single integer, a list of integer |
129 | 129 | if (empty(array_filter(GeneralUtility::intExplode(',', $input->getOption('coll'), TRUE)))) { |
130 | - $io->error('ERROR: "' . $input->getOption('coll') . '" is not a valid list of collection UIDs for --coll|-c.'); |
|
130 | + $io->error('ERROR: "'.$input->getOption('coll').'" is not a valid list of collection UIDs for --coll|-c.'); |
|
131 | 131 | exit(1); |
132 | 132 | } |
133 | 133 | $documents = $this->getDocumentsToProceed($input->getOption('coll'), $startingPoint); |
@@ -137,18 +137,18 @@ discard block |
||
137 | 137 | $doc = Document::getInstance($document, $startingPoint, TRUE); |
138 | 138 | if ($doc->ready) { |
139 | 139 | if ($dryRun) { |
140 | - $io->writeln('DRY RUN: Would index ' . $id . '/' . count($documents) . ' ' . $doc->uid . ' ("' . $doc->location . '") on UID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
|
140 | + $io->writeln('DRY RUN: Would index '.$id.'/'.count($documents).' '.$doc->uid.' ("'.$doc->location.'") on UID '.$startingPoint.' and Solr core '.$solrCoreUid.'.'); |
|
141 | 141 | } else { |
142 | 142 | if ($io->isVerbose()) { |
143 | - $io->writeln(date('Y-m-d H:i:s') . ' Indexing ' . $id . '/' . count($documents) . ' ' . $doc->uid . ' ("' . $doc->location . '") on UID ' . $startingPoint . ' and Solr core ' . $solrCoreUid . '.'); |
|
143 | + $io->writeln(date('Y-m-d H:i:s').' Indexing '.$id.'/'.count($documents).' '.$doc->uid.' ("'.$doc->location.'") on UID '.$startingPoint.' and Solr core '.$solrCoreUid.'.'); |
|
144 | 144 | } |
145 | 145 | // ...and save it to the database... |
146 | 146 | if (!$doc->save($startingPoint, $solrCoreUid)) { |
147 | - $io->error('ERROR: Document "' . $id . '" not saved and indexed.'); |
|
147 | + $io->error('ERROR: Document "'.$id.'" not saved and indexed.'); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | } else { |
151 | - $io->error('ERROR: Document "' . $id . '" could not be loaded.'); |
|
151 | + $io->error('ERROR: Document "'.$id.'" could not be loaded.'); |
|
152 | 152 | } |
153 | 153 | // Clear document registry to prevent memory exhaustion. |
154 | 154 | Document::clearRegistry(); |
@@ -27,13 +27,11 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * Reindex a collection into database and Solr. |
29 | 29 | */ |
30 | -class ReindexCommand extends Command |
|
31 | -{ |
|
30 | +class ReindexCommand extends Command { |
|
32 | 31 | /** |
33 | 32 | * Configure the command by defining the name, options and arguments |
34 | 33 | */ |
35 | - public function configure() |
|
36 | - { |
|
34 | + public function configure() { |
|
37 | 35 | $this |
38 | 36 | ->setDescription('Reindex a collection into database and Solr.') |
39 | 37 | ->setHelp('') |
@@ -75,8 +73,7 @@ discard block |
||
75 | 73 | * @param InputInterface $input |
76 | 74 | * @param OutputInterface $output |
77 | 75 | */ |
78 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
79 | - { |
|
76 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
80 | 77 | // Make sure the _cli_ user is loaded |
81 | 78 | Bootstrap::getInstance()->initializeBackendAuthentication(); |
82 | 79 |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | 'TEIHDR' => 'Kitodo\\\\Dlf\\\\Format\\\\TeiHeader' |
216 | 216 | ]; |
217 | 217 | foreach ($oldRecords as $uid => $type) { |
218 | - $sqlQuery = 'UPDATE tx_dlf_formats SET class="' . $newValues[$type] . '" WHERE uid=' . $uid; |
|
218 | + $sqlQuery = 'UPDATE tx_dlf_formats SET class="'.$newValues[$type].'" WHERE uid='.$uid; |
|
219 | 219 | $GLOBALS['TYPO3_DB']->sql_query($sqlQuery); |
220 | 220 | } |
221 | 221 | Helper::addMessage( |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
243 | 243 | 'tx_dlf_metadata.uid AS uid,tx_dlf_metadata.pid AS pid,tx_dlf_metadata.cruser_id AS cruser_id,tx_dlf_metadata.encoded AS encoded,tx_dlf_metadata.xpath AS xpath,tx_dlf_metadata.xpath_sorting AS xpath_sorting', |
244 | 244 | 'tx_dlf_metadata', |
245 | - 'tx_dlf_metadata.uid IN (' . implode(',', $metadataUids) . ')' |
|
245 | + 'tx_dlf_metadata.uid IN ('.implode(',', $metadataUids).')' |
|
246 | 246 | . Helper::whereClause('tx_dlf_metadata') |
247 | 247 | ); |
248 | 248 | while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $solrInfo['username'] |
335 | 335 | && $solrInfo['password'] |
336 | 336 | ) { |
337 | - $host = $solrInfo['username'] . ':' . $solrInfo['password'] . '@' . $solrInfo['host']; |
|
337 | + $host = $solrInfo['username'].':'.$solrInfo['password'].'@'.$solrInfo['host']; |
|
338 | 338 | } else { |
339 | 339 | $host = $solrInfo['host']; |
340 | 340 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | ]); |
347 | 347 | // Build request for adding new Solr core. |
348 | 348 | // @see http://wiki.apache.org/solr/CoreAdmin |
349 | - $url = $solrInfo['scheme'] . '://' . $host . ':' . $solrInfo['port'] . '/' . $solrInfo['path'] . '/admin/cores?wt=xml&action=CREATE&name=' . $resArray['index_name'] . '&instanceDir=' . $resArray['index_name'] . '&dataDir=data&configSet=dlf'; |
|
349 | + $url = $solrInfo['scheme'].'://'.$host.':'.$solrInfo['port'].'/'.$solrInfo['path'].'/admin/cores?wt=xml&action=CREATE&name='.$resArray['index_name'].'&instanceDir='.$resArray['index_name'].'&dataDir=data&configSet=dlf'; |
|
350 | 350 | $response = @simplexml_load_string(file_get_contents($url, FALSE, $context)); |
351 | 351 | // Process response. |
352 | 352 | if ($response) { |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
382 | 382 | 'COLUMN_NAME', |
383 | 383 | 'INFORMATION_SCHEMA.COLUMNS', |
384 | - 'TABLE_NAME="tx_dlf_documents" AND TABLE_SCHEMA="' . $database . '" AND COLUMN_NAME="document_format"' |
|
384 | + 'TABLE_NAME="tx_dlf_documents" AND TABLE_SCHEMA="'.$database.'" AND COLUMN_NAME="document_format"' |
|
385 | 385 | ); |
386 | 386 | while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
387 | 387 | if ($resArray['COLUMN_NAME'] == 'document_format') { |
@@ -21,8 +21,7 @@ discard block |
||
21 | 21 | * @subpackage dlf |
22 | 22 | * @access public |
23 | 23 | */ |
24 | -class ext_update |
|
25 | -{ |
|
24 | +class ext_update { |
|
26 | 25 | /** |
27 | 26 | * This holds the output ready to return |
28 | 27 | * |
@@ -38,8 +37,7 @@ discard block |
||
38 | 37 | * |
39 | 38 | * @return boolean Should the update option be shown? |
40 | 39 | */ |
41 | - public function access() |
|
42 | - { |
|
40 | + public function access() { |
|
43 | 41 | if (count($this->getMetadataConfig())) { |
44 | 42 | return TRUE; |
45 | 43 | } elseif ($this->oldIndexRelatedTableNames()) { |
@@ -61,8 +59,7 @@ discard block |
||
61 | 59 | * |
62 | 60 | * @return array Array of UIDs of outdated records |
63 | 61 | */ |
64 | - protected function getMetadataConfig() |
|
65 | - { |
|
62 | + protected function getMetadataConfig() { |
|
66 | 63 | $uids = []; |
67 | 64 | // check if tx_dlf_metadata.xpath exists anyhow |
68 | 65 | $fieldsInDatabase = $GLOBALS['TYPO3_DB']->admin_get_fields('tx_dlf_metadata'); |
@@ -92,8 +89,7 @@ discard block |
||
92 | 89 | * |
93 | 90 | * @return string The content that is displayed on the website |
94 | 91 | */ |
95 | - public function main() |
|
96 | - { |
|
92 | + public function main() { |
|
97 | 93 | // Load localization file. |
98 | 94 | $GLOBALS['LANG']->includeLLFile('EXT:dlf/Resources/Private/Language/FlashMessages.xml'); |
99 | 95 | // Update the metadata configuration. |
@@ -123,8 +119,7 @@ discard block |
||
123 | 119 | * |
124 | 120 | * @return array containing old format classes |
125 | 121 | */ |
126 | - protected function oldFormatClasses() |
|
127 | - { |
|
122 | + protected function oldFormatClasses() { |
|
128 | 123 | $oldRecords = []; |
129 | 124 | // Get all records with outdated configuration. |
130 | 125 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
@@ -146,8 +141,7 @@ discard block |
||
146 | 141 | * |
147 | 142 | * @return boolean TRUE if old index related columns exist |
148 | 143 | */ |
149 | - protected function oldIndexRelatedTableNames() |
|
150 | - { |
|
144 | + protected function oldIndexRelatedTableNames() { |
|
151 | 145 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
152 | 146 | 'column_name', |
153 | 147 | 'INFORMATION_SCHEMA.COLUMNS', |
@@ -173,8 +167,7 @@ discard block |
||
173 | 167 | * |
174 | 168 | * @return void |
175 | 169 | */ |
176 | - protected function renameIndexRelatedColumns() |
|
177 | - { |
|
170 | + protected function renameIndexRelatedColumns() { |
|
178 | 171 | $sqlQuery = 'UPDATE tx_dlf_metadata' |
179 | 172 | . ' SET `index_tokenized` = `tokenized`' |
180 | 173 | . ', `index_stored` = `stored`' |
@@ -206,8 +199,7 @@ discard block |
||
206 | 199 | * |
207 | 200 | * @return void |
208 | 201 | */ |
209 | - protected function updateFormatClasses() |
|
210 | - { |
|
202 | + protected function updateFormatClasses() { |
|
211 | 203 | $oldRecords = $this->oldFormatClasses(); |
212 | 204 | $newValues = [ |
213 | 205 | 'ALTO' => 'Kitodo\\\\Dlf\\\\Format\\\\Alto', // Those are effectively single backslashes |
@@ -233,8 +225,7 @@ discard block |
||
233 | 225 | * |
234 | 226 | * @return void |
235 | 227 | */ |
236 | - protected function updateMetadataConfig() |
|
237 | - { |
|
228 | + protected function updateMetadataConfig() { |
|
238 | 229 | $metadataUids = $this->getMetadataConfig(); |
239 | 230 | if (!empty($metadataUids)) { |
240 | 231 | $data = []; |
@@ -288,8 +279,7 @@ discard block |
||
288 | 279 | * |
289 | 280 | * @return boolean |
290 | 281 | */ |
291 | - protected function solariumSolrUpdateRequired() |
|
292 | - { |
|
282 | + protected function solariumSolrUpdateRequired() { |
|
293 | 283 | // Get all Solr cores that were not deleted. |
294 | 284 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
295 | 285 | 'index_name', |
@@ -314,8 +304,7 @@ discard block |
||
314 | 304 | * |
315 | 305 | * @return void |
316 | 306 | */ |
317 | - protected function doSolariumSolrUpdate() |
|
318 | - { |
|
307 | + protected function doSolariumSolrUpdate() { |
|
319 | 308 | // Get all Solr cores that were not deleted. |
320 | 309 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
321 | 310 | 'index_name', |
@@ -375,8 +364,7 @@ discard block |
||
375 | 364 | $this->content .= Helper::renderFlashMessages(); |
376 | 365 | } |
377 | 366 | |
378 | - protected function hasNoFormatForDocument() |
|
379 | - { |
|
367 | + protected function hasNoFormatForDocument() { |
|
380 | 368 | $database = $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname']; |
381 | 369 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
382 | 370 | 'COLUMN_NAME', |
@@ -391,8 +379,7 @@ discard block |
||
391 | 379 | return TRUE; |
392 | 380 | } |
393 | 381 | |
394 | - protected function updateDocumentAddFormat() |
|
395 | - { |
|
382 | + protected function updateDocumentAddFormat() { |
|
396 | 383 | $sqlQuery = 'ALTER TABLE tx_dlf_documents ADD COLUMN document_format varchar(100) DEFAULT "" NOT NULL;'; |
397 | 384 | $result = $GLOBALS['TYPO3_DB']->sql_query($sqlQuery); |
398 | 385 | if ($result) { |