Index: trunk/extensions/PageSchemas/PageSchemas.hooks.php |
— | — | @@ -10,21 +10,22 @@ |
11 | 11 | |
12 | 12 | // Initialization |
13 | 13 | public static function register( &$parser ) { |
| 14 | + global $wgOut, $wgScriptPath; |
| 15 | + |
14 | 16 | // Register the hook with the parser |
15 | 17 | $parser->setHook( 'PageSchema', array( 'PageSchemasHooks', 'render' ) ); |
16 | 18 | // add the CSS |
17 | | - global $wgOut, $wgScriptPath; |
18 | | - $wgOut->addStyle($wgScriptPath . '/extensions/PageSchemas/PageSchemas.css'); |
| 19 | + $wgOut->addStyle( $wgScriptPath . '/extensions/PageSchemas/PageSchemas.css' ); |
19 | 20 | return true; |
20 | 21 | } |
21 | 22 | |
22 | | - |
23 | 23 | // Render the displayed XML, if any |
24 | 24 | public static function render( $input, $args, $parser, $frame ) { |
25 | | - // if this call is contained in a transcluded page or template, |
26 | | - // or if the input is empty, display nothing |
27 | | - if ( !$frame->title->equals( $parser->getTitle() ) || $input == '' ) |
| 25 | + // If this call is contained in a transcluded page or template, |
| 26 | + // or if the input is empty, display nothing. |
| 27 | + if ( !$frame->title->equals( $parser->getTitle() ) || $input == '' ) { |
28 | 28 | return; |
| 29 | + } |
29 | 30 | |
30 | 31 | // TODO: Do processing here, like parse to an array |
31 | 32 | $error_msg = null; |
— | — | @@ -32,31 +33,17 @@ |
33 | 34 | // recreate the top-level <PageSchema> tag, with whatever |
34 | 35 | // attributes it contained, because that was actually a tag- |
35 | 36 | // function call, as opposed to a real XML tag |
36 | | - $input = Xml::tags('PageSchema', $args, $input); |
| 37 | + $input = Xml::tags( 'PageSchema', $args, $input ); |
37 | 38 | |
38 | | - // if 'type=' was specified, and it wasn't set to one of the |
39 | | - // allowed values (currently just 'auto'), don't validate - |
40 | | - // just display the XML |
41 | | - if ( array_key_exists( 'type', $args ) && $args['type'] != 'auto' ) { |
42 | | - // Store XML in the page_props table - the Javascript |
43 | | - // can figure out on its own whether or not to handle it |
44 | | - $parser->getOutput()->setProperty( 'PageSchema', $input ); |
45 | | - // TODO - a hook should be called here, to allow other |
46 | | - // XML handlers to parse and display this |
47 | | - $text = Html::element('p', null, "The (unhandled) XML definition for this schema is:") . "\n"; |
48 | | - $text .= Html::element('pre', null, $input); |
49 | | - return $text; |
50 | | - } |
51 | | - |
52 | 39 | if ( $xml_object = PageSchemas::validateXML( $input, $error_msg ) ) { |
53 | | - // Store XML in the page_props table |
| 40 | + // Store the XML in the page_props table |
54 | 41 | $parser->getOutput()->setProperty( 'PageSchema', $input ); |
55 | 42 | $text = PageSchemas::parsePageSchemas( $xml_object ); |
56 | 43 | } else { |
57 | 44 | // Store error message in the page_props table |
58 | 45 | $parser->getOutput()->setProperty( 'PageSchema', $error_msg ); |
59 | | - $text = Html::element('p', null, "The (incorrect) XML definition for this template is:") . "\n"; |
60 | | - $text .= Html::element('pre', null, $input); |
| 46 | + $text = Html::element( 'p', null, "The (incorrect) XML definition for this template is:" ) . "\n"; |
| 47 | + $text .= Html::element( 'pre', null, $input ); |
61 | 48 | } |
62 | 49 | |
63 | 50 | // return output |