Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -1448,7 +1448,7 @@ |
1449 | 1449 | |
1450 | 1450 | 'SpecialUploadComplete': Called after successfully uploading a file from |
1451 | 1451 | Special:Upload |
1452 | | -$form: The UploadForm object |
| 1452 | +$form: The SpecialUpload object |
1453 | 1453 | |
1454 | 1454 | 'SpecialVersionExtensionTypes': called when generating the extensions credits, |
1455 | 1455 | use this to change the tables headers |
— | — | @@ -1493,17 +1493,21 @@ |
1494 | 1494 | $user: user that watched |
1495 | 1495 | $article: article object that was watched |
1496 | 1496 | |
1497 | | -'UploadForm:initial': before the upload form is generated |
1498 | | -$form: UploadForm object |
1499 | | -You might set the member-variables $uploadFormTextTop and |
1500 | | -$uploadFormTextAfterSummary to inject text (HTML) either before |
1501 | | -or after the editform. |
| 1497 | +'UploadCreateFromRequest': when UploadBase::createFromRequest has been called |
| 1498 | +string $type: the requested upload type |
| 1499 | +&$className: the class name of the Upload instance to be created |
1502 | 1500 | |
1503 | | -'UploadForm:BeforeProcessing': at the beginning of processUpload() |
1504 | | -$form: UploadForm object |
1505 | | -Lets you poke at member variables like $mUploadDescription before the |
1506 | | -file is saved. |
| 1501 | +'UploadComplete': when Upload completes an upload |
| 1502 | +&$upload: an UploadBase child instance |
1507 | 1503 | |
| 1504 | +'UploadFormInitDescriptor': after the descriptor for the upload form as been |
| 1505 | +assembled |
| 1506 | +array $descriptor: the HTMLForm descriptor |
| 1507 | + |
| 1508 | +'UploadFormSourceDescriptors': after the standard source inputs have been |
| 1509 | +added to the descriptor |
| 1510 | +array $descriptor: the HTMLForm descriptor |
| 1511 | + |
1508 | 1512 | 'UploadVerification': additional chances to reject an uploaded file |
1509 | 1513 | string $saveName: destination file name |
1510 | 1514 | string $tempName: filesystem path to the temporary file for checks |
Index: trunk/phase3/includes/upload/UploadFromStash.php |
— | — | @@ -46,13 +46,13 @@ |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function initializeFromRequest( &$request ) { |
50 | | - $sessionKey = $request->getInt( 'wpSessionKey' ); |
| 50 | + $this->mSessionKey = $request->getInt( 'wpSessionKey' ); |
51 | 51 | $sessionData = $request->getSessionData('wsUploadData'); |
52 | 52 | |
53 | 53 | $desiredDestName = $request->getText( 'wpDestFile' ); |
54 | 54 | if( !$desiredDestName ) |
55 | 55 | $desiredDestName = $request->getText( 'wpUploadFile' ); |
56 | | - return $this->initialize( $desiredDestName, $sessionData[$sessionKey], false ); |
| 56 | + return $this->initialize( $desiredDestName, $sessionData[$this->mSessionKey], false ); |
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
— | — | @@ -62,11 +62,14 @@ |
63 | 63 | return true; |
64 | 64 | } |
65 | 65 | |
| 66 | + |
66 | 67 | /** |
67 | | - * We're here from "ignore warnings anyway" so return just OK |
| 68 | + * There is no need to stash the image twice |
68 | 69 | */ |
69 | | - public function checkWarnings() { |
70 | | - return array(); |
| 70 | + public function stashSession() { |
| 71 | + if ( !empty( $this->mSessionKey ) ) |
| 72 | + return $this->mSessionKey; |
| 73 | + return parent::stashSession(); |
71 | 74 | } |
72 | 75 | |
73 | 76 | /** |
Index: trunk/phase3/includes/upload/UploadFromUrl.php |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | public function initializeFromRequest( &$request ) { |
66 | 66 | $desiredDestName = $request->getText( 'wpDestFile' ); |
67 | 67 | if( !$desiredDestName ) |
68 | | - $desiredDestName = $request->getText( 'wpUploadFile' ); |
| 68 | + $desiredDestName = $request->getText( 'wpUploadFileURL' ); |
69 | 69 | return $this->initialize( |
70 | 70 | $desiredDestName, |
71 | 71 | $request->getVal( 'wpUploadFileURL' ), |
Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -76,10 +76,16 @@ |
77 | 77 | |
78 | 78 | // Get the upload class |
79 | 79 | $type = ucfirst( $type ); |
80 | | - $className = 'UploadFrom' . $type; |
81 | | - wfDebug( __METHOD__ . ": class name: $className\n" ); |
82 | | - if( !in_array( $type, self::$uploadHandlers ) ) |
83 | | - return null; |
| 80 | + |
| 81 | + // Give hooks the chance to handle this request |
| 82 | + $className = null; |
| 83 | + wfRunHooks( 'UploadCreateFromRequest', array( $type, &$className ) ); |
| 84 | + if ( is_null( $className ) ) { |
| 85 | + $className = 'UploadFrom' . $type; |
| 86 | + wfDebug( __METHOD__ . ": class name: $className\n" ); |
| 87 | + if( !in_array( $type, self::$uploadHandlers ) ) |
| 88 | + return null; |
| 89 | + } |
84 | 90 | |
85 | 91 | // Check whether this upload class is enabled |
86 | 92 | if( !call_user_func( array( $className, 'isEnabled' ) ) ) |
Index: trunk/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -56,7 +56,9 @@ |
57 | 57 | $this->mRequest = $request; |
58 | 58 | $this->mSourceType = $request->getVal( 'wpSourceType', 'file' ); |
59 | 59 | $this->mUpload = UploadBase::createFromRequest( $request ); |
60 | | - $this->mUploadClicked = $request->getCheck( 'wpUpload' ) && $request->wasPosted(); |
| 60 | + $this->mUploadClicked = $request->wasPosted() |
| 61 | + && ( $request->getCheck( 'wpUpload' ) |
| 62 | + || $request->getCheck( 'wpUploadIgnoreWarning' ) ); |
61 | 63 | |
62 | 64 | // Guess the desired name from the filename if not provided |
63 | 65 | $this->mDesiredDestName = $request->getText( 'wpDestFile' ); |
— | — | @@ -66,7 +68,8 @@ |
67 | 69 | $this->mLicense = $request->getText( 'wpLicense' ); |
68 | 70 | |
69 | 71 | |
70 | | - $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' ); |
| 72 | + $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' ) |
| 73 | + || $request->getCheck( 'wpUploadIgnoreWarning' ); |
71 | 74 | $this->mWatchthis = $request->getBool( 'wpWatchthis' ); |
72 | 75 | $this->mCopyrightStatus = $request->getText( 'wpUploadCopyStatus' ); |
73 | 76 | $this->mCopyrightSource = $request->getText( 'wpUploadSource' ); |
— | — | @@ -182,11 +185,16 @@ |
183 | 186 | * @param string $sessionKey Session key in case this is a stashed upload |
184 | 187 | * @return UploadForm |
185 | 188 | */ |
186 | | - protected function getUploadForm( $message = '', $sessionKey = '' ) { |
| 189 | + protected function getUploadForm( $message = '', $sessionKey = '', $hideIgnoreWarning = false ) { |
187 | 190 | global $wgOut; |
188 | 191 | |
189 | 192 | # Initialize form |
190 | | - $form = new UploadForm( $this->watchCheck(), $this->mForReUpload, $sessionKey ); |
| 193 | + $form = new UploadForm( array( |
| 194 | + 'watch' => $this->watchCheck(), |
| 195 | + 'forreupload' => $this->mForReUpload, |
| 196 | + 'sessionkey' => $sessionKey, |
| 197 | + 'hideignorewarning' => $hideIgnoreWarning, |
| 198 | + ) ); |
191 | 199 | $form->setTitle( $this->getTitle() ); |
192 | 200 | |
193 | 201 | # Check the token, but only if necessary |
— | — | @@ -251,7 +259,10 @@ |
252 | 260 | $sessionKey = $this->mUpload->stashSession(); |
253 | 261 | $message = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" . |
254 | 262 | '<div class="error">' . $message . "</div>\n"; |
255 | | - $this->showUploadForm( $this->getUploadForm( $message, $sessionKey ) ); |
| 263 | + |
| 264 | + $form = $this->getUploadForm( $message, $sessionKey ); |
| 265 | + $form->setSubmitText( wfMsg( 'upload-tryagain' ) ); |
| 266 | + $this->showUploadForm( $form ); |
256 | 267 | } |
257 | 268 | /** |
258 | 269 | * Stashes the upload, shows the main form, but adds an "continue anyway button" |
— | — | @@ -286,10 +297,12 @@ |
287 | 298 | } |
288 | 299 | $warningHtml .= $msg; |
289 | 300 | } |
290 | | - $warningHtml .= '</ul>'; |
| 301 | + $warningHtml .= "</ul>\n"; |
| 302 | + $warningHtml .= wfMsgExt( 'uploadwarning-text', 'parse' ); |
291 | 303 | |
292 | | - $form = $this->getUploadForm( $warningHtml, $sessionKey ); |
293 | | - $form->setSubmitText( wfMsg( 'ignorewarning' ) ); |
| 304 | + $form = $this->getUploadForm( $warningHtml, $sessionKey, /* $hideIgnoreWarning */ true ); |
| 305 | + $form->setSubmitText( wfMsg( 'upload-tryagain' ) ); |
| 306 | + $form->addButton( 'wpUploadIgnoreWarning', wfMsg( 'ignorewarning' ) ); |
294 | 307 | $form->addButton( 'wpCancelUpload', wfMsg( 'reuploaddesc' ) ); |
295 | 308 | |
296 | 309 | $this->showUploadForm( $form ); |
— | — | @@ -621,14 +634,18 @@ |
622 | 635 | protected $mWatch; |
623 | 636 | protected $mForReUpload; |
624 | 637 | protected $mSessionKey; |
| 638 | + protected $mHideIgnoreWarning; |
| 639 | + |
625 | 640 | protected $mSourceIds; |
626 | 641 | |
627 | | - public function __construct( $watch, $forReUpload = false, $sessionKey = '' ) { |
| 642 | + public function __construct( $options = array() ) { |
628 | 643 | global $wgLang; |
629 | 644 | |
630 | | - $this->mWatch = $watch; |
631 | | - $this->mForReUpload = $forReUpload; |
632 | | - $this->mSessionKey = $sessionKey; |
| 645 | + $this->mWatch = !empty( $options['watch'] ); |
| 646 | + $this->mForReUpload = !empty( $options['forreupload'] ); |
| 647 | + $this->mSessionKey = isset( $options['sessionkey'] ) |
| 648 | + ? $options['sessionkey'] : ''; |
| 649 | + $this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] ); |
633 | 650 | |
634 | 651 | $sourceDescriptor = $this->getSourceSection(); |
635 | 652 | $descriptor = $sourceDescriptor |
— | — | @@ -841,14 +858,16 @@ |
842 | 859 | 'id' => 'wpWatchthis', |
843 | 860 | 'label-message' => 'watchthisupload', |
844 | 861 | 'section' => 'options', |
845 | | - ), |
846 | | - 'IgnoreWarning' => array( |
| 862 | + ) |
| 863 | + ); |
| 864 | + if ( !$this->mHideIgnoreWarning ) { |
| 865 | + $descriptor['IgnoreWarning'] = array( |
847 | 866 | 'type' => 'check', |
848 | 867 | 'id' => 'wpIgnoreWarning', |
849 | 868 | 'label-message' => 'ignorewarnings', |
850 | 869 | 'section' => 'options', |
851 | | - ), |
852 | | - ); |
| 870 | + ); |
| 871 | + } |
853 | 872 | |
854 | 873 | return $descriptor; |
855 | 874 | |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2040,6 +2040,7 @@ |
2041 | 2041 | 'upload' => 'Upload file', |
2042 | 2042 | 'uploadbtn' => 'Upload file', |
2043 | 2043 | 'reuploaddesc' => 'Cancel upload and return to the upload form', |
| 2044 | +'upload-tryagain' => 'Submit modified file description', |
2044 | 2045 | 'uploadnologin' => 'Not logged in', |
2045 | 2046 | 'uploadnologintext' => 'You must be [[Special:UserLogin|logged in]] to upload files.', |
2046 | 2047 | 'upload_directory_missing' => 'The upload directory ($1) is missing and could not be created by the webserver.', |
— | — | @@ -2115,6 +2116,7 @@ |
2116 | 2117 | You should check that file's deletion history before proceeding to re-upload it.", |
2117 | 2118 | 'successfulupload' => 'Successful upload', |
2118 | 2119 | 'uploadwarning' => 'Upload warning', |
| 2120 | +'uploadwarning-text' => 'Please modify the file description below and try again.', |
2119 | 2121 | 'savefile' => 'Save file', |
2120 | 2122 | 'uploadedimage' => 'uploaded "[[$1]]"', |
2121 | 2123 | 'overwroteimage' => 'uploaded a new version of "[[$1]]"', |