73 ConvertibleTimestamp $ts,
75 LoggerInterface $logger,
78 $pageLang = $parser->getTargetLanguage();
81 $source = $title->getPrefixedDBkey() .
" ($id)";
83 $cacheTTL = self::CACHE_TTL_BY_ID[$id] ?? -1;
84 if ( $cacheTTL > -1 ) {
96 return $pageLang->formatNumNoSeparators( $ts->format(
'm' ) );
100 return $pageLang->formatNumNoSeparators( $ts->format(
'n' ) );
101 case 'currentmonthname':
104 return $pageLang->getMonthName( (
int)$ts->format(
'n' ) );
105 case 'currentmonthnamegen':
108 return $pageLang->getMonthNameGen( (
int)$ts->format(
'n' ) );
109 case 'currentmonthabbrev':
112 return $pageLang->getMonthAbbreviation( (
int)$ts->format(
'n' ) );
116 return $pageLang->formatNumNoSeparators( $ts->format(
'j' ) );
120 return $pageLang->formatNumNoSeparators( $ts->format(
'd' ) );
122 $localTs = self::makeTsLocal( $svcOptions, $ts );
125 return $pageLang->formatNumNoSeparators( $localTs->format(
'm' ) );
127 $localTs = self::makeTsLocal( $svcOptions, $ts );
130 return $pageLang->formatNumNoSeparators( $localTs->format(
'n' ) );
131 case 'localmonthname':
132 $localTs = self::makeTsLocal( $svcOptions, $ts );
135 return $pageLang->getMonthName( (
int)$localTs->format(
'n' ) );
136 case 'localmonthnamegen':
137 $localTs = self::makeTsLocal( $svcOptions, $ts );
140 return $pageLang->getMonthNameGen( (
int)$localTs->format(
'n' ) );
141 case 'localmonthabbrev':
142 $localTs = self::makeTsLocal( $svcOptions, $ts );
145 return $pageLang->getMonthAbbreviation( (
int)$localTs->format(
'n' ) );
147 $localTs = self::makeTsLocal( $svcOptions, $ts );
150 return $pageLang->formatNumNoSeparators( $localTs->format(
'j' ) );
152 $localTs = self::makeTsLocal( $svcOptions, $ts );
155 return $pageLang->formatNumNoSeparators( $localTs->format(
'd' ) );
159 case 'fullpagenamee':
163 case 'rootpagenamee':
165 case 'basepagenamee':
167 case 'talkpagenamee':
168 case 'subjectpagename':
169 case 'subjectpagenamee':
175 case 'revisionmonth':
176 case 'revisionmonth1':
178 case 'revisiontimestamp':
181 case 'namespacenumber':
185 case 'subjectspacee':
186 case 'cascadingsources':
187 # First argument of the corresponding parser function
188 # (second argument of the PHP implementation) is
191 # Note that for many of these {{FOO}} is subtly different
192 # from {{FOO:{{PAGENAME}}}}, so we can't pass $title here
193 # we have to explicitly use the "no arguments" form of the
194 # parser function by passing `null` to indicate a missing
195 # argument (which then defaults to the current page title).
196 return CoreParserFunctions::$id( $parser,
null );
199 case 'currentdayname':
202 return $pageLang->getWeekdayName( (
int)$ts->format(
'w' ) + 1 );
206 return $pageLang->formatNumNoSeparators( $ts->format(
'Y' ) );
208 return $pageLang->time( $ts->getTimestamp( TS::MW ),
false,
false );
212 return $pageLang->formatNumNoSeparators( $ts->format(
'H' ) );
217 return $pageLang->formatNum( (
int)$ts->format(
'W' ) );
221 return $pageLang->formatNum( $ts->format(
'w' ) );
223 $localTs = self::makeTsLocal( $svcOptions, $ts );
226 return $pageLang->getWeekdayName( (
int)$localTs->format(
'w' ) + 1 );
228 $localTs = self::makeTsLocal( $svcOptions, $ts );
231 return $pageLang->formatNumNoSeparators( $localTs->format(
'Y' ) );
233 $localTs = self::makeTsLocal( $svcOptions, $ts );
235 return $pageLang->time(
236 $localTs->format(
'YmdHis' ),
241 $localTs = self::makeTsLocal( $svcOptions, $ts );
244 return $pageLang->formatNumNoSeparators( $localTs->format(
'H' ) );
246 $localTs = self::makeTsLocal( $svcOptions, $ts );
250 return $pageLang->formatNum( (
int)$localTs->format(
'W' ) );
252 $localTs = self::makeTsLocal( $svcOptions, $ts );
255 return $pageLang->formatNum( $localTs->format(
'w' ) );
256 case 'numberofarticles':
257 case 'numberoffiles':
258 case 'numberofusers':
259 case 'numberofactiveusers':
260 case 'numberofpages':
261 case 'numberofadmins':
262 case 'numberofedits':
263 # second argument is 'raw'; magic variables are "not raw"
264 return CoreParserFunctions::$id( $parser,
null );
265 case 'currenttimestamp':
266 return $ts->getTimestamp( TS::MW );
267 case 'localtimestamp':
268 $localTs = self::makeTsLocal( $svcOptions, $ts );
270 return $localTs->format(
'YmdHis' );
271 case 'currentversion':
272 return SpecialVersion::getVersion();
285 case 'directionmark':
286 return $pageLang->getDirMark();
287 case 'contentlanguage':
290 return $pageLang->getCode();
297 return $pageLang->getCode();
303 # magic variables are the same as empty/default first argument
304 return CoreParserFunctions::$id( $parser );