SpecialLinkSearch: clean up munged query variable handling
[mediawiki.git] / includes / pager / AlphabeticPager.php
blob34c78976cb8c19905e045287c3340ef5753890bd
1 <?php
2 /**
3 * Efficient paging for SQL queries.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup Pager
24 /**
25 * IndexPager with an alphabetic list and a formatted navigation bar
26 * @ingroup Pager
28 abstract class AlphabeticPager extends IndexPager {
30 /**
31 * Shamelessly stolen bits from ReverseChronologicalPager,
32 * didn't want to do class magic as may be still revamped
34 * @return string HTML
36 function getNavigationBar() {
37 if ( !$this->isNavigationBarShown() ) {
38 return '';
41 if ( isset( $this->mNavigationBar ) ) {
42 return $this->mNavigationBar;
45 $linkTexts = array(
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()
52 $lang = $this->getLanguage();
54 $pagingLinks = $this->getPagingLinks( $linkTexts );
55 $limitLinks = $this->getLimitLinks();
56 $limits = $lang->pipeList( $limitLinks );
58 $this->mNavigationBar = $this->msg( 'parentheses' )->rawParams(
59 $lang->pipeList( array( $pagingLinks['first'],
60 $pagingLinks['last'] ) ) )->escaped() . " " .
61 $this->msg( 'viewprevnext' )->rawParams( $pagingLinks['prev'],
62 $pagingLinks['next'], $limits )->escaped();
64 if ( !is_array( $this->getIndexField() ) ) {
65 # Early return to avoid undue nesting
66 return $this->mNavigationBar;
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();
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 array( 'order' => $order )
89 if ( $extra !== '' ) {
90 $extra = ' ' . $this->msg( 'parentheses' )->rawParams( $extra )->escaped();
91 $this->mNavigationBar .= $extra;
94 return $this->mNavigationBar;
97 /**
98 * If this supports multiple order type messages, give the message key for
99 * enabling each one in getNavigationBar. The return type is an associative
100 * array whose keys must exactly match the keys of the array returned
101 * by getIndexField(), and whose values are message keys.
103 * @return array
105 protected function getOrderTypeMessages() {
106 return null;