MediaWiki REL1_28
ReverseChronologicalPager.php
Go to the documentation of this file.
1<?php
28abstract class ReverseChronologicalPager extends IndexPager {
30 public $mYear;
31 public $mMonth;
32 public $mDay;
33
34 function getNavigationBar() {
35 if ( !$this->isNavigationBarShown() ) {
36 return '';
37 }
38
39 if ( isset( $this->mNavigationBar ) ) {
41 }
42
43 $linkTexts = [
44 'prev' => $this->msg( 'pager-newer-n' )->numParams( $this->mLimit )->escaped(),
45 'next' => $this->msg( 'pager-older-n' )->numParams( $this->mLimit )->escaped(),
46 'first' => $this->msg( 'histlast' )->escaped(),
47 'last' => $this->msg( 'histfirst' )->escaped()
48 ];
49
50 $pagingLinks = $this->getPagingLinks( $linkTexts );
51 $limitLinks = $this->getLimitLinks();
52 $limits = $this->getLanguage()->pipeList( $limitLinks );
53 $firstLastLinks = $this->msg( 'parentheses' )->rawParams( "{$pagingLinks['first']}" .
54 $this->msg( 'pipe-separator' )->escaped() .
55 "{$pagingLinks['last']}" )->escaped();
56
57 $this->mNavigationBar = $firstLastLinks . ' ' .
58 $this->msg( 'viewprevnext' )->rawParams(
59 $pagingLinks['prev'], $pagingLinks['next'], $limits )->escaped();
60
62 }
63
72 function getDateCond( $year, $month, $day = -1 ) {
73 $year = intval( $year );
74 $month = intval( $month );
75 $day = intval( $day );
76
77 // Basic validity checks for year and month
78 $this->mYear = $year > 0 ? $year : false;
79 $this->mMonth = ( $month > 0 && $month < 13 ) ? $month : false;
80
81 // If year and month are false, don't update the mOffset
82 if ( !$this->mYear && !$this->mMonth ) {
83 return;
84 }
85
86 // Given an optional year, month, and day, we need to generate a timestamp
87 // to use as "WHERE rev_timestamp <= result"
88 // Examples: year = 2006 equals < 20070101 (+000000)
89 // year=2005, month=1 equals < 20050201
90 // year=2005, month=12 equals < 20060101
91 // year=2005, month=12, day=5 equals < 20051206
92 if ( $this->mYear ) {
93 $year = $this->mYear;
94 } else {
95 // If no year given, assume the current one
97 $year = $timestamp->format( 'Y' );
98 // If this month hasn't happened yet this year, go back to last year's month
99 if ( $this->mMonth > $timestamp->format( 'n' ) ) {
100 $year--;
101 }
102 }
103
104 if ( $this->mMonth ) {
105 $month = $this->mMonth;
106
107 // Day validity check after we have month and year checked
108 $this->mDay = checkdate( $month, $day, $year ) ? $day : false;
109
110 if ( $this->mDay ) {
111 // If we have a day, we want up to the day immediately afterward
112 $day = $this->mDay + 1;
113
114 // Did we overflow the current month?
115 if ( !checkdate( $month, $day, $year ) ) {
116 $day = 1;
117 $month++;
118 }
119 } else {
120 // If no day, assume beginning of next month
121 $day = 1;
122 $month++;
123 }
124
125 // Did we overflow the current year?
126 if ( $month > 12 ) {
127 $month = 1;
128 $year++;
129 }
130
131 } else {
132 // No month implies we want up to the end of the year in question
133 $month = 1;
134 $day = 1;
135 $year++;
136 }
137
138 // Y2K38 bug
139 if ( $year > 2032 ) {
140 $year = 2032;
141 }
142
143 $ymd = (int)sprintf( "%04d%02d%02d", $year, $month, $day );
144
145 if ( $ymd > 20320101 ) {
146 $ymd = 20320101;
147 }
148
149 // Treat the given time in the wiki timezone and get a UTC timestamp for the database lookup
150 $timestamp = MWTimestamp::getInstance( "${ymd}000000" );
151 $timestamp->setTimezone( $this->getConfig()->get( 'Localtimezone' ) );
152
153 $this->mOffset = $this->mDb->timestamp( $timestamp->getTimestamp() );
154 return $this->mOffset;
155 }
156}
getConfig()
Get the Config object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getLanguage()
Get the Language object.
IndexPager is an efficient pager which uses a (roughly unique) index in the data set to implement pag...
getPagingLinks( $linkTexts, $disabledTexts=[])
Get paging links.
isNavigationBarShown()
Returns whether to show the "navigation bar".
const DIR_DESCENDING
static getInstance( $ts=false)
Get a timestamp instance in GMT.
IndexPager with a formatted navigation bar.
getDateCond( $year, $month, $day=-1)
Set and return the mOffset timestamp such that we can get all revisions with a timestamp up to the sp...
if( $limit) $timestamp
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37