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
25 * IndexPager with an alphabetic list and a formatted navigation bar
28 abstract class AlphabeticPager
extends IndexPager
{
31 * Shamelessly stolen bits from ReverseChronologicalPager,
32 * didn't want to do class magic as may be still revamped
36 function getNavigationBar() {
37 if ( !$this->isNavigationBarShown() ) {
41 if ( isset( $this->mNavigationBar
) ) {
42 return $this->mNavigationBar
;
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
;
71 $msgs = $this->getOrderTypeMessages();
72 foreach ( array_keys( $msgs ) as $order ) {
76 $extra .= $this->msg( 'pipe-separator' )->escaped();
79 if ( $order == $this->mOrderType
) {
80 $extra .= $this->msg( $msgs[$order] )->escaped();
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
;
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.
105 protected function getOrderTypeMessages() {