* fixes for firefogg multiple forms on the special upload page.
function isError($data, $code = null)
{
if (class_exists('pear')) {
- return PEAR::isError($data, $code);
+ //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)
+ return @PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
return true;
* Verify whether the upload is sane.
* Returns self::OK or else an array with error information
*/
- function verifyUpload( $resultDetails ) {
+ function verifyUpload() {
// no checks on chunk upload mode:
if( $this->chunk_mode == UploadFromChunks::INIT )
return self::OK;
// verify on init and last chunk request
if( $this->chunk_mode == UploadFromChunks::CHUNK ||
$this->chunk_mode == UploadFromChunks::DONE )
- return parent::verifyUpload( $resultDetails );
+ return parent::verifyUpload();
}
// only run verifyFile on completed uploaded chunks
'mComment' => $comment,
'mSummary' => $summary,
'mWatch' => $watch,
+ 'mIgnorewarnings' => true, //ignore warning on chunk uploads (for now)
'mFilteredName' => $this->mFilteredName,
'mTempAppendPath' => null, // the repo append path (not temporary local node mTempPath)
'mDesiredDestName' => $this->mDesiredDestName,
if( is_file( $this->getRealPath( $this->mTempAppendPath ) ) ){
$status = $this->appendToUploadFile( $this->mTempAppendPath, $this->mTempPath );
} else {
- $status->fatal( 'filenotfound', $this->mTempAppendPath );
+ $status = Status::newFatal( 'filenotfound', $this->mTempAppendPath );
}
return $status;
}
'parent_uploader':null,
'edit_from':null,
'done_upload_cb': null,
+ 'target_edit_from':null,
//upload_mode can be 'post', 'chunks' or autodetect. (autodetect issues an api call)
'upload_mode':'autodetect'
+
}
var mvBaseUploadInterface = function( iObj ){
return this.init( iObj );
etoken:false,
init: function( iObj ){
if(!iObj)
- iObj = {};
+ iObj = {};
//inherit iObj properties:
for(var i in default_bui_options){
if(iObj[i]){
}
},
setupForm:function(){
- var _this = this;
+ var _this = this;
//set up the local pointer to the edit form:
- _this.editForm = _this.getEditForm();
-
- if(_this.editForm){
+ _this.editForm = _this.getEditForm();
+
+ if( _this.editForm ){
//set up the org_onsubmit if not set:
- if( typeof( _this.org_onsubmit ) == 'undefined' )
- _this.org_onsubmit = _this.editForm.onsubmit;
+ if( typeof( _this.org_onsubmit ) == 'undefined' && _this.editForm.onsubmit )
+ _this.org_onsubmit = _this.editForm.onsubmit;
//have to define the onsubmit function inline or its hard to pass the "_this" instance
- _this.editForm.onsubmit = function(){
+ $j( '#mw-upload-form' ).submit( function(){
//run the original onsubmit (if not run yet set flag to avoid excessive chaining )
- if( typeof( _this.org_onsubmit ) == 'function' ){
+ if( typeof( _this.org_onsubmit ) == 'function' ){
if( ! _this.org_onsubmit() ){
//error in org submit return false;
- return false;
+ return false;
}
}
//check for post action override:
//don't submit the form we will do the post in ajax
return false;
- };
+ });
}
},
getProgressTitle:function(){
return gM('upload-in-progress');
},
- getEditForm:function(){
- if(this.target_edit_from){
- return $j(this.target_edit_from).get(0);
+ getEditForm:function(){
+ if( this.target_edit_from && $j( this.target_edit_from ).length != 0){
+ return $j( this.target_edit_from ).get(0);
}
//just return the first form fond on the page.
return $j('form :first').get(0);
_this.selectFogg();
});
//also setup the text file display on Click to select file:
- $j(this.target_input_file_name).unbind().attr('readonly', 'readonly').click(function(){
+ $j( this.target_input_file_name ).unbind().attr('readonly', 'readonly').click(function(){
_this.selectFogg();
})
}else{
//first check firefox version:
- if(!($j.browser.mozilla && $j.browser.version >= '1.9.1')) {
- js_log('show use latest::' + _this.target_use_latest_fox);
- if(_this.target_use_latest_fox){
- if(_this.form_rewrite)
- $j(_this.target_use_latest_fox).prepend( gM('fogg-for_improved_uplods') );
+ if(!( $j.browser.mozilla && $j.browser.version >= '1.9.1' )) {
+ js_log( 'show use latest::' + _this.target_use_latest_fox );
+ if( _this.target_use_latest_fox ){
+ if( _this.form_rewrite )
+ $j( _this.target_use_latest_fox ).prepend( gM('fogg-for_improved_uplods') );
- $j(_this.target_use_latest_fox).show();
+ $j( _this.target_use_latest_fox ).show();
}
return ;
}
}
//if rewriting form use upload msg text
var upMsg = (_this.form_rewrite) ? gM('fogg-for_improved_uplods') : '';
- $j(_this.target_please_install).html( upMsg + gM('fogg-please_install',os_link )).css('padding', '10px').show();
+ $j( _this.target_please_install ).html( upMsg + gM('fogg-please_install',os_link )).css('padding', '10px').show();
}
//setup the target save local file bindins:
$j( _this.target_btn_save_local_file ).unbind().click(function(){
//assume input target
setupForm: function(){
js_log('firefogg::setupForm::');
- //to parent form setup if we want http updates
+ //to parent form setup if we want http updates
if( this.form_rewrite ){
//do parent form setup:
this.pe_setupForm();
inTag+= '/><span id="' + $j(this.selector).attr('name') + '_fogg-control"></span>';
js_log('set input: ' + inTag);
- $j(this.selector).replaceWith(inTag);
+ $j( this.selector ).replaceWith( inTag );
this.target_input_file_name = 'input[name=' + $j(this.selector).attr('name') + ']';
//update the selector to the control target:
this.doControlBindings();
},
getEditForm:function(){
+ if( this.target_edit_from ){
+ return this.pe_getEditForm();
+ }
js_log('get form: action=' + $j(this.selector).parents().find("form").attr('action'));
return $j(this.selector).parents().find("form").get(0);
},
},
doUploadSwitch:function(){
var _this = this;
- js_log("firefogg: doUploadSwitch:: " + this.fogg_enabled);
+ js_log( "firefogg: doUploadSwitch:: " + this.fogg_enabled );
//make sure firefogg is enabled otherwise do parent UploadSwich:
if( !this.fogg_enabled || !this.firefogg_form_action )
return _this.pe_doUploadSwitch();
- //check what mode to use firefogg in:
+ //check what mode to use firefogg in:
if( _this.upload_mode == 'post' ){
_this.doEncode();
}else if( _this.upload_mode == 'api' && _this.chunks_supported){ //if api mode and chunks supported do chunkUpload
}
},
//doChunkUpload does both uploading and encoding at the same time and uploads one meg chunks as they are ready
- doChunkUpload : function(){
+ doChunkUpload : function(){
var _this = this;
_this.action_done = false;
'comment' : _this.formData['wpUploadDescription'],
'enablechunks': true
};
+
//check for editToken:
- if(!this.etoken)
+ if( !this.etoken )
this.etoken = _this.formData['wpEditToken'];
- if(this.etoken)
+ if( this.etoken )
aReq['token'] = this.etoken;
if( _this.formData['wpWatchthis'] )
aReq['watch'] = _this.formData['wpWatchthis'];
- if( _this.formData['wpIgnoreWarning'] )
+ if( _this.formData['wpIgnoreWarning'] )
aReq['ignorewarnings'] = _this.formData['wpIgnoreWarning'];
js_log('do fogg upload/encode call: '+ _this.api_url + ' :: ' + JSON.stringify( aReq ) );
},
//doEncode and monitor progress:
doEncode : function(){
+ js_log('firefogg:doEncode');
var _this = this;
_this.action_done = false;
_this.dispProgressOverlay();
_this.updateProgressWin( gM('successfulupload'), gM( 'mv_upload_done', _this.fogg.resultUrl),buttons);
}else{
//done state with error? ..not really possible given how firefogg works
- js_log(" upload done, in chunks mode, but no resultUrl!");
+ js_log(" upload done, in chunks mode, but no resultUrl::" + response_text);
}
}
}else{
attr_name = attr_name.split('|');
}
- $j.each(item.getElementsByTagName( tag_name ), function (inx, node){
+ $j.each( item.getElementsByTagName( tag_name ), function ( inx, node ){
var tag_val = '';
if( node!=null && attr_name == null ){
if( node.childNodes[0] != null){
}
}
if( node!=null && attr_name != null){
- if(typeof attr_name == 'string'){
+ if( typeof attr_name == 'string' ){
tag_val = $j.trim( $j( node ).attr( attr_name ) );
}else{
var attr_vals = {};
- for(var j in attr_name){
+ for( var j in attr_name ){
if( $j(node).attr( attr_name[j] ).length != 0)
attr_vals[ attr_name[j] ] = $j.trim( $j(node).attr( attr_name[j]) ).replace(/(<([^>]+)>)/ig,"");
}
MV_DO_INIT=false;
}
//used to grab fresh copies of scripts. (should be changed on commit)
-var MV_EMBED_VERSION = '1.0r17';
+var MV_EMBED_VERSION = '1.0r18';
/*
* Configuration variables (can be set from some precceding script)
js2AddOnloadHook( function(){
mwUploadHelper.init();
});
+var mwUploadFormTarget = '#mw-upload-form';
//set up the upoload form bindings once all dom manipluation is done
var mwUploadHelper = {
firefogg_installed:false,
$j('#wpUploadFile').firefogg({
//an api url (we won't submit directly to action of the form)
'api_url' : wgServer + wgScriptPath + '/api.php',
- 'form_rewrite': true,
+ 'form_rewrite': true,
+ 'target_edit_from' : mwUploadFormTarget,
'new_source_cb' : function( orgFilename, oggName ){
if($j('#wpDestFile').val() == "")
$j('#wpDestFile').val( oggName );
mwUploadHelper.doDestCheck();
},
- 'detect_cb':function(fogg_installed){
+ 'detect_cb':function( fogg_installed ){
if(fogg_installed){
_this.firefogg_installed=true;
}else{
if($j('#wpUploadFileURL').length != 0){
$j('#wpUploadFileURL').baseUploadInterface({
'api_url' : wgServer + wgScriptPath + '/api.php',
- 'target_edit_from' : '#mw-upload-form'
+ 'target_edit_from' : mwUploadFormTarget
});
}
}
var onloadFuncts = [];
}
-//should use mwAddOnloadHook once js2 is enabled
+//code that is dependent on js2 functions should use js2AddOnloadHook
function addOnloadHook(hookFunct) {
// Allows add-on scripts to add onload functions
if(!doneOnloadHook) {
}
}
+
function hookEvent(hookName, hookFunct) {
addHandler(window, hookName, hookFunct);
}