From 11dc93627e7ebe2479e515d4589fd5a0d1e37813 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Mon, 17 Jan 2011 01:16:00 +0000 Subject: [PATCH] (bug 26737; follow-up r70415) Make new category stuff play nice with __NOGALLERY__ This changes it so non-gallery cat pages with images, put the images in a list (like the other sections), but in its own section, instead of as part of the pages section like it used to be. --- includes/CategoryPage.php | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index cb469d2857..7c1bea5935 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -89,6 +89,7 @@ class CategoryViewer { $articles, $articles_start_char, $children, $children_start_char, $showGallery, $gallery, + $imgsNoGalley, $imgsNoGallery_start_char, $skin; # Category object for this page private $cat; @@ -155,6 +156,9 @@ class CategoryViewer { if ( $this->showGallery ) { $this->gallery = new ImageGallery(); $this->gallery->setHideBadImages(); + } else { + $this->imgsNoGallery = array(); + $this->imgsNoGallery_start_char = array(); } } @@ -217,6 +221,7 @@ class CategoryViewer { * Add a page in the image namespace */ function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) { + global $wgContLang; if ( $this->showGallery ) { $flip = $this->flip['file']; if ( $flip ) { @@ -225,7 +230,18 @@ class CategoryViewer { $this->gallery->add( $title ); } } else { - $this->addPage( $title, $sortkey, $pageLength, $isRedirect ); + $this->imgsNoGallery[] = $isRedirect + ? '' . + $this->getSkin()->link( + $title, + null, + array(), + array(), + array( 'known', 'noclasses' ) + ) . '' + : $this->getSkin()->link( $title ); + + $this->imgsNoGallery_start_char[] = $wgContLang->convert( $wgContLang->firstLetterForLists( $sortkey ) ); } } @@ -257,6 +273,10 @@ class CategoryViewer { $this->articles = array_reverse( $this->articles ); $this->articles_start_char = array_reverse( $this->articles_start_char ); } + if ( !$this->showGallery && $this->flip['file'] ) { + $this->imgsNoGallery = array_reverse( $this->imgsNoGallery ); + $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char ); + } } function doCategoryQuery() { @@ -318,7 +338,7 @@ class CategoryViewer { if ( $title->getNamespace() == NS_CATEGORY ) { $cat = Category::newFromRow( $row, $title ); $this->addSubcategoryObject( $cat, $rawSortkey, $row->page_len ); - } elseif ( $this->showGallery && $title->getNamespace() == NS_FILE ) { + } elseif ( $title->getNamespace() == NS_FILE ) { $this->addImage( $title, $rawSortkey, $row->page_len, $row->page_is_redirect ); } else { $this->addPage( $title, $rawSortkey, $row->page_len, $row->page_is_redirect ); @@ -382,16 +402,20 @@ class CategoryViewer { function getImageSection() { $r = ''; - if ( $this->showGallery && ! $this->gallery->isEmpty() ) { + $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery ); + if ( $rescnt > 0 ) { $dbcnt = $this->cat->getFileCount(); - $rescnt = $this->gallery->count(); $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' ); $r .= "
\n"; $r .= '

' . wfMsg( 'category-media-header', htmlspecialchars( $this->title->getText() ) ) . "

\n"; $r .= $countmsg; $r .= $this->getSectionPagingLinks( 'file' ); - $r .= $this->gallery->toHTML(); + if ( $this->showGallery ) { + $r .= $this->gallery->toHTML(); + } else { + $r .= $this->formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char ); + } $r .= $this->getSectionPagingLinks( 'file' ); $r .= "\n
"; } @@ -594,7 +618,7 @@ class CategoryViewer { # know the right figure. # 3) We have no idea. $totalrescnt = count( $this->articles ) + count( $this->children ) + - ( $this->showGallery ? $this->gallery->count() : 0 ); + ( $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery ) ); # Check if there's a "from" or "until" for anything $fromOrUntil = false; -- 2.20.1