| [ 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 a formatted navigation bar 26 * @ingroup Pager 27 */ 28 abstract class ReverseChronologicalPager extends IndexPager { 29 public $mDefaultDirection = IndexPager::DIR_DESCENDING; 30 public $mYear; 31 public $mMonth; 32 33 function getNavigationBar() { 34 if ( !$this->isNavigationBarShown() ) { 35 return ''; 36 } 37 38 if ( isset( $this->mNavigationBar ) ) { 39 return $this->mNavigationBar; 40 } 41 42 $linkTexts = array( 43 'prev' => $this->msg( 'pager-newer-n' )->numParams( $this->mLimit )->escaped(), 44 'next' => $this->msg( 'pager-older-n' )->numParams( $this->mLimit )->escaped(), 45 'first' => $this->msg( 'histlast' )->escaped(), 46 'last' => $this->msg( 'histfirst' )->escaped() 47 ); 48 49 $pagingLinks = $this->getPagingLinks( $linkTexts ); 50 $limitLinks = $this->getLimitLinks(); 51 $limits = $this->getLanguage()->pipeList( $limitLinks ); 52 $firstLastLinks = $this->msg( 'parentheses' )->rawParams( "{$pagingLinks['first']}" . 53 $this->msg( 'pipe-separator' )->escaped() . 54 "{$pagingLinks['last']}" )->escaped(); 55 56 $this->mNavigationBar = $firstLastLinks . ' ' . 57 $this->msg( 'viewprevnext' )->rawParams( 58 $pagingLinks['prev'], $pagingLinks['next'], $limits )->escaped(); 59 60 return $this->mNavigationBar; 61 } 62 63 function getDateCond( $year, $month ) { 64 $year = intval( $year ); 65 $month = intval( $month ); 66 67 // Basic validity checks 68 $this->mYear = $year > 0 ? $year : false; 69 $this->mMonth = ( $month > 0 && $month < 13 ) ? $month : false; 70 71 // Given an optional year and month, we need to generate a timestamp 72 // to use as "WHERE rev_timestamp <= result" 73 // Examples: year = 2006 equals < 20070101 (+000000) 74 // year=2005, month=1 equals < 20050201 75 // year=2005, month=12 equals < 20060101 76 if ( !$this->mYear && !$this->mMonth ) { 77 return; 78 } 79 80 if ( $this->mYear ) { 81 $year = $this->mYear; 82 } else { 83 // If no year given, assume the current one 84 $timestamp = MWTimestamp::getInstance(); 85 $year = $timestamp->format( 'Y' ); 86 // If this month hasn't happened yet this year, go back to last year's month 87 if ( $this->mMonth > $timestamp->format( 'n' ) ) { 88 $year--; 89 } 90 } 91 92 if ( $this->mMonth ) { 93 $month = $this->mMonth + 1; 94 // For December, we want January 1 of the next year 95 if ( $month > 12 ) { 96 $month = 1; 97 $year++; 98 } 99 } else { 100 // No month implies we want up to the end of the year in question 101 $month = 1; 102 $year++; 103 } 104 105 // Y2K38 bug 106 if ( $year > 2032 ) { 107 $year = 2032; 108 } 109 110 $ymd = (int)sprintf( "%04d%02d01", $year, $month ); 111 112 if ( $ymd > 20320101 ) { 113 $ymd = 20320101; 114 } 115 116 $this->mOffset = $this->mDb->timestamp( "$ymd}000000" ); 117 } 118 }
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 |