88 ConvertibleTimestamp $ts,
90 LoggerInterface $logger
92 $pageLang = $parser->getTargetLanguage();
94 $cacheTTL = self::CACHE_TTL_BY_ID[$id] ?? -1;
95 if ( $cacheTTL > -1 ) {
96 $parser->
getOutput()->updateCacheExpiry( $cacheTTL );
105 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
107 return $pageLang->formatNumNoSeparators( $ts->format(
'm' ) );
108 case 'currentmonth1':
109 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
111 return $pageLang->formatNumNoSeparators( $ts->format(
'n' ) );
112 case 'currentmonthname':
113 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
115 return $pageLang->getMonthName( (
int)$ts->format(
'n' ) );
116 case 'currentmonthnamegen':
117 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
119 return $pageLang->getMonthNameGen( (
int)$ts->format(
'n' ) );
120 case 'currentmonthabbrev':
121 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
123 return $pageLang->getMonthAbbreviation( (
int)$ts->format(
'n' ) );
125 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
127 return $pageLang->formatNumNoSeparators( $ts->format(
'j' ) );
129 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
131 return $pageLang->formatNumNoSeparators( $ts->format(
'd' ) );
133 $localTs = self::makeTsLocal( $svcOptions, $ts );
134 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
136 return $pageLang->formatNumNoSeparators( $localTs->format(
'm' ) );
138 $localTs = self::makeTsLocal( $svcOptions, $ts );
139 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
141 return $pageLang->formatNumNoSeparators( $localTs->format(
'n' ) );
142 case 'localmonthname':
143 $localTs = self::makeTsLocal( $svcOptions, $ts );
144 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
146 return $pageLang->getMonthName( (
int)$localTs->format(
'n' ) );
147 case 'localmonthnamegen':
148 $localTs = self::makeTsLocal( $svcOptions, $ts );
149 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
151 return $pageLang->getMonthNameGen( (
int)$localTs->format(
'n' ) );
152 case 'localmonthabbrev':
153 $localTs = self::makeTsLocal( $svcOptions, $ts );
154 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
156 return $pageLang->getMonthAbbreviation( (
int)$localTs->format(
'n' ) );
158 $localTs = self::makeTsLocal( $svcOptions, $ts );
159 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
161 return $pageLang->formatNumNoSeparators( $localTs->format(
'j' ) );
163 $localTs = self::makeTsLocal( $svcOptions, $ts );
164 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
166 return $pageLang->formatNumNoSeparators( $localTs->format(
'd' ) );
170 case 'fullpagenamee':
174 case 'rootpagenamee':
176 case 'basepagenamee':
178 case 'talkpagenamee':
179 case 'subjectpagename':
180 case 'subjectpagenamee':
186 case 'revisionmonth':
187 case 'revisionmonth1':
189 case 'revisiontimestamp':
192 case 'namespacenumber':
196 case 'subjectspacee':
197 case 'cascadingsources':
198 # First argument of the corresponding parser function
199 # (second argument of the PHP implementation) is
202 # Note that for many of these {{FOO}} is subtly different
203 # from {{FOO:{{PAGENAME}}}}, so we can't pass $title here
204 # we have to explicitly use the "no arguments" form of the
205 # parser function by passing `null` to indicate a missing
206 # argument (which then defaults to the current page title).
207 return CoreParserFunctions::$id( $parser,
null );
210 case 'currentdayname':
211 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
213 return $pageLang->getWeekdayName( (
int)$ts->format(
'w' ) + 1 );
215 self::applyUnitTimestampDeadline( $parser, $ts,
'Y' );
217 return $pageLang->formatNumNoSeparators( $ts->format(
'Y' ) );
219 return $pageLang->time( $ts->getTimestamp( TS_MW ),
false,
false );
221 self::applyUnitTimestampDeadline( $parser, $ts,
'H' );
223 return $pageLang->formatNumNoSeparators( $ts->format(
'H' ) );
225 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
228 return $pageLang->formatNum( (
int)$ts->format(
'W' ) );
230 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
232 return $pageLang->formatNum( $ts->format(
'w' ) );
234 $localTs = self::makeTsLocal( $svcOptions, $ts );
235 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
237 return $pageLang->getWeekdayName( (
int)$localTs->format(
'w' ) + 1 );
239 $localTs = self::makeTsLocal( $svcOptions, $ts );
240 self::applyUnitTimestampDeadline( $parser, $localTs,
'Y' );
242 return $pageLang->formatNumNoSeparators( $localTs->format(
'Y' ) );
244 $localTs = self::makeTsLocal( $svcOptions, $ts );
246 return $pageLang->time(
247 $localTs->format(
'YmdHis' ),
252 $localTs = self::makeTsLocal( $svcOptions, $ts );
253 self::applyUnitTimestampDeadline( $parser, $localTs,
'H' );
255 return $pageLang->formatNumNoSeparators( $localTs->format(
'H' ) );
257 $localTs = self::makeTsLocal( $svcOptions, $ts );
258 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
261 return $pageLang->formatNum( (
int)$localTs->format(
'W' ) );
263 $localTs = self::makeTsLocal( $svcOptions, $ts );
264 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
266 return $pageLang->formatNum( $localTs->format(
'w' ) );
267 case 'numberofarticles':
268 case 'numberoffiles':
269 case 'numberofusers':
270 case 'numberofactiveusers':
271 case 'numberofpages':
272 case 'numberofadmins':
273 case 'numberofedits':
274 # second argument is 'raw'; magic variables are "not raw"
275 return CoreParserFunctions::$id( $parser,
null );
276 case 'currenttimestamp':
277 return $ts->getTimestamp( TS_MW );
278 case 'localtimestamp':
279 $localTs = self::makeTsLocal( $svcOptions, $ts );
281 return $localTs->format(
'YmdHis' );
282 case 'currentversion':
283 return SpecialVersion::getVersion();
285 return (
string)$svcOptions->
get( MainConfigNames::ArticlePath );
287 return (
string)$svcOptions->
get( MainConfigNames::Sitename );
289 return (
string)$svcOptions->
get( MainConfigNames::Server );
291 return (
string)$svcOptions->
get( MainConfigNames::ServerName );
293 return (
string)$svcOptions->
get( MainConfigNames::ScriptPath );
295 return (
string)$svcOptions->
get( MainConfigNames::StylePath );
296 case 'directionmark':
297 return $pageLang->getDirMark();
298 case 'contentlanguage':
301 return $pageLang->getCode();