Index: branches/priyanka-wmf-fixes/docs/hooks.txt |
— | — | @@ -356,7 +356,8 @@ |
357 | 357 | $output: the OutputPage object ($wgOut) |
358 | 358 | &$reason: the reason (string) the article is being deleted |
359 | 359 | |
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. |
361 | 362 | $diffEngine: the DifferenceEngine |
362 | 363 | $output: the OutputPage object ($wgOut) |
363 | 364 | |
Index: branches/priyanka-wmf-fixes/includes/diff/DifferenceInterface.php |
— | — | @@ -412,60 +412,53 @@ |
413 | 413 | function renderNewRevision() { |
414 | 414 | global $wgOut, $wgUser; |
415 | 415 | wfProfileIn( __METHOD__ ); |
416 | | - |
| 416 | + # Add "current version as of X" title |
417 | 417 | $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 | + } |
421 | 426 | |
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(); |
437 | 428 | $wgOut->setRevisionId( $this->mNewRev->getId() ); |
438 | | - } |
439 | 429 | |
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 | + } |
456 | 450 | } 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 | + } |
461 | 457 | } |
462 | | - |
463 | | - if( is_object( $this->mNewRev ) && !$this->mNewRev->isCurrent() ) { |
464 | | - $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting ); |
465 | | - } |
466 | | - |
| 458 | + |
467 | 459 | # Add redundant patrol link on bottom... |
468 | 460 | if( $this->mRcidMarkPatrolled && $this->mTitle->quickUserCan('patrol') ) { |
469 | 461 | $sk = $wgUser->getSkin(); |
| 462 | + $token = $wgUser->editToken( $this->mRcidMarkPatrolled ); |
470 | 463 | $wgOut->addHTML( |
471 | 464 | "<div class='patrollink'>[" . $sk->link( |
472 | 465 | $this->mTitle, |
— | — | @@ -473,10 +466,11 @@ |
474 | 467 | array(), |
475 | 468 | array( |
476 | 469 | 'action' => 'markpatrolled', |
477 | | - 'rcid' => $this->mRcidMarkPatrolled |
| 470 | + 'rcid' => $this->mRcidMarkPatrolled, |
| 471 | + 'token' => $token, |
478 | 472 | ) |
479 | 473 | ) . ']</div>' |
480 | | - ); |
| 474 | + ); |
481 | 475 | } |
482 | 476 | |
483 | 477 | wfProfileOut( __METHOD__ ); |