Degrade flash upload if the server is lightttpd < 1.5. Props nbachyski. fixes #6243

git-svn-id: http://svn.automattic.com/wordpress/trunk@7406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-20 00:33:59 +00:00
parent 7c83d7abd1
commit 95c51418d8
5 changed files with 18 additions and 6 deletions

View File

@ -811,7 +811,6 @@ jQuery(function($){
file_size_limit : "<?php echo wp_max_upload_size(); ?>b",
swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available
degraded_element_id : "html-upload-ui", // when swfupload is unavailable
swfupload_loaded_handler : uploadLoaded,
file_dialog_start_handler : fileDialogStart,
file_queued_handler : fileQueued,
upload_start_handler : uploadStart,
@ -843,6 +842,9 @@ jQuery(function($){
</p>
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
<br class="clear" />
<?php if ( is_lighttpd_before_150() ): ?>
<p><?php _e('If you want to use all capabilties of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p>
<?php endif;?>
</div>
<?php
}

View File

@ -1705,4 +1705,15 @@ function _deprecated_file($file, $version, $replacement=null) {
trigger_error( printf( __("%1$s is <strong>deprecated</strong> since version %2$s with no alternative available."), $file, $version ) );
}
}
/**
* is_lighttpd_before_150() - Is the server running earlier than 1.5.0 version of lighttpd
*
* @return bool Whether the server is running lighttpd < 1.5.0
*/
function is_lighttpd_before_150() {
$server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' );
$server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : '';
return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' );
}
?>

View File

@ -1,8 +1,3 @@
function uploadLoaded() {
jQuery("#html-upload-ui").remove();
jQuery("#flash-upload-ui").show();
}
function fileDialogStart() {
jQuery("#media-upload-error").empty();
}

View File

@ -36,6 +36,7 @@ if (typeof(SWFUpload) === "function") {
SWFUpload.gracefulDegradation.swfUploadLoaded = function () {
var swfupload_container_id, swfupload_container, degraded_container_id, degraded_container, user_swfUploadLoaded_handler;
try {
if (uploadDegradeOptions.is_lighttpd_before_150) throw "Lighttpd versions earlier than 1.5.0 aren't supported!";
swfupload_element_id = this.getSetting("swfupload_element_id");
degraded_element_id = this.getSetting("degraded_element_id");

View File

@ -83,6 +83,9 @@ class WP_Scripts {
$this->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1');
$this->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.0.2');
$this->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2');
$this->localize( 'swfupload-degrade', 'uploadDegradeOptions', array(
'is_lighttpd_before_150' => is_lighttpd_before_150(),
) );
$this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2');
$this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080301');
// these error messages came from the sample swfupload js, they might need changing.