From 91e194556c52d2f354344f930419eef2dd6267f0 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 4 Sep 2013 05:51:59 +0200 Subject: Update to MediaWiki 1.21.2 --- tests/parser/parserTestsParserHook.php | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tests/parser/parserTestsParserHook.php (limited to 'tests/parser/parserTestsParserHook.php') diff --git a/tests/parser/parserTestsParserHook.php b/tests/parser/parserTestsParserHook.php new file mode 100644 index 00000000..c8b3e897 --- /dev/null +++ b/tests/parser/parserTestsParserHook.php @@ -0,0 +1,66 @@ + + */ + +class ParserTestParserHook { + + static function setup( &$parser ) { + $parser->setHook( 'tag', array( __CLASS__, 'dumpHook' ) ); + $parser->setHook( 'statictag', array( __CLASS__, 'staticTagHook' ) ); + return true; + } + + static function dumpHook( $in, $argv ) { + return "
\n" .
+			var_export( $in, true ) . "\n" .
+			var_export( $argv, true ) . "\n" .
+			"
"; + } + + static function staticTagHook( $in, $argv, $parser ) { + if ( !count( $argv ) ) { + $parser->static_tag_buf = $in; + return ''; + } elseif ( count( $argv ) === 1 && isset( $argv['action'] ) + && $argv['action'] === 'flush' && $in === null + ) { + // Clear the buffer, we probably don't need to + if ( isset( $parser->static_tag_buf ) ) { + $tmp = $parser->static_tag_buf; + } else { + $tmp = ''; + } + $parser->static_tag_buf = null; + return $tmp; + } else { // wtf? + return + "\nCall this extension as string or as" . + " , not in any other way.\n" . + "text: " . var_export( $in, true ) . "\n" . + "argv: " . var_export( $argv, true ) . "\n"; + } + } +} -- cgit v1.2.2