Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | * (which in turn the browser understands, and can display). |
17 | 17 | * |
18 | 18 | * <pre> |
19 | | - * There are five main entry points into the Parser class: |
| 19 | + * There are six main entry points into the Parser class: |
20 | 20 | * parse() |
21 | 21 | * produces HTML output |
22 | 22 | * preSaveTransform(). |
— | — | @@ -26,6 +26,8 @@ |
27 | 27 | * Cleans a signature before saving it to preferences |
28 | 28 | * extractSections() |
29 | 29 | * Extracts sections from an article for section editing |
| 30 | + * getTransclusionText() |
| 31 | + * Extracts the text of a template with only <includeonly>, etc., parsed |
30 | 32 | * |
31 | 33 | * Globals used: |
32 | 34 | * objects: $wgLang, $wgContLang |
— | — | @@ -82,6 +84,7 @@ |
83 | 85 | const OT_WIKI = 2; |
84 | 86 | const OT_PREPROCESS = 3; |
85 | 87 | const OT_MSG = 3; |
| 88 | + const OT_INCLUDES = 4; |
86 | 89 | |
87 | 90 | // Marker Suffix needs to be accessible staticly. |
88 | 91 | const MARKER_SUFFIX = "-QINU\x7f"; |
— | — | @@ -500,7 +503,13 @@ |
501 | 504 | * |
502 | 505 | * This is not called by the parser itself, see braceSubstitution for its transclusion. |
503 | 506 | */ |
504 | | - public function getTransclusionText( $title ) { |
| 507 | + public function getTransclusionText( $title, $options ) { |
| 508 | + // Must initialize first |
| 509 | + $this->clearState(); |
| 510 | + $this->setOutputType( self::OT_INCLUDES ); |
| 511 | + $this->mOptions = $options; |
| 512 | + $this->setTitle( new FakeTitle ); |
| 513 | + |
505 | 514 | list( $text, $title ) = $this->getTemplateDom( $title ); |
506 | 515 | $flags = PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES; |
507 | 516 | return $this->getPreprocessor()->newFrame()->expand( $text, $flags ); |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -227,13 +227,13 @@ |
228 | 228 | * @return string The contents of the page. |
229 | 229 | */ |
230 | 230 | protected function getPreloadedText( $preload ) { |
231 | | - global $wgParser; |
| 231 | + global $wgParser, $wgUser; |
232 | 232 | if ( !empty( $this->mPreloadText ) ) { |
233 | 233 | return $this->mPreloadText; |
234 | 234 | } else { |
235 | 235 | $preloadTitle = Title::newFromText( $preload ); |
236 | 236 | if ( isset( $preloadTitle ) && $preloadTitle->userCanRead() ) { |
237 | | - return $wgParser->getTransclusionText( $preloadTitle ); |
| 237 | + return $wgParser->getTransclusionText( $preloadTitle, ParserOptions::newFromUser( $wgUser ) ); |
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |