MediaWiki REL1_32
ExtParserFunctions.php
Go to the documentation of this file.
1<?php
2
4
6 public static $mExprParser;
7 public static $mTimeCache = [];
8 public static $mTimeChars = 0;
9 public static $mMaxTimeChars = 6000; # ~10 seconds
10
15 public static function clearState( $parser ) {
16 self::$mTimeChars = 0;
17 return true;
18 }
19
25 public static function registerClearHook() {
26 static $done = false;
27 if ( !$done ) {
28 global $wgHooks;
29 $wgHooks['ParserClearState'][] = __CLASS__ . '::clearState';
30 $done = true;
31 }
32 }
33
37 public static function &getExprParser() {
38 if ( !isset( self::$mExprParser ) ) {
39 self::$mExprParser = new ExprParser;
40 }
41 return self::$mExprParser;
42 }
43
49 public static function expr( $parser, $expr = '' ) {
50 try {
51 return self::getExprParser()->doExpression( $expr );
52 } catch ( ExprError $e ) {
53 return '<strong class="error">' . htmlspecialchars( $e->getMessage() ) . '</strong>';
54 }
55 }
56
64 public static function ifexpr( $parser, $expr = '', $then = '', $else = '' ) {
65 try {
66 $ret = self::getExprParser()->doExpression( $expr );
67 if ( is_numeric( $ret ) ) {
68 $ret = (float)$ret;
69 }
70 if ( $ret ) {
71 return $then;
72 } else {
73 return $else;
74 }
75 } catch ( ExprError $e ) {
76 return '<strong class="error">' . htmlspecialchars( $e->getMessage() ) . '</strong>';
77 }
78 }
79
86 public static function ifexprObj( $parser, $frame, $args ) {
87 $expr = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
88 $then = isset( $args[1] ) ? $args[1] : '';
89 $else = isset( $args[2] ) ? $args[2] : '';
90 $result = self::ifexpr( $parser, $expr, $then, $else );
91 if ( is_object( $result ) ) {
92 $result = trim( $frame->expand( $result ) );
93 }
94 return $result;
95 }
96
103 public static function ifObj( $parser, $frame, $args ) {
104 $test = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
105 if ( $test !== '' ) {
106 return isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : '';
107 } else {
108 return isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : '';
109 }
110 }
111
118 public static function ifeqObj( $parser, $frame, $args ) {
119 $left = isset( $args[0] ) ? self::decodeTrimExpand( $args[0], $frame ) : '';
120 $right = isset( $args[1] ) ? self::decodeTrimExpand( $args[1], $frame ) : '';
121
122 // Strict compare is not possible here. 01 should equal 1 for example.
124 if ( $left == $right ) {
125 return isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : '';
126 } else {
127 return isset( $args[3] ) ? trim( $frame->expand( $args[3] ) ) : '';
128 }
129 }
130
138 public static function iferror( $parser, $test = '', $then = '', $else = false ) {
139 if ( preg_match(
140 '/<(?:strong|span|p|div)\s(?:[^\s>]*\s+)*?class="(?:[^"\s>]*\s+)*?error(?:\s[^">]*)?"/',
141 $test )
142 ) {
143 return $then;
144 } elseif ( $else === false ) {
145 return $test;
146 } else {
147 return $else;
148 }
149 }
150
157 public static function iferrorObj( $parser, $frame, $args ) {
158 $test = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
159 $then = isset( $args[1] ) ? $args[1] : false;
160 $else = isset( $args[2] ) ? $args[2] : false;
161 $result = self::iferror( $parser, $test, $then, $else );
162 if ( $result === false ) {
163 return '';
164 } else {
165 return trim( $frame->expand( $result ) );
166 }
167 }
168
175 public static function switchObj( $parser, $frame, $args ) {
176 if ( count( $args ) === 0 ) {
177 return '';
178 }
179 $primary = self::decodeTrimExpand( array_shift( $args ), $frame );
180 $found = $defaultFound = false;
181 $default = null;
182 $lastItemHadNoEquals = false;
183 $lastItem = '';
184 if ( class_exists( MagicWordFactory::class ) ) {
185 $mwDefault = $parser->getMagicWordFactory()->get( 'default' );
186 } else {
187 $mwDefault = MagicWord::get( 'default' );
188 }
189 foreach ( $args as $arg ) {
190 $bits = $arg->splitArg();
191 $nameNode = $bits['name'];
192 $index = $bits['index'];
193 $valueNode = $bits['value'];
194
195 if ( $index === '' ) {
196 # Found "="
197 $lastItemHadNoEquals = false;
198 if ( $found ) {
199 # Multiple input match
200 return trim( $frame->expand( $valueNode ) );
201 } else {
202 $test = self::decodeTrimExpand( $nameNode, $frame );
204 if ( $test == $primary ) {
205 # Found a match, return now
206 return trim( $frame->expand( $valueNode ) );
207 } elseif ( $defaultFound || $mwDefault->matchStartToEnd( $test ) ) {
208 $default = $valueNode;
209 $defaultFound = false;
210 } # else wrong case, continue
211 }
212 } else {
213 # Multiple input, single output
214 # If the value matches, set a flag and continue
215 $lastItemHadNoEquals = true;
216 // $lastItem is an "out" variable
217 $decodedTest = self::decodeTrimExpand( $valueNode, $frame, $lastItem );
219 if ( $decodedTest == $primary ) {
220 $found = true;
221 } elseif ( $mwDefault->matchStartToEnd( $decodedTest ) ) {
222 $defaultFound = true;
223 }
224 }
225 }
226 # Default case
227 # Check if the last item had no = sign, thus specifying the default case
228 if ( $lastItemHadNoEquals ) {
229 return $lastItem;
230 } elseif ( !is_null( $default ) ) {
231 return trim( $frame->expand( $default ) );
232 } else {
233 return '';
234 }
235 }
236
250 public static function rel2abs( $parser, $to = '', $from = '' ) {
251 $from = trim( $from );
252 if ( $from === '' ) {
253 $from = $parser->getTitle()->getPrefixedText();
254 }
255
256 $to = rtrim( $to, ' /' );
257
258 // if we have an empty path, or just one containing a dot
259 if ( $to === '' || $to === '.' ) {
260 return $from;
261 }
262
263 // if the path isn't relative
264 if ( substr( $to, 0, 1 ) !== '/' &&
265 substr( $to, 0, 2 ) !== './' &&
266 substr( $to, 0, 3 ) !== '../' &&
267 $to !== '..'
268 ) {
269 $from = '';
270 }
271 // Make a long path, containing both, enclose it in /.../
272 $fullPath = '/' . $from . '/' . $to . '/';
273
274 // remove redundant current path dots
275 $fullPath = preg_replace( '!/(\./)+!', '/', $fullPath );
276
277 // remove double slashes
278 $fullPath = preg_replace( '!/{2,}!', '/', $fullPath );
279
280 // remove the enclosing slashes now
281 $fullPath = trim( $fullPath, '/' );
282 $exploded = explode( '/', $fullPath );
283 $newExploded = [];
284
285 foreach ( $exploded as $current ) {
286 if ( $current === '..' ) { // removing one level
287 if ( !count( $newExploded ) ) {
288 // attempted to access a node above root node
289 $msg = wfMessage( 'pfunc_rel2abs_invalid_depth', $fullPath )
290 ->inContentLanguage()->escaped();
291 return '<strong class="error">' . $msg . '</strong>';
292 }
293 // remove last level from the stack
294 array_pop( $newExploded );
295 } else {
296 // add the current level to the stack
297 $newExploded[] = $current;
298 }
299 }
300
301 // we can now join it again
302 return implode( '/', $newExploded );
303 }
304
314 public static function ifexistCommon(
315 $parser, $frame, $titletext = '', $then = '', $else = ''
316 ) {
317 global $wgContLang;
318 $title = Title::newFromText( $titletext );
319 $wgContLang->findVariantLink( $titletext, $title, true );
320 if ( $title ) {
321 if ( $title->getNamespace() === NS_MEDIA ) {
322 /* If namespace is specified as NS_MEDIA, then we want to
323 * check the physical file, not the "description" page.
324 */
325 if ( !$parser->incrementExpensiveFunctionCount() ) {
326 return $else;
327 }
328 $file = wfFindFile( $title );
329 if ( !$file ) {
330 return $else;
331 }
332 $parser->mOutput->addImage(
333 $file->getName(), $file->getTimestamp(), $file->getSha1() );
334 return $file->exists() ? $then : $else;
335 } elseif ( $title->isSpecialPage() ) {
336 /* Don't bother with the count for special pages,
337 * since their existence can be checked without
338 * accessing the database.
339 */
340 return MediaWikiServices::getInstance()->getSpecialPageFactory()
341 ->exists( $title->getDBkey() ) ? $then : $else;
342 } elseif ( $title->isExternal() ) {
343 /* Can't check the existence of pages on other sites,
344 * so just return $else. Makes a sort of sense, since
345 * they don't exist _locally_.
346 */
347 return $else;
348 } else {
349 $pdbk = $title->getPrefixedDBkey();
350 $lc = LinkCache::singleton();
351 $id = $lc->getGoodLinkID( $pdbk );
352 if ( $id !== 0 ) {
353 $parser->mOutput->addLink( $title, $id );
354 return $then;
355 } elseif ( $lc->isBadLink( $pdbk ) ) {
356 $parser->mOutput->addLink( $title, 0 );
357 return $else;
358 }
359 if ( !$parser->incrementExpensiveFunctionCount() ) {
360 return $else;
361 }
362 $id = $title->getArticleID();
363 $parser->mOutput->addLink( $title, $id );
364
365 // bug 70495: don't just check whether the ID != 0
366 if ( $title->exists() ) {
367 return $then;
368 }
369 }
370 }
371 return $else;
372 }
373
380 public static function ifexistObj( $parser, $frame, $args ) {
381 $title = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
382 $then = isset( $args[1] ) ? $args[1] : null;
383 $else = isset( $args[2] ) ? $args[2] : null;
384
385 $result = self::ifexistCommon( $parser, $frame, $title, $then, $else );
386 if ( $result === null ) {
387 return '';
388 } else {
389 return trim( $frame->expand( $result ) );
390 }
391 }
392
402 public static function timeCommon(
403 $parser, $frame = null, $format = '', $date = '', $language = '', $local = false
404 ) {
405 global $wgLocaltimezone;
407 if ( $date === '' ) {
408 $cacheKey = $parser->getOptions()->getTimestamp();
409 $timestamp = new MWTimestamp( $cacheKey );
410 $date = $timestamp->getTimestamp( TS_ISO_8601 );
411 $useTTL = true;
412 } else {
413 $cacheKey = $date;
414 $useTTL = false;
415 }
416 if ( isset( self::$mTimeCache[$format][$cacheKey][$language][$local] ) ) {
417 $cachedVal = self::$mTimeCache[$format][$cacheKey][$language][$local];
418 if ( $useTTL
419 && $cachedVal[1] !== null && $frame && is_callable( [ $frame, 'setTTL' ] )
420 ) {
421 $frame->setTTL( $cachedVal[1] );
422 }
423 return $cachedVal[0];
424 }
425
426 # compute the timestamp string $ts
427 # PHP >= 5.2 can handle dates before 1970 or after 2038 using the DateTime object
428
429 $invalidTime = false;
430
431 # the DateTime constructor must be used because it throws exceptions
432 # when errors occur, whereas date_create appears to just output a warning
433 # that can't really be detected from within the code
434 try {
435
436 # Default input timezone is UTC.
437 $utc = new DateTimeZone( 'UTC' );
438
439 # Correct for DateTime interpreting 'XXXX' as XX:XX o'clock
440 if ( preg_match( '/^[0-9]{4}$/', $date ) ) {
441 $date = '00:00 ' . $date;
442 }
443
444 # Parse date
445 # UTC is a default input timezone.
446 $dateObject = new DateTime( $date, $utc );
447
448 # Set output timezone.
449 if ( $local ) {
450 if ( isset( $wgLocaltimezone ) ) {
451 $tz = new DateTimeZone( $wgLocaltimezone );
452 } else {
453 $tz = new DateTimeZone( date_default_timezone_get() );
454 }
455 } else {
456 $tz = $utc;
457 }
458 $dateObject->setTimezone( $tz );
459 # Generate timestamp
460 $ts = $dateObject->format( 'YmdHis' );
461
462 } catch ( Exception $ex ) {
463 $invalidTime = true;
464 }
465
466 $ttl = null;
467 # format the timestamp and return the result
468 if ( $invalidTime ) {
469 $result = '<strong class="error">' .
470 wfMessage( 'pfunc_time_error' )->inContentLanguage()->escaped() .
471 '</strong>';
472 } else {
473 self::$mTimeChars += strlen( $format );
474 if ( self::$mTimeChars > self::$mMaxTimeChars ) {
475 return '<strong class="error">' .
476 wfMessage( 'pfunc_time_too_long' )->inContentLanguage()->escaped() .
477 '</strong>';
478 } else {
479 if ( $ts < 0 ) { // Language can't deal with BC years
480 return '<strong class="error">' .
481 wfMessage( 'pfunc_time_too_small' )->inContentLanguage()->escaped() .
482 '</strong>';
483 } elseif ( $ts < 100000000000000 ) { // Language can't deal with years after 9999
484 if ( $language !== '' && Language::isValidBuiltInCode( $language ) ) {
485 // use whatever language is passed as a parameter
486 $langObject = Language::factory( $language );
487 } else {
488 // use wiki's content language
489 $langObject = $parser->getFunctionLang();
490 // $ttl is passed by reference, which doesn't work right on stub objects
491 StubObject::unstub( $langObject );
492 }
493 $result = $langObject->sprintfDate( $format, $ts, $tz, $ttl );
494 } else {
495 return '<strong class="error">' .
496 wfMessage( 'pfunc_time_too_big' )->inContentLanguage()->escaped() .
497 '</strong>';
498 }
499 }
500 }
501 self::$mTimeCache[$format][$cacheKey][$language][$local] = [ $result, $ttl ];
502 if ( $useTTL && $ttl !== null && $frame && is_callable( [ $frame, 'setTTL' ] ) ) {
503 $frame->setTTL( $ttl );
504 }
505 return $result;
506 }
507
516 public static function time(
517 $parser, $format = '', $date = '', $language = '', $local = false
518 ) {
519 return self::timeCommon( $parser, null, $format, $date, $language, $local );
520 }
521
528 public static function timeObj( $parser, $frame, $args ) {
529 $format = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
530 $date = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : '';
531 $language = isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : '';
532 $local = isset( $args[3] ) && trim( $frame->expand( $args[3] ) );
533 return self::timeCommon( $parser, $frame, $format, $date, $language, $local );
534 }
535
543 public static function localTime( $parser, $format = '', $date = '', $language = '' ) {
544 return self::timeCommon( $parser, null, $format, $date, $language, true );
545 }
546
553 public static function localTimeObj( $parser, $frame, $args ) {
554 $format = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
555 $date = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : '';
556 $language = isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : '';
557 return self::timeCommon( $parser, $frame, $format, $date, $language, true );
558 }
559
570 public static function titleparts( $parser, $title = '', $parts = 0, $offset = 0 ) {
571 $parts = (int)$parts;
572 $offset = (int)$offset;
573 $ntitle = Title::newFromText( $title );
574 if ( $ntitle instanceof Title ) {
575 $bits = explode( '/', $ntitle->getPrefixedText(), 25 );
576 if ( count( $bits ) <= 0 ) {
577 return $ntitle->getPrefixedText();
578 } else {
579 if ( $offset > 0 ) {
580 --$offset;
581 }
582 if ( $parts === 0 ) {
583 return implode( '/', array_slice( $bits, $offset ) );
584 } else {
585 return implode( '/', array_slice( $bits, $offset, $parts ) );
586 }
587 }
588 } else {
589 return $title;
590 }
591 }
592
598 private static function checkLength( $text ) {
599 global $wgPFStringLengthLimit;
600 return ( mb_strlen( $text ) < $wgPFStringLengthLimit );
601 }
602
607 private static function tooLongError() {
608 global $wgPFStringLengthLimit;
609 $msg = wfMessage( 'pfunc_string_too_long' )->numParams( $wgPFStringLengthLimit );
610 return '<strong class="error">' . $msg->inContentLanguage()->escaped() . '</strong>';
611 }
612
621 public static function runLen( $parser, $inStr = '' ) {
622 $inStr = $parser->killMarkers( (string)$inStr );
623 return mb_strlen( $inStr );
624 }
625
639 public static function runPos( $parser, $inStr = '', $inNeedle = '', $inOffset = 0 ) {
640 $inStr = $parser->killMarkers( (string)$inStr );
641 $inNeedle = $parser->killMarkers( (string)$inNeedle );
642
643 if ( !self::checkLength( $inStr ) ||
644 !self::checkLength( $inNeedle ) ) {
645 return self::tooLongError();
646 }
647
648 if ( $inNeedle === '' ) {
649 $inNeedle = ' ';
650 }
651
652 $pos = mb_strpos( $inStr, $inNeedle, min( (int)$inOffset, mb_strlen( $inStr ) ) );
653 if ( $pos === false ) {
654 $pos = '';
655 }
656
657 return $pos;
658 }
659
672 public static function runRPos( $parser, $inStr = '', $inNeedle = '' ) {
673 $inStr = $parser->killMarkers( (string)$inStr );
674 $inNeedle = $parser->killMarkers( (string)$inNeedle );
675
676 if ( !self::checkLength( $inStr ) ||
677 !self::checkLength( $inNeedle ) ) {
678 return self::tooLongError();
679 }
680
681 if ( $inNeedle === '' ) {
682 $inNeedle = ' ';
683 }
684
685 $pos = mb_strrpos( $inStr, $inNeedle );
686 if ( $pos === false ) {
687 $pos = -1;
688 }
689
690 return $pos;
691 }
692
711 public static function runSub( $parser, $inStr = '', $inStart = 0, $inLength = 0 ) {
712 $inStr = $parser->killMarkers( (string)$inStr );
713
714 if ( !self::checkLength( $inStr ) ) {
715 return self::tooLongError();
716 }
717
718 if ( (int)$inLength === 0 ) {
719 $result = mb_substr( $inStr, (int)$inStart );
720 } else {
721 $result = mb_substr( $inStr, (int)$inStart, (int)$inLength );
722 }
723
724 return $result;
725 }
726
738 public static function runCount( $parser, $inStr = '', $inSubStr = '' ) {
739 $inStr = $parser->killMarkers( (string)$inStr );
740 $inSubStr = $parser->killMarkers( (string)$inSubStr );
741
742 if ( !self::checkLength( $inStr ) ||
743 !self::checkLength( $inSubStr ) ) {
744 return self::tooLongError();
745 }
746
747 if ( $inSubStr === '' ) {
748 $inSubStr = ' ';
749 }
750
751 $result = mb_substr_count( $inStr, $inSubStr );
752
753 return $result;
754 }
755
771 public static function runReplace( $parser, $inStr = '',
772 $inReplaceFrom = '', $inReplaceTo = '', $inLimit = -1 ) {
773 global $wgPFStringLengthLimit;
774
775 $inStr = $parser->killMarkers( (string)$inStr );
776 $inReplaceFrom = $parser->killMarkers( (string)$inReplaceFrom );
777 $inReplaceTo = $parser->killMarkers( (string)$inReplaceTo );
778
779 if ( !self::checkLength( $inStr ) ||
780 !self::checkLength( $inReplaceFrom ) ||
781 !self::checkLength( $inReplaceTo ) ) {
782 return self::tooLongError();
783 }
784
785 if ( $inReplaceFrom === '' ) {
786 $inReplaceFrom = ' ';
787 }
788
789 // Precompute limit to avoid generating enormous string:
790 $diff = mb_strlen( $inReplaceTo ) - mb_strlen( $inReplaceFrom );
791 if ( $diff > 0 ) {
792 $limit = ( ( $wgPFStringLengthLimit - mb_strlen( $inStr ) ) / $diff ) + 1;
793 } else {
794 $limit = -1;
795 }
796
797 $inLimit = (int)$inLimit;
798 if ( $inLimit >= 0 ) {
799 if ( $limit > $inLimit || $limit == -1 ) {
800 $limit = $inLimit;
801 }
802 }
803
804 // Use regex to allow limit and handle UTF-8 correctly.
805 $inReplaceFrom = preg_quote( $inReplaceFrom, '/' );
806 $inReplaceTo = StringUtils::escapeRegexReplacement( $inReplaceTo );
807
808 $result = preg_replace( '/' . $inReplaceFrom . '/u',
809 $inReplaceTo, $inStr, $limit );
810
811 if ( !self::checkLength( $result ) ) {
812 return self::tooLongError();
813 }
814
815 return $result;
816 }
817
834 public static function runExplode(
835 $parser, $inStr = '', $inDiv = '', $inPos = 0, $inLim = null
836 ) {
837 $inStr = $parser->killMarkers( (string)$inStr );
838 $inDiv = $parser->killMarkers( (string)$inDiv );
839
840 if ( $inDiv === '' ) {
841 $inDiv = ' ';
842 }
843
844 if ( !self::checkLength( $inStr ) ||
845 !self::checkLength( $inDiv ) ) {
846 return self::tooLongError();
847 }
848
849 $inDiv = preg_quote( $inDiv, '/' );
850
851 $matches = preg_split( '/' . $inDiv . '/u', $inStr, $inLim );
852
853 if ( $inPos >= 0 && isset( $matches[$inPos] ) ) {
854 $result = $matches[$inPos];
855 } elseif ( $inPos < 0 && isset( $matches[count( $matches ) + $inPos] ) ) {
856 $result = $matches[count( $matches ) + $inPos];
857 } else {
858 $result = '';
859 }
860
861 return $result;
862 }
863
872 public static function runUrlDecode( $parser, $inStr = '' ) {
873 $inStr = $parser->killMarkers( (string)$inStr );
874 if ( !self::checkLength( $inStr ) ) {
875 return self::tooLongError();
876 }
877
878 return urldecode( $inStr );
879 }
880
893 private static function decodeTrimExpand( $obj, $frame, &$trimExpanded = null ) {
894 $expanded = $frame->expand( $obj );
895 $trimExpanded = trim( $expanded );
896 return trim( Sanitizer::decodeCharReferences( $expanded ) );
897 }
898}
$wgLocaltimezone
Fake out the timezone that the server thinks it's in.
wfFindFile( $title, $options=[])
Find a file.
$wgContLang
Definition Setup.php:809
if( $line===false) $args
Definition cdb.php:64
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
Definition ExprError.php:19
static ifeqObj( $parser, $frame, $args)
static runUrlDecode( $parser, $inStr='')
{{#urldecode:string}}
static runRPos( $parser, $inStr='', $inNeedle='')
{{#rpos: string | needle}}
static checkLength( $text)
Verifies parameter is less than max string length.
static ifexistCommon( $parser, $frame, $titletext='', $then='', $else='')
static iferrorObj( $parser, $frame, $args)
static expr( $parser, $expr='')
static titleparts( $parser, $title='', $parts=0, $offset=0)
Obtain a specified number of slash-separated parts of a title, e.g.
static ifObj( $parser, $frame, $args)
static runReplace( $parser, $inStr='', $inReplaceFrom='', $inReplaceTo='', $inLimit=-1)
{{replace:string | from | to | limit }}
static switchObj( $parser, $frame, $args)
static runPos( $parser, $inStr='', $inNeedle='', $inOffset=0)
{{#pos: string | needle | offset}}
static tooLongError()
Generates error message.
static runSub( $parser, $inStr='', $inStart=0, $inLength=0)
{{#sub: string | start | length }}
static localTime( $parser, $format='', $date='', $language='')
static rel2abs( $parser, $to='', $from='')
Returns the absolute path to a subpage, relative to the current article title.
static time( $parser, $format='', $date='', $language='', $local=false)
static runLen( $parser, $inStr='')
{{#len:string}}
static runExplode( $parser, $inStr='', $inDiv='', $inPos=0, $inLim=null)
{{#explode:string | delimiter | position | limit}}
static registerClearHook()
Register ParserClearState hook.
static decodeTrimExpand( $obj, $frame, &$trimExpanded=null)
Take a PPNode (-ish thing), expand it, remove entities, and trim.
static timeObj( $parser, $frame, $args)
static runCount( $parser, $inStr='', $inSubStr='')
{{#count: string | substr }}
static ifexpr( $parser, $expr='', $then='', $else='')
static localTimeObj( $parser, $frame, $args)
static iferror( $parser, $test='', $then='', $else=false)
static clearState( $parser)
static ifexistObj( $parser, $frame, $args)
static ifexprObj( $parser, $frame, $args)
static timeCommon( $parser, $frame=null, $format='', $date='', $language='', $local=false)
Library for creating and parsing MW-style timestamps.
static get( $id)
Factory: creates an object representing an ID.
MediaWikiServices is the service locator for the application scope of MediaWiki.
static escapeRegexReplacement( $string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
static unstub(&$obj)
Unstubs an object, if it is a stub object.
Represents a title within MediaWiki.
Definition Title.php:39
namespace being checked & $result
Definition hooks.txt:2385
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition hooks.txt:1873
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:994
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
$wgHooks['ArticleShow'][]
Definition hooks.txt:108
returning false will NOT prevent logging $e
Definition hooks.txt:2226
const NS_MEDIA
Definition Defines.php:52