X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FparserTestsStaticParserHook.php;h=63230fa3108aa1fc7bff042efbb69a48bec1e632;hb=8f1d2cb19924b3ade08c527bd79c308c8f9de79b;hp=09dde63bb71b9fc7fb5f6cc0beef3c0d2a451a05;hpb=6c5d3c8c6a80185fbe86e438d02f1ccea1601cf4;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/parserTestsStaticParserHook.php b/maintenance/parserTestsStaticParserHook.php index 09dde63bb7..63230fa310 100644 --- a/maintenance/parserTestsStaticParserHook.php +++ b/maintenance/parserTestsStaticParserHook.php @@ -1,42 +1,44 @@ * @copyright Copyright © 2005, 2006 Ævar Arnfjörð Bjarmason * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ -$wgHooks['ParserTestParser'][] = 'wfParserTestStaticParserHookSetup'; +class ParserTestStaticParserHook { + static function setup( &$parser ) { + $parser->setHook( 'statictag', array( __CLASS__, 'hook' ) ); -function wfParserTestStaticParserHookSetup( &$parser ) { - $parser->setHook( 'statictag', 'wfParserTestStaticParserHookHook' ); + return true; + } - return true; + static function hook( $in, $argv, $parser ) { + if ( ! count( $argv ) ) { + $parser->static_tag_buf = $in; + return ''; + } else if ( 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"; + } } - -function wfParserTestStaticParserHookHook( $in, $argv ) { - static $buf = null; - - if ( ! count( $argv ) ) { - $buf = $in; - return ''; - } else if ( count( $argv ) === 1 && $argv['action'] === 'flush' && $in === null ) { - // Clear the buffer, we probably don't need to - $tmp = $buf; - $buf = null; - return $tmp; - } else - // wtf? - die( - "\nCall this extension as string or as" . - " , not in any other way.\n" - ); -} -?>