Beispiel #1
0
    function Display()
    {
        global $is_IE, $is_opera;
        $id = $this->id;
        $upload_size_unit = $max_upload_size = WPFB_Core::GetMaxUlSize();
        $sizes = array('KB', 'MB', 'GB');
        for ($u = -1; $upload_size_unit > 1024 && $u < count($sizes) - 1; $u++) {
            $upload_size_unit /= 1024;
        }
        if ($u < 0) {
            $upload_size_unit = 0;
            $u = 0;
        } else {
            $upload_size_unit = (int) $upload_size_unit;
        }
        do_action('pre-upload-ui');
        $plupload_init = array('runtimes' => 'html5,silverlight,flash,html4', 'browse_button' => 'plupload-browse-button', 'container' => 'plupload-upload-ui', 'drop_element' => 'drag-drop-area', 'file_data_name' => 'async-upload', 'multiple_queues' => false, 'max_file_size' => $max_upload_size . 'b', 'url' => add_query_arg('wpfb_action', 'upload', WPFB_Core::$ajax_url_public), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => __('Allowed Files'), 'extensions' => '*')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => $this->GetAjaxAuthData());
        $plupload_init = apply_filters('plupload_init', $plupload_init);
        ?>

<script type="text/javascript">
var resize_height = 1024, resize_width = 1024, // this is for img resizing (not used here!)
wpUploaderInit = <?php 
        echo json_encode($plupload_init);
        ?>
;
</script>

<input type="hidden" id="file_flash_upload" name="file_flash_upload" value="0" />

<div id="plupload-upload-ui" class="hide-if-no-js">
<?php 
        do_action('pre-plupload-upload-ui');
        // hook change, old name: 'pre-flash-upload-ui'
        ?>
<div id="drag-drop-area">
	<div class="drag-drop-inside">
		<p class="drag-drop-info"><?php 
        _e('Drop files here - or -', 'wp-filebase');
        ?>
</p>
		<div class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php 
        esc_attr_e('Select Files');
        ?>
" class="button" /></div>
		<div class="drag-drop-info-spacer"></div>
	</div>
</div>
	<p class="upload-flash-bypass">
	<?php 
        printf(__('You are using the multi-file uploader. Problems? Try the <a href="%1$s">browser uploader</a> instead.'), esc_url(add_query_arg('flash', 0)));
        ?>
	</p>
	
</div>

<?php 
        if (($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024) {
            ?>
	<span class="big-file-warning"><?php 
            _e('Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.');
            ?>
</span>
<?php 
        }
        ?>
	<div id="media-upload-error"></div>
	<div id="file-upload-progress" class="media-item" style="width: auto;"></div>
<?php 
        //do_action('post-upload-ui');
    }
Beispiel #2
0
    ?>
" />
			</div>
			<div id="wpfilebase-upload-tabs">
				<div id="file-upload-wrap" <?php 
    echo $file->IsRemote() ? 'class="hidden"' : '';
    ?>
>
					<div id="html-upload-ui">
						<label for="file_upload"><?php 
    _e('Choose File', WPFB);
    ?>
</label>
						<input type="file" name="file_upload" id="file_upload" /><br />
						<?php 
    printf(str_replace('%d%s', '%s', __('Maximum upload file size: %d%s')), WPFB_Output::FormatFilesize(WPFB_Core::GetMaxUlSize()));
    ?>
 <b>&nbsp;&nbsp;<a href="#" onclick="alert(this.title); return false;" title="<?php 
    printf(__('Ask your webhoster to increase this limit, it is set in %s.', WPFB), 'php.ini');
    ?>
">?</a></b>
						<p class="upload-html-bypass hide-if-no-js"><?php 
    _e('You are using the Browser uploader.');
    printf(__('Try the <a href="%s">Flash uploader</a> instead.'), esc_url(add_query_arg('flash', 1)));
    ?>
					</div>
					<div id="flash-upload-ui"><?php 
    $adv_uploader->Display();
    ?>
</div> <!--  flash-upload-ui -->
					<?php 
Beispiel #3
0
    static function FileForm($prefix, $form_url, $vars, $secret_key = null)
    {
        unset($vars['adv_uploader']);
        // dont use adv_uploader arg for noncing! TODO
        ?>
	<div class="form-wrap">
		<form enctype="multipart/form-data" name="<?php 
        echo $prefix;
        ?>
form" id="<?php 
        echo $prefix;
        ?>
form" method="post" action="<?php 
        echo $form_url;
        ?>
">
			<div>
				<?php 
        self::DisplayExtendedFormFields($prefix, $secret_key, $vars);
        ?>
				
				<?php 
        if (empty($adv_uploader)) {
            ?>
					<label for="<?php 
            echo $prefix;
            ?>
file_upload"><?php 
            _e('Choose File', WPFB);
            ?>
</label>
					<input type="file" name="file_upload" id="<?php 
            echo $prefix;
            ?>
file_upload" /><br /> <!--   style="width: 160px" size="10" -->
				<?php 
        } else {
            $adv_uploader->Display($prefix);
        }
        ?>
				<small><?php 
        printf(str_replace('%d%s', '%s', __('Maximum upload file size: %d%s.')), WPFB_Output::FormatFilesize(WPFB_Core::GetMaxUlSize()));
        ?>
</small>
				
				<?php 
        if (empty($auto_submit)) {
            ?>
<div style="float: right; text-align:right;"><input type="submit" class="button-primary" name="submit-btn" value="<?php 
            _e('Add New', WPFB);
            ?>
" /></div>
				<?php 
        }
        ?>
			</div>
		</form>	
	</div>
	<?php 
    }
Beispiel #4
0
		</div>
		<div id="wpfilebase-upload-tabs">
			<div id="file-upload-wrap" <?php 
echo $file->IsRemote() ? 'class="hidden"' : '';
?>
>
				<div id="file_thumbnail_preview"></div>

				<div id="html-upload-ui">
					<label for="file_upload"><?php 
_e('Choose File', 'wp-filebase');
?>
</label>
					<input type="file" name="file_upload" id="file_upload" /><br />
					<?php 
printf(__('Maximum upload file size: %s.'), WPFB_Output::FormatFilesize(WPFB_Core::GetMaxUlSize()));
?>
 <b>&nbsp;&nbsp;<a href="#" onclick="return alert(this.title) && false;" title="<?php 
printf(__('Ask your webhoster to increase this limit, it is set in %s.', 'wp-filebase'), 'php.ini');
?>
">?</a></b>
					<p class="upload-html-bypass hide-if-no-js"><?php 
_e('You are using the Browser uploader.');
printf(__('Try the <a href="%s">Drag&amp;Drop uploader</a> instead.', 'wp-filebase'), esc_url(add_query_arg('flash', 1)));
?>
				</div>
				<div id="flash-upload-ui"><?php 
$adv_uploader->Display();
?>
					<script> jQuery('#file-upload-progress').appendTo('#wpfilebase-upload-menu').addClass('admin-scheme-color-3');</script>
				</div> <!--  flash-upload-ui -->
Beispiel #5
0
    public function Init($cotainer_id, $browser_btn_id = '', $error_el_id = null, $drop_el_id = null)
    {
        if (empty($drop_el_id)) {
            $drop_el_id = $cotainer_id;
        }
        if (empty($browser_btn_id)) {
            $browser_btn_id = $cotainer_id . '-btn';
            echo '<input type="button" value="Select Files" id="' . $browser_btn_id . '" style="display:none;" />';
        }
        $max_upload_size = WPFB_Core::GetMaxUlSize();
        if (is_admin()) {
            self::PrintScripts();
        }
        $plupload_init = array('runtimes' => 'html5,gears,silverlight,flash,html4', 'browse_button' => $browser_btn_id, 'container' => $cotainer_id, 'drop_element' => $drop_el_id, 'file_data_name' => 'async-upload', 'multiple_queues' => $this->multi, 'max_file_size' => $max_upload_size . 'b', 'url' => WPFB_Core::PluginUrl('wpfb-async-upload.php'), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => $this->images_only ? __('Images') : __('Allowed Files'), 'extensions' => $this->images_only ? 'jpg,gif,png,bmp' : '*')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => array_merge($this->GetAjaxAuthData(), $this->post_params));
        $jss = md5(uniqid());
        ?>
<script type="text/javascript">
	init_<?php 
        echo $jss;
        ?>
 = (function() {
		if('undefined' == typeof plupload) {
			setTimeout(init_<?php 
        echo $jss;
        ?>
, 100);
			return;
		}
		var uploader = new plupload.Uploader(<?php 
        echo json_encode($plupload_init);
        ?>
);
		
		uploader.bind('Init', function(up) {
			var uploaddiv = jQuery('#<?php 
        echo $cotainer_id;
        ?>
');
			var dropdiv = jQuery('#<?php 
        echo $drop_el_id;
        ?>
');
			
			uploaddiv.data('uploader', up);

			if ( !jQuery(document.body).hasClass('mobile') ) {
				dropdiv.addClass('drag-drop');
				dropdiv.bind('dragover', function(e){ dropdiv.addClass('drag-over'); })
						  .bind('dragleave', function(e){ dropdiv.removeClass('drag-over'); })
						  .bind('drop', function(e){	dropdiv.removeClass('drag-over'); });
			} else {
				dropdiv.removeClass('drag-drop');
				//dropdiv.hide();
			}

//			if ( up.runtime == 'html4' )
//				jQuery('.upload-flash-bypass').hide();
		});
		
		uploader.init();
		
		var mobile = <?php 
        echo (int) wp_is_mobile();
        ?>
;
		var supported = <?php 
        echo (int) (!wp_is_mobile() || function_exists('_device_can_upload') && _device_can_upload());
        ?>
;
			
		var supports_dragdrop = uploader.features.dragdrop && !mobile;

		// Generate drag/drop helper classes.
		(function( dropzone, supported ) {
			var timer, active;

			if ( ! dropzone )
				return;

			dropzone.toggleClass( 'supports-drag-drop', !! supported );

			if ( ! supported )
				return dropzone.unbind('.wp-uploader');

			// 'dragenter' doesn't fire correctly,
			// simulate it with a limited 'dragover'
			dropzone.bind( 'dragover.wp-uploader', function(){
				if ( timer )
					clearTimeout( timer );

				if ( active )
					return;

				dropzone.trigger('dropzone:enter').addClass('drag-over');
				active = true;
			});

			dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function(){
				// Using an instant timer prevents the drag-over class from
				// being quickly removed and re-added when elements inside the
				// dropzone are repositioned.
				//
				// See http://core.trac.wordpress.org/ticket/21705
				timer = setTimeout( function() {
					active = false;
					dropzone.trigger('dropzone:leave').removeClass('drag-over');
				}, 0 );
			});
		}( jQuery('#<?php 
        echo $drop_el_id;
        ?>
'), supports_dragdrop ));
		
		uploader.bind('FilesAdded', function(up, files) {
			var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10);

			<?php 
        if (!empty($error_el_id)) {
            ?>
 jQuery('#<?php 
            echo $error_el_id;
            ?>
').html('');<?php 
        }
        ?>
			
			<?php 
        if (!empty($this->js_files_queued)) {
            echo $this->js_files_queued . '(up, files)';
        }
        ?>

			plupload.each(files, function(file){
				if ( max > hundredmb && file.size > hundredmb && up.runtime != 'html5' )
					wpfbPlUploadSizeError( up, file, true );
				else {
					file.dom_id = '<?php 
        echo $cotainer_id;
        ?>
-ul'+file.id;
					<?php 
        echo $this->js_file_queued;
        ?>
(up, file);
				}
			});

			up.refresh();
			up.start();
		});

		uploader.bind('BeforeUpload', function(up, file) {
			// something
		});

		uploader.bind('UploadFile', function(up, file) {
			wpfbPlFileUploading(up, file);
		});

		uploader.bind('UploadProgress', function(up, file) {
			var item = jQuery('#'+file.dom_id);
			jQuery('.bar', item).width( (200 * file.loaded) / file.size );
			jQuery('.percent', item).html( file.percent + '%' );
			<?php 
        if (!empty($this->js_upload_progress)) {
            echo $this->js_upload_progress . '(file);';
        }
        ?>
		});

		uploader.bind('Error', function(up, err) {
			wpfbPlUploadError(err.file, err.code, err.message, up);
			up.refresh();
		});

		uploader.bind('FileUploaded', function(up, file, response) {
			// on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag
			var serverData = response.response.replace(/^<pre>(.+)<\/pre>$/, '$1');
			
			if ( serverData.match('media-upload-error') || serverData.match('error-div') ) {
				wpfbPlFileError(file, serverData);
				return;
			}
			
			serverData = jQuery.parseJSON(serverData);
			
			<?php 
        echo $this->js_upload_success;
        ?>
(file, serverData);
		});

		uploader.bind('UploadComplete', function(up, files) {
			//uploadComplete();
		}); 
		
		
	
	
	
	
	


	


function wpfbPlFileUploading(up, file) {
	var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10);

	if ( max > hundredmb && file.size > hundredmb ) {
		setTimeout(function(){
			var done;

			if ( file.status < 3 && file.loaded == 0 ) { // not uploading
				wpfbPlFileError(file, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'));
				up.stop(); // stops the whole queue
				up.removeFile(file);
				up.start(); // restart the queue
			}
		}, 10000); // wait for 10 sec. for the file to start uploading
	}
}

/*
function uploadProgress(up, file) {
	var item = jQuery('#media-item-' + file.id);

	jQuery('.bar', item).width( (200 * file.loaded) / file.size );
	jQuery('.percent', item).html( file.percent + '%' );
}*/


function wpfbPlUploadSizeError( up, file, over100mb ) {
	var message;

	if ( over100mb )
		message = pluploadL10n.big_upload_queued.replace('%s', file.name) + ' ' + pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>');
	else
		message = pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);

	<?php 
        echo $this->js_file_error;
        ?>
 (message,file);

	up.removeFile(file);
}

function wpfbPlUploadError(fileObj, errorCode, message, uploader) {
	var hundredmb = 100 * 1024 * 1024, max;

	switch (errorCode) {
		case plupload.FAILED:
			wpfbPlFileError(fileObj, pluploadL10n.upload_failed);
			break;
		case plupload.FILE_EXTENSION_ERROR:
			wpfbPlFileError(fileObj, pluploadL10n.invalid_filetype);
			break;
		case plupload.FILE_SIZE_ERROR:
			wpfbPlUploadSizeError(uploader, fileObj);
			break;
		case plupload.IMAGE_FORMAT_ERROR:
			wpfbPlFileError(fileObj, pluploadL10n.not_an_image);
			break;
		case plupload.IMAGE_MEMORY_ERROR:
			wpfbPlFileError(fileObj, pluploadL10n.image_memory_exceeded);
			break;
		case plupload.IMAGE_DIMENSIONS_ERROR:
			wpfbPlFileError(fileObj, pluploadL10n.image_dimensions_exceeded);
			break;
		case plupload.GENERIC_ERROR:
			wpfbPlQueueError(pluploadL10n.upload_failed);
			break;
		case plupload.IO_ERROR:
			max = parseInt(uploader.settings.max_file_size, 10);

			if ( max > hundredmb && fileObj.size > hundredmb )
				wpfbPlFileError(fileObj, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'));
			else
				wpfbPlQueueError(pluploadL10n.io_error);
			break;
		case plupload.HTTP_ERROR:
			wpfbPlQueueError(pluploadL10n.http_error);
			break;
		case plupload.INIT_ERROR:
			//jQuery('.media-upload-form').addClass('html-uploader');
			// TODO: on init failure
			break;
		case plupload.SECURITY_ERROR:
			wpfbPlQueueError(pluploadL10n.security_error);
			break;
/*		case plupload.UPLOAD_ERROR.UPLOAD_STOPPED:
		case plupload.UPLOAD_ERROR.FILE_CANCELLED:
			jQuery('#media-item-' + fileObj.id).remove();
			break;*/
		default:
			wpfbPlFileError(fileObj, pluploadL10n.default_error);
	}
}






function wpfbPlFileError(fileObj, message) {
	var item = jQuery('#' + fileObj.dom_id);
	jQuery('.error', item).show().html(message);
	<?php 
        if (!empty($this->js_file_error)) {
            ?>
 <?php 
            echo $this->js_file_error;
            ?>
 (message,fileObj); <?php 
        }
        ?>
}

// generic error message
function wpfbPlQueueError(message) {
	<?php 
        if (!empty($error_el_id)) {
            ?>
			jQuery('#<?php 
            echo $error_el_id;
            ?>
').show().html( '<div class="error"><p>' + message + '</p></div>' ); 
	<?php 
        } else {
            ?>
			alert(message);
	<?php 
        }
        ?>
}
	});
	init_<?php 
        echo $jss;
        ?>
();
</script>
<?php 
    }
Beispiel #6
0
    public function Init($cotainer_id, $browser_btn_id, $drop_el_id, $error_el_id)
    {
        $max_upload_size = WPFB_Core::GetMaxUlSize();
        wp_print_scripts('plupload-all');
        wp_print_scripts('wp-plupload');
        $plupload_init = array('runtimes' => 'html5,gears,silverlight,flash,html4', 'browse_button' => $browser_btn_id, 'container' => $cotainer_id, 'drop_element' => $drop_el_id, 'file_data_name' => 'async-upload', 'multiple_queues' => $this->multi, 'max_file_size' => $max_upload_size . 'b', 'url' => WPFB_PLUGIN_URI . 'wpfb-async-upload.php', 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => $this->images_only ? __('Images') : __('Allowed Files'), 'extensions' => $this->images_only ? 'jpg,gif,png,bmp' : '*')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => array_merge($this->GetAjaxAuthData(), $this->post_params));
        ?>
<script type="text/javascript">
	(function() {
		var uploader = new plupload.Uploader(<?php 
        echo json_encode($plupload_init);
        ?>
);
		
		uploader.bind('Init', function(up) {
			//var uploaddiv = jQuery('#<?php 
        echo $cotainer_id;
        ?>
');
			var dropdiv = jQuery('#<?php 
        echo $drop_el_id;
        ?>
');

			if ( !jQuery(document.body).hasClass('mobile') ) {
				dropdiv.addClass('drag-drop');
				dropdiv.bind('dragover', function(e){
					dropdiv.addClass('drag-over');
				}).bind('dragleave, drop', function(){
					dropdiv.removeClass('drag-over');
				});
			} else {
				dropdiv.removeClass('drag-drop');
				dropdiv.hide();
			}

//			if ( up.runtime == 'html4' )
//				jQuery('.upload-flash-bypass').hide();
		});
		
		uploader.init();
		
		var mobile = <?php 
        echo (int) wp_is_mobile();
        ?>
;
		var supported = <?php 
        echo (int) (!wp_is_mobile() || function_exists('_device_can_upload') && _device_can_upload());
        ?>
;
			
		var supports_dragdrop = uploader.features.dragdrop && !mobile;

		// Generate drag/drop helper classes.
		(function( dropzone, supported ) {
			var timer, active;

			if ( ! dropzone )
				return;

			dropzone.toggleClass( 'supports-drag-drop', !! supported );

			if ( ! supported )
				return dropzone.unbind('.wp-uploader');

			// 'dragenter' doesn't fire correctly,
			// simulate it with a limited 'dragover'
			dropzone.bind( 'dragover.wp-uploader', function(){
				if ( timer )
					clearTimeout( timer );

				if ( active )
					return;

				dropzone.trigger('dropzone:enter').addClass('drag-over');
				active = true;
			});

			dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function(){
				// Using an instant timer prevents the drag-over class from
				// being quickly removed and re-added when elements inside the
				// dropzone are repositioned.
				//
				// See http://core.trac.wordpress.org/ticket/21705
				timer = setTimeout( function() {
					active = false;
					dropzone.trigger('dropzone:leave').removeClass('drag-over');
				}, 0 );
			});
		}( jQuery('#<?php 
        echo $drop_el_id;
        ?>
'), supports_dragdrop ));
		
		uploader.bind('FilesAdded', function(up, files) {
			var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10);

			jQuery('#<?php 
        echo $error_el_id;
        ?>
').html('');
			
			<?php 
        if (!empty($this->js_files_queued)) {
            echo $this->js_files_queued . '(up, files)';
        }
        ?>

			plupload.each(files, function(file){
				if ( max > hundredmb && file.size > hundredmb && up.runtime != 'html5' )
					wpfbPlUploadSizeError( up, file, true );
				else
					<?php 
        echo $this->js_file_queued;
        ?>
(up, file);
			});

			up.refresh();
			up.start();
		});

		uploader.bind('BeforeUpload', function(up, file) {
			// something
		});

		uploader.bind('UploadFile', function(up, file) {
			wpfbPlFileUploading(up, file);
		});

		uploader.bind('UploadProgress', function(up, file) {
			<?php 
        echo $this->js_upload_progress;
        ?>
(file);
		});

		uploader.bind('Error', function(up, err) {
			wpfbPlUploadError(err.file, err.code, err.message, up);
			up.refresh();
		});

		uploader.bind('FileUploaded', function(up, file, response) {
			// on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag
			var serverData = response.response.replace(/^<pre>(.+)<\/pre>$/, '$1');
			
			if ( serverData.match('media-upload-error') || serverData.match('error-div') ) {
				wpfbPlFileError(file, serverData);
				return;
			}
			
			serverData = jQuery.parseJSON(serverData);
			
			<?php 
        echo $this->js_upload_success;
        ?>
(file, serverData);
		});

		uploader.bind('UploadComplete', function(up, files) {
			//uploadComplete();
		}); 
		
		
	})();
	
// EXTERNAL
/*
function fileQueued(fileObj) {
	
	
	// Create a progress bar containing the filename
	jQuery('#<?php 
        echo $this->prefix;
        ?>
files').append('<div id="<?php 
        echo $this->prefix;
        ?>
file-' + fileObj.id + '" class="media-item child-of-' + postid + '"><div class="progress"><div class="percent">0%</div><div class="bar"></div></div><div class="filename original"> ' + fileObj.name + '</div></div>');
	
	
	jQuery('#file-upload-progress').show().html('<div class="progress"><div class="percent">0%</div><div class="bar" style="width: 30px"></div></div><div class="filename original"> ' + fileObj.name + '</div>');

	jQuery('.progress', '#file-upload-progress').show();
	jQuery('.filename', '#file-upload-progress').show();

	jQuery("#media-upload-error").empty();
	jQuery('.upload-flash-bypass').hide();
	
	jQuery('#file-submit').prop('disabled', true);
	jQuery('#cancel-upload').show().prop('disabled', false);

	 // delete already uploaded temp file	
	if(jQuery('#file_flash_upload').val() != '0') {
		var postdata = <?php 
        echo json_encode($this->GetAjaxAuthData());
        ?>
;
		postdata.delupload = jQuery('#file_flash_upload').val();
		jQuery.ajax({type: 'POST', async: true, url:"<?php 
        echo esc_attr(WPFB_PLUGIN_URI . 'wpfb-async-upload.php');
        ?>
",
		data: postdata,
		success: (function(data){})
		});
		jQuery('#file_flash_upload').val(0);
	}
}
*/

function wpfbPlFileUploading(up, file) {
	var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10);

	if ( max > hundredmb && file.size > hundredmb ) {
		setTimeout(function(){
			var done;

			if ( file.status < 3 && file.loaded == 0 ) { // not uploading
				wpfbPlFileError(file, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'));
				up.stop(); // stops the whole queue
				up.removeFile(file);
				up.start(); // restart the queue
			}
		}, 10000); // wait for 10 sec. for the file to start uploading
	}
}

/*
function uploadProgress(up, file) {
	var item = jQuery('#media-item-' + file.id);

	jQuery('.bar', item).width( (200 * file.loaded) / file.size );
	jQuery('.percent', item).html( file.percent + '%' );
}*/


function wpfbPlUploadSizeError( up, file, over100mb ) {
	var message;

	if ( over100mb )
		message = pluploadL10n.big_upload_queued.replace('%s', file.name) + ' ' + pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>');
	else
		message = pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);

	<?php 
        echo $this->js_file_error;
        ?>
 (message,file);

	up.removeFile(file);
}

function wpfbPlUploadError(fileObj, errorCode, message, uploader) {
	var hundredmb = 100 * 1024 * 1024, max;

	switch (errorCode) {
		case plupload.FAILED:
			wpfbPlFileError(fileObj, pluploadL10n.upload_failed);
			break;
		case plupload.FILE_EXTENSION_ERROR:
			wpfbPlFileError(fileObj, pluploadL10n.invalid_filetype);
			break;
		case plupload.FILE_SIZE_ERROR:
			wpfbPlUploadSizeError(uploader, fileObj);
			break;
		case plupload.IMAGE_FORMAT_ERROR:
			wpfbPlFileError(fileObj, pluploadL10n.not_an_image);
			break;
		case plupload.IMAGE_MEMORY_ERROR:
			wpfbPlFileError(fileObj, pluploadL10n.image_memory_exceeded);
			break;
		case plupload.IMAGE_DIMENSIONS_ERROR:
			wpfbPlFileError(fileObj, pluploadL10n.image_dimensions_exceeded);
			break;
		case plupload.GENERIC_ERROR:
			wpfbPlQueueError(pluploadL10n.upload_failed);
			break;
		case plupload.IO_ERROR:
			max = parseInt(uploader.settings.max_file_size, 10);

			if ( max > hundredmb && fileObj.size > hundredmb )
				wpfbPlFileError(fileObj, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'));
			else
				wpfbPlQueueError(pluploadL10n.io_error);
			break;
		case plupload.HTTP_ERROR:
			wpfbPlQueueError(pluploadL10n.http_error);
			break;
		case plupload.INIT_ERROR:
			//jQuery('.media-upload-form').addClass('html-uploader');
			// TODO: on init failure
			break;
		case plupload.SECURITY_ERROR:
			wpfbPlQueueError(pluploadL10n.security_error);
			break;
/*		case plupload.UPLOAD_ERROR.UPLOAD_STOPPED:
		case plupload.UPLOAD_ERROR.FILE_CANCELLED:
			jQuery('#media-item-' + fileObj.id).remove();
			break;*/
		default:
			wpfbPlFileError(fileObj, pluploadL10n.default_error);
	}
}

/*
function uploadSuccess(fileObj, serverData) {
	var item = jQuery('#media-item-' + fileObj.id);

	// on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag
	serverData = serverData.replace(/^<pre>(\d+)<\/pre>$/, '$1');

	// if async-upload returned an error message, place it in the media item div and return
	if ( serverData.match(/media-upload-error|error-div/) ) {
		item.html(serverData);
		return;
	} else {
		jQuery('.percent', item).html( pluploadL10n.crunching );
	}

	prepareMediaItem(fileObj, serverData);
	updateMediaForm();

	// Increment the counter.
	if ( post_id && item.hasClass('child-of-' + post_id) )
		jQuery('#attachments-count').text(1 * jQuery('#attachments-count').text() + 1);
}
*/

function wpfbPlFileError(fileObj, message) {
	<?php 
        echo $this->js_file_error;
        ?>
 (message,fileObj);
}

// generic error message
function wpfbPlQueueError(message) {
	jQuery('#<?php 
        echo $error_el_id;
        ?>
').show().html( '<div class="error"><p>' + message + '</p></div>' );
}
</script>
<?php 
    }