r78219 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78218‎ | r78219 | r78220 >
Date:05:32, 11 December 2010
Author:aaron
Status:ok
Tags:
Comment:
* Removed redundant revdelete msg above content
* Show bottom patrol link even if hook replaces preview content
* Hook doc tweaks
* Assorted minor cleanups
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/diff/DifferenceEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -380,7 +380,8 @@
381381 $output: the OutputPage object ($wgOut)
382382 &$reason: the reason (string) the article is being deleted
383383
384 -'ArticleContentOnDiff': before showing the article below a diff
 384+'ArticleContentOnDiff': before showing the article content below a diff.
 385+Use this to change the content in this area or how it is loaded.
385386 $diffEngine: the DifferenceEngine
386387 $output: the OutputPage object ($wgOut)
387388
Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -62,7 +62,7 @@
6363 $this->mTitle = $titleObj;
6464 } else {
6565 global $wgTitle;
66 - $this->mTitle = $wgTitle;
 66+ $this->mTitle = $wgTitle; // @TODO: get rid of this
6767 }
6868 wfDebug( "DifferenceEngine old '$old' new '$new' rcid '$rcid'\n" );
6969
@@ -425,57 +425,48 @@
426426 function renderNewRevision() {
427427 global $wgOut, $wgUser;
428428 wfProfileIn( __METHOD__ );
429 -
 429+ # Add "current version as of X" title
430430 $wgOut->addHTML( "<hr /><h2>{$this->mPagetitle}</h2>\n" );
431 - if ( !wfRunHooks( 'ArticleContentOnDiff', array( $this, $wgOut ) ) ) {
432 - return;
433 - }
434 -
435 - # Add deleted rev tag if needed
436 - if ( !$this->mNewRev->userCan( Revision::DELETED_TEXT ) ) {
437 - $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
438 - } else if ( $this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
439 - $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' );
440 - }
 431+ # Page content may be handled by a hooked call instead...
 432+ if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $wgOut ) ) ) {
 433+ # Use the current version parser cache if applicable
 434+ $pCache = true;
 435+ if ( !$this->mNewRev->isCurrent() ) {
 436+ $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection( false );
 437+ $pCache = false;
 438+ }
441439
442 - $pCache = true;
443 - if ( !$this->mNewRev->isCurrent() ) {
444 - $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection( false );
445 - $pCache = false;
446 - }
447 -
448 - $this->loadNewText();
449 - if ( is_object( $this->mNewRev ) ) {
 440+ $this->loadNewText();
450441 $wgOut->setRevisionId( $this->mNewRev->getId() );
451 - }
452 -
453 - if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) {
454 - // Stolen from Article::view --AG 2007-10-11
455 - // Give hooks a chance to customise the output
456 - if ( wfRunHooks( 'ShowRawCssJs', array( $this->mNewtext, $this->mTitle, $wgOut ) ) ) {
457 - // Wrap the whole lot in a <pre> and don't parse
458 - $m = array();
459 - preg_match( '!\.(css|js)$!u', $this->mTitle->getText(), $m );
460 - $wgOut->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
461 - $wgOut->addHTML( htmlspecialchars( $this->mNewtext ) );
462 - $wgOut->addHTML( "\n</pre>\n" );
463 - }
464 - } elseif ( $pCache ) {
465 - $article = new Article( $this->mTitle, 0 );
466 - $pOutput = ParserCache::singleton()->get( $article, $wgOut->parserOptions() );
467 - if( $pOutput ) {
468 - $wgOut->addParserOutput( $pOutput );
 442+
 443+ if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) {
 444+ // Stolen from Article::view --AG 2007-10-11
 445+ // Give hooks a chance to customise the output
 446+ // @TODO: standardize this crap into one function
 447+ if ( wfRunHooks( 'ShowRawCssJs', array( $this->mNewtext, $this->mTitle, $wgOut ) ) ) {
 448+ // Wrap the whole lot in a <pre> and don't parse
 449+ $m = array();
 450+ preg_match( '!\.(css|js)$!u', $this->mTitle->getText(), $m );
 451+ $wgOut->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
 452+ $wgOut->addHTML( htmlspecialchars( $this->mNewtext ) );
 453+ $wgOut->addHTML( "\n</pre>\n" );
 454+ }
 455+ } elseif ( $pCache ) {
 456+ $article = new Article( $this->mTitle, 0 );
 457+ $pOutput = ParserCache::singleton()->get( $article, $wgOut->parserOptions() );
 458+ if( $pOutput ) {
 459+ $wgOut->addParserOutput( $pOutput );
 460+ } else {
 461+ $article->doViewParse();
 462+ }
469463 } else {
470 - $article->doViewParse();
471 - }
472 - } else {
473 - $wgOut->addWikiTextTidy( $this->mNewtext );
474 - }
 464+ $wgOut->addWikiTextTidy( $this->mNewtext );
 465+ }
475466
476 - if ( is_object( $this->mNewRev ) && !$this->mNewRev->isCurrent() ) {
477 - $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting );
 467+ if ( !$this->mNewRev->isCurrent() ) {
 468+ $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting );
 469+ }
478470 }
479 -
480471 # Add redundant patrol link on bottom...
481472 if ( $this->mRcidMarkPatrolled && $this->mTitle->quickUserCan( 'patrol' ) ) {
482473 $sk = $wgUser->getSkin();
@@ -486,9 +477,9 @@
487478 wfMsgHtml( 'markaspatrolleddiff' ),
488479 array(),
489480 array(
490 - 'action' => 'markpatrolled',
491 - 'rcid' => $this->mRcidMarkPatrolled,
492 - 'token' => $token,
 481+ 'action' => 'markpatrolled',
 482+ 'rcid' => $this->mRcidMarkPatrolled,
 483+ 'token' => $token,
493484 )
494485 ) . ']</div>'
495486 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r78331Merged r78219 from trunk.pdhanda21:34, 13 December 2010

Status & tagging log