<?php
/**
- * User interface for the difference engine
+ * User interface for the difference engine.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
*
* @file
* @ingroup DifferenceEngine
$samePage = false;
}
- if ( $samePage && $this->mNewPage->userCan( 'edit', $user ) ) {
+ if ( $samePage && $this->mNewPage->quickUserCan( 'edit', $user ) ) {
if ( $this->mNewRev->isCurrent() && $this->mNewPage->userCan( 'rollback', $user ) ) {
$out->preventClickjacking();
$rollback = '   ' . Linker::generateRollback( $this->mNewRev );
if ( $this->mMarkPatrolledLink === null ) {
// Prepare a change patrol link, if applicable
- if ( $wgUseRCPatrol && $this->mNewPage->userCan( 'patrol', $this->getUser() ) ) {
+ if ( $wgUseRCPatrol && $this->mNewPage->quickUserCan( 'patrol', $this->getUser() ) ) {
// If we've been given an explicit change identifier, use it; saves time
if ( $this->mRcidMarkPatrolled ) {
$rcid = $this->mRcidMarkPatrolled;
// Build the link
if ( $rcid ) {
$this->getOutput()->preventClickjacking();
- $token = $this->getUser()->editToken( $rcid );
+ $token = $this->getUser()->getEditToken( $rcid );
$this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown(
$this->mNewPage,
$this->msg( 'markaspatrolleddiff' )->escaped(),
* @return String
*/
protected function revisionDeleteLink( $rev ) {
- $link = '';
- $user = $this->getUser();
- $canHide = $user->isAllowed( 'deleterevision' );
- // Show del/undel link if:
- // (a) the user can delete revisions, or
- // (b) the user can view deleted revision *and* this one is deleted
- if ( $canHide || ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
- if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
- $link = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
- } else {
- $query = array(
- 'type' => 'revision',
- 'target' => $rev->getTitle()->getPrefixedDBkey(),
- 'ids' => $rev->getId()
- );
- $link = Linker::revDeleteLink( $query,
- $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
- }
+ $link = Linker::getRevDeleteLink( $this->getUser(), $rev, $rev->getTitle() );
+ if ( $link !== '' ) {
$link = '   ' . $link . ' ';
}
return $link;
<h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
# Page content may be handled by a hooked call instead...
if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
- # Use the current version parser cache if applicable
- $pCache = true;
- if ( !$this->mNewRev->isCurrent() ) {
- $oldEditSectionSetting = $out->parserOptions()->setEditSection( false );
- $pCache = false;
- }
-
$this->loadNewText();
- $out->setRevisionId( $this->mNewRev->getId() );
+ $out->setRevisionId( $this->mNewid );
+ $out->setRevisionTimestamp( $this->mNewRev->getTimestamp() );
$out->setArticleFlag( true );
if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) {
$out->addHTML( htmlspecialchars( $this->mNewtext ) );
$out->addHTML( "\n</pre>\n" );
}
- } elseif ( $pCache ) {
- $wikipage = WikiPage::factory( $this->mNewPage );
- $pOutput = ParserCache::singleton()->get( $wikipage, $out->parserOptions() );
- if( $pOutput ) {
- $out->addParserOutput( $pOutput );
+ } elseif ( !wfRunHooks( 'ArticleViewCustom', array( $this->mNewtext, $this->mNewPage, $out ) ) ) {
+ // Handled by extension
+ } else {
+ // Normal page
+ if ( $this->getTitle()->equals( $this->mNewPage ) ) {
+ // If the Title stored in the context is the same as the one
+ // of the new revision, we can use its associated WikiPage
+ // object.
+ $wikiPage = $this->getWikiPage();
} else {
- $out->addWikiTextTidy( $this->mNewtext );
+ // Otherwise we need to create our own WikiPage object
+ $wikiPage = WikiPage::factory( $this->mNewPage );
+ }
+
+ $parserOptions = ParserOptions::newFromContext( $this->getContext() );
+ $parserOptions->enableLimitReport();
+ $parserOptions->setTidy( true );
+
+ if ( !$this->mNewRev->isCurrent() ) {
+ $parserOptions->setEditSection( false );
}
- } else {
- $out->addWikiTextTidy( $this->mNewtext );
- }
- if ( !$this->mNewRev->isCurrent() ) {
- $out->parserOptions()->setEditSection( $oldEditSectionSetting );
+ $parserOutput = $wikiPage->getParserOutput( $parserOptions, $this->mNewid );
+
+ # WikiPage::getParserOutput() should not return false, but just in case
+ if( $parserOutput ) {
+ $out->addParserOutput( $parserOutput );
+ }
}
}
# Add redundant patrol link on bottom...
*
* @param $otext String: old text, must be already segmented
* @param $ntext String: new text, must be already segmented
+ * @return bool|string
*/
function generateDiffBody( $otext, $ntext ) {
global $wgExternalDiffEngine, $wgContLang;
/**
* Generate a debug comment indicating diff generating time,
* server node, and generator backend.
+ * @return string
*/
protected function debug( $generator = "internal" ) {
global $wgShowHostnames;
/**
* Replace line numbers with the text in the user's language
+ * @return mixed
*/
function localiseLineNumbers( $text ) {
return preg_replace_callback( '/<!--LINE (\d+)-->/',
* @return String HTML fragment
*/
private function getRevisionHeader( Revision $rev, $complete = '' ) {
- $lang = $this->getLang();
+ $lang = $this->getLanguage();
$user = $this->getUser();
$revtimestamp = $rev->getTimestamp();
$timestamp = $lang->userTimeAndDate( $revtimestamp, $user );
$editQuery['oldid'] = $rev->getID();
}
- $msg = $this->msg( $title->userCan( 'edit', $user ) ? 'editold' : 'viewsourceold' )->escaped();
+ $msg = $this->msg( $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold' )->escaped();
$header .= ' (' . Linker::linkKnown( $title, $msg, array(), $editQuery ) . ')';
if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
$header = Html::rawElement( 'span', array( 'class' => 'history-deleted' ), $header );