MediaWiki  master
CoreParserFunctions.php
Go to the documentation of this file.
1 <?php
24 
34  public static function register( $parser ) {
36 
37  # Syntax for arguments (see Parser::setFunctionHook):
38  # "name for lookup in localized magic words array",
39  # function callback,
40  # optional Parser::SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}}
41  # instead of {{#int:...}})
42  $noHashFunctions = [
43  'ns', 'nse', 'urlencode', 'lcfirst', 'ucfirst', 'lc', 'uc',
44  'localurl', 'localurle', 'fullurl', 'fullurle', 'canonicalurl',
45  'canonicalurle', 'formatnum', 'grammar', 'gender', 'plural', 'bidi',
46  'numberofpages', 'numberofusers', 'numberofactiveusers',
47  'numberofarticles', 'numberoffiles', 'numberofadmins',
48  'numberingroup', 'numberofedits', 'language',
49  'padleft', 'padright', 'anchorencode', 'defaultsort', 'filepath',
50  'pagesincategory', 'pagesize', 'protectionlevel', 'protectionexpiry',
51  'namespacee', 'namespacenumber', 'talkspace', 'talkspacee',
52  'subjectspace', 'subjectspacee', 'pagename', 'pagenamee',
53  'fullpagename', 'fullpagenamee', 'rootpagename', 'rootpagenamee',
54  'basepagename', 'basepagenamee', 'subpagename', 'subpagenamee',
55  'talkpagename', 'talkpagenamee', 'subjectpagename',
56  'subjectpagenamee', 'pageid', 'revisionid', 'revisionday',
57  'revisionday2', 'revisionmonth', 'revisionmonth1', 'revisionyear',
58  'revisiontimestamp', 'revisionuser', 'cascadingsources',
59  ];
60  foreach ( $noHashFunctions as $func ) {
61  $parser->setFunctionHook( $func, [ __CLASS__, $func ], Parser::SFH_NO_HASH );
62  }
63 
64  $parser->setFunctionHook(
65  'namespace',
66  [ __CLASS__, 'mwnamespace' ],
68  );
69  $parser->setFunctionHook( 'int', [ __CLASS__, 'intFunction' ], Parser::SFH_NO_HASH );
70  $parser->setFunctionHook( 'special', [ __CLASS__, 'special' ] );
71  $parser->setFunctionHook( 'speciale', [ __CLASS__, 'speciale' ] );
72  $parser->setFunctionHook( 'tag', [ __CLASS__, 'tagObj' ], Parser::SFH_OBJECT_ARGS );
73  $parser->setFunctionHook( 'formatdate', [ __CLASS__, 'formatDate' ] );
74 
75  if ( $wgAllowDisplayTitle ) {
76  $parser->setFunctionHook(
77  'displaytitle',
78  [ __CLASS__, 'displaytitle' ],
80  );
81  }
82  if ( $wgAllowSlowParserFunctions ) {
83  $parser->setFunctionHook(
84  'pagesinnamespace',
85  [ __CLASS__, 'pagesinnamespace' ],
87  );
88  }
89  }
90 
97  public static function intFunction( $parser, $part1 = '', ...$params ) {
98  if ( strval( $part1 ) !== '' ) {
99  $message = wfMessage( $part1, $params )
100  ->inLanguage( $parser->getOptions()->getUserLangObj() );
101  return [ $message->plain(), 'noparse' => false ];
102  } else {
103  return [ 'found' => false ];
104  }
105  }
106 
114  public static function formatDate( $parser, $date, $defaultPref = null ) {
115  $lang = $parser->getFunctionLang();
116  $df = MediaWikiServices::getInstance()->getDateFormatterFactory()->get( $lang );
117 
118  $date = trim( $date );
119 
120  $pref = $parser->getOptions()->getDateFormat();
121 
122  // Specify a different default date format other than the normal default
123  // if the user has 'default' for their setting
124  if ( $pref == 'default' && $defaultPref ) {
125  $pref = $defaultPref;
126  }
127 
128  $date = $df->reformat( $pref, $date, [ 'match-whole' ] );
129  return $date;
130  }
131 
132  public static function ns( $parser, $part1 = '' ) {
133  if ( intval( $part1 ) || $part1 == "0" ) {
134  $index = intval( $part1 );
135  } else {
136  $index = $parser->getContentLanguage()->getNsIndex( str_replace( ' ', '_', $part1 ) );
137  }
138  if ( $index !== false ) {
139  return $parser->getContentLanguage()->getFormattedNsText( $index );
140  } else {
141  return [ 'found' => false ];
142  }
143  }
144 
145  public static function nse( $parser, $part1 = '' ) {
146  $ret = self::ns( $parser, $part1 );
147  if ( is_string( $ret ) ) {
148  $ret = wfUrlencode( str_replace( ' ', '_', $ret ) );
149  }
150  return $ret;
151  }
152 
165  public static function urlencode( $parser, $s = '', $arg = null ) {
166  static $magicWords = null;
167  if ( is_null( $magicWords ) ) {
168  $magicWords =
169  $parser->getMagicWordFactory()->newArray( [ 'url_path', 'url_query', 'url_wiki' ] );
170  }
171  switch ( $magicWords->matchStartToEnd( $arg ) ) {
172  // Encode as though it's a wiki page, '_' for ' '.
173  case 'url_wiki':
174  $func = 'wfUrlencode';
175  $s = str_replace( ' ', '_', $s );
176  break;
177 
178  // Encode for an HTTP Path, '%20' for ' '.
179  case 'url_path':
180  $func = 'rawurlencode';
181  break;
182 
183  // Encode for HTTP query, '+' for ' '.
184  case 'url_query':
185  default:
186  $func = 'urlencode';
187  }
188  // See T105242, where the choice to kill markers and various
189  // other options were discussed.
190  return $func( $parser->killMarkers( $s ) );
191  }
192 
193  public static function lcfirst( $parser, $s = '' ) {
194  return $parser->getContentLanguage()->lcfirst( $s );
195  }
196 
197  public static function ucfirst( $parser, $s = '' ) {
198  return $parser->getContentLanguage()->ucfirst( $s );
199  }
200 
206  public static function lc( $parser, $s = '' ) {
207  return $parser->markerSkipCallback( $s, [ $parser->getContentLanguage(), 'lc' ] );
208  }
209 
215  public static function uc( $parser, $s = '' ) {
216  return $parser->markerSkipCallback( $s, [ $parser->getContentLanguage(), 'uc' ] );
217  }
218 
219  public static function localurl( $parser, $s = '', $arg = null ) {
220  return self::urlFunction( 'getLocalURL', $s, $arg );
221  }
222 
223  public static function localurle( $parser, $s = '', $arg = null ) {
224  $temp = self::urlFunction( 'getLocalURL', $s, $arg );
225  if ( !is_string( $temp ) ) {
226  return $temp;
227  } else {
228  return htmlspecialchars( $temp );
229  }
230  }
231 
232  public static function fullurl( $parser, $s = '', $arg = null ) {
233  return self::urlFunction( 'getFullURL', $s, $arg );
234  }
235 
236  public static function fullurle( $parser, $s = '', $arg = null ) {
237  $temp = self::urlFunction( 'getFullURL', $s, $arg );
238  if ( !is_string( $temp ) ) {
239  return $temp;
240  } else {
241  return htmlspecialchars( $temp );
242  }
243  }
244 
245  public static function canonicalurl( $parser, $s = '', $arg = null ) {
246  return self::urlFunction( 'getCanonicalURL', $s, $arg );
247  }
248 
249  public static function canonicalurle( $parser, $s = '', $arg = null ) {
250  $temp = self::urlFunction( 'getCanonicalURL', $s, $arg );
251  if ( !is_string( $temp ) ) {
252  return $temp;
253  } else {
254  return htmlspecialchars( $temp );
255  }
256  }
257 
258  public static function urlFunction( $func, $s = '', $arg = null ) {
260  # Due to order of execution of a lot of bits, the values might be encoded
261  # before arriving here; if that's true, then the title can't be created
262  # and the variable will fail. If we can't get a decent title from the first
263  # attempt, url-decode and try for a second.
264  if ( is_null( $title ) ) {
265  $title = Title::newFromURL( urldecode( $s ) );
266  }
267  if ( !is_null( $title ) ) {
268  # Convert NS_MEDIA -> NS_FILE
269  if ( $title->inNamespace( NS_MEDIA ) ) {
270  $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
271  }
272  if ( !is_null( $arg ) ) {
273  $text = $title->$func( $arg );
274  } else {
275  $text = $title->$func();
276  }
277  return $text;
278  } else {
279  return [ 'found' => false ];
280  }
281  }
282 
289  public static function formatnum( $parser, $num = '', $arg = null ) {
290  if ( self::matchAgainstMagicword( $parser->getMagicWordFactory(), 'rawsuffix', $arg ) ) {
291  $func = [ $parser->getFunctionLang(), 'parseFormattedNumber' ];
292  } elseif (
293  self::matchAgainstMagicword( $parser->getMagicWordFactory(), 'nocommafysuffix', $arg )
294  ) {
295  $func = [ $parser->getFunctionLang(), 'formatNumNoSeparators' ];
296  } else {
297  $func = [ $parser->getFunctionLang(), 'formatNum' ];
298  }
299  return $parser->markerSkipCallback( $num, $func );
300  }
301 
308  public static function grammar( $parser, $case = '', $word = '' ) {
309  $word = $parser->killMarkers( $word );
310  return $parser->getFunctionLang()->convertGrammar( $word, $case );
311  }
312 
319  public static function gender( $parser, $username, ...$forms ) {
320  // Some shortcuts to avoid loading user data unnecessarily
321  if ( count( $forms ) === 0 ) {
322  return '';
323  } elseif ( count( $forms ) === 1 ) {
324  return $forms[0];
325  }
326 
327  $username = trim( $username );
328 
329  $gender = User::getDefaultOption( 'gender' );
330 
331  // allow prefix and normalize (e.g. "&#42;foo" -> "*foo" ).
333 
334  if ( $title && $title->inNamespace( NS_USER ) ) {
335  $username = $title->getText();
336  }
337 
338  // check parameter, or use the ParserOptions if in interface message
340  $genderCache = MediaWikiServices::getInstance()->getGenderCache();
341  if ( $user ) {
342  $gender = $genderCache->getGenderOf( $user, __METHOD__ );
343  } elseif ( $username === '' && $parser->getOptions()->getInterfaceMessage() ) {
344  $gender = $genderCache->getGenderOf( $parser->getOptions()->getUser(), __METHOD__ );
345  }
346  $ret = $parser->getFunctionLang()->gender( $gender, $forms );
347  return $ret;
348  }
349 
356  public static function plural( $parser, $text = '', ...$forms ) {
357  $text = $parser->getFunctionLang()->parseFormattedNumber( $text );
358  settype( $text, ctype_digit( $text ) ? 'int' : 'float' );
359  return $parser->getFunctionLang()->convertPlural( $text, $forms );
360  }
361 
367  public static function bidi( $parser, $text = '' ) {
368  return $parser->getFunctionLang()->embedBidi( $text );
369  }
370 
380  public static function displaytitle( $parser, $text = '', $uarg = '' ) {
382 
383  static $magicWords = null;
384  if ( is_null( $magicWords ) ) {
385  $magicWords = $parser->getMagicWordFactory()->newArray(
386  [ 'displaytitle_noerror', 'displaytitle_noreplace' ] );
387  }
388  $arg = $magicWords->matchStartToEnd( $uarg );
389 
390  // parse a limited subset of wiki markup (just the single quote items)
391  $text = $parser->doQuotes( $text );
392 
393  // remove stripped text (e.g. the UNIQ-QINU stuff) that was generated by tag extensions/whatever
394  $text = $parser->killMarkers( $text );
395 
396  // list of disallowed tags for DISPLAYTITLE
397  // these will be escaped even though they are allowed in normal wiki text
398  $bad = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr',
399  'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rtc', 'rp', 'br' ];
400 
401  // disallow some styles that could be used to bypass $wgRestrictDisplayTitle
402  if ( $wgRestrictDisplayTitle ) {
403  $htmlTagsCallback = function ( &$params ) {
405 
406  if ( isset( $decoded['style'] ) ) {
407  // this is called later anyway, but we need it right now for the regexes below to be safe
408  // calling it twice doesn't hurt
409  $decoded['style'] = Sanitizer::checkCss( $decoded['style'] );
410 
411  if ( preg_match( '/(display|user-select|visibility)\s*:/i', $decoded['style'] ) ) {
412  $decoded['style'] = '/* attempt to bypass $wgRestrictDisplayTitle */';
413  }
414  }
415 
417  };
418  } else {
419  $htmlTagsCallback = null;
420  }
421 
422  // only requested titles that normalize to the actual title are allowed through
423  // if $wgRestrictDisplayTitle is true (it is by default)
424  // mimic the escaping process that occurs in OutputPage::setPageTitle
426  $text,
427  $htmlTagsCallback,
428  [],
429  [],
430  $bad
431  ) );
433 
434  if ( !$wgRestrictDisplayTitle ||
435  ( $title instanceof Title
436  && !$title->hasFragment()
437  && $title->equals( $parser->mTitle ) )
438  ) {
439  $old = $parser->mOutput->getProperty( 'displaytitle' );
440  if ( $old === false || $arg !== 'displaytitle_noreplace' ) {
441  $parser->mOutput->setDisplayTitle( $text );
442  }
443  if ( $old !== false && $old !== $text && !$arg ) {
444  $converter = $parser->getTargetLanguage()->getConverter();
445  return '<span class="error">' .
446  wfMessage( 'duplicate-displaytitle',
447  // Message should be parsed, but these params should only be escaped.
448  $converter->markNoConversion( wfEscapeWikiText( $old ) ),
449  $converter->markNoConversion( wfEscapeWikiText( $text ) )
450  )->inContentLanguage()->text() .
451  '</span>';
452  } else {
453  return '';
454  }
455  } else {
456  $parser->getOutput()->addWarning(
457  wfMessage( 'restricted-displaytitle',
458  // Message should be parsed, but this param should only be escaped.
459  wfEscapeWikiText( $text )
460  )->text()
461  );
462  $parser->addTrackingCategory( 'restricted-displaytitle-ignored' );
463  }
464  }
465 
475  private static function matchAgainstMagicword(
476  MagicWordFactory $magicWordFactory, $magicword, $value
477  ) {
478  $value = trim( strval( $value ) );
479  if ( $value === '' ) {
480  return false;
481  }
482  $mwObject = $magicWordFactory->get( $magicword );
483  return $mwObject->matchStartToEnd( $value );
484  }
485 
495  public static function formatRaw(
496  $num, $raw, $language, MagicWordFactory $magicWordFactory = null
497  ) {
498  if ( $raw !== null && !$magicWordFactory ) {
499  $magicWordFactory = MediaWikiServices::getInstance()->getMagicWordFactory();
500  }
501  if (
502  $raw !== null && self::matchAgainstMagicword( $magicWordFactory, 'rawsuffix', $raw )
503  ) {
504  return $num;
505  } else {
506  return $language->formatNum( $num );
507  }
508  }
509 
510  public static function numberofpages( $parser, $raw = null ) {
511  return self::formatRaw( SiteStats::pages(), $raw, $parser->getFunctionLang() );
512  }
513 
514  public static function numberofusers( $parser, $raw = null ) {
515  return self::formatRaw( SiteStats::users(), $raw, $parser->getFunctionLang() );
516  }
517  public static function numberofactiveusers( $parser, $raw = null ) {
518  return self::formatRaw( SiteStats::activeUsers(), $raw, $parser->getFunctionLang() );
519  }
520 
521  public static function numberofarticles( $parser, $raw = null ) {
522  return self::formatRaw( SiteStats::articles(), $raw, $parser->getFunctionLang() );
523  }
524 
525  public static function numberoffiles( $parser, $raw = null ) {
526  return self::formatRaw( SiteStats::images(), $raw, $parser->getFunctionLang() );
527  }
528 
529  public static function numberofadmins( $parser, $raw = null ) {
530  return self::formatRaw(
531  SiteStats::numberingroup( 'sysop' ),
532  $raw,
533  $parser->getFunctionLang()
534  );
535  }
536 
537  public static function numberofedits( $parser, $raw = null ) {
538  return self::formatRaw( SiteStats::edits(), $raw, $parser->getFunctionLang() );
539  }
540 
541  public static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) {
542  return self::formatRaw(
543  SiteStats::pagesInNs( intval( $namespace ) ),
544  $raw,
545  $parser->getFunctionLang()
546  );
547  }
548  public static function numberingroup( $parser, $name = '', $raw = null ) {
549  return self::formatRaw(
550  SiteStats::numberingroup( strtolower( $name ) ),
551  $raw,
552  $parser->getFunctionLang()
553  );
554  }
555 
565  public static function mwnamespace( $parser, $title = null ) {
567  if ( is_null( $t ) ) {
568  return '';
569  }
570  return str_replace( '_', ' ', $t->getNsText() );
571  }
572  public static function namespacee( $parser, $title = null ) {
574  if ( is_null( $t ) ) {
575  return '';
576  }
577  return wfUrlencode( $t->getNsText() );
578  }
579  public static function namespacenumber( $parser, $title = null ) {
581  if ( is_null( $t ) ) {
582  return '';
583  }
584  return $t->getNamespace();
585  }
586  public static function talkspace( $parser, $title = null ) {
588  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
589  return '';
590  }
591  return str_replace( '_', ' ', $t->getTalkNsText() );
592  }
593  public static function talkspacee( $parser, $title = null ) {
595  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
596  return '';
597  }
598  return wfUrlencode( $t->getTalkNsText() );
599  }
600  public static function subjectspace( $parser, $title = null ) {
602  if ( is_null( $t ) ) {
603  return '';
604  }
605  return str_replace( '_', ' ', $t->getSubjectNsText() );
606  }
607  public static function subjectspacee( $parser, $title = null ) {
609  if ( is_null( $t ) ) {
610  return '';
611  }
612  return wfUrlencode( $t->getSubjectNsText() );
613  }
614 
622  public static function pagename( $parser, $title = null ) {
624  if ( is_null( $t ) ) {
625  return '';
626  }
627  return wfEscapeWikiText( $t->getText() );
628  }
629  public static function pagenamee( $parser, $title = null ) {
631  if ( is_null( $t ) ) {
632  return '';
633  }
634  return wfEscapeWikiText( $t->getPartialURL() );
635  }
636  public static function fullpagename( $parser, $title = null ) {
638  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
639  return '';
640  }
641  return wfEscapeWikiText( $t->getPrefixedText() );
642  }
643  public static function fullpagenamee( $parser, $title = null ) {
645  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
646  return '';
647  }
648  return wfEscapeWikiText( $t->getPrefixedURL() );
649  }
650  public static function subpagename( $parser, $title = null ) {
652  if ( is_null( $t ) ) {
653  return '';
654  }
655  return wfEscapeWikiText( $t->getSubpageText() );
656  }
657  public static function subpagenamee( $parser, $title = null ) {
659  if ( is_null( $t ) ) {
660  return '';
661  }
662  return wfEscapeWikiText( $t->getSubpageUrlForm() );
663  }
664  public static function rootpagename( $parser, $title = null ) {
666  if ( is_null( $t ) ) {
667  return '';
668  }
669  return wfEscapeWikiText( $t->getRootText() );
670  }
671  public static function rootpagenamee( $parser, $title = null ) {
673  if ( is_null( $t ) ) {
674  return '';
675  }
676  return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getRootText() ) ) );
677  }
678  public static function basepagename( $parser, $title = null ) {
680  if ( is_null( $t ) ) {
681  return '';
682  }
683  return wfEscapeWikiText( $t->getBaseText() );
684  }
685  public static function basepagenamee( $parser, $title = null ) {
687  if ( is_null( $t ) ) {
688  return '';
689  }
690  return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getBaseText() ) ) );
691  }
692  public static function talkpagename( $parser, $title = null ) {
694  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
695  return '';
696  }
697  return wfEscapeWikiText( $t->getTalkPage()->getPrefixedText() );
698  }
699  public static function talkpagenamee( $parser, $title = null ) {
701  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
702  return '';
703  }
704  return wfEscapeWikiText( $t->getTalkPage()->getPrefixedURL() );
705  }
706  public static function subjectpagename( $parser, $title = null ) {
708  if ( is_null( $t ) ) {
709  return '';
710  }
711  return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() );
712  }
713  public static function subjectpagenamee( $parser, $title = null ) {
715  if ( is_null( $t ) ) {
716  return '';
717  }
718  return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedURL() );
719  }
720 
731  public static function pagesincategory( $parser, $name = '', $arg1 = null, $arg2 = null ) {
732  static $magicWords = null;
733  if ( is_null( $magicWords ) ) {
734  $magicWords = $parser->getMagicWordFactory()->newArray( [
735  'pagesincategory_all',
736  'pagesincategory_pages',
737  'pagesincategory_subcats',
738  'pagesincategory_files'
739  ] );
740  }
741  static $cache = [];
742 
743  // split the given option to its variable
744  if ( self::matchAgainstMagicword( $parser->getMagicWordFactory(), 'rawsuffix', $arg1 ) ) {
745  // {{pagesincategory:|raw[|type]}}
746  $raw = $arg1;
747  $type = $magicWords->matchStartToEnd( $arg2 );
748  } else {
749  // {{pagesincategory:[|type[|raw]]}}
750  $type = $magicWords->matchStartToEnd( $arg1 );
751  $raw = $arg2;
752  }
753  if ( !$type ) { // backward compatibility
754  $type = 'pagesincategory_all';
755  }
756 
758  if ( !$title ) { # invalid title
759  return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
760  }
761  $parser->getContentLanguage()->findVariantLink( $name, $title, true );
762 
763  // Normalize name for cache
764  $name = $title->getDBkey();
765 
766  if ( !isset( $cache[$name] ) ) {
767  $category = Category::newFromTitle( $title );
768 
769  $allCount = $subcatCount = $fileCount = $pagesCount = 0;
770  if ( $parser->incrementExpensiveFunctionCount() ) {
771  // $allCount is the total number of cat members,
772  // not the count of how many members are normal pages.
773  $allCount = (int)$category->getPageCount();
774  $subcatCount = (int)$category->getSubcatCount();
775  $fileCount = (int)$category->getFileCount();
776  $pagesCount = $allCount - $subcatCount - $fileCount;
777  }
778  $cache[$name]['pagesincategory_all'] = $allCount;
779  $cache[$name]['pagesincategory_pages'] = $pagesCount;
780  $cache[$name]['pagesincategory_subcats'] = $subcatCount;
781  $cache[$name]['pagesincategory_files'] = $fileCount;
782  }
783 
784  $count = $cache[$name][$type];
785  return self::formatRaw( $count, $raw, $parser->getFunctionLang() );
786  }
787 
797  public static function pagesize( $parser, $page = '', $raw = null ) {
798  $title = Title::newFromText( $page );
799 
800  if ( !is_object( $title ) ) {
801  return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
802  }
803 
804  // fetch revision from cache/database and return the value
805  $rev = self::getCachedRevisionObject( $parser, $title );
806  $length = $rev ? $rev->getSize() : 0;
807  if ( $length === null ) {
808  // We've had bugs where rev_len was not being recorded for empty pages, see T135414
809  $length = 0;
810  }
811  return self::formatRaw( $length, $raw, $parser->getFunctionLang() );
812  }
813 
826  public static function protectionlevel( $parser, $type = '', $title = '' ) {
827  $titleObject = Title::newFromText( $title );
828  if ( !( $titleObject instanceof Title ) ) {
829  $titleObject = $parser->mTitle;
830  }
831  if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
832  $restrictions = $titleObject->getRestrictions( strtolower( $type ) );
833  # Title::getRestrictions returns an array, its possible it may have
834  # multiple values in the future
835  return implode( ',', $restrictions );
836  }
837  return '';
838  }
839 
852  public static function protectionexpiry( $parser, $type = '', $title = '' ) {
853  $titleObject = Title::newFromText( $title );
854  if ( !( $titleObject instanceof Title ) ) {
855  $titleObject = $parser->mTitle;
856  }
857  if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
858  $expiry = $titleObject->getRestrictionExpiry( strtolower( $type ) );
859  // getRestrictionExpiry() returns false on invalid type; trying to
860  // match protectionlevel() function that returns empty string instead
861  if ( $expiry === false ) {
862  $expiry = '';
863  }
864  return $expiry;
865  }
866  return '';
867  }
868 
876  public static function language( $parser, $code = '', $inLanguage = '' ) {
877  $code = strtolower( $code );
878  $inLanguage = strtolower( $inLanguage );
879  $lang = Language::fetchLanguageName( $code, $inLanguage );
880  return $lang !== '' ? $lang : LanguageCode::bcp47( $code );
881  }
882 
892  public static function pad(
893  $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT
894  ) {
895  $padding = $parser->killMarkers( $padding );
896  $lengthOfPadding = mb_strlen( $padding );
897  if ( $lengthOfPadding == 0 ) {
898  return $string;
899  }
900 
901  # The remaining length to add counts down to 0 as padding is added
902  $length = min( (int)$length, 500 ) - mb_strlen( $string );
903  if ( $length <= 0 ) {
904  // Nothing to add
905  return $string;
906  }
907 
908  # $finalPadding is just $padding repeated enough times so that
909  # mb_strlen( $string ) + mb_strlen( $finalPadding ) == $length
910  $finalPadding = '';
911  while ( $length > 0 ) {
912  # If $length < $lengthofPadding, truncate $padding so we get the
913  # exact length desired.
914  $finalPadding .= mb_substr( $padding, 0, $length );
915  $length -= $lengthOfPadding;
916  }
917 
918  if ( $direction == STR_PAD_LEFT ) {
919  return $finalPadding . $string;
920  } else {
921  return $string . $finalPadding;
922  }
923  }
924 
925  public static function padleft( $parser, $string = '', $length = 0, $padding = '0' ) {
926  return self::pad( $parser, $string, $length, $padding, STR_PAD_LEFT );
927  }
928 
929  public static function padright( $parser, $string = '', $length = 0, $padding = '0' ) {
930  return self::pad( $parser, $string, $length, $padding );
931  }
932 
938  public static function anchorencode( $parser, $text ) {
939  $text = $parser->killMarkers( $text );
940  $section = (string)substr( $parser->guessSectionNameFromWikiText( $text ), 1 );
942  }
943 
944  public static function special( $parser, $text ) {
945  list( $page, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
946  resolveAlias( $text );
947  if ( $page ) {
948  $title = SpecialPage::getTitleFor( $page, $subpage );
949  return $title->getPrefixedText();
950  } else {
951  // unknown special page, just use the given text as its title, if at all possible
953  return $title ? $title->getPrefixedText() : self::special( $parser, 'Badtitle' );
954  }
955  }
956 
957  public static function speciale( $parser, $text ) {
958  return wfUrlencode( str_replace( ' ', '_', self::special( $parser, $text ) ) );
959  }
960 
969  public static function defaultsort( $parser, $text, $uarg = '' ) {
970  static $magicWords = null;
971  if ( is_null( $magicWords ) ) {
972  $magicWords = $parser->getMagicWordFactory()->newArray(
973  [ 'defaultsort_noerror', 'defaultsort_noreplace' ] );
974  }
975  $arg = $magicWords->matchStartToEnd( $uarg );
976 
977  $text = trim( $text );
978  if ( strlen( $text ) == 0 ) {
979  return '';
980  }
981  $old = $parser->getCustomDefaultSort();
982  if ( $old === false || $arg !== 'defaultsort_noreplace' ) {
983  $parser->setDefaultSort( $text );
984  }
985 
986  if ( $old === false || $old == $text || $arg ) {
987  return '';
988  } else {
989  $converter = $parser->getTargetLanguage()->getConverter();
990  return '<span class="error">' .
991  wfMessage( 'duplicate-defaultsort',
992  // Message should be parsed, but these params should only be escaped.
993  $converter->markNoConversion( wfEscapeWikiText( $old ) ),
994  $converter->markNoConversion( wfEscapeWikiText( $text ) )
995  )->inContentLanguage()->text() .
996  '</span>';
997  }
998  }
999 
1011  public static function filepath( $parser, $name = '', $argA = '', $argB = '' ) {
1012  $file = wfFindFile( $name );
1013 
1014  if ( $argA == 'nowiki' ) {
1015  // {{filepath: | option [| size] }}
1016  $isNowiki = true;
1017  $parsedWidthParam = Parser::parseWidthParam( $argB );
1018  } else {
1019  // {{filepath: [| size [|option]] }}
1020  $parsedWidthParam = Parser::parseWidthParam( $argA );
1021  $isNowiki = ( $argB == 'nowiki' );
1022  }
1023 
1024  if ( $file ) {
1025  $url = $file->getFullUrl();
1026 
1027  // If a size is requested...
1028  if ( count( $parsedWidthParam ) ) {
1029  $mto = $file->transform( $parsedWidthParam );
1030  // ... and we can
1031  if ( $mto && !$mto->isError() ) {
1032  // ... change the URL to point to a thumbnail.
1033  $url = wfExpandUrl( $mto->getUrl(), PROTO_RELATIVE );
1034  }
1035  }
1036  if ( $isNowiki ) {
1037  return [ $url, 'nowiki' => true ];
1038  }
1039  return $url;
1040  } else {
1041  return '';
1042  }
1043  }
1044 
1052  public static function tagObj( $parser, $frame, $args ) {
1053  if ( !count( $args ) ) {
1054  return '';
1055  }
1056  $tagName = strtolower( trim( $frame->expand( array_shift( $args ) ) ) );
1057 
1058  if ( count( $args ) ) {
1059  $inner = $frame->expand( array_shift( $args ) );
1060  } else {
1061  $inner = null;
1062  }
1063 
1064  $attributes = [];
1065  foreach ( $args as $arg ) {
1066  $bits = $arg->splitArg();
1067  if ( strval( $bits['index'] ) === '' ) {
1068  $name = trim( $frame->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
1069  $value = trim( $frame->expand( $bits['value'] ) );
1070  if ( preg_match( '/^(?:["\'](.+)["\']|""|\'\')$/s', $value, $m ) ) {
1071  $value = $m[1] ?? '';
1072  }
1073  $attributes[$name] = $value;
1074  }
1075  }
1076 
1077  $stripList = $parser->getStripList();
1078  if ( !in_array( $tagName, $stripList ) ) {
1079  // we can't handle this tag (at least not now), so just re-emit it as an ordinary tag
1080  $attrText = '';
1081  foreach ( $attributes as $name => $value ) {
1082  $attrText .= ' ' . htmlspecialchars( $name ) . '="' . htmlspecialchars( $value ) . '"';
1083  }
1084  if ( $inner === null ) {
1085  return "<$tagName$attrText/>";
1086  }
1087  return "<$tagName$attrText>$inner</$tagName>";
1088  }
1089 
1090  $params = [
1091  'name' => $tagName,
1092  'inner' => $inner,
1093  'attributes' => $attributes,
1094  'close' => "</$tagName>",
1095  ];
1096  return $parser->extensionSubstitution( $params, $frame );
1097  }
1098 
1111  private static function getCachedRevisionObject( $parser, $title = null ) {
1112  if ( is_null( $title ) ) {
1113  return null;
1114  }
1115 
1116  // Use the revision from the parser itself, when param is the current page
1117  // and the revision is the current one
1118  if ( $title->equals( $parser->getTitle() ) ) {
1119  $parserRev = $parser->getRevisionObject();
1120  if ( $parserRev && $parserRev->isCurrent() ) {
1121  // force reparse after edit with vary-revision flag
1122  $parser->getOutput()->setFlag( 'vary-revision' );
1123  wfDebug( __METHOD__ . ": use current revision from parser, setting vary-revision...\n" );
1124  return $parserRev;
1125  }
1126  }
1127 
1128  // Normalize name for cache
1129  $page = $title->getPrefixedDBkey();
1130 
1131  if ( !( $parser->currentRevisionCache && $parser->currentRevisionCache->has( $page ) )
1132  && !$parser->incrementExpensiveFunctionCount() ) {
1133  return null;
1134  }
1135  $rev = $parser->fetchCurrentRevisionOfTitle( $title );
1136  $pageID = $rev ? $rev->getPage() : 0;
1137  $revID = $rev ? $rev->getId() : 0;
1138 
1139  // Register dependency in templatelinks
1140  $parser->getOutput()->addTemplate( $title, $pageID, $revID );
1141 
1142  return $rev;
1143  }
1144 
1152  public static function pageid( $parser, $title = null ) {
1154  if ( is_null( $t ) ) {
1155  return '';
1156  }
1157  // Use title from parser to have correct pageid after edit
1158  if ( $t->equals( $parser->getTitle() ) ) {
1159  $t = $parser->getTitle();
1160  return $t->getArticleID();
1161  }
1162 
1163  // These can't have ids
1164  if ( !$t->canExist() || $t->isExternal() ) {
1165  return 0;
1166  }
1167 
1168  // Check the link cache, maybe something already looked it up.
1169  $linkCache = MediaWikiServices::getInstance()->getLinkCache();
1170  $pdbk = $t->getPrefixedDBkey();
1171  $id = $linkCache->getGoodLinkID( $pdbk );
1172  if ( $id != 0 ) {
1173  $parser->mOutput->addLink( $t, $id );
1174  return $id;
1175  }
1176  if ( $linkCache->isBadLink( $pdbk ) ) {
1177  $parser->mOutput->addLink( $t, 0 );
1178  return $id;
1179  }
1180 
1181  // We need to load it from the DB, so mark expensive
1182  if ( $parser->incrementExpensiveFunctionCount() ) {
1183  $id = $t->getArticleID();
1184  $parser->mOutput->addLink( $t, $id );
1185  return $id;
1186  }
1187  return null;
1188  }
1189 
1197  public static function revisionid( $parser, $title = null ) {
1199  if ( is_null( $t ) ) {
1200  return '';
1201  }
1202  // fetch revision from cache/database and return the value
1203  $rev = self::getCachedRevisionObject( $parser, $t );
1204  return $rev ? $rev->getId() : '';
1205  }
1206 
1214  public static function revisionday( $parser, $title = null ) {
1216  if ( is_null( $t ) ) {
1217  return '';
1218  }
1219  // fetch revision from cache/database and return the value
1220  $rev = self::getCachedRevisionObject( $parser, $t );
1221  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'j' ) : '';
1222  }
1223 
1231  public static function revisionday2( $parser, $title = null ) {
1233  if ( is_null( $t ) ) {
1234  return '';
1235  }
1236  // fetch revision from cache/database and return the value
1237  $rev = self::getCachedRevisionObject( $parser, $t );
1238  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'd' ) : '';
1239  }
1240 
1248  public static function revisionmonth( $parser, $title = null ) {
1250  if ( is_null( $t ) ) {
1251  return '';
1252  }
1253  // fetch revision from cache/database and return the value
1254  $rev = self::getCachedRevisionObject( $parser, $t );
1255  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'm' ) : '';
1256  }
1257 
1265  public static function revisionmonth1( $parser, $title = null ) {
1267  if ( is_null( $t ) ) {
1268  return '';
1269  }
1270  // fetch revision from cache/database and return the value
1271  $rev = self::getCachedRevisionObject( $parser, $t );
1272  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'n' ) : '';
1273  }
1274 
1282  public static function revisionyear( $parser, $title = null ) {
1284  if ( is_null( $t ) ) {
1285  return '';
1286  }
1287  // fetch revision from cache/database and return the value
1288  $rev = self::getCachedRevisionObject( $parser, $t );
1289  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'Y' ) : '';
1290  }
1291 
1299  public static function revisiontimestamp( $parser, $title = null ) {
1301  if ( is_null( $t ) ) {
1302  return '';
1303  }
1304  // fetch revision from cache/database and return the value
1305  $rev = self::getCachedRevisionObject( $parser, $t );
1306  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'YmdHis' ) : '';
1307  }
1308 
1316  public static function revisionuser( $parser, $title = null ) {
1318  if ( is_null( $t ) ) {
1319  return '';
1320  }
1321  // fetch revision from cache/database and return the value
1322  $rev = self::getCachedRevisionObject( $parser, $t );
1323  return $rev ? $rev->getUserText() : '';
1324  }
1325 
1338  public static function cascadingsources( $parser, $title = '' ) {
1339  $titleObject = Title::newFromText( $title );
1340  if ( !( $titleObject instanceof Title ) ) {
1341  $titleObject = $parser->mTitle;
1342  }
1343  if ( $titleObject->areCascadeProtectionSourcesLoaded()
1344  || $parser->incrementExpensiveFunctionCount()
1345  ) {
1346  $names = [];
1347  $sources = $titleObject->getCascadeProtectionSources();
1348  foreach ( $sources[0] as $sourceTitle ) {
1349  $names[] = $sourceTitle->getPrefixedText();
1350  }
1351  return implode( '|', $names );
1352  }
1353  return '';
1354  }
1355 
1356 }
static intFunction( $parser, $part1='',... $params)
static revisionday( $parser, $title=null)
Get the day from the last revision of a specified page.
static special( $parser, $text)
static subpagenamee( $parser, $title=null)
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
static grammar( $parser, $case='', $word='')
static getLocalInstance( $ts=false)
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
static numberofusers( $parser, $raw=null)
static rootpagename( $parser, $title=null)
static fullpagename( $parser, $title=null)
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
static pagename( $parser, $title=null)
Functions to get and normalize pagenames, corresponding to the magic words of the same names...
static newFromTitle( $title)
Factory function.
Definition: Category.php:144
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1982
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Definition: router.php:42
static getCachedRevisionObject( $parser, $title=null)
Fetched the current revision of the given title and return this.
static revisiontimestamp( $parser, $title=null)
Get the timestamp from the last revision of a specified page.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
if(!isset( $args[0])) $lang
static nse( $parser, $part1='')
static revisionday2( $parser, $title=null)
Get the day with leading zeros from the last revision of a specified page.
static talkpagename( $parser, $title=null)
static namespacee( $parser, $title=null)
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition: hooks.txt:175
$value
const NS_SPECIAL
Definition: Defines.php:53
static basepagenamee( $parser, $title=null)
static talkspace( $parser, $title=null)
static localurl( $parser, $s='', $arg=null)
static language( $parser, $code='', $inLanguage='')
Gives language names.
static gender( $parser, $username,... $forms)
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 MediaWikiServices
Definition: injection.txt:23
static activeUsers()
Definition: SiteStats.php:130
$wgRestrictDisplayTitle
For consistency, restrict DISPLAYTITLE to text that normalizes to the same canonical DB key...
static anchorencode( $parser, $text)
static uc( $parser, $s='')
static subjectspacee( $parser, $title=null)
title
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition: hooks.txt:1799
static pagesize( $parser, $page='', $raw=null)
Return the size of the given page, or 0 if it&#39;s nonexistent.
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
const SFH_NO_HASH
Definition: Parser.php:85
static fullpagenamee( $parser, $title=null)
static padleft( $parser, $string='', $length=0, $padding='0')
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.
if( $line===false) $args
Definition: cdb.php:64
static numberingroup( $group)
Find the number of users in a given user group.
Definition: SiteStats.php:150
static revisionmonth1( $parser, $title=null)
Get the month from the last revision of a specified page.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1982
static formatDate( $parser, $date, $defaultPref=null)
static edits()
Definition: SiteStats.php:94
static pagesincategory( $parser, $name='', $arg1=null, $arg2=null)
Return the number of pages, files or subcats in the given category, or 0 if it&#39;s nonexistent.
static parseWidthParam( $value, $parseHeight=true)
Parsed a width param of imagelink like 300px or 200x300px.
Definition: Parser.php:6294
static stripAllTags( $html)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed, encoded as plain text.
Definition: Sanitizer.php:1992
static revisionyear( $parser, $title=null)
Get the year from the last revision of a specified page.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness, which urlencode encodes by default.
static pagesInNs( $ns)
Definition: SiteStats.php:201
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
static numberofpages( $parser, $raw=null)
wfFindFile( $title, $options=[])
Find a file.
static fullurl( $parser, $s='', $arg=null)
const NS_MEDIA
Definition: Defines.php:52
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static localurle( $parser, $s='', $arg=null)
static pagenamee( $parser, $title=null)
$cache
Definition: mcc.php:33
static bidi( $parser, $text='')
$params
const NS_CATEGORY
Definition: Defines.php:78
static numberofadmins( $parser, $raw=null)
static urlencode( $parser, $s='', $arg=null)
urlencodes a string according to one of three patterns: (T24474)
static fullurle( $parser, $s='', $arg=null)
Various core parser functions, registered in Parser::firstCallInit()
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:780
static displaytitle( $parser, $text='', $uarg='')
Override the title of the page when viewed, provided we&#39;ve been given a title which will normalise to...
static decodeTagAttributes( $text)
Return an associative array of attribute names and values from a partial tag string.
Definition: Sanitizer.php:1442
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
const PROTO_RELATIVE
Definition: Defines.php:221
static numberoffiles( $parser, $raw=null)
static talkspacee( $parser, $title=null)
const NS_FILE
Definition: Defines.php:70
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don&#39;t need a full Title object...
Definition: SpecialPage.php:82
static rootpagenamee( $parser, $title=null)
static normalizeCharReferences( $text)
Ensure that any entities and character references are legal for XML and XHTML specifically.
Definition: Sanitizer.php:1561
static subjectpagename( $parser, $title=null)
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1766
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition: hooks.txt:780
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
static padright( $parser, $string='', $length=0, $padding='0')
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition: hooks.txt:3050
static speciale( $parser, $text)
static getDefaultOption( $opt)
Get a given default option value.
Definition: User.php:1820
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:617
static images()
Definition: SiteStats.php:139
static formatRaw( $num, $raw, $language, MagicWordFactory $magicWordFactory=null)
Formats a number according to a language.
static filepath( $parser, $name='', $argA='', $argB='')
Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}} or {{...
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:589
static fetchLanguageName( $code, $inLanguage=self::AS_AUTONYMS, $include=self::ALL)
Definition: Language.php:933
static ns( $parser, $part1='')
static matchAgainstMagicword(MagicWordFactory $magicWordFactory, $magicword, $value)
Matches the given value against the value of given magic word.
static talkpagenamee( $parser, $title=null)
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:35
static safeEncodeTagAttributes( $assoc_array)
Build a partial tag string from an associative array of attribute names and values as returned by dec...
Definition: Sanitizer.php:1484
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:780
static lcfirst( $parser, $s='')
static defaultsort( $parser, $text, $uarg='')
static numberofactiveusers( $parser, $raw=null)
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
Definition: Title.php:407
static numberofedits( $parser, $raw=null)
static urlFunction( $func, $s='', $arg=null)
static lc( $parser, $s='')
static subjectspace( $parser, $title=null)
static articles()
Definition: SiteStats.php:103
static pages()
Definition: SiteStats.php:112
static namespacenumber( $parser, $title=null)
const SFH_OBJECT_ARGS
Definition: Parser.php:86
static protectionlevel( $parser, $type='', $title='')
Returns the requested protection level for the current page.
$wgAllowSlowParserFunctions
Enable slow parser functions.
static plural( $parser, $text='',... $forms)
static checkCss( $value)
Pick apart some CSS and check it for forbidden or unsafe structures.
Definition: Sanitizer.php:1058
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
static tagObj( $parser, $frame, $args)
Parser function to extension tag adaptor.
static revisionid( $parser, $title=null)
Get the id from the last revision of a specified page.
static removeHTMLtags( $text, $processCallback=null, $args=[], $extratags=[], $removetags=[], $warnCallback=null)
Cleans up HTML, removes dangerous tags and attributes, and removes HTML comments. ...
Definition: Sanitizer.php:497
static formatnum( $parser, $num='', $arg=null)
static mwnamespace( $parser, $title=null)
Given a title, return the namespace name that would be given by the corresponding magic word Note: fu...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:587
const STRIP_COMMENTS
static revisionuser( $parser, $title=null)
Get the user from the last revision of a specified page.
static subpagename( $parser, $title=null)
static cascadingsources( $parser, $title='')
Returns the sources of any cascading protection acting on a specified page.
static revisionmonth( $parser, $title=null)
Get the month with leading zeros from the last revision of a specified page.
static numberingroup( $parser, $name='', $raw=null)
$wgAllowDisplayTitle
Allow DISPLAYTITLE to change title display.
static pageid( $parser, $title=null)
Get the pageid of a specified page.
static basepagename( $parser, $title=null)
static canonicalurle( $parser, $s='', $arg=null)
static ucfirst( $parser, $s='')
static numberofarticles( $parser, $raw=null)
static subjectpagenamee( $parser, $title=null)
get( $id)
Factory: creates an object representing an ID.
static users()
Definition: SiteStats.php:121
static pagesinnamespace( $parser, $namespace=0, $raw=null)
static protectionexpiry( $parser, $type='', $title='')
Returns the requested protection expiry for the current page.
static bcp47( $code)
Get the normalised IETF language tag See unit test for examples.
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1473
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1641
static canonicalurl( $parser, $s='', $arg=null)
magicword txt Magic Words are some phrases used in the wikitext They are used for two that looks like templates but that don t accept any parameter *Parser functions(like {{fullurl:...}}, {{#special:...}}) $magicWords['en']
Definition: magicword.txt:33
static safeEncodeAttribute( $text)
Encode an attribute value for HTML tags, with extra armoring against further wiki processing...
Definition: Sanitizer.php:1191
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:319