Merge "Add columns option to Special:PrefixIndex"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 13 Apr 2014 22:40:58 +0000 (22:40 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 13 Apr 2014 22:40:58 +0000 (22:40 +0000)
1  2 
includes/specials/SpecialPrefixindex.php

@@@ -36,6 -36,9 +36,9 @@@ class SpecialPrefixindex extends Specia
  
        protected $hideRedirects = false;
  
+       // number of columns in output table
+       protected $columns = 3;
        // Inherit $maxPerPage
  
        function __construct() {
                $namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN).
                $this->hideRedirects = $request->getBool( 'hideredirects', $this->hideRedirects );
                $this->stripPrefix = $request->getBool( 'stripprefix', $this->stripPrefix );
+               $this->columns = $request->getInt( 'columns', $this->columns );
  
                $namespaces = $wgContLang->getNamespaces();
                $out->setPageTitle(
 -                      ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) )
 +                      ( $namespace > 0 && array_key_exists( $namespace, $namespaces ) )
                                ? $this->msg( 'prefixindex-namespace', str_replace( '_', ' ', $namespaces[$namespace] ) )
                                : $this->msg( 'prefixindex' )
                );
  
                if ( !$prefixList || !$fromList ) {
                        $out = $this->msg( 'allpagesbadtitle' )->parseAsBlock();
 -              } elseif ( !in_array( $namespace, array_keys( $namespaces ) ) ) {
 +              } elseif ( !array_key_exists( $namespace, $namespaces ) ) {
                        // Show errormessage and reset to NS_MAIN
                        $out = $this->msg( 'allpages-bad-ns', $namespace )->parse();
                        $namespace = NS_MAIN;
  
                        $n = 0;
                        if ( $res->numRows() > 0 ) {
 -                              $out = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-list-table' ) );
 +                              $out = Xml::openElement( 'table', array( 'class' => 'mw-prefixindex-list-table' ) );
  
                                $prefixLength = strlen( $prefix );
                                while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
                                        } else {
                                                $link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
                                        }
-                                       if ( $n % 3 == 0 ) {
+                                       if ( $n % $this->columns == 0 ) {
                                                $out .= '<tr>';
                                        }
                                        $out .= "<td>$link</td>";
                                        $n++;
-                                       if ( $n % 3 == 0 ) {
+                                       if ( $n % $this->columns == 0 ) {
                                                $out .= '</tr>';
                                        }
                                }
  
-                               if ( $n % 3 != 0 ) {
+                               if ( $n % $this->columns != 0 ) {
                                        $out .= '</tr>';
                                }
  
                                        'prefix' => $prefix,
                                        'hideredirects' => $this->hideRedirects,
                                        'stripprefix' => $this->stripPrefix,
+                                       'columns' => $this->columns,
                                );
  
                                if ( $namespace || $prefix == '' ) {