Merge "Rewrite pref cleanup script"
[lhc/web/wiklou.git] / includes / specials / SpecialUpload.php
index 59f9796..53b7a2f 100644 (file)
@@ -344,15 +344,16 @@ class SpecialUpload extends SpecialPage {
                $stashStatus = $this->mUpload->tryStashFile( $this->getUser() );
                if ( $stashStatus->isGood() ) {
                        $sessionKey = $stashStatus->getValue()->getFileKey();
+                       $uploadWarning = 'upload-tryagain';
                } else {
                        $sessionKey = null;
-                       // TODO Add a warning message about the failure to stash here?
+                       $uploadWarning = 'upload-tryagain-nostash';
                }
                $message = '<h2>' . $this->msg( 'uploaderror' )->escaped() . "</h2>\n" .
                        '<div class="error">' . $message . "</div>\n";
 
                $form = $this->getUploadForm( $message, $sessionKey );
-               $form->setSubmitText( $this->msg( 'upload-tryagain' )->escaped() );
+               $form->setSubmitText( $this->msg( $uploadWarning )->escaped() );
                $this->showUploadForm( $form );
        }
 
@@ -379,9 +380,10 @@ class SpecialUpload extends SpecialPage {
                $stashStatus = $this->mUpload->tryStashFile( $this->getUser() );
                if ( $stashStatus->isGood() ) {
                        $sessionKey = $stashStatus->getValue()->getFileKey();
+                       $uploadWarning = 'uploadwarning-text';
                } else {
                        $sessionKey = null;
-                       // TODO Add a warning message about the failure to stash here?
+                       $uploadWarning = 'uploadwarning-text-nostash';
                }
 
                // Add styles for the warning, reused from the live preview
@@ -443,7 +445,7 @@ class SpecialUpload extends SpecialPage {
                        $warningHtml .= $msg;
                }
                $warningHtml .= "</ul></div>\n";
-               $warningHtml .= $this->msg( 'uploadwarning-text' )->parseAsBlock();
+               $warningHtml .= $this->msg( $uploadWarning )->parseAsBlock();
 
                $form = $this->getUploadForm( $warningHtml, $sessionKey, /* $hideIgnoreWarning */ true );
                $form->setSubmitText( $this->msg( 'upload-tryagain' )->text() );
@@ -610,25 +612,23 @@ class SpecialUpload extends SpecialPage {
                        }
                }
 
+               $licenseText = '';
+               if ( $license !== '' ) {
+                       $licenseText = '== ' . $msg['license-header'] . " ==\n{{" . $license . "}}\n";
+               }
+
+               $pageText = $comment == '' ? '' : '== ' . $msg['filedesc'] . " ==\n" . $comment . "\n";
                if ( $config->get( 'UseCopyrightUpload' ) ) {
-                       $licensetxt = '';
-                       if ( $license != '' ) {
-                               $licensetxt = '== ' . $msg['license-header'] . " ==\n" . '{{' . $license . '}}' . "\n";
-                       }
-                       $pageText = '== ' . $msg['filedesc'] . " ==\n" . $comment . "\n" .
-                               '== ' . $msg['filestatus'] . " ==\n" . $copyStatus . "\n" .
-                               "$licensetxt" .
-                               '== ' . $msg['filesource'] . " ==\n" . $source;
+                       $pageText .= '== ' . $msg['filestatus'] . " ==\n" . $copyStatus . "\n";
+                       $pageText .= $licenseText;
+                       $pageText .= '== ' . $msg['filesource'] . " ==\n" . $source;
                } else {
-                       if ( $license != '' ) {
-                               $filedesc = $comment == '' ? '' : '== ' . $msg['filedesc'] . " ==\n" . $comment . "\n";
-                                       $pageText = $filedesc .
-                                       '== ' . $msg['license-header'] . " ==\n" . '{{' . $license . '}}' . "\n";
-                       } else {
-                               $pageText = $comment;
-                       }
+                       $pageText .= $licenseText;
                }
 
+               // allow extensions to modify the content
+               Hooks::run( 'UploadForm:getInitialPageText', [ &$pageText, $msg, $config ] );
+
                return $pageText;
        }