@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | OutputFormatValueFormatterFactory $valueFormatterFactory, |
99 | 99 | CrossCheckInteractor $crossCheckInteractor |
100 | 100 | ) { |
101 | - parent::__construct( 'CrossCheck' ); |
|
101 | + parent::__construct('CrossCheck'); |
|
102 | 102 | |
103 | 103 | $this->entityLookup = $entityLookup; |
104 | 104 | $this->entityIdParser = $entityIdParser; |
105 | 105 | |
106 | 106 | $formatterOptions = new FormatterOptions(); |
107 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $this->getLanguage()->getCode() ); |
|
108 | - $this->dataValueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
107 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $this->getLanguage()->getCode()); |
|
108 | + $this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
109 | 109 | |
110 | - $labelLookup = new LanguageLabelDescriptionLookup( $termLookup, $this->getLanguage()->getCode() ); |
|
111 | - $this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelLookup ); |
|
112 | - $this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelLookup ); |
|
110 | + $labelLookup = new LanguageLabelDescriptionLookup($termLookup, $this->getLanguage()->getCode()); |
|
111 | + $this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelLookup); |
|
112 | + $this->entityIdLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelLookup); |
|
113 | 113 | |
114 | 114 | $this->crossCheckInteractor = $crossCheckInteractor; |
115 | 115 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return string (plain text) |
130 | 130 | */ |
131 | 131 | public function getDescription() { |
132 | - return $this->msg( 'wbqev-crosscheck' )->text(); |
|
132 | + return $this->msg('wbqev-crosscheck')->text(); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -141,55 +141,55 @@ discard block |
||
141 | 141 | * @throws EntityIdParsingException |
142 | 142 | * @throws UnexpectedValueException |
143 | 143 | */ |
144 | - public function execute( $subPage ) { |
|
144 | + public function execute($subPage) { |
|
145 | 145 | $out = $this->getOutput(); |
146 | - $postRequest = $this->getContext()->getRequest()->getVal( 'entityid' ); |
|
147 | - if ( $postRequest ) { |
|
148 | - $out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() ); |
|
146 | + $postRequest = $this->getContext()->getRequest()->getVal('entityid'); |
|
147 | + if ($postRequest) { |
|
148 | + $out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL()); |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | - $out->addModules( 'SpecialCrossCheckPage' ); |
|
152 | + $out->addModules('SpecialCrossCheckPage'); |
|
153 | 153 | |
154 | 154 | $this->setHeaders(); |
155 | 155 | |
156 | - $out->addHTML( $this->buildInfoBox() ); |
|
156 | + $out->addHTML($this->buildInfoBox()); |
|
157 | 157 | $this->buildEntityIdForm(); |
158 | 158 | |
159 | - if ( $subPage ) { |
|
160 | - $this->buildResult( $subPage ); |
|
159 | + if ($subPage) { |
|
160 | + $this->buildResult($subPage); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * @param string $idSerialization |
166 | 166 | */ |
167 | - private function buildResult( $idSerialization ) { |
|
167 | + private function buildResult($idSerialization) { |
|
168 | 168 | $out = $this->getOutput(); |
169 | 169 | |
170 | 170 | try { |
171 | - $entityId = $this->entityIdParser->parse( $idSerialization ); |
|
172 | - } catch ( EntityIdParsingException $ex ) { |
|
173 | - $out->addHTML( $this->buildNotice( 'wbqev-crosscheck-invalid-entity-id', true ) ); |
|
171 | + $entityId = $this->entityIdParser->parse($idSerialization); |
|
172 | + } catch (EntityIdParsingException $ex) { |
|
173 | + $out->addHTML($this->buildNotice('wbqev-crosscheck-invalid-entity-id', true)); |
|
174 | 174 | return; |
175 | 175 | } |
176 | 176 | |
177 | - $out->addHTML( $this->buildResultHeader( $entityId ) ); |
|
177 | + $out->addHTML($this->buildResultHeader($entityId)); |
|
178 | 178 | |
179 | - $entity = $this->entityLookup->getEntity( $entityId ); |
|
180 | - if ( $entity === null ) { |
|
181 | - $out->addHTML( $this->buildNotice( 'wbqev-crosscheck-not-existent-entity', true ) ); |
|
179 | + $entity = $this->entityLookup->getEntity($entityId); |
|
180 | + if ($entity === null) { |
|
181 | + $out->addHTML($this->buildNotice('wbqev-crosscheck-not-existent-entity', true)); |
|
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
185 | - $results = $this->getCrossCheckResultsFromEntity( $entity ); |
|
185 | + $results = $this->getCrossCheckResultsFromEntity($entity); |
|
186 | 186 | |
187 | - if ( $results === null || $results->toArray() === [] ) { |
|
188 | - $out->addHTML( $this->buildNotice( 'wbqev-crosscheck-empty-result' ) ); |
|
187 | + if ($results === null || $results->toArray() === []) { |
|
188 | + $out->addHTML($this->buildNotice('wbqev-crosscheck-empty-result')); |
|
189 | 189 | } else { |
190 | 190 | $out->addHTML( |
191 | - $this->buildSummary( $results ) |
|
192 | - . $this->buildResultTable( $results ) |
|
191 | + $this->buildSummary($results) |
|
192 | + . $this->buildResultTable($results) |
|
193 | 193 | ); |
194 | 194 | } |
195 | 195 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return CrossCheckResultList|null |
201 | 201 | */ |
202 | - private function getCrossCheckResultsFromEntity( EntityDocument $entity ) { |
|
203 | - if ( $entity instanceof StatementListProvider ) { |
|
204 | - return $this->crossCheckInteractor->crossCheckStatements( $entity->getStatements() ); |
|
202 | + private function getCrossCheckResultsFromEntity(EntityDocument $entity) { |
|
203 | + if ($entity instanceof StatementListProvider) { |
|
204 | + return $this->crossCheckInteractor->crossCheckStatements($entity->getStatements()); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return null; |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | 'name' => 'entityid', |
219 | 219 | 'label-message' => 'wbqev-crosscheck-form-entityid-label', |
220 | 220 | 'cssclass' => 'wbqev-crosscheck-form-entity-id', |
221 | - 'placeholder' => $this->msg( 'wbqev-crosscheck-form-entityid-placeholder' )->escaped() |
|
221 | + 'placeholder' => $this->msg('wbqev-crosscheck-form-entityid-placeholder')->escaped() |
|
222 | 222 | ] |
223 | 223 | ]; |
224 | - $htmlForm = new HTMLForm( $formDescriptor, $this->getContext(), 'wbqev-crosscheck-form' ); |
|
225 | - $htmlForm->setSubmitText( $this->msg( 'wbqev-crosscheck-form-submit-label' )->escaped() ); |
|
226 | - $htmlForm->setSubmitCallback( function() { |
|
224 | + $htmlForm = new HTMLForm($formDescriptor, $this->getContext(), 'wbqev-crosscheck-form'); |
|
225 | + $htmlForm->setSubmitText($this->msg('wbqev-crosscheck-form-submit-label')->escaped()); |
|
226 | + $htmlForm->setSubmitCallback(function() { |
|
227 | 227 | return false; |
228 | 228 | } ); |
229 | - $htmlForm->setMethod( 'post' ); |
|
229 | + $htmlForm->setMethod('post'); |
|
230 | 230 | $htmlForm->show(); |
231 | 231 | } |
232 | 232 | |
@@ -236,18 +236,18 @@ discard block |
||
236 | 236 | * @return string HTML |
237 | 237 | */ |
238 | 238 | private function buildInfoBox() { |
239 | - $externalDbLink = Linker::specialLink( 'ExternalDatabases', 'wbqev-externaldbs' ); |
|
239 | + $externalDbLink = Linker::specialLink('ExternalDatabases', 'wbqev-externaldbs'); |
|
240 | 240 | $infoBox = |
241 | 241 | Html::openElement( |
242 | 242 | 'div', |
243 | - [ 'class' => 'wbqev-infobox' ] |
|
243 | + ['class' => 'wbqev-infobox'] |
|
244 | 244 | ) |
245 | - . $this->msg( 'wbqev-crosscheck-explanation-general' )->parse() |
|
246 | - . sprintf( ' %s.', $externalDbLink ) |
|
247 | - . Html::element( 'br' ) |
|
248 | - . Html::element( 'br' ) |
|
249 | - . $this->msg( 'wbqev-crosscheck-explanation-detail' )->parse() |
|
250 | - . Html::closeElement( 'div' ); |
|
245 | + . $this->msg('wbqev-crosscheck-explanation-general')->parse() |
|
246 | + . sprintf(' %s.', $externalDbLink) |
|
247 | + . Html::element('br') |
|
248 | + . Html::element('br') |
|
249 | + . $this->msg('wbqev-crosscheck-explanation-detail')->parse() |
|
250 | + . Html::closeElement('div'); |
|
251 | 251 | |
252 | 252 | return $infoBox; |
253 | 253 | } |
@@ -262,16 +262,16 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return string HTML |
264 | 264 | */ |
265 | - private function buildNotice( $messageKey, $error = false ) { |
|
265 | + private function buildNotice($messageKey, $error = false) { |
|
266 | 266 | $cssClasses = 'wbqev-crosscheck-notice'; |
267 | - if ( $error ) { |
|
267 | + if ($error) { |
|
268 | 268 | $cssClasses .= ' wbqev-crosscheck-notice-error'; |
269 | 269 | } |
270 | 270 | |
271 | 271 | return Html::element( |
272 | 272 | 'p', |
273 | - [ 'class' => $cssClasses ], |
|
274 | - $this->msg( $messageKey )->text() |
|
273 | + ['class' => $cssClasses], |
|
274 | + $this->msg($messageKey)->text() |
|
275 | 275 | ); |
276 | 276 | } |
277 | 277 | |
@@ -282,17 +282,17 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return string HTML |
284 | 284 | */ |
285 | - private function buildResultHeader( EntityId $entityId ) { |
|
285 | + private function buildResultHeader(EntityId $entityId) { |
|
286 | 286 | $entityLink = sprintf( |
287 | 287 | '%s (%s)', |
288 | - $this->entityIdLinkFormatter->formatEntityId( $entityId ), |
|
289 | - htmlspecialchars( $entityId->getSerialization() ) |
|
288 | + $this->entityIdLinkFormatter->formatEntityId($entityId), |
|
289 | + htmlspecialchars($entityId->getSerialization()) |
|
290 | 290 | ); |
291 | 291 | |
292 | 292 | return Html::rawElement( |
293 | 293 | 'h3', |
294 | 294 | [], |
295 | - sprintf( '%s %s', $this->msg( 'wbqev-crosscheck-result-headline' )->escaped(), $entityLink ) |
|
295 | + sprintf('%s %s', $this->msg('wbqev-crosscheck-result-headline')->escaped(), $entityLink) |
|
296 | 296 | ); |
297 | 297 | } |
298 | 298 | |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return string HTML |
305 | 305 | */ |
306 | - private function buildSummary( $results ) { |
|
306 | + private function buildSummary($results) { |
|
307 | 307 | $statuses = []; |
308 | - foreach ( $results as $result ) { |
|
309 | - $status = strtolower( $result->getComparisonResult()->getStatus() ); |
|
310 | - if ( array_key_exists( $status, $statuses ) ) { |
|
308 | + foreach ($results as $result) { |
|
309 | + $status = strtolower($result->getComparisonResult()->getStatus()); |
|
310 | + if (array_key_exists($status, $statuses)) { |
|
311 | 311 | $statuses[$status]++; |
312 | 312 | } else { |
313 | 313 | $statuses[$status] = 1; |
@@ -315,15 +315,15 @@ discard block |
||
315 | 315 | } |
316 | 316 | |
317 | 317 | $statusElements = []; |
318 | - foreach ( $statuses as $status => $count ) { |
|
319 | - if ( $count > 0 ) { |
|
320 | - $statusElements[] = $this->formatStatus( $status ) . ': ' . $count; |
|
318 | + foreach ($statuses as $status => $count) { |
|
319 | + if ($count > 0) { |
|
320 | + $statusElements[] = $this->formatStatus($status).': '.$count; |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | $summary = |
324 | - Html::openElement( 'p' ) |
|
325 | - . implode( ', ', $statusElements ) |
|
326 | - . Html::closeElement( 'p' ); |
|
324 | + Html::openElement('p') |
|
325 | + . implode(', ', $statusElements) |
|
326 | + . Html::closeElement('p'); |
|
327 | 327 | |
328 | 328 | return $summary; |
329 | 329 | } |
@@ -337,16 +337,16 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @return string HTML |
339 | 339 | */ |
340 | - private function formatStatus( $status ) { |
|
341 | - $messageKey = 'wbqev-crosscheck-status-' . strtolower( $status ); |
|
340 | + private function formatStatus($status) { |
|
341 | + $messageKey = 'wbqev-crosscheck-status-'.strtolower($status); |
|
342 | 342 | |
343 | 343 | $formattedStatus = |
344 | 344 | Html::element( |
345 | 345 | 'span', |
346 | 346 | [ |
347 | - 'class' => 'wbqev-status wbqev-status-' . $status |
|
347 | + 'class' => 'wbqev-status wbqev-status-'.$status |
|
348 | 348 | ], |
349 | - $this->msg( $messageKey )->text() |
|
349 | + $this->msg($messageKey)->text() |
|
350 | 350 | ); |
351 | 351 | |
352 | 352 | return $formattedStatus; |
@@ -363,29 +363,29 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return string HTML |
365 | 365 | */ |
366 | - private function formatDataValues( $dataValues, $linking = true, $separator = null ) { |
|
367 | - if ( $dataValues instanceof DataValue ) { |
|
368 | - $dataValues = [ $dataValues ]; |
|
366 | + private function formatDataValues($dataValues, $linking = true, $separator = null) { |
|
367 | + if ($dataValues instanceof DataValue) { |
|
368 | + $dataValues = [$dataValues]; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $formattedDataValues = []; |
372 | - foreach ( $dataValues as $dataValue ) { |
|
373 | - if ( $dataValue instanceof EntityIdValue ) { |
|
374 | - if ( $linking ) { |
|
375 | - $formattedDataValues[] = $this->entityIdLinkFormatter->formatEntityId( $dataValue->getEntityId() ); |
|
372 | + foreach ($dataValues as $dataValue) { |
|
373 | + if ($dataValue instanceof EntityIdValue) { |
|
374 | + if ($linking) { |
|
375 | + $formattedDataValues[] = $this->entityIdLinkFormatter->formatEntityId($dataValue->getEntityId()); |
|
376 | 376 | } else { |
377 | - $formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() ); |
|
377 | + $formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId()); |
|
378 | 378 | } |
379 | 379 | } else { |
380 | - $formattedDataValues[] = $this->dataValueFormatter->format( $dataValue ); |
|
380 | + $formattedDataValues[] = $this->dataValueFormatter->format($dataValue); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - if ( $separator ) { |
|
385 | - return implode( $separator, $formattedDataValues ); |
|
384 | + if ($separator) { |
|
385 | + return implode($separator, $formattedDataValues); |
|
386 | 386 | } |
387 | 387 | |
388 | - return $this->getLanguage()->commaList( $formattedDataValues ); |
|
388 | + return $this->getLanguage()->commaList($formattedDataValues); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -393,31 +393,31 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return string HTML |
395 | 395 | */ |
396 | - private function buildResultTable( $results ) { |
|
396 | + private function buildResultTable($results) { |
|
397 | 397 | $table = new HtmlTableBuilder( |
398 | 398 | [ |
399 | 399 | new HtmlTableHeaderBuilder( |
400 | - $this->msg( 'wbqev-crosscheck-result-table-header-status' )->escaped(), |
|
400 | + $this->msg('wbqev-crosscheck-result-table-header-status')->escaped(), |
|
401 | 401 | true |
402 | 402 | ), |
403 | 403 | new HtmlTableHeaderBuilder( |
404 | - $this->msg( 'datatypes-type-wikibase-property' )->escaped(), |
|
404 | + $this->msg('datatypes-type-wikibase-property')->escaped(), |
|
405 | 405 | true |
406 | 406 | ), |
407 | 407 | new HtmlTableHeaderBuilder( |
408 | - $this->msg( 'wbqev-crosscheck-result-table-header-local-value' )->escaped() |
|
408 | + $this->msg('wbqev-crosscheck-result-table-header-local-value')->escaped() |
|
409 | 409 | ), |
410 | 410 | new HtmlTableHeaderBuilder( |
411 | - $this->msg( 'wbqev-crosscheck-result-table-header-external-value' )->escaped() |
|
411 | + $this->msg('wbqev-crosscheck-result-table-header-external-value')->escaped() |
|
412 | 412 | ), |
413 | 413 | new HtmlTableHeaderBuilder( |
414 | - $this->msg( 'wbqev-crosscheck-result-table-header-references' )->escaped(), |
|
414 | + $this->msg('wbqev-crosscheck-result-table-header-references')->escaped(), |
|
415 | 415 | true |
416 | 416 | ), |
417 | 417 | new HtmlTableHeaderBuilder( |
418 | 418 | Linker::linkKnown( |
419 | - self::getTitleFor( 'ExternalDatabases' ), |
|
420 | - $this->msg( 'wbqev-crosscheck-result-table-header-external-source' )->escaped() |
|
419 | + self::getTitleFor('ExternalDatabases'), |
|
420 | + $this->msg('wbqev-crosscheck-result-table-header-external-source')->escaped() |
|
421 | 421 | ), |
422 | 422 | true, |
423 | 423 | true |
@@ -426,28 +426,28 @@ discard block |
||
426 | 426 | true |
427 | 427 | ); |
428 | 428 | |
429 | - foreach ( $results as $result ) { |
|
430 | - $status = $this->formatStatus( $result->getComparisonResult()->getStatus() ); |
|
431 | - $propertyId = $this->entityIdLinkFormatter->formatEntityId( $result->getPropertyId() ); |
|
432 | - $localValue = $this->formatDataValues( $result->getComparisonResult()->getLocalValue() ); |
|
429 | + foreach ($results as $result) { |
|
430 | + $status = $this->formatStatus($result->getComparisonResult()->getStatus()); |
|
431 | + $propertyId = $this->entityIdLinkFormatter->formatEntityId($result->getPropertyId()); |
|
432 | + $localValue = $this->formatDataValues($result->getComparisonResult()->getLocalValue()); |
|
433 | 433 | $externalValue = $this->formatDataValues( |
434 | 434 | $result->getComparisonResult()->getExternalValues(), |
435 | 435 | true, |
436 | - Html::element( 'br' ) |
|
436 | + Html::element('br') |
|
437 | 437 | ); |
438 | 438 | $referenceStatus = $this->msg( |
439 | - 'wbqev-crosscheck-status-' . $result->getReferenceResult()->getStatus() |
|
439 | + 'wbqev-crosscheck-status-'.$result->getReferenceResult()->getStatus() |
|
440 | 440 | )->text(); |
441 | - $dataSource = $this->entityIdLinkFormatter->formatEntityId( $result->getDumpMetaInformation()->getSourceItemId() ); |
|
441 | + $dataSource = $this->entityIdLinkFormatter->formatEntityId($result->getDumpMetaInformation()->getSourceItemId()); |
|
442 | 442 | |
443 | 443 | $table->appendRow( |
444 | 444 | [ |
445 | - new HtmlTableCellBuilder( $status, [], true ), |
|
446 | - new HtmlTableCellBuilder( $propertyId, [], true ), |
|
447 | - new HtmlTableCellBuilder( $localValue, [], true ), |
|
448 | - new HtmlTableCellBuilder( $externalValue, [], true ), |
|
449 | - new HtmlTableCellBuilder( $referenceStatus, [] ), |
|
450 | - new HtmlTableCellBuilder( $dataSource, [], true ) |
|
445 | + new HtmlTableCellBuilder($status, [], true), |
|
446 | + new HtmlTableCellBuilder($propertyId, [], true), |
|
447 | + new HtmlTableCellBuilder($localValue, [], true), |
|
448 | + new HtmlTableCellBuilder($externalValue, [], true), |
|
449 | + new HtmlTableCellBuilder($referenceStatus, []), |
|
450 | + new HtmlTableCellBuilder($dataSource, [], true) |
|
451 | 451 | ] |
452 | 452 | ); |
453 | 453 | } |