Localisation updates from https://translatewiki.net.
[lhc/web/wiklou.git] / includes / CategoryViewer.php
index b912603..8dd3f5c 100644 (file)
@@ -138,9 +138,13 @@ class CategoryViewer extends ContextSource {
                }
 
                $lang = $this->getLanguage();
-               $langAttribs = [ 'lang' => $lang->getHtmlCode(), 'dir' => $lang->getDir() ];
+               $attribs = [
+                       'class' => 'mw-category-generated',
+                       'lang' => $lang->getHtmlCode(),
+                       'dir' => $lang->getDir()
+               ];
                # put a div around the headings which are in the user language
-               $r = Html::openElement( 'div', $langAttribs ) . $r . '</div>';
+               $r = Html::openElement( 'div', $attribs ) . $r . '</div>';
 
                return $r;
        }
@@ -387,6 +391,7 @@ class CategoryViewer extends ContextSource {
                $r = '';
                $rescnt = count( $this->children );
                $dbcnt = $this->cat->getSubcatCount();
+               // This function should be called even if the result isn't used, it has side-effects
                $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' );
 
                if ( $rescnt > 0 ) {
@@ -417,6 +422,7 @@ class CategoryViewer extends ContextSource {
                $dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
                        - $this->cat->getFileCount();
                $rescnt = count( $this->articles );
+               // This function should be called even if the result isn't used, it has side-effects
                $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' );
 
                if ( $rescnt > 0 ) {
@@ -437,10 +443,11 @@ class CategoryViewer extends ContextSource {
        function getImageSection() {
                $r = '';
                $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
-               if ( $rescnt > 0 ) {
-                       $dbcnt = $this->cat->getFileCount();
-                       $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
+               $dbcnt = $this->cat->getFileCount();
+               // This function should be called even if the result isn't used, it has side-effects
+               $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
 
+               if ( $rescnt > 0 ) {
                        $r .= "<div id=\"mw-category-media\">\n";
                        $r .= '<h2>' .
                                $this->msg(
@@ -525,17 +532,17 @@ class CategoryViewer extends ContextSource {
        }
 
        /**
-        * Format a list of articles chunked by letter in a three-column
-        * list, ordered vertically.
+        * Format a list of articles chunked by letter in a three-column list, ordered
+        * vertically. This is used for categories with a significant number of pages.
         *
         * TODO: Take the headers into account when creating columns, so they're
         * more visually equal.
         *
         * TODO: shortList and columnList are similar, need merging
         *
-        * @param array $articles
-        * @param string[] $articles_start_char
-        * @return string
+        * @param string[] $articles HTML links to each article
+        * @param string[] $articles_start_char The header characters for each article
+        * @return string HTML to output
         * @private
         */
        static function columnList( $articles, $articles_start_char ) {
@@ -572,10 +579,11 @@ class CategoryViewer extends ContextSource {
        }
 
        /**
-        * Format a list of articles chunked by letter in a bullet list.
-        * @param array $articles
-        * @param string[] $articles_start_char
-        * @return string
+        * Format a list of articles chunked by letter in a bullet list. This is used
+        * for categories with a small number of pages (when columns aren't needed).
+        * @param string[] $articles HTML links to each article
+        * @param string[] $articles_start_char The header characters for each article
+        * @return string HTML to output
         * @private
         */
        static function shortList( $articles, $articles_start_char ) {