MediaWiki REL1_35
AlphabeticPager.php
Go to the documentation of this file.
1<?php
29abstract class AlphabeticPager extends IndexPager {
30
39 public function getNavigationBar() {
40 if ( !$this->isNavigationBarShown() ) {
41 return '';
42 }
43
44 if ( isset( $this->mNavigationBar ) ) {
46 }
47
48 $linkTexts = [
49 'prev' => $this->msg( 'prevn' )->numParams( $this->mLimit )->escaped(),
50 'next' => $this->msg( 'nextn' )->numParams( $this->mLimit )->escaped(),
51 'first' => $this->msg( 'page_first' )->escaped(),
52 'last' => $this->msg( 'page_last' )->escaped()
53 ];
54
55 $lang = $this->getLanguage();
56
57 $pagingLinks = $this->getPagingLinks( $linkTexts );
58 $limitLinks = $this->getLimitLinks();
59 $limits = $lang->pipeList( $limitLinks );
60
61 $this->mNavigationBar = $this->msg( 'parentheses' )->rawParams(
62 $lang->pipeList( [ $pagingLinks['first'],
63 $pagingLinks['last'] ] ) )->escaped() . " " .
64 $this->msg( 'viewprevnext' )->rawParams( $pagingLinks['prev'],
65 $pagingLinks['next'], $limits )->escaped();
66
67 if ( !is_array( $this->getIndexField() ) ) {
68 # Early return to avoid undue nesting
70 }
71
72 $extra = '';
73 $first = true;
74 $msgs = $this->getOrderTypeMessages();
75 foreach ( array_keys( $msgs ) as $order ) {
76 if ( $first ) {
77 $first = false;
78 } else {
79 $extra .= $this->msg( 'pipe-separator' )->escaped();
80 }
81
82 if ( $order == $this->mOrderType ) {
83 $extra .= $this->msg( $msgs[$order] )->escaped();
84 } else {
85 $extra .= $this->makeLink(
86 $this->msg( $msgs[$order] )->escaped(),
87 [ 'order' => $order ]
88 );
89 }
90 }
91
92 if ( $extra !== '' ) {
93 $extra = ' ' . $this->msg( 'parentheses' )->rawParams( $extra )->escaped();
94 $this->mNavigationBar .= $extra;
95 }
96
98 }
99
110 protected function getOrderTypeMessages() {
111 return null;
112 }
113}
IndexPager with an alphabetic list and a formatted navigation bar Stable to extend.
getOrderTypeMessages()
If this supports multiple order type messages, give the message key for enabling each one in getNavig...
getNavigationBar()
Shamelessly stolen bits from ReverseChronologicalPager, didn't want to do class magic as may be still...
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
IndexPager is an efficient pager which uses a (roughly unique) index in the data set to implement pag...
makeLink( $text, array $query=null, $type=null)
Make a self-link.
string $mNavigationBar
getPagingLinks( $linkTexts, $disabledTexts=[])
Get paging links.
isNavigationBarShown()
Returns whether to show the "navigation bar" Stable to override.
getIndexField()
Returns the name of the index field.
if(!isset( $args[0])) $lang