MediaWiki REL1_39
PrevNextNavigationRenderer.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Navigation;
22
24use Title;
25
33
37 private $messageLocalizer;
38
42 public function __construct( MessageLocalizer $messageLocalizer ) {
43 $this->messageLocalizer = $messageLocalizer;
44 }
45
57 public function buildPrevNextNavigation(
59 $offset,
60 $limit,
61 array $query = [],
62 $atend = false
63 ) {
64 $navBuilder = new PagerNavigationBuilder( $this->messageLocalizer );
65 $navBuilder
66 ->setPage( $title )
67 ->setLinkQuery( [ 'limit' => $limit, 'offset' => $offset ] + $query )
68 ->setLimitLinkQueryParam( 'limit' )
69 ->setCurrentLimit( $limit )
70 ->setPrevTooltipMsg( 'prevn-title' )
71 ->setNextTooltipMsg( 'nextn-title' )
72 ->setLimitTooltipMsg( 'shown-title' );
73
74 if ( $offset > 0 ) {
75 $navBuilder->setPrevLinkQuery( [ 'offset' => (string)max( $offset - $limit, 0 ) ] );
76 }
77 if ( !$atend ) {
78 $navBuilder->setNextLinkQuery( [ 'offset' => (string)( $offset + $limit ) ] );
79 }
80
81 return $navBuilder->getHtml();
82 }
83}
Build the navigation for a pager, with links to prev/next page, links to change limits,...
Helper class for generating prev/next links for paging.
buildPrevNextNavigation(Title $title, $offset, $limit, array $query=[], $atend=false)
Generate (prev x| next x) (20|50|100...) type links for paging (only suitable when paging by numeric ...
Represents a title within MediaWiki.
Definition Title.php:49
Interface for localizing messages in MediaWiki.