MediaWiki  master
AlphabeticPager.php
Go to the documentation of this file.
1 <?php
28 abstract class AlphabeticPager extends IndexPager {
29 
36  public function getNavigationBar() {
37  if ( !$this->isNavigationBarShown() ) {
38  return '';
39  }
40 
41  if ( isset( $this->mNavigationBar ) ) {
42  return $this->mNavigationBar;
43  }
44 
45  $linkTexts = [
46  'prev' => $this->msg( 'prevn' )->numParams( $this->mLimit )->escaped(),
47  'next' => $this->msg( 'nextn' )->numParams( $this->mLimit )->escaped(),
48  'first' => $this->msg( 'page_first' )->escaped(),
49  'last' => $this->msg( 'page_last' )->escaped()
50  ];
51 
52  $lang = $this->getLanguage();
53 
54  $pagingLinks = $this->getPagingLinks( $linkTexts );
55  $limitLinks = $this->getLimitLinks();
56  $limits = $lang->pipeList( $limitLinks );
57 
58  $this->mNavigationBar = $this->msg( 'parentheses' )->rawParams(
59  $lang->pipeList( [ $pagingLinks['first'],
60  $pagingLinks['last'] ] ) )->escaped() . " " .
61  $this->msg( 'viewprevnext' )->rawParams( $pagingLinks['prev'],
62  $pagingLinks['next'], $limits )->escaped();
63 
64  if ( !is_array( $this->getIndexField() ) ) {
65  # Early return to avoid undue nesting
66  return $this->mNavigationBar;
67  }
68 
69  $extra = '';
70  $first = true;
71  $msgs = $this->getOrderTypeMessages();
72  foreach ( array_keys( $msgs ) as $order ) {
73  if ( $first ) {
74  $first = false;
75  } else {
76  $extra .= $this->msg( 'pipe-separator' )->escaped();
77  }
78 
79  if ( $order == $this->mOrderType ) {
80  $extra .= $this->msg( $msgs[$order] )->escaped();
81  } else {
82  $extra .= $this->makeLink(
83  $this->msg( $msgs[$order] )->escaped(),
84  [ 'order' => $order ]
85  );
86  }
87  }
88 
89  if ( $extra !== '' ) {
90  $extra = ' ' . $this->msg( 'parentheses' )->rawParams( $extra )->escaped();
91  $this->mNavigationBar .= $extra;
92  }
93 
94  return $this->mNavigationBar;
95  }
96 
105  protected function getOrderTypeMessages() {
106  return null;
107  }
108 }
getIndexField()
This function should be overridden to return the name of the index fi- eld.
if(!isset( $args[0])) $lang
IndexPager with an alphabetic list and a formatted navigation bar.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getPagingLinks( $linkTexts, $disabledTexts=[])
Get paging links.
Definition: IndexPager.php:676
IndexPager is an efficient pager which uses a (roughly unique) index in the data set to implement pag...
Definition: IndexPager.php:72
makeLink( $text, array $query=null, $type=null)
Make a self-link.
Definition: IndexPager.php:516
isNavigationBarShown()
Returns whether to show the "navigation bar".
Definition: IndexPager.php:658
string $mNavigationBar
Definition: IndexPager.php:146
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&#39;t want to do class magic as may be still...