r78331 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78330‎ | r78331 | r78332 >
Date:21:34, 13 December 2010
Author:pdhanda
Status:ok
Tags:
Comment:
Merged r78219 from trunk.
Modified paths:
  • /branches/priyanka-wmf-fixes/docs/hooks.txt (modified) (history)
  • /branches/priyanka-wmf-fixes/includes/diff/DifferenceInterface.php (modified) (history)

Diff [purge]

Index: branches/priyanka-wmf-fixes/docs/hooks.txt
@@ -356,7 +356,8 @@
357357 $output: the OutputPage object ($wgOut)
358358 &$reason: the reason (string) the article is being deleted
359359
360 -'ArticleContentOnDiff': before showing the article below a diff
 360+'ArticleContentOnDiff': before showing the article content below a diff.
 361+Use this to change the content in this area or how it is loaded.
361362 $diffEngine: the DifferenceEngine
362363 $output: the OutputPage object ($wgOut)
363364
Index: branches/priyanka-wmf-fixes/includes/diff/DifferenceInterface.php
@@ -412,60 +412,53 @@
413413 function renderNewRevision() {
414414 global $wgOut, $wgUser;
415415 wfProfileIn( __METHOD__ );
416 -
 416+ # Add "current version as of X" title
417417 $wgOut->addHTML( "<hr /><h2>{$this->mPagetitle}</h2>\n" );
418 - if ( !wfRunHooks( 'ArticleContentOnDiff', array( $this, $wgOut ) ) ) {
419 - return;
420 - }
 418+ # Page content may be handled by a hooked call instead...
 419+ if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $wgOut ) ) ) {
 420+ # Use the current version parser cache if applicable
 421+ $pCache = true;
 422+ if( !$this->mNewRev->isCurrent() ) {
 423+ $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection( false );
 424+ $pCache = false;
 425+ }
421426
422 - # Add deleted rev tag if needed
423 - if( !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) {
424 - $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n", 'rev-deleted-text-permission' );
425 - } else if( $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) {
426 - $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n", 'rev-deleted-text-view' );
427 - }
428 -
429 - $pCache = true;
430 - if( !$this->mNewRev->isCurrent() ) {
431 - $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection( false );
432 - $pCache = false;
433 - }
434 -
435 - $this->loadNewText();
436 - if( is_object( $this->mNewRev ) ) {
 427+ $this->loadNewText();
437428 $wgOut->setRevisionId( $this->mNewRev->getId() );
438 - }
439429
440 - if( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) {
441 - // Stolen from Article::view --AG 2007-10-11
442 - // Give hooks a chance to customise the output
443 - if( wfRunHooks( 'ShowRawCssJs', array( $this->mNewtext, $this->mTitle, $wgOut ) ) ) {
444 - // Wrap the whole lot in a <pre> and don't parse
445 - $m = array();
446 - preg_match( '!\.(css|js)$!u', $this->mTitle->getText(), $m );
447 - $wgOut->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
448 - $wgOut->addHTML( htmlspecialchars( $this->mNewtext ) );
449 - $wgOut->addHTML( "\n</pre>\n" );
450 - }
451 - } elseif ( $pCache ) {
452 - $article = new Article( $this->mTitle, 0 );
453 - $pOutput = ParserCache::singleton()->get( $article, $wgOut->parserOptions() );
454 - if( $pOutput ) {
455 - $wgOut->addParserOutput( $pOutput );
 430+ if( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) {
 431+ // Stolen from Article::view --AG 2007-10-11
 432+ // Give hooks a chance to customise the output
 433+ // @TODO: standardize this crap into one function
 434+ if( wfRunHooks( 'ShowRawCssJs', array( $this->mNewtext, $this->mTitle, $wgOut ) ) ) {
 435+ // Wrap the whole lot in a <pre> and don't parse
 436+ $m = array();
 437+ preg_match( '!\.(css|js)$!u', $this->mTitle->getText(), $m );
 438+ $wgOut->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
 439+ $wgOut->addHTML( htmlspecialchars( $this->mNewtext ) );
 440+ $wgOut->addHTML( "\n</pre>\n" );
 441+ }
 442+ } elseif ( $pCache ) {
 443+ $article = new Article( $this->mTitle, 0 );
 444+ $pOutput = ParserCache::singleton()->get( $article, $wgOut->parserOptions() );
 445+ if( $pOutput ) {
 446+ $wgOut->addParserOutput( $pOutput );
 447+ } else {
 448+ $article->doViewParse();
 449+ }
456450 } else {
457 - $article->doViewParse();
458 - }
459 - } else {
460 - $wgOut->addWikiTextTidy( $this->mNewtext );
 451+ $wgOut->addWikiTextTidy( $this->mNewtext );
 452+ }
 453+
 454+ if ( !$this->mNewRev->isCurrent() ) {
 455+ $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting );
 456+ }
461457 }
462 -
463 - if( is_object( $this->mNewRev ) && !$this->mNewRev->isCurrent() ) {
464 - $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting );
465 - }
466 -
 458+
467459 # Add redundant patrol link on bottom...
468460 if( $this->mRcidMarkPatrolled && $this->mTitle->quickUserCan('patrol') ) {
469461 $sk = $wgUser->getSkin();
 462+ $token = $wgUser->editToken( $this->mRcidMarkPatrolled );
470463 $wgOut->addHTML(
471464 "<div class='patrollink'>[" . $sk->link(
472465 $this->mTitle,
@@ -473,10 +466,11 @@
474467 array(),
475468 array(
476469 'action' => 'markpatrolled',
477 - 'rcid' => $this->mRcidMarkPatrolled
 470+ 'rcid' => $this->mRcidMarkPatrolled,
 471+ 'token' => $token,
478472 )
479473 ) . ']</div>'
480 - );
 474+ );
481475 }
482476
483477 wfProfileOut( __METHOD__ );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78219* Removed redundant revdelete msg above content...aaron05:32, 11 December 2010

Status & tagging log