From 0bb1fb5cbd6ca15f31a9f9f91765beac1e687e8b Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 11 Dec 2010 05:32:48 +0000 Subject: [PATCH] * Removed redundant revdelete msg above content * Show bottom patrol link even if hook replaces preview content * Hook doc tweaks * Assorted minor cleanups --- docs/hooks.txt | 3 +- includes/diff/DifferenceEngine.php | 89 ++++++++++++++---------------- 2 files changed, 42 insertions(+), 50 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index ef66db013f..569c0f70d4 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -380,7 +380,8 @@ $article: the article (object) being deleted $output: the OutputPage object ($wgOut) &$reason: the reason (string) the article is being deleted -'ArticleContentOnDiff': before showing the article below a diff +'ArticleContentOnDiff': before showing the article content below a diff. +Use this to change the content in this area or how it is loaded. $diffEngine: the DifferenceEngine $output: the OutputPage object ($wgOut) diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 6b026b0990..b295c572fb 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -62,7 +62,7 @@ class DifferenceEngine { $this->mTitle = $titleObj; } else { global $wgTitle; - $this->mTitle = $wgTitle; + $this->mTitle = $wgTitle; // @TODO: get rid of this } wfDebug( "DifferenceEngine old '$old' new '$new' rcid '$rcid'\n" ); @@ -425,57 +425,48 @@ CONTROL; function renderNewRevision() { global $wgOut, $wgUser; wfProfileIn( __METHOD__ ); - + # Add "current version as of X" title $wgOut->addHTML( "

{$this->mPagetitle}

\n" ); - if ( !wfRunHooks( 'ArticleContentOnDiff', array( $this, $wgOut ) ) ) { - return; - } - - # Add deleted rev tag if needed - if ( !$this->mNewRev->userCan( Revision::DELETED_TEXT ) ) { - $wgOut->wrapWikiMsg( "\n", 'rev-deleted-text-permission' ); - } else if ( $this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) { - $wgOut->wrapWikiMsg( "\n", 'rev-deleted-text-view' ); - } - - $pCache = true; - if ( !$this->mNewRev->isCurrent() ) { - $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection( false ); - $pCache = false; - } + # Page content may be handled by a hooked call instead... + if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $wgOut ) ) ) { + # Use the current version parser cache if applicable + $pCache = true; + if ( !$this->mNewRev->isCurrent() ) { + $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection( false ); + $pCache = false; + } - $this->loadNewText(); - if ( is_object( $this->mNewRev ) ) { + $this->loadNewText(); $wgOut->setRevisionId( $this->mNewRev->getId() ); - } - - if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) { - // Stolen from Article::view --AG 2007-10-11 - // Give hooks a chance to customise the output - if ( wfRunHooks( 'ShowRawCssJs', array( $this->mNewtext, $this->mTitle, $wgOut ) ) ) { - // Wrap the whole lot in a
 and don't parse
-				$m = array();
-				preg_match( '!\.(css|js)$!u', $this->mTitle->getText(), $m );
-				$wgOut->addHTML( "
\n" );
-				$wgOut->addHTML( htmlspecialchars( $this->mNewtext ) );
-				$wgOut->addHTML( "\n
\n" ); - } - } elseif ( $pCache ) { - $article = new Article( $this->mTitle, 0 ); - $pOutput = ParserCache::singleton()->get( $article, $wgOut->parserOptions() ); - if( $pOutput ) { - $wgOut->addParserOutput( $pOutput ); + + if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) { + // Stolen from Article::view --AG 2007-10-11 + // Give hooks a chance to customise the output + // @TODO: standardize this crap into one function + if ( wfRunHooks( 'ShowRawCssJs', array( $this->mNewtext, $this->mTitle, $wgOut ) ) ) { + // Wrap the whole lot in a
 and don't parse
+					$m = array();
+					preg_match( '!\.(css|js)$!u', $this->mTitle->getText(), $m );
+					$wgOut->addHTML( "
\n" );
+					$wgOut->addHTML( htmlspecialchars( $this->mNewtext ) );
+					$wgOut->addHTML( "\n
\n" ); + } + } elseif ( $pCache ) { + $article = new Article( $this->mTitle, 0 ); + $pOutput = ParserCache::singleton()->get( $article, $wgOut->parserOptions() ); + if( $pOutput ) { + $wgOut->addParserOutput( $pOutput ); + } else { + $article->doViewParse(); + } } else { - $article->doViewParse(); - } - } else { - $wgOut->addWikiTextTidy( $this->mNewtext ); - } + $wgOut->addWikiTextTidy( $this->mNewtext ); + } - if ( is_object( $this->mNewRev ) && !$this->mNewRev->isCurrent() ) { - $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting ); + if ( !$this->mNewRev->isCurrent() ) { + $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting ); + } } - # Add redundant patrol link on bottom... if ( $this->mRcidMarkPatrolled && $this->mTitle->quickUserCan( 'patrol' ) ) { $sk = $wgUser->getSkin(); @@ -486,9 +477,9 @@ CONTROL; wfMsgHtml( 'markaspatrolleddiff' ), array(), array( - 'action' => 'markpatrolled', - 'rcid' => $this->mRcidMarkPatrolled, - 'token' => $token, + 'action' => 'markpatrolled', + 'rcid' => $this->mRcidMarkPatrolled, + 'token' => $token, ) ) . ']' ); -- 2.20.1