MediaWiki  master
AlphabeticPager.php
Go to the documentation of this file.
1 <?php
29 abstract class AlphabeticPager extends IndexPager {
30 
39  public function getNavigationBar() {
40  if ( !$this->isNavigationBarShown() ) {
41  return '';
42  }
43 
44  if ( isset( $this->mNavigationBar ) ) {
45  return $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
69  return $this->mNavigationBar;
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 
97  return $this->mNavigationBar;
98  }
99 
110  protected function getOrderTypeMessages() {
111  return null;
112  }
113 }
AlphabeticPager\getOrderTypeMessages
getOrderTypeMessages()
If this supports multiple order type messages, give the message key for enabling each one in getNavig...
Definition: AlphabeticPager.php:110
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:37
AlphabeticPager
IndexPager with an alphabetic list and a formatted navigation bar Stable for subclassing.
Definition: AlphabeticPager.php:29
IndexPager\$mNavigationBar
string $mNavigationBar
Definition: IndexPager.php:151
IndexPager\makeLink
makeLink( $text, array $query=null, $type=null)
Make a self-link.
Definition: IndexPager.php:632
AlphabeticPager\getNavigationBar
getNavigationBar()
Shamelessly stolen bits from ReverseChronologicalPager, didn't want to do class magic as may be still...
Definition: AlphabeticPager.php:39
IndexPager\getLimitLinks
getLimitLinks()
Definition: IndexPager.php:825
IndexPager\getIndexField
getIndexField()
Returns the name of the index field.
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:140
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:184
IndexPager\isNavigationBarShown
isNavigationBarShown()
Returns whether to show the "navigation bar" @stable for overriding.
Definition: IndexPager.php:786
IndexPager
IndexPager is an efficient pager which uses a (roughly unique) index in the data set to implement pag...
Definition: IndexPager.php:74
IndexPager\getPagingLinks
getPagingLinks( $linkTexts, $disabledTexts=[])
Get paging links.
Definition: IndexPager.php:804