diff options
author | Glaisher <glaisher.wiki@gmail.com> | 2015-11-09 21:50:53 +0500 |
---|---|---|
committer | Glaisher <glaisher.wiki@gmail.com> | 2015-11-09 22:28:37 +0500 |
commit | 0968cce3f78b81dc32b0db097b5a6a61fffc5ce9 (patch) | |
tree | ad715e33148462afc0acb665ab2f9f2bc8e02747 /includes/specials | |
parent | cfdf523008736d6ec9b8a7b512ea7f204ac54afb (diff) | |
download | mediawikicore-0968cce3f78b81dc32b0db097b5a6a61fffc5ce9.tar.gz mediawikicore-0968cce3f78b81dc32b0db097b5a6a61fffc5ce9.zip |
Don't apply CSS columns if less than 3 results were found on AllPages & PrefixIndex
If there are less than 3 entries, the browser still tries to render as it would
appear as if there are 3 columns, so the final rendering is broken. So don't apply
CSS columns and just show a normal list if there are less than 3 results. This also
matches the behavior of CategoryViewer.
Bug: T117887
Change-Id: Ie6ac0e1174ff8cc14008f39a91c95bcd6f616353
Diffstat (limited to 'includes/specials')
-rw-r--r-- | includes/specials/SpecialAllPages.php | 10 | ||||
-rw-r--r-- | includes/specials/SpecialPrefixindex.php | 12 |
2 files changed, 15 insertions, 7 deletions
diff --git a/includes/specials/SpecialAllPages.php b/includes/specials/SpecialAllPages.php index 244627008577..190fe8f739b2 100644 --- a/includes/specials/SpecialAllPages.php +++ b/includes/specials/SpecialAllPages.php @@ -205,8 +205,7 @@ class SpecialAllPages extends IncludableSpecialPage { ); if ( $res->numRows() > 0 ) { - $out = Html::openElement( 'div', array( 'class' => 'mw-allpages-body' ) ); - $out .= Html::openElement( 'ul', array( 'class' => 'mw-allpages-chunk' ) ); + $out = Html::openElement( 'ul', array( 'class' => 'mw-allpages-chunk' ) ); while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { $t = Title::newFromRow( $s ); @@ -222,7 +221,12 @@ class SpecialAllPages extends IncludableSpecialPage { $n++; } $out .= Html::closeElement( 'ul' ); - $out .= Html::closeElement( 'div' ); + + if ( $res->numRows() > 2 ) { + // Only apply CSS column styles if there's more than 2 entries. + // Otherwise, rendering is broken as "mw-allpages-body"'s CSS column count is 3. + $out = Html::rawElement( 'div', array( 'class' => 'mw-allpages-body' ), $out ); + } } else { $out = ''; } diff --git a/includes/specials/SpecialPrefixindex.php b/includes/specials/SpecialPrefixindex.php index fbe5ab39eafc..f10a979922d1 100644 --- a/includes/specials/SpecialPrefixindex.php +++ b/includes/specials/SpecialPrefixindex.php @@ -205,8 +205,7 @@ class SpecialPrefixindex extends SpecialAllPages { $n = 0; if ( $res->numRows() > 0 ) { - $out = Html::openElement( 'div', array( 'class' => 'mw-prefixindex-body' ) ); - $out .= Html::openElement( 'ul', array( 'class' => 'mw-prefixindex-list' ) ); + $out = Html::openElement( 'ul', array( 'class' => 'mw-prefixindex-list' ) ); $prefixLength = strlen( $prefix ); while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { @@ -228,12 +227,17 @@ class SpecialPrefixindex extends SpecialAllPages { $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; } - $out .= "<li> $link </li>\n"; + $out .= "<li>$link</li>\n"; $n++; } $out .= Html::closeElement( 'ul' ); - $out .= Html::closeElement( 'div' ); + + 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 = ''; } |