* @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
$limit = $key;
$text = $value;
}
- $s .= Xml::option( $text, $limit, $limit == $this->mLimit ) . "\n";
+ $ret[$text] = $limit;
}
- $s .= Html::closeElement( 'select' );
- return $s;
+ return $ret;
}
/**