diff options
Diffstat (limited to 'includes/CategoryPage.php')
-rw-r--r-- | includes/CategoryPage.php | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index 356f9ea2..76a388a6 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -90,6 +90,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 +106,7 @@ class CategoryViewer { $this->children_start_char = array(); if( $this->showGallery ) { $this->gallery = new ImageGallery(); - $this->gallery->setParsing(); + $this->gallery->setHideBadImages(); } } @@ -147,7 +152,7 @@ class CategoryViewer { /** * Add a page in the image namespace */ - function addImage( $title, $sortkey, $pageLength ) { + function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) { if ( $this->showGallery ) { $image = new Image( $title ); if( $this->flip ) { @@ -156,18 +161,18 @@ class CategoryViewer { $this->gallery->add( $image ); } } else { - $this->addPage( $title, $sortkey, $pageLength ); + $this->addPage( $title, $sortkey, $pageLength, $isRedirect ); } } /** * Add a miscellaneous page */ - function addPage( $title, $sortkey, $pageLength ) { + function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) { global $wgContLang; - $this->articles[] = $this->getSkin()->makeSizeLinkObj( - $pageLength, $title, $wgContLang->convert( $title->getPrefixedText() ) - ); + $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 ) ); } @@ -194,7 +199,7 @@ class CategoryViewer { } $res = $dbr->select( array( 'page', 'categorylinks' ), - array( 'page_title', 'page_namespace', 'page_len', 'cl_sortkey' ), + array( 'page_title', 'page_namespace', 'page_len', 'page_is_redirect', 'cl_sortkey' ), array( $pageCondition, 'cl_from = page_id', 'cl_to' => $this->title->getDBKey()), @@ -219,23 +224,25 @@ class CategoryViewer { if( $title->getNamespace() == NS_CATEGORY ) { $this->addSubcategory( $title, $x->cl_sortkey, $x->page_len ); - } elseif( $title->getNamespace() == NS_IMAGE ) { - $this->addImage( $title, $x->cl_sortkey, $x->page_len ); + } elseif( $this->showGallery && $title->getNamespace() == NS_IMAGE ) { + $this->addImage( $title, $x->cl_sortkey, $x->page_len, $x->page_is_redirect ); } else { - $this->addPage( $title, $x->cl_sortkey, $x->page_len ); + $this->addPage( $title, $x->cl_sortkey, $x->page_len, $x->page_is_redirect ); } } $dbr->freeResult( $res ); } 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() { @@ -352,7 +359,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]; } @@ -423,4 +430,4 @@ class CategoryViewer { } -?> + |