MediaWiki REL1_31
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' ],
67 Parser::SFH_NO_HASH
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
76 $parser->setFunctionHook(
77 'displaytitle',
78 [ __CLASS__, 'displaytitle' ],
79 Parser::SFH_NO_HASH
80 );
81 }
83 $parser->setFunctionHook(
84 'pagesinnamespace',
85 [ __CLASS__, 'pagesinnamespace' ],
86 Parser::SFH_NO_HASH
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 ) {
268 $title = Title::newFromText( $s );
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" ).
341 $title = Title::newFromText( $username, NS_USER );
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
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
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 ) {
563 $t = Title::newFromText( $title );
564 if ( is_null( $t ) ) {
565 return '';
566 }
567 return str_replace( '_', ' ', $t->getNsText() );
568 }
569 public static function namespacee( $parser, $title = null ) {
570 $t = Title::newFromText( $title );
571 if ( is_null( $t ) ) {
572 return '';
573 }
574 return wfUrlencode( $t->getNsText() );
575 }
576 public static function namespacenumber( $parser, $title = null ) {
577 $t = Title::newFromText( $title );
578 if ( is_null( $t ) ) {
579 return '';
580 }
581 return $t->getNamespace();
582 }
583 public static function talkspace( $parser, $title = null ) {
584 $t = Title::newFromText( $title );
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 ) {
591 $t = Title::newFromText( $title );
592 if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
593 return '';
594 }
595 return wfUrlencode( $t->getTalkNsText() );
596 }
597 public static function subjectspace( $parser, $title = null ) {
598 $t = Title::newFromText( $title );
599 if ( is_null( $t ) ) {
600 return '';
601 }
602 return str_replace( '_', ' ', $t->getSubjectNsText() );
603 }
604 public static function subjectspacee( $parser, $title = null ) {
605 $t = Title::newFromText( $title );
606 if ( is_null( $t ) ) {
607 return '';
608 }
609 return wfUrlencode( $t->getSubjectNsText() );
610 }
611
619 public static function pagename( $parser, $title = null ) {
620 $t = Title::newFromText( $title );
621 if ( is_null( $t ) ) {
622 return '';
623 }
624 return wfEscapeWikiText( $t->getText() );
625 }
626 public static function pagenamee( $parser, $title = null ) {
627 $t = Title::newFromText( $title );
628 if ( is_null( $t ) ) {
629 return '';
630 }
631 return wfEscapeWikiText( $t->getPartialURL() );
632 }
633 public static function fullpagename( $parser, $title = null ) {
634 $t = Title::newFromText( $title );
635 if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
636 return '';
637 }
638 return wfEscapeWikiText( $t->getPrefixedText() );
639 }
640 public static function fullpagenamee( $parser, $title = null ) {
641 $t = Title::newFromText( $title );
642 if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
643 return '';
644 }
645 return wfEscapeWikiText( $t->getPrefixedURL() );
646 }
647 public static function subpagename( $parser, $title = null ) {
648 $t = Title::newFromText( $title );
649 if ( is_null( $t ) ) {
650 return '';
651 }
652 return wfEscapeWikiText( $t->getSubpageText() );
653 }
654 public static function subpagenamee( $parser, $title = null ) {
655 $t = Title::newFromText( $title );
656 if ( is_null( $t ) ) {
657 return '';
658 }
659 return wfEscapeWikiText( $t->getSubpageUrlForm() );
660 }
661 public static function rootpagename( $parser, $title = null ) {
662 $t = Title::newFromText( $title );
663 if ( is_null( $t ) ) {
664 return '';
665 }
666 return wfEscapeWikiText( $t->getRootText() );
667 }
668 public static function rootpagenamee( $parser, $title = null ) {
669 $t = Title::newFromText( $title );
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 ) {
676 $t = Title::newFromText( $title );
677 if ( is_null( $t ) ) {
678 return '';
679 }
680 return wfEscapeWikiText( $t->getBaseText() );
681 }
682 public static function basepagenamee( $parser, $title = null ) {
683 $t = Title::newFromText( $title );
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 ) {
690 $t = Title::newFromText( $title );
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 ) {
697 $t = Title::newFromText( $title );
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 ) {
704 $t = Title::newFromText( $title );
705 if ( is_null( $t ) ) {
706 return '';
707 }
708 return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() );
709 }
710 public static function subjectpagenamee( $parser, $title = null ) {
711 $t = Title::newFromText( $title );
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 ) ) {
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
755 $title = Title::makeTitleSafe( NS_CATEGORY, $name );
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
949 $title = Title::makeTitleSafe( NS_SPECIAL, $text );
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 ) {
1149 $t = Title::newFromText( $title );
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 ) {
1194 $t = Title::newFromText( $title );
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 ) {
1211 $t = Title::newFromText( $title );
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 ) {
1228 $t = Title::newFromText( $title );
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 ) {
1245 $t = Title::newFromText( $title );
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 ) {
1262 $t = Title::newFromText( $title );
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 ) {
1279 $t = Title::newFromText( $title );
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 ) {
1296 $t = Title::newFromText( $title );
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 ) {
1313 $t = Title::newFromText( $title );
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}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgAllowDisplayTitle
Allow DISPLAYTITLE to change title display.
$wgRestrictDisplayTitle
For consistency, restrict DISPLAYTITLE to text that normalizes to the same canonical DB key.
$wgAllowSlowParserFunctions
Enable slow parser functions.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfFindFile( $title, $options=[])
Find a file.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
if( $line===false) $args
Definition cdb.php:64
Various core parser functions, registered in Parser::firstCallInit()
static language( $parser, $code='', $inLanguage='')
Gives language names.
static numberingroup( $parser, $name='', $raw=null)
static rootpagename( $parser, $title=null)
static localurl( $parser, $s='', $arg=null)
static formatnum( $parser, $num='', $arg=null)
static ns( $parser, $part1='')
static protectionexpiry( $parser, $type='', $title='')
Returns the requested protection expiry for the current page.
static pagenamee( $parser, $title=null)
static padleft( $parser, $string='', $length=0, $padding='0')
static fullurle( $parser, $s='', $arg=null)
static revisionmonth( $parser, $title=null)
Get the month with leading zeros from the last revision of a specified page.
static fullpagename( $parser, $title=null)
static revisionid( $parser, $title=null)
Get the id from the last revision of a specified page.
static intFunction( $parser, $part1='')
static pagesinnamespace( $parser, $namespace=0, $raw=null)
static numberofusers( $parser, $raw=null)
static pagesincategory( $parser, $name='', $arg1=null, $arg2=null)
Return the number of pages, files or subcats in the given category, or 0 if it's nonexistent.
static special( $parser, $text)
static nse( $parser, $part1='')
static pagesize( $parser, $page='', $raw=null)
Return the size of the given page, or 0 if it's nonexistent.
static canonicalurl( $parser, $s='', $arg=null)
static basepagenamee( $parser, $title=null)
static subjectspacee( $parser, $title=null)
static numberofedits( $parser, $raw=null)
static numberoffiles( $parser, $raw=null)
static ucfirst( $parser, $s='')
static basepagename( $parser, $title=null)
static numberofpages( $parser, $raw=null)
static lcfirst( $parser, $s='')
static urlFunction( $func, $s='', $arg=null)
static talkspacee( $parser, $title=null)
static bidi( $parser, $text='')
static revisionuser( $parser, $title=null)
Get the user from the last revision of a specified page.
static anchorencode( $parser, $text)
static subjectpagenamee( $parser, $title=null)
static namespacee( $parser, $title=null)
static subjectpagename( $parser, $title=null)
static filepath( $parser, $name='', $argA='', $argB='')
Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}} or {{...
static padright( $parser, $string='', $length=0, $padding='0')
static pad( $parser, $string, $length, $padding='0', $direction=STR_PAD_RIGHT)
Unicode-safe str_pad with the restriction that $length is forced to be <= 500.
static canonicalurle( $parser, $s='', $arg=null)
static cascadingsources( $parser, $title='')
Returns the sources of any cascading protection acting on a specified page.
static numberofactiveusers( $parser, $raw=null)
static plural( $parser, $text='')
static displaytitle( $parser, $text='', $uarg='')
Override the title of the page when viewed, provided we've been given a title which will normalise to...
static pageid( $parser, $title=null)
Get the pageid of a specified page.
static formatDate( $parser, $date, $defaultPref=null)
static gender( $parser, $username)
static urlencode( $parser, $s='', $arg=null)
urlencodes a string according to one of three patterns: (T24474)
static grammar( $parser, $case='', $word='')
static subpagenamee( $parser, $title=null)
static tagObj( $parser, $frame, $args)
Parser function to extension tag adaptor.
static revisionmonth1( $parser, $title=null)
Get the month from the last revision of a specified page.
static rootpagenamee( $parser, $title=null)
static protectionlevel( $parser, $type='', $title='')
Returns the requested protection level for the current page.
static namespacenumber( $parser, $title=null)
static revisionday( $parser, $title=null)
Get the day from the last revision of a specified page.
static subjectspace( $parser, $title=null)
static lc( $parser, $s='')
static talkpagename( $parser, $title=null)
static fullurl( $parser, $s='', $arg=null)
static mwnamespace( $parser, $title=null)
Given a title, return the namespace name that would be given by the corresponding magic word Note: fu...
static pagename( $parser, $title=null)
Functions to get and normalize pagenames, corresponding to the magic words of the same names.
static getCachedRevisionObject( $parser, $title=null)
Fetched the current revision of the given title and return this.
static matchAgainstMagicword( $magicword, $value)
Matches the given value against the value of given magic word.
static numberofadmins( $parser, $raw=null)
static numberofarticles( $parser, $raw=null)
static revisionyear( $parser, $title=null)
Get the year from the last revision of a specified page.
static revisionday2( $parser, $title=null)
Get the day with leading zeros from the last revision of a specified page.
static uc( $parser, $s='')
static talkpagenamee( $parser, $title=null)
static revisiontimestamp( $parser, $title=null)
Get the timestamp from the last revision of a specified page.
static subpagename( $parser, $title=null)
static localurle( $parser, $s='', $arg=null)
static defaultsort( $parser, $text, $uarg='')
static fullpagenamee( $parser, $title=null)
static talkspace( $parser, $title=null)
static formatRaw( $num, $raw, $language)
Formats a number according to a language.
static speciale( $parser, $text)
static getInstance( $lang=null)
Get a DateFormatter object.
Class for handling an array of magic words.
static & get( $id)
Factory: creates an object representing an ID.
MediaWikiServices is the service locator for the application scope of MediaWiki.
doQuotes( $text)
Helper function for doAllQuotes()
Definition Parser.php:1658
static articles()
static pagesInNs( $ns)
static images()
static edits()
Definition SiteStats.php:94
static users()
static pages()
static numberingroup( $group)
Find the number of users in a given user group.
static activeUsers()
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
Represents a title within MediaWiki.
Definition Title.php:39
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:591
static getDefaultOption( $opt)
Get a given default option value.
Definition User.php:1762
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
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition design.txt:57
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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:18
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
const NS_USER
Definition Defines.php:76
const NS_FILE
Definition Defines.php:80
const NS_SPECIAL
Definition Defines.php:63
const NS_MEDIA
Definition Defines.php:62
const PROTO_RELATIVE
Definition Defines.php:231
const NS_CATEGORY
Definition Defines.php:88
do that in ParserLimitReportFormat instead $parser
Definition hooks.txt:2603
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:181
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:865
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
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;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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:2006
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:2005
this hook is for auditing only or null if authentication failed before getting that far $username
Definition hooks.txt:785
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
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:3022
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:1777
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:247
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:37
const STRIP_COMMENTS
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
$cache
Definition mcc.php:33
title
$params
if(!isset( $args[0])) $lang