* (bug 21503) There's now a "reason" field when creating account for other users
[lhc/web/wiklou.git] / maintenance / parserTestsStaticParserHook.php
1 <?php
2 /**
3 * A basic extension that's used by the parser tests to test whether the parser
4 * calls extensions when they're called inside comments, it shouldn't do that
5 *
6 * @file
7 * @ingroup Maintenance
8 *
9 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
10 * @copyright Copyright © 2005, 2006 Ævar Arnfjörð Bjarmason
11 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
12 */
13
14 class ParserTestStaticParserHook {
15 static function setup( &$parser ) {
16 $parser->setHook( 'statictag', array( __CLASS__, 'hook' ) );
17
18 return true;
19 }
20
21 static function hook( $in, $argv, $parser ) {
22 if ( ! count( $argv ) ) {
23 $parser->static_tag_buf = $in;
24 return '';
25 } else if ( count( $argv ) === 1 && isset( $argv['action'] )
26 && $argv['action'] === 'flush' && $in === null )
27 {
28 // Clear the buffer, we probably don't need to
29 if ( isset( $parser->static_tag_buf ) ) {
30 $tmp = $parser->static_tag_buf;
31 } else {
32 $tmp = '';
33 }
34 $parser->static_tag_buf = null;
35 return $tmp;
36 } else
37 // wtf?
38 return
39 "\nCall this extension as <statictag>string</statictag> or as" .
40 " <statictag action=flush/>, not in any other way.\n" .
41 "text: " . var_export( $in, true ) . "\n" .
42 "argv: " . var_export( $argv, true ) . "\n";
43 }
44 }