r45647 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45646‎ | r45647 | r45648 >
Date:18:26, 10 January 2009
Author:dale
Status:deferred
Tags:
Comment:
stubs for add_media_wizard upload page rewrite for firefogg support
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/firefogg.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mv_upload.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php
@@ -310,7 +310,7 @@
311311
312312 //temp for testing:
313313 if( $mvgJSDebug )
314 - $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/external_media_wizard.js?{$unique_req_param}\"></script>" );
 314+ $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/add_media_wizard.js?{$unique_req_param}\"></script>" );
315315
316316 $mvCssUrl = $mvgScriptPath . '/skins/mv_custom.css';
317317 $wgOut->addLink( array(
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mv_upload.js
@@ -23,6 +23,8 @@
2424 init:function( iObj ){
2525 var _this = this;
2626 js_log('init uploader');
 27+ if(!iObj)
 28+ iObj = {};
2729 for(var i in default_upload_options){
2830 if(iObj[i]){
2931 this[i] = iObj[i];
@@ -30,41 +32,57 @@
3133 this[i] = default_upload_options[i];
3234 }
3335 }
 36+ //check if we are on the uplaod page:
 37+ this.on_upload_page = ( wgPageName== "Special:Upload")?true:false;
 38+ js_log('f:mvUploader: onuppage:' + this.on_upload_page);
3439 //grab firefogg.js:
35 - mvJsLoader.doLoad({'upFirefogg' : 'libAddMedia/firefogg.js'},function(){
36 - //for now grab the upload HTML (uggly but will be replaced by API shortly I promise )
37 - $j.get(wgArticlePath.replace(/\$1/, 'Special:Upload'), {}, function(data){
38 - //filter the data:
39 - sp = data.indexOf('<div id="content">');
40 - se = data.indexOf('<!-- end content -->');
41 - if(sp!=-1 && se !=-1){
42 - $j('#'+_this.target_div).html( data.substr(sp, (se-sp) ) );
43 - }
44 - //add firebug html if not already there: ( same as $wgEnableFirebug )
45 - if( $j('#fogg-video-file').length==0 ){
46 - _this.addFirebugHtml();
47 - }else{
48 - js_log('firefogg already there init:');
49 - }
50 - init_firefogg({'add_done_action':function( rTitle ){
 40+ mvJsLoader.doLoad({'upFirefogg' : 'libAddMedia/firefogg.js'},function(){
 41+ //if we are not on the upload page grab the upload html via ajax:
 42+ if( !_this.on_upload_page){
 43+ $j.get(wgArticlePath.replace(/\$1/, 'Special:Upload'), {}, function(data){
 44+ sp = data.indexOf('<div id="content">');
 45+ se = data.indexOf('<!-- end content -->');
 46+ if(sp!=-1 && se !=-1){
 47+ $j('#'+_this.target_div).html( data.substr(sp, (se-sp) ) );
 48+ }
 49+ _this.setupFirefogg();
 50+ });
 51+ }else{
 52+ _this.setupFirefogg();
 53+ }
 54+ });
 55+ },
 56+ setupFirefogg:function(){
 57+ var _this = this;
 58+ //add firebug html if not already there: ( same as $wgEnableFirebug added in SpecialUpload.php )
 59+ if( $j('#fogg-video-file').length==0 ){
 60+ js_log('add addFirefoggHtml');
 61+ _this.addFirefoggHtml();
 62+ }else{
 63+ js_log('firefogg already there init:');
 64+ }
 65+ //set up the upload_done action
 66+ //redirect if we are on the upload page
 67+ //do a callback if in called from gui)
 68+ var intFirefoggObj = (this.on_upload_page)?
 69+ {'upload_done_action':'redirect'}:
 70+ {'upload_done_action':function( rTitle ){
5171 js_log('add_done_action callback for uploader');
52 - //call the parent insert resource preview
53 -
 72+ //call the parent insert resource preview
5473 }
55 - });
56 - //set up the bindings
57 - $j('#mw-upload-form').submit(function(){
58 - //do an ajax submit
59 -
60 - //(don't do the normal submit)
61 - return false;
62 - });
63 - });
64 - });
 74+ };
 75+ init_firefogg( intFirefoggObj );
 76+ //firefogg handles the form submit (even on image uploads when called by gui)
 77+ if( !this.on_upload_page ){
 78+ $j('#mw-upload-form').submit(function(){
 79+ return false;
 80+ });
 81+ }
6582 },
6683 //same add code as specialUpload if($wgEnableFirefogg){
67 - addFirebugHtml:function(){
68 - $j('#mw-upload-table .mw-input :first').wrap('<div id="wg-base-upload"></div>');
 84+ addFirefoggHtml:function(){
 85+ var itd_html = $j('#mw-upload-table .mw-input:first').html();
 86+ $j('#mw-upload-table .mw-input').eq(0).html('<div id="wg-base-upload">' + itd_html + '</div>');
6987 //add in firefogg control
7088 $j('#wg-base-upload').after('<p id="fogg-enable-item" >' +
7189 '<input style="display:none" id="fogg-video-file" name="fogg-video-file" type="button" value="Select File..">' +
@@ -74,9 +92,7 @@
7593 '<span id="wgfogg_installed" style="display:none" >'+
7694 '<input id="wgEnableFirefogg" type="checkbox" name="wgEnableFirefogg" >' +
7795 getMsg('upload-enable-converter') +
78 - '<span><br></p>');
79 - alert('wtf');
80 - js_log('FOUND: ' + $j('#fogg-enable-item').length + ' wg: ' + $j('#wgEnableFirefogg').length );
 96+ '<span><br></p>');
8197 //add in loader dl box:
8298 $j('#mw-upload-table').before('<div id="dlbox-centered" class="dlbox-centered" >'+
8399 '<h5>' + getMsg('upload-in-progress') + '</h5>' +
@@ -87,9 +103,6 @@
88104 '<span id="fogg-status-transcode">' + getMsg('upload-transcoded-status') + '</span>'+
89105 '<span style="display:none" id="fogg-status-upload">' + getMsg('uploaded-status') + '</span>' +
90106 '</div>'+
91 - '<div class="dlbox-overlay" ></div>');
92 - //init firefogg (check for its existance)
93 - js_log('FOUND: ' + $j('#wgEnableFirefogg').length );
94 - js_log('run init_firefogg');
 107+ '<div class="dlbox-overlay" ></div>');
95108 }
96109 }
\ No newline at end of file
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/firefogg.js
@@ -194,12 +194,12 @@
195195 var sstring = 'var wgTitle = "' + data['wpDestFile'].replace('_',' ');
196196 if( result_page.toLowerCase().indexOf( sstring.toLowerCase() ) != -1){
197197 js_log('upload done got redirect found: ' +sstring);
198 - if(_this.add_done_action == 'redirect'){
 198+ if(_this.upload_done_action == 'redirect'){
199199 window.location = wgArticlePath.replace(/\$1/, 'File:' + data['wpDestFile'] );
200200 }else{
201201 //check if the add_done_action is a callback:
202 - if(typeof _this.add_done_action == 'function')
203 - _this.add_done_action();
 202+ if(typeof _this.upload_done_action == 'function')
 203+ _this.upload_done_action();
204204 }
205205 }else{
206206 js_log('upload page error: did not find: ' +sstring);

Status & tagging log