Display permissions specific to the API (such as writeapi and apihighlimits) on actio...
[lhc/web/wiklou.git] / includes / DifferenceEngine.php
index 7a2f3f7..eaa706b 100644 (file)
@@ -1,10 +1,6 @@
 <?php
 /**
  * @defgroup DifferenceEngine DifferenceEngine
- *
- * @file
- * See diff.doc
- * @todo indicate where diff.doc can be found.
  */
 
 /**
@@ -73,6 +69,10 @@ class DifferenceEngine {
                $this->mRefreshCache = $refreshCache;
        }
 
+       function getTitle() {
+               return $this->mTitle;
+       }
+
        function showDiffPage( $diffOnly = false ) {
                global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol;
                wfProfileIn( __METHOD__ );
@@ -108,9 +108,10 @@ CONTROL;
 
                $wgOut->setArticleFlag( false );
                if ( ! $this->loadRevisionData() ) {
-                       $t = $this->mTitle->getPrefixedText() . ' ' . wfMsgExt( 'missingarticle-diff', array( 'escape' ), $this->mOldid, $this->mNewid );
+                       $t = $this->mTitle->getPrefixedText();
+                       $d = wfMsgExt( 'missingarticle-diff', array( 'escape' ), $this->mOldid, $this->mNewid );
                        $wgOut->setPagetitle( wfMsg( 'errorpagetitle' ) );
-                       $wgOut->addWikiMsg( 'missingarticle', "<nowiki>$t</nowiki>" );
+                       $wgOut->addWikiMsg( 'missing-article', "<nowiki>$t</nowiki>", $d );
                        wfProfileOut( __METHOD__ );
                        return;
                }
@@ -141,7 +142,7 @@ CONTROL;
                        $wgOut->setPageTitle( $oldTitle . ', ' . $newTitle );
                }
                $wgOut->setSubtitle( wfMsg( 'difference' ) );
-               $wgOut->setRobotpolicy( 'noindex,nofollow' );
+               $wgOut->setRobotPolicy( 'noindex,nofollow' );
 
                if ( !( $this->mOldPage->userCanRead() && $this->mNewPage->userCanRead() ) ) {
                        $wgOut->loginToUse();
@@ -152,7 +153,9 @@ CONTROL;
 
                $sk = $wgUser->getSkin();
 
-               if ( $this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback') ) {
+               // Check if page is editable
+               $editable = $this->mNewRev->getTitle()->userCan( 'edit' );
+               if ( $editable && $this->mNewRev->isCurrent() && $wgUser->isAllowed( 'rollback' ) ) {
                        $rollback = '&nbsp;&nbsp;&nbsp;' . $sk->generateRollback( $this->mNewRev );
                } else {
                        $rollback = '';
@@ -327,9 +330,10 @@ CONTROL;
                # Get article text from the DB
                #
                if ( ! $this->loadNewText() ) {
-                       $t = $this->mTitle->getPrefixedText() . ' ' . wfMsgExt( 'missingarticle-diff', array( 'escape' ), $this->mOldid, $this->mNewid );
+                       $t = $this->mTitle->getPrefixedText();
+                       $d = wfMsgExt( 'missingarticle-diff', array( 'escape' ), $this->mOldid, $this->mNewid );
                        $wgOut->setPagetitle( wfMsg( 'errorpagetitle' ) );
-                       $wgOut->addWikiMsg( 'missingarticle', "<nowiki>$t</nowiki>" );
+                       $wgOut->addWikiMsg( 'missing-article', "<nowiki>$t</nowiki>", $d );
                        wfProfileOut( __METHOD__ );
                        return;
                }
@@ -359,7 +363,7 @@ CONTROL;
                $wgOut->addHTML( $header );
 
                $wgOut->setSubtitle( wfMsg( 'difference' ) );
-               $wgOut->setRobotpolicy( 'noindex,nofollow' );
+               $wgOut->setRobotPolicy( 'noindex,nofollow' );
 
                wfProfileOut( __METHOD__ );
        }
@@ -372,7 +376,7 @@ CONTROL;
                global $wgOut;
                $diff = $this->getDiff( $otitle, $ntitle );
                if ( $diff === false ) {
-                       $wgOut->addWikiMsg( 'missingarticle', "<nowiki>(fixme, bug)</nowiki>" );
+                       $wgOut->addWikiMsg( 'missing-article', "<nowiki>(fixme, bug)</nowiki>", '' );
                        return false;
                } else {
                        $this->showDiffStyle();
@@ -668,7 +672,7 @@ CONTROL;
                $timestamp = $wgLang->timeanddate( $this->mNewRev->getTimestamp(), true );
                $this->mNewPage = $this->mNewRev->getTitle();
                if( $this->mNewRev->isCurrent() ) {
-                       $newLink = $this->mNewPage->escapeLocalUrl();
+                       $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid );
                        $this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev' ) );
                        $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit' );