Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -380,7 +380,8 @@ |
381 | 381 | $output: the OutputPage object ($wgOut) |
382 | 382 | &$reason: the reason (string) the article is being deleted |
383 | 383 | |
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. |
385 | 386 | $diffEngine: the DifferenceEngine |
386 | 387 | $output: the OutputPage object ($wgOut) |
387 | 388 | |
Index: trunk/phase3/includes/diff/DifferenceEngine.php |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | $this->mTitle = $titleObj; |
64 | 64 | } else { |
65 | 65 | global $wgTitle; |
66 | | - $this->mTitle = $wgTitle; |
| 66 | + $this->mTitle = $wgTitle; // @TODO: get rid of this |
67 | 67 | } |
68 | 68 | wfDebug( "DifferenceEngine old '$old' new '$new' rcid '$rcid'\n" ); |
69 | 69 | |
— | — | @@ -425,57 +425,48 @@ |
426 | 426 | function renderNewRevision() { |
427 | 427 | global $wgOut, $wgUser; |
428 | 428 | wfProfileIn( __METHOD__ ); |
429 | | - |
| 429 | + # Add "current version as of X" title |
430 | 430 | $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 | + } |
441 | 439 | |
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(); |
450 | 441 | $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 | + } |
469 | 463 | } else { |
470 | | - $article->doViewParse(); |
471 | | - } |
472 | | - } else { |
473 | | - $wgOut->addWikiTextTidy( $this->mNewtext ); |
474 | | - } |
| 464 | + $wgOut->addWikiTextTidy( $this->mNewtext ); |
| 465 | + } |
475 | 466 | |
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 | + } |
478 | 470 | } |
479 | | - |
480 | 471 | # Add redundant patrol link on bottom... |
481 | 472 | if ( $this->mRcidMarkPatrolled && $this->mTitle->quickUserCan( 'patrol' ) ) { |
482 | 473 | $sk = $wgUser->getSkin(); |
— | — | @@ -486,9 +477,9 @@ |
487 | 478 | wfMsgHtml( 'markaspatrolleddiff' ), |
488 | 479 | array(), |
489 | 480 | array( |
490 | | - 'action' => 'markpatrolled', |
491 | | - 'rcid' => $this->mRcidMarkPatrolled, |
492 | | - 'token' => $token, |
| 481 | + 'action' => 'markpatrolled', |
| 482 | + 'rcid' => $this->mRcidMarkPatrolled, |
| 483 | + 'token' => $token, |
493 | 484 | ) |
494 | 485 | ) . ']</div>' |
495 | 486 | ); |