Add failing test for bug 14404.
[lhc/web/wiklou.git] / includes / CategoryPage.php
index c6a7f14..05bc6f3 100644 (file)
@@ -23,11 +23,13 @@ class CategoryPage extends Article {
                $diff = $wgRequest->getVal( 'diff' );
                $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
 
-               if ( isset( $diff ) && $diffOnly )
+               if ( isset( $diff ) && $diffOnly ) {
                        return parent::view();
+               }
 
-               if ( !wfRunHooks( 'CategoryPageView', array( &$this ) ) )
+               if ( !wfRunHooks( 'CategoryPageView', array( &$this ) ) ) {
                        return;
+               }
 
                if ( NS_CATEGORY == $this->mTitle->getNamespace() ) {
                        $this->openShowCategory();
@@ -99,9 +101,8 @@ class CategoryViewer {
         * Format the category data list.
         *
         * @return string HTML output
-        * @private
         */
-       function getHTML() {
+       public function getHTML() {
                global $wgOut, $wgCategoryMagicGallery, $wgContLang;
                wfProfileIn( __METHOD__ );
 
@@ -159,26 +160,27 @@ class CategoryViewer {
        /**
         * Add a subcategory to the internal lists, using a Category object
         */
-       function addSubcategoryObject( $cat, $sortkey, $pageLength ) {
-               $title = $cat->getTitle();
-               $this->addSubcategory( $title, $sortkey, $pageLength );
-       }
-
-       /**
-        * Add a subcategory to the internal lists, using a title object
-        * @deprecated kept for compatibility, please use addSubcategoryObject instead
-        */
-       function addSubcategory( $title, $sortkey, $pageLength ) {
+       function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
                // Subcategory; strip the 'Category' namespace from the link text.
+               $title = $cat->getTitle();
                $this->children[] = $this->getSkin()->link(
                        $title,
-                       null,
+                       $title->getText(),
                        array(),
                        array(),
                        array( 'known', 'noclasses' )
                );
 
-               $this->children_start_char[] = $this->getSubcategorySortChar( $title, $sortkey );
+               $this->children_start_char[] = 
+                       $this->getSubcategorySortChar( $cat->getTitle(), $sortkey );
+       }
+
+       /**
+        * Add a subcategory to the internal lists, using a title object
+        * @deprecated kept for compatibility, please use addSubcategoryObject instead
+        */
+       function addSubcategory( Title $title, $sortkey, $pageLength ) {
+               $this->addSubcategoryObject( Category::newFromTitle( $title ), $sortkey, $pageLength );
        }
 
        /**
@@ -420,10 +422,10 @@ class CategoryViewer {
         */
        function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
                if ( count ( $articles ) > $cutoff ) {
-                       return $this->columnList( $articles, $articles_start_char );
+                       return self::columnList( $articles, $articles_start_char );
                } elseif ( count( $articles ) > 0 ) {
                        // for short lists of articles in categories.
-                       return $this->shortList( $articles, $articles_start_char );
+                       return self::shortList( $articles, $articles_start_char );
                }
                return '';
        }
@@ -443,7 +445,7 @@ class CategoryViewer {
         * @return String
         * @private
         */
-       function columnList( $articles, $articles_start_char ) {
+       static function columnList( $articles, $articles_start_char ) {
                $columns = array_combine( $articles, $articles_start_char );
                # Split into three columns
                $columns = array_chunk( $columns, ceil( count( $columns ) / 3 ), true /* preserve keys */ );
@@ -495,7 +497,7 @@ class CategoryViewer {
         * @return String
         * @private
         */
-       function shortList( $articles, $articles_start_char ) {
+       static function shortList( $articles, $articles_start_char ) {
                $r = '<h3>' . htmlspecialchars( $articles_start_char[0] ) . "</h3>\n";
                $r .= '<ul><li>' . $articles[0] . '</li>';
                for ( $index = 1; $index < count( $articles ); $index++ )
@@ -587,8 +589,8 @@ class CategoryViewer {
 
                # Check if there's a "from" or "until" for anything
                $fromOrUntil = false;
-               foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
-                       if ( $this->from[$type] !== null || $this->until[$type] !== null ) {
+               foreach ( array( 'page', 'subcat', 'file' ) as $t ) {
+                       if ( $this->from[$t] !== null || $this->until[$t] !== null ) {
                                $fromOrUntil = true;
                                break;
                        }