Revert revert of setSingleton(), unrelated to broken, accidentally committed code...
[lhc/web/wiklou.git] / includes / CategoryPage.php
index 40c465a..656d316 100644 (file)
@@ -37,6 +37,19 @@ class CategoryPage extends Article {
                }
        }
 
+       /**
+        * This page should not be cached if 'from' or 'until' has been used
+        * @return bool
+        */
+       function isFileCacheable() {
+               global $wgRequest;
+
+               return ( ! Article::isFileCacheable()
+                               || $wgRequest->getVal( 'from' )
+                               || $wgRequest->getVal( 'until' )
+               ) ? false : true;
+       }
+
        function openShowCategory() {
                # For overloading
        }
@@ -90,6 +103,11 @@ class CategoryViewer {
                        $this->getImageSection() .
                        $this->getCategoryBottom();
 
+               // Give a proper message if category is empty
+               if ( $r == '' ) {
+                       $r = wfMsgExt( 'category-empty', array( 'parse' ) );
+               }
+
                wfProfileOut( __METHOD__ );
                return $r;
        }
@@ -101,7 +119,7 @@ class CategoryViewer {
                $this->children_start_char = array();
                if( $this->showGallery ) {
                        $this->gallery = new ImageGallery();
-                       $this->gallery->setParsing();
+                       $this->gallery->setHideBadImages();
                }
        }
 
@@ -165,12 +183,9 @@ class CategoryViewer {
         */
        function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
                global $wgContLang;
-               $link = $this->getSkin()->makeSizeLinkObj( 
-                       $pageLength, $title, $wgContLang->convert( $title->getPrefixedText() ) 
-               );
-               if ($isRedirect)
-                       $link = '<span class="redirect-in-category">'.$link.'</span>';
-               $this->articles[] = $link;
+               $this->articles[] = $isRedirect
+                       ? '<span class="redirect-in-category">' . $this->getSkin()->makeKnownLinkObj( $title ) . '</span>'
+                       : $this->getSkin()->makeSizeLinkObj( $pageLength, $title );
                $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $sortkey ) );
        }
 
@@ -232,13 +247,15 @@ class CategoryViewer {
        }
 
        function getCategoryTop() {
-               $r = "<br style=\"clear:both;\"/>\n";
+               $r = '';
                if( $this->until != '' ) {
                        $r .= $this->pagingLinks( $this->title, $this->nextPage, $this->until, $this->limit );
                } elseif( $this->nextPage != '' || $this->from != '' ) {
                        $r .= $this->pagingLinks( $this->title, $this->from, $this->nextPage, $this->limit );
                }
-               return $r;
+               return $r == ''
+                       ? $r
+                       : "<br style=\"clear:both;\"/>\n" . $r;
        }
 
        function getSubcategorySection() {
@@ -355,7 +372,7 @@ class CategoryViewer {
                                        }
                                        $cont_msg = "";
                                        if ( $articles_start_char[$index] == $prev_start_char )
-                                               $cont_msg = wfMsgHtml('listingcontinuesabbrev');
+                                               $cont_msg = ' ' . wfMsgHtml( 'listingcontinuesabbrev' );
                                        $r .= "<h3>" . htmlspecialchars( $articles_start_char[$index] ) . "$cont_msg</h3>\n<ul>";
                                        $prev_start_char = $articles_start_char[$index];
                                }
@@ -406,7 +423,7 @@ class CategoryViewer {
         * @private
         */
        function pagingLinks( $title, $first, $last, $limit, $query = array() ) {
-               global $wgUser, $wgLang;
+               global $wgLang;
                $sk = $this->getSkin();
                $limitText = $wgLang->formatNum( $limit );