X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialPrefixindex.php;h=f10a979922d1b9d6460e5fcbeb11136da63a7536;hp=d92010a4b86f48ff5ed444eff4996b383235c82c;hb=0968cce3f78b81dc32b0db097b5a6a61fffc5ce9;hpb=c54766586acab549f186e81eeab259845112809d diff --git a/includes/specials/SpecialPrefixindex.php b/includes/specials/SpecialPrefixindex.php index d92010a4b8..f10a979922 100644 --- a/includes/specials/SpecialPrefixindex.php +++ b/includes/specials/SpecialPrefixindex.php @@ -36,9 +36,6 @@ class SpecialPrefixindex extends SpecialAllPages { protected $hideRedirects = false; - // number of columns in output table - protected $columns = 3; - // Inherit $maxPerPage function __construct() { @@ -66,7 +63,6 @@ class SpecialPrefixindex extends SpecialAllPages { $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( @@ -205,11 +201,11 @@ class SpecialPrefixindex extends SpecialAllPages { ) ); - # ## @todo FIXME: Side link to previous + // @todo FIXME: Side link to previous $n = 0; if ( $res->numRows() > 0 ) { - $out = Xml::openElement( 'table', array( 'class' => 'mw-prefixindex-list-table' ) ); + $out = Html::openElement( 'ul', array( 'class' => 'mw-prefixindex-list' ) ); $prefixLength = strlen( $prefix ); while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { @@ -230,75 +226,72 @@ class SpecialPrefixindex extends SpecialAllPages { } else { $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; } - if ( $n % $this->columns == 0 ) { - $out .= ''; - } - $out .= "$link"; + + $out .= "
  • $link
  • \n"; $n++; - if ( $n % $this->columns == 0 ) { - $out .= ''; - } - } - if ( $n % $this->columns != 0 ) { - $out .= ''; } + $out .= Html::closeElement( 'ul' ); - $out .= Xml::closeElement( 'table' ); + if ( $res->numRows() > 2 ) { + // Only apply CSS column styles if there's more than 2 entries. + // Otherwise rendering is broken as "mw-prefixindex-body"'s CSS column count is 3. + $out = Html::rawElement( 'div', array( 'class' => 'mw-prefixindex-body' ), $out ); + } } else { $out = ''; } } - $footer = ''; - if ( $this->including() ) { - $out2 = ''; - } else { - $nsForm = $this->namespacePrefixForm( $namespace, $prefix ); - $self = $this->getPageTitle(); - $out2 = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-nav-table' ) ) . - ' - ' . - $nsForm . - ' - '; - - if ( $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { - $query = array( - 'from' => $s->page_title, - 'prefix' => $prefix, - 'hideredirects' => $this->hideRedirects, - 'stripprefix' => $this->stripPrefix, - 'columns' => $this->columns, - ); + $output = $this->getOutput(); - if ( $namespace || $prefix == '' ) { - // Keep the namespace even if it's 0 for empty prefixes. - // This tells us we're not just a holdover from old links. - $query['namespace'] = $namespace; - } + if ( $this->including() ) { + // We don't show the nav-links and the form when included into other + // pages so let's just finish here. + $output->addHTML( $out ); + return; + } - $nextLink = Linker::linkKnown( - $self, - $this->msg( 'nextpage', str_replace( '_', ' ', $s->page_title ) )->escaped(), - array(), - $query - ); + $topOut = $this->namespacePrefixForm( $namespace, $prefix ); - $out2 .= $nextLink; + if ( $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { + $query = array( + 'from' => $s->page_title, + 'prefix' => $prefix, + 'hideredirects' => $this->hideRedirects, + 'stripprefix' => $this->stripPrefix, + ); - $footer = "\n" . Html::element( 'hr' ) . - Html::rawElement( - 'div', - array( 'class' => 'mw-prefixindex-nav' ), - $nextLink - ); + if ( $namespace || $prefix == '' ) { + // Keep the namespace even if it's 0 for empty prefixes. + // This tells us we're not just a holdover from old links. + $query['namespace'] = $namespace; } - $out2 .= "" . - Xml::closeElement( 'table' ); + + $nextLink = Linker::linkKnown( + $this->getPageTitle(), + $this->msg( 'nextpage', str_replace( '_', ' ', $s->page_title ) )->escaped(), + array(), + $query + ); + + // Link shown at the top of the page below the form + $topOut .= Html::rawElement( 'div', + array( 'class' => 'mw-prefixindex-nav' ), + $nextLink + ); + + // Link shown at the footer + $out .= "\n" . Html::element( 'hr' ) . + Html::rawElement( + 'div', + array( 'class' => 'mw-prefixindex-nav' ), + $nextLink + ); + } - $this->getOutput()->addHTML( $out2 . $out . $footer ); + $output->addHTML( $topOut . $out ); } protected function getGroupName() {