From: daniel Date: Mon, 16 Apr 2012 07:12:34 +0000 (+0200) Subject: make html generation optional in Content::getParserOutput X-Git-Tag: 1.31.0-rc.0~22097^2^2~255 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=52abc24967c01d9f037ae108841d063ca722bf94;p=lhc%2Fweb%2Fwiklou.git make html generation optional in Content::getParserOutput Change-Id: Ie1c6588057dbce1a5e6955ebcbd9905df53b2f5a --- diff --git a/includes/Article.php b/includes/Article.php index e2b920ea49..7fc436f236 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -627,7 +627,7 @@ class Article extends Page { # Viewing a redirect page (e.g. with parameter redirect=no) $wgOut->addHTML( $this->viewRedirect( $rt ) ); # Parse just to get categories, displaytitle, etc. - $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid, $parserOptions ); + $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid, $parserOptions, false ); $wgOut->addParserOutputNoText( $this->mParserOutput ); $outputDone = true; } diff --git a/includes/Content.php b/includes/Content.php index 913eb067c8..30e8400606 100644 --- a/includes/Content.php +++ b/includes/Content.php @@ -112,9 +112,13 @@ abstract class Content { * @param null|Title $title * @param null $revId * @param null|ParserOptions $options + * @param Boolean $generateHtml whether to generate Html (default: true). If false, + * the result of calling getText() on the ParserOutput object returned by + * this method is undefined. + * * @return ParserOutput */ - public abstract function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = NULL ); + public abstract function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = NULL, $generateHtml = true ); /** * Construct the redirect destination from this content and return an @@ -317,10 +321,12 @@ abstract class TextContent extends Content { * * @return ParserOutput representing the HTML form of the text */ - public function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = null ) { + public function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = null, $generateHtml = true ) { # generic implementation, relying on $this->getHtml() - $html = $this->getHtml( $options ); + if ( $generateHtml ) $html = $this->getHtml( $options ); + else $html = ''; + $po = new ParserOutput( $html ); return $po; @@ -356,7 +362,7 @@ class WikitextContent extends TextContent { * * @return ParserOutput representing the HTML form of the text */ - public function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = null ) { + public function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = null, $generateHtml = true ) { global $wgParser; if ( !$options ) { diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 10f17a27c2..93e13cb6ed 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -189,7 +189,7 @@ class ApiParse extends ApiBase { return; } // Not cached (save or load) - $p_result = $wgParser->parse( $params['pst'] ? $this->pstText : $this->text, $titleObj, $popts ); + $p_result = $wgParser->parse( $params['pst'] ? $this->pstText : $this->text, $titleObj, $popts ); #FIXME: use Content object¡ } $result_array = array();