MediaWiki  1.28.0
CoreParserFunctions.php
Go to the documentation of this file.
1 <?php
33  public static function register( $parser ) {
34  global $wgAllowDisplayTitle, $wgAllowSlowParserFunctions;
35 
36  # Syntax for arguments (see Parser::setFunctionHook):
37  # "name for lookup in localized magic words array",
38  # function callback,
39  # optional Parser::SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}}
40  # instead of {{#int:...}})
41  $noHashFunctions = [
42  'ns', 'nse', 'urlencode', 'lcfirst', 'ucfirst', 'lc', 'uc',
43  'localurl', 'localurle', 'fullurl', 'fullurle', 'canonicalurl',
44  'canonicalurle', 'formatnum', 'grammar', 'gender', 'plural', 'bidi',
45  'numberofpages', 'numberofusers', 'numberofactiveusers',
46  'numberofarticles', 'numberoffiles', 'numberofadmins',
47  'numberingroup', 'numberofedits', 'language',
48  'padleft', 'padright', 'anchorencode', 'defaultsort', 'filepath',
49  'pagesincategory', 'pagesize', 'protectionlevel', 'protectionexpiry',
50  'namespacee', 'namespacenumber', 'talkspace', 'talkspacee',
51  'subjectspace', 'subjectspacee', 'pagename', 'pagenamee',
52  'fullpagename', 'fullpagenamee', 'rootpagename', 'rootpagenamee',
53  'basepagename', 'basepagenamee', 'subpagename', 'subpagenamee',
54  'talkpagename', 'talkpagenamee', 'subjectpagename',
55  'subjectpagenamee', 'pageid', 'revisionid', 'revisionday',
56  'revisionday2', 'revisionmonth', 'revisionmonth1', 'revisionyear',
57  'revisiontimestamp', 'revisionuser', 'cascadingsources',
58  ];
59  foreach ( $noHashFunctions as $func ) {
60  $parser->setFunctionHook( $func, [ __CLASS__, $func ], Parser::SFH_NO_HASH );
61  }
62 
63  $parser->setFunctionHook(
64  'namespace',
65  [ __CLASS__, 'mwnamespace' ],
67  );
68  $parser->setFunctionHook( 'int', [ __CLASS__, 'intFunction' ], Parser::SFH_NO_HASH );
69  $parser->setFunctionHook( 'special', [ __CLASS__, 'special' ] );
70  $parser->setFunctionHook( 'speciale', [ __CLASS__, 'speciale' ] );
71  $parser->setFunctionHook( 'tag', [ __CLASS__, 'tagObj' ], Parser::SFH_OBJECT_ARGS );
72  $parser->setFunctionHook( 'formatdate', [ __CLASS__, 'formatDate' ] );
73 
74  if ( $wgAllowDisplayTitle ) {
75  $parser->setFunctionHook(
76  'displaytitle',
77  [ __CLASS__, 'displaytitle' ],
79  );
80  }
81  if ( $wgAllowSlowParserFunctions ) {
82  $parser->setFunctionHook(
83  'pagesinnamespace',
84  [ __CLASS__, 'pagesinnamespace' ],
86  );
87  }
88  }
89 
95  public static function intFunction( $parser, $part1 = '' /*, ... */ ) {
96  if ( strval( $part1 ) !== '' ) {
97  $args = array_slice( func_get_args(), 2 );
98  $message = wfMessage( $part1, $args )
99  ->inLanguage( $parser->getOptions()->getUserLangObj() );
100  if ( !$message->exists() ) {
101  // When message does not exists, the message name is surrounded by angle
102  // and can result in a tag, therefore escape the angles
103  return $message->escaped();
104  }
105  return [ $message->plain(), 'noparse' => false ];
106  } else {
107  return [ 'found' => false ];
108  }
109  }
110 
118  public static function formatDate( $parser, $date, $defaultPref = null ) {
119  $lang = $parser->getFunctionLang();
121 
122  $date = trim( $date );
123 
124  $pref = $parser->getOptions()->getDateFormat();
125 
126  // Specify a different default date format other than the normal default
127  // if the user has 'default' for their setting
128  if ( $pref == 'default' && $defaultPref ) {
129  $pref = $defaultPref;
130  }
131 
132  $date = $df->reformat( $pref, $date, [ 'match-whole' ] );
133  return $date;
134  }
135 
136  public static function ns( $parser, $part1 = '' ) {
138  if ( intval( $part1 ) || $part1 == "0" ) {
139  $index = intval( $part1 );
140  } else {
141  $index = $wgContLang->getNsIndex( str_replace( ' ', '_', $part1 ) );
142  }
143  if ( $index !== false ) {
144  return $wgContLang->getFormattedNsText( $index );
145  } else {
146  return [ 'found' => false ];
147  }
148  }
149 
150  public static function nse( $parser, $part1 = '' ) {
151  $ret = self::ns( $parser, $part1 );
152  if ( is_string( $ret ) ) {
153  $ret = wfUrlencode( str_replace( ' ', '_', $ret ) );
154  }
155  return $ret;
156  }
157 
170  public static function urlencode( $parser, $s = '', $arg = null ) {
171  static $magicWords = null;
172  if ( is_null( $magicWords ) ) {
173  $magicWords = new MagicWordArray( [ 'url_path', 'url_query', 'url_wiki' ] );
174  }
175  switch ( $magicWords->matchStartToEnd( $arg ) ) {
176 
177  // Encode as though it's a wiki page, '_' for ' '.
178  case 'url_wiki':
179  $func = 'wfUrlencode';
180  $s = str_replace( ' ', '_', $s );
181  break;
182 
183  // Encode for an HTTP Path, '%20' for ' '.
184  case 'url_path':
185  $func = 'rawurlencode';
186  break;
187 
188  // Encode for HTTP query, '+' for ' '.
189  case 'url_query':
190  default:
191  $func = 'urlencode';
192  }
193  // See T105242, where the choice to kill markers and various
194  // other options were discussed.
195  return $func( $parser->killMarkers( $s ) );
196  }
197 
198  public static function lcfirst( $parser, $s = '' ) {
200  return $wgContLang->lcfirst( $s );
201  }
202 
203  public static function ucfirst( $parser, $s = '' ) {
205  return $wgContLang->ucfirst( $s );
206  }
207 
213  public static function lc( $parser, $s = '' ) {
215  return $parser->markerSkipCallback( $s, [ $wgContLang, 'lc' ] );
216  }
217 
223  public static function uc( $parser, $s = '' ) {
225  return $parser->markerSkipCallback( $s, [ $wgContLang, 'uc' ] );
226  }
227 
228  public static function localurl( $parser, $s = '', $arg = null ) {
229  return self::urlFunction( 'getLocalURL', $s, $arg );
230  }
231 
232  public static function localurle( $parser, $s = '', $arg = null ) {
233  $temp = self::urlFunction( 'getLocalURL', $s, $arg );
234  if ( !is_string( $temp ) ) {
235  return $temp;
236  } else {
237  return htmlspecialchars( $temp );
238  }
239  }
240 
241  public static function fullurl( $parser, $s = '', $arg = null ) {
242  return self::urlFunction( 'getFullURL', $s, $arg );
243  }
244 
245  public static function fullurle( $parser, $s = '', $arg = null ) {
246  $temp = self::urlFunction( 'getFullURL', $s, $arg );
247  if ( !is_string( $temp ) ) {
248  return $temp;
249  } else {
250  return htmlspecialchars( $temp );
251  }
252  }
253 
254  public static function canonicalurl( $parser, $s = '', $arg = null ) {
255  return self::urlFunction( 'getCanonicalURL', $s, $arg );
256  }
257 
258  public static function canonicalurle( $parser, $s = '', $arg = null ) {
259  $temp = self::urlFunction( 'getCanonicalURL', $s, $arg );
260  if ( !is_string( $temp ) ) {
261  return $temp;
262  } else {
263  return htmlspecialchars( $temp );
264  }
265  }
266 
267  public static function urlFunction( $func, $s = '', $arg = null ) {
269  # Due to order of execution of a lot of bits, the values might be encoded
270  # before arriving here; if that's true, then the title can't be created
271  # and the variable will fail. If we can't get a decent title from the first
272  # attempt, url-decode and try for a second.
273  if ( is_null( $title ) ) {
274  $title = Title::newFromURL( urldecode( $s ) );
275  }
276  if ( !is_null( $title ) ) {
277  # Convert NS_MEDIA -> NS_FILE
278  if ( $title->getNamespace() == NS_MEDIA ) {
279  $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
280  }
281  if ( !is_null( $arg ) ) {
282  $text = $title->$func( $arg );
283  } else {
284  $text = $title->$func();
285  }
286  return $text;
287  } else {
288  return [ 'found' => false ];
289  }
290  }
291 
298  public static function formatnum( $parser, $num = '', $arg = null ) {
299  if ( self::matchAgainstMagicword( 'rawsuffix', $arg ) ) {
300  $func = [ $parser->getFunctionLang(), 'parseFormattedNumber' ];
301  } elseif ( self::matchAgainstMagicword( 'nocommafysuffix', $arg ) ) {
302  $func = [ $parser->getFunctionLang(), 'formatNumNoSeparators' ];
303  } else {
304  $func = [ $parser->getFunctionLang(), 'formatNum' ];
305  }
306  return $parser->markerSkipCallback( $num, $func );
307  }
308 
315  public static function grammar( $parser, $case = '', $word = '' ) {
316  $word = $parser->killMarkers( $word );
317  return $parser->getFunctionLang()->convertGrammar( $word, $case );
318  }
319 
325  public static function gender( $parser, $username ) {
326  $forms = array_slice( func_get_args(), 2 );
327 
328  // Some shortcuts to avoid loading user data unnecessarily
329  if ( count( $forms ) === 0 ) {
330  return '';
331  } elseif ( count( $forms ) === 1 ) {
332  return $forms[0];
333  }
334 
335  $username = trim( $username );
336 
337  // default
338  $gender = User::getDefaultOption( 'gender' );
339 
340  // allow prefix.
342 
343  if ( $title && $title->getNamespace() == NS_USER ) {
344  $username = $title->getText();
345  }
346 
347  // check parameter, or use the ParserOptions if in interface message
349  if ( $user ) {
350  $gender = GenderCache::singleton()->getGenderOf( $user, __METHOD__ );
351  } elseif ( $username === '' && $parser->getOptions()->getInterfaceMessage() ) {
352  $gender = GenderCache::singleton()->getGenderOf( $parser->getOptions()->getUser(), __METHOD__ );
353  }
354  $ret = $parser->getFunctionLang()->gender( $gender, $forms );
355  return $ret;
356  }
357 
363  public static function plural( $parser, $text = '' ) {
364  $forms = array_slice( func_get_args(), 2 );
365  $text = $parser->getFunctionLang()->parseFormattedNumber( $text );
366  settype( $text, ctype_digit( $text ) ? 'int' : 'float' );
367  return $parser->getFunctionLang()->convertPlural( $text, $forms );
368  }
369 
375  public static function bidi( $parser, $text = '' ) {
376  return $parser->getFunctionLang()->embedBidi( $text );
377  }
378 
388  public static function displaytitle( $parser, $text = '', $uarg = '' ) {
389  global $wgRestrictDisplayTitle;
390 
391  static $magicWords = null;
392  if ( is_null( $magicWords ) ) {
393  $magicWords = new MagicWordArray( [ 'displaytitle_noerror', 'displaytitle_noreplace' ] );
394  }
395  $arg = $magicWords->matchStartToEnd( $uarg );
396 
397  // parse a limited subset of wiki markup (just the single quote items)
398  $text = $parser->doQuotes( $text );
399 
400  // remove stripped text (e.g. the UNIQ-QINU stuff) that was generated by tag extensions/whatever
401  $text = $parser->killMarkers( $text );
402 
403  // list of disallowed tags for DISPLAYTITLE
404  // these will be escaped even though they are allowed in normal wiki text
405  $bad = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr',
406  'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rtc', 'rp', 'br' ];
407 
408  // disallow some styles that could be used to bypass $wgRestrictDisplayTitle
409  if ( $wgRestrictDisplayTitle ) {
410  $htmlTagsCallback = function ( &$params ) {
412 
413  if ( isset( $decoded['style'] ) ) {
414  // this is called later anyway, but we need it right now for the regexes below to be safe
415  // calling it twice doesn't hurt
416  $decoded['style'] = Sanitizer::checkCss( $decoded['style'] );
417 
418  if ( preg_match( '/(display|user-select|visibility)\s*:/i', $decoded['style'] ) ) {
419  $decoded['style'] = '/* attempt to bypass $wgRestrictDisplayTitle */';
420  }
421  }
422 
424  };
425  } else {
426  $htmlTagsCallback = null;
427  }
428 
429  // only requested titles that normalize to the actual title are allowed through
430  // if $wgRestrictDisplayTitle is true (it is by default)
431  // mimic the escaping process that occurs in OutputPage::setPageTitle
433  $text,
434  $htmlTagsCallback,
435  [],
436  [],
437  $bad
438  ) );
440 
441  if ( !$wgRestrictDisplayTitle ||
442  ( $title instanceof Title
443  && !$title->hasFragment()
444  && $title->equals( $parser->mTitle ) )
445  ) {
446  $old = $parser->mOutput->getProperty( 'displaytitle' );
447  if ( $old === false || $arg !== 'displaytitle_noreplace' ) {
448  $parser->mOutput->setDisplayTitle( $text );
449  }
450  if ( $old !== false && $old !== $text && !$arg ) {
451  $converter = $parser->getConverterLanguage()->getConverter();
452  return '<span class="error">' .
453  wfMessage( 'duplicate-displaytitle',
454  // Message should be parsed, but these params should only be escaped.
455  $converter->markNoConversion( wfEscapeWikiText( $old ) ),
456  $converter->markNoConversion( wfEscapeWikiText( $text ) )
457  )->inContentLanguage()->text() .
458  '</span>';
459  } else {
460  return '';
461  }
462  } else {
463  $converter = $parser->getConverterLanguage()->getConverter();
464  $parser->getOutput()->addWarning(
465  wfMessage( 'restricted-displaytitle',
466  // Message should be parsed, but this param should only be escaped.
467  $converter->markNoConversion( wfEscapeWikiText( $text ) )
468  )->text()
469  );
470  $parser->addTrackingCategory( 'restricted-displaytitle-ignored' );
471  }
472  }
473 
481  private static function matchAgainstMagicword( $magicword, $value ) {
482  $value = trim( strval( $value ) );
483  if ( $value === '' ) {
484  return false;
485  }
486  $mwObject = MagicWord::get( $magicword );
487  return $mwObject->matchStartToEnd( $value );
488  }
489 
490  public static function formatRaw( $num, $raw ) {
491  if ( self::matchAgainstMagicword( 'rawsuffix', $raw ) ) {
492  return $num;
493  } else {
495  return $wgContLang->formatNum( $num );
496  }
497  }
498  public static function numberofpages( $parser, $raw = null ) {
499  return self::formatRaw( SiteStats::pages(), $raw );
500  }
501  public static function numberofusers( $parser, $raw = null ) {
502  return self::formatRaw( SiteStats::users(), $raw );
503  }
504  public static function numberofactiveusers( $parser, $raw = null ) {
505  return self::formatRaw( SiteStats::activeUsers(), $raw );
506  }
507  public static function numberofarticles( $parser, $raw = null ) {
508  return self::formatRaw( SiteStats::articles(), $raw );
509  }
510  public static function numberoffiles( $parser, $raw = null ) {
511  return self::formatRaw( SiteStats::images(), $raw );
512  }
513  public static function numberofadmins( $parser, $raw = null ) {
514  return self::formatRaw( SiteStats::numberingroup( 'sysop' ), $raw );
515  }
516  public static function numberofedits( $parser, $raw = null ) {
517  return self::formatRaw( SiteStats::edits(), $raw );
518  }
519  public static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) {
520  return self::formatRaw( SiteStats::pagesInNs( intval( $namespace ) ), $raw );
521  }
522  public static function numberingroup( $parser, $name = '', $raw = null ) {
523  return self::formatRaw( SiteStats::numberingroup( strtolower( $name ) ), $raw );
524  }
525 
535  public static function mwnamespace( $parser, $title = null ) {
537  if ( is_null( $t ) ) {
538  return '';
539  }
540  return str_replace( '_', ' ', $t->getNsText() );
541  }
542  public static function namespacee( $parser, $title = null ) {
544  if ( is_null( $t ) ) {
545  return '';
546  }
547  return wfUrlencode( $t->getNsText() );
548  }
549  public static function namespacenumber( $parser, $title = null ) {
551  if ( is_null( $t ) ) {
552  return '';
553  }
554  return $t->getNamespace();
555  }
556  public static function talkspace( $parser, $title = null ) {
558  if ( is_null( $t ) || !$t->canTalk() ) {
559  return '';
560  }
561  return str_replace( '_', ' ', $t->getTalkNsText() );
562  }
563  public static function talkspacee( $parser, $title = null ) {
565  if ( is_null( $t ) || !$t->canTalk() ) {
566  return '';
567  }
568  return wfUrlencode( $t->getTalkNsText() );
569  }
570  public static function subjectspace( $parser, $title = null ) {
572  if ( is_null( $t ) ) {
573  return '';
574  }
575  return str_replace( '_', ' ', $t->getSubjectNsText() );
576  }
577  public static function subjectspacee( $parser, $title = null ) {
579  if ( is_null( $t ) ) {
580  return '';
581  }
582  return wfUrlencode( $t->getSubjectNsText() );
583  }
584 
592  public static function pagename( $parser, $title = null ) {
594  if ( is_null( $t ) ) {
595  return '';
596  }
597  return wfEscapeWikiText( $t->getText() );
598  }
599  public static function pagenamee( $parser, $title = null ) {
601  if ( is_null( $t ) ) {
602  return '';
603  }
604  return wfEscapeWikiText( $t->getPartialURL() );
605  }
606  public static function fullpagename( $parser, $title = null ) {
608  if ( is_null( $t ) || !$t->canTalk() ) {
609  return '';
610  }
611  return wfEscapeWikiText( $t->getPrefixedText() );
612  }
613  public static function fullpagenamee( $parser, $title = null ) {
615  if ( is_null( $t ) || !$t->canTalk() ) {
616  return '';
617  }
618  return wfEscapeWikiText( $t->getPrefixedURL() );
619  }
620  public static function subpagename( $parser, $title = null ) {
622  if ( is_null( $t ) ) {
623  return '';
624  }
625  return wfEscapeWikiText( $t->getSubpageText() );
626  }
627  public static function subpagenamee( $parser, $title = null ) {
629  if ( is_null( $t ) ) {
630  return '';
631  }
632  return wfEscapeWikiText( $t->getSubpageUrlForm() );
633  }
634  public static function rootpagename( $parser, $title = null ) {
636  if ( is_null( $t ) ) {
637  return '';
638  }
639  return wfEscapeWikiText( $t->getRootText() );
640  }
641  public static function rootpagenamee( $parser, $title = null ) {
643  if ( is_null( $t ) ) {
644  return '';
645  }
646  return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getRootText() ) ) );
647  }
648  public static function basepagename( $parser, $title = null ) {
650  if ( is_null( $t ) ) {
651  return '';
652  }
653  return wfEscapeWikiText( $t->getBaseText() );
654  }
655  public static function basepagenamee( $parser, $title = null ) {
657  if ( is_null( $t ) ) {
658  return '';
659  }
660  return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getBaseText() ) ) );
661  }
662  public static function talkpagename( $parser, $title = null ) {
664  if ( is_null( $t ) || !$t->canTalk() ) {
665  return '';
666  }
667  return wfEscapeWikiText( $t->getTalkPage()->getPrefixedText() );
668  }
669  public static function talkpagenamee( $parser, $title = null ) {
671  if ( is_null( $t ) || !$t->canTalk() ) {
672  return '';
673  }
674  return wfEscapeWikiText( $t->getTalkPage()->getPrefixedURL() );
675  }
676  public static function subjectpagename( $parser, $title = null ) {
678  if ( is_null( $t ) ) {
679  return '';
680  }
681  return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() );
682  }
683  public static function subjectpagenamee( $parser, $title = null ) {
685  if ( is_null( $t ) ) {
686  return '';
687  }
688  return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedURL() );
689  }
690 
701  public static function pagesincategory( $parser, $name = '', $arg1 = null, $arg2 = null ) {
703  static $magicWords = null;
704  if ( is_null( $magicWords ) ) {
705  $magicWords = new MagicWordArray( [
706  'pagesincategory_all',
707  'pagesincategory_pages',
708  'pagesincategory_subcats',
709  'pagesincategory_files'
710  ] );
711  }
712  static $cache = [];
713 
714  // split the given option to its variable
715  if ( self::matchAgainstMagicword( 'rawsuffix', $arg1 ) ) {
716  // {{pagesincategory:|raw[|type]}}
717  $raw = $arg1;
718  $type = $magicWords->matchStartToEnd( $arg2 );
719  } else {
720  // {{pagesincategory:[|type[|raw]]}}
721  $type = $magicWords->matchStartToEnd( $arg1 );
722  $raw = $arg2;
723  }
724  if ( !$type ) { // backward compatibility
725  $type = 'pagesincategory_all';
726  }
727 
729  if ( !$title ) { # invalid title
730  return self::formatRaw( 0, $raw );
731  }
732  $wgContLang->findVariantLink( $name, $title, true );
733 
734  // Normalize name for cache
735  $name = $title->getDBkey();
736 
737  if ( !isset( $cache[$name] ) ) {
738  $category = Category::newFromTitle( $title );
739 
740  $allCount = $subcatCount = $fileCount = $pagesCount = 0;
741  if ( $parser->incrementExpensiveFunctionCount() ) {
742  // $allCount is the total number of cat members,
743  // not the count of how many members are normal pages.
744  $allCount = (int)$category->getPageCount();
745  $subcatCount = (int)$category->getSubcatCount();
746  $fileCount = (int)$category->getFileCount();
747  $pagesCount = $allCount - $subcatCount - $fileCount;
748  }
749  $cache[$name]['pagesincategory_all'] = $allCount;
750  $cache[$name]['pagesincategory_pages'] = $pagesCount;
751  $cache[$name]['pagesincategory_subcats'] = $subcatCount;
752  $cache[$name]['pagesincategory_files'] = $fileCount;
753  }
754 
755  $count = $cache[$name][$type];
756  return self::formatRaw( $count, $raw );
757  }
758 
768  public static function pagesize( $parser, $page = '', $raw = null ) {
770 
771  if ( !is_object( $title ) ) {
772  return self::formatRaw( 0, $raw );
773  }
774 
775  // fetch revision from cache/database and return the value
776  $rev = self::getCachedRevisionObject( $parser, $title );
777  $length = $rev ? $rev->getSize() : 0;
778  if ( $length === null ) {
779  // We've had bugs where rev_len was not being recorded for empty pages, see T135414
780  $length = 0;
781  }
782  return self::formatRaw( $length, $raw );
783  }
784 
797  public static function protectionlevel( $parser, $type = '', $title = '' ) {
798  $titleObject = Title::newFromText( $title );
799  if ( !( $titleObject instanceof Title ) ) {
800  $titleObject = $parser->mTitle;
801  }
802  if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
803  $restrictions = $titleObject->getRestrictions( strtolower( $type ) );
804  # Title::getRestrictions returns an array, its possible it may have
805  # multiple values in the future
806  return implode( $restrictions, ',' );
807  }
808  return '';
809  }
810 
823  public static function protectionexpiry( $parser, $type = '', $title = '' ) {
824  $titleObject = Title::newFromText( $title );
825  if ( !( $titleObject instanceof Title ) ) {
826  $titleObject = $parser->mTitle;
827  }
828  if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
829  $expiry = $titleObject->getRestrictionExpiry( strtolower( $type ) );
830  // getRestrictionExpiry() returns false on invalid type; trying to
831  // match protectionlevel() function that returns empty string instead
832  if ( $expiry === false ) {
833  $expiry = '';
834  }
835  return $expiry;
836  }
837  return '';
838  }
839 
847  public static function language( $parser, $code = '', $inLanguage = '' ) {
848  $code = strtolower( $code );
849  $inLanguage = strtolower( $inLanguage );
850  $lang = Language::fetchLanguageName( $code, $inLanguage );
851  return $lang !== '' ? $lang : wfBCP47( $code );
852  }
853 
863  public static function pad(
864  $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT
865  ) {
866  $padding = $parser->killMarkers( $padding );
867  $lengthOfPadding = mb_strlen( $padding );
868  if ( $lengthOfPadding == 0 ) {
869  return $string;
870  }
871 
872  # The remaining length to add counts down to 0 as padding is added
873  $length = min( $length, 500 ) - mb_strlen( $string );
874  # $finalPadding is just $padding repeated enough times so that
875  # mb_strlen( $string ) + mb_strlen( $finalPadding ) == $length
876  $finalPadding = '';
877  while ( $length > 0 ) {
878  # If $length < $lengthofPadding, truncate $padding so we get the
879  # exact length desired.
880  $finalPadding .= mb_substr( $padding, 0, $length );
881  $length -= $lengthOfPadding;
882  }
883 
884  if ( $direction == STR_PAD_LEFT ) {
885  return $finalPadding . $string;
886  } else {
887  return $string . $finalPadding;
888  }
889  }
890 
891  public static function padleft( $parser, $string = '', $length = 0, $padding = '0' ) {
892  return self::pad( $parser, $string, $length, $padding, STR_PAD_LEFT );
893  }
894 
895  public static function padright( $parser, $string = '', $length = 0, $padding = '0' ) {
896  return self::pad( $parser, $string, $length, $padding );
897  }
898 
904  public static function anchorencode( $parser, $text ) {
905  $text = $parser->killMarkers( $text );
906  return (string)substr( $parser->guessSectionNameFromWikiText( $text ), 1 );
907  }
908 
909  public static function special( $parser, $text ) {
910  list( $page, $subpage ) = SpecialPageFactory::resolveAlias( $text );
911  if ( $page ) {
912  $title = SpecialPage::getTitleFor( $page, $subpage );
913  return $title->getPrefixedText();
914  } else {
915  // unknown special page, just use the given text as its title, if at all possible
917  return $title ? $title->getPrefixedText() : self::special( $parser, 'Badtitle' );
918  }
919  }
920 
921  public static function speciale( $parser, $text ) {
922  return wfUrlencode( str_replace( ' ', '_', self::special( $parser, $text ) ) );
923  }
924 
933  public static function defaultsort( $parser, $text, $uarg = '' ) {
934  static $magicWords = null;
935  if ( is_null( $magicWords ) ) {
936  $magicWords = new MagicWordArray( [ 'defaultsort_noerror', 'defaultsort_noreplace' ] );
937  }
938  $arg = $magicWords->matchStartToEnd( $uarg );
939 
940  $text = trim( $text );
941  if ( strlen( $text ) == 0 ) {
942  return '';
943  }
944  $old = $parser->getCustomDefaultSort();
945  if ( $old === false || $arg !== 'defaultsort_noreplace' ) {
946  $parser->setDefaultSort( $text );
947  }
948 
949  if ( $old === false || $old == $text || $arg ) {
950  return '';
951  } else {
952  $converter = $parser->getConverterLanguage()->getConverter();
953  return '<span class="error">' .
954  wfMessage( 'duplicate-defaultsort',
955  // Message should be parsed, but these params should only be escaped.
956  $converter->markNoConversion( wfEscapeWikiText( $old ) ),
957  $converter->markNoConversion( wfEscapeWikiText( $text ) )
958  )->inContentLanguage()->text() .
959  '</span>';
960  }
961  }
962 
974  public static function filepath( $parser, $name = '', $argA = '', $argB = '' ) {
975  $file = wfFindFile( $name );
976 
977  if ( $argA == 'nowiki' ) {
978  // {{filepath: | option [| size] }}
979  $isNowiki = true;
980  $parsedWidthParam = $parser->parseWidthParam( $argB );
981  } else {
982  // {{filepath: [| size [|option]] }}
983  $parsedWidthParam = $parser->parseWidthParam( $argA );
984  $isNowiki = ( $argB == 'nowiki' );
985  }
986 
987  if ( $file ) {
988  $url = $file->getFullUrl();
989 
990  // If a size is requested...
991  if ( count( $parsedWidthParam ) ) {
992  $mto = $file->transform( $parsedWidthParam );
993  // ... and we can
994  if ( $mto && !$mto->isError() ) {
995  // ... change the URL to point to a thumbnail.
996  $url = wfExpandUrl( $mto->getUrl(), PROTO_RELATIVE );
997  }
998  }
999  if ( $isNowiki ) {
1000  return [ $url, 'nowiki' => true ];
1001  }
1002  return $url;
1003  } else {
1004  return '';
1005  }
1006  }
1007 
1015  public static function tagObj( $parser, $frame, $args ) {
1016  if ( !count( $args ) ) {
1017  return '';
1018  }
1019  $tagName = strtolower( trim( $frame->expand( array_shift( $args ) ) ) );
1020 
1021  if ( count( $args ) ) {
1022  $inner = $frame->expand( array_shift( $args ) );
1023  } else {
1024  $inner = null;
1025  }
1026 
1027  $attributes = [];
1028  foreach ( $args as $arg ) {
1029  $bits = $arg->splitArg();
1030  if ( strval( $bits['index'] ) === '' ) {
1031  $name = trim( $frame->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
1032  $value = trim( $frame->expand( $bits['value'] ) );
1033  if ( preg_match( '/^(?:["\'](.+)["\']|""|\'\')$/s', $value, $m ) ) {
1034  $value = isset( $m[1] ) ? $m[1] : '';
1035  }
1036  $attributes[$name] = $value;
1037  }
1038  }
1039 
1040  $stripList = $parser->getStripList();
1041  if ( !in_array( $tagName, $stripList ) ) {
1042  // we can't handle this tag (at least not now), so just re-emit it as an ordinary tag
1043  $attrText = '';
1044  foreach ( $attributes as $name => $value ) {
1045  $attrText .= ' ' . htmlspecialchars( $name ) . '="' . htmlspecialchars( $value ) . '"';
1046  }
1047  if ( $inner === null ) {
1048  return "<$tagName$attrText/>";
1049  }
1050  return "<$tagName$attrText>$inner</$tagName>";
1051  }
1052 
1053  $params = [
1054  'name' => $tagName,
1055  'inner' => $inner,
1056  'attributes' => $attributes,
1057  'close' => "</$tagName>",
1058  ];
1059  return $parser->extensionSubstitution( $params, $frame );
1060  }
1061 
1074  private static function getCachedRevisionObject( $parser, $title = null ) {
1075  if ( is_null( $title ) ) {
1076  return null;
1077  }
1078 
1079  // Use the revision from the parser itself, when param is the current page
1080  // and the revision is the current one
1081  if ( $title->equals( $parser->getTitle() ) ) {
1082  $parserRev = $parser->getRevisionObject();
1083  if ( $parserRev && $parserRev->isCurrent() ) {
1084  // force reparse after edit with vary-revision flag
1085  $parser->getOutput()->setFlag( 'vary-revision' );
1086  wfDebug( __METHOD__ . ": use current revision from parser, setting vary-revision...\n" );
1087  return $parserRev;
1088  }
1089  }
1090 
1091  // Normalize name for cache
1092  $page = $title->getPrefixedDBkey();
1093 
1094  if ( !( $parser->currentRevisionCache && $parser->currentRevisionCache->has( $page ) )
1095  && !$parser->incrementExpensiveFunctionCount() ) {
1096  return null;
1097  }
1098  $rev = $parser->fetchCurrentRevisionOfTitle( $title );
1099  $pageID = $rev ? $rev->getPage() : 0;
1100  $revID = $rev ? $rev->getId() : 0;
1101 
1102  // Register dependency in templatelinks
1103  $parser->getOutput()->addTemplate( $title, $pageID, $revID );
1104 
1105  return $rev;
1106  }
1107 
1115  public static function pageid( $parser, $title = null ) {
1117  if ( is_null( $t ) ) {
1118  return '';
1119  }
1120  // Use title from parser to have correct pageid after edit
1121  if ( $t->equals( $parser->getTitle() ) ) {
1122  $t = $parser->getTitle();
1123  return $t->getArticleID();
1124  }
1125 
1126  // These can't have ids
1127  if ( !$t->canExist() || $t->isExternal() ) {
1128  return 0;
1129  }
1130 
1131  // Check the link cache, maybe something already looked it up.
1132  $linkCache = LinkCache::singleton();
1133  $pdbk = $t->getPrefixedDBkey();
1134  $id = $linkCache->getGoodLinkID( $pdbk );
1135  if ( $id != 0 ) {
1136  $parser->mOutput->addLink( $t, $id );
1137  return $id;
1138  }
1139  if ( $linkCache->isBadLink( $pdbk ) ) {
1140  $parser->mOutput->addLink( $t, 0 );
1141  return $id;
1142  }
1143 
1144  // We need to load it from the DB, so mark expensive
1145  if ( $parser->incrementExpensiveFunctionCount() ) {
1146  $id = $t->getArticleID();
1147  $parser->mOutput->addLink( $t, $id );
1148  return $id;
1149  }
1150  return null;
1151  }
1152 
1160  public static function revisionid( $parser, $title = null ) {
1162  if ( is_null( $t ) ) {
1163  return '';
1164  }
1165  // fetch revision from cache/database and return the value
1166  $rev = self::getCachedRevisionObject( $parser, $t );
1167  return $rev ? $rev->getId() : '';
1168  }
1169 
1177  public static function revisionday( $parser, $title = null ) {
1179  if ( is_null( $t ) ) {
1180  return '';
1181  }
1182  // fetch revision from cache/database and return the value
1183  $rev = self::getCachedRevisionObject( $parser, $t );
1184  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'j' ) : '';
1185  }
1186 
1194  public static function revisionday2( $parser, $title = null ) {
1196  if ( is_null( $t ) ) {
1197  return '';
1198  }
1199  // fetch revision from cache/database and return the value
1200  $rev = self::getCachedRevisionObject( $parser, $t );
1201  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'd' ) : '';
1202  }
1203 
1211  public static function revisionmonth( $parser, $title = null ) {
1213  if ( is_null( $t ) ) {
1214  return '';
1215  }
1216  // fetch revision from cache/database and return the value
1217  $rev = self::getCachedRevisionObject( $parser, $t );
1218  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'm' ) : '';
1219  }
1220 
1228  public static function revisionmonth1( $parser, $title = null ) {
1230  if ( is_null( $t ) ) {
1231  return '';
1232  }
1233  // fetch revision from cache/database and return the value
1234  $rev = self::getCachedRevisionObject( $parser, $t );
1235  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'n' ) : '';
1236  }
1237 
1245  public static function revisionyear( $parser, $title = null ) {
1247  if ( is_null( $t ) ) {
1248  return '';
1249  }
1250  // fetch revision from cache/database and return the value
1251  $rev = self::getCachedRevisionObject( $parser, $t );
1252  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'Y' ) : '';
1253  }
1254 
1262  public static function revisiontimestamp( $parser, $title = null ) {
1264  if ( is_null( $t ) ) {
1265  return '';
1266  }
1267  // fetch revision from cache/database and return the value
1268  $rev = self::getCachedRevisionObject( $parser, $t );
1269  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'YmdHis' ) : '';
1270  }
1271 
1279  public static function revisionuser( $parser, $title = null ) {
1281  if ( is_null( $t ) ) {
1282  return '';
1283  }
1284  // fetch revision from cache/database and return the value
1285  $rev = self::getCachedRevisionObject( $parser, $t );
1286  return $rev ? $rev->getUserText() : '';
1287  }
1288 
1301  public static function cascadingsources( $parser, $title = '' ) {
1302  $titleObject = Title::newFromText( $title );
1303  if ( !( $titleObject instanceof Title ) ) {
1304  $titleObject = $parser->mTitle;
1305  }
1306  if ( $titleObject->areCascadeProtectionSourcesLoaded()
1307  || $parser->incrementExpensiveFunctionCount()
1308  ) {
1309  $names = [];
1310  $sources = $titleObject->getCascadeProtectionSources();
1311  foreach ( $sources[0] as $sourceTitle ) {
1312  $names[] = $sourceTitle->getPrefixedText();
1313  }
1314  return implode( $names, '|' );
1315  }
1316  return '';
1317  }
1318 
1319 }
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
Definition: User.php:525
static numberofedits($parser, $raw=null)
static namespacenumber($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
static decodeTagAttributes($text)
Return an associative array of attribute names and values from a partial tag string.
Definition: Sanitizer.php:1287
static formatRaw($num, $raw)
static numberofactiveusers($parser, $raw=null)
static subjectspacee($parser, $title=null)
static padleft($parser, $string= '', $length=0, $padding= '0')
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:1323
static urlFunction($func, $s= '', $arg=null)
static language($parser, $code= '', $inLanguage= '')
Gives language names.
static basepagename($parser, $title=null)
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
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:1936
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name If you don't need a full Title object...
Definition: SpecialPage.php:82
static pagesize($parser, $page= '', $raw=null)
Return the size of the given page, or 0 if it's nonexistent.
static singleton()
Definition: GenderCache.php:41
if(!isset($args[0])) $lang
static rootpagenamee($parser, $title=null)
static formatnum($parser, $num= '', $arg=null)
static canonicalurle($parser, $s= '', $arg=null)
static fullpagenamee($parser, $title=null)
$value
static fullurle($parser, $s= '', $arg=null)
const NS_SPECIAL
Definition: Defines.php:45
static defaultsort($parser, $text, $uarg= '')
static lcfirst($parser, $s= '')
static activeUsers()
Definition: SiteStats.php:165
static protectionexpiry($parser, $type= '', $title= '')
Returns the requested protection expiry for the current 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 newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:262
static getInstance($lang=null)
Get a DateFormatter object.
static stripAllTags($text)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed, encoded as plain text.
Definition: Sanitizer.php:1823
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
wfExpandUrl($url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
title
static numberofusers($parser, $raw=null)
magic word & $parser
Definition: hooks.txt:2487
const SFH_NO_HASH
Definition: Parser.php:85
static revisionmonth($parser, $title=null)
Get the month with leading zeros from the last revision of a specified page.
static revisiontimestamp($parser, $title=null)
Get the timestamp from the last revision of a specified page.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
if($line===false) $args
Definition: cdb.php:64
static getLocalInstance($ts=false)
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
static talkpagename($parser, $title=null)
static tagObj($parser, $frame, $args)
Parser function to extension tag adaptor.
static lc($parser, $s= '')
static filepath($parser, $name= '', $argA= '', $argB= '')
Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}} or {{...
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:1936
static revisionuser($parser, $title=null)
Get the user from the last revision of a specified page.
static edits()
Definition: SiteStats.php:133
static grammar($parser, $case= '', $word= '')
static subpagenamee($parser, $title=null)
static anchorencode($parser, $text)
static localurl($parser, $s= '', $arg=null)
static talkspace($parser, $title=null)
static canonicalurl($parser, $s= '', $arg=null)
static subjectpagenamee($parser, $title=null)
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
static revisionmonth1($parser, $title=null)
Get the month from the last revision of a specified page.
static revisionday2($parser, $title=null)
Get the day with leading zeros from the last revision of a specified page.
static talkpagenamee($parser, $title=null)
static singleton()
Get an instance of this class.
Definition: LinkCache.php:64
static formatDate($parser, $date, $defaultPref=null)
static intFunction($parser, $part1= '')
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 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 unsetoffset-wrap String Wrap the message in html(usually something like"&lt
static subjectspace($parser, $title=null)
static basepagenamee($parser, $title=null)
const NS_MEDIA
Definition: Defines.php:44
static subjectpagename($parser, $title=null)
static urlencode($parser, $s= '', $arg=null)
urlencodes a string according to one of three patterns: (bug 22474)
static pagesincategory($parser, $name= '', $arg1=null, $arg2=null)
Return the number of pages, files or subcats in the given category, or 0 if it's nonexistent.
static newFromTitle($title)
Factory function.
Definition: Category.php:140
$cache
Definition: mcc.php:33
$params
const NS_CATEGORY
Definition: Defines.php:70
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:535
Various core parser functions, registered in Parser::firstCallInit()
wfBCP47($code)
Get the normalised IETF language tag See unit test for examples.
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:953
const PROTO_RELATIVE
Definition: Defines.php:225
static numberingroup($parser, $name= '', $raw=null)
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
const NS_FILE
Definition: Defines.php:62
static revisionday($parser, $title=null)
Get the day from the last revision of a specified page.
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:1721
static rootpagename($parser, $title=null)
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
Class for handling an array of magic words.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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:802
static fetchLanguageName($code, $inLanguage=null, $include= 'all')
Definition: Language.php:888
static & get($id)
Factory: creates an object representing an ID.
Definition: MagicWord.php:257
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition: hooks.txt:242
static pagenamee($parser, $title=null)
static getCachedRevisionObject($parser, $title=null)
Fetched the current revision of the given title and return this.
static fullpagename($parser, $title=null)
static localurle($parser, $s= '', $arg=null)
static fullurl($parser, $s= '', $arg=null)
static images()
Definition: SiteStats.php:173
static subpagename($parser, $title=null)
static plural($parser, $text= '')
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 mwnamespace($parser, $title=null)
Given a title, return the namespace name that would be given by the corresponding magic word Note: fu...
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:802
static numberofadmins($parser, $raw=null)
static matchAgainstMagicword($magicword, $value)
Matches the given value against the value of given magic word.
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:462
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.
static namespacee($parser, $title=null)
static resolveAlias($alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
static nse($parser, $part1= '')
static normalizeCharReferences($text)
Ensure that any entities and character references are legal for XML and XHTML specifically.
Definition: Sanitizer.php:1400
static articles()
Definition: SiteStats.php:141
static revisionid($parser, $title=null)
Get the id from the last revision of a specified page.
static bidi($parser, $text= '')
static pages()
Definition: SiteStats.php:149
static pagesInNs($ns)
Definition: SiteStats.php:230
static newFromURL($url)
THIS IS NOT THE FUNCTION YOU WANT.
Definition: Title.php:339
const SFH_OBJECT_ARGS
Definition: Parser.php:86
static gender($parser, $username)
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition: design.txt:56
$wgAllowSlowParserFunctions
Enable slow parser functions.
static numberofpages($parser, $raw=null)
$count
static special($parser, $text)
static revisionyear($parser, $title=null)
Get the year from the last revision of a specified page.
static checkCss($value)
Pick apart some CSS and check it for forbidden or unsafe structures.
Definition: Sanitizer.php:1001
static numberingroup($group)
Find the number of users in a given user group.
Definition: SiteStats.php:183
static pagesinnamespace($parser, $namespace=0, $raw=null)
const STRIP_COMMENTS
static getDefaultOption($opt)
Get a given default option value.
Definition: User.php:1563
static ns($parser, $part1= '')
static uc($parser, $s= '')
static protectionlevel($parser, $type= '', $title= '')
Returns the requested protection level for the current page.
static ucfirst($parser, $s= '')
static cascadingsources($parser, $title= '')
Returns the sources of any cascading protection acting on a specified page.
static pageid($parser, $title=null)
Get the pageid of a specified page.
static displaytitle($parser, $text= '', $uarg= '')
Override the title of the page when viewed, provided we've been given a title which will normalise to...
wfFindFile($title, $options=[])
Find a file.
static users()
Definition: SiteStats.php:157
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2491
static numberoffiles($parser, $raw=null)
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:511
static padright($parser, $string= '', $length=0, $padding= '0')
static talkspacee($parser, $title=null)
static speciale($parser, $text)
static pagename($parser, $title=null)
Functions to get and normalize pagenames, corresponding to the magic words of the same names...
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1610
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2491
static numberofarticles($parser, $raw=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
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:300