MediaWiki REL1_40
PrevNextNavigationRenderer.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Navigation;
22
25
33
37 private $messageLocalizer;
38
42 public function __construct( MessageLocalizer $messageLocalizer ) {
43 wfDeprecated( __CLASS__, '1.39' );
44 $this->messageLocalizer = $messageLocalizer;
45 }
46
58 public function buildPrevNextNavigation(
60 $offset,
61 $limit,
62 array $query = [],
63 $atend = false
64 ) {
65 $navBuilder = new PagerNavigationBuilder( $this->messageLocalizer );
66 $navBuilder
67 ->setPage( $title )
68 ->setLinkQuery( [ 'limit' => $limit, 'offset' => $offset ] + $query )
69 ->setLimitLinkQueryParam( 'limit' )
70 ->setCurrentLimit( $limit )
71 ->setPrevTooltipMsg( 'prevn-title' )
72 ->setNextTooltipMsg( 'nextn-title' )
73 ->setLimitTooltipMsg( 'shown-title' );
74
75 if ( $offset > 0 ) {
76 $navBuilder->setPrevLinkQuery( [ 'offset' => (string)max( $offset - $limit, 0 ) ] );
77 }
78 if ( !$atend ) {
79 $navBuilder->setNextLinkQuery( [ 'offset' => (string)( $offset + $limit ) ] );
80 }
81
82 return $navBuilder->getHtml();
83 }
84}
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
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:82
Interface for localizing messages in MediaWiki.