+ /**
+ * Convert text to a document tree, like preprocessToDom(), but with some special handling
+ * assuming the source text is from a template -- specifically noinclude/includeonly behaviour.
+ */
+ function preprocessTplToDom( $text ) {
+ # If there are any <onlyinclude> tags, only include them
+ if ( !$this->ot['msg'] ) {
+ if ( in_string( '<onlyinclude>', $text ) && in_string( '</onlyinclude>', $text ) ) {
+ $replacer = new OnlyIncludeReplacer;
+ StringUtils::delimiterReplaceCallback( '<onlyinclude>', '</onlyinclude>',
+ array( &$replacer, 'replace' ), $text );
+ $text = $replacer->output;
+ }
+ # Remove <noinclude> sections and <includeonly> tags
+ $text = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $text );
+ $text = strtr( $text, array( '<includeonly>' => '' , '</includeonly>' => '' ) );
+ }
+
+ return $this->preprocessToDom( $text );
+ }
+