X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FCategoryViewer.php;h=60694c95e3ac5f87aebdd2fa984bce880d6396f6;hb=1bb93ae45ab6fefd269b1be1c1dab13077aec320;hp=d6755c2f48814b707a79cba2e31a8802b0c234b9;hpb=e219e90fda3dc29e421e74b7fd5085e87f7155ef;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index d6755c2f48..60694c95e3 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -54,6 +54,9 @@ class CategoryViewer extends ContextSource { /** @var array */ protected $nextPage; + /** @var array */ + protected $prevPage; + /** @var array */ protected $flip; @@ -84,12 +87,11 @@ class CategoryViewer extends ContextSource { function __construct( $title, IContextSource $context, $from = array(), $until = array(), $query = array() ) { - global $wgCategoryPagingLimit; $this->title = $title; $this->setContext( $context ); $this->from = $from; $this->until = $until; - $this->limit = $wgCategoryPagingLimit; + $this->limit = $context->getConfig()->get( 'CategoryPagingLimit' ); $this->cat = Category::newFromTitle( $title ); $this->query = $query; $this->collation = Collation::singleton(); @@ -102,10 +104,10 @@ class CategoryViewer extends ContextSource { * @return string HTML output */ public function getHTML() { - global $wgCategoryMagicGallery; wfProfileIn( __METHOD__ ); - $this->showGallery = $wgCategoryMagicGallery && !$this->getOutput()->mNoGallery; + $this->showGallery = $this->getConfig()->get( 'CategoryMagicGallery' ) + && !$this->getOutput()->mNoGallery; $this->clearCategoryState(); $this->doCategoryQuery(); @@ -151,14 +153,13 @@ class CategoryViewer extends ContextSource { // Note that null for mode is taken to mean use default. $mode = $this->getRequest()->getVal( 'gallerymode', null ); try { - $this->gallery = ImageGalleryBase::factory( $mode ); + $this->gallery = ImageGalleryBase::factory( $mode, $this->getContext() ); } catch ( MWException $e ) { // User specified something invalid, fallback to default. - $this->gallery = ImageGalleryBase::factory(); + $this->gallery = ImageGalleryBase::factory( false, $this->getContext() ); } $this->gallery->setHideBadImages(); - $this->gallery->setContext( $this->getContext() ); } else { $this->imgsNoGallery = array(); $this->imgsNoGallery_start_char = array(); @@ -288,6 +289,12 @@ class CategoryViewer extends ContextSource { 'subcat' => null, 'file' => null, ); + $this->prevPage = array( + 'page' => null, + 'subcat' => null, + 'file' => null, + ); + $this->flip = array( 'page' => false, 'subcat' => false, 'file' => false ); foreach ( array( 'page', 'subcat', 'file' ) as $type ) { @@ -344,6 +351,9 @@ class CategoryViewer extends ContextSource { $this->nextPage[$type] = $humanSortkey; break; } + if ( $count == $this->limit ) { + $this->prevPage[$type] = $humanSortkey; + } if ( $title->getNamespace() == NS_CATEGORY ) { $cat = Category::newFromRow( $row, $title ); @@ -458,7 +468,17 @@ class CategoryViewer extends ContextSource { */ private function getSectionPagingLinks( $type ) { if ( isset( $this->until[$type] ) && $this->until[$type] !== null ) { - return $this->pagingLinks( $this->nextPage[$type], $this->until[$type], $type ); + // The new value for the until parameter should be pointing to the first + // result displayed on the page which is the second last result retrieved + // from the database.The next link should have a from parameter pointing + // to the until parameter of the current page. + if ( $this->nextPage[$type] !== null ) { + return $this->pagingLinks( $this->prevPage[$type], $this->until[$type], $type ); + } else { + // If the nextPage variable is null, it means that we have reached the first page + // and therefore the previous link should be disabled. + return $this->pagingLinks( null, $this->until[$type], $type ); + } } elseif ( $this->nextPage[$type] !== null || ( isset( $this->from[$type] ) && $this->from[$type] !== null ) ) {