MediaWiki REL1_33
ParserFunctions.php
Go to the documentation of this file.
1<?php
2
4
5use DateTime;
6use DateTimeZone;
7use Exception;
8use Language;
9use LinkCache;
11use MWTimestamp;
12use Parser;
13use PPFrame;
14use PPNode;
15use Sanitizer;
16use StringUtils;
17use StubObject;
18use Title;
19
21 public static $mExprParser;
22 public static $mTimeCache = [];
23 public static $mTimeChars = 0;
24
26 const MAX_TIME_CHARS = 6000;
27
33 public static function registerClearHook() {
34 static $done = false;
35 if ( !$done ) {
36 global $wgHooks;
37 $wgHooks['ParserClearState'][] = function () {
38 self::$mTimeChars = 0;
39 };
40 $done = true;
41 }
42 }
43
47 public static function &getExprParser() {
48 if ( !isset( self::$mExprParser ) ) {
49 self::$mExprParser = new ExprParser;
50 }
51 return self::$mExprParser;
52 }
53
59 public static function expr( $parser, $expr = '' ) {
60 try {
61 return self::getExprParser()->doExpression( $expr );
62 } catch ( ExprError $e ) {
63 return '<strong class="error">' . htmlspecialchars( $e->getMessage() ) . '</strong>';
64 }
65 }
66
74 public static function ifexpr( $parser, $expr = '', $then = '', $else = '' ) {
75 try {
76 $ret = self::getExprParser()->doExpression( $expr );
77 if ( is_numeric( $ret ) ) {
78 $ret = (float)$ret;
79 }
80 if ( $ret ) {
81 return $then;
82 } else {
83 return $else;
84 }
85 } catch ( ExprError $e ) {
86 return '<strong class="error">' . htmlspecialchars( $e->getMessage() ) . '</strong>';
87 }
88 }
89
96 public static function ifexprObj( $parser, $frame, $args ) {
97 $expr = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
98 $then = $args[1] ?? '';
99 $else = $args[2] ?? '';
100 $result = self::ifexpr( $parser, $expr, $then, $else );
101 if ( is_object( $result ) ) {
102 $result = trim( $frame->expand( $result ) );
103 }
104 return $result;
105 }
106
113 public static function ifObj( $parser, $frame, $args ) {
114 $test = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
115 if ( $test !== '' ) {
116 return isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : '';
117 } else {
118 return isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : '';
119 }
120 }
121
128 public static function ifeqObj( $parser, $frame, $args ) {
129 $left = isset( $args[0] ) ? self::decodeTrimExpand( $args[0], $frame ) : '';
130 $right = isset( $args[1] ) ? self::decodeTrimExpand( $args[1], $frame ) : '';
131
132 // Strict compare is not possible here. 01 should equal 1 for example.
134 if ( $left == $right ) {
135 return isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : '';
136 } else {
137 return isset( $args[3] ) ? trim( $frame->expand( $args[3] ) ) : '';
138 }
139 }
140
148 public static function iferror( $parser, $test = '', $then = '', $else = false ) {
149 if ( preg_match(
150 '/<(?:strong|span|p|div)\s(?:[^\s>]*\s+)*?class="(?:[^"\s>]*\s+)*?error(?:\s[^">]*)?"/',
151 $test )
152 ) {
153 return $then;
154 } elseif ( $else === false ) {
155 return $test;
156 } else {
157 return $else;
158 }
159 }
160
167 public static function iferrorObj( $parser, $frame, $args ) {
168 $test = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
169 $then = $args[1] ?? false;
170 $else = $args[2] ?? false;
171 $result = self::iferror( $parser, $test, $then, $else );
172 if ( $result === false ) {
173 return '';
174 } else {
175 return trim( $frame->expand( $result ) );
176 }
177 }
178
185 public static function switchObj( $parser, $frame, $args ) {
186 if ( count( $args ) === 0 ) {
187 return '';
188 }
189 $primary = self::decodeTrimExpand( array_shift( $args ), $frame );
190 $found = $defaultFound = false;
191 $default = null;
192 $lastItemHadNoEquals = false;
193 $lastItem = '';
194 $mwDefault = $parser->getMagicWordFactory()->get( 'default' );
195 foreach ( $args as $arg ) {
196 $bits = $arg->splitArg();
197 $nameNode = $bits['name'];
198 $index = $bits['index'];
199 $valueNode = $bits['value'];
200
201 if ( $index === '' ) {
202 # Found "="
203 $lastItemHadNoEquals = false;
204 if ( $found ) {
205 # Multiple input match
206 return trim( $frame->expand( $valueNode ) );
207 } else {
208 $test = self::decodeTrimExpand( $nameNode, $frame );
210 if ( $test == $primary ) {
211 # Found a match, return now
212 return trim( $frame->expand( $valueNode ) );
213 } elseif ( $defaultFound || $mwDefault->matchStartToEnd( $test ) ) {
214 $default = $valueNode;
215 $defaultFound = false;
216 } # else wrong case, continue
217 }
218 } else {
219 # Multiple input, single output
220 # If the value matches, set a flag and continue
221 $lastItemHadNoEquals = true;
222 // $lastItem is an "out" variable
223 $decodedTest = self::decodeTrimExpand( $valueNode, $frame, $lastItem );
225 if ( $decodedTest == $primary ) {
226 $found = true;
227 } elseif ( $mwDefault->matchStartToEnd( $decodedTest ) ) {
228 $defaultFound = true;
229 }
230 }
231 }
232 # Default case
233 # Check if the last item had no = sign, thus specifying the default case
234 if ( $lastItemHadNoEquals ) {
235 return $lastItem;
236 } elseif ( !is_null( $default ) ) {
237 return trim( $frame->expand( $default ) );
238 } else {
239 return '';
240 }
241 }
242
256 public static function rel2abs( $parser, $to = '', $from = '' ) {
257 $from = trim( $from );
258 if ( $from === '' ) {
259 $from = $parser->getTitle()->getPrefixedText();
260 }
261
262 $to = rtrim( $to, ' /' );
263
264 // if we have an empty path, or just one containing a dot
265 if ( $to === '' || $to === '.' ) {
266 return $from;
267 }
268
269 // if the path isn't relative
270 if ( substr( $to, 0, 1 ) !== '/' &&
271 substr( $to, 0, 2 ) !== './' &&
272 substr( $to, 0, 3 ) !== '../' &&
273 $to !== '..'
274 ) {
275 $from = '';
276 }
277 // Make a long path, containing both, enclose it in /.../
278 $fullPath = '/' . $from . '/' . $to . '/';
279
280 // remove redundant current path dots
281 $fullPath = preg_replace( '!/(\./)+!', '/', $fullPath );
282
283 // remove double slashes
284 $fullPath = preg_replace( '!/{2,}!', '/', $fullPath );
285
286 // remove the enclosing slashes now
287 $fullPath = trim( $fullPath, '/' );
288 $exploded = explode( '/', $fullPath );
289 $newExploded = [];
290
291 foreach ( $exploded as $current ) {
292 if ( $current === '..' ) { // removing one level
293 if ( !count( $newExploded ) ) {
294 // attempted to access a node above root node
295 $msg = wfMessage( 'pfunc_rel2abs_invalid_depth', $fullPath )
296 ->inContentLanguage()->escaped();
297 return '<strong class="error">' . $msg . '</strong>';
298 }
299 // remove last level from the stack
300 array_pop( $newExploded );
301 } else {
302 // add the current level to the stack
303 $newExploded[] = $current;
304 }
305 }
306
307 // we can now join it again
308 return implode( '/', $newExploded );
309 }
310
320 public static function ifexistCommon(
321 $parser, $frame, $titletext = '', $then = '', $else = ''
322 ) {
323 $title = Title::newFromText( $titletext );
324 $parser->getContentLanguage()->findVariantLink( $titletext, $title, true );
325 if ( $title ) {
326 if ( $title->getNamespace() === NS_MEDIA ) {
327 /* If namespace is specified as NS_MEDIA, then we want to
328 * check the physical file, not the "description" page.
329 */
330 if ( !$parser->incrementExpensiveFunctionCount() ) {
331 return $else;
332 }
333 $file = wfFindFile( $title );
334 if ( !$file ) {
335 return $else;
336 }
337 $parser->mOutput->addImage(
338 $file->getName(), $file->getTimestamp(), $file->getSha1() );
339 return $file->exists() ? $then : $else;
340 } elseif ( $title->isSpecialPage() ) {
341 /* Don't bother with the count for special pages,
342 * since their existence can be checked without
343 * accessing the database.
344 */
345 return MediaWikiServices::getInstance()->getSpecialPageFactory()
346 ->exists( $title->getDBkey() ) ? $then : $else;
347 } elseif ( $title->isExternal() ) {
348 /* Can't check the existence of pages on other sites,
349 * so just return $else. Makes a sort of sense, since
350 * they don't exist _locally_.
351 */
352 return $else;
353 } else {
354 $pdbk = $title->getPrefixedDBkey();
355 $lc = LinkCache::singleton();
356 $id = $lc->getGoodLinkID( $pdbk );
357 if ( $id !== 0 ) {
358 $parser->mOutput->addLink( $title, $id );
359 return $then;
360 } elseif ( $lc->isBadLink( $pdbk ) ) {
361 $parser->mOutput->addLink( $title, 0 );
362 return $else;
363 }
364 if ( !$parser->incrementExpensiveFunctionCount() ) {
365 return $else;
366 }
367 $id = $title->getArticleID();
368 $parser->mOutput->addLink( $title, $id );
369
370 // bug 70495: don't just check whether the ID != 0
371 if ( $title->exists() ) {
372 return $then;
373 }
374 }
375 }
376 return $else;
377 }
378
385 public static function ifexistObj( $parser, $frame, $args ) {
386 $title = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
387 $then = $args[1] ?? null;
388 $else = $args[2] ?? null;
389
390 $result = self::ifexistCommon( $parser, $frame, $title, $then, $else );
391 if ( $result === null ) {
392 return '';
393 } else {
394 return trim( $frame->expand( $result ) );
395 }
396 }
397
407 public static function timeCommon(
408 $parser, $frame = null, $format = '', $date = '', $language = '', $local = false
409 ) {
410 global $wgLocaltimezone;
412 if ( $date === '' ) {
413 $cacheKey = $parser->getOptions()->getTimestamp();
414 $timestamp = new MWTimestamp( $cacheKey );
415 $date = $timestamp->getTimestamp( TS_ISO_8601 );
416 $useTTL = true;
417 } else {
418 $cacheKey = $date;
419 $useTTL = false;
420 }
421 if ( isset( self::$mTimeCache[$format][$cacheKey][$language][$local] ) ) {
422 $cachedVal = self::$mTimeCache[$format][$cacheKey][$language][$local];
423 if ( $useTTL
424 && $cachedVal[1] !== null && $frame && is_callable( [ $frame, 'setTTL' ] )
425 ) {
426 $frame->setTTL( $cachedVal[1] );
427 }
428 return $cachedVal[0];
429 }
430
431 # compute the timestamp string $ts
432 # PHP >= 5.2 can handle dates before 1970 or after 2038 using the DateTime object
433
434 $invalidTime = false;
435
436 # the DateTime constructor must be used because it throws exceptions
437 # when errors occur, whereas date_create appears to just output a warning
438 # that can't really be detected from within the code
439 try {
440
441 # Default input timezone is UTC.
442 $utc = new DateTimeZone( 'UTC' );
443
444 # Correct for DateTime interpreting 'XXXX' as XX:XX o'clock
445 if ( preg_match( '/^[0-9]{4}$/', $date ) ) {
446 $date = '00:00 ' . $date;
447 }
448
449 # Parse date
450 # UTC is a default input timezone.
451 $dateObject = new DateTime( $date, $utc );
452
453 # Set output timezone.
454 if ( $local ) {
455 if ( isset( $wgLocaltimezone ) ) {
456 $tz = new DateTimeZone( $wgLocaltimezone );
457 } else {
458 $tz = new DateTimeZone( date_default_timezone_get() );
459 }
460 } else {
461 $tz = $utc;
462 }
463 $dateObject->setTimezone( $tz );
464 # Generate timestamp
465 $ts = $dateObject->format( 'YmdHis' );
466
467 } catch ( Exception $ex ) {
468 $invalidTime = true;
469 }
470
471 $ttl = null;
472 # format the timestamp and return the result
473 if ( $invalidTime ) {
474 $result = '<strong class="error">' .
475 wfMessage( 'pfunc_time_error' )->inContentLanguage()->escaped() .
476 '</strong>';
477 } else {
478 self::$mTimeChars += strlen( $format );
479 if ( self::$mTimeChars > self::MAX_TIME_CHARS ) {
480 return '<strong class="error">' .
481 wfMessage( 'pfunc_time_too_long' )->inContentLanguage()->escaped() .
482 '</strong>';
483 } else {
484 if ( $ts < 0 ) { // Language can't deal with BC years
485 return '<strong class="error">' .
486 wfMessage( 'pfunc_time_too_small' )->inContentLanguage()->escaped() .
487 '</strong>';
488 } elseif ( $ts < 100000000000000 ) { // Language can't deal with years after 9999
489 if ( $language !== '' && Language::isValidBuiltInCode( $language ) ) {
490 // use whatever language is passed as a parameter
491 $langObject = Language::factory( $language );
492 } else {
493 // use wiki's content language
494 $langObject = $parser->getFunctionLang();
495 // $ttl is passed by reference, which doesn't work right on stub objects
496 StubObject::unstub( $langObject );
497 }
498 $result = $langObject->sprintfDate( $format, $ts, $tz, $ttl );
499 } else {
500 return '<strong class="error">' .
501 wfMessage( 'pfunc_time_too_big' )->inContentLanguage()->escaped() .
502 '</strong>';
503 }
504 }
505 }
506 self::$mTimeCache[$format][$cacheKey][$language][$local] = [ $result, $ttl ];
507 if ( $useTTL && $ttl !== null && $frame && is_callable( [ $frame, 'setTTL' ] ) ) {
508 $frame->setTTL( $ttl );
509 }
510 return $result;
511 }
512
521 public static function time(
522 $parser, $format = '', $date = '', $language = '', $local = false
523 ) {
524 return self::timeCommon( $parser, null, $format, $date, $language, $local );
525 }
526
533 public static function timeObj( $parser, $frame, $args ) {
534 $format = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
535 $date = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : '';
536 $language = isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : '';
537 $local = isset( $args[3] ) && trim( $frame->expand( $args[3] ) );
538 return self::timeCommon( $parser, $frame, $format, $date, $language, $local );
539 }
540
548 public static function localTime( $parser, $format = '', $date = '', $language = '' ) {
549 return self::timeCommon( $parser, null, $format, $date, $language, true );
550 }
551
558 public static function localTimeObj( $parser, $frame, $args ) {
559 $format = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
560 $date = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : '';
561 $language = isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : '';
562 return self::timeCommon( $parser, $frame, $format, $date, $language, true );
563 }
564
575 public static function titleparts( $parser, $title = '', $parts = 0, $offset = 0 ) {
576 $parts = (int)$parts;
577 $offset = (int)$offset;
578 $ntitle = Title::newFromText( $title );
579 if ( $ntitle instanceof Title ) {
580 $bits = explode( '/', $ntitle->getPrefixedText(), 25 );
581 if ( count( $bits ) <= 0 ) {
582 return $ntitle->getPrefixedText();
583 } else {
584 if ( $offset > 0 ) {
585 --$offset;
586 }
587 if ( $parts === 0 ) {
588 return implode( '/', array_slice( $bits, $offset ) );
589 } else {
590 return implode( '/', array_slice( $bits, $offset, $parts ) );
591 }
592 }
593 } else {
594 return $title;
595 }
596 }
597
603 private static function checkLength( $text ) {
605 return ( mb_strlen( $text ) < $wgPFStringLengthLimit );
606 }
607
612 private static function tooLongError() {
614 $msg = wfMessage( 'pfunc_string_too_long' )->numParams( $wgPFStringLengthLimit );
615 return '<strong class="error">' . $msg->inContentLanguage()->escaped() . '</strong>';
616 }
617
626 public static function runLen( $parser, $inStr = '' ) {
627 $inStr = $parser->killMarkers( (string)$inStr );
628 return mb_strlen( $inStr );
629 }
630
644 public static function runPos( $parser, $inStr = '', $inNeedle = '', $inOffset = 0 ) {
645 $inStr = $parser->killMarkers( (string)$inStr );
646 $inNeedle = $parser->killMarkers( (string)$inNeedle );
647
648 if ( !self::checkLength( $inStr ) ||
649 !self::checkLength( $inNeedle ) ) {
650 return self::tooLongError();
651 }
652
653 if ( $inNeedle === '' ) {
654 $inNeedle = ' ';
655 }
656
657 $pos = mb_strpos( $inStr, $inNeedle, min( (int)$inOffset, mb_strlen( $inStr ) ) );
658 if ( $pos === false ) {
659 $pos = '';
660 }
661
662 return $pos;
663 }
664
677 public static function runRPos( $parser, $inStr = '', $inNeedle = '' ) {
678 $inStr = $parser->killMarkers( (string)$inStr );
679 $inNeedle = $parser->killMarkers( (string)$inNeedle );
680
681 if ( !self::checkLength( $inStr ) ||
682 !self::checkLength( $inNeedle ) ) {
683 return self::tooLongError();
684 }
685
686 if ( $inNeedle === '' ) {
687 $inNeedle = ' ';
688 }
689
690 $pos = mb_strrpos( $inStr, $inNeedle );
691 if ( $pos === false ) {
692 $pos = -1;
693 }
694
695 return $pos;
696 }
697
716 public static function runSub( $parser, $inStr = '', $inStart = 0, $inLength = 0 ) {
717 $inStr = $parser->killMarkers( (string)$inStr );
718
719 if ( !self::checkLength( $inStr ) ) {
720 return self::tooLongError();
721 }
722
723 if ( (int)$inLength === 0 ) {
724 $result = mb_substr( $inStr, (int)$inStart );
725 } else {
726 $result = mb_substr( $inStr, (int)$inStart, (int)$inLength );
727 }
728
729 return $result;
730 }
731
743 public static function runCount( $parser, $inStr = '', $inSubStr = '' ) {
744 $inStr = $parser->killMarkers( (string)$inStr );
745 $inSubStr = $parser->killMarkers( (string)$inSubStr );
746
747 if ( !self::checkLength( $inStr ) ||
748 !self::checkLength( $inSubStr ) ) {
749 return self::tooLongError();
750 }
751
752 if ( $inSubStr === '' ) {
753 $inSubStr = ' ';
754 }
755
756 $result = mb_substr_count( $inStr, $inSubStr );
757
758 return $result;
759 }
760
776 public static function runReplace( $parser, $inStr = '',
777 $inReplaceFrom = '', $inReplaceTo = '', $inLimit = -1 ) {
779
780 $inStr = $parser->killMarkers( (string)$inStr );
781 $inReplaceFrom = $parser->killMarkers( (string)$inReplaceFrom );
782 $inReplaceTo = $parser->killMarkers( (string)$inReplaceTo );
783
784 if ( !self::checkLength( $inStr ) ||
785 !self::checkLength( $inReplaceFrom ) ||
786 !self::checkLength( $inReplaceTo ) ) {
787 return self::tooLongError();
788 }
789
790 if ( $inReplaceFrom === '' ) {
791 $inReplaceFrom = ' ';
792 }
793
794 // Precompute limit to avoid generating enormous string:
795 $diff = mb_strlen( $inReplaceTo ) - mb_strlen( $inReplaceFrom );
796 if ( $diff > 0 ) {
797 $limit = ( ( $wgPFStringLengthLimit - mb_strlen( $inStr ) ) / $diff ) + 1;
798 } else {
799 $limit = -1;
800 }
801
802 $inLimit = (int)$inLimit;
803 if ( $inLimit >= 0 ) {
804 if ( $limit > $inLimit || $limit == -1 ) {
805 $limit = $inLimit;
806 }
807 }
808
809 // Use regex to allow limit and handle UTF-8 correctly.
810 $inReplaceFrom = preg_quote( $inReplaceFrom, '/' );
811 $inReplaceTo = StringUtils::escapeRegexReplacement( $inReplaceTo );
812
813 $result = preg_replace( '/' . $inReplaceFrom . '/u',
814 $inReplaceTo, $inStr, $limit );
815
816 if ( !self::checkLength( $result ) ) {
817 return self::tooLongError();
818 }
819
820 return $result;
821 }
822
839 public static function runExplode(
840 $parser, $inStr = '', $inDiv = '', $inPos = 0, $inLim = null
841 ) {
842 $inStr = $parser->killMarkers( (string)$inStr );
843 $inDiv = $parser->killMarkers( (string)$inDiv );
844
845 if ( $inDiv === '' ) {
846 $inDiv = ' ';
847 }
848
849 if ( !self::checkLength( $inStr ) ||
850 !self::checkLength( $inDiv ) ) {
851 return self::tooLongError();
852 }
853
854 $inDiv = preg_quote( $inDiv, '/' );
855
856 $matches = preg_split( '/' . $inDiv . '/u', $inStr, $inLim );
857
858 if ( $inPos >= 0 && isset( $matches[$inPos] ) ) {
859 $result = $matches[$inPos];
860 } elseif ( $inPos < 0 && isset( $matches[count( $matches ) + $inPos] ) ) {
861 $result = $matches[count( $matches ) + $inPos];
862 } else {
863 $result = '';
864 }
865
866 return $result;
867 }
868
877 public static function runUrlDecode( $parser, $inStr = '' ) {
878 $inStr = $parser->killMarkers( (string)$inStr );
879 if ( !self::checkLength( $inStr ) ) {
880 return self::tooLongError();
881 }
882
883 return urldecode( $inStr );
884 }
885
898 private static function decodeTrimExpand( $obj, $frame, &$trimExpanded = null ) {
899 $expanded = $frame->expand( $obj );
900 $trimExpanded = trim( $expanded );
901 return trim( Sanitizer::decodeCharReferences( $expanded ) );
902 }
903}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgLocaltimezone
Fake out the timezone that the server thinks it's in.
wfFindFile( $title, $options=[])
Find a file.
if( $line===false) $args
Definition cdb.php:64
Internationalisation code.
Definition Language.php:36
static isValidBuiltInCode( $code)
Returns true if a language code is of a valid form for the purposes of internal customisation of Medi...
Definition Language.php:412
static factory( $code)
Get a cached or new language object for a given language code.
Definition Language.php:215
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition LinkCache.php:34
static singleton()
Get an instance of this class.
Definition LinkCache.php:67
Library for creating and parsing MW-style timestamps.
static iferror( $parser, $test='', $then='', $else=false)
static runPos( $parser, $inStr='', $inNeedle='', $inOffset=0)
{{#pos: string | needle | offset}}
static localTime( $parser, $format='', $date='', $language='')
static runExplode( $parser, $inStr='', $inDiv='', $inPos=0, $inLim=null)
{{#explode:string | delimiter | position | limit}}
static rel2abs( $parser, $to='', $from='')
Returns the absolute path to a subpage, relative to the current article title.
static ifexpr( $parser, $expr='', $then='', $else='')
static runSub( $parser, $inStr='', $inStart=0, $inLength=0)
{{#sub: string | start | length }}
static titleparts( $parser, $title='', $parts=0, $offset=0)
Obtain a specified number of slash-separated parts of a title, e.g.
static registerClearHook()
Register ParserClearState hook.
static runRPos( $parser, $inStr='', $inNeedle='')
{{#rpos: string | needle}}
static runUrlDecode( $parser, $inStr='')
{{#urldecode:string}}
static time( $parser, $format='', $date='', $language='', $local=false)
static runCount( $parser, $inStr='', $inSubStr='')
{{#count: string | substr }}
static runReplace( $parser, $inStr='', $inReplaceFrom='', $inReplaceTo='', $inLimit=-1)
{{replace:string | from | to | limit }}
static checkLength( $text)
Verifies parameter is less than max string length.
static timeCommon( $parser, $frame=null, $format='', $date='', $language='', $local=false)
static decodeTrimExpand( $obj, $frame, &$trimExpanded=null)
Take a PPNode (-ish thing), expand it, remove entities, and trim.
static runLen( $parser, $inStr='')
{{#len:string}}
static ifexistCommon( $parser, $frame, $titletext='', $then='', $else='')
MediaWikiServices is the service locator for the application scope of MediaWiki.
static getInstance()
Returns the global default instance of the top level service locator.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition Parser.php:69
HTML sanitizer for MediaWiki.
Definition Sanitizer.php:33
static decodeCharReferences( $text)
Decode any character references, numeric or named entities, in the text and return a UTF-8 string.
A collection of static methods to play with strings.
static escapeRegexReplacement( $string)
Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
Class to implement stub globals, which are globals that delay loading the their associated module cod...
static unstub(&$obj)
Unstubs an object, if it is a stub object.
Represents a title within MediaWiki.
Definition Title.php:40
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition Title.php:306
namespace being checked & $result
Definition hooks.txt:2340
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition hooks.txt:1834
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:955
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:2003
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:2175
const NS_MEDIA
Definition Defines.php:61
There are three types of nodes:
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
Definition ExprError.php:19