From 2d23e2a9779b3d56b307db62da4d1a290e48ca30 Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Mon, 23 Jan 2006 18:37:46 +0000 Subject: [PATCH] Tidy up only article views, previews, image pages and diffs. --- includes/DifferenceEngine.php | 4 ++-- includes/EditPage.php | 2 +- includes/ImagePage.php | 2 +- includes/OutputPage.php | 14 +++++++++++++- includes/Parser.php | 10 ++++++---- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 588f215a59..3a10e8e62b 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -207,7 +207,7 @@ CONTROL; if( is_object( $this->mNewRev ) ) { $wgOut->setRevisionId( $this->mNewRev->getId() ); } - $wgOut->addWikiText( $this->mNewtext ); + $wgOut->addSecondaryWikiText( $this->mNewtext ); if( !$this->mNewRev->isCurrent() ) { $wgOut->mParserOptions->setEditSection( $oldEditSectionSetting ); @@ -275,7 +275,7 @@ CONTROL; if( is_object( $this->mNewRev ) ) { $wgOut->setRevisionId( $this->mNewRev->getId() ); } - $wgOut->addWikiText( $this->mNewtext ); + $wgOut->addSecondaryWikiText( $this->mNewtext ); wfProfileOut( $fname ); } diff --git a/includes/EditPage.php b/includes/EditPage.php index 3a4d7619a3..9a5be6b455 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -424,7 +424,7 @@ class EditPage { if(isset($introtitle) && $introtitle->userCanRead()) { $rev=Revision::newFromTitle($introtitle); if($rev) { - $wgOut->addWikiText($rev->getText()); + $wgOut->addSecondaryWikiText($rev->getText()); $addstandardintro=false; } } diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 5f681d631a..9d06e38a78 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -27,7 +27,7 @@ class ImagePage extends Article { function render() { global $wgOut; $wgOut->setArticleBodyOnly( true ); - $wgOut->addWikitext( $this->getContent() ); + $wgOut->addSecondaryWikitext( $this->getContent() ); } function view() { diff --git a/includes/OutputPage.php b/includes/OutputPage.php index d7c88a4fe7..0c73c333f9 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -306,9 +306,10 @@ class OutputPage { function addPrimaryWikiText( $text, $article, $cache = true ) { global $wgParser, $wgUser; + $this->mParserOptions->setTidy(true); $parserOutput = $wgParser->parse( $text, $article->mTitle, $this->mParserOptions, true, true, $this->mRevisionId ); - + $this->mParserOptions->setTidy(false); if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) { $parserCache =& ParserCache::singleton(); $parserCache->save( $parserOutput, $article, $wgUser ); @@ -321,6 +322,17 @@ class OutputPage { $this->addHTML( $parserOutput->getText() ); } + /** + * For anything that isn't primary text or interface message + */ + function addSecondaryWikiText( $text, $linestart = true ) { + global $wgTitle; + $this->mParserOptions->setTidy(true); + $this->addWikiTextTitle($text, $wgTitle, $linestart); + $this->mParserOptions->setTidy(false); + } + + /** * Add the output of a QuickTemplate to the output buffer * @param QuickTemplate $template diff --git a/includes/Parser.php b/includes/Parser.php index 0a12424589..75ccde8fed 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -237,7 +237,7 @@ class Parser $text = Sanitizer::normalizeCharReferences( $text ); - if ($wgUseTidy) { + if ($wgUseTidy and $this->mOptions->getTidy()) { $text = Parser::tidy($text); } @@ -3837,6 +3837,7 @@ class ParserOptions var $mEditSection; # Create "edit section" links var $mNumberHeadings; # Automatically number headings var $mAllowSpecialInclusion; # Allow inclusion of special pages + var $mTidy; # Ask for tidy cleanup function getUseTeX() { return $this->mUseTeX; } function getUseDynamicDates() { return $this->mUseDynamicDates; } @@ -3848,7 +3849,7 @@ class ParserOptions function getEditSection() { return $this->mEditSection; } function getNumberHeadings() { return $this->mNumberHeadings; } function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; } - + function getTidy() { return $this->mTidy; } function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX, $x ); } function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates, $x ); } @@ -3859,7 +3860,7 @@ class ParserOptions function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); } function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); } function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); } - + function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); } function setSkin( &$x ) { $this->mSkin =& $x; } function ParserOptions() { @@ -3902,6 +3903,7 @@ class ParserOptions $this->mEditSection = true; $this->mNumberHeadings = $user->getOption( 'numberheadings' ); $this->mAllowSpecialInclusion = $wgAllowSpecialInclusion; + $this->mTidy = false; wfProfileOut( $fname ); } } @@ -3977,4 +3979,4 @@ function wfEscapeHTMLTagsOnly( $in ) { $in ); } -?> +?> \ No newline at end of file -- 2.20.1