IAlex has uploaded a new change for review.
https://gerrit.wikimedia.org/r/59820
Change subject: Move list generation out of TablePager::getLimitSelect()
......................................................................
Move list generation out of TablePager::getLimitSelect()
Added TablePager::getLimitSelectList() to get the list of values to
show for the drop-down so that it can be used to generate a custom
<select> or to be used on a form generated with HTMLForm.
Also changed HTML generation to use XmlSelect class.
Change-Id: I13ac9f17c95445b04f3cf6feec6ae36f0b9cb03d
---
M includes/Pager.php
1 file changed, 16 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/20/59820/1
diff --git a/includes/Pager.php b/includes/Pager.php
index 56b5d48..1219552 100644
--- a/includes/Pager.php
+++ b/includes/Pager.php
@@ -1156,13 +1156,26 @@
* @return String: HTML fragment
*/
public function getLimitSelect() {
+ $select = new XmlSelect( 'limit', false, $this->mLimit );
+ $select->addOptions( $this->getLimitSelectList() );
+ return $select->getHTML();
+ }
+
+ /**
+ * Get a list of items to show in a "<select>" element of limits.
+ * This can be passed directly to XmlSelect::addOptions().
+ *
+ * @since 1.22
+ * @return array
+ */
+ public function getLimitSelectList() {
# Add the current limit from the query string
# to avoid that the limit is lost after clicking Go next time
if ( !in_array( $this->mLimit, $this->mLimitsShown ) ) {
$this->mLimitsShown[] = $this->mLimit;
sort( $this->mLimitsShown );
}
- $s = Html::openElement( 'select', array( 'name' => 'limit' ) )
. "\n";
+ $ret = array();
foreach ( $this->mLimitsShown as $key => $value ) {
# The pair is either $index => $limit, in which case
the $value
# will be numeric, or $limit => $text, in which case
the $value
@@ -1174,10 +1187,9 @@
$limit = $key;
$text = $value;
}
- $s .= Xml::option( $text, $limit, $limit ==
$this->mLimit ) . "\n";
+ $ret[$text] = $limit;
}
- $s .= Html::closeElement( 'select' );
- return $s;
+ return $ret;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/59820
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I13ac9f17c95445b04f3cf6feec6ae36f0b9cb03d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: IAlex <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits