MediaWiki  1.29.1
CoreParserFunctions.php
Go to the documentation of this file.
1 <?php
24 
34  public static function register( $parser ) {
35  global $wgAllowDisplayTitle, $wgAllowSlowParserFunctions;
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  }
83  $parser->setFunctionHook(
84  'pagesinnamespace',
85  [ __CLASS__, 'pagesinnamespace' ],
87  );
88  }
89  }
90 
96  public static function intFunction( $parser, $part1 = '' /*, ... */ ) {
97  if ( strval( $part1 ) !== '' ) {
98  $args = array_slice( func_get_args(), 2 );
99  $message = wfMessage( $part1, $args )
100  ->inLanguage( $parser->getOptions()->getUserLangObj() );
101  if ( !$message->exists() ) {
102  // When message does not exists, the message name is surrounded by angle
103  // and can result in a tag, therefore escape the angles
104  return $message->escaped();
105  }
106  return [ $message->plain(), 'noparse' => false ];
107  } else {
108  return [ 'found' => false ];
109  }
110  }
111 
119  public static function formatDate( $parser, $date, $defaultPref = null ) {
120  $lang = $parser->getFunctionLang();
122 
123  $date = trim( $date );
124 
125  $pref = $parser->getOptions()->getDateFormat();
126 
127  // Specify a different default date format other than the normal default
128  // if the user has 'default' for their setting
129  if ( $pref == 'default' && $defaultPref ) {
130  $pref = $defaultPref;
131  }
132 
133  $date = $df->reformat( $pref, $date, [ 'match-whole' ] );
134  return $date;
135  }
136 
137  public static function ns( $parser, $part1 = '' ) {
139  if ( intval( $part1 ) || $part1 == "0" ) {
140  $index = intval( $part1 );
141  } else {
142  $index = $wgContLang->getNsIndex( str_replace( ' ', '_', $part1 ) );
143  }
144  if ( $index !== false ) {
145  return $wgContLang->getFormattedNsText( $index );
146  } else {
147  return [ 'found' => false ];
148  }
149  }
150 
151  public static function nse( $parser, $part1 = '' ) {
152  $ret = self::ns( $parser, $part1 );
153  if ( is_string( $ret ) ) {
154  $ret = wfUrlencode( str_replace( ' ', '_', $ret ) );
155  }
156  return $ret;
157  }
158 
171  public static function urlencode( $parser, $s = '', $arg = null ) {
172  static $magicWords = null;
173  if ( is_null( $magicWords ) ) {
174  $magicWords = new MagicWordArray( [ 'url_path', 'url_query', 'url_wiki' ] );
175  }
176  switch ( $magicWords->matchStartToEnd( $arg ) ) {
177 
178  // Encode as though it's a wiki page, '_' for ' '.
179  case 'url_wiki':
180  $func = 'wfUrlencode';
181  $s = str_replace( ' ', '_', $s );
182  break;
183 
184  // Encode for an HTTP Path, '%20' for ' '.
185  case 'url_path':
186  $func = 'rawurlencode';
187  break;
188 
189  // Encode for HTTP query, '+' for ' '.
190  case 'url_query':
191  default:
192  $func = 'urlencode';
193  }
194  // See T105242, where the choice to kill markers and various
195  // other options were discussed.
196  return $func( $parser->killMarkers( $s ) );
197  }
198 
199  public static function lcfirst( $parser, $s = '' ) {
201  return $wgContLang->lcfirst( $s );
202  }
203 
204  public static function ucfirst( $parser, $s = '' ) {
206  return $wgContLang->ucfirst( $s );
207  }
208 
214  public static function lc( $parser, $s = '' ) {
216  return $parser->markerSkipCallback( $s, [ $wgContLang, 'lc' ] );
217  }
218 
224  public static function uc( $parser, $s = '' ) {
226  return $parser->markerSkipCallback( $s, [ $wgContLang, 'uc' ] );
227  }
228 
229  public static function localurl( $parser, $s = '', $arg = null ) {
230  return self::urlFunction( 'getLocalURL', $s, $arg );
231  }
232 
233  public static function localurle( $parser, $s = '', $arg = null ) {
234  $temp = self::urlFunction( 'getLocalURL', $s, $arg );
235  if ( !is_string( $temp ) ) {
236  return $temp;
237  } else {
238  return htmlspecialchars( $temp );
239  }
240  }
241 
242  public static function fullurl( $parser, $s = '', $arg = null ) {
243  return self::urlFunction( 'getFullURL', $s, $arg );
244  }
245 
246  public static function fullurle( $parser, $s = '', $arg = null ) {
247  $temp = self::urlFunction( 'getFullURL', $s, $arg );
248  if ( !is_string( $temp ) ) {
249  return $temp;
250  } else {
251  return htmlspecialchars( $temp );
252  }
253  }
254 
255  public static function canonicalurl( $parser, $s = '', $arg = null ) {
256  return self::urlFunction( 'getCanonicalURL', $s, $arg );
257  }
258 
259  public static function canonicalurle( $parser, $s = '', $arg = null ) {
260  $temp = self::urlFunction( 'getCanonicalURL', $s, $arg );
261  if ( !is_string( $temp ) ) {
262  return $temp;
263  } else {
264  return htmlspecialchars( $temp );
265  }
266  }
267 
268  public static function urlFunction( $func, $s = '', $arg = null ) {
270  # Due to order of execution of a lot of bits, the values might be encoded
271  # before arriving here; if that's true, then the title can't be created
272  # and the variable will fail. If we can't get a decent title from the first
273  # attempt, url-decode and try for a second.
274  if ( is_null( $title ) ) {
275  $title = Title::newFromURL( urldecode( $s ) );
276  }
277  if ( !is_null( $title ) ) {
278  # Convert NS_MEDIA -> NS_FILE
279  if ( $title->inNamespace( NS_MEDIA ) ) {
280  $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
281  }
282  if ( !is_null( $arg ) ) {
283  $text = $title->$func( $arg );
284  } else {
285  $text = $title->$func();
286  }
287  return $text;
288  } else {
289  return [ 'found' => false ];
290  }
291  }
292 
299  public static function formatnum( $parser, $num = '', $arg = null ) {
300  if ( self::matchAgainstMagicword( 'rawsuffix', $arg ) ) {
301  $func = [ $parser->getFunctionLang(), 'parseFormattedNumber' ];
302  } elseif ( self::matchAgainstMagicword( 'nocommafysuffix', $arg ) ) {
303  $func = [ $parser->getFunctionLang(), 'formatNumNoSeparators' ];
304  } else {
305  $func = [ $parser->getFunctionLang(), 'formatNum' ];
306  }
307  return $parser->markerSkipCallback( $num, $func );
308  }
309 
316  public static function grammar( $parser, $case = '', $word = '' ) {
317  $word = $parser->killMarkers( $word );
318  return $parser->getFunctionLang()->convertGrammar( $word, $case );
319  }
320 
326  public static function gender( $parser, $username ) {
327  $forms = array_slice( func_get_args(), 2 );
328 
329  // Some shortcuts to avoid loading user data unnecessarily
330  if ( count( $forms ) === 0 ) {
331  return '';
332  } elseif ( count( $forms ) === 1 ) {
333  return $forms[0];
334  }
335 
336  $username = trim( $username );
337 
338  // default
339  $gender = User::getDefaultOption( 'gender' );
340 
341  // allow prefix.
343 
344  if ( $title && $title->inNamespace( NS_USER ) ) {
345  $username = $title->getText();
346  }
347 
348  // check parameter, or use the ParserOptions if in interface message
350  $genderCache = MediaWikiServices::getInstance()->getGenderCache();
351  if ( $user ) {
352  $gender = $genderCache->getGenderOf( $user, __METHOD__ );
353  } elseif ( $username === '' && $parser->getOptions()->getInterfaceMessage() ) {
354  $gender = $genderCache->getGenderOf( $parser->getOptions()->getUser(), __METHOD__ );
355  }
356  $ret = $parser->getFunctionLang()->gender( $gender, $forms );
357  return $ret;
358  }
359 
365  public static function plural( $parser, $text = '' ) {
366  $forms = array_slice( func_get_args(), 2 );
367  $text = $parser->getFunctionLang()->parseFormattedNumber( $text );
368  settype( $text, ctype_digit( $text ) ? 'int' : 'float' );
369  return $parser->getFunctionLang()->convertPlural( $text, $forms );
370  }
371 
377  public static function bidi( $parser, $text = '' ) {
378  return $parser->getFunctionLang()->embedBidi( $text );
379  }
380 
390  public static function displaytitle( $parser, $text = '', $uarg = '' ) {
391  global $wgRestrictDisplayTitle;
392 
393  static $magicWords = null;
394  if ( is_null( $magicWords ) ) {
395  $magicWords = new MagicWordArray( [ 'displaytitle_noerror', 'displaytitle_noreplace' ] );
396  }
397  $arg = $magicWords->matchStartToEnd( $uarg );
398 
399  // parse a limited subset of wiki markup (just the single quote items)
400  $text = $parser->doQuotes( $text );
401 
402  // remove stripped text (e.g. the UNIQ-QINU stuff) that was generated by tag extensions/whatever
403  $text = $parser->killMarkers( $text );
404 
405  // list of disallowed tags for DISPLAYTITLE
406  // these will be escaped even though they are allowed in normal wiki text
407  $bad = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr',
408  'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rtc', 'rp', 'br' ];
409 
410  // disallow some styles that could be used to bypass $wgRestrictDisplayTitle
411  if ( $wgRestrictDisplayTitle ) {
412  $htmlTagsCallback = function ( &$params ) {
413  $decoded = Sanitizer::decodeTagAttributes( $params );
414 
415  if ( isset( $decoded['style'] ) ) {
416  // this is called later anyway, but we need it right now for the regexes below to be safe
417  // calling it twice doesn't hurt
418  $decoded['style'] = Sanitizer::checkCss( $decoded['style'] );
419 
420  if ( preg_match( '/(display|user-select|visibility)\s*:/i', $decoded['style'] ) ) {
421  $decoded['style'] = '/* attempt to bypass $wgRestrictDisplayTitle */';
422  }
423  }
424 
425  $params = Sanitizer::safeEncodeTagAttributes( $decoded );
426  };
427  } else {
428  $htmlTagsCallback = null;
429  }
430 
431  // only requested titles that normalize to the actual title are allowed through
432  // if $wgRestrictDisplayTitle is true (it is by default)
433  // mimic the escaping process that occurs in OutputPage::setPageTitle
434  $text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags(
435  $text,
436  $htmlTagsCallback,
437  [],
438  [],
439  $bad
440  ) );
441  $title = Title::newFromText( Sanitizer::stripAllTags( $text ) );
442 
443  if ( !$wgRestrictDisplayTitle ||
444  ( $title instanceof Title
445  && !$title->hasFragment()
446  && $title->equals( $parser->mTitle ) )
447  ) {
448  $old = $parser->mOutput->getProperty( 'displaytitle' );
449  if ( $old === false || $arg !== 'displaytitle_noreplace' ) {
450  $parser->mOutput->setDisplayTitle( $text );
451  }
452  if ( $old !== false && $old !== $text && !$arg ) {
453  $converter = $parser->getConverterLanguage()->getConverter();
454  return '<span class="error">' .
455  wfMessage( 'duplicate-displaytitle',
456  // Message should be parsed, but these params should only be escaped.
457  $converter->markNoConversion( wfEscapeWikiText( $old ) ),
458  $converter->markNoConversion( wfEscapeWikiText( $text ) )
459  )->inContentLanguage()->text() .
460  '</span>';
461  } else {
462  return '';
463  }
464  } else {
465  $converter = $parser->getConverterLanguage()->getConverter();
466  $parser->getOutput()->addWarning(
467  wfMessage( 'restricted-displaytitle',
468  // Message should be parsed, but this param should only be escaped.
469  $converter->markNoConversion( wfEscapeWikiText( $text ) )
470  )->text()
471  );
472  $parser->addTrackingCategory( 'restricted-displaytitle-ignored' );
473  }
474  }
475 
483  private static function matchAgainstMagicword( $magicword, $value ) {
484  $value = trim( strval( $value ) );
485  if ( $value === '' ) {
486  return false;
487  }
488  $mwObject = MagicWord::get( $magicword );
489  return $mwObject->matchStartToEnd( $value );
490  }
491 
500  public static function formatRaw( $num, $raw, $language ) {
501  if ( self::matchAgainstMagicword( 'rawsuffix', $raw ) ) {
502  return $num;
503  } else {
504  return $language->formatNum( $num );
505  }
506  }
507 
508  public static function numberofpages( $parser, $raw = null ) {
509  return self::formatRaw( SiteStats::pages(), $raw, $parser->getFunctionLang() );
510  }
511 
512  public static function numberofusers( $parser, $raw = null ) {
513  return self::formatRaw( SiteStats::users(), $raw, $parser->getFunctionLang() );
514  }
515  public static function numberofactiveusers( $parser, $raw = null ) {
516  return self::formatRaw( SiteStats::activeUsers(), $raw, $parser->getFunctionLang() );
517  }
518 
519  public static function numberofarticles( $parser, $raw = null ) {
520  return self::formatRaw( SiteStats::articles(), $raw, $parser->getFunctionLang() );
521  }
522 
523  public static function numberoffiles( $parser, $raw = null ) {
524  return self::formatRaw( SiteStats::images(), $raw, $parser->getFunctionLang() );
525  }
526 
527  public static function numberofadmins( $parser, $raw = null ) {
528  return self::formatRaw(
529  SiteStats::numberingroup( 'sysop' ),
530  $raw,
531  $parser->getFunctionLang()
532  );
533  }
534 
535  public static function numberofedits( $parser, $raw = null ) {
536  return self::formatRaw( SiteStats::edits(), $raw, $parser->getFunctionLang() );
537  }
538 
539  public static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) {
540  return self::formatRaw(
541  SiteStats::pagesInNs( intval( $namespace ) ),
542  $raw,
543  $parser->getFunctionLang()
544  );
545  }
546  public static function numberingroup( $parser, $name = '', $raw = null ) {
547  return self::formatRaw(
548  SiteStats::numberingroup( strtolower( $name ) ),
549  $raw,
550  $parser->getFunctionLang()
551  );
552  }
553 
563  public static function mwnamespace( $parser, $title = null ) {
565  if ( is_null( $t ) ) {
566  return '';
567  }
568  return str_replace( '_', ' ', $t->getNsText() );
569  }
570  public static function namespacee( $parser, $title = null ) {
572  if ( is_null( $t ) ) {
573  return '';
574  }
575  return wfUrlencode( $t->getNsText() );
576  }
577  public static function namespacenumber( $parser, $title = null ) {
579  if ( is_null( $t ) ) {
580  return '';
581  }
582  return $t->getNamespace();
583  }
584  public static function talkspace( $parser, $title = null ) {
586  if ( is_null( $t ) || !$t->canTalk() ) {
587  return '';
588  }
589  return str_replace( '_', ' ', $t->getTalkNsText() );
590  }
591  public static function talkspacee( $parser, $title = null ) {
593  if ( is_null( $t ) || !$t->canTalk() ) {
594  return '';
595  }
596  return wfUrlencode( $t->getTalkNsText() );
597  }
598  public static function subjectspace( $parser, $title = null ) {
600  if ( is_null( $t ) ) {
601  return '';
602  }
603  return str_replace( '_', ' ', $t->getSubjectNsText() );
604  }
605  public static function subjectspacee( $parser, $title = null ) {
607  if ( is_null( $t ) ) {
608  return '';
609  }
610  return wfUrlencode( $t->getSubjectNsText() );
611  }
612 
620  public static function pagename( $parser, $title = null ) {
622  if ( is_null( $t ) ) {
623  return '';
624  }
625  return wfEscapeWikiText( $t->getText() );
626  }
627  public static function pagenamee( $parser, $title = null ) {
629  if ( is_null( $t ) ) {
630  return '';
631  }
632  return wfEscapeWikiText( $t->getPartialURL() );
633  }
634  public static function fullpagename( $parser, $title = null ) {
636  if ( is_null( $t ) || !$t->canTalk() ) {
637  return '';
638  }
639  return wfEscapeWikiText( $t->getPrefixedText() );
640  }
641  public static function fullpagenamee( $parser, $title = null ) {
643  if ( is_null( $t ) || !$t->canTalk() ) {
644  return '';
645  }
646  return wfEscapeWikiText( $t->getPrefixedURL() );
647  }
648  public static function subpagename( $parser, $title = null ) {
650  if ( is_null( $t ) ) {
651  return '';
652  }
653  return wfEscapeWikiText( $t->getSubpageText() );
654  }
655  public static function subpagenamee( $parser, $title = null ) {
657  if ( is_null( $t ) ) {
658  return '';
659  }
660  return wfEscapeWikiText( $t->getSubpageUrlForm() );
661  }
662  public static function rootpagename( $parser, $title = null ) {
664  if ( is_null( $t ) ) {
665  return '';
666  }
667  return wfEscapeWikiText( $t->getRootText() );
668  }
669  public static function rootpagenamee( $parser, $title = null ) {
671  if ( is_null( $t ) ) {
672  return '';
673  }
674  return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getRootText() ) ) );
675  }
676  public static function basepagename( $parser, $title = null ) {
678  if ( is_null( $t ) ) {
679  return '';
680  }
681  return wfEscapeWikiText( $t->getBaseText() );
682  }
683  public static function basepagenamee( $parser, $title = null ) {
685  if ( is_null( $t ) ) {
686  return '';
687  }
688  return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getBaseText() ) ) );
689  }
690  public static function talkpagename( $parser, $title = null ) {
692  if ( is_null( $t ) || !$t->canTalk() ) {
693  return '';
694  }
695  return wfEscapeWikiText( $t->getTalkPage()->getPrefixedText() );
696  }
697  public static function talkpagenamee( $parser, $title = null ) {
699  if ( is_null( $t ) || !$t->canTalk() ) {
700  return '';
701  }
702  return wfEscapeWikiText( $t->getTalkPage()->getPrefixedURL() );
703  }
704  public static function subjectpagename( $parser, $title = null ) {
706  if ( is_null( $t ) ) {
707  return '';
708  }
709  return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() );
710  }
711  public static function subjectpagenamee( $parser, $title = null ) {
713  if ( is_null( $t ) ) {
714  return '';
715  }
716  return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedURL() );
717  }
718 
729  public static function pagesincategory( $parser, $name = '', $arg1 = null, $arg2 = null ) {
731  static $magicWords = null;
732  if ( is_null( $magicWords ) ) {
733  $magicWords = new MagicWordArray( [
734  'pagesincategory_all',
735  'pagesincategory_pages',
736  'pagesincategory_subcats',
737  'pagesincategory_files'
738  ] );
739  }
740  static $cache = [];
741 
742  // split the given option to its variable
743  if ( self::matchAgainstMagicword( 'rawsuffix', $arg1 ) ) {
744  // {{pagesincategory:|raw[|type]}}
745  $raw = $arg1;
746  $type = $magicWords->matchStartToEnd( $arg2 );
747  } else {
748  // {{pagesincategory:[|type[|raw]]}}
749  $type = $magicWords->matchStartToEnd( $arg1 );
750  $raw = $arg2;
751  }
752  if ( !$type ) { // backward compatibility
753  $type = 'pagesincategory_all';
754  }
755 
757  if ( !$title ) { # invalid title
758  return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
759  }
760  $wgContLang->findVariantLink( $name, $title, true );
761 
762  // Normalize name for cache
763  $name = $title->getDBkey();
764 
765  if ( !isset( $cache[$name] ) ) {
766  $category = Category::newFromTitle( $title );
767 
768  $allCount = $subcatCount = $fileCount = $pagesCount = 0;
769  if ( $parser->incrementExpensiveFunctionCount() ) {
770  // $allCount is the total number of cat members,
771  // not the count of how many members are normal pages.
772  $allCount = (int)$category->getPageCount();
773  $subcatCount = (int)$category->getSubcatCount();
774  $fileCount = (int)$category->getFileCount();
775  $pagesCount = $allCount - $subcatCount - $fileCount;
776  }
777  $cache[$name]['pagesincategory_all'] = $allCount;
778  $cache[$name]['pagesincategory_pages'] = $pagesCount;
779  $cache[$name]['pagesincategory_subcats'] = $subcatCount;
780  $cache[$name]['pagesincategory_files'] = $fileCount;
781  }
782 
783  $count = $cache[$name][$type];
784  return self::formatRaw( $count, $raw, $parser->getFunctionLang() );
785  }
786 
796  public static function pagesize( $parser, $page = '', $raw = null ) {
798 
799  if ( !is_object( $title ) ) {
800  return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
801  }
802 
803  // fetch revision from cache/database and return the value
805  $length = $rev ? $rev->getSize() : 0;
806  if ( $length === null ) {
807  // We've had bugs where rev_len was not being recorded for empty pages, see T135414
808  $length = 0;
809  }
810  return self::formatRaw( $length, $raw, $parser->getFunctionLang() );
811  }
812 
825  public static function protectionlevel( $parser, $type = '', $title = '' ) {
826  $titleObject = Title::newFromText( $title );
827  if ( !( $titleObject instanceof Title ) ) {
828  $titleObject = $parser->mTitle;
829  }
830  if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
831  $restrictions = $titleObject->getRestrictions( strtolower( $type ) );
832  # Title::getRestrictions returns an array, its possible it may have
833  # multiple values in the future
834  return implode( $restrictions, ',' );
835  }
836  return '';
837  }
838 
851  public static function protectionexpiry( $parser, $type = '', $title = '' ) {
852  $titleObject = Title::newFromText( $title );
853  if ( !( $titleObject instanceof Title ) ) {
854  $titleObject = $parser->mTitle;
855  }
856  if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
857  $expiry = $titleObject->getRestrictionExpiry( strtolower( $type ) );
858  // getRestrictionExpiry() returns false on invalid type; trying to
859  // match protectionlevel() function that returns empty string instead
860  if ( $expiry === false ) {
861  $expiry = '';
862  }
863  return $expiry;
864  }
865  return '';
866  }
867 
875  public static function language( $parser, $code = '', $inLanguage = '' ) {
876  $code = strtolower( $code );
877  $inLanguage = strtolower( $inLanguage );
878  $lang = Language::fetchLanguageName( $code, $inLanguage );
879  return $lang !== '' ? $lang : wfBCP47( $code );
880  }
881 
891  public static function pad(
892  $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT
893  ) {
894  $padding = $parser->killMarkers( $padding );
895  $lengthOfPadding = mb_strlen( $padding );
896  if ( $lengthOfPadding == 0 ) {
897  return $string;
898  }
899 
900  # The remaining length to add counts down to 0 as padding is added
901  $length = min( $length, 500 ) - mb_strlen( $string );
902  # $finalPadding is just $padding repeated enough times so that
903  # mb_strlen( $string ) + mb_strlen( $finalPadding ) == $length
904  $finalPadding = '';
905  while ( $length > 0 ) {
906  # If $length < $lengthofPadding, truncate $padding so we get the
907  # exact length desired.
908  $finalPadding .= mb_substr( $padding, 0, $length );
909  $length -= $lengthOfPadding;
910  }
911 
912  if ( $direction == STR_PAD_LEFT ) {
913  return $finalPadding . $string;
914  } else {
915  return $string . $finalPadding;
916  }
917  }
918 
919  public static function padleft( $parser, $string = '', $length = 0, $padding = '0' ) {
920  return self::pad( $parser, $string, $length, $padding, STR_PAD_LEFT );
921  }
922 
923  public static function padright( $parser, $string = '', $length = 0, $padding = '0' ) {
924  return self::pad( $parser, $string, $length, $padding );
925  }
926 
932  public static function anchorencode( $parser, $text ) {
933  $text = $parser->killMarkers( $text );
934  return (string)substr( $parser->guessSectionNameFromWikiText( $text ), 1 );
935  }
936 
937  public static function special( $parser, $text ) {
938  list( $page, $subpage ) = SpecialPageFactory::resolveAlias( $text );
939  if ( $page ) {
940  $title = SpecialPage::getTitleFor( $page, $subpage );
941  return $title->getPrefixedText();
942  } else {
943  // unknown special page, just use the given text as its title, if at all possible
945  return $title ? $title->getPrefixedText() : self::special( $parser, 'Badtitle' );
946  }
947  }
948 
949  public static function speciale( $parser, $text ) {
950  return wfUrlencode( str_replace( ' ', '_', self::special( $parser, $text ) ) );
951  }
952 
961  public static function defaultsort( $parser, $text, $uarg = '' ) {
962  static $magicWords = null;
963  if ( is_null( $magicWords ) ) {
964  $magicWords = new MagicWordArray( [ 'defaultsort_noerror', 'defaultsort_noreplace' ] );
965  }
966  $arg = $magicWords->matchStartToEnd( $uarg );
967 
968  $text = trim( $text );
969  if ( strlen( $text ) == 0 ) {
970  return '';
971  }
972  $old = $parser->getCustomDefaultSort();
973  if ( $old === false || $arg !== 'defaultsort_noreplace' ) {
974  $parser->setDefaultSort( $text );
975  }
976 
977  if ( $old === false || $old == $text || $arg ) {
978  return '';
979  } else {
980  $converter = $parser->getConverterLanguage()->getConverter();
981  return '<span class="error">' .
982  wfMessage( 'duplicate-defaultsort',
983  // Message should be parsed, but these params should only be escaped.
984  $converter->markNoConversion( wfEscapeWikiText( $old ) ),
985  $converter->markNoConversion( wfEscapeWikiText( $text ) )
986  )->inContentLanguage()->text() .
987  '</span>';
988  }
989  }
990 
1002  public static function filepath( $parser, $name = '', $argA = '', $argB = '' ) {
1003  $file = wfFindFile( $name );
1004 
1005  if ( $argA == 'nowiki' ) {
1006  // {{filepath: | option [| size] }}
1007  $isNowiki = true;
1008  $parsedWidthParam = $parser->parseWidthParam( $argB );
1009  } else {
1010  // {{filepath: [| size [|option]] }}
1011  $parsedWidthParam = $parser->parseWidthParam( $argA );
1012  $isNowiki = ( $argB == 'nowiki' );
1013  }
1014 
1015  if ( $file ) {
1016  $url = $file->getFullUrl();
1017 
1018  // If a size is requested...
1019  if ( count( $parsedWidthParam ) ) {
1020  $mto = $file->transform( $parsedWidthParam );
1021  // ... and we can
1022  if ( $mto && !$mto->isError() ) {
1023  // ... change the URL to point to a thumbnail.
1024  $url = wfExpandUrl( $mto->getUrl(), PROTO_RELATIVE );
1025  }
1026  }
1027  if ( $isNowiki ) {
1028  return [ $url, 'nowiki' => true ];
1029  }
1030  return $url;
1031  } else {
1032  return '';
1033  }
1034  }
1035 
1043  public static function tagObj( $parser, $frame, $args ) {
1044  if ( !count( $args ) ) {
1045  return '';
1046  }
1047  $tagName = strtolower( trim( $frame->expand( array_shift( $args ) ) ) );
1048 
1049  if ( count( $args ) ) {
1050  $inner = $frame->expand( array_shift( $args ) );
1051  } else {
1052  $inner = null;
1053  }
1054 
1055  $attributes = [];
1056  foreach ( $args as $arg ) {
1057  $bits = $arg->splitArg();
1058  if ( strval( $bits['index'] ) === '' ) {
1059  $name = trim( $frame->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
1060  $value = trim( $frame->expand( $bits['value'] ) );
1061  if ( preg_match( '/^(?:["\'](.+)["\']|""|\'\')$/s', $value, $m ) ) {
1062  $value = isset( $m[1] ) ? $m[1] : '';
1063  }
1064  $attributes[$name] = $value;
1065  }
1066  }
1067 
1068  $stripList = $parser->getStripList();
1069  if ( !in_array( $tagName, $stripList ) ) {
1070  // we can't handle this tag (at least not now), so just re-emit it as an ordinary tag
1071  $attrText = '';
1072  foreach ( $attributes as $name => $value ) {
1073  $attrText .= ' ' . htmlspecialchars( $name ) . '="' . htmlspecialchars( $value ) . '"';
1074  }
1075  if ( $inner === null ) {
1076  return "<$tagName$attrText/>";
1077  }
1078  return "<$tagName$attrText>$inner</$tagName>";
1079  }
1080 
1081  $params = [
1082  'name' => $tagName,
1083  'inner' => $inner,
1084  'attributes' => $attributes,
1085  'close' => "</$tagName>",
1086  ];
1087  return $parser->extensionSubstitution( $params, $frame );
1088  }
1089 
1102  private static function getCachedRevisionObject( $parser, $title = null ) {
1103  if ( is_null( $title ) ) {
1104  return null;
1105  }
1106 
1107  // Use the revision from the parser itself, when param is the current page
1108  // and the revision is the current one
1109  if ( $title->equals( $parser->getTitle() ) ) {
1110  $parserRev = $parser->getRevisionObject();
1111  if ( $parserRev && $parserRev->isCurrent() ) {
1112  // force reparse after edit with vary-revision flag
1113  $parser->getOutput()->setFlag( 'vary-revision' );
1114  wfDebug( __METHOD__ . ": use current revision from parser, setting vary-revision...\n" );
1115  return $parserRev;
1116  }
1117  }
1118 
1119  // Normalize name for cache
1120  $page = $title->getPrefixedDBkey();
1121 
1122  if ( !( $parser->currentRevisionCache && $parser->currentRevisionCache->has( $page ) )
1123  && !$parser->incrementExpensiveFunctionCount() ) {
1124  return null;
1125  }
1126  $rev = $parser->fetchCurrentRevisionOfTitle( $title );
1127  $pageID = $rev ? $rev->getPage() : 0;
1128  $revID = $rev ? $rev->getId() : 0;
1129 
1130  // Register dependency in templatelinks
1131  $parser->getOutput()->addTemplate( $title, $pageID, $revID );
1132 
1133  return $rev;
1134  }
1135 
1143  public static function pageid( $parser, $title = null ) {
1145  if ( is_null( $t ) ) {
1146  return '';
1147  }
1148  // Use title from parser to have correct pageid after edit
1149  if ( $t->equals( $parser->getTitle() ) ) {
1150  $t = $parser->getTitle();
1151  return $t->getArticleID();
1152  }
1153 
1154  // These can't have ids
1155  if ( !$t->canExist() || $t->isExternal() ) {
1156  return 0;
1157  }
1158 
1159  // Check the link cache, maybe something already looked it up.
1160  $linkCache = LinkCache::singleton();
1161  $pdbk = $t->getPrefixedDBkey();
1162  $id = $linkCache->getGoodLinkID( $pdbk );
1163  if ( $id != 0 ) {
1164  $parser->mOutput->addLink( $t, $id );
1165  return $id;
1166  }
1167  if ( $linkCache->isBadLink( $pdbk ) ) {
1168  $parser->mOutput->addLink( $t, 0 );
1169  return $id;
1170  }
1171 
1172  // We need to load it from the DB, so mark expensive
1173  if ( $parser->incrementExpensiveFunctionCount() ) {
1174  $id = $t->getArticleID();
1175  $parser->mOutput->addLink( $t, $id );
1176  return $id;
1177  }
1178  return null;
1179  }
1180 
1188  public static function revisionid( $parser, $title = null ) {
1190  if ( is_null( $t ) ) {
1191  return '';
1192  }
1193  // fetch revision from cache/database and return the value
1195  return $rev ? $rev->getId() : '';
1196  }
1197 
1205  public static function revisionday( $parser, $title = null ) {
1207  if ( is_null( $t ) ) {
1208  return '';
1209  }
1210  // fetch revision from cache/database and return the value
1212  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'j' ) : '';
1213  }
1214 
1222  public static function revisionday2( $parser, $title = null ) {
1224  if ( is_null( $t ) ) {
1225  return '';
1226  }
1227  // fetch revision from cache/database and return the value
1229  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'd' ) : '';
1230  }
1231 
1239  public static function revisionmonth( $parser, $title = null ) {
1241  if ( is_null( $t ) ) {
1242  return '';
1243  }
1244  // fetch revision from cache/database and return the value
1246  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'm' ) : '';
1247  }
1248 
1256  public static function revisionmonth1( $parser, $title = null ) {
1258  if ( is_null( $t ) ) {
1259  return '';
1260  }
1261  // fetch revision from cache/database and return the value
1263  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'n' ) : '';
1264  }
1265 
1273  public static function revisionyear( $parser, $title = null ) {
1275  if ( is_null( $t ) ) {
1276  return '';
1277  }
1278  // fetch revision from cache/database and return the value
1280  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'Y' ) : '';
1281  }
1282 
1290  public static function revisiontimestamp( $parser, $title = null ) {
1292  if ( is_null( $t ) ) {
1293  return '';
1294  }
1295  // fetch revision from cache/database and return the value
1297  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'YmdHis' ) : '';
1298  }
1299 
1307  public static function revisionuser( $parser, $title = null ) {
1309  if ( is_null( $t ) ) {
1310  return '';
1311  }
1312  // fetch revision from cache/database and return the value
1314  return $rev ? $rev->getUserText() : '';
1315  }
1316 
1329  public static function cascadingsources( $parser, $title = '' ) {
1330  $titleObject = Title::newFromText( $title );
1331  if ( !( $titleObject instanceof Title ) ) {
1332  $titleObject = $parser->mTitle;
1333  }
1334  if ( $titleObject->areCascadeProtectionSourcesLoaded()
1335  || $parser->incrementExpensiveFunctionCount()
1336  ) {
1337  $names = [];
1338  $sources = $titleObject->getCascadeProtectionSources();
1339  foreach ( $sources[0] as $sourceTitle ) {
1340  $names[] = $sourceTitle->getPrefixedText();
1341  }
1342  return implode( $names, '|' );
1343  }
1344  return '';
1345  }
1346 
1347 }
User\getDefaultOption
static getDefaultOption( $opt)
Get a given default option value.
Definition: User.php:1603
CoreParserFunctions\protectionexpiry
static protectionexpiry( $parser, $type='', $title='')
Returns the requested protection expiry for the current page.
Definition: CoreParserFunctions.php:851
SiteStats\articles
static articles()
Definition: SiteStats.php:144
MagicWordArray
Class for handling an array of magic words.
Definition: MagicWordArray.php:31
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:265
PPFrame\STRIP_COMMENTS
const STRIP_COMMENTS
Definition: Preprocessor.php:168
CoreParserFunctions\displaytitle
static displaytitle( $parser, $text='', $uarg='')
Override the title of the page when viewed, provided we've been given a title which will normalise to...
Definition: CoreParserFunctions.php:390
wfBCP47
wfBCP47( $code)
Get the normalised IETF language tag See unit test for examples.
Definition: GlobalFunctions.php:3370
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
SiteStats\users
static users()
Definition: SiteStats.php:160
CoreParserFunctions\matchAgainstMagicword
static matchAgainstMagicword( $magicword, $value)
Matches the given value against the value of given magic word.
Definition: CoreParserFunctions.php:483
SiteStats\activeUsers
static activeUsers()
Definition: SiteStats.php:168
CoreParserFunctions\pad
static pad( $parser, $string, $length, $padding='0', $direction=STR_PAD_RIGHT)
Unicode-safe str_pad with the restriction that $length is forced to be <= 500.
Definition: CoreParserFunctions.php:891
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
CoreParserFunctions\numberofactiveusers
static numberofactiveusers( $parser, $raw=null)
Definition: CoreParserFunctions.php:515
CoreParserFunctions\pageid
static pageid( $parser, $title=null)
Get the pageid of a specified page.
Definition: CoreParserFunctions.php:1143
captcha-old.count
count
Definition: captcha-old.py:225
text
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
CoreParserFunctions\talkpagename
static talkpagename( $parser, $title=null)
Definition: CoreParserFunctions.php:690
CoreParserFunctions\rootpagename
static rootpagename( $parser, $title=null)
Definition: CoreParserFunctions.php:662
CoreParserFunctions\tagObj
static tagObj( $parser, $frame, $args)
Parser function to extension tag adaptor.
Definition: CoreParserFunctions.php:1043
CoreParserFunctions\pagesize
static pagesize( $parser, $page='', $raw=null)
Return the size of the given page, or 0 if it's nonexistent.
Definition: CoreParserFunctions.php:796
SiteStats\pages
static pages()
Definition: SiteStats.php:152
CoreParserFunctions\rootpagenamee
static rootpagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:669
CoreParserFunctions\protectionlevel
static protectionlevel( $parser, $type='', $title='')
Returns the requested protection level for the current page.
Definition: CoreParserFunctions.php:825
DateFormatter\getInstance
static getInstance( $lang=null)
Get a DateFormatter object.
Definition: DateFormatter.php:133
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
wfUrlencode
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
Definition: GlobalFunctions.php:371
SiteStats\numberingroup
static numberingroup( $group)
Find the number of users in a given user group.
Definition: SiteStats.php:186
$user
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 account $user
Definition: hooks.txt:246
SFH_OBJECT_ARGS
const SFH_OBJECT_ARGS
Definition: Defines.php:196
MagicWord\get
static & get( $id)
Factory: creates an object representing an ID.
Definition: MagicWord.php:258
CoreParserFunctions\nse
static nse( $parser, $part1='')
Definition: CoreParserFunctions.php:151
NS_FILE
const NS_FILE
Definition: Defines.php:68
$params
$params
Definition: styleTest.css.php:40
CoreParserFunctions\revisionmonth1
static revisionmonth1( $parser, $title=null)
Get the month from the last revision of a specified page.
Definition: CoreParserFunctions.php:1256
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:556
$s
$s
Definition: mergeMessageFileList.php:188
SpecialPage\getTitleFor
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
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
CoreParserFunctions\namespacenumber
static namespacenumber( $parser, $title=null)
Definition: CoreParserFunctions.php:577
CoreParserFunctions\talkspace
static talkspace( $parser, $title=null)
Definition: CoreParserFunctions.php:584
$type
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 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:2536
CoreParserFunctions\grammar
static grammar( $parser, $case='', $word='')
Definition: CoreParserFunctions.php:316
CoreParserFunctions\formatRaw
static formatRaw( $num, $raw, $language)
Formats a number according to a language.
Definition: CoreParserFunctions.php:500
CoreParserFunctions\defaultsort
static defaultsort( $parser, $text, $uarg='')
Definition: CoreParserFunctions.php:961
php
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
CoreParserFunctions\revisionday
static revisionday( $parser, $title=null)
Get the day from the last revision of a specified page.
Definition: CoreParserFunctions.php:1205
CoreParserFunctions\pagename
static pagename( $parser, $title=null)
Functions to get and normalize pagenames, corresponding to the magic words of the same names.
Definition: CoreParserFunctions.php:620
SiteStats\images
static images()
Definition: SiteStats.php:176
CoreParserFunctions\revisionid
static revisionid( $parser, $title=null)
Get the id from the last revision of a specified page.
Definition: CoreParserFunctions.php:1188
CoreParserFunctions\talkspacee
static talkspacee( $parser, $title=null)
Definition: CoreParserFunctions.php:591
CoreParserFunctions\localurle
static localurle( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:233
CoreParserFunctions\getCachedRevisionObject
static getCachedRevisionObject( $parser, $title=null)
Fetched the current revision of the given title and return this.
Definition: CoreParserFunctions.php:1102
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:51
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
CoreParserFunctions\plural
static plural( $parser, $text='')
Definition: CoreParserFunctions.php:365
CoreParserFunctions\numberofpages
static numberofpages( $parser, $raw=null)
Definition: CoreParserFunctions.php:508
CoreParserFunctions\basepagenamee
static basepagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:683
$page
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:2536
CoreParserFunctions\revisionyear
static revisionyear( $parser, $title=null)
Get the year from the last revision of a specified page.
Definition: CoreParserFunctions.php:1273
CoreParserFunctions\mwnamespace
static mwnamespace( $parser, $title=null)
Given a title, return the namespace name that would be given by the corresponding magic word Note: fu...
Definition: CoreParserFunctions.php:563
CoreParserFunctions\fullurle
static fullurle( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:246
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:2536
CoreParserFunctions\numberofedits
static numberofedits( $parser, $raw=null)
Definition: CoreParserFunctions.php:535
CoreParserFunctions\revisionday2
static revisionday2( $parser, $title=null)
Get the day with leading zeros from the last revision of a specified page.
Definition: CoreParserFunctions.php:1222
CoreParserFunctions\fullurl
static fullurl( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:242
CoreParserFunctions\ucfirst
static ucfirst( $parser, $s='')
Definition: CoreParserFunctions.php:204
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:514
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:76
CoreParserFunctions\fullpagenamee
static fullpagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:641
$magicWords
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
CoreParserFunctions\gender
static gender( $parser, $username)
Definition: CoreParserFunctions.php:326
CoreParserFunctions\pagenamee
static pagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:627
CoreParserFunctions\ns
static ns( $parser, $part1='')
Definition: CoreParserFunctions.php:137
CoreParserFunctions\subjectpagename
static subjectpagename( $parser, $title=null)
Definition: CoreParserFunctions.php:704
CoreParserFunctions\language
static language( $parser, $code='', $inLanguage='')
Gives language names.
Definition: CoreParserFunctions.php:875
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:999
CoreParserFunctions\revisiontimestamp
static revisiontimestamp( $parser, $title=null)
Get the timestamp from the last revision of a specified page.
Definition: CoreParserFunctions.php:1290
list
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
CoreParserFunctions\bidi
static bidi( $parser, $text='')
Definition: CoreParserFunctions.php:377
Category\newFromTitle
static newFromTitle( $title)
Factory function.
Definition: Category.php:140
CoreParserFunctions\urlencode
static urlencode( $parser, $s='', $arg=null)
urlencodes a string according to one of three patterns: (T24474)
Definition: CoreParserFunctions.php:171
CoreParserFunctions\formatDate
static formatDate( $parser, $date, $defaultPref=null)
Definition: CoreParserFunctions.php:119
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:538
CoreParserFunctions\fullpagename
static fullpagename( $parser, $title=null)
Definition: CoreParserFunctions.php:634
SiteStats\pagesInNs
static pagesInNs( $ns)
Definition: SiteStats.php:236
$value
$value
Definition: styleTest.css.php:45
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:50
CoreParserFunctions\padleft
static padleft( $parser, $string='', $length=0, $padding='0')
Definition: CoreParserFunctions.php:919
title
title
Definition: parserTests.txt:211
CoreParserFunctions\padright
static padright( $parser, $string='', $length=0, $padding='0')
Definition: CoreParserFunctions.php:923
Title\newFromURL
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
Definition: Title.php:342
CoreParserFunctions\revisionmonth
static revisionmonth( $parser, $title=null)
Get the month with leading zeros from the last revision of a specified page.
Definition: CoreParserFunctions.php:1239
SpecialPageFactory\resolveAlias
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
Definition: SpecialPageFactory.php:338
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1657
PROTO_RELATIVE
const PROTO_RELATIVE
Definition: Defines.php:219
$ret
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:1956
CoreParserFunctions\subjectspacee
static subjectspacee( $parser, $title=null)
Definition: CoreParserFunctions.php:605
CoreParserFunctions\speciale
static speciale( $parser, $text)
Definition: CoreParserFunctions.php:949
Language\fetchLanguageName
static fetchLanguageName( $code, $inLanguage=null, $include='all')
Definition: Language.php:891
CoreParserFunctions\urlFunction
static urlFunction( $func, $s='', $arg=null)
Definition: CoreParserFunctions.php:268
CoreParserFunctions\lc
static lc( $parser, $s='')
Definition: CoreParserFunctions.php:214
CoreParserFunctions\subjectspace
static subjectspace( $parser, $title=null)
Definition: CoreParserFunctions.php:598
CoreParserFunctions\subjectpagenamee
static subjectpagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:711
format
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1630
wfFindFile
wfFindFile( $title, $options=[])
Find a file.
Definition: GlobalFunctions.php:3101
SFH_NO_HASH
const SFH_NO_HASH
Definition: Defines.php:195
$args
if( $line===false) $args
Definition: cdb.php:63
Title
Represents a title within MediaWiki.
Definition: Title.php:39
CoreParserFunctions\numberofadmins
static numberofadmins( $parser, $raw=null)
Definition: CoreParserFunctions.php:527
CoreParserFunctions\cascadingsources
static cascadingsources( $parser, $title='')
Returns the sources of any cascading protection acting on a specified page.
Definition: CoreParserFunctions.php:1329
CoreParserFunctions\anchorencode
static anchorencode( $parser, $text)
Definition: CoreParserFunctions.php:932
$cache
$cache
Definition: mcc.php:33
CoreParserFunctions\uc
static uc( $parser, $s='')
Definition: CoreParserFunctions.php:224
CoreParserFunctions\special
static special( $parser, $text)
Definition: CoreParserFunctions.php:937
$code
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:783
CoreParserFunctions\subpagenamee
static subpagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:655
CoreParserFunctions\filepath
static filepath( $parser, $name='', $argA='', $argB='')
Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}} or {{...
Definition: CoreParserFunctions.php:1002
CoreParserFunctions\namespacee
static namespacee( $parser, $title=null)
Definition: CoreParserFunctions.php:570
CoreParserFunctions\numberofarticles
static numberofarticles( $parser, $raw=null)
Definition: CoreParserFunctions.php:519
LinkCache\singleton
static singleton()
Get an instance of this class.
Definition: LinkCache.php:67
$rev
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:1741
as
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
CoreParserFunctions
Various core parser functions, registered in Parser::firstCallInit()
Definition: CoreParserFunctions.php:29
CoreParserFunctions\subpagename
static subpagename( $parser, $title=null)
Definition: CoreParserFunctions.php:648
NS_USER
const NS_USER
Definition: Defines.php:64
CoreParserFunctions\revisionuser
static revisionuser( $parser, $title=null)
Get the user from the last revision of a specified page.
Definition: CoreParserFunctions.php:1307
true
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:1956
CoreParserFunctions\numberingroup
static numberingroup( $parser, $name='', $raw=null)
Definition: CoreParserFunctions.php:546
wfMessage
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 unset offset - wrap String Wrap the message in html(usually something like "&lt
CoreParserFunctions\numberofusers
static numberofusers( $parser, $raw=null)
Definition: CoreParserFunctions.php:512
$t
$t
Definition: testCompression.php:67
CoreParserFunctions\pagesincategory
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.
Definition: CoreParserFunctions.php:729
$wgAllowSlowParserFunctions
$wgAllowSlowParserFunctions
Enable slow parser functions.
Definition: DefaultSettings.php:2164
MediaWikiServices
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
CoreParserFunctions\numberoffiles
static numberoffiles( $parser, $raw=null)
Definition: CoreParserFunctions.php:523
CoreParserFunctions\pagesinnamespace
static pagesinnamespace( $parser, $namespace=0, $raw=null)
Definition: CoreParserFunctions.php:539
CoreParserFunctions\formatnum
static formatnum( $parser, $num='', $arg=null)
Definition: CoreParserFunctions.php:299
CoreParserFunctions\lcfirst
static lcfirst( $parser, $s='')
Definition: CoreParserFunctions.php:199
CoreParserFunctions\canonicalurl
static canonicalurl( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:255
$username
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:783
MWTimestamp\getLocalInstance
static getLocalInstance( $ts=false)
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
Definition: MWTimestamp.php:204
SiteStats\edits
static edits()
Definition: SiteStats.php:136
CoreParserFunctions\intFunction
static intFunction( $parser, $part1='')
Definition: CoreParserFunctions.php:96
CoreParserFunctions\basepagename
static basepagename( $parser, $title=null)
Definition: CoreParserFunctions.php:676
CoreParserFunctions\canonicalurle
static canonicalurle( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:259
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:552
$wgContLang
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 content language as $wgContLang
Definition: design.txt:56
CoreParserFunctions\localurl
static localurl( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:229
CoreParserFunctions\talkpagenamee
static talkpagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:697