http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88774

Revision: 88774
Author:   dale
Date:     2011-05-25 03:27:25 +0000 (Wed, 25 May 2011)
Log Message:
-----------
* fixed api.post call in postWithEditToken ( was passing 3 arguments of type 
object, function, function to method that accepts 2 arguments of type object, 
object ) 
** supports "continue anyway" on final step by supporting error process for 
postWithEditToken
* added ( disabled by default ) minimal upload framework modification firefogg 
support for converting non-free video files
 

Modified Paths:
--------------
    trunk/extensions/UploadWizard/UploadWizard.config.php
    trunk/extensions/UploadWizard/UploadWizard.i18n.php
    trunk/extensions/UploadWizard/UploadWizardHooks.php
    trunk/extensions/UploadWizard/resources/mw.Api.edit.js
    trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
    trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
    trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js

Added Paths:
-----------
    trunk/extensions/UploadWizard/resources/mw.Firefogg.js
    trunk/extensions/UploadWizard/resources/mw.FirefoggHandler.js
    trunk/extensions/UploadWizard/resources/mw.FirefoggTransport.js

Modified: trunk/extensions/UploadWizard/UploadWizard.config.php
===================================================================
--- trunk/extensions/UploadWizard/UploadWizard.config.php       2011-05-25 
01:15:09 UTC (rev 88773)
+++ trunk/extensions/UploadWizard/UploadWizard.config.php       2011-05-25 
03:27:25 UTC (rev 88774)
@@ -245,12 +245,32 @@
                //      /^(\d{10}[\s_-][0-9a-f]{10}[\s_-][a-z])$/   // flickr
                // ]    
 
-       // Check if we want to enable firefogg ( for transcoding ) 
-       'enableFirefogg' => false, 
-
-       // Check if we have the firefogg upload api module enabled: 
-       'enableFirefoggChunkUpload' => isset( $wgAPIModules['firefoggupload'] 
)? true : false,
+       // Check if we want to enable firefogg, will result in 
+       // 1) firefogg install recommendation when users try to upload media 
asset with an extension in the 
+       //              transcodeExtensionList
+       // 2) Once the user installs firefogg its used for all uploads because 
of the security model
+       //              of the file select box, you can't pass off local file 
references to add ons. Firefogg
+       //              supports "passthrough" mode so that assets that don't 
need conversions behave very similar
+       //              to a normal XHR post. 
+       'enableFirefogg' => false,
        
+       // Setup list of video extensions for recomending firefogg. 
+       'transcodeExtensionList' => array( 
'avi','asf','asx','wmv','wmx','dv','rm','ra','3gp','mkv',
+                                                                               
'mp4','m4v','mov','qt','mpeg','mpeg2','mp2','mpg'),
+       
+       // Firefogg encode settings copied from TimedMediHandler high end ogg. 
Once Timed Media Handler
+       // is added, these videos will be transcoded by the server to lower 
resolutions for web playback. 
+       // Also we should switch uploadWizard to encode to high quality WebM 
once TMH is deployed since it 
+       // will provide a higher quality source upload file.
+       'firefoggEncodeSettings' => array(
+               'maxSize'                       => '1280', // 720P
+               'videoQuality'          => 6,
+               'audioQuality'          => 3,
+               'noUpscaling'           => 'true',
+               'keyframeInterval'      => '128',
+               'videoCodec'            => 'theora',
+       ),
+       
        // Set skipTutorial to true to always skip tutorial step
        'skipTutorial' => false,
        

Modified: trunk/extensions/UploadWizard/UploadWizard.i18n.php
===================================================================
--- trunk/extensions/UploadWizard/UploadWizard.i18n.php 2011-05-25 01:15:09 UTC 
(rev 88773)
+++ trunk/extensions/UploadWizard/UploadWizard.i18n.php 2011-05-25 03:27:25 UTC 
(rev 88774)
@@ -125,6 +125,7 @@
        'mwe-upwiz-thanks-wikitext' => '<b>To use the file in a wiki</b>, copy 
this text into a page:',
        'mwe-upwiz-thanks-url' => '<b>To link to it in HTML</b>, copy this URL 
address:',
        'mwe-upwiz-upload-error-bad-filename-extension' => 'This wiki does not 
accept filenames that end in the extension ".$1".',
+       'mwe-upwiz-upload-error-bad-extension-video-firefogg' => 'You have 
selected a video file for uploading thats not in a free format. You can [$1 
install firefogg] to automatically convert it, or use other [$2 converting 
options].',
        'mwe-upwiz-upload-error-bad-filename-no-extension' => 'This wiki 
requires that files have an extension — like ".JPG" at the end of the 
filename.',
        'mwe-upwiz-allowed-filename-extensions' => 'The allowed extensions 
are:',
        'mwe-upwiz-help-allowed-filename-extensions' => 'Allowed filename 
extensions',

Modified: trunk/extensions/UploadWizard/UploadWizardHooks.php
===================================================================
--- trunk/extensions/UploadWizard/UploadWizardHooks.php 2011-05-25 01:15:09 UTC 
(rev 88773)
+++ trunk/extensions/UploadWizard/UploadWizardHooks.php 2011-05-25 03:27:25 UTC 
(rev 88774)
@@ -64,7 +64,12 @@
                                'resources/mw.ApiUploadHandler.js',
                                'resources/mw.DestinationChecker.js',
                                'resources/mw.UploadWizardUtil.js',
-
+                               
+                               // firefogg support libraries
+                               'resources/mw.Firefogg.js',
+                               'resources/mw.FirefoggHandler.js',
+                               'resources/mw.FirefoggTransport.js',
+                       
                                // interface libraries
                                'resources/mw.GroupProgressBar.js',
 
@@ -207,6 +212,7 @@
                                'mwe-upwiz-thanks-explain',
                                'mwe-upwiz-thanks-wikitext',
                                'mwe-upwiz-thanks-url',
+                               
'mwe-upwiz-upload-error-bad-extension-video-firefogg',
                                'mwe-upwiz-upload-error-bad-filename-extension',
                                
'mwe-upwiz-upload-error-bad-filename-no-extension',
                                'mwe-upwiz-allowed-filename-extensions',

Modified: trunk/extensions/UploadWizard/resources/mw.Api.edit.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.Api.edit.js      2011-05-25 
01:15:09 UTC (rev 88773)
+++ trunk/extensions/UploadWizard/resources/mw.Api.edit.js      2011-05-25 
03:27:25 UTC (rev 88774)
@@ -38,7 +38,7 @@
                                                err( code, result );
                                        }
                                };
-                               api.post( params, ok, getTokenIfBad );
+                               api.post( params, { 'ok' : ok, 'err' : 
getTokenIfBad });
                        }
                },
        

Added: trunk/extensions/UploadWizard/resources/mw.Firefogg.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.Firefogg.js                      
        (rev 0)
+++ trunk/extensions/UploadWizard/resources/mw.Firefogg.js      2011-05-25 
03:27:25 UTC (rev 88774)
@@ -0,0 +1,28 @@
+// Firefogg utilities not related to the upload handler or transport
+mw.Firefogg = {
+               
+       firefoggInstallLinks: {
+               'macosx': 'http://firefogg.org/macosx/Firefogg.xpi',
+               'win32': 'http://firefogg.org/win32/Firefogg.xpi',
+               'linux': 'http://firefogg.org/linux/Firefogg.xpi'
+       },
+       
+       /**
+        * Get the URL for installing firefogg on the client OS
+        */
+       getFirefoggInstallUrl: function() {
+               var osLink = false;
+               if( ! $.browser.mozilla ){
+                       return 'http://firefogg.org/';
+               }
+               if ( navigator.oscpu ) {
+                       if ( navigator.oscpu.search( 'Linux' ) >= 0 )
+                               osLink = this.firefoggInstallLinks['linux'];
+                       else if ( navigator.oscpu.search( 'Mac' ) >= 0 )
+                               osLink = this.firefoggInstallLinks['macosx'];
+                       else if (navigator.oscpu.search( 'Win' ) >= 0 )
+                               osLink = this.firefoggInstallLinks['win32'];
+               }
+               return osLink;
+       }
+};
\ No newline at end of file


Property changes on: trunk/extensions/UploadWizard/resources/mw.Firefogg.js
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/extensions/UploadWizard/resources/mw.FirefoggHandler.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.FirefoggHandler.js               
                (rev 0)
+++ trunk/extensions/UploadWizard/resources/mw.FirefoggHandler.js       
2011-05-25 03:27:25 UTC (rev 88774)
@@ -0,0 +1,108 @@
+/**
+ * Represents an object which configures a form to upload its files via an 
firefogg talking to the MediaWiki API.
+ * @param an UploadInterface object, which contains a .form property which 
points to a real HTML form in the DOM
+ */
+
+mw.FirefoggHandler = function( upload ) {
+       return this.init( upload );
+};
+
+mw.FirefoggHandler.prototype = {
+       // The transport object
+       transport : null, // lazy init
+       /**
+        * Constructor 
+        */
+       init: function( upload ){
+               this.upload = upload;
+               this.api = upload.api;          
+               // update the mwe-upwiz-file-input target
+               this.upload.ui.$fileInputCtrl = this.getInputControl()
+               this.upload.ui.fileCtrlContainer.empty().append(
+                       this.upload.ui.$fileInputCtrl
+               )
+               // update the "valid" extension to include firefogg transcode 
extensions: 
+               mw.UploadWizard.config[ 'fileExtensions' ] = $.merge(
+                               mw.UploadWizard.config[ 'fileExtensions' ], 
+                               mw.UploadWizard.config[ 
'transcodeExtensionList' ]
+               )
+               
+       },
+       // Setup local pointer to firefogg instance
+       getFogg: function(){
+               if( ! this.fogg ){
+                       this.fogg = new Firefogg();
+               }
+               return this.fogg;
+       },
+       getTransport: function(){
+               var _this = this;
+               if( !this.transport ){
+                       this.transport = new mw.FirefoggTransport(      
+                                       this.getForm(),
+                                       this.getFogg(),
+                                       function( fraction ) { 
+                                               
_this.upload.setTransportProgress( fraction ); 
+                                               // also update preview video: 
+                                       },
+                                       function( result ) {    
+                                               
mw.log("FirefoggTransport::getTransport> Transport done " + JSON.stringify( 
result ) );
+                                               _this.upload.setTransported( 
result ); 
+                                       }
+                               );
+               }
+               return this.transport;
+       },
+       isGoodExtension: function( ext ){
+               // First check if its an oky extension for the wiki: 
+               if( $j.inArray( ext.toLowerCase(), mw.UploadWizard.config[ 
'fileExtensions' ] ) !== -1 ){
+                       return true;
+               } 
+               // Check if its a file that can be transcoded:
+               if( this.getTransport().isSourceAudio() || 
this.getTransport().isSourceVideo() ){
+                       return true;
+               }
+               // file can't be transcoded
+               return false;
+       },
+       
+       getForm: function(){
+               return  $j( this.upload.ui.form );
+       },
+       
+       /**
+        * Get a pointer to the "file" input control 
+        */
+       getInputControl: function(){
+               var _this = this;               
+               return $j('<input />').attr({
+                               'size': "1",
+                                'name': "file",
+                                'type': "text"
+                       })
+                       .addClass( "mwe-upwiz-file-input" )
+                       .click( function() {
+                               if( _this.getFogg().selectVideo() ) {   
+                                       // Update the value of the input file: 
+                                       $j( this )
+                                       .val( _this.getFogg().sourceFilename )  
                
+                                       //.trigger('change');
+                                       // note the change trigger does not 
work because we replace the target: 
+                                       _this.upload.ui.fileChanged();
+                               }
+                       } );
+       },
+
+       /**
+        * If chunks are disabled transcode then upload else
+        * upload and transcode at the same time
+        */
+       start: function() {
+               var _this = this;               
+               mw.log( "mw.FirefoggHandler::start> upload start!" );           
+               _this.beginTime = ( new Date() ).getTime();
+               _this.upload.ui.setStatus( 'mwe-upwiz-transport-started' );
+               _this.upload.ui.showTransportProgress();
+               _this.getTransport().doUpload();                        
+       }
+};


Property changes on: 
trunk/extensions/UploadWizard/resources/mw.FirefoggHandler.js
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/extensions/UploadWizard/resources/mw.FirefoggTransport.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.FirefoggTransport.js             
                (rev 0)
+++ trunk/extensions/UploadWizard/resources/mw.FirefoggTransport.js     
2011-05-25 03:27:25 UTC (rev 88774)
@@ -0,0 +1,245 @@
+/**
+ * Represents a "transport" for files to upload; in this case an firefogg.
+ *
+ * @param form jQuery selector for HTML form
+ * @param progressCb   callback to execute as the upload progresses 
+ * @param transportedCb        callback to execute when we've finished the 
upload
+ */
+mw.FirefoggTransport = function( $form, fogg, progressCb, transportedCb ) {
+       this.$form = $form;
+       this.fogg = fogg;
+       this.progressCb = progressCb;
+       this.transportedCb = transportedCb;
+};
+
+mw.FirefoggTransport.prototype = {
+
+       passthrough: false,
+       /**
+        * Do an upload on a given fogg object: 
+        */
+       doUpload: function(){
+               // check if the server supports chunks:
+               if( this.isChunkUpload() ){
+                       mw.log("FirefoggTransport::doUpload> Chunks");
+                       // encode and upload at the same time: 
+                       this.doChunkUpload();
+               } else {
+                       mw.log("FirefoggTransport::doUpload> Encode then 
upload");
+                       this.doEncodeThenUpload();
+               }
+       },
+       isChunkUpload: function(){
+               // for now just test post
+               return false;
+               return ( mw.UploadWizard.config[ 'enableFirefoggChunkUpload' ] 
);
+       },                      
+       /**
+        * Check if the asset should be uploaded in passthrough mode ( or if it 
should be encoded )
+        */
+       isPassThrough: function(){
+               // Check if the server supports webm uploads: 
+               var wembExt = ( $j.inArray( 'webm', mw.UploadWizard.config[ 
'fileExtensions'] ) !== -1 )
+               // Determine passthrough mode
+               if ( this.isOggFormat() || ( wembExt && this.isWebMFormat() ) ) 
{
+                       // Already Ogg, no need to encode
+                       return true;
+               } else if ( this.isSourceAudio() || this.isSourceVideo() ) {
+                       // OK to encode
+                       return false;
+               } else {
+                       // Not audio or video, can't encode
+                       return true;
+               }
+       },
+
+       isSourceAudio: function() {
+               return ( this.getSourceFileInfo().contentType.indexOf("audio/") 
!= -1 );
+       },
+
+       isSourceVideo: function() {
+               return ( this.getSourceFileInfo().contentType.indexOf("video/") 
!= -1 );
+       },
+
+       isOggFormat: function() {
+               var contentType = this.getSourceFileInfo().contentType;
+               return ( contentType.indexOf("video/ogg") != -1
+                       || contentType.indexOf("application/ogg") != -1 
+                       || contentType.indexOf("audio/ogg") != -1);
+       },
+       isWebMFormat: function() {
+               return (  this.getSourceFileInfo().contentType.indexOf('webm') 
!= -1 );
+       },
+       
+       /**
+        * Get the source file info for the current file selected into this.fogg
+        */
+       getSourceFileInfo: function() {
+               if ( !this.fogg.sourceInfo ) {
+                       mw.log( 'Error:: No firefogg source info is available' 
);
+                       return false;
+               }
+               try {
+                       this.sourceFileInfo = JSON.parse( this.fogg.sourceInfo 
);
+               } catch ( e ) {
+                       mw.log( 'Error :: could not parse fogg sourceInfo' );
+                       return false;
+               }
+               return this.sourceFileInfo;
+       },
+       
+       // Get the filename
+       getFileName: function(){
+               // If passthrough don't change it
+               if( this.isPassThrough() ){
+                       return this.fogg.sourceFilename;
+               } else {                        
+                       if( this.isSourceAudio() ){
+                               return 
this.fogg.sourceFilename.split('.').slice(0,-1).join('.') + '.oga';
+                       }
+                       if( this.isSourceVideo() ){
+                               return 
this.fogg.sourceFilename.split('.').slice(0,-1).join('.') + '.webm';
+                       }
+               }
+       },
+       getEncodeExt: function(){
+               var encodeSettings = mw.UploadWizard.config[ 
'firefoggEncodeSettings'];
+               if( encodeSettings['videoCodec'] 
+                           && 
+                   encodeSettings['videoCodec'] == 'vp8' )
+               {
+                       return 'webm';
+               } else { 
+                       return 'ogv';
+               }
+       },
+       
+       /**
+        * Get the encode settings from configuration and the current selected 
video type 
+        */
+       getEncodeSettings: function(){
+               if( this.isPassThrough() ){
+                       return { 'passthrough' : true };
+               }
+               // Get the default encode settings: 
+               var encodeSettings = mw.UploadWizard.config[ 
'firefoggEncodeSettings'];
+               // Update the format: 
+               this.fogg.setFormat( ( this.getEncodeExt() == 'webm' )? 'webm' 
: 'ogg' );
+               
+               mw.log("FirefoggTransport::getEncodeSettings> " +  
JSON.stringify(  encodeSettings ) );
+               return encodeSettings;
+       },
+       
+       /**
+        * Encode then upload
+        */
+       doEncodeThenUpload: function(){
+               this.fogg.encode( JSON.stringify( this.getEncodeSettings() ) );
+               this.monitorProgress();
+       },
+       
+       /**
+        * Do fogg post 
+        */
+       doFoggPost: function(){
+               var _this = this;               
+               // Get the upload request with a callback ( populates the 
request token )       
+                this.getUploadRequest( function( request ){
+                       mw.log("FirefoggTransport::doFoggPost> " + 
_this.getUploadUrl() + ' request:' + 
+                                       JSON.stringify( request ) );
+                       
+                       _this.fogg.post( _this.getUploadUrl(), 
+                               'file', 
+                               JSON.stringify( request ) 
+                       );
+                       _this.monitorProgress();
+               } );
+       },
+       
+       /**
+        * Encode and upload in chunks
+        */
+       doChunkUpload: function(){
+               var _this = this;
+               this.getUploadRequest( function( request ){
+                       this.fogg.upload( 
+                                       JSON.stringify( 
_this.getEncodeSettings() ), 
+                                       _this.getUploadUrl(),
+                                       JSON.stringify( request )
+                       );
+               });
+               _this.monitorProgress();
+       },
+       
+       /**
+        * Get the upload url
+        */ 
+       getUploadUrl: function(){
+               return mw.UploadWizard.config['apiUrl'];
+       },
+       
+       /**
+        * Get the upload settings
+        * @param {function} callback function to send the request object 
+        */     
+       getUploadRequest: function( callback ){
+               var _this = this;
+               // ugly probably would be nice to have base reference to the 
upload class so we can use the 
+                new mw.Api( { 
+                        'url' : _this.getUploadUrl() 
+                } )
+                .getEditToken( function( token ) {
+                       callback( {
+                               'action' : ( _this.isChunkUpload() )? 
'firefoggupload' : 'upload',
+                               'stash' :1,
+                               'comment' : 'DUMMY TEXT',
+                               'format' : 'json',
+                               'filename' : _this.getFileName(),
+                               'token' : token
+                       } );
+               }, function( code, info ) {
+                       _this.upload.setError( code, info );
+               } );            
+       },
+       /**
+        * Monitor progress on an upload:
+        */
+       monitorProgress: function(){
+               var _this = this;
+               var fogg = this.fogg;
+               var progress = fogg.progress();
+               var state = fogg.state;
+               
+               //mw.log("FirefoggTransport::monitorProgress> " + progress + ' 
state: ' + state  + ' status: ' + this.fogg.status() + ' rt: ' + 
this.getResponseText() );
+               this.progressCb( progress );
+               
+               if( state == 'encoding done' && ! this.isChunkUpload() ){
+                       // ( if encoding done, we are in a two step encode then 
upload process )
+                       this.doFoggPost();
+                       return ;
+               }
+               // If state is 'in progress' ... fire monitor progress
+               if( state == 'encoding' || state == 'uploading' || state == '' 
){
+                       setTimeout( function(){
+                               _this.monitorProgress();
+                       }, mw.UploadWizard.config['uploadProgressInterval'] );
+               }
+               // return the api result: 
+               if( state == 'done' || state == 'upload done' ){
+                       this.transportedCb( JSON.parse( this.getResponseText() 
) );
+               }
+               
+       },
+       /**
+        * Get the response text from a firefogg upload
+        */
+       getResponseText: function(){
+               var _this = this;
+               try {
+                       var pstatus = JSON.parse( _this.fogg.uploadstatus() );
+                       return pstatus["responseText"];
+               } catch( e ) {
+                       mw.log( "Error:: Firefogg could not parse uploadstatus 
/ could not get responseText: " + e );
+               }               
+       }
+};


Property changes on: 
trunk/extensions/UploadWizard/resources/mw.FirefoggTransport.js
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.UploadWizard.js  2011-05-25 
01:15:09 UTC (rev 88773)
+++ trunk/extensions/UploadWizard/resources/mw.UploadWizard.js  2011-05-25 
03:27:25 UTC (rev 88774)
@@ -29,14 +29,17 @@
        // handler -- usually ApiUploadHandler
        // this.handler = new ( mw.UploadWizard.config[  'uploadHandlerClass'  
] )( this );
        // this.handler = new mw.MockUploadHandler( this );
-       this.handler = new mw.ApiUploadHandler( this, api );
+       this.handler = this.getUploadHandler();
        
+       
        this.index = mw.UploadWizardUpload.prototype.count;
        mw.UploadWizardUpload.prototype.count++;
 };
 
 mw.UploadWizardUpload.prototype = {
-
+       // Upload handler 
+       uploadHandler: null,
+       
        // increments with each upload
        count: 0,
 
@@ -383,8 +386,26 @@
 
                this.api.get( params, { ok: ok, err: err } );
        },
-
        /**
+        * Get the upload handler per browser capabilities 
+        */
+       getUploadHandler: function(){
+               if( !this.uploadHandler ){
+                       if( typeof( Firefogg ) != 'undefined'
+                                       &&
+                               mw.UploadWizard.config[ 'enableFirefogg' ]
+                       ) {
+                               mw.log("mw.UploadWizard::getUploadHandler> 
FirefoggHandler");
+                               this.uploadHandler = new mw.FirefoggHandler( 
this, this.api );                  
+                       } else {
+                               // By default use the apiUploadHandler
+                               mw.log("mw.UploadWizard::getUploadHandler> 
ApiUploadHandler");
+                               this.uploadHandler = new mw.ApiUploadHandler( 
this, this.api );
+                       }
+               }               
+               return this.uploadHandler;
+       },
+       /**
         * Fetch a thumbnail for a stashed upload of the desired width.
         * It is assumed you don't call this until it's been transported.
         *

Modified: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js   
2011-05-25 01:15:09 UTC (rev 88773)
+++ trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js   
2011-05-25 03:27:25 UTC (rev 88774)
@@ -184,6 +184,17 @@
                        )
                );
 
+       // Add in remove control to submittingDiv
+       _this.$removeCtrl = $j.fn.removeCtrl( 
+                       'mwe-upwiz-remove', 
+                       'mwe-upwiz-remove-upload', 
+                       function() { _this.upload.remove(); } 
+               ).addClass( "mwe-upwiz-file-status-line-item" );
+
+       _this.submittingDiv.find( '.mwe-upwiz-file-status-line' )
+               .append( _this.$removeCtrl );
+       
+       
        $j( _this.dataDiv ).append( 
                _this.$form,
                _this.submittingDiv
@@ -687,7 +698,7 @@
         */
        submit: function() {
                var _this = this;
-
+               
                _this.upload.state = 'submitting-details';
                _this.setStatus( gM( 'mwe-upwiz-submitting-details' ) ); 
                _this.showIndicator( 'progress' );

Modified: 
trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js   
2011-05-25 01:15:09 UTC (rev 88773)
+++ trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js   
2011-05-25 03:27:25 UTC (rev 88774)
@@ -162,7 +162,7 @@
        },
 
        /**
-        * Put the visual state of an individual upload ito "progress"
+        * Put the visual state of an individual upload into "progress"
         * @param fraction      The fraction of progress. Float between 0 and 1
         */
        showTransportProgress: function( fraction ) {
@@ -220,10 +220,23 @@
                if ( hasExtension && isGoodExtension ) {
                        _this.updateFilename();
                } else {       
-                       var errorMessage = hasExtension ? 
'mwe-upwiz-upload-error-bad-filename-extension' : 
'mwe-upwiz-upload-error-bad-filename-no-extension';
+                       // Check if firefogg should be recommended to be 
installed ( user selects an extension that can be converted) 
+                       if( mw.UploadWizard.config['enableFirefogg']
+                                       &&
+                               $j.inArray( extension.toLowerCase(), 
mw.UploadWizard.config['transcodeExtensionList'] ) !== -1 
+                       ){
+                               var $errorMessage = $j( '<p>' 
).msg('mwe-upwiz-upload-error-bad-extension-video-firefogg',
+                                               
mw.Firefogg.getFirefoggInstallUrl(),
+                                               
'http://commons.wikimedia.org/wiki/Help:Converting_video'
+                                       );
+                               
+                       } else {
+                               var errorKey = hasExtension ? 
'mwe-upwiz-upload-error-bad-filename-extension' : 
'mwe-upwiz-upload-error-bad-filename-no-extension';
+                               var $errorMessage = $j( '<p>' ).msg( errorKey, 
extension );
+                       }
                        $( '<div></div>' )
                                .append( 
-                                       $j( '<p>' ).msg( errorMessage, 
extension ),
+                                       $errorMessage,
                                        $j( '<p>' ).msg( 
'mwe-upwiz-allowed-filename-extensions' ),
                                        $j( '<blockquote>' ).append( $j( '<tt>' 
).append(  
                                                mw.UploadWizard.config[ 
'fileExtensions' ].join( " " )


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to