Thiemo Mättig (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/352124 )
Change subject: Streamline HTML generation code in SpecialConstraintReport
......................................................................
Streamline HTML generation code in SpecialConstraintReport
"Html::openElement + raw HTML + Html::closeElement" really is the same as
Html::rawElement.
Warning: I'm not sure if it's correct to use Html::rawElement in all these
cases! It might be that some need HTML escaping and must use Html::element
because of this. But if such cases exist they are not introduced by this bug,
and should be fixed in a later one.
Change-Id: I53dbef8ae2e8aa1cdb0d90650499d3cf15b3f536
---
M specials/SpecialConstraintReport.php
1 file changed, 31 insertions(+), 48 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
refs/changes/24/352124/1
diff --git a/specials/SpecialConstraintReport.php
b/specials/SpecialConstraintReport.php
index 65634c7..03d4214 100644
--- a/specials/SpecialConstraintReport.php
+++ b/specials/SpecialConstraintReport.php
@@ -298,12 +298,9 @@
$cssClasses .= ' wbqc-constraintreport-notice-error';
}
- return
- Html::element(
+ return Html::element(
'p',
- [
- 'class' => $cssClasses
- ],
+ [ 'class' => $cssClasses ],
$this->msg( $messageKey )->escaped()
);
}
@@ -312,14 +309,17 @@
* @return string HTML
*/
private function getExplanationText() {
- return
- Html::openElement( 'div', [ 'class' =>
'wbqc-explanation'] )
- . $this->msg(
'wbqc-constraintreport-explanation-part-one' )->escaped()
- . Html::closeElement( 'div' )
+ return Html::rawElement(
+ 'div',
+ [ 'class' => 'wbqc-explanation' ],
+ $this->msg(
'wbqc-constraintreport-explanation-part-one' )->escaped()
+ )
. Html::element( 'br' )
- . Html::openElement( 'div', [ 'class' =>
'wbqc-explanation'] )
- . $this->msg(
'wbqc-constraintreport-explanation-part-two' )->escaped()
- . Html::closeElement( 'div' );
+ . Html::rawElement(
+ 'div',
+ [ 'class' => 'wbqc-explanation' ],
+ $this->msg(
'wbqc-constraintreport-explanation-part-two' )->escaped()
+ );
}
/**
@@ -436,10 +436,11 @@
$this->entityIdLinkFormatter->formatEntityId( $entityId ),
htmlspecialchars(
$entityId->getSerialization() ) );
- return
- Html::openElement( 'h3' )
- . sprintf( '%s %s', $this->msg(
'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
- . Html::closeElement( 'h3' );
+ return Html::rawElement(
+ 'h3',
+ [],
+ sprintf( '%s %s', $this->msg(
'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
+ );
}
/**
@@ -465,12 +466,8 @@
. $count;
}
}
- $summary =
- Html::openElement( 'p' )
- . implode( ', ', $statusElements )
- . Html::closeElement( 'p' );
- return $summary;
+ return Html::rawElement( 'p', [], implode( ', ',
$statusElements ) );
}
/**
@@ -499,26 +496,21 @@
$tooltipIndicator = Html::element(
'span',
- [
- 'class' => 'wbqc-indicator'
- ],
+ [ 'class' => 'wbqc-indicator' ],
$indicator
);
$tooltip = Html::rawElement(
'div',
- [
- 'class' => 'wbqc-tooltip'
- ],
+ [ 'class' => 'wbqc-tooltip' ],
$tooltipContent
);
- return
- Html::openElement(
- 'span'
- )
- . sprintf( '%s %s %s', $content, $tooltipIndicator,
$tooltip )
- . Html::closeElement( 'span' );
+ return Html::rawElement(
+ 'span',
+ [],
+ sprintf( '%s %s %s', $content, $tooltipIndicator,
$tooltip )
+ );
}
/**
@@ -547,22 +539,17 @@
$tooltipIndicator = Html::element(
'span',
- [
- 'class' => 'wbqc-expandable-content-indicator
wbqc-indicator'
- ],
+ [ 'class' => 'wbqc-expandable-content-indicator
wbqc-indicator' ],
$indicator
);
$expandableContent = Html::element(
'div',
- [
- 'class' => 'wbqc-expandable-content'
- ],
+ [ 'class' => 'wbqc-expandable-content' ],
$expandableContent
);
- return
- sprintf( '%s %s %s', $content, $tooltipIndicator,
$expandableContent );
+ return sprintf( '%s %s %s', $content, $tooltipIndicator,
$expandableContent );
}
/**
@@ -577,12 +564,9 @@
private function formatStatus( $status ) {
$messageName = "wbqc-constraintreport-status-" . strtolower(
$status );
- $formattedStatus =
- Html::element(
+ $formattedStatus = Html::element(
'span',
- [
- 'class' => 'wbqc-status wbqc-status-' .
$status
- ],
+ [ 'class' => 'wbqc-status wbqc-status-' .
$status ],
$this->msg( $messageName )->text()
);
@@ -631,8 +615,7 @@
* @return string HTML
*/
private function getClaimLink( EntityId $entityId, PropertyId
$propertyId, $text ) {
- return
- Html::rawElement(
+ return Html::rawElement(
'a',
[
'href' => $this->getClaimUrl(
$entityId, $propertyId ),
--
To view, visit https://gerrit.wikimedia.org/r/352124
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I53dbef8ae2e8aa1cdb0d90650499d3cf15b3f536
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits