Matmarex has uploaded a new change for review.
https://gerrit.wikimedia.org/r/78463
Change subject: HTMLCheckMatrix: Allow custom input names to be specified
......................................................................
HTMLCheckMatrix: Allow custom input names to be specified
This will allow for non-disruptive migration of preferences which
should be using the matrix layout, but currently don't. Prerequisite
for bug 37878 and bug 51941.
Change-Id: I839d645c5ad6f557bac7d16ec266d1cadf6acb1c
---
M includes/HTMLForm.php
1 file changed, 19 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/63/78463/1
diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php
index e06a934..f18a2df 100644
--- a/includes/HTMLForm.php
+++ b/includes/HTMLForm.php
@@ -1918,6 +1918,21 @@
}
parent::__construct( $params );
}
+
+ /**
+ * Build a tag name for given column and row. By default it is of the
form columnName-rowName, but
+ * can be overriden using the 'custom' parameter.
+ * @param string $columnName
+ * @param string $rowName
+ * @return string
+ */
+ private function buildTag( $columnName, $rowName ) {
+ $tag = $columnName . '-' . $rowName;
+ if ( isset( $this->mParams['custom'][$tag] ) ) {
+ $tag = $this->mParams['custom'][$tag];
+ }
+ return $tag;
+ }
function validate( $value, $alldata ) {
$rows = $this->mParams['rows'];
@@ -1939,7 +1954,7 @@
$validOptions = array();
foreach ( $rows as $rowTag ) {
foreach ( $columns as $columnTag ) {
- $validOptions[] = $columnTag . '-' . $rowTag;
+ $validOptions[] = $this->buildTag( $columnTag,
$rowTag );
}
}
$validValues = array_intersect( $value, $validOptions );
@@ -1994,7 +2009,8 @@
}
$rowContents = Html::rawElement( 'td', array(),
$rowLabel );
foreach ( $columns as $columnTag ) {
- $thisTag = "$columnTag-$rowTag";
+ $thisTag = $this->buildTag( $columnTag, $rowTag
);
+
// Construct the checkbox
$thisAttribs = array(
'id' => "{$this->mID}-$thisTag",
@@ -2106,7 +2122,7 @@
foreach ( $columns as $column ) {
foreach ( $rows as $row ) {
// Make sure option hasn't been forced
- $thisTag = "$column-$row";
+ $thisTag = $this->buildTag( $column, $row );
if ( $this->isTagForcedOff( $thisTag ) ) {
$res[$thisTag] = false;
} elseif ( $this->isTagForcedOn( $thisTag ) ) {
--
To view, visit https://gerrit.wikimedia.org/r/78463
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I839d645c5ad6f557bac7d16ec266d1cadf6acb1c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Matmarex <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits