Movatterモバイル変換


[0]ホーム

URL:


MediaWiki master
CoreParserFunctions.php
Go to the documentation of this file.
1<?php
24namespaceMediaWiki\Parser;
25
26use InvalidArgumentException;
27useMediaWiki\Category\Category;
28useMediaWiki\Config\ServiceOptions;
29useMediaWiki\Language\Language;
30useMediaWiki\Language\LanguageCode;
31use MediaWiki\Languages\LanguageNameUtils;
32useMediaWiki\Linker\Linker;
33useMediaWiki\MainConfigNames;
34useMediaWiki\MediaWikiServices;
35useMediaWiki\Message\Message;
36useMediaWiki\Revision\RevisionAccessException;
37useMediaWiki\Revision\RevisionRecord;
38useMediaWiki\SiteStats\SiteStats;
39useMediaWiki\SpecialPage\SpecialPage;
40useMediaWiki\Title\Title;
41useMediaWiki\Title\TitleValue;
42useMediaWiki\User\User;
43use Wikimedia\Bcp47Code\Bcp47CodeValue;
44use Wikimedia\RemexHtml\Tokenizer\Attributes;
45use Wikimedia\RemexHtml\Tokenizer\PlainAttributes;
46
51classCoreParserFunctions {
53privateconst MAX_TTS = 900;
54
58publicconstREGISTER_OPTIONS = [
59// See documentation for the corresponding config options
60MainConfigNames::AllowDisplayTitle,
61MainConfigNames::AllowSlowParserFunctions,
62 ];
63
71publicstaticfunctionregister(Parser $parser,ServiceOptions $options ) {
72 $options->assertRequiredOptions( self::REGISTER_OPTIONS );
73 $allowDisplayTitle = $options->get(MainConfigNames::AllowDisplayTitle );
74 $allowSlowParserFunctions = $options->get(MainConfigNames::AllowSlowParserFunctions );
75
76 # Syntax for arguments (see Parser::setFunctionHook):
77 # "name for lookup in localized magic words array",
78 # function callback,
79 # optional Parser::SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}}
80 # instead of {{#int:...}})
81 $noHashFunctions = [
82'ns','nse','urlencode','lcfirst','ucfirst','lc','uc',
83'localurl','localurle','fullurl','fullurle','canonicalurl',
84'canonicalurle','formatnum','grammar','gender','plural','formal',
85'bidi','numberingroup','language',
86'padleft','padright','anchorencode','defaultsort','filepath',
87'pagesincategory','pagesize','protectionlevel','protectionexpiry',
88 # The following are the "parser function" forms of magic
89 # variables defined in CoreMagicVariables. The no-args form will
90 # go through the magic variable code path (and be cached); the
91 # presence of arguments will cause the parser function form to
92 # be invoked. (Note that the actual implementation will pass
93 # a Parser object as first argument, in addition to the
94 # parser function parameters.)
95
96 # For this group, the first parameter to the parser function is
97 # "page title", and the no-args form (and the magic variable)
98 # defaults to "current page title".
99'pagename','pagenamee',
100'fullpagename','fullpagenamee',
101'subpagename','subpagenamee',
102'rootpagename','rootpagenamee',
103'basepagename','basepagenamee',
104'talkpagename','talkpagenamee',
105'subjectpagename','subjectpagenamee',
106'pageid','revisionid','revisionday',
107'revisionday2','revisionmonth','revisionmonth1','revisionyear',
108'revisiontimestamp',
109'revisionuser',
110'cascadingsources',
111'namespace','namespacee','namespacenumber','talkspace','talkspacee',
112'subjectspace','subjectspacee',
113
114 # More parser functions corresponding to CoreMagicVariables.
115 # For this group, the first parameter to the parser function is
116 # "raw" (uses the 'raw' format if present) and the no-args form
117 # (and the magic variable) defaults to 'not raw'.
118'numberofarticles','numberoffiles',
119'numberofusers',
120'numberofactiveusers',
121'numberofpages',
122'numberofadmins',
123'numberofedits',
124
125 # These magic words already contain the hash, and the no-args form
126 # is the same as passing an empty first argument
127'bcp47',
128'dir',
129'interwikilink',
130'interlanguagelink',
131 ];
132foreach ( $noHashFunctions as $func ) {
133 $parser->setFunctionHook( $func, [ self::class, $func ],Parser::SFH_NO_HASH );
134 }
135
136 $parser->setFunctionHook('int', [ self::class,'intFunction' ],Parser::SFH_NO_HASH );
137 $parser->setFunctionHook('special', [ self::class,'special' ] );
138 $parser->setFunctionHook('speciale', [ self::class,'speciale' ] );
139 $parser->setFunctionHook('tag', [ self::class,'tagObj' ],Parser::SFH_OBJECT_ARGS );
140 $parser->setFunctionHook('formatdate', [ self::class,'formatDate' ] );
141
142if ( $allowDisplayTitle ) {
143 $parser->setFunctionHook(
144'displaytitle',
145 [ self::class,'displaytitle' ],
147 );
148 }
149if ( $allowSlowParserFunctions ) {
150 $parser->setFunctionHook(
151'pagesinnamespace',
152 [ self::class,'pagesinnamespace' ],
154 );
155 }
156 }
157
164publicstaticfunctionintFunction( $parser, $part1 ='', ...$params ) {
165if ( strval( $part1 ) !=='' ) {
166 $message =wfMessage( $part1, $params )
167 ->inLanguage( $parser->getOptions()->getUserLangObj() );
168return [ $message->plain(),'noparse' => false ];
169 }else {
170return ['found' => false ];
171 }
172 }
173
181publicstaticfunctionformatDate( $parser, $date, $defaultPref =null ) {
182 $lang = $parser->getTargetLanguage();
183 $df =MediaWikiServices::getInstance()->getDateFormatterFactory()->get( $lang );
184
185 $date = trim( $date );
186
187 $pref = $parser->getOptions()->getDateFormat();
188
189// Specify a different default date format other than the normal default
190// if the user has 'default' for their setting
191if ( $pref =='default' && $defaultPref ) {
192 $pref = $defaultPref;
193 }
194
195 $date = $df->reformat( $pref, $date, ['match-whole' ] );
196return $date;
197 }
198
199publicstaticfunctionns( $parser, $part1 ='' ) {
200if ( intval( $part1 ) || $part1 =="0" ) {
201 $index = intval( $part1 );
202 }else {
203 $index = $parser->getContentLanguage()->getNsIndex( str_replace(' ','_', $part1 ) );
204 }
205if ( $index !==false ) {
206return $parser->getContentLanguage()->getFormattedNsText( $index );
207 }else {
208return ['found' => false ];
209 }
210 }
211
212publicstaticfunctionnse( $parser, $part1 ='' ) {
213 $ret = self::ns( $parser, $part1 );
214if ( is_string( $ret ) ) {
215 $ret =wfUrlencode( str_replace(' ','_', $ret ) );
216 }
217return $ret;
218 }
219
232publicstaticfunctionurlencode( $parser, $s ='', $arg =null ) {
233static$magicWords =null;
234if ($magicWords ===null ) {
236 $parser->getMagicWordFactory()->newArray( ['url_path','url_query','url_wiki' ] );
237 }
238switch ($magicWords->matchStartToEnd( $arg ??'' ) ) {
239// Encode as though it's a wiki page, '_' for ' '.
240case'url_wiki':
241 $func ='wfUrlencode';
242 $s = str_replace(' ','_', $s );
243break;
244
245// Encode for an HTTP Path, '%20' for ' '.
246case'url_path':
247 $func ='rawurlencode';
248break;
249
250// Encode for HTTP query, '+' for ' '.
251case'url_query':
252default:
253 $func ='urlencode';
254 }
255// See T105242, where the choice to kill markers and various
256// other options were discussed.
257return $func( $parser->killMarkers( $s ) );
258 }
259
260publicstaticfunctionlcfirst( $parser, $s ='' ) {
261return $parser->getContentLanguage()->lcfirst( $s );
262 }
263
264publicstaticfunctionucfirst( $parser, $s ='' ) {
265return $parser->getContentLanguage()->ucfirst( $s );
266 }
267
273publicstaticfunctionlc( $parser, $s ='' ) {
274return $parser->markerSkipCallback( $s, [ $parser->getContentLanguage(),'lc' ] );
275 }
276
282publicstaticfunctionuc( $parser, $s ='' ) {
283return $parser->markerSkipCallback( $s, [ $parser->getContentLanguage(),'uc' ] );
284 }
285
286publicstaticfunctionlocalurl( $parser, $s ='', $arg =null ) {
287return self::urlFunction('getLocalURL', $s, $arg );
288 }
289
290publicstaticfunctionlocalurle( $parser, $s ='', $arg =null ) {
291 $temp = self::urlFunction('getLocalURL', $s, $arg );
292if ( !is_string( $temp ) ) {
293return $temp;
294 }else {
295return htmlspecialchars( $temp, ENT_COMPAT );
296 }
297 }
298
299publicstaticfunctionfullurl( $parser, $s ='', $arg =null ) {
300return self::urlFunction('getFullURL', $s, $arg );
301 }
302
303publicstaticfunctionfullurle( $parser, $s ='', $arg =null ) {
304 $temp = self::urlFunction('getFullURL', $s, $arg );
305if ( !is_string( $temp ) ) {
306return $temp;
307 }else {
308return htmlspecialchars( $temp, ENT_COMPAT );
309 }
310 }
311
312publicstaticfunctioncanonicalurl( $parser, $s ='', $arg =null ) {
313return self::urlFunction('getCanonicalURL', $s, $arg );
314 }
315
316publicstaticfunctioncanonicalurle( $parser, $s ='', $arg =null ) {
317 $temp = self::urlFunction('getCanonicalURL', $s, $arg );
318if ( !is_string( $temp ) ) {
319return $temp;
320 }else {
321return htmlspecialchars( $temp, ENT_COMPAT );
322 }
323 }
324
325publicstaticfunctionurlFunction( $func, $s ='', $arg =null ) {
326 # Due to order of execution of a lot of bits, the values might be encoded
327 # before arriving here; if that's true, then the title can't be created
328 # and the variable will fail. If we can't get a decent title from the first
329 # attempt, url-decode and try for a second.
330 $title = Title::newFromText( $s ) ?? Title::newFromURL( urldecode( $s ) );
331if ( $title !==null ) {
332 # Convert NS_MEDIA -> NS_FILE
333if ( $title->inNamespace(NS_MEDIA ) ) {
334 $title = Title::makeTitle(NS_FILE, $title->getDBkey() );
335 }
336if ( $arg !==null ) {
337 $text = $title->$func( $arg );
338 }else {
339 $text = $title->$func();
340 }
341return $text;
342 }else {
343return ['found' => false ];
344 }
345 }
346
354publicstaticfunctionformatnum( $parser, $num ='', $arg1 ='', $arg2 ='' ) {
355static$magicWords =null;
356if ($magicWords ===null ) {
357$magicWords = $parser->getMagicWordFactory()->newArray( [
358'rawsuffix',
359'nocommafysuffix',
360'lossless',
361 ] );
362 }
363
364 $modifiers = [$magicWords->matchStartToEnd( $arg1 ),$magicWords->matchStartToEnd( $arg2 ) ];
365 $targetLanguage = $parser->getTargetLanguage();
366if ( in_array('rawsuffix', $modifiers,true ) ) {
367 $func = [ $targetLanguage,'parseFormattedNumber' ];
368 }else {
369if ( in_array('nocommafysuffix', $modifiers,true ) ) {
370 $func = [ $targetLanguage,'formatNumNoSeparators' ];
371 }else {
372 $func = [ $targetLanguage,'formatNum' ];
373 $func = self::getLegacyFormatNum( $parser, $func );
374 }
375if ( in_array('lossless', $modifiers,true ) ) {
376 $potentiallyLossyFunc = $func;
377 $func =staticfunction ( $num ) use ( $targetLanguage, $potentiallyLossyFunc ) {
378 $formatted = $potentiallyLossyFunc( $num );
379 $parsed = $targetLanguage->parseFormattedNumber( $formatted );
380if ( $num === $parsed ) {
381return $formatted;
382 }else {
383return (string)$num;
384 }
385 };
386 }
387 }
388return $parser->markerSkipCallback( $num, $func );
389 }
390
397privatestaticfunction getLegacyFormatNum( $parser, $callback ) {
398// For historic reasons, the formatNum parser function will
399// take arguments which are not actually formatted numbers,
400// which then trigger deprecation warnings in Language::formatNum*.
401// Instead emit a tracking category instead to allow linting.
402returnstaticfunction ( $number ) use ( $parser, $callback ) {
403 $validNumberRe ='(-(?=[\d\.]))?(\d+|(?=\.\d))(\.\d*)?([Ee][-+]?\d+)?';
404if (
405 !is_numeric( $number ) &&
406 $number !== (string)NAN &&
407 $number !== (string)INF &&
408 $number !== (string)-INF
409 ) {
410 $parser->addTrackingCategory('nonnumeric-formatnum' );
411// Don't split on NAN/INF in the legacy case since they are
412// likely to be found embedded inside non-numeric text.
413return preg_replace_callback("/{$validNumberRe}/",staticfunction ( $m ) use ( $callback ) {
414return $callback( $m[0] );
415 }, $number );
416 }
417return $callback( $number );
418 };
419 }
420
427publicstaticfunctiongrammar( $parser, $case ='', $word ='' ) {
428 $word = $parser->killMarkers( $word );
429return $parser->getTargetLanguage()->convertGrammar( $word, $case );
430 }
431
438publicstaticfunctiongender( $parser, $username, ...$forms ) {
439// Some shortcuts to avoid loading user data unnecessarily
440if ( count( $forms ) === 0 ) {
441return'';
442 } elseif ( count( $forms ) === 1 ) {
443return $forms[0];
444 }
445
446 $username = trim( $username );
447
448 $userOptionsLookup =MediaWikiServices::getInstance()->getUserOptionsLookup();
449 $gender = $userOptionsLookup->getDefaultOption('gender' );
450
451// allow prefix and normalize (e.g. "&#42;foo" -> "*foo" ).
452 $title = Title::newFromText( $username,NS_USER );
453
454if ( $title && $title->inNamespace(NS_USER ) ) {
455 $username = $title->getText();
456 }
457
458// check parameter, or use the ParserOptions if in interface message
459 $user = User::newFromName( $username );
460 $genderCache =MediaWikiServices::getInstance()->getGenderCache();
461if ( $user ) {
462 $gender = $genderCache->getGenderOf( $user, __METHOD__ );
463 } elseif ( $username ==='' && $parser->getOptions()->isMessage() ) {
464 $gender = $genderCache->getGenderOf( $parser->getOptions()->getUserIdentity(), __METHOD__ );
465 }
466 $ret = $parser->getTargetLanguage()->gender( $gender, $forms );
467return $ret;
468 }
469
476publicstaticfunctionplural( $parser, $text ='', ...$forms ) {
477 $text = $parser->getTargetLanguage()->parseFormattedNumber( $text );
478 settype( $text, ctype_digit( $text ) ?'int' :'float' );
479// @phan-suppress-next-line PhanTypeMismatchArgument Phan does not handle settype
480return $parser->getTargetLanguage()->convertPlural( $text, $forms );
481 }
482
483publicstaticfunctionformal(Parser $parser,string ...$forms ): string {
484 $index = $parser->getTargetLanguage()->getFormalityIndex();
485return $forms[$index] ?? $forms[0];
486 }
487
493publicstaticfunctionbidi( $parser, $text ='' ) {
494return $parser->getTargetLanguage()->embedBidi( $text );
495 }
496
506publicstaticfunctiondisplaytitle( $parser, $text ='', $uarg ='' ) {
507 $restrictDisplayTitle =MediaWikiServices::getInstance()->getMainConfig()
509
510static$magicWords =null;
511if ($magicWords ===null ) {
512$magicWords = $parser->getMagicWordFactory()->newArray(
513 ['displaytitle_noerror','displaytitle_noreplace' ] );
514 }
515 $arg =$magicWords->matchStartToEnd( $uarg );
516
517// parse a limited subset of wiki markup (just the single quote items)
518 $text = $parser->doQuotes( $text );
519
520// remove stripped text (e.g. the UNIQ-QINU stuff) that was generated by tag extensions/whatever
521 $text = $parser->killMarkers( $text );
522
523// See T28547 for rationale for this processing.
524// list of disallowed tags for DISPLAYTITLE
525// these will be escaped even though they are allowed in normal wiki text
526 $bad = ['h1','h2','h3','h4','h5','h6','div','blockquote','ol','ul','li','hr',
527'table','tr','th','td','dl','dd','caption','p','ruby','rb','rt','rtc','rp','br' ];
528
529// disallow some styles that could be used to bypass $wgRestrictDisplayTitle
530if ( $restrictDisplayTitle ) {
531// This code is tested with the cases marked T28547 in
532// parserTests.txt
533 $htmlTagsCallback =staticfunction ( Attributes $attr ): Attributes {
534 $decoded = $attr->getValues();
535
536if ( isset( $decoded['style'] ) ) {
537// this is called later anyway, but we need it right now for the regexes below to be safe
538// calling it twice doesn't hurt
539 $decoded['style'] =Sanitizer::checkCss( $decoded['style'] );
540
541if ( preg_match('/(display|user-select|visibility)\s*:/i', $decoded['style'] ) ) {
542 $decoded['style'] ='/* attempt to bypass $wgRestrictDisplayTitle */';
543 }
544 }
545
546returnnew PlainAttributes( $decoded );
547 };
548 }else {
549 $htmlTagsCallback =null;
550 }
551
552// only requested titles that normalize to the actual title are allowed through
553// if $wgRestrictDisplayTitle is true (it is by default)
554// mimic the escaping process that occurs in OutputPage::setPageTitle
555 $text =Sanitizer::removeSomeTags( $text, [
556'attrCallback' => $htmlTagsCallback,
557'removeTags' => $bad,
558 ] );
559 $title = Title::newFromText(Sanitizer::stripAllTags( $text ) );
560// Decode entities in $text the same way that Title::newFromText does
561 $filteredText =Sanitizer::decodeCharReferencesAndNormalize( $text );
562
563if ( !$restrictDisplayTitle ||
564 ( $title instanceofTitle
565 && !$title->hasFragment()
566 && $title->equals( $parser->getTitle() ) )
567 ) {
568 $old = $parser->getOutput()->getPageProperty('displaytitle' );
569if ( $old ===null || $arg !=='displaytitle_noreplace' ) {
570 $parser->getOutput()->setDisplayTitle( $text );
571 }
572if ( $old !==null && $old !== $text && !$arg ) {
573
574 $converter = $parser->getTargetLanguageConverter();
575return'<span class="error">' .
576 $parser->msg('duplicate-displaytitle',
577// Message should be parsed, but these params should only be escaped.
578 $converter->markNoConversion(wfEscapeWikiText( $old ) ),
579 $converter->markNoConversion(wfEscapeWikiText( $filteredText ) )
580 )->text() .
581'</span>';
582 }else {
583return'';
584 }
585 }else {
586 $parser->getOutput()->addWarningMsg(
587'restricted-displaytitle',
588// Message should be parsed, but this param should only be escaped.
589Message::plaintextParam( $filteredText )
590 );
591 $parser->addTrackingCategory('restricted-displaytitle-ignored' );
592 }
593 }
594
604privatestaticfunction matchAgainstMagicword(
605MagicWordFactory $magicWordFactory, $magicword, $value
606 ) {
607 $value = trim( strval( $value ) );
608if ( $value ==='' ) {
609returnfalse;
610 }
611 $mwObject = $magicWordFactory->get( $magicword );
612return $mwObject->matchStartToEnd( $value );
613 }
614
624publicstaticfunctionformatRaw(
625 $num, $raw, $language, ?MagicWordFactory $magicWordFactory =null
626 ) {
627if ( $raw !==null && $raw !=='' ) {
628if ( !$magicWordFactory ) {
629 $magicWordFactory =MediaWikiServices::getInstance()->getMagicWordFactory();
630 }
631if ( self::matchAgainstMagicword( $magicWordFactory,'rawsuffix', $raw ) ) {
632return (string)$num;
633 }
634 }
635return $language->formatNum( $num );
636 }
637
638publicstaticfunctionnumberofpages( $parser, $raw =null ) {
639return self::formatRaw( SiteStats::pages(), $raw, $parser->getTargetLanguage() );
640 }
641
642publicstaticfunctionnumberofusers( $parser, $raw =null ) {
643return self::formatRaw( SiteStats::users(), $raw, $parser->getTargetLanguage() );
644 }
645
646publicstaticfunctionnumberofactiveusers( $parser, $raw =null ) {
647return self::formatRaw( SiteStats::activeUsers(), $raw, $parser->getTargetLanguage() );
648 }
649
650publicstaticfunctionnumberofarticles( $parser, $raw =null ) {
651return self::formatRaw( SiteStats::articles(), $raw, $parser->getTargetLanguage() );
652 }
653
654publicstaticfunctionnumberoffiles( $parser, $raw =null ) {
655return self::formatRaw( SiteStats::images(), $raw, $parser->getTargetLanguage() );
656 }
657
658publicstaticfunctionnumberofadmins( $parser, $raw =null ) {
659return self::formatRaw(
660 SiteStats::numberingroup('sysop' ),
661 $raw,
662 $parser->getTargetLanguage()
663 );
664 }
665
666publicstaticfunctionnumberofedits( $parser, $raw =null ) {
667return self::formatRaw( SiteStats::edits(), $raw, $parser->getTargetLanguage() );
668 }
669
670publicstaticfunctionpagesinnamespace( $parser, $namespace = 0, $raw =null ) {
671return self::formatRaw(
672 SiteStats::pagesInNs( intval( $namespace ) ),
673 $raw,
674 $parser->getTargetLanguage()
675 );
676 }
677
678publicstaticfunctionnumberingroup( $parser, $name ='', $raw =null ) {
679return self::formatRaw(
680 SiteStats::numberingroup( strtolower( $name ) ),
681 $raw,
682 $parser->getTargetLanguage()
683 );
684 }
685
694privatestaticfunction makeTitle(Parser $parser, ?string $t ) {
695if ( $t ===null ) {
696// For consistency with magic variable forms
697 $title = $parser->getTitle();
698 }else {
699 $title = Title::newFromText( $t );
700 }
701return $title;
702 }
703
712publicstaticfunctionnamespace( $parser, $title = null ) {
713$t = self::makeTitle( $parser, $title );
714if ( $t ===null ) {
715return'';
716 }
717return str_replace('_',' ', $t->getNsText() );
718 }
719
720publicstaticfunctionnamespacee( $parser, $title =null ) {
721 $t = self::makeTitle( $parser, $title );
722if ( $t ===null ) {
723return'';
724 }
725returnwfUrlencode( $t->getNsText() );
726 }
727
728publicstaticfunctionnamespacenumber( $parser, $title =null ) {
729 $t = self::makeTitle( $parser, $title );
730if ( $t ===null ) {
731return'';
732 }
733return (string)$t->getNamespace();
734 }
735
736publicstaticfunctiontalkspace( $parser, $title =null ) {
737 $t = self::makeTitle( $parser, $title );
738if ( $t ===null || !$t->canHaveTalkPage() ) {
739return'';
740 }
741return str_replace('_',' ', $t->getTalkNsText() );
742 }
743
744publicstaticfunctiontalkspacee( $parser, $title =null ) {
745 $t = self::makeTitle( $parser, $title );
746if ( $t ===null || !$t->canHaveTalkPage() ) {
747return'';
748 }
749returnwfUrlencode( $t->getTalkNsText() );
750 }
751
752publicstaticfunctionsubjectspace( $parser, $title =null ) {
753 $t = self::makeTitle( $parser, $title );
754if ( $t ===null ) {
755return'';
756 }
757return str_replace('_',' ', $t->getSubjectNsText() );
758 }
759
760publicstaticfunctionsubjectspacee( $parser, $title =null ) {
761 $t = self::makeTitle( $parser, $title );
762if ( $t ===null ) {
763return'';
764 }
765returnwfUrlencode( $t->getSubjectNsText() );
766 }
767
775publicstaticfunctionpagename( $parser, $title =null ) {
776 $t = self::makeTitle( $parser, $title );
777if ( $t ===null ) {
778return'';
779 }
780returnwfEscapeWikiText( $t->getText() );
781 }
782
783publicstaticfunctionpagenamee( $parser, $title =null ) {
784 $t = self::makeTitle( $parser, $title );
785if ( $t ===null ) {
786return'';
787 }
788returnwfEscapeWikiText( $t->getPartialURL() );
789 }
790
791publicstaticfunctionfullpagename( $parser, $title =null ) {
792 $t = self::makeTitle( $parser, $title );
793if ( $t ===null ) {
794return'';
795 }
796returnwfEscapeWikiText( $t->getPrefixedText() );
797 }
798
799publicstaticfunctionfullpagenamee( $parser, $title =null ) {
800 $t = self::makeTitle( $parser, $title );
801if ( $t ===null ) {
802return'';
803 }
804returnwfEscapeWikiText( $t->getPrefixedURL() );
805 }
806
807publicstaticfunctionsubpagename( $parser, $title =null ) {
808 $t = self::makeTitle( $parser, $title );
809if ( $t ===null ) {
810return'';
811 }
812returnwfEscapeWikiText( $t->getSubpageText() );
813 }
814
815publicstaticfunctionsubpagenamee( $parser, $title =null ) {
816 $t = self::makeTitle( $parser, $title );
817if ( $t ===null ) {
818return'';
819 }
820returnwfEscapeWikiText( $t->getSubpageUrlForm() );
821 }
822
823publicstaticfunctionrootpagename( $parser, $title =null ) {
824 $t = self::makeTitle( $parser, $title );
825if ( $t ===null ) {
826return'';
827 }
828returnwfEscapeWikiText( $t->getRootText() );
829 }
830
831publicstaticfunctionrootpagenamee( $parser, $title =null ) {
832 $t = self::makeTitle( $parser, $title );
833if ( $t ===null ) {
834return'';
835 }
836returnwfEscapeWikiText(wfUrlencode( str_replace(' ','_', $t->getRootText() ) ) );
837 }
838
839publicstaticfunctionbasepagename( $parser, $title =null ) {
840 $t = self::makeTitle( $parser, $title );
841if ( $t ===null ) {
842return'';
843 }
844returnwfEscapeWikiText( $t->getBaseText() );
845 }
846
847publicstaticfunctionbasepagenamee( $parser, $title =null ) {
848 $t = self::makeTitle( $parser, $title );
849if ( $t ===null ) {
850return'';
851 }
852returnwfEscapeWikiText(wfUrlencode( str_replace(' ','_', $t->getBaseText() ) ) );
853 }
854
855publicstaticfunctiontalkpagename( $parser, $title =null ) {
856 $t = self::makeTitle( $parser, $title );
857if ( $t ===null || !$t->canHaveTalkPage() ) {
858return'';
859 }
860returnwfEscapeWikiText( $t->getTalkPage()->getPrefixedText() );
861 }
862
863publicstaticfunctiontalkpagenamee( $parser, $title =null ) {
864 $t = self::makeTitle( $parser, $title );
865if ( $t ===null || !$t->canHaveTalkPage() ) {
866return'';
867 }
868returnwfEscapeWikiText( $t->getTalkPage()->getPrefixedURL() );
869 }
870
871publicstaticfunctionsubjectpagename( $parser, $title =null ) {
872 $t = self::makeTitle( $parser, $title );
873if ( $t ===null ) {
874return'';
875 }
876returnwfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() );
877 }
878
879publicstaticfunctionsubjectpagenamee( $parser, $title =null ) {
880 $t = self::makeTitle( $parser, $title );
881if ( $t ===null ) {
882return'';
883 }
884returnwfEscapeWikiText( $t->getSubjectPage()->getPrefixedURL() );
885 }
886
897publicstaticfunctionpagesincategory( $parser, $name ='', $arg1 ='', $arg2 ='' ) {
898static$magicWords =null;
899if ($magicWords ===null ) {
900$magicWords = $parser->getMagicWordFactory()->newArray( [
901'pagesincategory_all',
902'pagesincategory_pages',
903'pagesincategory_subcats',
904'pagesincategory_files'
905 ] );
906 }
907static $cache = [];
908
909// split the given option to its variable
910if ( self::matchAgainstMagicword( $parser->getMagicWordFactory(),'rawsuffix', $arg1 ) ) {
911// {{pagesincategory:|raw[|type]}}
912 $raw = $arg1;
913 $type =$magicWords->matchStartToEnd( $arg2 );
914 }else {
915// {{pagesincategory:[|type[|raw]]}}
916 $type =$magicWords->matchStartToEnd( $arg1 );
917 $raw = $arg2;
918 }
919if ( !$type ) {// backward compatibility
920 $type ='pagesincategory_all';
921 }
922
923 $title = Title::makeTitleSafe(NS_CATEGORY, $name );
924if ( !$title ) { # invalid title
925return self::formatRaw( 0, $raw, $parser->getTargetLanguage() );
926 }
927 $languageConverter =MediaWikiServices::getInstance()
928 ->getLanguageConverterFactory()
929 ->getLanguageConverter( $parser->getContentLanguage() );
930 $languageConverter->findVariantLink( $name, $title,true );
931
932// Normalize name for cache
933 $name = $title->getDBkey();
934
935if ( !isset( $cache[$name] ) ) {
936 $category = Category::newFromTitle( $title );
937
938 $allCount = $subcatCount = $fileCount = $pageCount = 0;
939if ( $parser->incrementExpensiveFunctionCount() ) {
940 $allCount = $category->getMemberCount();
941 $subcatCount = $category->getSubcatCount();
942 $fileCount = $category->getFileCount();
943 $pageCount = $category->getPageCount( Category::COUNT_CONTENT_PAGES );
944 }
945 $cache[$name]['pagesincategory_all'] = $allCount;
946 $cache[$name]['pagesincategory_pages'] = $pageCount;
947 $cache[$name]['pagesincategory_subcats'] = $subcatCount;
948 $cache[$name]['pagesincategory_files'] = $fileCount;
949 }
950
951 $count = $cache[$name][$type];
952return self::formatRaw( $count, $raw, $parser->getTargetLanguage() );
953 }
954
964publicstaticfunctionpagesize( $parser, $page ='', $raw =null ) {
965 $title = Title::newFromText( $page );
966
967if ( !is_object( $title ) || $title->isExternal() ) {
968return self::formatRaw( 0, $raw, $parser->getTargetLanguage() );
969 }
970
971// fetch revision from cache/database and return the value
972 $rev = self::getCachedRevisionObject( $parser, $title, ParserOutputFlags::VARY_REVISION_SHA1 );
973 $length = $rev ? $rev->getSize() : 0;
974if ( $length ===null ) {
975// We've had bugs where rev_len was not being recorded for empty pages, see T135414
976 $length = 0;
977 }
978return self::formatRaw( $length, $raw, $parser->getTargetLanguage() );
979 }
980
993publicstaticfunctionprotectionlevel( $parser, $type ='', $title ='' ) {
994 $titleObject = Title::newFromText( $title ) ?? $parser->getTitle();
995 $restrictionStore =MediaWikiServices::getInstance()->getRestrictionStore();
996if ( $restrictionStore->areRestrictionsLoaded( $titleObject ) || $parser->incrementExpensiveFunctionCount() ) {
997 $restrictions = $restrictionStore->getRestrictions( $titleObject, strtolower( $type ) );
998 # RestrictionStore::getRestrictions returns an array, its possible it may have
999 # multiple values in the future
1000return implode(',', $restrictions );
1001 }
1002return'';
1003 }
1004
1017publicstaticfunctionprotectionexpiry( $parser, $type ='', $title ='' ) {
1018 $titleObject = Title::newFromText( $title ) ?? $parser->getTitle();
1019 $restrictionStore =MediaWikiServices::getInstance()->getRestrictionStore();
1020if ( $restrictionStore->areRestrictionsLoaded( $titleObject ) || $parser->incrementExpensiveFunctionCount() ) {
1021// getRestrictionExpiry() returns null on invalid type; trying to
1022// match protectionlevel() function that returns empty string instead
1023return $restrictionStore->getRestrictionExpiry( $titleObject, strtolower( $type ) ) ??'';
1024 }
1025return'';
1026 }
1027
1036publicstaticfunctionlanguage( $parser, $code ='', $inLanguage ='' ) {
1037if ( $code ==='' ) {
1038 $code = $parser->getTargetLanguage()->getCode();
1039 }
1040if ( $inLanguage ==='' ) {
1041 $inLanguage = LanguageNameUtils::AUTONYMS;
1042 }
1044 ->getLanguageNameUtils()
1045 ->getLanguageName( $code, $inLanguage );
1046return $lang !=='' ? $lang : LanguageCode::bcp47( $code );
1047 }
1048
1060publicstaticfunctiondir(Parser $parser,string $code ='',string $arg ='' ): string {
1061 static$magicWords = null;
1062 $languageFactory =MediaWikiServices::getInstance()->getLanguageFactory();
1063
1064if ( $code ==='' ) {
1065 $lang = $parser->getTargetLanguage();
1066 }else {
1067if ( $arg !=='' ) {
1068if ($magicWords ===null ) {
1069$magicWords = $parser->getMagicWordFactory()->newArray( ['language_option_bcp47' ] );
1070 }
1071if ($magicWords->matchStartToEnd( $arg ) ==='language_option_bcp47' ) {
1072// Prefer the BCP-47 interpretation of this code.
1073 $code =new Bcp47CodeValue( $code );
1074 }
1075 }
1076try {
1077 $lang = $languageFactory->getLanguage( $code );
1078 }catch ( InvalidArgumentException ) {
1079 $parser->addTrackingCategory('bad-language-code-category' );
1080return'ltr';
1081 }
1082 }
1083return $lang->getDir();
1084 }
1085
1094publicstaticfunctionbcp47(Parser $parser,string $code ='' ): string {
1095if ( $code ==='' ) {
1096return $parser->getTargetLanguage()->toBcp47Code();
1097 }else {
1098return LanguageCode::bcp47( $code );
1099 }
1100 }
1101
1111publicstaticfunctionpad(
1112 $parser, $string, $length, $padding ='0', $direction = STR_PAD_RIGHT
1113 ) {
1114 $padding = $parser->killMarkers( $padding );
1115 $lengthOfPadding = mb_strlen( $padding );
1116if ( $lengthOfPadding == 0 ) {
1117return $string;
1118 }
1119
1120 # The remaining length to add counts down to 0 as padding is added
1121 $length = min( (int)$length, 500 ) - mb_strlen( $string );
1122if ( $length <= 0 ) {
1123// Nothing to add
1124return $string;
1125 }
1126
1127 # $finalPadding is just $padding repeated enough times so that
1128 # mb_strlen( $string ) + mb_strlen( $finalPadding ) == $length
1129 $finalPadding ='';
1130while ( $length > 0 ) {
1131 # If $length < $lengthofPadding, truncate $padding so we get the
1132 # exact length desired.
1133 $finalPadding .= mb_substr( $padding, 0, $length );
1134 $length -= $lengthOfPadding;
1135 }
1136
1137if ( $direction == STR_PAD_LEFT ) {
1138return $finalPadding . $string;
1139 }else {
1140return $string . $finalPadding;
1141 }
1142 }
1143
1144publicstaticfunctionpadleft( $parser, $string ='', $length = 0, $padding ='0' ) {
1145return self::pad( $parser, $string, $length, $padding, STR_PAD_LEFT );
1146 }
1147
1148publicstaticfunctionpadright( $parser, $string ='', $length = 0, $padding ='0' ) {
1149return self::pad( $parser, $string, $length, $padding );
1150 }
1151
1157publicstaticfunctionanchorencode( $parser, $text ) {
1158 $text = $parser->killMarkers( $text );
1159 $section = substr( $parser->guessSectionNameFromWikiText( $text ), 1 );
1160return Sanitizer::safeEncodeAttribute( $section );
1161 }
1162
1163publicstaticfunctionspecial( $parser, $text ) {
1164 [ $page, $subpage ] = MediaWikiServices::getInstance()->getSpecialPageFactory()->
1165 resolveAlias( $text );
1166if ( $page ) {
1167 $title = SpecialPage::getTitleFor( $page, $subpage );
1168return $title->getPrefixedText();
1169 }else {
1170// unknown special page, just use the given text as its title, if at all possible
1171 $title = Title::makeTitleSafe(NS_SPECIAL, $text );
1172return $title ? $title->getPrefixedText() : self::special( $parser,'Badtitle' );
1173 }
1174 }
1175
1176publicstaticfunctionspeciale( $parser, $text ) {
1177returnwfUrlencode( str_replace(' ','_', self::special( $parser, $text ) ) );
1178 }
1179
1188publicstaticfunctiondefaultsort( $parser, $text, $uarg ='' ) {
1189static$magicWords =null;
1190if ($magicWords ===null ) {
1191$magicWords = $parser->getMagicWordFactory()->newArray(
1192 ['defaultsort_noerror','defaultsort_noreplace' ] );
1193 }
1194 $arg =$magicWords->matchStartToEnd( $uarg );
1195
1196 $text = trim( $text );
1197if ( $text ==='' ) {
1198return'';
1199 }
1200 $old = $parser->getOutput()->getPageProperty('defaultsort' );
1201if ( $old ===null || $arg !=='defaultsort_noreplace' ) {
1202 $parser->getOutput()->setPageProperty('defaultsort', $text );
1203 }
1204
1205if ( $old ===null || $old == $text || $arg ) {
1206return'';
1207 }else {
1208 $converter = $parser->getTargetLanguageConverter();
1209return'<span class="error">' .
1210 $parser->msg('duplicate-defaultsort',
1211// Message should be parsed, but these params should only be escaped.
1212 $converter->markNoConversion(wfEscapeWikiText( $old ) ),
1213 $converter->markNoConversion(wfEscapeWikiText( $text ) )
1214 )->text() .
1215'</span>';
1216 }
1217 }
1218
1230publicstaticfunctionfilepath( $parser, $name ='', $argA ='', $argB ='' ) {
1231 $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $name );
1232
1233if ( $argA =='nowiki' ) {
1234// {{filepath: | option [| size] }}
1235 $isNowiki =true;
1236 $parsedWidthParam = $parser->parseWidthParam( $argB );
1237 }else {
1238// {{filepath: [| size [|option]] }}
1239 $parsedWidthParam = $parser->parseWidthParam( $argA );
1240 $isNowiki = ( $argB =='nowiki' );
1241 }
1242
1243if ( $file ) {
1244$url = $file->getFullUrl();
1245
1246// If a size is requested...
1247if ( count( $parsedWidthParam ) ) {
1248 $mto = $file->transform( $parsedWidthParam );
1249// ... and we can
1250if ( $mto && !$mto->isError() ) {
1251// ... change the URL to point to a thumbnail.
1252 $urlUtils = MediaWikiServices::getInstance()->getUrlUtils();
1253$url = $urlUtils->expand( $mto->getUrl(),PROTO_RELATIVE ) ??false;
1254 }
1255 }
1256if ( $isNowiki ) {
1257return [$url,'nowiki' => true ];
1258 }
1259return$url;
1260 }else {
1261return'';
1262 }
1263 }
1264
1272publicstaticfunctiontagObj( $parser, $frame, $args ) {
1273if ( !count( $args ) ) {
1274return'';
1275 }
1276 $tagName = strtolower( trim( $parser->killMarkers(
1277 $frame->expand( array_shift( $args ) )
1278 ) ) );
1279 $processNowiki = $parser->tagNeedsNowikiStrippedInTagPF( $tagName ) ? PPFrame::PROCESS_NOWIKI : 0;
1280
1281if ( count( $args ) ) {
1282// With Parsoid Fragment support, $processNoWiki flag
1283// isn't actually required as a ::expand() flag, but it
1284// doesn't do any harm.
1285 $inner = $frame->expand( array_shift( $args ), $processNowiki );
1286if ( $processNowiki ) {
1287// This is the T299103 workaround for <syntaxhighlight>,
1288// and reproduces the code in SyntaxHighlight::parserHook.
1289// The Parsoid extension API (SyntaxHighlight::sourceToDom)
1290// doesn't (yet) know about strip state, and so can't do
1291// this itself.
1292 $inner = $parser->getStripState()->unstripNoWiki( $inner );
1293 }
1294 }else {
1295 $inner =null;
1296 }
1297
1298 $attributes = [];
1299foreach ( $args as $arg ) {
1300 $bits = $arg->splitArg();
1301if ( strval( $bits['index'] ) ==='' ) {
1302 $name = trim( $frame->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
1303 $value = trim( $frame->expand( $bits['value'] ) );
1304if ( preg_match('/^(?:["\'](.+)["\']|""|\'\')$/s', $value, $m ) ) {
1305 $value = $m[1] ??'';
1306 }
1307 $attributes[$name] = $value;
1308 }
1309 }
1310
1311 $stripList = $parser->getStripList();
1312if ( !in_array( $tagName, $stripList ) ) {
1313// we can't handle this tag (at least not now), so just re-emit it as an ordinary tag
1314 $attrText ='';
1315foreach ( $attributes as $name => $value ) {
1316 $attrText .=' ' . htmlspecialchars( $name ) .
1317'="' . htmlspecialchars( $parser->killMarkers( $value ), ENT_COMPAT ) .'"';
1318 }
1319if ( $inner ===null ) {
1320return"<$tagName$attrText/>";
1321 }
1322return"<$tagName$attrText>$inner</$tagName>";
1323 }
1324
1325 $params = [
1326'name' => $tagName,
1327'inner' => $inner,
1328'attributes' => $attributes,
1329'close' =>"</$tagName>",
1330 ];
1331return $parser->extensionSubstitution( $params, $frame );
1332 }
1333
1347privatestaticfunction getCachedRevisionObject( $parser, $title, $vary ) {
1348if ( !$title ) {
1349returnnull;
1350 }
1351
1352 $revisionRecord =null;
1353
1354 $isSelfReferential = $title->equals( $parser->getTitle() );
1355if ( $isSelfReferential ) {
1356// Revision is for the same title that is currently being parsed. Only use the last
1357// saved revision, regardless of Parser::getRevisionId() or fake revision injection
1358// callbacks against the current title.
1359
1360// FIXME (T318278): the above is the intention, but doesn't
1361// describe the actual current behavior of this code, since
1362// ->isCurrent() for the last saved revision will return
1363// false so we're going to fall through and end up calling
1364// ->getCurrentRevisionRecordOfTitle().
1365 $parserRevisionRecord = $parser->getRevisionRecordObject();
1366if ( $parserRevisionRecord && $parserRevisionRecord->isCurrent() ) {
1367 $revisionRecord = $parserRevisionRecord;
1368 }
1369 }
1370
1371 $parserOutput = $parser->getOutput();
1372if ( !$revisionRecord ) {
1373if (
1374 !$parser->isCurrentRevisionOfTitleCached( $title ) &&
1375 !$parser->incrementExpensiveFunctionCount()
1376 ) {
1377returnnull;// not allowed
1378 }
1379// Get the current revision, ignoring Parser::getRevisionId() being null/old
1380 $revisionRecord = $parser->fetchCurrentRevisionRecordOfTitle( $title );
1381if ( !$revisionRecord ) {
1382// Convert `false` error return to `null`
1383 $revisionRecord =null;
1384 }
1385// Register dependency in templatelinks
1386 $parserOutput->addTemplate(
1387 $title,
1388 $revisionRecord ? $revisionRecord->getPageId() : 0,
1389 $revisionRecord ? $revisionRecord->getId() : 0
1390 );
1391 }
1392
1393if ( $isSelfReferential ) {
1394wfDebug( __METHOD__ .": used current revision, setting {$vary->value}" );
1395// Upon page save, the result of the parser function using this might change
1396 $parserOutput->setOutputFlag( $vary );
1397if ( $vary === ParserOutputFlags::VARY_REVISION_SHA1 && $revisionRecord ) {
1398try {
1399 $sha1 = $revisionRecord->getSha1();
1400 }catch ( RevisionAccessException ) {
1401 $sha1 =null;
1402 }
1403 $parserOutput->setRevisionUsedSha1Base36( $sha1 );
1404 }
1405 }
1406
1407return $revisionRecord;
1408 }
1409
1417publicstaticfunctionpageid( $parser, $title =null ) {
1418 $t = self::makeTitle( $parser, $title );
1419if ( !$t ) {
1420return'';
1421 } elseif ( !$t->canExist() || $t->isExternal() ) {
1422return 0;// e.g. special page or interwiki link
1423 }
1424
1425 $parserOutput = $parser->getOutput();
1426
1427if ( $t->equals( $parser->getTitle() ) ) {
1428// Revision is for the same title that is currently being parsed.
1429// Use the title from Parser in case a new page ID was injected into it.
1430 $parserOutput->setOutputFlag( ParserOutputFlags::VARY_PAGE_ID );
1431 $id = $parser->getTitle()->getArticleID();
1432if ( $id ) {
1433 $parserOutput->setSpeculativePageIdUsed( $id );
1434 }
1435
1436return $id;
1437 }
1438
1439// Check the link cache for the title
1440 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
1441 $pdbk = $t->getPrefixedDBkey();
1442 $id = $linkCache->getGoodLinkID( $pdbk );
1443if ( $id != 0 || $linkCache->isBadLink( $pdbk ) ) {
1444 $parserOutput->addLink( $t, $id );
1445
1446return $id;
1447 }
1448
1449// We need to load it from the DB, so mark expensive
1450if ( $parser->incrementExpensiveFunctionCount() ) {
1451 $id = $t->getArticleID();
1452 $parserOutput->addLink( $t, $id );
1453
1454return $id;
1455 }
1456
1457returnnull;
1458 }
1459
1467publicstaticfunctionrevisionid( $parser, $title =null ) {
1468 $t = self::makeTitle( $parser, $title );
1469if ( $t ===null || $t->isExternal() ) {
1470return'';
1471 }
1472
1473 $services = MediaWikiServices::getInstance();
1474if (
1475 $t->equals( $parser->getTitle() ) &&
1476 $services->getMainConfig()->get( MainConfigNames::MiserMode ) &&
1477 !$parser->getOptions()->getInterfaceMessage() &&
1478// @TODO: disallow this word on all namespaces (T235957)
1479 $services->getNamespaceInfo()->isSubject( $t->getNamespace() )
1480 ) {
1481// Use a stub result instead of the actual revision ID in order to avoid
1482// double parses on page save but still allow preview detection (T137900)
1483if ( $parser->getRevisionId() || $parser->getOptions()->getSpeculativeRevId() ) {
1484return'-';
1485 }else {
1486 $parser->getOutput()->setOutputFlag( ParserOutputFlags::VARY_REVISION_EXISTS );
1487return'';
1488 }
1489 }
1490// Fetch revision from cache/database and return the value.
1491// Inform the edit saving system that getting the canonical output
1492// after revision insertion requires a parse that used that exact
1493// revision ID.
1494if ( $t->equals( $parser->getTitle() ) && $title ===null ) {
1495// special handling for no-arg case: use speculative rev id
1496// for current page.
1497 $parser->getOutput()->setOutputFlag( ParserOutputFlags::VARY_REVISION_ID );
1498 $id = $parser->getRevisionId();
1499if ( $id === 0 ) {
1500 $rev = $parser->getRevisionRecordObject();
1501if ( $rev ) {
1502 $id = $rev->getId();
1503 }
1504 }
1505if ( !$id ) {
1506 $id = $parser->getOptions()->getSpeculativeRevId();
1507if ( $id ) {
1508 $parser->getOutput()->setSpeculativeRevIdUsed( $id );
1509 }
1510 }
1511return (string)$id;
1512 }
1513 $rev = self::getCachedRevisionObject( $parser, $t, ParserOutputFlags::VARY_REVISION_ID );
1514return $rev ? $rev->getId() :'';
1515 }
1516
1517privatestaticfunction getRevisionTimestampSubstring(
1518Parser $parser,
1519Title $title,
1520int $start,
1521int $len,
1522int $mtts
1523 ): string {
1524// If fetching the revision timestamp of the current page, substitute the
1525// speculative timestamp to be used when this revision is saved. This
1526// avoids having to invalidate the cache immediately by assuming the "last
1527// saved revision" will in fact be this one.
1528// Don't do this for interface messages (eg, edit notices) however; in that
1529// case fall through and use the actual timestamp of the last saved revision.
1530if ( $title->equals( $parser->getTitle() ) && !$parser->getOptions()->getInterfaceMessage() ) {
1531// Get the timezone-adjusted timestamp to be used for this revision
1532 $resNow = substr( $parser->getRevisionTimestamp(), $start, $len );
1533// Possibly set vary-revision if there is not yet an associated revision
1534if ( !$parser->getRevisionRecordObject() ) {
1535// Get the timezone-adjusted timestamp $mtts seconds in the future.
1536// This future is relative to the current time and not that of the
1537// parser options. The rendered timestamp can be compared to that
1538// of the timestamp specified by the parser options.
1539 $resThen = substr(
1540 $parser->getContentLanguage()->userAdjust(wfTimestamp( TS_MW, time() + $mtts ),'' ),
1541 $start,
1542 $len
1543 );
1544
1545if ( $resNow !== $resThen ) {
1546// Inform the edit saving system that getting the canonical output after
1547// revision insertion requires a parse that used an actual revision timestamp
1548 $parser->getOutput()->setOutputFlag( ParserOutputFlags::VARY_REVISION_TIMESTAMP );
1549 }
1550 }
1551
1552return $resNow;
1553 }else {
1554 $rev = self::getCachedRevisionObject( $parser, $title, ParserOutputFlags::VARY_REVISION_TIMESTAMP );
1555if ( !$rev ) {
1556return'';
1557 }
1558 $resNow = substr(
1559 $parser->getContentLanguage()->userAdjust( $rev->getTimestamp(),'' ), $start, $len
1560 );
1561return $resNow;
1562 }
1563 }
1564
1572publicstaticfunctionrevisionday( $parser, $title =null ) {
1573 $t = self::makeTitle( $parser, $title );
1574if ( $t ===null || $t->isExternal() ) {
1575return'';
1576 }
1577return strval( (int)self::getRevisionTimestampSubstring(
1578 $parser, $t, 6, 2, self::MAX_TTS
1579 ) );
1580 }
1581
1589publicstaticfunctionrevisionday2( $parser, $title =null ) {
1590 $t = self::makeTitle( $parser, $title );
1591if ( $t ===null || $t->isExternal() ) {
1592return'';
1593 }
1594return self::getRevisionTimestampSubstring(
1595 $parser, $t, 6, 2, self::MAX_TTS
1596 );
1597 }
1598
1606publicstaticfunctionrevisionmonth( $parser, $title =null ) {
1607 $t = self::makeTitle( $parser, $title );
1608if ( $t ===null || $t->isExternal() ) {
1609return'';
1610 }
1611return self::getRevisionTimestampSubstring(
1612 $parser, $t, 4, 2, self::MAX_TTS
1613 );
1614 }
1615
1623publicstaticfunctionrevisionmonth1( $parser, $title =null ) {
1624 $t = self::makeTitle( $parser, $title );
1625if ( $t ===null || $t->isExternal() ) {
1626return'';
1627 }
1628return strval( (int)self::getRevisionTimestampSubstring(
1629 $parser, $t, 4, 2, self::MAX_TTS
1630 ) );
1631 }
1632
1640publicstaticfunctionrevisionyear( $parser, $title =null ) {
1641 $t = self::makeTitle( $parser, $title );
1642if ( $t ===null || $t->isExternal() ) {
1643return'';
1644 }
1645return self::getRevisionTimestampSubstring(
1646 $parser, $t, 0, 4, self::MAX_TTS
1647 );
1648 }
1649
1657publicstaticfunctionrevisiontimestamp( $parser, $title =null ) {
1658 $t = self::makeTitle( $parser, $title );
1659if ( $t ===null || $t->isExternal() ) {
1660return'';
1661 }
1662return self::getRevisionTimestampSubstring(
1663 $parser, $t, 0, 14, self::MAX_TTS
1664 );
1665 }
1666
1674publicstaticfunctionrevisionuser( $parser, $title =null ) {
1675 $t = self::makeTitle( $parser, $title );
1676if ( $t ===null || $t->isExternal() ) {
1677return'';
1678 }
1679// VARY_USER informs the edit saving system that getting the canonical
1680// output after revision insertion requires a parse that used the
1681// actual user ID.
1682if ( $t->equals( $parser->getTitle() ) ) {
1683// Fall back to Parser's "revision user" for the current title
1684 $parser->getOutput()->setOutputFlag( ParserOutputFlags::VARY_USER );
1685// Note that getRevisionUser() can return null; we need to
1686// be sure to cast this to (an empty) string, since returning
1687// null means "magic variable not handled".
1688return (string)$parser->getRevisionUser();
1689 }
1690// Fetch revision from cache/database and return the value.
1691 $rev = self::getCachedRevisionObject( $parser, $t, ParserOutputFlags::VARY_USER );
1692 $user = ( $rev !== null ) ? $rev->getUser() :null;
1693return $user ? $user->getName() :'';
1694 }
1695
1708publicstaticfunctioncascadingsources( $parser, $title ='' ) {
1709 $titleObject = Title::newFromText( $title ) ?? $parser->getTitle();
1710 $restrictionStore = MediaWikiServices::getInstance()->getRestrictionStore();
1711if ( $restrictionStore->areCascadeProtectionSourcesLoaded( $titleObject )
1713 ) {
1714 $names = [];
1715 $sources = $restrictionStore->getCascadeProtectionSources( $titleObject );
1716 $titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
1717foreach ( $sources[0] as $sourcePageIdentity ) {
1718 $names[] = $titleFormatter->getPrefixedText( $sourcePageIdentity );
1719 }
1720return implode('|', $names );
1721 }
1722return'';
1723 }
1724
1725publicstaticfunctioninterwikilink( $parser, $prefix ='', $title ='', $linkText =null ) {
1726 $services = MediaWikiServices::getInstance();
1727if (
1728 $prefix !=='' &&
1729 $services->getInterwikiLookup()->isValidInterwiki( $prefix )
1730 ) {
1731if ( $linkText !==null ) {
1732 $linkText = Parser::stripOuterParagraph(
1733 # FIXME T382287: whenusingParsoidthis may leave
1734 # strip markers behind for embedded extension tags.
1735 $parser->recursiveTagParseFully( $linkText )
1736 );
1737 }
1738 [ $title, $frag ] = array_pad( explode('#', $title, 2 ), 2,'' );
1739 $target =newTitleValue(NS_MAIN, $title, $frag, $prefix );
1740 $parser->getOutput()->addInterwikiLink( $target );
1741return [
1742'text' => Linker::link( $target, $linkText ),
1743'isHTML' =>true,
1744 ];
1745 }
1746// Invalid interwiki link, render as plain text
1747return ['found' => false ];
1748 }
1749
1750publicstaticfunctioninterlanguagelink( $parser, $prefix ='', $title ='', $linkText =null ) {
1751 $services = MediaWikiServices::getInstance();
1752 $extraInterlanguageLinkPrefixes = $services->getMainConfig()->get(
1753 MainConfigNames::ExtraInterlanguageLinkPrefixes
1754 );
1755if (
1756 $prefix !=='' &&
1757 $services->getInterwikiLookup()->isValidInterwiki( $prefix ) &&
1758 (
1759 $services->getLanguageNameUtils()->getLanguageName(
1760 $prefix, LanguageNameUtils::AUTONYMS, LanguageNameUtils::DEFINED
1761 ) || in_array( $prefix, $extraInterlanguageLinkPrefixes,true )
1762 )
1763 ) {
1764// $linkText is ignored for language links, but fragment is kept
1765 [ $title, $frag ] = array_pad( explode('#', $title, 2 ), 2,'' );
1766 $parser->getOutput()->addLanguageLink(
1767newTitleValue(
1768NS_MAIN, $title, $frag, $prefix
1769 )
1770 );
1771return'';
1772 }
1773// Invalid language link, render as plain text
1774return ['found' => false ];
1775 }
1776}
1777
1779class_alias( CoreParserFunctions::class,'CoreParserFunctions' );
NS_USER
const NS_USER
DefinitionDefines.php:67
NS_FILE
const NS_FILE
DefinitionDefines.php:71
NS_MAIN
const NS_MAIN
DefinitionDefines.php:65
NS_SPECIAL
const NS_SPECIAL
DefinitionDefines.php:54
NS_MEDIA
const NS_MEDIA
DefinitionDefines.php:53
PROTO_RELATIVE
const PROTO_RELATIVE
DefinitionDefines.php:233
NS_CATEGORY
const NS_CATEGORY
DefinitionDefines.php:79
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
DefinitionGlobalFunctions.php:671
wfUrlencode
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
DefinitionGlobalFunctions.php:311
wfEscapeWikiText
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
DefinitionGlobalFunctions.php:1097
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
DefinitionGlobalFunctions.php:1331
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
DefinitionGlobalFunctions.php:859
$magicWords
$magicWords
@phpcs-require-sorted-array
DefinitionMessagesAb.php:70
getTitle
getTitle()
DefinitionRevisionSearchResultTrait.php:84
if
if(!defined('MW_SETUP_CALLBACK'))
DefinitionWebStart.php:82
MediaWiki\Category\Category
Category objects are immutable, strictly speaking.
DefinitionCategory.php:44
MediaWiki\Config\ServiceOptions
A class for passing options to services.
DefinitionServiceOptions.php:26
MediaWiki\Language\LanguageCode
Methods for dealing with language codes.
DefinitionLanguageCode.php:32
MediaWiki\Language\Language
Base class for language-specific code.
DefinitionLanguage.php:81
MediaWiki\Linker\Linker
Some internal bits split of from Skin.php.
DefinitionLinker.php:61
MediaWiki\MainConfigNames
A class containing constants representing the names of configuration variables.
DefinitionMainConfigNames.php:22
MediaWiki\MainConfigNames\AllowSlowParserFunctions
const AllowSlowParserFunctions
Name constant for the AllowSlowParserFunctions setting, for use with Config::get()
DefinitionMainConfigNames.php:1386
MediaWiki\MainConfigNames\AllowDisplayTitle
const AllowDisplayTitle
Name constant for the AllowDisplayTitle setting, for use with Config::get()
DefinitionMainConfigNames.php:2419
MediaWiki\MainConfigNames\RestrictDisplayTitle
const RestrictDisplayTitle
Name constant for the RestrictDisplayTitle setting, for use with Config::get()
DefinitionMainConfigNames.php:2425
MediaWiki\MediaWikiServices
Service locator for MediaWiki core services.
DefinitionMediaWikiServices.php:250
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
DefinitionMediaWikiServices.php:338
MediaWiki\Message\Message
The Message class deals with fetching and processing of interface message into a variety of formats.
DefinitionMessage.php:157
MediaWiki\Message\Message\plaintextParam
static plaintextParam( $plaintext)
DefinitionMessage.php:1354
MediaWiki\Parser\CoreParserFunctions
Various core parser functions, registered in every Parser.
DefinitionCoreParserFunctions.php:51
MediaWiki\Parser\CoreParserFunctions\pagesize
static pagesize( $parser, $page='', $raw=null)
Return the size of the given page, or 0 if it's nonexistent.
DefinitionCoreParserFunctions.php:964
MediaWiki\Parser\CoreParserFunctions\pagesincategory
static pagesincategory( $parser, $name='', $arg1='', $arg2='')
Return the number of pages, files or subcats in the given category, or 0 if it's nonexistent.
DefinitionCoreParserFunctions.php:897
MediaWiki\Parser\CoreParserFunctions\lc
static lc( $parser, $s='')
DefinitionCoreParserFunctions.php:273
MediaWiki\Parser\CoreParserFunctions\speciale
static speciale( $parser, $text)
DefinitionCoreParserFunctions.php:1176
MediaWiki\Parser\CoreParserFunctions\language
static language( $parser, $code='', $inLanguage='')
Gives language names.
DefinitionCoreParserFunctions.php:1036
MediaWiki\Parser\CoreParserFunctions\bcp47
static bcp47(Parser $parser, string $code='')
Gives the BCP-47 code for a language given the mediawiki internal language code.
DefinitionCoreParserFunctions.php:1094
MediaWiki\Parser\CoreParserFunctions\numberofedits
static numberofedits( $parser, $raw=null)
DefinitionCoreParserFunctions.php:666
MediaWiki\Parser\CoreParserFunctions\bidi
static bidi( $parser, $text='')
DefinitionCoreParserFunctions.php:493
MediaWiki\Parser\CoreParserFunctions\namespacenumber
static namespacenumber( $parser, $title=null)
DefinitionCoreParserFunctions.php:728
MediaWiki\Parser\CoreParserFunctions\revisiontimestamp
static revisiontimestamp( $parser, $title=null)
Get the timestamp from the last revision of a specified page.
DefinitionCoreParserFunctions.php:1657
MediaWiki\Parser\CoreParserFunctions\defaultsort
static defaultsort( $parser, $text, $uarg='')
DefinitionCoreParserFunctions.php:1188
MediaWiki\Parser\CoreParserFunctions\basepagename
static basepagename( $parser, $title=null)
DefinitionCoreParserFunctions.php:839
MediaWiki\Parser\CoreParserFunctions\formal
static formal(Parser $parser, string ... $forms)
DefinitionCoreParserFunctions.php:483
MediaWiki\Parser\CoreParserFunctions\namespacee
static namespacee( $parser, $title=null)
DefinitionCoreParserFunctions.php:720
MediaWiki\Parser\CoreParserFunctions\numberofpages
static numberofpages( $parser, $raw=null)
DefinitionCoreParserFunctions.php:638
MediaWiki\Parser\CoreParserFunctions\dir
static dir(Parser $parser, string $code='', string $arg='')
Gives direction of script of a language given a language code.
DefinitionCoreParserFunctions.php:1060
MediaWiki\Parser\CoreParserFunctions\pagesinnamespace
static pagesinnamespace( $parser, $namespace=0, $raw=null)
DefinitionCoreParserFunctions.php:670
MediaWiki\Parser\CoreParserFunctions\numberingroup
static numberingroup( $parser, $name='', $raw=null)
DefinitionCoreParserFunctions.php:678
MediaWiki\Parser\CoreParserFunctions\interlanguagelink
static interlanguagelink( $parser, $prefix='', $title='', $linkText=null)
DefinitionCoreParserFunctions.php:1750
MediaWiki\Parser\CoreParserFunctions\fullurle
static fullurle( $parser, $s='', $arg=null)
DefinitionCoreParserFunctions.php:303
MediaWiki\Parser\CoreParserFunctions\pageid
static pageid( $parser, $title=null)
Get the pageid of a specified page.
DefinitionCoreParserFunctions.php:1417
MediaWiki\Parser\CoreParserFunctions\intFunction
static intFunction( $parser, $part1='',... $params)
DefinitionCoreParserFunctions.php:164
MediaWiki\Parser\CoreParserFunctions\tagObj
static tagObj( $parser, $frame, $args)
Parser function to extension tag adaptor.
DefinitionCoreParserFunctions.php:1272
MediaWiki\Parser\CoreParserFunctions\numberofusers
static numberofusers( $parser, $raw=null)
DefinitionCoreParserFunctions.php:642
MediaWiki\Parser\CoreParserFunctions\formatDate
static formatDate( $parser, $date, $defaultPref=null)
DefinitionCoreParserFunctions.php:181
MediaWiki\Parser\CoreParserFunctions\talkspacee
static talkspacee( $parser, $title=null)
DefinitionCoreParserFunctions.php:744
MediaWiki\Parser\CoreParserFunctions\subjectpagenamee
static subjectpagenamee( $parser, $title=null)
DefinitionCoreParserFunctions.php:879
MediaWiki\Parser\CoreParserFunctions\rootpagename
static rootpagename( $parser, $title=null)
DefinitionCoreParserFunctions.php:823
MediaWiki\Parser\CoreParserFunctions\cascadingsources
static cascadingsources( $parser, $title='')
Returns the sources of any cascading protection acting on a specified page.
DefinitionCoreParserFunctions.php:1708
MediaWiki\Parser\CoreParserFunctions\fullpagename
static fullpagename( $parser, $title=null)
DefinitionCoreParserFunctions.php:791
MediaWiki\Parser\CoreParserFunctions\formatRaw
static formatRaw( $num, $raw, $language, ?MagicWordFactory $magicWordFactory=null)
Formats a number according to a language.
DefinitionCoreParserFunctions.php:624
MediaWiki\Parser\CoreParserFunctions\plural
static plural( $parser, $text='',... $forms)
DefinitionCoreParserFunctions.php:476
MediaWiki\Parser\CoreParserFunctions\subpagenamee
static subpagenamee( $parser, $title=null)
DefinitionCoreParserFunctions.php:815
MediaWiki\Parser\CoreParserFunctions\fullpagenamee
static fullpagenamee( $parser, $title=null)
DefinitionCoreParserFunctions.php:799
MediaWiki\Parser\CoreParserFunctions\padright
static padright( $parser, $string='', $length=0, $padding='0')
DefinitionCoreParserFunctions.php:1148
MediaWiki\Parser\CoreParserFunctions\urlFunction
static urlFunction( $func, $s='', $arg=null)
DefinitionCoreParserFunctions.php:325
MediaWiki\Parser\CoreParserFunctions\talkpagenamee
static talkpagenamee( $parser, $title=null)
DefinitionCoreParserFunctions.php:863
MediaWiki\Parser\CoreParserFunctions\canonicalurl
static canonicalurl( $parser, $s='', $arg=null)
DefinitionCoreParserFunctions.php:312
MediaWiki\Parser\CoreParserFunctions\pad
static pad( $parser, $string, $length, $padding='0', $direction=STR_PAD_RIGHT)
Unicode-safe str_pad with the restriction that $length is forced to be <= 500.
DefinitionCoreParserFunctions.php:1111
MediaWiki\Parser\CoreParserFunctions\revisionday2
static revisionday2( $parser, $title=null)
Get the day with leading zeros from the last revision of a specified page.
DefinitionCoreParserFunctions.php:1589
MediaWiki\Parser\CoreParserFunctions\protectionexpiry
static protectionexpiry( $parser, $type='', $title='')
Returns the requested protection expiry for the current page.
DefinitionCoreParserFunctions.php:1017
MediaWiki\Parser\CoreParserFunctions\ucfirst
static ucfirst( $parser, $s='')
DefinitionCoreParserFunctions.php:264
MediaWiki\Parser\CoreParserFunctions\uc
static uc( $parser, $s='')
DefinitionCoreParserFunctions.php:282
MediaWiki\Parser\CoreParserFunctions\talkspace
static talkspace( $parser, $title=null)
DefinitionCoreParserFunctions.php:736
MediaWiki\Parser\CoreParserFunctions\anchorencode
static anchorencode( $parser, $text)
DefinitionCoreParserFunctions.php:1157
MediaWiki\Parser\CoreParserFunctions\numberofactiveusers
static numberofactiveusers( $parser, $raw=null)
DefinitionCoreParserFunctions.php:646
MediaWiki\Parser\CoreParserFunctions\subjectspacee
static subjectspacee( $parser, $title=null)
DefinitionCoreParserFunctions.php:760
MediaWiki\Parser\CoreParserFunctions\pagenamee
static pagenamee( $parser, $title=null)
DefinitionCoreParserFunctions.php:783
MediaWiki\Parser\CoreParserFunctions\grammar
static grammar( $parser, $case='', $word='')
DefinitionCoreParserFunctions.php:427
MediaWiki\Parser\CoreParserFunctions\revisionuser
static revisionuser( $parser, $title=null)
Get the user from the last revision of a specified page.
DefinitionCoreParserFunctions.php:1674
MediaWiki\Parser\CoreParserFunctions\padleft
static padleft( $parser, $string='', $length=0, $padding='0')
DefinitionCoreParserFunctions.php:1144
MediaWiki\Parser\CoreParserFunctions\localurl
static localurl( $parser, $s='', $arg=null)
DefinitionCoreParserFunctions.php:286
MediaWiki\Parser\CoreParserFunctions\urlencode
static urlencode( $parser, $s='', $arg=null)
urlencodes a string according to one of three patterns: (T24474)
DefinitionCoreParserFunctions.php:232
MediaWiki\Parser\CoreParserFunctions\localurle
static localurle( $parser, $s='', $arg=null)
DefinitionCoreParserFunctions.php:290
MediaWiki\Parser\CoreParserFunctions\nse
static nse( $parser, $part1='')
DefinitionCoreParserFunctions.php:212
MediaWiki\Parser\CoreParserFunctions\formatnum
static formatnum( $parser, $num='', $arg1='', $arg2='')
DefinitionCoreParserFunctions.php:354
MediaWiki\Parser\CoreParserFunctions\rootpagenamee
static rootpagenamee( $parser, $title=null)
DefinitionCoreParserFunctions.php:831
MediaWiki\Parser\CoreParserFunctions\protectionlevel
static protectionlevel( $parser, $type='', $title='')
Returns the requested protection level for the current page.
DefinitionCoreParserFunctions.php:993
MediaWiki\Parser\CoreParserFunctions\subpagename
static subpagename( $parser, $title=null)
DefinitionCoreParserFunctions.php:807
MediaWiki\Parser\CoreParserFunctions\subjectpagename
static subjectpagename( $parser, $title=null)
DefinitionCoreParserFunctions.php:871
MediaWiki\Parser\CoreParserFunctions\interwikilink
static interwikilink( $parser, $prefix='', $title='', $linkText=null)
DefinitionCoreParserFunctions.php:1725
MediaWiki\Parser\CoreParserFunctions\numberofadmins
static numberofadmins( $parser, $raw=null)
DefinitionCoreParserFunctions.php:658
MediaWiki\Parser\CoreParserFunctions\revisionday
static revisionday( $parser, $title=null)
Get the day from the last revision of a specified page.
DefinitionCoreParserFunctions.php:1572
MediaWiki\Parser\CoreParserFunctions\canonicalurle
static canonicalurle( $parser, $s='', $arg=null)
DefinitionCoreParserFunctions.php:316
MediaWiki\Parser\CoreParserFunctions\subjectspace
static subjectspace( $parser, $title=null)
DefinitionCoreParserFunctions.php:752
MediaWiki\Parser\CoreParserFunctions\ns
static ns( $parser, $part1='')
DefinitionCoreParserFunctions.php:199
MediaWiki\Parser\CoreParserFunctions\revisionmonth
static revisionmonth( $parser, $title=null)
Get the month with leading zeros from the last revision of a specified page.
DefinitionCoreParserFunctions.php:1606
MediaWiki\Parser\CoreParserFunctions\basepagenamee
static basepagenamee( $parser, $title=null)
DefinitionCoreParserFunctions.php:847
MediaWiki\Parser\CoreParserFunctions\gender
static gender( $parser, $username,... $forms)
DefinitionCoreParserFunctions.php:438
MediaWiki\Parser\CoreParserFunctions\revisionyear
static revisionyear( $parser, $title=null)
Get the year from the last revision of a specified page.
DefinitionCoreParserFunctions.php:1640
MediaWiki\Parser\CoreParserFunctions\pagename
static pagename( $parser, $title=null)
Functions to get and normalize pagenames, corresponding to the magic words of the same names.
DefinitionCoreParserFunctions.php:775
MediaWiki\Parser\CoreParserFunctions\fullurl
static fullurl( $parser, $s='', $arg=null)
DefinitionCoreParserFunctions.php:299
MediaWiki\Parser\CoreParserFunctions\numberofarticles
static numberofarticles( $parser, $raw=null)
DefinitionCoreParserFunctions.php:650
MediaWiki\Parser\CoreParserFunctions\special
static special( $parser, $text)
DefinitionCoreParserFunctions.php:1163
MediaWiki\Parser\CoreParserFunctions\lcfirst
static lcfirst( $parser, $s='')
DefinitionCoreParserFunctions.php:260
MediaWiki\Parser\CoreParserFunctions\revisionmonth1
static revisionmonth1( $parser, $title=null)
Get the month from the last revision of a specified page.
DefinitionCoreParserFunctions.php:1623
MediaWiki\Parser\CoreParserFunctions\displaytitle
static displaytitle( $parser, $text='', $uarg='')
Override the title of the page when viewed, provided we've been given a title which will normalise to...
DefinitionCoreParserFunctions.php:506
MediaWiki\Parser\CoreParserFunctions\talkpagename
static talkpagename( $parser, $title=null)
DefinitionCoreParserFunctions.php:855
MediaWiki\Parser\CoreParserFunctions\revisionid
static revisionid( $parser, $title=null)
Get the id from the last revision of a specified page.
DefinitionCoreParserFunctions.php:1467
MediaWiki\Parser\CoreParserFunctions\numberoffiles
static numberoffiles( $parser, $raw=null)
DefinitionCoreParserFunctions.php:654
MediaWiki\Parser\CoreParserFunctions\REGISTER_OPTIONS
const REGISTER_OPTIONS
DefinitionCoreParserFunctions.php:58
MediaWiki\Parser\CoreParserFunctions\filepath
static filepath( $parser, $name='', $argA='', $argB='')
Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}} or {{...
DefinitionCoreParserFunctions.php:1230
MediaWiki\Parser\MagicWordFactory
Store information about magic words, and create/cache MagicWord objects.
DefinitionMagicWordFactory.php:39
MediaWiki\Parser\MagicWordFactory\get
get( $id)
Get a MagicWord object for a given internal ID.
DefinitionMagicWordFactory.php:174
MediaWiki\Parser\Parser
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
DefinitionParser.php:147
MediaWiki\Parser\Parser\getOptions
getOptions()
DefinitionParser.php:1133
MediaWiki\Parser\Parser\getTargetLanguageConverter
getTargetLanguageConverter()
Shorthand for getting a Language Converter for Target language.
DefinitionParser.php:1666
MediaWiki\Parser\Parser\addTrackingCategory
addTrackingCategory( $msg)
DefinitionParser.php:4235
MediaWiki\Parser\Parser\SFH_OBJECT_ARGS
const SFH_OBJECT_ARGS
DefinitionParser.php:152
MediaWiki\Parser\Parser\markerSkipCallback
markerSkipCallback( $s, callable $callback)
Call a callback function on all regions of the given text that are not inside strip markers,...
DefinitionParser.php:6373
MediaWiki\Parser\Parser\getTitle
getTitle()
DefinitionParser.php:1032
MediaWiki\Parser\Parser\tagNeedsNowikiStrippedInTagPF
tagNeedsNowikiStrippedInTagPF(string $lowerTagName)
DefinitionParser.php:4025
MediaWiki\Parser\Parser\getMagicWordFactory
getMagicWordFactory()
Get the MagicWordFactory that this Parser is using.
DefinitionParser.php:1247
MediaWiki\Parser\Parser\setFunctionHook
setFunctionHook( $id, callable $callback, $flags=0)
Create a function, e.g.
DefinitionParser.php:5135
MediaWiki\Parser\Parser\guessSectionNameFromWikiText
guessSectionNameFromWikiText( $text)
Try to guess the section anchor name based on a wikitext fragment presumably extracted from a heading...
DefinitionParser.php:6268
MediaWiki\Parser\Parser\incrementExpensiveFunctionCount
incrementExpensiveFunctionCount()
DefinitionParser.php:4166
MediaWiki\Parser\Parser\isCurrentRevisionOfTitleCached
isCurrentRevisionOfTitleCached(LinkTarget $link)
DefinitionParser.php:3635
MediaWiki\Parser\Parser\getRevisionId
getRevisionId()
Get the ID of the revision we are parsing.
DefinitionParser.php:6087
MediaWiki\Parser\Parser\getContentLanguage
getContentLanguage()
Get the content language that this Parser is using.
DefinitionParser.php:1257
MediaWiki\Parser\Parser\parseWidthParam
parseWidthParam( $value, $parseHeight=true, bool $localized=false)
Parsed a width param of imagelink like 300px or 200x300px.
DefinitionParser.php:6421
MediaWiki\Parser\Parser\killMarkers
killMarkers( $text)
Remove any strip markers found in the given text.
DefinitionParser.php:6404
MediaWiki\Parser\Parser\getOutput
getOutput()
DefinitionParser.php:1119
MediaWiki\Parser\Parser\getRevisionUser
getRevisionUser()
Get the name of the user that edited the last revision.
DefinitionParser.php:6182
MediaWiki\Parser\Parser\getTargetLanguage
getTargetLanguage()
Get the target language for the content being parsed.
DefinitionParser.php:1193
MediaWiki\Parser\Parser\msg
msg(string $msg,... $params)
Helper function to correctly set the target language and title of a message based on the parser conte...
DefinitionParser.php:4256
MediaWiki\Parser\Parser\SFH_NO_HASH
const SFH_NO_HASH
DefinitionParser.php:151
MediaWiki\Parser\Parser\getStripList
getStripList()
Get a list of strippable XML-like elements.
DefinitionParser.php:1353
MediaWiki\Parser\Parser\extensionSubstitution
extensionSubstitution(array $params, PPFrame $frame, bool $processNowiki=false)
Return the text to be used for a given extension tag.
DefinitionParser.php:4049
MediaWiki\Parser\Parser\getRevisionRecordObject
getRevisionRecordObject()
Get the revision record object for $this->mRevisionId.
DefinitionParser.php:6097
MediaWiki\Parser\Parser\getRevisionTimestamp
getRevisionTimestamp()
Get the timestamp associated with the current revision, adjusted for the default server-local timesta...
DefinitionParser.php:6154
MediaWiki\Parser\Parser\getStripState
getStripState()
DefinitionParser.php:1361
MediaWiki\Parser\Parser\doQuotes
doQuotes( $text)
Helper function for handleAllQuotes()
DefinitionParser.php:2000
MediaWiki\Parser\Parser\recursiveTagParseFully
recursiveTagParseFully( $text, $frame=false)
Fully parse wikitext to fully parsed HTML.
DefinitionParser.php:899
MediaWiki\Parser\Parser\fetchCurrentRevisionRecordOfTitle
fetchCurrentRevisionRecordOfTitle(LinkTarget $link)
Fetch the current revision of a given title as a RevisionRecord.
DefinitionParser.php:3606
MediaWiki\Parser\Sanitizer\stripAllTags
static stripAllTags(string $html)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed,...
DefinitionSanitizer.php:1794
MediaWiki\Parser\Sanitizer\checkCss
static checkCss( $value)
Pick apart some CSS and check it for forbidden or unsafe structures.
DefinitionSanitizer.php:712
MediaWiki\Parser\Sanitizer\decodeCharReferencesAndNormalize
static decodeCharReferencesAndNormalize(string $text)
Decode any character references, numeric or named entities, in the next and normalize the resulting s...
DefinitionSanitizer.php:1295
MediaWiki\Parser\Sanitizer\removeSomeTags
static removeSomeTags(string $text, array $options=[])
Cleans up HTML, removes dangerous tags and attributes, and removes HTML comments; the result will alw...
DefinitionSanitizer.php:343
MediaWiki\Revision\RevisionAccessException
Exception representing a failure to look up a revision.
DefinitionRevisionAccessException.php:37
MediaWiki\Revision\RevisionRecord
Page revision base class.
DefinitionRevisionRecord.php:49
MediaWiki\SiteStats\SiteStats
Static accessor class for site_stats and related things.
DefinitionSiteStats.php:36
MediaWiki\SpecialPage\SpecialPage
Parent class for all special pages.
DefinitionSpecialPage.php:65
MediaWiki\Title\TitleValue
Represents the target of a wiki link.
DefinitionTitleValue.php:47
MediaWiki\Title\Title
Represents a title within MediaWiki.
DefinitionTitle.php:78
MediaWiki\Title\Title\inNamespace
inNamespace(int $ns)
Returns true if the title is inside the specified namespace.
DefinitionTitle.php:1304
MediaWiki\Title\Title\equals
equals(object $other)
Compares with another Title.
DefinitionTitle.php:3109
MediaWiki\Title\Title\getDBkey
getDBkey()
Get the main part with underscores.
DefinitionTitle.php:1037
MediaWiki\Title\Title\getText
getText()
Get the text form (spaces not underscores) of the main part.
DefinitionTitle.php:1019
MediaWiki\User\Options\UserOptionsLookup\getDefaultOption
getDefaultOption(string $opt, ?UserIdentity $userIdentity=null)
Get a given default option value.
DefinitionUserOptionsLookup.php:69
MediaWiki\User\User
User class for the MediaWiki software.
DefinitionUser.php:123
MediaWiki\Linker\LinkTarget\hasFragment
hasFragment()
Whether the link target has a fragment.
MediaWiki\Parser\CoreParserFunctions\null\$t
$t
DefinitionCoreParserFunctions.php:713
MediaWiki\Parser
DefinitionBlockLevelPass.php:27
$url
$url
Definitionopensearch_desc.php:37

[8]ページ先頭

©2009-2025 Movatter.jp