* (bug 18449) Fixed items number per column on category pages when the total is divis...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Thu, 16 Apr 2009 16:31:29 +0000 (16:31 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Thu, 16 Apr 2009 16:31:29 +0000 (16:31 +0000)
RELEASE-NOTES
includes/CategoryPage.php

index 0092726..44c8a48 100644 (file)
@@ -346,6 +346,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 18441) rebuildrecentchanges.inc no longer ignores $wgLogRestrictions
 * (bug 18317) Bolded selections in 1 | 3 | etc days on RecentChanges now use
   <strong> instead of hardcoded styles
+* (bug 18449) Fixed items number per column on category pages when the total is
+  divisible by 3
 
 == API changes in 1.15 ==
 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions
index 4ad2f3c..559f813 100644 (file)
@@ -362,7 +362,8 @@ class CategoryViewer {
         */
        function columnList( $articles, $articles_start_char ) {
                // divide list into three equal chunks
-               $chunk = (int) (count ( $articles ) / 3);
+               $chunk = (int) ( count( $articles ) / 3 );
+               $remaining = count( $articles ) % 3;
 
                // get and display header
                $r = '<table width="100%"><tr valign="top">';
@@ -370,9 +371,9 @@ class CategoryViewer {
                $prev_start_char = 'none';
 
                // loop through the chunks
-               for($startChunk = 0, $endChunk = $chunk, $chunkIndex = 0;
+               for( $startChunk = 0, $endChunk = $chunk, $chunkIndex = 0;
                        $chunkIndex < 3;
-                       $chunkIndex++, $startChunk = $endChunk, $endChunk += $chunk + 1)
+                       $chunkIndex++, $startChunk = $endChunk, $endChunk += $remaining == 0 ? $chunk : $chunk + 1 )
                {
                        $r .= "<td>\n";
                        $atColumnTop = true;