| Index: trunk/extensions/MultiUpload/MultiUpload.body.php |
| — | — | @@ -13,7 +13,7 @@ |
| 14 | 14 | public $mUploadHasBeenShown; |
| 15 | 15 | public $mSessionKeys; |
| 16 | 16 | |
| 17 | | - // status messagse for multiple files |
| | 17 | + // status messages for multiple files |
| 18 | 18 | public $mWarnings; |
| 19 | 19 | public $mSuccesses; |
| 20 | 20 | public $mErrors; |
| — | — | @@ -24,11 +24,9 @@ |
| 25 | 25 | * @param WebRequest $request Data posted. |
| 26 | 26 | */ |
| 27 | 27 | public function __construct( $request = null ) { |
| 28 | | - global $wgRequest; |
| 29 | | - |
| 30 | 28 | SpecialPage::__construct( 'MultipleUpload', 'upload' ); |
| 31 | 29 | |
| 32 | | - $this->loadRequest( is_null( $request ) ? $wgRequest : $request ); |
| | 30 | + $this->loadRequest(); |
| 33 | 31 | $this->mUploadHasBeenShown = false; |
| 34 | 32 | $this->mSessionKeys = array(); |
| 35 | 33 | $this->mWarnings = array(); |
| — | — | @@ -37,12 +35,33 @@ |
| 38 | 36 | } |
| 39 | 37 | |
| 40 | 38 | /** |
| | 39 | + * ShoutWiki change -- gets and returns the amount of files a user can |
| | 40 | + * upload at once. |
| | 41 | + * |
| | 42 | + * @return Integer: amount of files the user can upload at once |
| | 43 | + */ |
| | 44 | + public static function getMaxUploadFiles() { |
| | 45 | + global $wgUser, $wgMaxUploadFiles; |
| | 46 | + $groups = $wgUser->getEffectiveGroups(); |
| | 47 | + if( in_array( 'staff', $groups ) ) { |
| | 48 | + $wgMaxUploadFiles = 40; |
| | 49 | + } elseif( in_array( 'sysop', $groups ) ) { |
| | 50 | + $wgMaxUploadFiles = 20; |
| | 51 | + } elseif( in_array( 'autoconfirmed', $groups ) ) { |
| | 52 | + $wgMaxUploadFiles = 10; |
| | 53 | + } else { |
| | 54 | + $wgMaxUploadFiles = 5; |
| | 55 | + } |
| | 56 | + return $wgMaxUploadFiles; |
| | 57 | + } |
| | 58 | + |
| | 59 | + /** |
| 41 | 60 | * Initialize instance variables from request and create an Upload handler |
| 42 | 61 | * |
| 43 | 62 | * @param WebRequest $request The request to extract variables from |
| 44 | 63 | */ |
| 45 | | - protected function loadRequest( $request ) { |
| 46 | | - global $wgUser, $wgMaxUploadFiles; |
| | 64 | + protected function loadRequest() { |
| | 65 | + $request = $this->getRequest(); |
| 47 | 66 | |
| 48 | 67 | // let's make the parent happy |
| 49 | 68 | wfSuppressWarnings(); |
| — | — | @@ -50,16 +69,16 @@ |
| 51 | 70 | wfRestoreWarnings(); |
| 52 | 71 | // Guess the desired name from the filename if not provided |
| 53 | 72 | $this->mDesiredDestNames = array(); |
| 54 | | - $this->mUploads = array(); |
| | 73 | + $this->mUploads = array(); |
| 55 | 74 | |
| 56 | 75 | // deal with session keys, if we have some pick the first one, for now |
| 57 | 76 | $vals = $request->getValues(); |
| 58 | | - $fromsession = false; |
| | 77 | + $fromSession = false; |
| 59 | 78 | foreach ( $vals as $k => $v ) { |
| 60 | | - if ( preg_match( "@^wpSessionKey@", $k ) ) { |
| | 79 | + if ( preg_match( '@^wpSessionKey@', $k ) ) { |
| 61 | 80 | $request->setVal( 'wpSessionKey', $v ); |
| 62 | | - $fromsession = true; |
| 63 | | - $filenum = preg_replace( "@wpSessionKey@", '', $k ); |
| | 81 | + $fromSession = true; |
| | 82 | + $filenum = preg_replace( '@wpSessionKey@', '', $k ); |
| 64 | 83 | $request->setVal( 'wpDestFile', $request->getVal( 'wpDestFile' . $filenum ) ); |
| 65 | 84 | $up = UploadBase::createFromRequest( $request ); |
| 66 | 85 | $this->mUploads[] = $up; |
| — | — | @@ -73,8 +92,8 @@ |
| 74 | 93 | && ( $request->getCheck( 'wpUpload' ) |
| 75 | 94 | || $request->getCheck( 'wpUploadIgnoreWarning' ) ); |
| 76 | 95 | |
| 77 | | - if ( !$fromsession ) { |
| 78 | | - for ( $i = 0; $i < $wgMaxUploadFiles; $i++ ) { |
| | 96 | + if ( !$fromSession ) { |
| | 97 | + for ( $i = 0; $i < MultipleUpload::getMaxUploadFiles(); $i++ ) { |
| 79 | 98 | $this->mDesiredDestNames[$i] = $request->getText( 'wpDestFile'. $i ); |
| 80 | 99 | if( !$this->mDesiredDestNames[$i] && $request->getFileName( 'wpUploadFile' . $i ) !== null ) { |
| 81 | 100 | $this->mDesiredDestNames[$i] = $request->getFileName( 'wpUploadFile' . $i ); |
| — | — | @@ -88,13 +107,13 @@ |
| 89 | 108 | $_FILES['wpUploadFile'] = $_FILES['wpUploadFile' . $i]; |
| 90 | 109 | wfRestoreWarnings(); |
| 91 | 110 | $up = UploadBase::createFromRequest( $request ); |
| 92 | | - if ($up) { |
| | 111 | + if ( $up ) { |
| 93 | 112 | $this->mUploads[] = $up; |
| 94 | 113 | } |
| 95 | 114 | } |
| 96 | 115 | } |
| 97 | 116 | $this->mDesiredDestName = $this->mDesiredDestNames[0]; |
| 98 | | - $this->mUpload= $this->mUploads[0]; |
| | 117 | + $this->mUpload = $this->mUploads[0]; |
| 99 | 118 | } |
| 100 | 119 | |
| 101 | 120 | function showUploadForm( $form ) { |
| — | — | @@ -113,8 +132,6 @@ |
| 114 | 133 | * @return UploadForm |
| 115 | 134 | */ |
| 116 | 135 | protected function getUploadForm( $message = '', $sessionKeys = array(), $hideIgnoreWarning = false ) { |
| 117 | | - global $wgOut, $wgMaxUploadFiles; |
| 118 | | - |
| 119 | 136 | # Initialize form |
| 120 | 137 | $options = array( |
| 121 | 138 | 'watch' => $this->getWatchCheck(), |
| — | — | @@ -125,9 +142,9 @@ |
| 126 | 143 | 'textaftersummary' => $this->uploadFormTextAfterSummary, |
| 127 | 144 | ); |
| 128 | 145 | foreach ( $this->mSessionKeys as $f => $key ) { |
| 129 | | - $options['sessionkey'. $f] = $key; |
| | 146 | + $options['sessionkey' . $f] = $key; |
| 130 | 147 | } |
| 131 | | - for ( $i = 0; $i < $wgMaxUploadFiles; $i++ ) { |
| | 148 | + for ( $i = 0; $i < MultipleUpload::getMaxUploadFiles(); $i++ ) { |
| 132 | 149 | $options['destfile' . $i] = $this->mDesiredDestNames[$i]; |
| 133 | 150 | } |
| 134 | 151 | $form = new MultiUploadForm( $options ); |
| — | — | @@ -150,7 +167,7 @@ |
| 151 | 168 | $uploadFooter = wfMsgNoTrans( 'uploadfooter' ); |
| 152 | 169 | if ( $uploadFooter != '-' && !wfEmptyMsg( 'uploadfooter', $uploadFooter ) ) { |
| 153 | 170 | $form->addPostText( '<div id="mw-upload-footer-message">' |
| 154 | | - . $wgOut->parse( $uploadFooter ) . "</div>\n" ); |
| | 171 | + . $this->getOutput()->parse( $uploadFooter ) . "</div>\n" ); |
| 155 | 172 | } |
| 156 | 173 | |
| 157 | 174 | return $form; |
| — | — | @@ -160,35 +177,33 @@ |
| 161 | 178 | * Shows the "view X deleted revivions link" |
| 162 | 179 | */ |
| 163 | 180 | protected function showViewDeletedLinks() { |
| 164 | | - global $wgMaxUploadFiles; |
| 165 | | - for ( $i = 0; $i < $wgMaxUploadFiles; $i++ ) { |
| | 181 | + for ( $i = 0; $i < MultipleUpload::getMaxUploadFiles(); $i++ ) { |
| 166 | 182 | $this->showViewDeletedLinksInner( $this->mDesiredDestNames[$i] ); |
| 167 | 183 | } |
| 168 | 184 | } |
| 169 | 185 | |
| 170 | 186 | protected function showViewDeletedLinksInner( $name ) { |
| 171 | | - global $wgOut, $wgUser; |
| 172 | | - |
| 173 | 187 | $title = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName ); |
| 174 | 188 | // Show a subtitle link to deleted revisions (to sysops et al only) |
| 175 | 189 | if( $title instanceof Title ) { |
| 176 | 190 | $count = $title->isDeleted(); |
| 177 | | - if ( $count > 0 && $wgUser->isAllowed( 'deletedhistory' ) ) { |
| | 191 | + $user = $this->getUser(); |
| | 192 | + if ( $count > 0 && $user->isAllowed( 'deletedhistory' ) ) { |
| 178 | 193 | $link = wfMsgExt( |
| 179 | | - $wgUser->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted', |
| | 194 | + $user->isAllowed( 'delete' ) ? 'thisisdeleted' : 'viewdeleted', |
| 180 | 195 | array( 'parse', 'replaceafter' ), |
| 181 | | - $wgUser->getSkin()->linkKnown( |
| | 196 | + Linker::linkKnown( |
| 182 | 197 | SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedText() ), |
| 183 | 198 | wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $count ) |
| 184 | 199 | ) |
| 185 | 200 | ); |
| 186 | | - $wgOut->addHTML( "<div id=\"contentSub2\">{$link}</div>" ); |
| | 201 | + $this->getOutput()->addHTML( "<div id=\"contentSub2\">{$link}</div>" ); |
| 187 | 202 | } |
| 188 | 203 | } |
| 189 | 204 | |
| 190 | 205 | // Show the relevant lines from deletion log (for still deleted files only) |
| 191 | 206 | if( $title instanceof Title && $title->isDeletedQuick() && !$title->exists() ) { |
| 192 | | - $this->showDeletionLog( $wgOut, $title->getPrefixedText() ); |
| | 207 | + $this->showDeletionLog( $this->getOutput(), $title->getPrefixedText() ); |
| 193 | 208 | } |
| 194 | 209 | } |
| 195 | 210 | |
| — | — | @@ -201,8 +216,6 @@ |
| 202 | 217 | * warnings and the should continue processing like there was no warning |
| 203 | 218 | */ |
| 204 | 219 | protected function showUploadWarning( $warnings ) { |
| 205 | | - global $wgUser; |
| 206 | | - |
| 207 | 220 | # If there are no warnings, or warnings we can ignore, return early. |
| 208 | 221 | # mDestWarningAck is set when some javascript has shown the warning |
| 209 | 222 | # to the user. mForReUpload is set when the user clicks the "upload a |
| — | — | @@ -216,8 +229,6 @@ |
| 217 | 230 | |
| 218 | 231 | $sessionKey = $this->mUpload->stashSession(); |
| 219 | 232 | |
| 220 | | - $sk = $wgUser->getSkin(); |
| 221 | | - |
| 222 | 233 | $warningHtml = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" |
| 223 | 234 | . '<ul class="warning">'; |
| 224 | 235 | foreach( $warnings as $warning => $args ) { |
| — | — | @@ -257,12 +268,12 @@ |
| 258 | 269 | * @param $message String |
| 259 | 270 | */ |
| 260 | 271 | protected function showUploadError( $message ) { |
| 261 | | - $err ='<ul><li>'; |
| | 272 | + $err = '<ul><li>'; |
| 262 | 273 | $file = $this->mLocalFile; |
| 263 | 274 | if ( $file ) { |
| 264 | 275 | $t = $this->mLocalFile->getTitle(); |
| 265 | 276 | if ( $t ) { |
| 266 | | - $err .= $t->getFullText() . ":"; |
| | 277 | + $err .= $t->getFullText() . ':'; |
| 267 | 278 | } |
| 268 | 279 | } |
| 269 | 280 | $err .= $message . "</li></ul>\n"; |
| — | — | @@ -274,38 +285,42 @@ |
| 275 | 286 | * Checks are made in SpecialUpload::execute() |
| 276 | 287 | */ |
| 277 | 288 | protected function processUpload() { |
| 278 | | - global $wgMaxUploadFiles, $wgOut; |
| 279 | | - |
| 280 | | - for ( $i = 0; $i < $wgMaxUploadFiles; $i++ ) { |
| | 289 | + for ( $i = 0; $i < MultipleUpload::getMaxUploadFiles(); $i++ ) { |
| 281 | 290 | if ( isset( $this->mUploads[$i] ) ) { |
| 282 | 291 | $this->mUpload = $this->mUploads[$i]; |
| 283 | | - $this->mUploadSuccessful = false; // reset |
| 284 | | - parent::processUpload(); |
| 285 | | - if ( $this->mUploadSuccessful ) { |
| 286 | | - $this->mSuccesses[] = "<ul><li><a href='" . $this->mLocalFile->getTitle()->getFullURL() . |
| 287 | | - "' target='new'>{$this->mLocalFile->getTitle()->getFullText()}: " . |
| 288 | | - wfMsg( 'multiupload-fileuploaded' ) . '</a></li></ul>'; |
| | 292 | + $title = $this->mUpload->getTitle(); |
| | 293 | + if ( !empty( $title ) ) { |
| | 294 | + $this->mUploadSuccessful = false; // reset |
| | 295 | + parent::processUpload(); |
| | 296 | + if ( $this->mUploadSuccessful ) { |
| | 297 | + $this->mSuccesses[] = "<ul><li><a href='" . $this->mLocalFile->getTitle()->getFullURL() . |
| | 298 | + "' target='new'>{$this->mLocalFile->getTitle()->getFullText()}: " . |
| | 299 | + wfMsg( 'multiupload-fileuploaded' ) . '</a></li></ul>'; |
| | 300 | + } |
| 289 | 301 | } |
| 290 | 302 | } |
| 291 | 303 | } |
| | 304 | + |
| | 305 | + $out = $this->getOutput(); |
| | 306 | + |
| 292 | 307 | // clear out the redirects |
| 293 | | - $wgOut->redirect( '' ); |
| | 308 | + $out->redirect( '' ); |
| 294 | 309 | |
| 295 | 310 | // tell the good news first |
| 296 | 311 | if ( sizeof( $this->mSuccesses ) > 0 ) { |
| 297 | | - $wgOut->addHTML( '<h2>' . wfMsgHtml( 'successfulupload' ) . "</h2>\n" ); |
| 298 | | - $wgOut->addHTML( implode( $this->mSuccesses ) ); |
| | 312 | + $out->addHTML( '<h2>' . wfMsgHtml( 'multiupload-successful-upload' ) . "</h2>\n" ); |
| | 313 | + $out->addHTML( implode( $this->mSuccesses ) ); |
| 299 | 314 | } |
| 300 | 315 | |
| 301 | 316 | // the bad news |
| 302 | 317 | if ( sizeof( $this->mErrors ) > 0 ) { |
| 303 | | - $wgOut->addHTML( '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" ); |
| 304 | | - $wgOut->addHTML( implode( $this->mErrors ) ); |
| | 318 | + $out->addHTML( '<h2>' . wfMsgHtml( 'uploaderror' ) . "</h2>\n" ); |
| | 319 | + $out->addHTML( implode( $this->mErrors ) ); |
| 305 | 320 | } |
| 306 | 321 | |
| 307 | 322 | // the hopefully recoverable news |
| 308 | 323 | if ( sizeof( $this->mWarnings ) > 0 || sizeof( $this->mErrors ) > 0 ) { |
| 309 | | - $wgOut->addHTML( '<br /><br /><hr />' ); // visually separate the form from the errors/successes |
| | 324 | + $out->addHTML( '<br /><br /><hr />' ); // visually separate the form from the errors/successes |
| 310 | 325 | $form = $this->getUploadForm( implode( $this->mWarnings ), $this->mSessionKeys, /* $hideIgnoreWarning */ true ); |
| 311 | 326 | $form->setSubmitText( wfMsg( 'upload-tryagain' ) ); |
| 312 | 327 | $form->addButton( 'wpUploadIgnoreWarning', wfMsg( 'ignorewarning' ) ); |
| — | — | @@ -321,9 +336,8 @@ |
| 322 | 337 | * @return Boolean: success |
| 323 | 338 | */ |
| 324 | 339 | protected function unsaveUploadedFile() { |
| 325 | | - global $wgMaxUploadFiles; |
| 326 | 340 | $ret = true; |
| 327 | | - for ( $i = 0; $i < $wgMaxUploadFiles; $i++ ) { |
| | 341 | + for ( $i = 0; $i < MultipleUpload::getMaxUploadFiles(); $i++ ) { |
| 328 | 342 | if ( isset( $this->mUploads[$i] ) ) { |
| 329 | 343 | $this->mUpload = $this->mUploads[$i]; |
| 330 | 344 | // return false if even one of them failed |
| — | — | @@ -337,9 +351,9 @@ |
| 338 | 352 | * Construct a warning and a gallery from an array of duplicate files. |
| 339 | 353 | * Override because the original doesn't say which file is a dupe |
| 340 | 354 | */ |
| 341 | | - public static function getDupeWarning( $dupes, $dupetitle = null ) { |
| | 355 | + public static function getDupeWarning( $dupes, $dupeTitle = null ) { |
| 342 | 356 | $result = parent::getDupeWarning( $dupes ); |
| 343 | | - return preg_replace( "@<li>@", "<li>{$dupetitle->getText()}", $result ); |
| | 357 | + return preg_replace( '@<li>@', "<li>{$dupeTitle->getText()}", $result ); |
| 344 | 358 | } |
| 345 | 359 | |
| 346 | 360 | } |
| — | — | @@ -352,20 +366,63 @@ |
| 353 | 367 | protected $mDestFiles; |
| 354 | 368 | protected $mSessionKeys; |
| 355 | 369 | |
| 356 | | - public function __construct( $options = array() ) { |
| | 370 | + public function __construct( $options = array(), $context = null, $messagePrefix = 'multiupload' ) { |
| 357 | 371 | // basically we want to map filenames to session keys here somehow |
| 358 | | - global $wgMaxUploadFiles; |
| 359 | 372 | $this->mDestFiles = array(); |
| 360 | | - for( $i = 0; $i < $wgMaxUploadFiles; $i++ ) { |
| | 373 | + for( $i = 0; $i < MultipleUpload::getMaxUploadFiles(); $i++ ) { |
| 361 | 374 | $this->mDestFiles[$i] = $options['destfile'. $i]; |
| 362 | 375 | } |
| 363 | 376 | $this->mSessionKeys = array(); |
| 364 | 377 | foreach ( $options as $k => $v ) { |
| 365 | | - if ( preg_match( "@^sessionkey@", $k ) ) { |
| | 378 | + if ( preg_match( '@^sessionkey@', $k ) ) { |
| 366 | 379 | $this->mSessionKeys[$k] = $v; |
| 367 | 380 | } |
| 368 | 381 | } |
| 369 | | - parent::__construct( $options ); |
| | 382 | + // In an ideal world, this would work: |
| | 383 | + #parent::__construct( $options, $context, $messagePrefix ); |
| | 384 | + // But MediaWiki is MediaWiki, so of course you can't pass the third |
| | 385 | + // parameter to UploadForm::__construct(), but instead it hardcodes it |
| | 386 | + // to 'upload'...great. So, we have to duplicate that function here. :( |
| | 387 | + $this->mWatch = !empty( $options['watch'] ); |
| | 388 | + $this->mForReUpload = !empty( $options['forreupload'] ); |
| | 389 | + $this->mSessionKey = isset( $options['sessionkey'] ) |
| | 390 | + ? $options['sessionkey'] : ''; |
| | 391 | + $this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] ); |
| | 392 | + $this->mDestWarningAck = !empty( $options['destwarningack'] ); |
| | 393 | + $this->mDestFile = isset( $options['destfile'] ) ? $options['destfile'] : ''; |
| | 394 | + |
| | 395 | + $this->mComment = isset( $options['description'] ) ? |
| | 396 | + $options['description'] : ''; |
| | 397 | + |
| | 398 | + $this->mTextTop = isset( $options['texttop'] ) |
| | 399 | + ? $options['texttop'] : ''; |
| | 400 | + |
| | 401 | + $this->mTextAfterSummary = isset( $options['textaftersummary'] ) |
| | 402 | + ? $options['textaftersummary'] : ''; |
| | 403 | + |
| | 404 | + $sourceDescriptor = $this->getSourceSection(); |
| | 405 | + $descriptor = $sourceDescriptor |
| | 406 | + + $this->getDescriptionSection() |
| | 407 | + + $this->getOptionsSection(); |
| | 408 | + |
| | 409 | + wfRunHooks( 'UploadFormInitDescriptor', array( &$descriptor ) ); |
| | 410 | + $this->setMessagePrefix( 'multiupload' ); |
| | 411 | + HTMLForm::__construct( $descriptor, $context, 'multiupload' ); // here's the change |
| | 412 | + |
| | 413 | + # Set some form properties |
| | 414 | + $this->setSubmitText( wfMsg( 'uploadbtn' ) ); |
| | 415 | + $this->setSubmitName( 'wpUpload' ); |
| | 416 | + # Used message keys: 'accesskey-upload', 'tooltip-upload' |
| | 417 | + $this->setSubmitTooltip( 'upload' ); |
| | 418 | + $this->setId( 'mw-upload-form' ); |
| | 419 | + |
| | 420 | + # Build a list of IDs for javascript insertion |
| | 421 | + $this->mSourceIds = array(); |
| | 422 | + foreach ( $sourceDescriptor as $field ) { |
| | 423 | + if ( !empty( $field['id'] ) ) { |
| | 424 | + $this->mSourceIds[] = $field['id']; |
| | 425 | + } |
| | 426 | + } |
| 370 | 427 | } |
| 371 | 428 | |
| 372 | 429 | protected function getDescriptionSection() { |
| — | — | @@ -382,9 +439,7 @@ |
| 383 | 440 | * @return array Descriptor array |
| 384 | 441 | */ |
| 385 | 442 | protected function getSourceSection() { |
| 386 | | - global $wgLang, $wgUser, $wgRequest, $wgMaxUploadFiles; |
| 387 | | - |
| 388 | | - if ( sizeof( $this->mSessionKeys ) > 0) { |
| | 443 | + if ( sizeof( $this->mSessionKeys ) > 0 ) { |
| 389 | 444 | $data = array( |
| 390 | 445 | 'wpSourceType' => array( |
| 391 | 446 | 'type' => 'hidden', |
| — | — | @@ -409,9 +464,9 @@ |
| 410 | 465 | return $data; |
| 411 | 466 | } |
| 412 | 467 | |
| 413 | | - $canUploadByUrl = UploadFromUrl::isEnabled() && $wgUser->isAllowed( 'upload_by_url' ); |
| | 468 | + $canUploadByUrl = UploadFromUrl::isEnabled() && $this->getUser()->isAllowed( 'upload_by_url' ); |
| 414 | 469 | $radio = $canUploadByUrl; |
| 415 | | - $selectedSourceType = strtolower( $wgRequest->getText( 'wpSourceType', 'File' ) ); |
| | 470 | + $selectedSourceType = strtolower( $this->getRequest()->getText( 'wpSourceType', 'File' ) ); |
| 416 | 471 | |
| 417 | 472 | $descriptor = array(); |
| 418 | 473 | if ( $this->mTextTop ) { |
| — | — | @@ -423,7 +478,7 @@ |
| 424 | 479 | ); |
| 425 | 480 | } |
| 426 | 481 | |
| 427 | | - for ( $i = 0; $i < $wgMaxUploadFiles; $i++ ) { |
| | 482 | + for ( $i = 0; $i < MultipleUpload::getMaxUploadFiles(); $i++ ) { |
| 428 | 483 | $descriptor['UploadFile' . $i] = array( |
| 429 | 484 | 'class' => 'UploadSourceField', |
| 430 | 485 | 'section' => 'source', |
| — | — | @@ -456,7 +511,7 @@ |
| 457 | 512 | 'radio' => &$radio, |
| 458 | 513 | 'help' => wfMsgExt( 'upload-maxfilesize', |
| 459 | 514 | array( 'parseinline', 'escapenoentities' ), |
| 460 | | - $wgLang->formatSize( $wgMaxUploadSize ) |
| | 515 | + $this->getLang()->formatSize( $wgMaxUploadSize ) |
| 461 | 516 | ) . ' ' . wfMsgHtml( 'upload_source_url' ), |
| 462 | 517 | 'checked' => $selectedSourceType == 'url', |
| 463 | 518 | ); |
| — | — | @@ -471,7 +526,7 @@ |
| 472 | 527 | 'raw' => true, |
| 473 | 528 | 'help' => wfMsgExt( 'upload-maxfilesize', |
| 474 | 529 | array( 'parseinline', 'escapenoentities' ), |
| 475 | | - $wgLang->formatSize( |
| | 530 | + $this->getLang()->formatSize( |
| 476 | 531 | wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ) |
| 477 | 532 | ) |
| 478 | 533 | ) . ' ' . wfMsgHtml( 'upload_source_file' ), |
| — | — | @@ -483,10 +538,9 @@ |
| 484 | 539 | * Add upload JavaScript to $wgOut |
| 485 | 540 | */ |
| 486 | 541 | protected function addUploadJS() { |
| 487 | | - global $wgScriptPath, $wgMaxUploadFiles, $wgFileExtensions; |
| | 542 | + global $wgScriptPath, $wgFileExtensions; |
| 488 | 543 | |
| 489 | 544 | global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview, $wgEnableAPI; |
| 490 | | - global $wgOut; |
| 491 | 545 | |
| 492 | 546 | $useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck; |
| 493 | 547 | $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview && $wgEnableAPI; |
| — | — | @@ -501,19 +555,19 @@ |
| 502 | 556 | 'wgUploadSourceIds' => $this->mSourceIds, |
| 503 | 557 | ); |
| 504 | 558 | |
| 505 | | - $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) ); |
| | 559 | + $out = $this->getOutput(); |
| | 560 | + $out->addScript( Skin::makeVariablesScript( $scriptVars ) ); |
| 506 | 561 | |
| 507 | 562 | // For <charinsert> support |
| 508 | | - $wgOut->addScriptFile( 'edit.js' ); |
| | 563 | + $out->addScriptFile( 'edit.js' ); |
| 509 | 564 | |
| 510 | 565 | // changed |
| 511 | | - $wgOut->addScriptFile( "$wgScriptPath/extensions/MultiUpload/multiupload.js" ); |
| | 566 | + $out->addScriptFile( "$wgScriptPath/extensions/MultiUpload/multiupload.js" ); |
| 512 | 567 | $newscriptVars = array( |
| 513 | | - 'wgMaxUploadFiles' => $wgMaxUploadFiles, |
| | 568 | + 'wgMaxUploadFiles' => MultipleUpload::getMaxUploadFiles(), |
| 514 | 569 | 'wgFileExtensions' => $wgFileExtensions |
| 515 | 570 | ); |
| 516 | | - $wgOut->addScript( Skin::makeVariablesScript( $newscriptVars ) ); |
| | 571 | + $out->addScript( Skin::makeVariablesScript( $newscriptVars ) ); |
| 517 | 572 | } |
| 518 | 573 | |
| 519 | | -} |
| 520 | | - |
| | 574 | +} |
| \ No newline at end of file |
| Index: trunk/extensions/MultiUpload/MultiUpload.i18n.php |
| — | — | @@ -30,6 +30,10 @@ |
| 31 | 31 | 'multiupload-toolbox' => 'Upload multiple files', |
| 32 | 32 | 'multiupload-no-files' => 'Please select at least one file to upload', |
| 33 | 33 | 'multiupload-blank' => 'No file selected', |
| | 34 | + 'multiupload-source' => 'Source files', |
| | 35 | + 'multiupload-description' => 'File description', // duplicate of upload-description |
| | 36 | + 'multiupload-options' => 'Upload options', // duplicate of upload-options |
| | 37 | + 'multiupload-successful-upload' => 'Successful upload', |
| 34 | 38 | ); |
| 35 | 39 | |
| 36 | 40 | /** Message documentation (Message documentation) |
| Index: trunk/extensions/MultiUpload/MultiUpload.php |
| — | — | @@ -21,7 +21,7 @@ |
| 22 | 22 | 'path' => __FILE__, |
| 23 | 23 | 'name' => 'MultipleUpload', |
| 24 | 24 | 'author' => 'Travis Derouin', |
| 25 | | - 'version' => '2.0', |
| | 25 | + 'version' => '2.1', |
| 26 | 26 | 'descriptionmsg' => 'multiupload-desc', |
| 27 | 27 | 'url' => 'https://www.mediawiki.org/wiki/Extension:MultiUpload', |
| 28 | 28 | ); |