Media Library updates from andy. see #5911
git-svn-id: http://svn.automattic.com/wordpress/trunk@7100 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3bf5a1849b
commit
daf37cc98c
|
@ -21,6 +21,12 @@ div#media-upload-error {
|
||||||
color: #f00;
|
color: #f00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.file-error {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #f00;
|
||||||
|
margin: 0 15px;
|
||||||
|
}
|
||||||
|
|
||||||
form {
|
form {
|
||||||
margin: 1em;
|
margin: 1em;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1175,6 +1175,21 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = NULL ) {
|
||||||
return array( 'file' => $new_file, 'url' => $url, 'error' => false );
|
return array( 'file' => $new_file, 'url' => $url, 'error' => false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wp_ext2type( $ext ) {
|
||||||
|
$ext2type = apply_filters('ext2type', array(
|
||||||
|
'audio' => array('aac','ac3','aif','aiff','mp1','mp2','mp3','m3a','m4a','m4b','ogg','ram','wav','wma'),
|
||||||
|
'video' => array('asf','avi','divx','dv','mov','mpg','mpeg','mp4','mpv','ogm','qt','rm','vob','wmv'),
|
||||||
|
'document' => array('doc','pages','odt','rtf','pdf'),
|
||||||
|
'spreadsheet' => array('xls','numbers','ods'),
|
||||||
|
'interactive' => array('ppt','key','odp','swf'),
|
||||||
|
'text' => array('txt'),
|
||||||
|
'archive' => array('tar','bz2','gz','cab','dmg','rar','sea','sit','sqx','zip'),
|
||||||
|
'code' => array('css','html','php','js'),
|
||||||
|
));
|
||||||
|
foreach ( $ext2type as $type => $exts )
|
||||||
|
if ( in_array($ext, $exts) )
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
function wp_check_filetype( $filename, $mimes = null ) {
|
function wp_check_filetype( $filename, $mimes = null ) {
|
||||||
// Accepted MIME types are set here as PCRE unless provided.
|
// Accepted MIME types are set here as PCRE unless provided.
|
||||||
|
|
|
@ -117,7 +117,8 @@ function wpQueueError(message) {
|
||||||
|
|
||||||
// file-specific message
|
// file-specific message
|
||||||
function wpFileError(fileObj, message) {
|
function wpFileError(fileObj, message) {
|
||||||
jQuery('#media-upload-error-' + fileObj.id).show().text(message);
|
jQuery('#media-item-' + fileObj.id + ' .filename').append('<span class="file-error">'+message+'</span> <button type="button" class="button dismiss">'+swfuploadL10n.dismiss+'</button>');
|
||||||
|
jQuery('.dismiss').click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
|
||||||
}
|
}
|
||||||
|
|
||||||
function fileQueueError(fileObj, error_code, message) {
|
function fileQueueError(fileObj, error_code, message) {
|
||||||
|
@ -126,12 +127,15 @@ function fileQueueError(fileObj, error_code, message) {
|
||||||
wpQueueError(swfuploadL10n.queue_limit_exceeded);
|
wpQueueError(swfuploadL10n.queue_limit_exceeded);
|
||||||
}
|
}
|
||||||
else if ( error_code == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT ) {
|
else if ( error_code == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT ) {
|
||||||
|
fileQueued(fileObj);
|
||||||
wpFileError(fileObj, swfuploadL10n.file_exceeds_size_limit);
|
wpFileError(fileObj, swfuploadL10n.file_exceeds_size_limit);
|
||||||
}
|
}
|
||||||
else if ( error_code == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE ) {
|
else if ( error_code == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE ) {
|
||||||
|
fileQueued(fileObj);
|
||||||
wpFileError(fileObj, swfuploadL10n.zero_byte_file);
|
wpFileError(fileObj, swfuploadL10n.zero_byte_file);
|
||||||
}
|
}
|
||||||
else if ( error_code == SWFUpload.QUEUE_ERROR.INVALID_FILETYPE ) {
|
else if ( error_code == SWFUpload.QUEUE_ERROR.INVALID_FILETYPE ) {
|
||||||
|
fileQueued(fileObj);
|
||||||
wpFileError(fileObj, swfuploadL10n.invalid_filetype);
|
wpFileError(fileObj, swfuploadL10n.invalid_filetype);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -884,10 +884,10 @@ function wp_match_mime_types($wildcard_mime_types, $real_mime_types) {
|
||||||
$wild = '[-._a-z0-9]*';
|
$wild = '[-._a-z0-9]*';
|
||||||
foreach ( (array) $wildcard_mime_types as $type ) {
|
foreach ( (array) $wildcard_mime_types as $type ) {
|
||||||
$type = str_replace('*', $wild, $type);
|
$type = str_replace('*', $wild, $type);
|
||||||
$patternses[1][$type] = $type;
|
$patternses[1][$type] = "^$type$";
|
||||||
if ( false === strpos($type, '/') ) {
|
if ( false === strpos($type, '/') ) {
|
||||||
$patternses[2][$type] = "^$type/$wild$";
|
$patternses[2][$type] = "^$type/";
|
||||||
$patternses[3][$type] = "$wild$type$wild";
|
$patternses[3][$type] = $type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
asort($patternses);
|
asort($patternses);
|
||||||
|
@ -2361,7 +2361,6 @@ function wp_attachment_is_image( $post_id = 0 ) {
|
||||||
function wp_mime_type_icon( $mime = 0 ) {
|
function wp_mime_type_icon( $mime = 0 ) {
|
||||||
if ( !is_numeric($mime) )
|
if ( !is_numeric($mime) )
|
||||||
$icon = wp_cache_get("mime_type_icon_$mime");
|
$icon = wp_cache_get("mime_type_icon_$mime");
|
||||||
|
|
||||||
if ( empty($icon) ) {
|
if ( empty($icon) ) {
|
||||||
$post_id = 0;
|
$post_id = 0;
|
||||||
$post_mimes = array();
|
$post_mimes = array();
|
||||||
|
@ -2370,8 +2369,11 @@ function wp_mime_type_icon( $mime = 0 ) {
|
||||||
if ( $post =& get_post( $mime ) ) {
|
if ( $post =& get_post( $mime ) ) {
|
||||||
$post_id = (int) $post->ID;
|
$post_id = (int) $post->ID;
|
||||||
$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $post->guid);
|
$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $post->guid);
|
||||||
if ( !empty($ext) )
|
if ( !empty($ext) ) {
|
||||||
$post_mimes[] = $ext;
|
$post_mimes[] = $ext;
|
||||||
|
if ( $ext_type = wp_ext2type( $ext ) )
|
||||||
|
$post_mimes[] = $ext_type;
|
||||||
|
}
|
||||||
$mime = $post->post_mime_type;
|
$mime = $post->post_mime_type;
|
||||||
} else {
|
} else {
|
||||||
$mime = 0;
|
$mime = 0;
|
||||||
|
@ -2383,16 +2385,20 @@ function wp_mime_type_icon( $mime = 0 ) {
|
||||||
$icon_files = wp_cache_get('icon_files');
|
$icon_files = wp_cache_get('icon_files');
|
||||||
|
|
||||||
if ( !is_array($icon_files) ) {
|
if ( !is_array($icon_files) ) {
|
||||||
$icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images' );
|
$icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' );
|
||||||
$icon_dir_uri = apply_filters( 'icon_dir_uri', trailingslashit(get_option('siteurl')) . WPINC . '/images' );
|
$icon_dir_uri = apply_filters( 'icon_dir_uri', trailingslashit(get_option('siteurl')) . WPINC . '/images/crystal' );
|
||||||
$dirs = apply_filters( 'icon_dirs', array($icon_dir => $icon_dir_uri) );
|
$dirs = apply_filters( 'icon_dirs', array($icon_dir => $icon_dir_uri) );
|
||||||
$icon_files = array();
|
$icon_files = array();
|
||||||
foreach ( $dirs as $dir => $uri) {
|
while ( $dirs ) {
|
||||||
|
$dir = array_shift(array_keys($dirs));
|
||||||
|
$uri = array_shift($dirs);
|
||||||
if ( $dh = opendir($dir) ) {
|
if ( $dh = opendir($dir) ) {
|
||||||
while ( false !== $file = readdir($dh) ) {
|
while ( false !== $file = readdir($dh) ) {
|
||||||
$file = basename($file);
|
$file = basename($file);
|
||||||
|
if ( substr($file, 0, 1) == '.' )
|
||||||
|
continue;
|
||||||
if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
|
if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
|
||||||
if ( is_dir($file) )
|
if ( is_dir("$dir/$file") )
|
||||||
$dirs["$dir/$file"] = "$uri/$file";
|
$dirs["$dir/$file"] = "$uri/$file";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,23 +88,23 @@ class WP_Scripts {
|
||||||
$this->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.0.2');
|
$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->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2');
|
||||||
$this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2');
|
$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-20080227');
|
$this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080228');
|
||||||
// these error messages came from the sample swfupload js, they might need changing.
|
// these error messages came from the sample swfupload js, they might need changing.
|
||||||
$this->localize( 'swfupload-handlers', 'swfuploadL10n', array(
|
$this->localize( 'swfupload-handlers', 'swfuploadL10n', array(
|
||||||
'queue_limit_exceeded' => 'You have attempted to queue too many files.',
|
'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
|
||||||
'file_exceeds_size_limit' => 'The file you have selected is too big.',
|
'file_exceeds_size_limit' => __('This file is too big. See php.ini.'),
|
||||||
'zero_byte_file' => 'The file you selected is empty. Please select another file.',
|
'zero_byte_file' => __('The file you selected is empty. Please select another file.'),
|
||||||
'invalid_filetype' => 'The file you choose is not an allowed file type.',
|
'invalid_filetype' => __('The file you choose is not an allowed file type.'),
|
||||||
'default_error' => 'An error occurred in the upload. Please try again later.',
|
'default_error' => __('An error occurred in the upload. Please try again later.'),
|
||||||
'missing_upload_url' => 'There was a configuration error. Please contact the server administrator.',
|
'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
|
||||||
'upload_limit_exceeded' => 'You may only upload 1 file.',
|
'upload_limit_exceeded' => __('You may only upload 1 file.'),
|
||||||
'http_error' => 'HTTP error.',
|
'http_error' => __('HTTP error.'),
|
||||||
'upload_failed' => 'Upload failed.',
|
'upload_failed' => __('Upload failed.'),
|
||||||
'io_error' => 'IO error.',
|
'io_error' => __('IO error.'),
|
||||||
'security_error' => 'Security error.',
|
'security_error' => __('Security error.'),
|
||||||
'file_cancelled' => 'File cancelled.',
|
'file_cancelled' => __('File cancelled.'),
|
||||||
'upload_stopped' => 'Upload stopped.',
|
'upload_stopped' => __('Upload stopped.'),
|
||||||
|
'dismiss' => __('Dismiss'),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$this->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery'), '3' );
|
$this->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery'), '3' );
|
||||||
|
|
Loading…
Reference in New Issue