Index: trunk/phase3/skins/common/wikibits.js |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | var onloadFuncts = []; |
38 | 38 | } |
39 | 39 | |
40 | | -//should use mwAddOnloadHook once js2 is enabled |
| 40 | +//code that is dependent on js2 functions should use js2AddOnloadHook |
41 | 41 | function addOnloadHook(hookFunct) { |
42 | 42 | // Allows add-on scripts to add onload functions |
43 | 43 | if(!doneOnloadHook) { |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
| 50 | + |
50 | 51 | function hookEvent(hookName, hookFunct) { |
51 | 52 | addHandler(window, hookName, hookFunct); |
52 | 53 | } |
Index: trunk/phase3/includes/upload/UploadFromChunks.php |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | * Verify whether the upload is sane. |
73 | 73 | * Returns self::OK or else an array with error information |
74 | 74 | */ |
75 | | - function verifyUpload( $resultDetails ) { |
| 75 | + function verifyUpload() { |
76 | 76 | // no checks on chunk upload mode: |
77 | 77 | if( $this->chunk_mode == UploadFromChunks::INIT ) |
78 | 78 | return self::OK; |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | // verify on init and last chunk request |
81 | 81 | if( $this->chunk_mode == UploadFromChunks::CHUNK || |
82 | 82 | $this->chunk_mode == UploadFromChunks::DONE ) |
83 | | - return parent::verifyUpload( $resultDetails ); |
| 83 | + return parent::verifyUpload(); |
84 | 84 | } |
85 | 85 | |
86 | 86 | // only run verifyFile on completed uploaded chunks |
— | — | @@ -114,6 +114,7 @@ |
115 | 115 | 'mComment' => $comment, |
116 | 116 | 'mSummary' => $summary, |
117 | 117 | 'mWatch' => $watch, |
| 118 | + 'mIgnorewarnings' => true, //ignore warning on chunk uploads (for now) |
118 | 119 | 'mFilteredName' => $this->mFilteredName, |
119 | 120 | 'mTempAppendPath' => null, // the repo append path (not temporary local node mTempPath) |
120 | 121 | 'mDesiredDestName' => $this->mDesiredDestName, |
— | — | @@ -230,7 +231,7 @@ |
231 | 232 | if( is_file( $this->getRealPath( $this->mTempAppendPath ) ) ){ |
232 | 233 | $status = $this->appendToUploadFile( $this->mTempAppendPath, $this->mTempPath ); |
233 | 234 | } else { |
234 | | - $status->fatal( 'filenotfound', $this->mTempAppendPath ); |
| 235 | + $status = Status::newFatal( 'filenotfound', $this->mTempAppendPath ); |
235 | 236 | } |
236 | 237 | return $status; |
237 | 238 | } |
Index: trunk/phase3/includes/api/ApiFormatJson_json.php |
— | — | @@ -816,7 +816,8 @@ |
817 | 817 | function isError($data, $code = null) |
818 | 818 | { |
819 | 819 | if (class_exists('pear')) { |
820 | | - return PEAR::isError($data, $code); |
| 820 | + //avoid some strict warnings on PEAR isError check (looks like http://pear.php.net/bugs/bug.php?id=9950 has been around for some time) |
| 821 | + return @PEAR::isError($data, $code); |
821 | 822 | } elseif (is_object($data) && (get_class($data) == 'services_json_error' || |
822 | 823 | is_subclass_of($data, 'services_json_error'))) { |
823 | 824 | return true; |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | attr_name = attr_name.split('|'); |
94 | 94 | } |
95 | 95 | |
96 | | - $j.each(item.getElementsByTagName( tag_name ), function (inx, node){ |
| 96 | + $j.each( item.getElementsByTagName( tag_name ), function ( inx, node ){ |
97 | 97 | var tag_val = ''; |
98 | 98 | if( node!=null && attr_name == null ){ |
99 | 99 | if( node.childNodes[0] != null){ |
— | — | @@ -101,11 +101,11 @@ |
102 | 102 | } |
103 | 103 | } |
104 | 104 | if( node!=null && attr_name != null){ |
105 | | - if(typeof attr_name == 'string'){ |
| 105 | + if( typeof attr_name == 'string' ){ |
106 | 106 | tag_val = $j.trim( $j( node ).attr( attr_name ) ); |
107 | 107 | }else{ |
108 | 108 | var attr_vals = {}; |
109 | | - for(var j in attr_name){ |
| 109 | + for( var j in attr_name ){ |
110 | 110 | if( $j(node).attr( attr_name[j] ).length != 0) |
111 | 111 | attr_vals[ attr_name[j] ] = $j.trim( $j(node).attr( attr_name[j]) ).replace(/(<([^>]+)>)/ig,""); |
112 | 112 | } |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js |
— | — | @@ -196,19 +196,19 @@ |
197 | 197 | _this.selectFogg(); |
198 | 198 | }); |
199 | 199 | //also setup the text file display on Click to select file: |
200 | | - $j(this.target_input_file_name).unbind().attr('readonly', 'readonly').click(function(){ |
| 200 | + $j( this.target_input_file_name ).unbind().attr('readonly', 'readonly').click(function(){ |
201 | 201 | _this.selectFogg(); |
202 | 202 | }) |
203 | 203 | |
204 | 204 | }else{ |
205 | 205 | //first check firefox version: |
206 | | - if(!($j.browser.mozilla && $j.browser.version >= '1.9.1')) { |
207 | | - js_log('show use latest::' + _this.target_use_latest_fox); |
208 | | - if(_this.target_use_latest_fox){ |
209 | | - if(_this.form_rewrite) |
210 | | - $j(_this.target_use_latest_fox).prepend( gM('fogg-for_improved_uplods') ); |
| 206 | + if(!( $j.browser.mozilla && $j.browser.version >= '1.9.1' )) { |
| 207 | + js_log( 'show use latest::' + _this.target_use_latest_fox ); |
| 208 | + if( _this.target_use_latest_fox ){ |
| 209 | + if( _this.form_rewrite ) |
| 210 | + $j( _this.target_use_latest_fox ).prepend( gM('fogg-for_improved_uplods') ); |
211 | 211 | |
212 | | - $j(_this.target_use_latest_fox).show(); |
| 212 | + $j( _this.target_use_latest_fox ).show(); |
213 | 213 | } |
214 | 214 | return ; |
215 | 215 | } |
— | — | @@ -224,7 +224,7 @@ |
225 | 225 | } |
226 | 226 | //if rewriting form use upload msg text |
227 | 227 | var upMsg = (_this.form_rewrite) ? gM('fogg-for_improved_uplods') : ''; |
228 | | - $j(_this.target_please_install).html( upMsg + gM('fogg-please_install',os_link )).css('padding', '10px').show(); |
| 228 | + $j( _this.target_please_install ).html( upMsg + gM('fogg-please_install',os_link )).css('padding', '10px').show(); |
229 | 229 | } |
230 | 230 | //setup the target save local file bindins: |
231 | 231 | $j( _this.target_btn_save_local_file ).unbind().click(function(){ |
— | — | @@ -243,7 +243,7 @@ |
244 | 244 | //assume input target |
245 | 245 | setupForm: function(){ |
246 | 246 | js_log('firefogg::setupForm::'); |
247 | | - //to parent form setup if we want http updates |
| 247 | + //to parent form setup if we want http updates |
248 | 248 | if( this.form_rewrite ){ |
249 | 249 | //do parent form setup: |
250 | 250 | this.pe_setupForm(); |
— | — | @@ -279,7 +279,7 @@ |
280 | 280 | inTag+= '/><span id="' + $j(this.selector).attr('name') + '_fogg-control"></span>'; |
281 | 281 | |
282 | 282 | js_log('set input: ' + inTag); |
283 | | - $j(this.selector).replaceWith(inTag); |
| 283 | + $j( this.selector ).replaceWith( inTag ); |
284 | 284 | |
285 | 285 | this.target_input_file_name = 'input[name=' + $j(this.selector).attr('name') + ']'; |
286 | 286 | //update the selector to the control target: |
— | — | @@ -292,6 +292,9 @@ |
293 | 293 | this.doControlBindings(); |
294 | 294 | }, |
295 | 295 | getEditForm:function(){ |
| 296 | + if( this.target_edit_from ){ |
| 297 | + return this.pe_getEditForm(); |
| 298 | + } |
296 | 299 | js_log('get form: action=' + $j(this.selector).parents().find("form").attr('action')); |
297 | 300 | return $j(this.selector).parents().find("form").get(0); |
298 | 301 | }, |
— | — | @@ -413,12 +416,12 @@ |
414 | 417 | }, |
415 | 418 | doUploadSwitch:function(){ |
416 | 419 | var _this = this; |
417 | | - js_log("firefogg: doUploadSwitch:: " + this.fogg_enabled); |
| 420 | + js_log( "firefogg: doUploadSwitch:: " + this.fogg_enabled ); |
418 | 421 | //make sure firefogg is enabled otherwise do parent UploadSwich: |
419 | 422 | if( !this.fogg_enabled || !this.firefogg_form_action ) |
420 | 423 | return _this.pe_doUploadSwitch(); |
421 | 424 | |
422 | | - //check what mode to use firefogg in: |
| 425 | + //check what mode to use firefogg in: |
423 | 426 | if( _this.upload_mode == 'post' ){ |
424 | 427 | _this.doEncode(); |
425 | 428 | }else if( _this.upload_mode == 'api' && _this.chunks_supported){ //if api mode and chunks supported do chunkUpload |
— | — | @@ -428,7 +431,7 @@ |
429 | 432 | } |
430 | 433 | }, |
431 | 434 | //doChunkUpload does both uploading and encoding at the same time and uploads one meg chunks as they are ready |
432 | | - doChunkUpload : function(){ |
| 435 | + doChunkUpload : function(){ |
433 | 436 | var _this = this; |
434 | 437 | _this.action_done = false; |
435 | 438 | |
— | — | @@ -455,17 +458,18 @@ |
456 | 459 | 'comment' : _this.formData['wpUploadDescription'], |
457 | 460 | 'enablechunks': true |
458 | 461 | }; |
| 462 | + |
459 | 463 | //check for editToken: |
460 | | - if(!this.etoken) |
| 464 | + if( !this.etoken ) |
461 | 465 | this.etoken = _this.formData['wpEditToken']; |
462 | 466 | |
463 | | - if(this.etoken) |
| 467 | + if( this.etoken ) |
464 | 468 | aReq['token'] = this.etoken; |
465 | 469 | |
466 | 470 | if( _this.formData['wpWatchthis'] ) |
467 | 471 | aReq['watch'] = _this.formData['wpWatchthis']; |
468 | 472 | |
469 | | - if( _this.formData['wpIgnoreWarning'] ) |
| 473 | + if( _this.formData['wpIgnoreWarning'] ) |
470 | 474 | aReq['ignorewarnings'] = _this.formData['wpIgnoreWarning']; |
471 | 475 | |
472 | 476 | js_log('do fogg upload/encode call: '+ _this.api_url + ' :: ' + JSON.stringify( aReq ) ); |
— | — | @@ -477,6 +481,7 @@ |
478 | 482 | }, |
479 | 483 | //doEncode and monitor progress: |
480 | 484 | doEncode : function(){ |
| 485 | + js_log('firefogg:doEncode'); |
481 | 486 | var _this = this; |
482 | 487 | _this.action_done = false; |
483 | 488 | _this.dispProgressOverlay(); |
— | — | @@ -597,7 +602,7 @@ |
598 | 603 | _this.updateProgressWin( gM('successfulupload'), gM( 'mv_upload_done', _this.fogg.resultUrl),buttons); |
599 | 604 | }else{ |
600 | 605 | //done state with error? ..not really possible given how firefogg works |
601 | | - js_log(" upload done, in chunks mode, but no resultUrl!"); |
| 606 | + js_log(" upload done, in chunks mode, but no resultUrl::" + response_text); |
602 | 607 | } |
603 | 608 | } |
604 | 609 | }else{ |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js |
— | — | @@ -45,9 +45,11 @@ |
46 | 46 | 'parent_uploader':null, |
47 | 47 | 'edit_from':null, |
48 | 48 | 'done_upload_cb': null, |
| 49 | + 'target_edit_from':null, |
49 | 50 | |
50 | 51 | //upload_mode can be 'post', 'chunks' or autodetect. (autodetect issues an api call) |
51 | 52 | 'upload_mode':'autodetect' |
| 53 | + |
52 | 54 | } |
53 | 55 | var mvBaseUploadInterface = function( iObj ){ |
54 | 56 | return this.init( iObj ); |
— | — | @@ -63,7 +65,7 @@ |
64 | 66 | etoken:false, |
65 | 67 | init: function( iObj ){ |
66 | 68 | if(!iObj) |
67 | | - iObj = {}; |
| 69 | + iObj = {}; |
68 | 70 | //inherit iObj properties: |
69 | 71 | for(var i in default_bui_options){ |
70 | 72 | if(iObj[i]){ |
— | — | @@ -74,22 +76,22 @@ |
75 | 77 | } |
76 | 78 | }, |
77 | 79 | setupForm:function(){ |
78 | | - var _this = this; |
| 80 | + var _this = this; |
79 | 81 | //set up the local pointer to the edit form: |
80 | | - _this.editForm = _this.getEditForm(); |
81 | | - |
82 | | - if(_this.editForm){ |
| 82 | + _this.editForm = _this.getEditForm(); |
| 83 | + |
| 84 | + if( _this.editForm ){ |
83 | 85 | //set up the org_onsubmit if not set: |
84 | | - if( typeof( _this.org_onsubmit ) == 'undefined' ) |
85 | | - _this.org_onsubmit = _this.editForm.onsubmit; |
| 86 | + if( typeof( _this.org_onsubmit ) == 'undefined' && _this.editForm.onsubmit ) |
| 87 | + _this.org_onsubmit = _this.editForm.onsubmit; |
86 | 88 | |
87 | 89 | //have to define the onsubmit function inline or its hard to pass the "_this" instance |
88 | | - _this.editForm.onsubmit = function(){ |
| 90 | + $j( '#mw-upload-form' ).submit( function(){ |
89 | 91 | //run the original onsubmit (if not run yet set flag to avoid excessive chaining ) |
90 | | - if( typeof( _this.org_onsubmit ) == 'function' ){ |
| 92 | + if( typeof( _this.org_onsubmit ) == 'function' ){ |
91 | 93 | if( ! _this.org_onsubmit() ){ |
92 | 94 | //error in org submit return false; |
93 | | - return false; |
| 95 | + return false; |
94 | 96 | } |
95 | 97 | } |
96 | 98 | //check for post action override: |
— | — | @@ -119,7 +121,7 @@ |
120 | 122 | |
121 | 123 | //don't submit the form we will do the post in ajax |
122 | 124 | return false; |
123 | | - }; |
| 125 | + }); |
124 | 126 | } |
125 | 127 | |
126 | 128 | }, |
— | — | @@ -524,9 +526,9 @@ |
525 | 527 | getProgressTitle:function(){ |
526 | 528 | return gM('upload-in-progress'); |
527 | 529 | }, |
528 | | - getEditForm:function(){ |
529 | | - if(this.target_edit_from){ |
530 | | - return $j(this.target_edit_from).get(0); |
| 530 | + getEditForm:function(){ |
| 531 | + if( this.target_edit_from && $j( this.target_edit_from ).length != 0){ |
| 532 | + return $j( this.target_edit_from ).get(0); |
531 | 533 | } |
532 | 534 | //just return the first form fond on the page. |
533 | 535 | return $j('form :first').get(0); |
Index: trunk/phase3/js2/mwEmbed/mv_embed.js |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | MV_DO_INIT=false; |
22 | 22 | } |
23 | 23 | //used to grab fresh copies of scripts. (should be changed on commit) |
24 | | -var MV_EMBED_VERSION = '1.0r17'; |
| 24 | +var MV_EMBED_VERSION = '1.0r18'; |
25 | 25 | |
26 | 26 | /* |
27 | 27 | * Configuration variables (can be set from some precceding script) |
Index: trunk/phase3/js2/uploadPage.js |
— | — | @@ -5,6 +5,7 @@ |
6 | 6 | js2AddOnloadHook( function(){ |
7 | 7 | mwUploadHelper.init(); |
8 | 8 | }); |
| 9 | +var mwUploadFormTarget = '#mw-upload-form'; |
9 | 10 | //set up the upoload form bindings once all dom manipluation is done |
10 | 11 | var mwUploadHelper = { |
11 | 12 | firefogg_installed:false, |
— | — | @@ -19,13 +20,14 @@ |
20 | 21 | $j('#wpUploadFile').firefogg({ |
21 | 22 | //an api url (we won't submit directly to action of the form) |
22 | 23 | 'api_url' : wgServer + wgScriptPath + '/api.php', |
23 | | - 'form_rewrite': true, |
| 24 | + 'form_rewrite': true, |
| 25 | + 'target_edit_from' : mwUploadFormTarget, |
24 | 26 | 'new_source_cb' : function( orgFilename, oggName ){ |
25 | 27 | if($j('#wpDestFile').val() == "") |
26 | 28 | $j('#wpDestFile').val( oggName ); |
27 | 29 | mwUploadHelper.doDestCheck(); |
28 | 30 | }, |
29 | | - 'detect_cb':function(fogg_installed){ |
| 31 | + 'detect_cb':function( fogg_installed ){ |
30 | 32 | if(fogg_installed){ |
31 | 33 | _this.firefogg_installed=true; |
32 | 34 | }else{ |
— | — | @@ -39,7 +41,7 @@ |
40 | 42 | if($j('#wpUploadFileURL').length != 0){ |
41 | 43 | $j('#wpUploadFileURL').baseUploadInterface({ |
42 | 44 | 'api_url' : wgServer + wgScriptPath + '/api.php', |
43 | | - 'target_edit_from' : '#mw-upload-form' |
| 45 | + 'target_edit_from' : mwUploadFormTarget |
44 | 46 | }); |
45 | 47 | } |
46 | 48 | } |