Changeset 8998

Show
Ignore:
Timestamp:
09/27/08 08:17:55 (2 months ago)
Author:
azaozz
Message:

Upload media from the Media Library page.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/async-upload.php

    r8618 r8998  
    2727// just fetch the detail form for that attachment 
    2828if ( ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) { 
    29     echo get_media_item($id); 
     29    if ( 2 == $_REQUEST['fetch'] ) { 
     30        add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2); 
     31        echo get_media_item($id, array( 'send' => false, 'delete' => false )); 
     32    } else { 
     33        echo get_media_item($id); 
     34    } 
    3035    exit; 
    3136} 
  • trunk/wp-admin/css/colors-classic.css

    r8988 r8998  
    6363li.widget-list-control-item, div.nav, .tablenav, #dashboard-widgets p.dashboard-widget-links, 
    6464ul.view-switch li.current, .form-table tr, #poststuff h3, #replyhandle, 
    65 .login form, h3.info-box-title, #post-status-info, #edit-settings-wrap { 
     65.login form, h3.info-box-title, #post-status-info, #edit-settings-wrap, 
     66#wpbody-content .describe tr { 
    6667    background-color: #cfebf7; 
    6768} 
     
    147148} 
    148149 
    149 .form-table td, .form-table th { 
     150.form-table td, 
     151.form-table th, 
     152#wpbody-content .describe td, 
     153#wpbody-content .describe th { 
    150154    border-bottom-color: #fff; 
    151155} 
  • trunk/wp-admin/css/colors-fresh.css

    r8988 r8998  
    6363li.widget-list-control-item, div.nav, .tablenav, #dashboard-widgets p.dashboard-widget-links, 
    6464ul.view-switch li.current, .form-table tr, #poststuff h3, #replyhandle, 
    65 .login form, h3.info-box-title, #post-status-info, #edit-settings-wrap { 
     65.login form, h3.info-box-title, #post-status-info, #edit-settings-wrap, 
     66#wpbody-content .describe tr { 
    6667    background-color: #eaf3fa; 
    6768} 
     
    147148} 
    148149 
    149 .form-table td, .form-table th { 
     150.form-table td, 
     151.form-table th, 
     152#wpbody-content .describe td, 
     153#wpbody-content .describe th { 
    150154    border-bottom-color: #fff; 
    151155} 
  • trunk/wp-admin/includes/media.php

    r8959 r8998  
    759759    global $redir_tab; 
    760760 
    761     $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true ); 
     761    $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true, 'show_title' => true ); 
    762762    $args = wp_parse_args( $args, $default_args ); 
    763763    extract( $args, EXTR_SKIP ); 
     
    806806 
    807807    $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case 
    808     $display_title = wp_html_excerpt($display_title, 60)
     808    $display_title = $show_title ? "<div class='filename new'>" . wp_html_excerpt($display_title, 60) . "</div>" : ''
    809809 
    810810    $gallery = ( (isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab']) || (isset($redir_tab) && 'gallery' == $redir_tab) ) ? true : false; 
     
    827827    $toggle_links 
    828828    $order 
    829     <div class='filename new'>$display_title</div> 
     829    $display_title 
    830830    <table class='slidetoggle describe $class'> 
    831831        <thead class='media-item-info'> 
  • trunk/wp-admin/media-upload.php

    r8645 r8998  
    1212/** Load WordPress Administration Bootstrap */ 
    1313require_once('admin.php'); 
     14 
     15if (!current_user_can('upload_files')) 
     16    wp_die(__('You do not have permission to upload files.')); 
     17 
    1418wp_enqueue_script('swfupload'); 
    1519wp_enqueue_script('swfupload-degrade'); 
     
    1822 
    1923@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); 
    20  
    21 if (!current_user_can('upload_files')) 
    22     wp_die(__('You do not have permission to upload files.')); 
    2324 
    2425// IDs should be integers 
     
    3031    wp_die(__("You are not allowed to be here")); 
    3132 
    32 // upload type: image, video, file, ..? 
    33 if ( isset($_GET['type']) ) 
    34     $type = strval($_GET['type']); 
    35 else 
    36     $type = apply_filters('media_upload_default_type', 'file'); 
     33if ( isset($_GET['inline']) ) { 
     34     
     35    if ( isset($_GET['upload-page-form']) ) { 
     36        $errors = media_upload_form_handler(); 
    3737 
    38 // tab: gallery, library, or type-specific 
    39 if ( isset($_GET['tab']) ) 
    40     $tab = strval($_GET['tab']); 
    41 else 
    42     $tab = apply_filters('media_upload_default_tab', 'type'); 
     38        $location = 'upload.php'; 
     39        if ( $errors ) 
     40            $location .= '?message=3'; 
    4341 
    44 $body_id = 'media-upload'; 
     42        wp_redirect( admin_url($location) ); 
     43    } 
     44     
     45    if ( isset($_POST['html-upload']) && !empty($_FILES) ) { 
     46        // Upload File button was clicked 
     47        $id = media_handle_upload('async-upload', $_REQUEST['post_id']); 
     48        unset($_FILES); 
     49        if ( is_wp_error($id) ) { 
     50            $errors['upload_error'] = $id; 
     51            $id = false; 
     52        } 
     53    } 
    4554 
    46 // let the action code decide how to handle the request 
    47 if ( $tab == 'type' ) 
    48     do_action("media_upload_$type"); 
    49 else 
    50     do_action("media_upload_$tab"); 
     55    $title = __('Upload Media'); 
     56    $parent_file = 'edit.php'; 
     57    require_once('admin-header.php'); ?> 
     58    <div class="wrap"> 
     59    <h2><?php _e('Upload Media') ?></h2> 
    5160 
     61    <form enctype="multipart/form-data" method="post" action="media-upload.php?inline=&upload-page-form=" class="media-upload-form type-form validate" id="file-form"> 
     62     
     63    <?php media_upload_form(); ?> 
     64     
     65    <script type="text/javascript"> 
     66    jQuery(function($){ 
     67        var preloaded = $(".media-item.preloaded"); 
     68        if ( preloaded.length > 0 ) { 
     69            preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); 
     70        } 
     71        updateMediaForm(); 
     72        post_id = 0; 
     73        shortform = 1; 
     74        $('body:last div:has(embed), body:last div:has(object)').css({'visibility':'hidden','marginTop':'-1px'}); 
     75    }); 
     76    </script> 
     77    <input type="hidden" name="post_id" id="post_id" value="0" /> 
     78    <?php wp_nonce_field('media-form'); ?> 
     79    <div id="media-items"> </div> 
     80    <p> 
     81    <input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" /> 
     82    </p> 
     83    </form> 
     84    </div> 
     85 
     86<?php 
     87    include('admin-footer.php'); 
     88 
     89} else { 
     90 
     91    // upload type: image, video, file, ..? 
     92    if ( isset($_GET['type']) ) 
     93        $type = strval($_GET['type']); 
     94    else 
     95        $type = apply_filters('media_upload_default_type', 'file'); 
     96     
     97    // tab: gallery, library, or type-specific 
     98    if ( isset($_GET['tab']) ) 
     99        $tab = strval($_GET['tab']); 
     100    else 
     101        $tab = apply_filters('media_upload_default_tab', 'type'); 
     102     
     103    $body_id = 'media-upload'; 
     104     
     105    // let the action code decide how to handle the request 
     106    if ( $tab == 'type' ) 
     107        do_action("media_upload_$type"); 
     108    else 
     109        do_action("media_upload_$tab"); 
     110} 
    52111?> 
  • trunk/wp-admin/media.php

    r8901 r8998  
    2424 
    2525    $errors = media_upload_form_handler(); 
    26  
    27  
    28     check_admin_referer('media-form'); 
    29  
    30     if ( !current_user_can('edit_post', $attachment_id) ) 
    31         wp_die ( __('You are not allowed to edit this attachment.') ); 
    3226 
    3327    if ( empty($errors) ) { 
     
    9387 
    9488<form method="post" action="<?php echo clean_url( remove_query_arg( 'message' ) ); ?>" class="media-upload-form" id="media-single-form"> 
    95 <div id="media-items" class="media-single"> 
     89<div class="media-single"> 
    9690<div id='media-item-<?php echo $att_id; ?>' class='media-item'> 
    97 <?php echo get_media_item( $att_id, array( 'toggle' => false, 'send' => false, 'delete' => false, 'errors' => $errors ) ); ?> 
     91<?php echo get_media_item( $att_id, array( 'toggle' => false, 'send' => false, 'delete' => false, 'show_title' => false, 'errors' => $errors ) ); ?> 
    9892</div> 
    9993</div> 
  • trunk/wp-admin/menu.php

    r8992 r8998  
    5050 
    5151$menu[10] = array( __('Media'), 'upload_files', 'upload.php' ); 
    52     $submenu['upload.php'][5] = array( __('Upload New'), 'upload_files', 'media-upload.php'); 
     52    $submenu['upload.php'][5] = array( __('Upload New'), 'upload_files', 'media-upload.php?inline'); 
    5353    $submenu['upload.php'][10] = array( __('View All'), 'upload_files', 'upload.php'); 
    5454 
  • trunk/wp-admin/upload.php

    r8984 r8998  
    99/** WordPress Administration Bootstrap */ 
    1010require_once('admin.php'); 
    11 add_thickbox(); 
     11//add_thickbox(); 
    1212wp_enqueue_script( 'media-upload' ); 
    1313wp_enqueue_script( 'wp-ajax-response' ); 
     
    183183    $h2_tag    = isset($_GET['tag']) && $_GET['tag'] ? ' ' . sprintf( __('tagged with &#8220;%s&#8221;'), single_tag_title('', false) ) : ''; 
    184184    $h2_month  = isset($_GET['m'])   && $_GET['m']   ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : ''; 
    185     printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s (<a href="%7$s" class="thickbox">Add New</a>)|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' ); 
     185    printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s (<a href="%7$s">Add New</a>)|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' ); 
    186186} 
    187187?></h2> 
     
    225225endif; 
    226226 
    227 $messages[1] = __('Media updated.'); 
     227$messages[1] = __('Media attachment updated.'); 
    228228$messages[2] = __('Media deleted.'); 
     229$messages[3] = __('Error saving media attachment.'); 
    229230 
    230231if ( isset($_GET['message']) && (int) $_GET['message'] ) 
  • trunk/wp-admin/wp-admin.css

    r8993 r8998  
    965965} 
    966966 
    967 .form-table td { 
     967.form-table td, 
     968#wpbody-content .describe td { 
    968969    margin-bottom: 9px; 
    969970    padding: 10px; 
     
    974975} 
    975976 
    976 .form-table th { 
     977.form-table th, 
     978#wpbody-content .describe th { 
    977979    vertical-align: top; 
    978980    text-align: left; 
     
    987989} 
    988990 
    989 .form-table input, .form-table textarea { 
     991.form-table input, 
     992.form-table textarea, 
     993#wpbody-content .describe input, 
     994#wpbody-content .describe textarea { 
    990995    border-width: 1px; 
    991996    border-style: solid; 
     
    23452350 
    23462351/* Media library */ 
    2347 #wpbody-content .media-item-info tr { 
     2352#wpbody-content #media-items .describe { 
     2353    border-collapse: collapse; 
     2354    width: 100%; 
     2355    border-top-style: solid; 
     2356    border-top-width: 1px; 
     2357    clear: both; 
     2358    cursor: default; 
     2359    padding: 5px; 
     2360    width: 100%; 
     2361
     2362 
     2363#wpbody-content .describe .media-item-info tr { 
    23482364    background-color: transparent; 
    23492365} 
     
    23702386} 
    23712387 
    2372 #wpbody-content .media-single input[type="text"], 
    2373 #wpbody-content .media-single textarea { 
     2388#wpbody-content .describe input[type="text"], 
     2389#wpbody-content .describe textarea { 
    23742390    width: 460px; 
    23752391} 
    23762392 
    2377 #wpbody-content .media-upload-form p.help { 
    2378     margin: 0; 
    2379     padding: 0; 
     2393#wpbody-content .describe p.help { 
     2394    margin: 0; 
     2395    padding: 0; 
     2396
     2397 
     2398.describe-toggle-on, .describe-toggle-off { 
     2399    display: block; 
     2400    line-height: 36px; 
     2401    float: right; 
     2402    margin-right: 20px; 
     2403
     2404 
     2405.describe-toggle-off { 
     2406    display: none; 
     2407
     2408 
     2409#wpbody-content .media-item { 
     2410    border-bottom-style: solid; 
     2411    border-bottom-width: 1px; 
     2412    min-height: 36px; 
     2413    position: relative; 
     2414    width: 100%; 
     2415
     2416 
     2417#wpbody-content #media-items { 
     2418    border-style: solid solid none; 
     2419    border-width: 1px; 
     2420    width: 670px; 
     2421
     2422 
     2423#wpbody-content #media-items .filename { 
     2424    float: left; 
     2425    line-height: 36px; 
     2426    margin-left: 10px; 
     2427    max-width: 430px; 
     2428    overflow: hidden; 
     2429
     2430 
     2431.media-item .pinkynail { 
     2432    float: left; 
     2433    height: 32px; 
     2434    margin: 2px; 
     2435    max-width: 40px; 
     2436    max-height: 40px; 
     2437
     2438 
     2439.media-item  .startopen, 
     2440.media-item .startclosed { 
     2441    display: none; 
    23802442} 
    23812443 
  • trunk/wp-includes/js/swfupload/handlers.js

    r7862 r8998  
    3636    jQuery('#media-item-' + fileObj.id + ' .progress').hide(); 
    3737 
     38    var f = ( typeof shortform == 'undefined' ) ? 1 : 2; 
    3839    // Old style: Append the HTML returned by the server -- thumbnail and form inputs 
    3940    if ( isNaN(serverData) || !serverData ) { 
     
    4344    // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server 
    4445    else { 
    45         jQuery('#media-item-' + fileObj.id).load('async-upload.php', {attachment_id:serverData, fetch:1}, function(){prepareMediaItemInit(fileObj);updateMediaForm()}); 
     46        jQuery('#media-item-' + fileObj.id).load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm()}); 
    4647    } 
    4748}