Migrate remaining usages of Title::userCan() to PermissionManager
[lhc/web/wiklou.git] / includes / specials / SpecialUpload.php
index e52945a..dcc35fc 100644 (file)
@@ -116,7 +116,7 @@ class SpecialUpload extends SpecialPage {
                $this->mForReUpload = $request->getBool( 'wpForReUpload' ); // updating a file
 
                $commentDefault = '';
-               $commentMsg = wfMessage( 'upload-default-description' )->inContentLanguage();
+               $commentMsg = $this->msg( 'upload-default-description' )->inContentLanguage();
                if ( !$this->mForReUpload && !$commentMsg->isDisabled() ) {
                        $commentDefault = $commentMsg->plain();
                }
@@ -146,8 +146,7 @@ class SpecialUpload extends SpecialPage {
        }
 
        /**
-        * Special page entry point
-        * @param string $par
+        * @param string|null $par
         * @throws ErrorPageError
         * @throws Exception
         * @throws FatalError
@@ -177,7 +176,7 @@ class SpecialUpload extends SpecialPage {
                }
 
                # Check blocks
-               if ( $user->isBlocked() ) {
+               if ( $user->isBlockedFromUpload() ) {
                        throw new UserBlockedError( $user->getBlock() );
                }
 
@@ -192,11 +191,9 @@ class SpecialUpload extends SpecialPage {
                $this->loadRequest();
 
                # Unsave the temporary file in case this was a cancelled upload
-               if ( $this->mCancelUpload ) {
-                       if ( !$this->unsaveUploadedFile() ) {
-                               # Something went wrong, so unsaveUploadedFile showed a warning
-                               return;
-                       }
+               if ( $this->mCancelUpload && !$this->unsaveUploadedFile() ) {
+                       # Something went wrong, so unsaveUploadedFile showed a warning
+                       return;
                }
 
                # Process upload or show a form
@@ -324,7 +321,13 @@ class SpecialUpload extends SpecialPage {
                                );
                                $link = $this->msg( $user->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted' )
                                        ->rawParams( $restorelink )->parseAsBlock();
-                               $this->getOutput()->addHTML( "<div id=\"contentSub2\">{$link}</div>" );
+                               $this->getOutput()->addHTML(
+                                       Html::rawElement(
+                                               'div',
+                                               [ 'id' => 'contentSub2' ],
+                                               $link
+                                       )
+                               );
                        }
                }
        }
@@ -401,12 +404,12 @@ class SpecialUpload extends SpecialPage {
                        } elseif ( $warning == 'no-change' ) {
                                $file = $args;
                                $filename = $file->getTitle()->getPrefixedText();
-                               $msg = "\t<li>" . wfMessage( 'fileexists-no-change', $filename )->parse() . "</li>\n";
+                               $msg = "\t<li>" . $this->msg( 'fileexists-no-change', $filename )->parse() . "</li>\n";
                        } elseif ( $warning == 'duplicate-version' ) {
                                $file = $args[0];
                                $count = count( $args );
                                $filename = $file->getTitle()->getPrefixedText();
-                               $message = wfMessage( 'fileexists-duplicate-version' )
+                               $message = $this->msg( 'fileexists-duplicate-version' )
                                        ->params( $filename )
                                        ->numParams( $count );
                                $msg = "\t<li>" . $message->parse() . "</li>\n";
@@ -415,14 +418,14 @@ class SpecialUpload extends SpecialPage {
                                $ltitle = SpecialPage::getTitleFor( 'Log' );
                                $llink = $linkRenderer->makeKnownLink(
                                        $ltitle,
-                                       wfMessage( 'deletionlog' )->text(),
+                                       $this->msg( 'deletionlog' )->text(),
                                        [],
                                        [
                                                'type' => 'delete',
                                                'page' => Title::makeTitle( NS_FILE, $args )->getPrefixedText(),
                                        ]
                                );
-                               $msg = "\t<li>" . wfMessage( 'filewasdeleted' )->rawParams( $llink )->parse() . "</li>\n";
+                               $msg = "\t<li>" . $this->msg( 'filewasdeleted' )->rawParams( $llink )->parse() . "</li>\n";
                        } elseif ( $warning == 'duplicate' ) {
                                $msg = $this->getDupeWarning( $args );
                        } elseif ( $warning == 'duplicate-archive' ) {
@@ -483,7 +486,7 @@ class SpecialUpload extends SpecialPage {
                // Fetch the file if required
                $status = $this->mUpload->fetchFile();
                if ( !$status->isOK() ) {
-                       $this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) );
+                       $this->showUploadError( $this->getOutput()->parseAsInterface( $status->getWikiText() ) );
 
                        return;
                }
@@ -553,7 +556,9 @@ class SpecialUpload extends SpecialPage {
                        $changeTagsStatus = ChangeTags::canAddTagsAccompanyingChange(
                                $changeTags, $this->getUser() );
                        if ( !$changeTagsStatus->isOK() ) {
-                               $this->showUploadError( $this->getOutput()->parse( $changeTagsStatus->getWikiText() ) );
+                               $this->showUploadError( $this->getOutput()->parseAsInterface(
+                                       $changeTagsStatus->getWikiText()
+                               ) );
 
                                return;
                        }
@@ -568,7 +573,9 @@ class SpecialUpload extends SpecialPage {
                );
 
                if ( !$status->isGood() ) {
-                       $this->showRecoverableUploadError( $this->getOutput()->parse( $status->getWikiText() ) );
+                       $this->showRecoverableUploadError(
+                               $this->getOutput()->parseAsInterface( $status->getWikiText() )
+                       );
 
                        return;
                }
@@ -761,7 +768,11 @@ class SpecialUpload extends SpecialPage {
                }
                $success = $this->mUpload->unsaveUploadedFile();
                if ( !$success ) {
-                       $this->getOutput()->showFileDeleteError( $this->mUpload->getTempPath() );
+                       $this->getOutput()->showFatalError(
+                               $this->msg( 'filedeleteerror' )
+                                       ->params( $this->mUpload->getTempPath() )
+                                       ->escaped()
+                       );
 
                        return false;
                } else {