jenkins-bot has submitted this change and it was merged.
Change subject: Convert spaces to tabs in CrossCheckViolationFormatter.php
......................................................................
Convert spaces to tabs in CrossCheckViolationFormatter.php
Change-Id: I29d8ac3b34e7d59a63c86cd8e39afa589a76086b
---
M includes/Violations/CrossCheckViolationFormatter.php
1 file changed, 229 insertions(+), 197 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Violations/CrossCheckViolationFormatter.php
b/includes/Violations/CrossCheckViolationFormatter.php
index 9b0a0ad..361d82e 100755
--- a/includes/Violations/CrossCheckViolationFormatter.php
+++ b/includes/Violations/CrossCheckViolationFormatter.php
@@ -3,8 +3,8 @@
namespace WikibaseQuality\ExternalValidation\Violations;
use Deserializers\Deserializer;
-use InvalidArgumentException;
use Html;
+use InvalidArgumentException;
use ValueFormatters\ValueFormatter;
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\Lib\EntityIdFormatter;
@@ -12,216 +12,244 @@
use WikibaseQuality\Violations\Violation;
use WikibaseQuality\Violations\ViolationFormatter;
-
class CrossCheckViolationFormatter implements ViolationFormatter {
+ const EXTERNAL_VIOLATION_ICON_CLASS = 'wbq-icon-arrows-severe';
- const EXTERNAL_VIOLATION_ICON_CLASS = 'wbq-icon-arrows-severe';
+ /**
+ * @var Deserializer
+ */
+ private $dataValueDeserializer;
- /**
- * @var Deserializer
- */
- private $dataValueDeserializer;
+ /**
+ * @var EntityIdFormatter
+ */
+ private $entityIdFormatter;
- /**
- * @var EntityIdFormatter
- */
- private $entityIdFormatter;
+ /**
+ * @var ValueFormatter
+ */
+ private $valueFormatter;
- /**
- * @var ValueFormatter
- */
- private $valueFormatter;
+ /**
+ * @var DumpMetaInformationLookup
+ */
+ private $dumpMetaInformationLookup;
- /**
- * @var DumpMetaInformationLookup
- */
- private $dumpMetaInformationLookup;
+ /**
+ * @param Deserializer $dataValueDeserializer
+ * @param EntityIdFormatter $entityIdFormatter (must return HTML)
+ * @param ValueFormatter $valueFormatter (must return HTML)
+ * @param DumpMetaInformationLookup $dumpMetaInformationLookup
+ */
+ public function __construct(
+ Deserializer $dataValueDeserializer,
+ EntityIdFormatter $entityIdFormatter,
+ ValueFormatter $valueFormatter,
+ DumpMetaInformationLookup $dumpMetaInformationLookup
+ ) {
+ $this->dataValueDeserializer = $dataValueDeserializer;
+ $this->entityIdFormatter = $entityIdFormatter;
+ $this->valueFormatter = $valueFormatter;
+ $this->dumpMetaInformationLookup = $dumpMetaInformationLookup;
+ }
- /**
- * @param Deserializer $dataValueDeserializer
- * @param EntityIdFormatter $entityIdFormatter (must return HTML)
- * @param ValueFormatter $valueFormatter (must return HTML)
- * @param DumpMetaInformationLookup $dumpMetaInformationLookup
- */
- public function __construct( Deserializer $dataValueDeserializer,
-
EntityIdFormatter $entityIdFormatter,
- ValueFormatter
$valueFormatter,
-
DumpMetaInformationLookup $dumpMetaInformationLookup ) {
- $this->dataValueDeserializer = $dataValueDeserializer;
- $this->entityIdFormatter = $entityIdFormatter;
- $this->valueFormatter = $valueFormatter;
- $this->dumpMetaInformationLookup = $dumpMetaInformationLookup;
- }
+ /**
+ * @see ViolationFormatter::isFormatterFor
+ *
+ * @param Violation $violation
+ *
+ * @return bool
+ */
+ public function isFormatterFor( Violation $violation ) {
+ $splitConstraintId =
+ explode( Violation::CONSTRAINT_ID_DELIMITER,
$violation->getConstraintId() );
+ $prefix = $splitConstraintId[0];
- /**
- * @see ViolationFormatter::isFormatterFor
- *
- * @param Violation $violation
- *
- * @return bool
- */
- public function isFormatterFor( Violation $violation ) {
- $splitConstraintId = explode( Violation::CONSTRAINT_ID_DELIMITER,
$violation->getConstraintId() );
- $prefix = $splitConstraintId[0];
+ return $prefix === WBQ_EXTERNAL_VALIDATION_ID;
+ }
- return $prefix === WBQ_EXTERNAL_VALIDATION_ID;
- }
+ /**
+ * @see ViolationFormatter::formatAdditionalInformation
+ *
+ * @param Violation $violation
+ *
+ * @throws InvalidArgumentException
+ * @return string HTML
+ */
+ public function formatAdditionalInformation( Violation $violation ) {
+ if ( !$this->isFormatterFor( $violation ) ) {
+ throw new InvalidArgumentException( 'Given violation is
not part of current context.' );
+ }
- /**
- * @see ViolationFormatter::formatAdditionalInformation
- *
- * @param Violation $violation
- * @throws InvalidArgumentException
- * @return string HTML
- */
- public function formatAdditionalInformation( Violation $violation ) {
- if ( !$this->isFormatterFor( $violation ) ) {
- throw new InvalidArgumentException( 'Given violation is not part
of current context.' );
- }
+ $additionalInfo = $violation->getAdditionalInfo();
+ $output = $this->buildDataSourceSection( $additionalInfo );
+ $output .= $this->buildExternalValuesSection( $additionalInfo );
- $additionalInfo = $violation->getAdditionalInfo();
- $output = $this->buildDataSourceSection( $additionalInfo );
- $output .= $this->buildExternalValuesSection( $additionalInfo );
+ return $output;
+ }
- return $output;
- }
+ /**
+ * @param array $additionalInformation
+ *
+ * @return string HTML
+ */
+ private function buildDataSourceSection( array $additionalInformation )
{
+ if ( array_key_exists( 'dump_id', $additionalInformation ) ) {
+ $dumpId = $additionalInformation['dump_id'];
+ $dumpMetaInformation =
$this->dumpMetaInformationLookup->getWithId( $dumpId );
+ $dataSourceEntityId =
$dumpMetaInformation->getSourceItemId();
+ $dataSource = $this->entityIdFormatter->formatEntityId(
$dataSourceEntityId );
- /**
- * @param array $additionalInformation
- * @return string HTML
- */
- private function buildDataSourceSection( array $additionalInformation ) {
- if ( array_key_exists( 'dump_id', $additionalInformation ) ) {
- $dumpId = $additionalInformation['dump_id'];
- $dumpMetaInformation =
$this->dumpMetaInformationLookup->getWithId( $dumpId );
- $dataSourceEntityId = $dumpMetaInformation->getSourceItemId();
- $dataSource = $this->entityIdFormatter->formatEntityId(
$dataSourceEntityId );
+ return $this->buildSection(
+ 'wbqev-violation-header-external-source',
+ $dataSource
+ );
+ }
+ }
- return $this->buildSection(
- 'wbqev-violation-header-external-source',
- $dataSource
- );
- }
- }
+ /**
+ * @param array $additionalInformation
+ *
+ * @return string HTML
+ */
+ private function buildExternalValuesSection( array
$additionalInformation ) {
+ if ( array_key_exists( 'external_values',
$additionalInformation ) ) {
+ $externalValues = $this->formatExternalValues(
$additionalInformation );
- /**
- * @param array $additionalInformation
- * @return string HTML
- */
- private function buildExternalValuesSection( array $additionalInformation
) {
- if ( array_key_exists( 'external_values', $additionalInformation ) ) {
- $externalValues = $this->formatExternalValues(
$additionalInformation );
+ return $this->buildSection(
+ 'wbqev-violation-header-external-values',
+ implode( Html::element( 'br' ), $externalValues
)
+ );
+ }
+ }
- return $this->buildSection(
- 'wbqev-violation-header-external-values',
- implode( Html::element( 'br' ), $externalValues )
- );
- }
- }
+ /**
+ * @param array $additionalInformation
+ *
+ * @return string HTML
+ */
+ private function formatExternalValues( array $additionalInformation ) {
+ if ( array_key_exists( 'external_values',
$additionalInformation ) ) {
+ $dataValueDeserializer = $this->dataValueDeserializer;
+ $valueFormatter = $this->valueFormatter;
- /**
- * @param array $additionalInformation
- * @return string HTML
- */
- private function formatExternalValues( array $additionalInformation ) {
- if ( array_key_exists( 'external_values', $additionalInformation ) ) {
- $dataValueDeserializer = $this->dataValueDeserializer;
- $valueFormatter = $this->valueFormatter;
- return array_map(
- function ( $serializedDataValue ) use (
$dataValueDeserializer, $valueFormatter ) {
- $dataValue = $dataValueDeserializer->deserialize(
$serializedDataValue );
- return $valueFormatter->format( $dataValue );
- },
- $additionalInformation['external_values']
- );
- }
- }
+ return array_map(
+ function ( $serializedDataValue ) use (
$dataValueDeserializer, $valueFormatter ) {
+ $dataValue =
$dataValueDeserializer->deserialize( $serializedDataValue );
- /**
- * Build section for additional information output.
- *
- * @param string $headlineMessage
- * @param string HTML $content
- * @return string HTML
- */
- private function buildSection( $headlineMessage, $content ) {
- return
- Html::openElement( 'p' )
- . Html::element(
- 'span',
- array(
- 'class' => 'wbq-violations-additional-information-header'
- ),
- wfMessage( $headlineMessage )->text()
- )
- . Html::element( 'br' )
- . $content
- . Html::closeElement( 'p' );
- }
+ return $valueFormatter->format(
$dataValue );
+ },
+ $additionalInformation['external_values']
+ );
+ }
+ }
- /**
- * @param Violation $violation
- * @throws InvalidArgumentException
- * @return string HTML
- */
- public function getIconClass( Violation $violation ) {
- if ( !$this->isFormatterFor( $violation ) ) {
- throw new InvalidArgumentException( 'The given violation is not
supported by this context.' );
- }
+ /**
+ * Build section for additional information output.
+ *
+ * @param string $headlineMessage
+ * @param string HTML $content
+ *
+ * @return string HTML
+ */
+ private function buildSection( $headlineMessage, $content ) {
+ return
+ Html::openElement( 'p' )
+ . Html::element(
+ 'span',
+ array(
+ 'class' =>
'wbq-violations-additional-information-header'
+ ),
+ wfMessage( $headlineMessage )->text()
+ )
+ . Html::element( 'br' )
+ . $content
+ . Html::closeElement( 'p' );
+ }
- return htmlspecialchars(
CrossCheckViolationFormatter::EXTERNAL_VIOLATION_ICON_CLASS );
- }
+ /**
+ * @param Violation $violation
+ *
+ * @throws InvalidArgumentException
+ * @return string HTML
+ */
+ public function getIconClass( Violation $violation ) {
+ if ( !$this->isFormatterFor( $violation ) ) {
+ throw new InvalidArgumentException(
+ 'The given violation is not supported by this
context.'
+ );
+ }
- /**
- * @param Violation $violation
- * @throws InvalidArgumentException
- * @return string HTML
- */
- public function getShortMessage( Violation $violation ) {
- if ( !$this->isFormatterFor( $violation ) ) {
- throw new InvalidArgumentException( 'The given violation is not
supported by this context.' );
- }
+ return htmlspecialchars(
CrossCheckViolationFormatter::EXTERNAL_VIOLATION_ICON_CLASS );
+ }
- $dataSourceEntityId = new ItemId(
$violation->getConstraintTypeEntityId() );
- $dataSource = $this->entityIdFormatter->formatEntityId(
$dataSourceEntityId );
+ /**
+ * @param Violation $violation
+ *
+ * @throws InvalidArgumentException
+ * @return string HTML
+ */
+ public function getShortMessage( Violation $violation ) {
+ if ( !$this->isFormatterFor( $violation ) ) {
+ throw new InvalidArgumentException(
+ 'The given violation is not supported by this
context.'
+ );
+ }
- return wfMessage( 'wbqev-violation-short-message' )
- ->params( $dataSource )
- ->text();
- }
+ $dataSourceEntityId = new ItemId(
$violation->getConstraintTypeEntityId() );
+ $dataSource = $this->entityIdFormatter->formatEntityId(
$dataSourceEntityId );
- /**
- * @param Violation $violation
- * @param bool $permissionStatus
- * @throws InvalidArgumentException
- * @return string HTML
- */
- public function getLongMessage( Violation $violation, $permissionStatus ) {
- if ( !$this->isFormatterFor( $violation ) ) {
- throw new InvalidArgumentException( 'The given violation is not
supported by this context.' );
- }
+ return wfMessage( 'wbqev-violation-short-message' )
+ ->params( $dataSource )
+ ->text();
+ }
- $dataSourceEntityId = new ItemId(
$violation->getConstraintTypeEntityId() );
- $dataSource = $this->entityIdFormatter->formatEntityId(
$dataSourceEntityId );
- $additionalInfo = $violation->getAdditionalInfo();
- $externalValues = $this->formatExternalValues( $additionalInfo );
+ /**
+ * @param Violation $violation
+ * @param bool $permissionStatus
+ *
+ * @throws InvalidArgumentException
+ * @return string HTML
+ */
+ public function getLongMessage( Violation $violation, $permissionStatus
) {
+ if ( !$this->isFormatterFor( $violation ) ) {
+ throw new InvalidArgumentException(
+ 'The given violation is not supported by this
context.'
+ );
+ }
- return $this->buildLongMessage( $additionalInfo, $dataSource,
$externalValues, $permissionStatus );
- }
+ $dataSourceEntityId = new ItemId(
$violation->getConstraintTypeEntityId() );
+ $dataSource = $this->entityIdFormatter->formatEntityId(
$dataSourceEntityId );
+ $additionalInfo = $violation->getAdditionalInfo();
+ $externalValues = $this->formatExternalValues( $additionalInfo
);
- /**
- * Build long message for item page.
- *
- * @param array $additionalInfo
- * @param string $dataSource (plain text)
+ return $this->buildLongMessage(
+ $additionalInfo,
+ $dataSource,
+ $externalValues,
+ $permissionStatus
+ );
+ }
+
+ /**
+ * Build long message for item page.
+ *
+ * @param array $additionalInfo
+ * @param string $dataSource (plain text)
* @param string $externalValues (plain text)
* @param bool $canMarkAsException
- * @return string HTML
- */
- private function buildLongMessage( array $additionalInfo, $dataSource,
$externalValues, $canMarkAsException ) {
+ *
+ * @return string HTML
+ */
+ private function buildLongMessage(
+ array $additionalInfo,
+ $dataSource,
+ $externalValues,
+ $canMarkAsException
+ ) {
- $message =
+ $message =
Html::element(
'span',
array( 'class' => 'wbq-long-message-headline' ),
@@ -229,37 +257,41 @@
->params( $dataSource )
->text()
);
- if( $externalValues ) {
- $message .= Html::element( 'br' );
- $message .= wfMessage(
'wbqev-violation-long-message-external-values' )
- ->params( implode( ', ', $externalValues ), sizeof(
$additionalInfo['external_values'] ) )
- ->escaped();
- }
- $message .= Html::element( 'br' );
+ if ( $externalValues ) {
+ $message .= Html::element( 'br' );
+ $message .= wfMessage(
'wbqev-violation-long-message-external-values' )
+ ->params(
+ implode( ', ', $externalValues ),
+ sizeof(
$additionalInfo['external_values'] )
+ )
+ ->escaped();
+ }
+ $message .= Html::element( 'br' );
- $message .= wfMessage( 'wbqev-violation-long-message-solve-issue'
)->escaped();
- $message .= Html::element( 'br' );
+ $message .= wfMessage(
'wbqev-violation-long-message-solve-issue' )->escaped();
+ $message .= Html::element( 'br' );
- if ( $canMarkAsException ) {
- $message .=
+ if ( $canMarkAsException ) {
+ $message .=
Html::openElement(
'div',
array( 'class' =>
'wbq-container-mark-as-exception' )
)
. wfMessage(
'wbqev-violation-long-message-headline' )
- ->params( $dataSource )
- ->text()
+ ->params( $dataSource )
+ ->text()
. Html::element(
'a',
array(
'href' => '',
'class' =>
'wbq-container-mark-as-exception'
),
-
wfMessage('wbqev-violation-mark-as-exception')->text()
+ wfMessage(
'wbqev-violation-mark-as-exception' )->text()
)
. Html::closeElement( 'div' );
- }
- return $message;
- }
+ }
+
+ return $message;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/224640
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I29d8ac3b34e7d59a63c86cd8e39afa589a76086b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/WikibaseQualityExternalValidation
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits