MediaWiki REL1_32
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 return [ $message->plain(), 'noparse' => false ];
102 } else {
103 return [ 'found' => false ];
104 }
105 }
106
114 public static function formatDate( $parser, $date, $defaultPref = null ) {
115 $lang = $parser->getFunctionLang();
117
118 $date = trim( $date );
119
120 $pref = $parser->getOptions()->getDateFormat();
121
122 // Specify a different default date format other than the normal default
123 // if the user has 'default' for their setting
124 if ( $pref == 'default' && $defaultPref ) {
125 $pref = $defaultPref;
126 }
127
128 $date = $df->reformat( $pref, $date, [ 'match-whole' ] );
129 return $date;
130 }
131
132 public static function ns( $parser, $part1 = '' ) {
133 if ( intval( $part1 ) || $part1 == "0" ) {
134 $index = intval( $part1 );
135 } else {
136 $index = $parser->getContentLanguage()->getNsIndex( str_replace( ' ', '_', $part1 ) );
137 }
138 if ( $index !== false ) {
139 return $parser->getContentLanguage()->getFormattedNsText( $index );
140 } else {
141 return [ 'found' => false ];
142 }
143 }
144
145 public static function nse( $parser, $part1 = '' ) {
146 $ret = self::ns( $parser, $part1 );
147 if ( is_string( $ret ) ) {
148 $ret = wfUrlencode( str_replace( ' ', '_', $ret ) );
149 }
150 return $ret;
151 }
152
165 public static function urlencode( $parser, $s = '', $arg = null ) {
166 static $magicWords = null;
167 if ( is_null( $magicWords ) ) {
169 $parser->getMagicWordFactory()->newArray( [ 'url_path', 'url_query', 'url_wiki' ] );
170 }
171 switch ( $magicWords->matchStartToEnd( $arg ) ) {
172 // Encode as though it's a wiki page, '_' for ' '.
173 case 'url_wiki':
174 $func = 'wfUrlencode';
175 $s = str_replace( ' ', '_', $s );
176 break;
177
178 // Encode for an HTTP Path, '%20' for ' '.
179 case 'url_path':
180 $func = 'rawurlencode';
181 break;
182
183 // Encode for HTTP query, '+' for ' '.
184 case 'url_query':
185 default:
186 $func = 'urlencode';
187 }
188 // See T105242, where the choice to kill markers and various
189 // other options were discussed.
190 return $func( $parser->killMarkers( $s ) );
191 }
192
193 public static function lcfirst( $parser, $s = '' ) {
194 return $parser->getContentLanguage()->lcfirst( $s );
195 }
196
197 public static function ucfirst( $parser, $s = '' ) {
198 return $parser->getContentLanguage()->ucfirst( $s );
199 }
200
206 public static function lc( $parser, $s = '' ) {
207 return $parser->markerSkipCallback( $s, [ $parser->getContentLanguage(), 'lc' ] );
208 }
209
215 public static function uc( $parser, $s = '' ) {
216 return $parser->markerSkipCallback( $s, [ $parser->getContentLanguage(), 'uc' ] );
217 }
218
219 public static function localurl( $parser, $s = '', $arg = null ) {
220 return self::urlFunction( 'getLocalURL', $s, $arg );
221 }
222
223 public static function localurle( $parser, $s = '', $arg = null ) {
224 $temp = self::urlFunction( 'getLocalURL', $s, $arg );
225 if ( !is_string( $temp ) ) {
226 return $temp;
227 } else {
228 return htmlspecialchars( $temp );
229 }
230 }
231
232 public static function fullurl( $parser, $s = '', $arg = null ) {
233 return self::urlFunction( 'getFullURL', $s, $arg );
234 }
235
236 public static function fullurle( $parser, $s = '', $arg = null ) {
237 $temp = self::urlFunction( 'getFullURL', $s, $arg );
238 if ( !is_string( $temp ) ) {
239 return $temp;
240 } else {
241 return htmlspecialchars( $temp );
242 }
243 }
244
245 public static function canonicalurl( $parser, $s = '', $arg = null ) {
246 return self::urlFunction( 'getCanonicalURL', $s, $arg );
247 }
248
249 public static function canonicalurle( $parser, $s = '', $arg = null ) {
250 $temp = self::urlFunction( 'getCanonicalURL', $s, $arg );
251 if ( !is_string( $temp ) ) {
252 return $temp;
253 } else {
254 return htmlspecialchars( $temp );
255 }
256 }
257
258 public static function urlFunction( $func, $s = '', $arg = null ) {
259 $title = Title::newFromText( $s );
260 # Due to order of execution of a lot of bits, the values might be encoded
261 # before arriving here; if that's true, then the title can't be created
262 # and the variable will fail. If we can't get a decent title from the first
263 # attempt, url-decode and try for a second.
264 if ( is_null( $title ) ) {
265 $title = Title::newFromURL( urldecode( $s ) );
266 }
267 if ( !is_null( $title ) ) {
268 # Convert NS_MEDIA -> NS_FILE
269 if ( $title->inNamespace( NS_MEDIA ) ) {
270 $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
271 }
272 if ( !is_null( $arg ) ) {
273 $text = $title->$func( $arg );
274 } else {
275 $text = $title->$func();
276 }
277 return $text;
278 } else {
279 return [ 'found' => false ];
280 }
281 }
282
289 public static function formatnum( $parser, $num = '', $arg = null ) {
290 if ( self::matchAgainstMagicword( $parser->getMagicWordFactory(), 'rawsuffix', $arg ) ) {
291 $func = [ $parser->getFunctionLang(), 'parseFormattedNumber' ];
292 } elseif (
293 self::matchAgainstMagicword( $parser->getMagicWordFactory(), 'nocommafysuffix', $arg )
294 ) {
295 $func = [ $parser->getFunctionLang(), 'formatNumNoSeparators' ];
296 } else {
297 $func = [ $parser->getFunctionLang(), 'formatNum' ];
298 }
299 return $parser->markerSkipCallback( $num, $func );
300 }
301
308 public static function grammar( $parser, $case = '', $word = '' ) {
309 $word = $parser->killMarkers( $word );
310 return $parser->getFunctionLang()->convertGrammar( $word, $case );
311 }
312
318 public static function gender( $parser, $username ) {
319 $forms = array_slice( func_get_args(), 2 );
320
321 // Some shortcuts to avoid loading user data unnecessarily
322 if ( count( $forms ) === 0 ) {
323 return '';
324 } elseif ( count( $forms ) === 1 ) {
325 return $forms[0];
326 }
327
328 $username = trim( $username );
329
330 // default
331 $gender = User::getDefaultOption( 'gender' );
332
333 // allow prefix and normalize (e.g. "&#42;foo" -> "*foo" ).
334 $title = Title::newFromText( $username, NS_USER );
335
336 if ( $title && $title->inNamespace( NS_USER ) ) {
337 $username = $title->getText();
338 }
339
340 // check parameter, or use the ParserOptions if in interface message
342 $genderCache = MediaWikiServices::getInstance()->getGenderCache();
343 if ( $user ) {
344 $gender = $genderCache->getGenderOf( $user, __METHOD__ );
345 } elseif ( $username === '' && $parser->getOptions()->getInterfaceMessage() ) {
346 $gender = $genderCache->getGenderOf( $parser->getOptions()->getUser(), __METHOD__ );
347 }
348 $ret = $parser->getFunctionLang()->gender( $gender, $forms );
349 return $ret;
350 }
351
357 public static function plural( $parser, $text = '' ) {
358 $forms = array_slice( func_get_args(), 2 );
359 $text = $parser->getFunctionLang()->parseFormattedNumber( $text );
360 settype( $text, ctype_digit( $text ) ? 'int' : 'float' );
361 return $parser->getFunctionLang()->convertPlural( $text, $forms );
362 }
363
369 public static function bidi( $parser, $text = '' ) {
370 return $parser->getFunctionLang()->embedBidi( $text );
371 }
372
382 public static function displaytitle( $parser, $text = '', $uarg = '' ) {
384
385 static $magicWords = null;
386 if ( is_null( $magicWords ) ) {
387 $magicWords = $parser->getMagicWordFactory()->newArray(
388 [ 'displaytitle_noerror', 'displaytitle_noreplace' ] );
389 }
390 $arg = $magicWords->matchStartToEnd( $uarg );
391
392 // parse a limited subset of wiki markup (just the single quote items)
393 $text = $parser->doQuotes( $text );
394
395 // remove stripped text (e.g. the UNIQ-QINU stuff) that was generated by tag extensions/whatever
396 $text = $parser->killMarkers( $text );
397
398 // list of disallowed tags for DISPLAYTITLE
399 // these will be escaped even though they are allowed in normal wiki text
400 $bad = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr',
401 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rtc', 'rp', 'br' ];
402
403 // disallow some styles that could be used to bypass $wgRestrictDisplayTitle
405 $htmlTagsCallback = function ( &$params ) {
406 $decoded = Sanitizer::decodeTagAttributes( $params );
407
408 if ( isset( $decoded['style'] ) ) {
409 // this is called later anyway, but we need it right now for the regexes below to be safe
410 // calling it twice doesn't hurt
411 $decoded['style'] = Sanitizer::checkCss( $decoded['style'] );
412
413 if ( preg_match( '/(display|user-select|visibility)\s*:/i', $decoded['style'] ) ) {
414 $decoded['style'] = '/* attempt to bypass $wgRestrictDisplayTitle */';
415 }
416 }
417
418 $params = Sanitizer::safeEncodeTagAttributes( $decoded );
419 };
420 } else {
421 $htmlTagsCallback = null;
422 }
423
424 // only requested titles that normalize to the actual title are allowed through
425 // if $wgRestrictDisplayTitle is true (it is by default)
426 // mimic the escaping process that occurs in OutputPage::setPageTitle
427 $text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags(
428 $text,
429 $htmlTagsCallback,
430 [],
431 [],
432 $bad
433 ) );
434 $title = Title::newFromText( Sanitizer::stripAllTags( $text ) );
435
437 ( $title instanceof Title
438 && !$title->hasFragment()
439 && $title->equals( $parser->mTitle ) )
440 ) {
441 $old = $parser->mOutput->getProperty( 'displaytitle' );
442 if ( $old === false || $arg !== 'displaytitle_noreplace' ) {
443 $parser->mOutput->setDisplayTitle( $text );
444 }
445 if ( $old !== false && $old !== $text && !$arg ) {
446 $converter = $parser->getTargetLanguage()->getConverter();
447 return '<span class="error">' .
448 wfMessage( 'duplicate-displaytitle',
449 // Message should be parsed, but these params should only be escaped.
450 $converter->markNoConversion( wfEscapeWikiText( $old ) ),
451 $converter->markNoConversion( wfEscapeWikiText( $text ) )
452 )->inContentLanguage()->text() .
453 '</span>';
454 } else {
455 return '';
456 }
457 } else {
458 $converter = $parser->getTargetLanguage()->getConverter();
459 $parser->getOutput()->addWarning(
460 wfMessage( 'restricted-displaytitle',
461 // Message should be parsed, but this param should only be escaped.
462 $converter->markNoConversion( wfEscapeWikiText( $text ) )
463 )->text()
464 );
465 $parser->addTrackingCategory( 'restricted-displaytitle-ignored' );
466 }
467 }
468
478 private static function matchAgainstMagicword(
479 MagicWordFactory $magicWordFactory, $magicword, $value
480 ) {
481 $value = trim( strval( $value ) );
482 if ( $value === '' ) {
483 return false;
484 }
485 $mwObject = $magicWordFactory->get( $magicword );
486 return $mwObject->matchStartToEnd( $value );
487 }
488
498 public static function formatRaw(
499 $num, $raw, $language, MagicWordFactory $magicWordFactory = null
500 ) {
501 if ( $raw !== null && !$magicWordFactory ) {
502 $magicWordFactory = MediaWikiServices::getInstance()->getMagicWordFactory();
503 }
504 if (
505 $raw !== null && self::matchAgainstMagicword( $magicWordFactory, 'rawsuffix', $raw )
506 ) {
507 return $num;
508 } else {
509 return $language->formatNum( $num );
510 }
511 }
512
513 public static function numberofpages( $parser, $raw = null ) {
514 return self::formatRaw( SiteStats::pages(), $raw, $parser->getFunctionLang() );
515 }
516
517 public static function numberofusers( $parser, $raw = null ) {
518 return self::formatRaw( SiteStats::users(), $raw, $parser->getFunctionLang() );
519 }
520 public static function numberofactiveusers( $parser, $raw = null ) {
521 return self::formatRaw( SiteStats::activeUsers(), $raw, $parser->getFunctionLang() );
522 }
523
524 public static function numberofarticles( $parser, $raw = null ) {
525 return self::formatRaw( SiteStats::articles(), $raw, $parser->getFunctionLang() );
526 }
527
528 public static function numberoffiles( $parser, $raw = null ) {
529 return self::formatRaw( SiteStats::images(), $raw, $parser->getFunctionLang() );
530 }
531
532 public static function numberofadmins( $parser, $raw = null ) {
533 return self::formatRaw(
534 SiteStats::numberingroup( 'sysop' ),
535 $raw,
536 $parser->getFunctionLang()
537 );
538 }
539
540 public static function numberofedits( $parser, $raw = null ) {
541 return self::formatRaw( SiteStats::edits(), $raw, $parser->getFunctionLang() );
542 }
543
544 public static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) {
545 return self::formatRaw(
546 SiteStats::pagesInNs( intval( $namespace ) ),
547 $raw,
548 $parser->getFunctionLang()
549 );
550 }
551 public static function numberingroup( $parser, $name = '', $raw = null ) {
552 return self::formatRaw(
553 SiteStats::numberingroup( strtolower( $name ) ),
554 $raw,
555 $parser->getFunctionLang()
556 );
557 }
558
568 public static function mwnamespace( $parser, $title = null ) {
569 $t = Title::newFromText( $title );
570 if ( is_null( $t ) ) {
571 return '';
572 }
573 return str_replace( '_', ' ', $t->getNsText() );
574 }
575 public static function namespacee( $parser, $title = null ) {
576 $t = Title::newFromText( $title );
577 if ( is_null( $t ) ) {
578 return '';
579 }
580 return wfUrlencode( $t->getNsText() );
581 }
582 public static function namespacenumber( $parser, $title = null ) {
583 $t = Title::newFromText( $title );
584 if ( is_null( $t ) ) {
585 return '';
586 }
587 return $t->getNamespace();
588 }
589 public static function talkspace( $parser, $title = null ) {
590 $t = Title::newFromText( $title );
591 if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
592 return '';
593 }
594 return str_replace( '_', ' ', $t->getTalkNsText() );
595 }
596 public static function talkspacee( $parser, $title = null ) {
597 $t = Title::newFromText( $title );
598 if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
599 return '';
600 }
601 return wfUrlencode( $t->getTalkNsText() );
602 }
603 public static function subjectspace( $parser, $title = null ) {
604 $t = Title::newFromText( $title );
605 if ( is_null( $t ) ) {
606 return '';
607 }
608 return str_replace( '_', ' ', $t->getSubjectNsText() );
609 }
610 public static function subjectspacee( $parser, $title = null ) {
611 $t = Title::newFromText( $title );
612 if ( is_null( $t ) ) {
613 return '';
614 }
615 return wfUrlencode( $t->getSubjectNsText() );
616 }
617
625 public static function pagename( $parser, $title = null ) {
626 $t = Title::newFromText( $title );
627 if ( is_null( $t ) ) {
628 return '';
629 }
630 return wfEscapeWikiText( $t->getText() );
631 }
632 public static function pagenamee( $parser, $title = null ) {
633 $t = Title::newFromText( $title );
634 if ( is_null( $t ) ) {
635 return '';
636 }
637 return wfEscapeWikiText( $t->getPartialURL() );
638 }
639 public static function fullpagename( $parser, $title = null ) {
640 $t = Title::newFromText( $title );
641 if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
642 return '';
643 }
644 return wfEscapeWikiText( $t->getPrefixedText() );
645 }
646 public static function fullpagenamee( $parser, $title = null ) {
647 $t = Title::newFromText( $title );
648 if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
649 return '';
650 }
651 return wfEscapeWikiText( $t->getPrefixedURL() );
652 }
653 public static function subpagename( $parser, $title = null ) {
654 $t = Title::newFromText( $title );
655 if ( is_null( $t ) ) {
656 return '';
657 }
658 return wfEscapeWikiText( $t->getSubpageText() );
659 }
660 public static function subpagenamee( $parser, $title = null ) {
661 $t = Title::newFromText( $title );
662 if ( is_null( $t ) ) {
663 return '';
664 }
665 return wfEscapeWikiText( $t->getSubpageUrlForm() );
666 }
667 public static function rootpagename( $parser, $title = null ) {
668 $t = Title::newFromText( $title );
669 if ( is_null( $t ) ) {
670 return '';
671 }
672 return wfEscapeWikiText( $t->getRootText() );
673 }
674 public static function rootpagenamee( $parser, $title = null ) {
675 $t = Title::newFromText( $title );
676 if ( is_null( $t ) ) {
677 return '';
678 }
679 return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getRootText() ) ) );
680 }
681 public static function basepagename( $parser, $title = null ) {
682 $t = Title::newFromText( $title );
683 if ( is_null( $t ) ) {
684 return '';
685 }
686 return wfEscapeWikiText( $t->getBaseText() );
687 }
688 public static function basepagenamee( $parser, $title = null ) {
689 $t = Title::newFromText( $title );
690 if ( is_null( $t ) ) {
691 return '';
692 }
693 return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getBaseText() ) ) );
694 }
695 public static function talkpagename( $parser, $title = null ) {
696 $t = Title::newFromText( $title );
697 if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
698 return '';
699 }
700 return wfEscapeWikiText( $t->getTalkPage()->getPrefixedText() );
701 }
702 public static function talkpagenamee( $parser, $title = null ) {
703 $t = Title::newFromText( $title );
704 if ( is_null( $t ) || !$t->canHaveTalkPage() ) {
705 return '';
706 }
707 return wfEscapeWikiText( $t->getTalkPage()->getPrefixedURL() );
708 }
709 public static function subjectpagename( $parser, $title = null ) {
710 $t = Title::newFromText( $title );
711 if ( is_null( $t ) ) {
712 return '';
713 }
714 return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() );
715 }
716 public static function subjectpagenamee( $parser, $title = null ) {
717 $t = Title::newFromText( $title );
718 if ( is_null( $t ) ) {
719 return '';
720 }
721 return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedURL() );
722 }
723
734 public static function pagesincategory( $parser, $name = '', $arg1 = null, $arg2 = null ) {
735 static $magicWords = null;
736 if ( is_null( $magicWords ) ) {
737 $magicWords = $parser->getMagicWordFactory()->newArray( [
738 'pagesincategory_all',
739 'pagesincategory_pages',
740 'pagesincategory_subcats',
741 'pagesincategory_files'
742 ] );
743 }
744 static $cache = [];
745
746 // split the given option to its variable
747 if ( self::matchAgainstMagicword( $parser->getMagicWordFactory(), 'rawsuffix', $arg1 ) ) {
748 // {{pagesincategory:|raw[|type]}}
749 $raw = $arg1;
750 $type = $magicWords->matchStartToEnd( $arg2 );
751 } else {
752 // {{pagesincategory:[|type[|raw]]}}
753 $type = $magicWords->matchStartToEnd( $arg1 );
754 $raw = $arg2;
755 }
756 if ( !$type ) { // backward compatibility
757 $type = 'pagesincategory_all';
758 }
759
760 $title = Title::makeTitleSafe( NS_CATEGORY, $name );
761 if ( !$title ) { # invalid title
762 return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
763 }
764 $parser->getContentLanguage()->findVariantLink( $name, $title, true );
765
766 // Normalize name for cache
767 $name = $title->getDBkey();
768
769 if ( !isset( $cache[$name] ) ) {
770 $category = Category::newFromTitle( $title );
771
772 $allCount = $subcatCount = $fileCount = $pagesCount = 0;
773 if ( $parser->incrementExpensiveFunctionCount() ) {
774 // $allCount is the total number of cat members,
775 // not the count of how many members are normal pages.
776 $allCount = (int)$category->getPageCount();
777 $subcatCount = (int)$category->getSubcatCount();
778 $fileCount = (int)$category->getFileCount();
779 $pagesCount = $allCount - $subcatCount - $fileCount;
780 }
781 $cache[$name]['pagesincategory_all'] = $allCount;
782 $cache[$name]['pagesincategory_pages'] = $pagesCount;
783 $cache[$name]['pagesincategory_subcats'] = $subcatCount;
784 $cache[$name]['pagesincategory_files'] = $fileCount;
785 }
786
787 $count = $cache[$name][$type];
788 return self::formatRaw( $count, $raw, $parser->getFunctionLang() );
789 }
790
800 public static function pagesize( $parser, $page = '', $raw = null ) {
801 $title = Title::newFromText( $page );
802
803 if ( !is_object( $title ) ) {
804 return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
805 }
806
807 // fetch revision from cache/database and return the value
809 $length = $rev ? $rev->getSize() : 0;
810 if ( $length === null ) {
811 // We've had bugs where rev_len was not being recorded for empty pages, see T135414
812 $length = 0;
813 }
814 return self::formatRaw( $length, $raw, $parser->getFunctionLang() );
815 }
816
829 public static function protectionlevel( $parser, $type = '', $title = '' ) {
830 $titleObject = Title::newFromText( $title );
831 if ( !( $titleObject instanceof Title ) ) {
832 $titleObject = $parser->mTitle;
833 }
834 if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
835 $restrictions = $titleObject->getRestrictions( strtolower( $type ) );
836 # Title::getRestrictions returns an array, its possible it may have
837 # multiple values in the future
838 return implode( ',', $restrictions );
839 }
840 return '';
841 }
842
855 public static function protectionexpiry( $parser, $type = '', $title = '' ) {
856 $titleObject = Title::newFromText( $title );
857 if ( !( $titleObject instanceof Title ) ) {
858 $titleObject = $parser->mTitle;
859 }
860 if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
861 $expiry = $titleObject->getRestrictionExpiry( strtolower( $type ) );
862 // getRestrictionExpiry() returns false on invalid type; trying to
863 // match protectionlevel() function that returns empty string instead
864 if ( $expiry === false ) {
865 $expiry = '';
866 }
867 return $expiry;
868 }
869 return '';
870 }
871
879 public static function language( $parser, $code = '', $inLanguage = '' ) {
880 $code = strtolower( $code );
881 $inLanguage = strtolower( $inLanguage );
882 $lang = Language::fetchLanguageName( $code, $inLanguage );
883 return $lang !== '' ? $lang : LanguageCode::bcp47( $code );
884 }
885
895 public static function pad(
896 $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT
897 ) {
898 $padding = $parser->killMarkers( $padding );
899 $lengthOfPadding = mb_strlen( $padding );
900 if ( $lengthOfPadding == 0 ) {
901 return $string;
902 }
903
904 # The remaining length to add counts down to 0 as padding is added
905 $length = min( (int)$length, 500 ) - mb_strlen( $string );
906 if ( $length <= 0 ) {
907 // Nothing to add
908 return $string;
909 }
910
911 # $finalPadding is just $padding repeated enough times so that
912 # mb_strlen( $string ) + mb_strlen( $finalPadding ) == $length
913 $finalPadding = '';
914 while ( $length > 0 ) {
915 # If $length < $lengthofPadding, truncate $padding so we get the
916 # exact length desired.
917 $finalPadding .= mb_substr( $padding, 0, $length );
918 $length -= $lengthOfPadding;
919 }
920
921 if ( $direction == STR_PAD_LEFT ) {
922 return $finalPadding . $string;
923 } else {
924 return $string . $finalPadding;
925 }
926 }
927
928 public static function padleft( $parser, $string = '', $length = 0, $padding = '0' ) {
929 return self::pad( $parser, $string, $length, $padding, STR_PAD_LEFT );
930 }
931
932 public static function padright( $parser, $string = '', $length = 0, $padding = '0' ) {
933 return self::pad( $parser, $string, $length, $padding );
934 }
935
941 public static function anchorencode( $parser, $text ) {
942 $text = $parser->killMarkers( $text );
943 $section = (string)substr( $parser->guessSectionNameFromWikiText( $text ), 1 );
944 return Sanitizer::safeEncodeAttribute( $section );
945 }
946
947 public static function special( $parser, $text ) {
948 list( $page, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
949 resolveAlias( $text );
950 if ( $page ) {
951 $title = SpecialPage::getTitleFor( $page, $subpage );
952 return $title->getPrefixedText();
953 } else {
954 // unknown special page, just use the given text as its title, if at all possible
955 $title = Title::makeTitleSafe( NS_SPECIAL, $text );
956 return $title ? $title->getPrefixedText() : self::special( $parser, 'Badtitle' );
957 }
958 }
959
960 public static function speciale( $parser, $text ) {
961 return wfUrlencode( str_replace( ' ', '_', self::special( $parser, $text ) ) );
962 }
963
972 public static function defaultsort( $parser, $text, $uarg = '' ) {
973 static $magicWords = null;
974 if ( is_null( $magicWords ) ) {
975 $magicWords = $parser->getMagicWordFactory()->newArray(
976 [ 'defaultsort_noerror', 'defaultsort_noreplace' ] );
977 }
978 $arg = $magicWords->matchStartToEnd( $uarg );
979
980 $text = trim( $text );
981 if ( strlen( $text ) == 0 ) {
982 return '';
983 }
984 $old = $parser->getCustomDefaultSort();
985 if ( $old === false || $arg !== 'defaultsort_noreplace' ) {
986 $parser->setDefaultSort( $text );
987 }
988
989 if ( $old === false || $old == $text || $arg ) {
990 return '';
991 } else {
992 $converter = $parser->getTargetLanguage()->getConverter();
993 return '<span class="error">' .
994 wfMessage( 'duplicate-defaultsort',
995 // Message should be parsed, but these params should only be escaped.
996 $converter->markNoConversion( wfEscapeWikiText( $old ) ),
997 $converter->markNoConversion( wfEscapeWikiText( $text ) )
998 )->inContentLanguage()->text() .
999 '</span>';
1000 }
1001 }
1002
1014 public static function filepath( $parser, $name = '', $argA = '', $argB = '' ) {
1015 $file = wfFindFile( $name );
1016
1017 if ( $argA == 'nowiki' ) {
1018 // {{filepath: | option [| size] }}
1019 $isNowiki = true;
1020 $parsedWidthParam = Parser::parseWidthParam( $argB );
1021 } else {
1022 // {{filepath: [| size [|option]] }}
1023 $parsedWidthParam = Parser::parseWidthParam( $argA );
1024 $isNowiki = ( $argB == 'nowiki' );
1025 }
1026
1027 if ( $file ) {
1028 $url = $file->getFullUrl();
1029
1030 // If a size is requested...
1031 if ( count( $parsedWidthParam ) ) {
1032 $mto = $file->transform( $parsedWidthParam );
1033 // ... and we can
1034 if ( $mto && !$mto->isError() ) {
1035 // ... change the URL to point to a thumbnail.
1036 $url = wfExpandUrl( $mto->getUrl(), PROTO_RELATIVE );
1037 }
1038 }
1039 if ( $isNowiki ) {
1040 return [ $url, 'nowiki' => true ];
1041 }
1042 return $url;
1043 } else {
1044 return '';
1045 }
1046 }
1047
1055 public static function tagObj( $parser, $frame, $args ) {
1056 if ( !count( $args ) ) {
1057 return '';
1058 }
1059 $tagName = strtolower( trim( $frame->expand( array_shift( $args ) ) ) );
1060
1061 if ( count( $args ) ) {
1062 $inner = $frame->expand( array_shift( $args ) );
1063 } else {
1064 $inner = null;
1065 }
1066
1067 $attributes = [];
1068 foreach ( $args as $arg ) {
1069 $bits = $arg->splitArg();
1070 if ( strval( $bits['index'] ) === '' ) {
1071 $name = trim( $frame->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
1072 $value = trim( $frame->expand( $bits['value'] ) );
1073 if ( preg_match( '/^(?:["\'](.+)["\']|""|\'\')$/s', $value, $m ) ) {
1074 $value = $m[1] ?? '';
1075 }
1076 $attributes[$name] = $value;
1077 }
1078 }
1079
1080 $stripList = $parser->getStripList();
1081 if ( !in_array( $tagName, $stripList ) ) {
1082 // we can't handle this tag (at least not now), so just re-emit it as an ordinary tag
1083 $attrText = '';
1084 foreach ( $attributes as $name => $value ) {
1085 $attrText .= ' ' . htmlspecialchars( $name ) . '="' . htmlspecialchars( $value ) . '"';
1086 }
1087 if ( $inner === null ) {
1088 return "<$tagName$attrText/>";
1089 }
1090 return "<$tagName$attrText>$inner</$tagName>";
1091 }
1092
1093 $params = [
1094 'name' => $tagName,
1095 'inner' => $inner,
1096 'attributes' => $attributes,
1097 'close' => "</$tagName>",
1098 ];
1099 return $parser->extensionSubstitution( $params, $frame );
1100 }
1101
1114 private static function getCachedRevisionObject( $parser, $title = null ) {
1115 if ( is_null( $title ) ) {
1116 return null;
1117 }
1118
1119 // Use the revision from the parser itself, when param is the current page
1120 // and the revision is the current one
1121 if ( $title->equals( $parser->getTitle() ) ) {
1122 $parserRev = $parser->getRevisionObject();
1123 if ( $parserRev && $parserRev->isCurrent() ) {
1124 // force reparse after edit with vary-revision flag
1125 $parser->getOutput()->setFlag( 'vary-revision' );
1126 wfDebug( __METHOD__ . ": use current revision from parser, setting vary-revision...\n" );
1127 return $parserRev;
1128 }
1129 }
1130
1131 // Normalize name for cache
1132 $page = $title->getPrefixedDBkey();
1133
1134 if ( !( $parser->currentRevisionCache && $parser->currentRevisionCache->has( $page ) )
1135 && !$parser->incrementExpensiveFunctionCount() ) {
1136 return null;
1137 }
1138 $rev = $parser->fetchCurrentRevisionOfTitle( $title );
1139 $pageID = $rev ? $rev->getPage() : 0;
1140 $revID = $rev ? $rev->getId() : 0;
1141
1142 // Register dependency in templatelinks
1143 $parser->getOutput()->addTemplate( $title, $pageID, $revID );
1144
1145 return $rev;
1146 }
1147
1155 public static function pageid( $parser, $title = null ) {
1156 $t = Title::newFromText( $title );
1157 if ( is_null( $t ) ) {
1158 return '';
1159 }
1160 // Use title from parser to have correct pageid after edit
1161 if ( $t->equals( $parser->getTitle() ) ) {
1162 $t = $parser->getTitle();
1163 return $t->getArticleID();
1164 }
1165
1166 // These can't have ids
1167 if ( !$t->canExist() || $t->isExternal() ) {
1168 return 0;
1169 }
1170
1171 // Check the link cache, maybe something already looked it up.
1172 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
1173 $pdbk = $t->getPrefixedDBkey();
1174 $id = $linkCache->getGoodLinkID( $pdbk );
1175 if ( $id != 0 ) {
1176 $parser->mOutput->addLink( $t, $id );
1177 return $id;
1178 }
1179 if ( $linkCache->isBadLink( $pdbk ) ) {
1180 $parser->mOutput->addLink( $t, 0 );
1181 return $id;
1182 }
1183
1184 // We need to load it from the DB, so mark expensive
1185 if ( $parser->incrementExpensiveFunctionCount() ) {
1186 $id = $t->getArticleID();
1187 $parser->mOutput->addLink( $t, $id );
1188 return $id;
1189 }
1190 return null;
1191 }
1192
1200 public static function revisionid( $parser, $title = null ) {
1201 $t = Title::newFromText( $title );
1202 if ( is_null( $t ) ) {
1203 return '';
1204 }
1205 // fetch revision from cache/database and return the value
1207 return $rev ? $rev->getId() : '';
1208 }
1209
1217 public static function revisionday( $parser, $title = null ) {
1218 $t = Title::newFromText( $title );
1219 if ( is_null( $t ) ) {
1220 return '';
1221 }
1222 // fetch revision from cache/database and return the value
1224 return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'j' ) : '';
1225 }
1226
1234 public static function revisionday2( $parser, $title = null ) {
1235 $t = Title::newFromText( $title );
1236 if ( is_null( $t ) ) {
1237 return '';
1238 }
1239 // fetch revision from cache/database and return the value
1241 return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'd' ) : '';
1242 }
1243
1251 public static function revisionmonth( $parser, $title = null ) {
1252 $t = Title::newFromText( $title );
1253 if ( is_null( $t ) ) {
1254 return '';
1255 }
1256 // fetch revision from cache/database and return the value
1258 return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'm' ) : '';
1259 }
1260
1268 public static function revisionmonth1( $parser, $title = null ) {
1269 $t = Title::newFromText( $title );
1270 if ( is_null( $t ) ) {
1271 return '';
1272 }
1273 // fetch revision from cache/database and return the value
1275 return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'n' ) : '';
1276 }
1277
1285 public static function revisionyear( $parser, $title = null ) {
1286 $t = Title::newFromText( $title );
1287 if ( is_null( $t ) ) {
1288 return '';
1289 }
1290 // fetch revision from cache/database and return the value
1292 return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'Y' ) : '';
1293 }
1294
1302 public static function revisiontimestamp( $parser, $title = null ) {
1303 $t = Title::newFromText( $title );
1304 if ( is_null( $t ) ) {
1305 return '';
1306 }
1307 // fetch revision from cache/database and return the value
1309 return $rev ? MWTimestamp::getLocalInstance( $rev->getTimestamp() )->format( 'YmdHis' ) : '';
1310 }
1311
1319 public static function revisionuser( $parser, $title = null ) {
1320 $t = Title::newFromText( $title );
1321 if ( is_null( $t ) ) {
1322 return '';
1323 }
1324 // fetch revision from cache/database and return the value
1326 return $rev ? $rev->getUserText() : '';
1327 }
1328
1341 public static function cascadingsources( $parser, $title = '' ) {
1342 $titleObject = Title::newFromText( $title );
1343 if ( !( $titleObject instanceof Title ) ) {
1344 $titleObject = $parser->mTitle;
1345 }
1346 if ( $titleObject->areCascadeProtectionSourcesLoaded()
1347 || $parser->incrementExpensiveFunctionCount()
1348 ) {
1349 $names = [];
1350 $sources = $titleObject->getCascadeProtectionSources();
1351 foreach ( $sources[0] as $sourceTitle ) {
1352 $names[] = $sourceTitle->getPrefixedText();
1353 }
1354 return implode( '|', $names );
1355 }
1356 return '';
1357 }
1358
1359}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
$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 formatRaw( $num, $raw, $language, MagicWordFactory $magicWordFactory=null)
Formats a number according to a language.
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 matchAgainstMagicword(MagicWordFactory $magicWordFactory, $magicword, $value)
Matches the given value against the value of given magic word.
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 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 speciale( $parser, $text)
static getInstance(Language $lang=null)
Get a DateFormatter object.
A factory that stores information about MagicWords, and creates them on demand with caching.
get( $id)
Factory: creates an object representing an ID.
MediaWikiServices is the service locator for the application scope of MediaWiki.
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()
Represents a title within MediaWiki.
Definition Title.php:39
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:592
static getDefaultOption( $opt)
Get a given default option value.
Definition User.php:1818
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 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:66
const NS_FILE
Definition Defines.php:70
const NS_SPECIAL
Definition Defines.php:53
const NS_MEDIA
Definition Defines.php:52
const PROTO_RELATIVE
Definition Defines.php:221
const NS_CATEGORY
Definition Defines.php:78
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition hooks.txt:1873
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
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:994
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:895
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:2055
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:2054
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;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
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
this hook is for auditing only or null if authentication failed before getting that far $username
Definition hooks.txt:815
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:3107
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:1818
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