MediaWiki  1.31.0
CoreParserFunctions.php
Go to the documentation of this file.
1 <?php
24 
34  public static function register( $parser ) {
36 
37  # Syntax for arguments (see Parser::setFunctionHook):
38  # "name for lookup in localized magic words array",
39  # function callback,
40  # optional Parser::SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}}
41  # instead of {{#int:...}})
42  $noHashFunctions = [
43  'ns', 'nse', 'urlencode', 'lcfirst', 'ucfirst', 'lc', 'uc',
44  'localurl', 'localurle', 'fullurl', 'fullurle', 'canonicalurl',
45  'canonicalurle', 'formatnum', 'grammar', 'gender', 'plural', 'bidi',
46  'numberofpages', 'numberofusers', 'numberofactiveusers',
47  'numberofarticles', 'numberoffiles', 'numberofadmins',
48  'numberingroup', 'numberofedits', 'language',
49  'padleft', 'padright', 'anchorencode', 'defaultsort', 'filepath',
50  'pagesincategory', 'pagesize', 'protectionlevel', 'protectionexpiry',
51  'namespacee', 'namespacenumber', 'talkspace', 'talkspacee',
52  'subjectspace', 'subjectspacee', 'pagename', 'pagenamee',
53  'fullpagename', 'fullpagenamee', 'rootpagename', 'rootpagenamee',
54  'basepagename', 'basepagenamee', 'subpagename', 'subpagenamee',
55  'talkpagename', 'talkpagenamee', 'subjectpagename',
56  'subjectpagenamee', 'pageid', 'revisionid', 'revisionday',
57  'revisionday2', 'revisionmonth', 'revisionmonth1', 'revisionyear',
58  'revisiontimestamp', 'revisionuser', 'cascadingsources',
59  ];
60  foreach ( $noHashFunctions as $func ) {
61  $parser->setFunctionHook( $func, [ __CLASS__, $func ], Parser::SFH_NO_HASH );
62  }
63 
64  $parser->setFunctionHook(
65  'namespace',
66  [ __CLASS__, 'mwnamespace' ],
68  );
69  $parser->setFunctionHook( 'int', [ __CLASS__, 'intFunction' ], Parser::SFH_NO_HASH );
70  $parser->setFunctionHook( 'special', [ __CLASS__, 'special' ] );
71  $parser->setFunctionHook( 'speciale', [ __CLASS__, 'speciale' ] );
72  $parser->setFunctionHook( 'tag', [ __CLASS__, 'tagObj' ], Parser::SFH_OBJECT_ARGS );
73  $parser->setFunctionHook( 'formatdate', [ __CLASS__, 'formatDate' ] );
74 
75  if ( $wgAllowDisplayTitle ) {
76  $parser->setFunctionHook(
77  'displaytitle',
78  [ __CLASS__, 'displaytitle' ],
80  );
81  }
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  // 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->inNamespace( 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 and normalize (e.g. "&#42;foo" -> "*foo" ).
342 
343  if ( $title && $title->inNamespace( NS_USER ) ) {
344  $username = $title->getText();
345  }
346 
347  // check parameter, or use the ParserOptions if in interface message
349  $genderCache = MediaWikiServices::getInstance()->getGenderCache();
350  if ( $user ) {
351  $gender = $genderCache->getGenderOf( $user, __METHOD__ );
352  } elseif ( $username === '' && $parser->getOptions()->getInterfaceMessage() ) {
353  $gender = $genderCache->getGenderOf( $parser->getOptions()->getUser(), __METHOD__ );
354  }
355  $ret = $parser->getFunctionLang()->gender( $gender, $forms );
356  return $ret;
357  }
358 
364  public static function plural( $parser, $text = '' ) {
365  $forms = array_slice( func_get_args(), 2 );
366  $text = $parser->getFunctionLang()->parseFormattedNumber( $text );
367  settype( $text, ctype_digit( $text ) ? 'int' : 'float' );
368  return $parser->getFunctionLang()->convertPlural( $text, $forms );
369  }
370 
376  public static function bidi( $parser, $text = '' ) {
377  return $parser->getFunctionLang()->embedBidi( $text );
378  }
379 
389  public static function displaytitle( $parser, $text = '', $uarg = '' ) {
391 
392  static $magicWords = null;
393  if ( is_null( $magicWords ) ) {
394  $magicWords = new MagicWordArray( [ 'displaytitle_noerror', 'displaytitle_noreplace' ] );
395  }
396  $arg = $magicWords->matchStartToEnd( $uarg );
397 
398  // parse a limited subset of wiki markup (just the single quote items)
399  $text = $parser->doQuotes( $text );
400 
401  // remove stripped text (e.g. the UNIQ-QINU stuff) that was generated by tag extensions/whatever
402  $text = $parser->killMarkers( $text );
403 
404  // list of disallowed tags for DISPLAYTITLE
405  // these will be escaped even though they are allowed in normal wiki text
406  $bad = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr',
407  'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rtc', 'rp', 'br' ];
408 
409  // disallow some styles that could be used to bypass $wgRestrictDisplayTitle
410  if ( $wgRestrictDisplayTitle ) {
411  $htmlTagsCallback = function ( &$params ) {
412  $decoded = Sanitizer::decodeTagAttributes( $params );
413 
414  if ( isset( $decoded['style'] ) ) {
415  // this is called later anyway, but we need it right now for the regexes below to be safe
416  // calling it twice doesn't hurt
417  $decoded['style'] = Sanitizer::checkCss( $decoded['style'] );
418 
419  if ( preg_match( '/(display|user-select|visibility)\s*:/i', $decoded['style'] ) ) {
420  $decoded['style'] = '/* attempt to bypass $wgRestrictDisplayTitle */';
421  }
422  }
423 
424  $params = Sanitizer::safeEncodeTagAttributes( $decoded );
425  };
426  } else {
427  $htmlTagsCallback = null;
428  }
429 
430  // only requested titles that normalize to the actual title are allowed through
431  // if $wgRestrictDisplayTitle is true (it is by default)
432  // mimic the escaping process that occurs in OutputPage::setPageTitle
433  $text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags(
434  $text,
435  $htmlTagsCallback,
436  [],
437  [],
438  $bad
439  ) );
440  $title = Title::newFromText( Sanitizer::stripAllTags( $text ) );
441 
442  if ( !$wgRestrictDisplayTitle ||
443  ( $title instanceof Title
444  && !$title->hasFragment()
445  && $title->equals( $parser->mTitle ) )
446  ) {
447  $old = $parser->mOutput->getProperty( 'displaytitle' );
448  if ( $old === false || $arg !== 'displaytitle_noreplace' ) {
449  $parser->mOutput->setDisplayTitle( $text );
450  }
451  if ( $old !== false && $old !== $text && !$arg ) {
452  $converter = $parser->getConverterLanguage()->getConverter();
453  return '<span class="error">' .
454  wfMessage( 'duplicate-displaytitle',
455  // Message should be parsed, but these params should only be escaped.
456  $converter->markNoConversion( wfEscapeWikiText( $old ) ),
457  $converter->markNoConversion( wfEscapeWikiText( $text ) )
458  )->inContentLanguage()->text() .
459  '</span>';
460  } else {
461  return '';
462  }
463  } else {
464  $converter = $parser->getConverterLanguage()->getConverter();
465  $parser->getOutput()->addWarning(
466  wfMessage( 'restricted-displaytitle',
467  // Message should be parsed, but this param should only be escaped.
468  $converter->markNoConversion( wfEscapeWikiText( $text ) )
469  )->text()
470  );
471  $parser->addTrackingCategory( 'restricted-displaytitle-ignored' );
472  }
473  }
474 
482  private static function matchAgainstMagicword( $magicword, $value ) {
483  $value = trim( strval( $value ) );
484  if ( $value === '' ) {
485  return false;
486  }
487  $mwObject = MagicWord::get( $magicword );
488  return $mwObject->matchStartToEnd( $value );
489  }
490 
499  public static function formatRaw( $num, $raw, $language ) {
500  if ( self::matchAgainstMagicword( 'rawsuffix', $raw ) ) {
501  return $num;
502  } else {
503  return $language->formatNum( $num );
504  }
505  }
506 
507  public static function numberofpages( $parser, $raw = null ) {
508  return self::formatRaw( SiteStats::pages(), $raw, $parser->getFunctionLang() );
509  }
510 
511  public static function numberofusers( $parser, $raw = null ) {
512  return self::formatRaw( SiteStats::users(), $raw, $parser->getFunctionLang() );
513  }
514  public static function numberofactiveusers( $parser, $raw = null ) {
515  return self::formatRaw( SiteStats::activeUsers(), $raw, $parser->getFunctionLang() );
516  }
517 
518  public static function numberofarticles( $parser, $raw = null ) {
519  return self::formatRaw( SiteStats::articles(), $raw, $parser->getFunctionLang() );
520  }
521 
522  public static function numberoffiles( $parser, $raw = null ) {
523  return self::formatRaw( SiteStats::images(), $raw, $parser->getFunctionLang() );
524  }
525 
526  public static function numberofadmins( $parser, $raw = null ) {
527  return self::formatRaw(
528  SiteStats::numberingroup( 'sysop' ),
529  $raw,
530  $parser->getFunctionLang()
531  );
532  }
533 
534  public static function numberofedits( $parser, $raw = null ) {
535  return self::formatRaw( SiteStats::edits(), $raw, $parser->getFunctionLang() );
536  }
537 
538  public static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) {
539  return self::formatRaw(
540  SiteStats::pagesInNs( intval( $namespace ) ),
541  $raw,
542  $parser->getFunctionLang()
543  );
544  }
545  public static function numberingroup( $parser, $name = '', $raw = null ) {
546  return self::formatRaw(
547  SiteStats::numberingroup( strtolower( $name ) ),
548  $raw,
549  $parser->getFunctionLang()
550  );
551  }
552 
562  public static function mwnamespace( $parser, $title = null ) {
564  if ( is_null( $t ) ) {
565  return '';
566  }
567  return str_replace( '_', ' ', $t->getNsText() );
568  }
569  public static function namespacee( $parser, $title = null ) {
571  if ( is_null( $t ) ) {
572  return '';
573  }
574  return wfUrlencode( $t->getNsText() );
575  }
576  public static function namespacenumber( $parser, $title = null ) {
578  if ( is_null( $t ) ) {
579  return '';
580  }
581  return $t->getNamespace();
582  }
583  public static function talkspace( $parser, $title = null ) {
585  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
586  return '';
587  }
588  return str_replace( '_', ' ', $t->getTalkNsText() );
589  }
590  public static function talkspacee( $parser, $title = null ) {
592  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
593  return '';
594  }
595  return wfUrlencode( $t->getTalkNsText() );
596  }
597  public static function subjectspace( $parser, $title = null ) {
599  if ( is_null( $t ) ) {
600  return '';
601  }
602  return str_replace( '_', ' ', $t->getSubjectNsText() );
603  }
604  public static function subjectspacee( $parser, $title = null ) {
606  if ( is_null( $t ) ) {
607  return '';
608  }
609  return wfUrlencode( $t->getSubjectNsText() );
610  }
611 
619  public static function pagename( $parser, $title = null ) {
621  if ( is_null( $t ) ) {
622  return '';
623  }
624  return wfEscapeWikiText( $t->getText() );
625  }
626  public static function pagenamee( $parser, $title = null ) {
628  if ( is_null( $t ) ) {
629  return '';
630  }
631  return wfEscapeWikiText( $t->getPartialURL() );
632  }
633  public static function fullpagename( $parser, $title = null ) {
635  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
636  return '';
637  }
638  return wfEscapeWikiText( $t->getPrefixedText() );
639  }
640  public static function fullpagenamee( $parser, $title = null ) {
642  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
643  return '';
644  }
645  return wfEscapeWikiText( $t->getPrefixedURL() );
646  }
647  public static function subpagename( $parser, $title = null ) {
649  if ( is_null( $t ) ) {
650  return '';
651  }
652  return wfEscapeWikiText( $t->getSubpageText() );
653  }
654  public static function subpagenamee( $parser, $title = null ) {
656  if ( is_null( $t ) ) {
657  return '';
658  }
659  return wfEscapeWikiText( $t->getSubpageUrlForm() );
660  }
661  public static function rootpagename( $parser, $title = null ) {
663  if ( is_null( $t ) ) {
664  return '';
665  }
666  return wfEscapeWikiText( $t->getRootText() );
667  }
668  public static function rootpagenamee( $parser, $title = null ) {
670  if ( is_null( $t ) ) {
671  return '';
672  }
673  return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getRootText() ) ) );
674  }
675  public static function basepagename( $parser, $title = null ) {
677  if ( is_null( $t ) ) {
678  return '';
679  }
680  return wfEscapeWikiText( $t->getBaseText() );
681  }
682  public static function basepagenamee( $parser, $title = null ) {
684  if ( is_null( $t ) ) {
685  return '';
686  }
687  return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getBaseText() ) ) );
688  }
689  public static function talkpagename( $parser, $title = null ) {
691  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
692  return '';
693  }
694  return wfEscapeWikiText( $t->getTalkPage()->getPrefixedText() );
695  }
696  public static function talkpagenamee( $parser, $title = null ) {
698  if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
699  return '';
700  }
701  return wfEscapeWikiText( $t->getTalkPage()->getPrefixedURL() );
702  }
703  public static function subjectpagename( $parser, $title = null ) {
705  if ( is_null( $t ) ) {
706  return '';
707  }
708  return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() );
709  }
710  public static function subjectpagenamee( $parser, $title = null ) {
712  if ( is_null( $t ) ) {
713  return '';
714  }
715  return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedURL() );
716  }
717 
728  public static function pagesincategory( $parser, $name = '', $arg1 = null, $arg2 = null ) {
730  static $magicWords = null;
731  if ( is_null( $magicWords ) ) {
732  $magicWords = new MagicWordArray( [
733  'pagesincategory_all',
734  'pagesincategory_pages',
735  'pagesincategory_subcats',
736  'pagesincategory_files'
737  ] );
738  }
739  static $cache = [];
740 
741  // split the given option to its variable
742  if ( self::matchAgainstMagicword( 'rawsuffix', $arg1 ) ) {
743  // {{pagesincategory:|raw[|type]}}
744  $raw = $arg1;
745  $type = $magicWords->matchStartToEnd( $arg2 );
746  } else {
747  // {{pagesincategory:[|type[|raw]]}}
748  $type = $magicWords->matchStartToEnd( $arg1 );
749  $raw = $arg2;
750  }
751  if ( !$type ) { // backward compatibility
752  $type = 'pagesincategory_all';
753  }
754 
756  if ( !$title ) { # invalid title
757  return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
758  }
759  $wgContLang->findVariantLink( $name, $title, true );
760 
761  // Normalize name for cache
762  $name = $title->getDBkey();
763 
764  if ( !isset( $cache[$name] ) ) {
765  $category = Category::newFromTitle( $title );
766 
767  $allCount = $subcatCount = $fileCount = $pagesCount = 0;
768  if ( $parser->incrementExpensiveFunctionCount() ) {
769  // $allCount is the total number of cat members,
770  // not the count of how many members are normal pages.
771  $allCount = (int)$category->getPageCount();
772  $subcatCount = (int)$category->getSubcatCount();
773  $fileCount = (int)$category->getFileCount();
774  $pagesCount = $allCount - $subcatCount - $fileCount;
775  }
776  $cache[$name]['pagesincategory_all'] = $allCount;
777  $cache[$name]['pagesincategory_pages'] = $pagesCount;
778  $cache[$name]['pagesincategory_subcats'] = $subcatCount;
779  $cache[$name]['pagesincategory_files'] = $fileCount;
780  }
781 
782  $count = $cache[$name][$type];
783  return self::formatRaw( $count, $raw, $parser->getFunctionLang() );
784  }
785 
795  public static function pagesize( $parser, $page = '', $raw = null ) {
796  $title = Title::newFromText( $page );
797 
798  if ( !is_object( $title ) ) {
799  return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
800  }
801 
802  // fetch revision from cache/database and return the value
804  $length = $rev ? $rev->getSize() : 0;
805  if ( $length === null ) {
806  // We've had bugs where rev_len was not being recorded for empty pages, see T135414
807  $length = 0;
808  }
809  return self::formatRaw( $length, $raw, $parser->getFunctionLang() );
810  }
811 
824  public static function protectionlevel( $parser, $type = '', $title = '' ) {
825  $titleObject = Title::newFromText( $title );
826  if ( !( $titleObject instanceof Title ) ) {
827  $titleObject = $parser->mTitle;
828  }
829  if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
830  $restrictions = $titleObject->getRestrictions( strtolower( $type ) );
831  # Title::getRestrictions returns an array, its possible it may have
832  # multiple values in the future
833  return implode( ',', $restrictions );
834  }
835  return '';
836  }
837 
850  public static function protectionexpiry( $parser, $type = '', $title = '' ) {
851  $titleObject = Title::newFromText( $title );
852  if ( !( $titleObject instanceof Title ) ) {
853  $titleObject = $parser->mTitle;
854  }
855  if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
856  $expiry = $titleObject->getRestrictionExpiry( strtolower( $type ) );
857  // getRestrictionExpiry() returns false on invalid type; trying to
858  // match protectionlevel() function that returns empty string instead
859  if ( $expiry === false ) {
860  $expiry = '';
861  }
862  return $expiry;
863  }
864  return '';
865  }
866 
874  public static function language( $parser, $code = '', $inLanguage = '' ) {
875  $code = strtolower( $code );
876  $inLanguage = strtolower( $inLanguage );
877  $lang = Language::fetchLanguageName( $code, $inLanguage );
878  return $lang !== '' ? $lang : LanguageCode::bcp47( $code );
879  }
880 
890  public static function pad(
891  $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT
892  ) {
893  $padding = $parser->killMarkers( $padding );
894  $lengthOfPadding = mb_strlen( $padding );
895  if ( $lengthOfPadding == 0 ) {
896  return $string;
897  }
898 
899  # The remaining length to add counts down to 0 as padding is added
900  $length = min( (int)$length, 500 ) - mb_strlen( $string );
901  if ( $length <= 0 ) {
902  // Nothing to add
903  return $string;
904  }
905 
906  # $finalPadding is just $padding repeated enough times so that
907  # mb_strlen( $string ) + mb_strlen( $finalPadding ) == $length
908  $finalPadding = '';
909  while ( $length > 0 ) {
910  # If $length < $lengthofPadding, truncate $padding so we get the
911  # exact length desired.
912  $finalPadding .= mb_substr( $padding, 0, $length );
913  $length -= $lengthOfPadding;
914  }
915 
916  if ( $direction == STR_PAD_LEFT ) {
917  return $finalPadding . $string;
918  } else {
919  return $string . $finalPadding;
920  }
921  }
922 
923  public static function padleft( $parser, $string = '', $length = 0, $padding = '0' ) {
924  return self::pad( $parser, $string, $length, $padding, STR_PAD_LEFT );
925  }
926 
927  public static function padright( $parser, $string = '', $length = 0, $padding = '0' ) {
928  return self::pad( $parser, $string, $length, $padding );
929  }
930 
936  public static function anchorencode( $parser, $text ) {
937  $text = $parser->killMarkers( $text );
938  $section = (string)substr( $parser->guessSectionNameFromWikiText( $text ), 1 );
939  return Sanitizer::safeEncodeAttribute( $section );
940  }
941 
942  public static function special( $parser, $text ) {
943  list( $page, $subpage ) = SpecialPageFactory::resolveAlias( $text );
944  if ( $page ) {
945  $title = SpecialPage::getTitleFor( $page, $subpage );
946  return $title->getPrefixedText();
947  } else {
948  // unknown special page, just use the given text as its title, if at all possible
950  return $title ? $title->getPrefixedText() : self::special( $parser, 'Badtitle' );
951  }
952  }
953 
954  public static function speciale( $parser, $text ) {
955  return wfUrlencode( str_replace( ' ', '_', self::special( $parser, $text ) ) );
956  }
957 
966  public static function defaultsort( $parser, $text, $uarg = '' ) {
967  static $magicWords = null;
968  if ( is_null( $magicWords ) ) {
969  $magicWords = new MagicWordArray( [ 'defaultsort_noerror', 'defaultsort_noreplace' ] );
970  }
971  $arg = $magicWords->matchStartToEnd( $uarg );
972 
973  $text = trim( $text );
974  if ( strlen( $text ) == 0 ) {
975  return '';
976  }
977  $old = $parser->getCustomDefaultSort();
978  if ( $old === false || $arg !== 'defaultsort_noreplace' ) {
979  $parser->setDefaultSort( $text );
980  }
981 
982  if ( $old === false || $old == $text || $arg ) {
983  return '';
984  } else {
985  $converter = $parser->getConverterLanguage()->getConverter();
986  return '<span class="error">' .
987  wfMessage( 'duplicate-defaultsort',
988  // Message should be parsed, but these params should only be escaped.
989  $converter->markNoConversion( wfEscapeWikiText( $old ) ),
990  $converter->markNoConversion( wfEscapeWikiText( $text ) )
991  )->inContentLanguage()->text() .
992  '</span>';
993  }
994  }
995 
1007  public static function filepath( $parser, $name = '', $argA = '', $argB = '' ) {
1008  $file = wfFindFile( $name );
1009 
1010  if ( $argA == 'nowiki' ) {
1011  // {{filepath: | option [| size] }}
1012  $isNowiki = true;
1013  $parsedWidthParam = Parser::parseWidthParam( $argB );
1014  } else {
1015  // {{filepath: [| size [|option]] }}
1016  $parsedWidthParam = Parser::parseWidthParam( $argA );
1017  $isNowiki = ( $argB == 'nowiki' );
1018  }
1019 
1020  if ( $file ) {
1021  $url = $file->getFullUrl();
1022 
1023  // If a size is requested...
1024  if ( count( $parsedWidthParam ) ) {
1025  $mto = $file->transform( $parsedWidthParam );
1026  // ... and we can
1027  if ( $mto && !$mto->isError() ) {
1028  // ... change the URL to point to a thumbnail.
1029  $url = wfExpandUrl( $mto->getUrl(), PROTO_RELATIVE );
1030  }
1031  }
1032  if ( $isNowiki ) {
1033  return [ $url, 'nowiki' => true ];
1034  }
1035  return $url;
1036  } else {
1037  return '';
1038  }
1039  }
1040 
1048  public static function tagObj( $parser, $frame, $args ) {
1049  if ( !count( $args ) ) {
1050  return '';
1051  }
1052  $tagName = strtolower( trim( $frame->expand( array_shift( $args ) ) ) );
1053 
1054  if ( count( $args ) ) {
1055  $inner = $frame->expand( array_shift( $args ) );
1056  } else {
1057  $inner = null;
1058  }
1059 
1060  $attributes = [];
1061  foreach ( $args as $arg ) {
1062  $bits = $arg->splitArg();
1063  if ( strval( $bits['index'] ) === '' ) {
1064  $name = trim( $frame->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
1065  $value = trim( $frame->expand( $bits['value'] ) );
1066  if ( preg_match( '/^(?:["\'](.+)["\']|""|\'\')$/s', $value, $m ) ) {
1067  $value = isset( $m[1] ) ? $m[1] : '';
1068  }
1069  $attributes[$name] = $value;
1070  }
1071  }
1072 
1073  $stripList = $parser->getStripList();
1074  if ( !in_array( $tagName, $stripList ) ) {
1075  // we can't handle this tag (at least not now), so just re-emit it as an ordinary tag
1076  $attrText = '';
1077  foreach ( $attributes as $name => $value ) {
1078  $attrText .= ' ' . htmlspecialchars( $name ) . '="' . htmlspecialchars( $value ) . '"';
1079  }
1080  if ( $inner === null ) {
1081  return "<$tagName$attrText/>";
1082  }
1083  return "<$tagName$attrText>$inner</$tagName>";
1084  }
1085 
1086  $params = [
1087  'name' => $tagName,
1088  'inner' => $inner,
1089  'attributes' => $attributes,
1090  'close' => "</$tagName>",
1091  ];
1092  return $parser->extensionSubstitution( $params, $frame );
1093  }
1094 
1107  private static function getCachedRevisionObject( $parser, $title = null ) {
1108  if ( is_null( $title ) ) {
1109  return null;
1110  }
1111 
1112  // Use the revision from the parser itself, when param is the current page
1113  // and the revision is the current one
1114  if ( $title->equals( $parser->getTitle() ) ) {
1115  $parserRev = $parser->getRevisionObject();
1116  if ( $parserRev && $parserRev->isCurrent() ) {
1117  // force reparse after edit with vary-revision flag
1118  $parser->getOutput()->setFlag( 'vary-revision' );
1119  wfDebug( __METHOD__ . ": use current revision from parser, setting vary-revision...\n" );
1120  return $parserRev;
1121  }
1122  }
1123 
1124  // Normalize name for cache
1125  $page = $title->getPrefixedDBkey();
1126 
1127  if ( !( $parser->currentRevisionCache && $parser->currentRevisionCache->has( $page ) )
1128  && !$parser->incrementExpensiveFunctionCount() ) {
1129  return null;
1130  }
1131  $rev = $parser->fetchCurrentRevisionOfTitle( $title );
1132  $pageID = $rev ? $rev->getPage() : 0;
1133  $revID = $rev ? $rev->getId() : 0;
1134 
1135  // Register dependency in templatelinks
1136  $parser->getOutput()->addTemplate( $title, $pageID, $revID );
1137 
1138  return $rev;
1139  }
1140 
1148  public static function pageid( $parser, $title = null ) {
1150  if ( is_null( $t ) ) {
1151  return '';
1152  }
1153  // Use title from parser to have correct pageid after edit
1154  if ( $t->equals( $parser->getTitle() ) ) {
1155  $t = $parser->getTitle();
1156  return $t->getArticleID();
1157  }
1158 
1159  // These can't have ids
1160  if ( !$t->canExist() || $t->isExternal() ) {
1161  return 0;
1162  }
1163 
1164  // Check the link cache, maybe something already looked it up.
1165  $linkCache = LinkCache::singleton();
1166  $pdbk = $t->getPrefixedDBkey();
1167  $id = $linkCache->getGoodLinkID( $pdbk );
1168  if ( $id != 0 ) {
1169  $parser->mOutput->addLink( $t, $id );
1170  return $id;
1171  }
1172  if ( $linkCache->isBadLink( $pdbk ) ) {
1173  $parser->mOutput->addLink( $t, 0 );
1174  return $id;
1175  }
1176 
1177  // We need to load it from the DB, so mark expensive
1178  if ( $parser->incrementExpensiveFunctionCount() ) {
1179  $id = $t->getArticleID();
1180  $parser->mOutput->addLink( $t, $id );
1181  return $id;
1182  }
1183  return null;
1184  }
1185 
1193  public static function revisionid( $parser, $title = null ) {
1195  if ( is_null( $t ) ) {
1196  return '';
1197  }
1198  // fetch revision from cache/database and return the value
1200  return $rev ? $rev->getId() : '';
1201  }
1202 
1210  public static function revisionday( $parser, $title = null ) {
1212  if ( is_null( $t ) ) {
1213  return '';
1214  }
1215  // fetch revision from cache/database and return the value
1217  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'j' ) : '';
1218  }
1219 
1227  public static function revisionday2( $parser, $title = null ) {
1229  if ( is_null( $t ) ) {
1230  return '';
1231  }
1232  // fetch revision from cache/database and return the value
1234  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'd' ) : '';
1235  }
1236 
1244  public static function revisionmonth( $parser, $title = null ) {
1246  if ( is_null( $t ) ) {
1247  return '';
1248  }
1249  // fetch revision from cache/database and return the value
1251  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'm' ) : '';
1252  }
1253 
1261  public static function revisionmonth1( $parser, $title = null ) {
1263  if ( is_null( $t ) ) {
1264  return '';
1265  }
1266  // fetch revision from cache/database and return the value
1268  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'n' ) : '';
1269  }
1270 
1278  public static function revisionyear( $parser, $title = null ) {
1280  if ( is_null( $t ) ) {
1281  return '';
1282  }
1283  // fetch revision from cache/database and return the value
1285  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'Y' ) : '';
1286  }
1287 
1295  public static function revisiontimestamp( $parser, $title = null ) {
1297  if ( is_null( $t ) ) {
1298  return '';
1299  }
1300  // fetch revision from cache/database and return the value
1302  return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'YmdHis' ) : '';
1303  }
1304 
1312  public static function revisionuser( $parser, $title = null ) {
1314  if ( is_null( $t ) ) {
1315  return '';
1316  }
1317  // fetch revision from cache/database and return the value
1319  return $rev ? $rev->getUserText() : '';
1320  }
1321 
1334  public static function cascadingsources( $parser, $title = '' ) {
1335  $titleObject = Title::newFromText( $title );
1336  if ( !( $titleObject instanceof Title ) ) {
1337  $titleObject = $parser->mTitle;
1338  }
1339  if ( $titleObject->areCascadeProtectionSourcesLoaded()
1340  || $parser->incrementExpensiveFunctionCount()
1341  ) {
1342  $names = [];
1343  $sources = $titleObject->getCascadeProtectionSources();
1344  foreach ( $sources[0] as $sourceTitle ) {
1345  $names[] = $sourceTitle->getPrefixedText();
1346  }
1347  return implode( '|', $names );
1348  }
1349  return '';
1350  }
1351 
1352 }
User\getDefaultOption
static getDefaultOption( $opt)
Get a given default option value.
Definition: User.php:1762
CoreParserFunctions\protectionexpiry
static protectionexpiry( $parser, $type='', $title='')
Returns the requested protection expiry for the current page.
Definition: CoreParserFunctions.php:850
SiteStats\articles
static articles()
Definition: SiteStats.php:103
MagicWordArray
Class for handling an array of magic words.
Definition: MagicWordArray.php:31
$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:244
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:273
PPFrame\STRIP_COMMENTS
const STRIP_COMMENTS
Definition: Preprocessor.php:169
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:389
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
SiteStats\users
static users()
Definition: SiteStats.php:121
CoreParserFunctions\matchAgainstMagicword
static matchAgainstMagicword( $magicword, $value)
Matches the given value against the value of given magic word.
Definition: CoreParserFunctions.php:482
SiteStats\activeUsers
static activeUsers()
Definition: SiteStats.php:130
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:890
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
CoreParserFunctions\numberofactiveusers
static numberofactiveusers( $parser, $raw=null)
Definition: CoreParserFunctions.php:514
CoreParserFunctions\pageid
static pageid( $parser, $title=null)
Get the pageid of a specified page.
Definition: CoreParserFunctions.php:1148
captcha-old.count
count
Definition: captcha-old.py:249
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:689
CoreParserFunctions\rootpagename
static rootpagename( $parser, $title=null)
Definition: CoreParserFunctions.php:661
CoreParserFunctions\tagObj
static tagObj( $parser, $frame, $args)
Parser function to extension tag adaptor.
Definition: CoreParserFunctions.php:1048
CoreParserFunctions\pagesize
static pagesize( $parser, $page='', $raw=null)
Return the size of the given page, or 0 if it's nonexistent.
Definition: CoreParserFunctions.php:795
SiteStats\pages
static pages()
Definition: SiteStats.php:112
CoreParserFunctions\rootpagenamee
static rootpagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:668
CoreParserFunctions\protectionlevel
static protectionlevel( $parser, $type='', $title='')
Returns the requested protection level for the current page.
Definition: CoreParserFunctions.php:824
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:340
SiteStats\numberingroup
static numberingroup( $group)
Find the number of users in a given user group.
Definition: SiteStats.php:150
SFH_OBJECT_ARGS
const SFH_OBJECT_ARGS
Definition: Defines.php:199
MagicWord\get
static & get( $id)
Factory: creates an object representing an ID.
Definition: MagicWord.php:277
CoreParserFunctions\nse
static nse( $parser, $part1='')
Definition: CoreParserFunctions.php:151
NS_FILE
const NS_FILE
Definition: Defines.php:71
$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:1261
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:591
$s
$s
Definition: mergeMessageFileList.php:187
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:302
CoreParserFunctions\namespacenumber
static namespacenumber( $parser, $title=null)
Definition: CoreParserFunctions.php:576
CoreParserFunctions\talkspace
static talkspace( $parser, $title=null)
Definition: CoreParserFunctions.php:583
CoreParserFunctions\grammar
static grammar( $parser, $case='', $word='')
Definition: CoreParserFunctions.php:315
CoreParserFunctions\formatRaw
static formatRaw( $num, $raw, $language)
Formats a number according to a language.
Definition: CoreParserFunctions.php:499
CoreParserFunctions\defaultsort
static defaultsort( $parser, $text, $uarg='')
Definition: CoreParserFunctions.php:966
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:1210
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:619
SiteStats\images
static images()
Definition: SiteStats.php:139
CoreParserFunctions\revisionid
static revisionid( $parser, $title=null)
Get the id from the last revision of a specified page.
Definition: CoreParserFunctions.php:1193
CoreParserFunctions\talkspacee
static talkspacee( $parser, $title=null)
Definition: CoreParserFunctions.php:590
CoreParserFunctions\localurle
static localurle( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:232
CoreParserFunctions\getCachedRevisionObject
static getCachedRevisionObject( $parser, $title=null)
Fetched the current revision of the given title and return this.
Definition: CoreParserFunctions.php:1107
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:54
$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:364
CoreParserFunctions\numberofpages
static numberofpages( $parser, $raw=null)
Definition: CoreParserFunctions.php:507
CoreParserFunctions\basepagenamee
static basepagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:682
CoreParserFunctions\revisionyear
static revisionyear( $parser, $title=null)
Get the year from the last revision of a specified page.
Definition: CoreParserFunctions.php:1278
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:562
CoreParserFunctions\fullurle
static fullurle( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:245
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:2595
CoreParserFunctions\numberofedits
static numberofedits( $parser, $raw=null)
Definition: CoreParserFunctions.php:534
CoreParserFunctions\revisionday2
static revisionday2( $parser, $title=null)
Get the day with leading zeros from the last revision of a specified page.
Definition: CoreParserFunctions.php:1227
CoreParserFunctions\fullurl
static fullurl( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:241
CoreParserFunctions\ucfirst
static ucfirst( $parser, $s='')
Definition: CoreParserFunctions.php:203
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:534
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:79
CoreParserFunctions\fullpagenamee
static fullpagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:640
$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:325
CoreParserFunctions\pagenamee
static pagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:626
CoreParserFunctions\ns
static ns( $parser, $part1='')
Definition: CoreParserFunctions.php:137
CoreParserFunctions\subjectpagename
static subjectpagename( $parser, $title=null)
Definition: CoreParserFunctions.php:703
CoreParserFunctions\language
static language( $parser, $code='', $inLanguage='')
Gives language names.
Definition: CoreParserFunctions.php:874
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:982
string
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition: hooks.txt:175
CoreParserFunctions\revisiontimestamp
static revisiontimestamp( $parser, $title=null)
Get the timestamp from the last revision of a specified page.
Definition: CoreParserFunctions.php:1295
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:376
Category\newFromTitle
static newFromTitle( $title)
Factory function.
Definition: Category.php:146
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:562
CoreParserFunctions\fullpagename
static fullpagename( $parser, $title=null)
Definition: CoreParserFunctions.php:633
SiteStats\pagesInNs
static pagesInNs( $ns)
Definition: SiteStats.php:200
$value
$value
Definition: styleTest.css.php:45
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:53
CoreParserFunctions\padleft
static padleft( $parser, $string='', $length=0, $padding='0')
Definition: CoreParserFunctions.php:923
title
title
Definition: parserTests.txt:219
CoreParserFunctions\padright
static padright( $parser, $string='', $length=0, $padding='0')
Definition: CoreParserFunctions.php:927
Title\newFromURL
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
Definition: Title.php:353
CoreParserFunctions\revisionmonth
static revisionmonth( $parser, $title=null)
Get the month with leading zeros from the last revision of a specified page.
Definition: CoreParserFunctions.php:1244
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:328
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1631
PROTO_RELATIVE
const PROTO_RELATIVE
Definition: Defines.php:222
$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:1987
CoreParserFunctions\subjectspacee
static subjectspacee( $parser, $title=null)
Definition: CoreParserFunctions.php:604
CoreParserFunctions\speciale
static speciale( $parser, $text)
Definition: CoreParserFunctions.php:954
Language\fetchLanguageName
static fetchLanguageName( $code, $inLanguage=null, $include='all')
Definition: Language.php:896
CoreParserFunctions\urlFunction
static urlFunction( $func, $s='', $arg=null)
Definition: CoreParserFunctions.php:267
CoreParserFunctions\lc
static lc( $parser, $s='')
Definition: CoreParserFunctions.php:213
CoreParserFunctions\subjectspace
static subjectspace( $parser, $title=null)
Definition: CoreParserFunctions.php:597
CoreParserFunctions\subjectpagenamee
static subjectpagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:710
format
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1649
wfFindFile
wfFindFile( $title, $options=[])
Find a file.
Definition: GlobalFunctions.php:2841
SFH_NO_HASH
const SFH_NO_HASH
Definition: Defines.php:198
$args
if( $line===false) $args
Definition: cdb.php:64
Title
Represents a title within MediaWiki.
Definition: Title.php:39
CoreParserFunctions\numberofadmins
static numberofadmins( $parser, $raw=null)
Definition: CoreParserFunctions.php:526
CoreParserFunctions\cascadingsources
static cascadingsources( $parser, $title='')
Returns the sources of any cascading protection acting on a specified page.
Definition: CoreParserFunctions.php:1334
CoreParserFunctions\anchorencode
static anchorencode( $parser, $text)
Definition: CoreParserFunctions.php:936
$cache
$cache
Definition: mcc.php:33
CoreParserFunctions\uc
static uc( $parser, $s='')
Definition: CoreParserFunctions.php:223
CoreParserFunctions\special
static special( $parser, $text)
Definition: CoreParserFunctions.php:942
$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:654
CoreParserFunctions\filepath
static filepath( $parser, $name='', $argA='', $argB='')
Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}} or {{...
Definition: CoreParserFunctions.php:1007
CoreParserFunctions\namespacee
static namespacee( $parser, $title=null)
Definition: CoreParserFunctions.php:569
CoreParserFunctions\numberofarticles
static numberofarticles( $parser, $raw=null)
Definition: CoreParserFunctions.php:518
LinkCache\singleton
static singleton()
Get an instance of this class.
Definition: LinkCache.php:67
$section
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition: hooks.txt:3005
$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:1767
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
LanguageCode\bcp47
static bcp47( $code)
Get the normalised IETF language tag See unit test for examples.
Definition: LanguageCode.php:94
CoreParserFunctions
Various core parser functions, registered in Parser::firstCallInit()
Definition: CoreParserFunctions.php:29
CoreParserFunctions\subpagename
static subpagename( $parser, $title=null)
Definition: CoreParserFunctions.php:647
NS_USER
const NS_USER
Definition: Defines.php:67
CoreParserFunctions\revisionuser
static revisionuser( $parser, $title=null)
Get the user from the last revision of a specified page.
Definition: CoreParserFunctions.php:1312
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:1987
CoreParserFunctions\numberingroup
static numberingroup( $parser, $name='', $raw=null)
Definition: CoreParserFunctions.php:545
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:511
$t
$t
Definition: testCompression.php:69
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:728
$wgAllowSlowParserFunctions
$wgAllowSlowParserFunctions
Enable slow parser functions.
Definition: DefaultSettings.php:2190
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:522
CoreParserFunctions\pagesinnamespace
static pagesinnamespace( $parser, $namespace=0, $raw=null)
Definition: CoreParserFunctions.php:538
$wgRestrictDisplayTitle
$wgRestrictDisplayTitle
For consistency, restrict DISPLAYTITLE to text that normalizes to the same canonical DB key.
Definition: DefaultSettings.php:4371
$wgAllowDisplayTitle
$wgAllowDisplayTitle
Allow DISPLAYTITLE to change title display.
Definition: DefaultSettings.php:4364
CoreParserFunctions\formatnum
static formatnum( $parser, $num='', $arg=null)
Definition: CoreParserFunctions.php:298
CoreParserFunctions\lcfirst
static lcfirst( $parser, $s='')
Definition: CoreParserFunctions.php:198
CoreParserFunctions\canonicalurl
static canonicalurl( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:254
$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:94
CoreParserFunctions\intFunction
static intFunction( $parser, $part1='')
Definition: CoreParserFunctions.php:96
CoreParserFunctions\basepagename
static basepagename( $parser, $title=null)
Definition: CoreParserFunctions.php:675
CoreParserFunctions\canonicalurle
static canonicalurle( $parser, $s='', $arg=null)
Definition: CoreParserFunctions.php:258
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:521
$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:228
$type
$type
Definition: testCompression.php:48
CoreParserFunctions\talkpagenamee
static talkpagenamee( $parser, $title=null)
Definition: CoreParserFunctions.php:696