71 ConvertibleTimestamp $ts,
73 LoggerInterface $logger
75 $pageLang = $parser->getTargetLanguage();
77 $cacheTTL = self::CACHE_TTL_BY_ID[$id] ?? -1;
78 if ( $cacheTTL > -1 ) {
79 $parser->
getOutput()->updateCacheExpiry( $cacheTTL );
90 return $pageLang->formatNumNoSeparators( $ts->format(
'm' ) );
94 return $pageLang->formatNumNoSeparators( $ts->format(
'n' ) );
95 case 'currentmonthname':
98 return $pageLang->getMonthName( (
int)$ts->format(
'n' ) );
99 case 'currentmonthnamegen':
102 return $pageLang->getMonthNameGen( (
int)$ts->format(
'n' ) );
103 case 'currentmonthabbrev':
106 return $pageLang->getMonthAbbreviation( (
int)$ts->format(
'n' ) );
110 return $pageLang->formatNumNoSeparators( $ts->format(
'j' ) );
114 return $pageLang->formatNumNoSeparators( $ts->format(
'd' ) );
116 $localTs = self::makeTsLocal( $svcOptions, $ts );
119 return $pageLang->formatNumNoSeparators( $localTs->format(
'm' ) );
121 $localTs = self::makeTsLocal( $svcOptions, $ts );
124 return $pageLang->formatNumNoSeparators( $localTs->format(
'n' ) );
125 case 'localmonthname':
126 $localTs = self::makeTsLocal( $svcOptions, $ts );
129 return $pageLang->getMonthName( (
int)$localTs->format(
'n' ) );
130 case 'localmonthnamegen':
131 $localTs = self::makeTsLocal( $svcOptions, $ts );
134 return $pageLang->getMonthNameGen( (
int)$localTs->format(
'n' ) );
135 case 'localmonthabbrev':
136 $localTs = self::makeTsLocal( $svcOptions, $ts );
139 return $pageLang->getMonthAbbreviation( (
int)$localTs->format(
'n' ) );
141 $localTs = self::makeTsLocal( $svcOptions, $ts );
144 return $pageLang->formatNumNoSeparators( $localTs->format(
'j' ) );
146 $localTs = self::makeTsLocal( $svcOptions, $ts );
149 return $pageLang->formatNumNoSeparators( $localTs->format(
'd' ) );
153 case 'fullpagenamee':
157 case 'rootpagenamee':
159 case 'basepagenamee':
161 case 'talkpagenamee':
162 case 'subjectpagename':
163 case 'subjectpagenamee':
169 case 'revisionmonth':
170 case 'revisionmonth1':
172 case 'revisiontimestamp':
175 case 'namespacenumber':
179 case 'subjectspacee':
180 case 'cascadingsources':
181 # First argument of the corresponding parser function
182 # (second argument of the PHP implementation) is
185 # Note that for many of these {{FOO}} is subtly different
186 # from {{FOO:{{PAGENAME}}}}, so we can't pass $title here
187 # we have to explicitly use the "no arguments" form of the
188 # parser function by passing `null` to indicate a missing
189 # argument (which then defaults to the current page title).
190 return CoreParserFunctions::$id( $parser,
null );
193 case 'currentdayname':
196 return $pageLang->getWeekdayName( (
int)$ts->format(
'w' ) + 1 );
200 return $pageLang->formatNumNoSeparators( $ts->format(
'Y' ) );
202 return $pageLang->time( $ts->getTimestamp( TS::MW ),
false,
false );
206 return $pageLang->formatNumNoSeparators( $ts->format(
'H' ) );
211 return $pageLang->formatNum( (
int)$ts->format(
'W' ) );
215 return $pageLang->formatNum( $ts->format(
'w' ) );
217 $localTs = self::makeTsLocal( $svcOptions, $ts );
220 return $pageLang->getWeekdayName( (
int)$localTs->format(
'w' ) + 1 );
222 $localTs = self::makeTsLocal( $svcOptions, $ts );
225 return $pageLang->formatNumNoSeparators( $localTs->format(
'Y' ) );
227 $localTs = self::makeTsLocal( $svcOptions, $ts );
229 return $pageLang->time(
230 $localTs->format(
'YmdHis' ),
235 $localTs = self::makeTsLocal( $svcOptions, $ts );
238 return $pageLang->formatNumNoSeparators( $localTs->format(
'H' ) );
240 $localTs = self::makeTsLocal( $svcOptions, $ts );
244 return $pageLang->formatNum( (
int)$localTs->format(
'W' ) );
246 $localTs = self::makeTsLocal( $svcOptions, $ts );
249 return $pageLang->formatNum( $localTs->format(
'w' ) );
250 case 'numberofarticles':
251 case 'numberoffiles':
252 case 'numberofusers':
253 case 'numberofactiveusers':
254 case 'numberofpages':
255 case 'numberofadmins':
256 case 'numberofedits':
257 # second argument is 'raw'; magic variables are "not raw"
258 return CoreParserFunctions::$id( $parser,
null );
259 case 'currenttimestamp':
260 return $ts->getTimestamp( TS::MW );
261 case 'localtimestamp':
262 $localTs = self::makeTsLocal( $svcOptions, $ts );
264 return $localTs->format(
'YmdHis' );
265 case 'currentversion':
266 return SpecialVersion::getVersion();
279 case 'directionmark':
280 return $pageLang->getDirMark();
281 case 'contentlanguage':
284 return $pageLang->getCode();
291 return $pageLang->getCode();
298 # magic variables are the same as empty/default first argument
299 return CoreParserFunctions::$id( $parser );