[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Efficient paging for SQL queries. 4 * 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. 9 * 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. 14 * 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 19 * 20 * @file 21 * @ingroup Pager 22 */ 23 24 /** 25 * IndexPager with an alphabetic list and a formatted navigation bar 26 * @ingroup Pager 27 */ 28 abstract class AlphabeticPager extends IndexPager { 29 30 /** 31 * Shamelessly stolen bits from ReverseChronologicalPager, 32 * didn't want to do class magic as may be still revamped 33 * 34 * @return string HTML 35 */ 36 function getNavigationBar() { 37 if ( !$this->isNavigationBarShown() ) { 38 return ''; 39 } 40 41 if ( isset( $this->mNavigationBar ) ) { 42 return $this->mNavigationBar; 43 } 44 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() 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( array( $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 array( '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 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. 102 * 103 * @return array 104 */ 105 protected function getOrderTypeMessages() { 106 return null; 107 } 108 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |