Localisation updates for core and extension messages from translatewiki.net (2010...
[lhc/web/wiklou.git] / includes / FileRevertForm.php
index b8455bb..2902734 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * File reversion user interface
  *
- * @addtogroup Media
+ * @ingroup Media
  * @author Rob Church <robchur@gmail.com>
  */
 class FileRevertForm {
@@ -13,17 +13,17 @@ class FileRevertForm {
        protected $archiveName = '';
        protected $timestamp = false;
        protected $oldFile;
-       
+
        /**
         * Constructor
         *
-        * @param File $file File we're reverting
+        * @param $file File we're reverting
         */
        public function __construct( $file ) {
                $this->title = $file->getTitle();
                $this->file = $file;
        }
-       
+
        /**
         * Fulfil the request; shows the form or reverts the file,
         * pending authentication, confirmation, etc.
@@ -38,7 +38,7 @@ class FileRevertForm {
                } elseif( !$wgUser->isLoggedIn() ) {
                        $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
                        return;
-               } elseif( !$this->title->userCan( 'edit' ) ) {
+               } elseif( !$this->title->userCan( 'edit' ) || !$this->title->userCan( 'upload' ) ) {
                        // The standard read-only thing doesn't make a whole lot of sense
                        // here; surely it should show the image or something? -- RC
                        $article = new Article( $this->title );
@@ -48,20 +48,20 @@ class FileRevertForm {
                        $wgOut->blockedPage();
                        return;
                }
-               
+
                $this->archiveName = $wgRequest->getText( 'oldimage' );
                $token = $wgRequest->getText( 'wpEditToken' );
                if( !$this->isValidOldSpec() ) {
                        $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars( $this->archiveName ) );
                        return;
                }
-               
+
                if( !$this->haveOldVersion() ) {
-                       $wgOut->addHtml( wfMsgExt( 'filerevert-badversion', 'parse' ) );
+                       $wgOut->addHTML( wfMsgExt( 'filerevert-badversion', 'parse' ) );
                        $wgOut->returnToMain( false, $this->title );
                        return;
                }
-               
+
                // Perform the reversion if appropriate
                if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->archiveName ) ) {
                        $source = $this->file->getArchiveVirtualUrl( $this->archiveName );
@@ -69,7 +69,7 @@ class FileRevertForm {
                        // TODO: Preserve file properties from database instead of reloading from file
                        $status = $this->file->upload( $source, $comment, $comment );
                        if( $status->isGood() ) {
-                               $wgOut->addHtml( wfMsgExt( 'filerevert-success', 'parse', $this->title->getText(),
+                               $wgOut->addHTML( wfMsgExt( 'filerevert-success', 'parse', $this->title->getText(),
                                        $wgLang->date( $this->getTimestamp(), true ),
                                        $wgLang->time( $this->getTimestamp(), true ),
                                        wfExpandUrl( $this->file->getArchiveUrl( $this->archiveName ) ) ) );
@@ -79,16 +79,16 @@ class FileRevertForm {
                        }
                        return;
                }
-               
+
                // Show the form
-               $this->showForm();              
+               $this->showForm();
        }
-       
+
        /**
         * Show the confirmation form
         */
        protected function showForm() {
-               global $wgOut, $wgUser, $wgRequest, $wgLang, $wgContLang;
+               global $wgOut, $wgUser, $wgLang, $wgContLang;
                $timestamp = $this->getTimestamp();
 
                $form  = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction() ) );
@@ -103,10 +103,10 @@ class FileRevertForm {
                $form .= '<p>' . Xml::submitButton( wfMsg( 'filerevert-submit' ) ) . '</p>';
                $form .= '</fieldset>';
                $form .= '</form>';
-               
-               $wgOut->addHtml( $form );
+
+               $wgOut->addHTML( $form );
        }
-       
+
        /**
         * Set headers, titles and other bits
         */
@@ -114,9 +114,18 @@ class FileRevertForm {
                global $wgOut, $wgUser;
                $wgOut->setPageTitle( wfMsg( 'filerevert', $this->title->getText() ) );
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
-               $wgOut->setSubtitle( wfMsg( 'filerevert-backlink', $wgUser->getSkin()->makeKnownLinkObj( $this->title ) ) );
+               $wgOut->setSubtitle( wfMsg(
+                       'filerevert-backlink',
+                       $wgUser->getSkin()->link(
+                               $this->title,
+                               null,
+                               array(),
+                               array(),
+                               array( 'known', 'noclasses' )
+                       )
+               ) );
        }
-       
+
        /**
         * Is the provided `oldimage` value valid?
         *
@@ -127,7 +136,7 @@ class FileRevertForm {
                        && strpos( $this->archiveName, '/' ) === false
                        && strpos( $this->archiveName, '\\' ) === false;
        }
-       
+
        /**
         * Does the provided `oldimage` value correspond
         * to an existing, local, old version of this file?
@@ -137,7 +146,7 @@ class FileRevertForm {
        protected function haveOldVersion() {
                return $this->getOldFile()->exists();
        }
-       
+
        /**
         * Prepare the form action
         *
@@ -149,7 +158,7 @@ class FileRevertForm {
                $q[] = 'oldimage=' . urlencode( $this->archiveName );
                return $this->title->getLocalUrl( implode( '&', $q ) );
        }
-       
+
        /**
         * Extract the timestamp of the old version
         *