From a6f7c12d48d7ab138954c2ae2a7f2d97b38902d0 Mon Sep 17 00:00:00 2001 From: azaozz Date: Sat, 27 Sep 2008 08:17:55 +0000 Subject: [PATCH] Upload media from the Media Library page. git-svn-id: http://svn.automattic.com/wordpress/trunk@8998 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/async-upload.php | 7 +- wp-admin/css/colors-classic.css | 8 ++- wp-admin/css/colors-fresh.css | 8 ++- wp-admin/includes/media.php | 6 +- wp-admin/media-upload.php | 97 ++++++++++++++++++++++------ wp-admin/media.php | 10 +-- wp-admin/menu.php | 2 +- wp-admin/upload.php | 7 +- wp-admin/wp-admin.css | 76 ++++++++++++++++++++-- wp-includes/js/swfupload/handlers.js | 3 +- 10 files changed, 177 insertions(+), 47 deletions(-) diff --git a/wp-admin/async-upload.php b/wp-admin/async-upload.php index dd85c73f0..4c225c4fd 100644 --- a/wp-admin/async-upload.php +++ b/wp-admin/async-upload.php @@ -26,7 +26,12 @@ if ( !current_user_can('upload_files') ) // just fetch the detail form for that attachment if ( ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) { - echo get_media_item($id); + if ( 2 == $_REQUEST['fetch'] ) { + add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2); + echo get_media_item($id, array( 'send' => false, 'delete' => false )); + } else { + echo get_media_item($id); + } exit; } diff --git a/wp-admin/css/colors-classic.css b/wp-admin/css/colors-classic.css index bfd472f72..39f784ac8 100644 --- a/wp-admin/css/colors-classic.css +++ b/wp-admin/css/colors-classic.css @@ -62,7 +62,8 @@ li.widget-list-control-item h4.widget-title a, li.widget-list-control-item, div.nav, .tablenav, #dashboard-widgets p.dashboard-widget-links, ul.view-switch li.current, .form-table tr, #poststuff h3, #replyhandle, -.login form, h3.info-box-title, #post-status-info, #edit-settings-wrap { +.login form, h3.info-box-title, #post-status-info, #edit-settings-wrap, +#wpbody-content .describe tr { background-color: #cfebf7; } @@ -146,7 +147,10 @@ ul#widget-list li.widget-list-item h4.widget-title { border-color: #c6d9e9; } -.form-table td, .form-table th { +.form-table td, +.form-table th, +#wpbody-content .describe td, +#wpbody-content .describe th { border-bottom-color: #fff; } diff --git a/wp-admin/css/colors-fresh.css b/wp-admin/css/colors-fresh.css index c39298ab3..e2cf34cd6 100644 --- a/wp-admin/css/colors-fresh.css +++ b/wp-admin/css/colors-fresh.css @@ -62,7 +62,8 @@ li.widget-list-control-item h4.widget-title a, li.widget-list-control-item, div.nav, .tablenav, #dashboard-widgets p.dashboard-widget-links, ul.view-switch li.current, .form-table tr, #poststuff h3, #replyhandle, -.login form, h3.info-box-title, #post-status-info, #edit-settings-wrap { +.login form, h3.info-box-title, #post-status-info, #edit-settings-wrap, +#wpbody-content .describe tr { background-color: #eaf3fa; } @@ -146,7 +147,10 @@ ul#widget-list li.widget-list-item h4.widget-title { border-color: #c6d9e9; } -.form-table td, .form-table th { +.form-table td, +.form-table th, +#wpbody-content .describe td, +#wpbody-content .describe th { border-bottom-color: #fff; } diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 2de68e360..95b90cbf9 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -758,7 +758,7 @@ function get_media_items( $post_id, $errors ) { function get_media_item( $attachment_id, $args = null ) { global $redir_tab; - $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true ); + $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true, 'show_title' => true ); $args = wp_parse_args( $args, $default_args ); extract( $args, EXTR_SKIP ); @@ -805,7 +805,7 @@ function get_media_item( $attachment_id, $args = null ) { } $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case - $display_title = wp_html_excerpt($display_title, 60); + $display_title = $show_title ? "
" . wp_html_excerpt($display_title, 60) . "
" : ''; $gallery = ( (isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab']) || (isset($redir_tab) && 'gallery' == $redir_tab) ) ? true : false; $order = ''; @@ -826,7 +826,7 @@ function get_media_item( $attachment_id, $args = null ) { $type $toggle_links $order -
$display_title
+ $display_title diff --git a/wp-admin/media-upload.php b/wp-admin/media-upload.php index cdf21aaa7..8cc3ae766 100644 --- a/wp-admin/media-upload.php +++ b/wp-admin/media-upload.php @@ -11,6 +11,10 @@ /** Load WordPress Administration Bootstrap */ require_once('admin.php'); + +if (!current_user_can('upload_files')) + wp_die(__('You do not have permission to upload files.')); + wp_enqueue_script('swfupload'); wp_enqueue_script('swfupload-degrade'); wp_enqueue_script('swfupload-queue'); @@ -18,9 +22,6 @@ wp_enqueue_script('swfupload-handlers'); @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); -if (!current_user_can('upload_files')) - wp_die(__('You do not have permission to upload files.')); - // IDs should be integers $ID = isset($ID) ? (int) $ID : 0; $post_id = isset($post_id)? (int) $post_id : 0; @@ -29,24 +30,82 @@ $post_id = isset($post_id)? (int) $post_id : 0; if ( isset($action) && $action == 'edit' && !$ID ) wp_die(__("You are not allowed to be here")); -// upload type: image, video, file, ..? -if ( isset($_GET['type']) ) - $type = strval($_GET['type']); -else - $type = apply_filters('media_upload_default_type', 'file'); +if ( isset($_GET['inline']) ) { + + if ( isset($_GET['upload-page-form']) ) { + $errors = media_upload_form_handler(); -// tab: gallery, library, or type-specific -if ( isset($_GET['tab']) ) - $tab = strval($_GET['tab']); -else - $tab = apply_filters('media_upload_default_tab', 'type'); + $location = 'upload.php'; + if ( $errors ) + $location .= '?message=3'; -$body_id = 'media-upload'; + wp_redirect( admin_url($location) ); + } + + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } -// let the action code decide how to handle the request -if ( $tab == 'type' ) - do_action("media_upload_$type"); -else - do_action("media_upload_$tab"); + $title = __('Upload Media'); + $parent_file = 'edit.php'; + require_once('admin-header.php'); ?> +
+

+
+ + + + + + +
+

+ +

+ +
+ + diff --git a/wp-admin/media.php b/wp-admin/media.php index f9fb79dff..f4d2a1939 100644 --- a/wp-admin/media.php +++ b/wp-admin/media.php @@ -24,12 +24,6 @@ case 'editattachment' : $errors = media_upload_form_handler(); - - check_admin_referer('media-form'); - - if ( !current_user_can('edit_post', $attachment_id) ) - wp_die ( __('You are not allowed to edit this attachment.') ); - if ( empty($errors) ) { $location = 'media.php'; if ( $referer = wp_get_original_referer() ) { @@ -92,9 +86,9 @@ case 'edit' :

-
+
- false, 'send' => false, 'delete' => false, 'errors' => $errors ) ); ?> + false, 'send' => false, 'delete' => false, 'show_title' => false, 'errors' => $errors ) ); ?>
diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 7a3eb44f9..667cf9be1 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -49,7 +49,7 @@ $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', 'wp-menu-open' ); $submenu['edit.php'][25] = array( __('Categories'), 'manage_categories', 'categories.php' ); $menu[10] = array( __('Media'), 'upload_files', 'upload.php' ); - $submenu['upload.php'][5] = array( __('Upload New'), 'upload_files', 'media-upload.php'); + $submenu['upload.php'][5] = array( __('Upload New'), 'upload_files', 'media-upload.php?inline'); $submenu['upload.php'][10] = array( __('View All'), 'upload_files', 'upload.php'); $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php' ); diff --git a/wp-admin/upload.php b/wp-admin/upload.php index f694ffa6d..60550a419 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -8,7 +8,7 @@ /** WordPress Administration Bootstrap */ require_once('admin.php'); -add_thickbox(); +//add_thickbox(); wp_enqueue_script( 'media-upload' ); wp_enqueue_script( 'wp-ajax-response' ); wp_enqueue_script( 'jquery-ui-draggable' ); @@ -182,7 +182,7 @@ if ( isset($_GET['detached']) ) { $h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in “%s”'), single_cat_title('', false) ) : ''; $h2_tag = isset($_GET['tag']) && $_GET['tag'] ? ' ' . sprintf( __('tagged with “%s”'), single_tag_title('', false) ) : ''; $h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : ''; - printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s (Add New)|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: tagged with {s}, 6: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_tag, $h2_month, 'media-upload.php?library=false&TB_iframe=true' ); + printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s (Add New)|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: tagged with {s}, 6: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_tag, $h2_month, 'media-upload.php?inline' ); } ?> @@ -224,8 +224,9 @@ if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET