Merge "Move list generation out of TablePager::getLimitSelect()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 26 Apr 2013 15:20:47 +0000 (15:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 26 Apr 2013 15:20:47 +0000 (15:20 +0000)
includes/Pager.php

index d70734c..34df830 100644 (file)
@@ -1162,13 +1162,26 @@ abstract class TablePager extends IndexPager {
         * @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
@@ -1180,10 +1193,9 @@ abstract class TablePager extends IndexPager {
                                $limit = $key;
                                $text = $value;
                        }
-                       $s .= Xml::option( $text, $limit, $limit == $this->mLimit ) . "\n";
+                       $ret[$text] = $limit;
                }
-               $s .= Html::closeElement( 'select' );
-               return $s;
+               return $ret;
        }
 
        /**