Index: trunk/extensions/Validator/Validator.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | die( 'Not an entry point.' ); |
26 | 26 | } |
27 | 27 | |
28 | | -define( 'Validator_VERSION', '0.4.3.1' ); |
| 28 | +define( 'Validator_VERSION', '0.4.4 alpha' ); |
29 | 29 | |
30 | 30 | // Register the internationalization file. |
31 | 31 | $wgExtensionMessagesFiles['Validator'] = dirname( __FILE__ ) . '/Validator.i18n.php'; |
Index: trunk/extensions/Validator/includes/parserHooks/Validator_Describe.php |
— | — | @@ -106,17 +106,8 @@ |
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | | - // Parse the wikitext to HTML. |
111 | | - $output = $this->parser->parse( |
112 | | - implode( "\n\n", $parts ), |
113 | | - $this->parser->mTitle, |
114 | | - $this->parser->mOptions, |
115 | | - true, |
116 | | - false |
117 | | - ); |
118 | | - |
119 | 110 | // This str_replace is a hack to allow for placing <pre>s into <pre>s, without breaking the outer ones. |
120 | | - return str_replace( 'pre!>', 'pre>', $output->getText() ); |
| 111 | + return str_replace( 'pre!>', 'pre>', $this->parseWikitext( implode( "\n\n", $parts ) ) ); |
121 | 112 | } |
122 | 113 | |
123 | 114 | /** |
— | — | @@ -455,4 +446,4 @@ |
456 | 447 | return wfMsg( 'validator-describe-description' ); |
457 | 448 | } |
458 | 449 | |
459 | | -} |
\ No newline at end of file |
| 450 | +} |
Index: trunk/extensions/Validator/includes/ParserHook.php |
— | — | @@ -64,6 +64,20 @@ |
65 | 65 | protected $parser; |
66 | 66 | |
67 | 67 | /** |
| 68 | + * @since 0.4.4 |
| 69 | + * |
| 70 | + * @var PPFrame |
| 71 | + */ |
| 72 | + protected $frame; |
| 73 | + |
| 74 | + /** |
| 75 | + * @since 0.4.4 |
| 76 | + * |
| 77 | + * @var ParserHook::TYPE_ enum item |
| 78 | + */ |
| 79 | + protected $currentType; |
| 80 | + |
| 81 | + /** |
68 | 82 | * @since 0.4 |
69 | 83 | * |
70 | 84 | * @var boolean |
— | — | @@ -190,12 +204,13 @@ |
191 | 205 | * @param minxed $input string or null |
192 | 206 | * @param array $args |
193 | 207 | * @param Parser $parser |
194 | | - * @param PPFrame $frame Available from 1.16 - commented out for bc for now |
| 208 | + * @param PPFrame $frame Available from 1.16 |
195 | 209 | * |
196 | 210 | * @return string |
197 | 211 | */ |
198 | | - public function renderTag( $input, array $args, Parser $parser /*, PPFrame $frame*/ ) { |
| 212 | + public function renderTag( $input, array $args, Parser $parser, PPFrame $frame = null ) { |
199 | 213 | $this->parser = $parser; |
| 214 | + $this->frame = $frame; |
200 | 215 | |
201 | 216 | $defaultParam = array_shift( $this->getDefaultParameters( self::TYPE_TAG ) ); |
202 | 217 | |
— | — | @@ -409,6 +424,57 @@ |
410 | 425 | return false; |
411 | 426 | } |
412 | 427 | |
| 428 | + /** |
| 429 | + * Returns if the current render request is comming from a tag extension. |
| 430 | + * |
| 431 | + * @since 0.4.4 |
| 432 | + * |
| 433 | + * @return boolean |
| 434 | + */ |
| 435 | + protected function isTag() { |
| 436 | + return $this->currentType == self::TYPE_TAG; |
| 437 | + } |
| 438 | + |
| 439 | + /** |
| 440 | + * Returns if the current render request is comming from a parser function. |
| 441 | + * |
| 442 | + * @since 0.4.4 |
| 443 | + * |
| 444 | + * @return boolean |
| 445 | + */ |
| 446 | + protected function isFunction() { |
| 447 | + return $this->currentType == self::TYPE_FUNCTION; |
| 448 | + } |
| 449 | + |
| 450 | + /** |
| 451 | + * Utility function to parse wikitext without having to care |
| 452 | + * about handling a tag extension or parser function. |
| 453 | + * |
| 454 | + * @since 0.4.4 |
| 455 | + * |
| 456 | + * @param string $text The wikitext to be parsed |
| 457 | + * |
| 458 | + * @return string the parsed output |
| 459 | + */ |
| 460 | + protected function parseWikitext( $text ) { |
| 461 | + // Parse the wikitext to HTML. |
| 462 | + if ( $this->isFunction() ) { |
| 463 | + return $this->parser->parse( |
| 464 | + text, |
| 465 | + $this->parser->mTitle, |
| 466 | + $this->parser->mOptions, |
| 467 | + true, |
| 468 | + false |
| 469 | + )->getText(); |
| 470 | + } |
| 471 | + else { |
| 472 | + return $this->parser->recursiveTagParse( |
| 473 | + $text, |
| 474 | + $this->frame |
| 475 | + ); |
| 476 | + } |
| 477 | + } |
| 478 | + |
413 | 479 | } |
414 | 480 | |
415 | 481 | /** |