MediaWiki REL1_32
ParserTestParserHook.php
Go to the documentation of this file.
1<?php
29
30 static function setup( &$parser ) {
31 $parser->setHook( 'tag', [ __CLASS__, 'dumpHook' ] );
32 $parser->setHook( 'tåg', [ __CLASS__, 'dumpHook' ] );
33 $parser->setHook( 'statictag', [ __CLASS__, 'staticTagHook' ] );
34 return true;
35 }
36
37 static function dumpHook( $in, $argv ) {
38 return "<pre>\n" .
39 var_export( $in, true ) . "\n" .
40 var_export( $argv, true ) . "\n" .
41 "</pre>";
42 }
43
44 static function staticTagHook( $in, $argv, $parser ) {
45 if ( !count( $argv ) ) {
46 $parser->static_tag_buf = $in;
47 return '';
48 } elseif ( count( $argv ) === 1 && isset( $argv['action'] )
49 && $argv['action'] === 'flush' && $in === null
50 ) {
51 // Clear the buffer, we probably don't need to
52 if ( isset( $parser->static_tag_buf ) ) {
53 $tmp = $parser->static_tag_buf;
54 } else {
55 $tmp = '';
56 }
57 $parser->static_tag_buf = null;
58 return $tmp;
59 } else { // wtf?
60 return "\nCall this extension as <statictag>string</statictag> or as" .
61 " <statictag action=flush/>, not in any other way.\n" .
62 "text: " . var_export( $in, true ) . "\n" .
63 "argv: " . var_export( $argv, true ) . "\n";
64 }
65 }
66}
static dumpHook( $in, $argv)
static staticTagHook( $in, $argv, $parser)
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition hooks.txt:1873