Make WordPress Core


Ignore:
Timestamp:
11/26/2008 02:27:37 AM (16 years ago)
Author:
azaozz
Message:

Move Gallery Settings to the Gallery tab in the uploader, split the Upload tab in "From Computer" and "From URL" tabs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r9746 r9894  
    1616function media_upload_tabs() {
    1717    $_default_tabs = array(
    18         'type' => __('Choose File'), // handler action suffix => tab text
     18        'type' => __('From Computer'), // handler action suffix => tab text
     19        'type_url' => __('From URL'),
    1920        'gallery' => __('Gallery'),
    20         'library' => __('Media Library'),
     21        'library' => __('Media Library')
    2122    );
    2223
     
    330331    $context = apply_filters('media_buttons_context', __('Upload %s'));
    331332    $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
    332     $media_title = __('Upload Media');
     333    $media_title = __('Add Media');
    333334    $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image");
    334     $image_title = __('Upload an Image');
     335    $image_title = __('Add an Image');
    335336    $video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src&type=video");
    336     $video_title = __('Upload Video');
     337    $video_title = __('Add Video');
    337338    $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&type=audio");
    338     $audio_title = __('Upload Audio');
     339    $audio_title = __('Add Audio');
    339340    $out = <<<EOF
    340341
     
    386387    }
    387388
    388     if ( isset($_POST['insert-gallery']) )
    389         return media_send_to_editor('[gallery]');
     389    if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
     390        <script type="text/javascript">
     391        /* <![CDATA[ */
     392        var win = window.dialogArguments || opener || parent || top;
     393        win.tb_remove();
     394        /* ]]> */
     395        </script>
     396        <?php
     397        exit;
     398    }
    390399
    391400    if ( isset($_POST['send']) ) {
     
    454463        return media_upload_gallery();
    455464    }
     465   
     466    if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
     467        return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
    456468
    457469    return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
     
    543555    }
    544556
     557    if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
     558        return wp_iframe( 'media_upload_type_url_form', 'audio', $errors, $id );
     559   
    545560    return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id );
    546561}
     
    593608    }
    594609
     610    if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
     611        return wp_iframe( 'media_upload_type_url_form', 'video', $errors, $id );
     612   
    595613    return wp_iframe( 'media_upload_type_form', 'video', $errors, $id );
    596614}
     
    643661    }
    644662
     663    if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
     664        return wp_iframe( 'media_upload_type_url_form', 'file', $errors, $id );
     665   
    645666    return wp_iframe( 'media_upload_type_form', 'file', $errors, $id );
    646667}
     
    13011322    $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
    13021323    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    1303 
    1304     $callback = "type_form_$type";
    13051324?>
    13061325
     
    13081327<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
    13091328<?php wp_nonce_field('media-form'); ?>
    1310 <h3><?php _e('From Computer'); ?></h3>
     1329
     1330<div class="media-blank">
     1331<h3><?php _e('Add media files from your computer'); ?></h3>
     1332</div>
     1333
    13111334<?php media_upload_form( $errors ); ?>
    13121335
     
    13221345-->
    13231346</script>
    1324 <?php if ( $id && !is_wp_error($id) ) : ?>
     1347<?php if ( $id && !is_wp_error($id) ) { ?>
    13251348<div id="media-items">
    13261349<?php echo get_media_items( $id, $errors ); ?>
    13271350</div>
    13281351<input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
    1329 
    1330 <?php elseif ( is_callable($callback) ) : ?>
     1352<?php
     1353    } elseif ( is_wp_error($id) ) {
     1354        echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
     1355        exit;
     1356    }
     1357}
     1358
     1359/**
     1360 * {@internal Missing Short Description}}
     1361 *
     1362 * @since unknown
     1363 *
     1364 * @param unknown_type $type
     1365 * @param unknown_type $errors
     1366 * @param unknown_type $id
     1367 */
     1368function media_upload_type_url_form($type = 'file', $errors = null, $id = null) {
     1369    media_upload_header();
     1370
     1371    $post_id = intval($_REQUEST['post_id']);
     1372
     1373    $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
     1374    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
     1375
     1376    $callback = "type_url_form_$type";
     1377?>
     1378
     1379<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form">
     1380<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
     1381<?php wp_nonce_field('media-form'); ?>
     1382
     1383<?php if ( is_callable($callback) ) { ?>
    13311384
    13321385<div class="media-blank">
    1333 <p style="text-align:center"><?php _e('&mdash; OR &mdash;'); ?></p>
    1334 <h3><?php _e('From URL'); ?></h3>
     1386<h3><?php _e('Add media file from URL'); ?></h3>
    13351387</div>
    13361388
     
    14151467</div>
    14161468</div>
    1417 <input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
    14181469</form>
    14191470<?php
    1420     endif;
     1471    } else {
     1472        wp_die( __('Unknown action.') );
     1473    }
    14211474}
    14221475
     
    14621515<?php echo get_media_items($post_id, $errors); ?>
    14631516</div>
     1517
    14641518<p class="ml-submit">
    1465 <input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
    1466 <input type="submit" class="button insert-gallery" name="insert-gallery" value="<?php echo attribute_escape( __( 'Insert gallery into post' ) ); ?>" />
     1519<input type="submit" class="button savebutton" style="display:none;" name="save" id="save-all" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
    14671520<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
    14681521<input type="hidden" name="type" value="<?php echo attribute_escape( $GLOBALS['type'] ); ?>" />
    14691522<input type="hidden" name="tab" value="<?php echo attribute_escape( $GLOBALS['tab'] ); ?>" />
    14701523</p>
     1524
     1525<div id="gallery-settings" style="display:none;">
     1526<div class="title"><?php _e('Gallery Settings'); ?></div>
     1527<table id="basic" class="describe"><tbody>
     1528    <tr>
     1529    <th scope="row" class="label">
     1530        <label>
     1531        <span class="alignleft"><?php _e('Link thumbnails to:'); ?></span>
     1532        </label>
     1533    </th>
     1534    <td class="field">
     1535        <input type="radio" name="linkto" id="linkto-file" value="file" />
     1536        <label for="linkto-file" class="radio"><?php _e('Image File'); ?></label>
     1537
     1538        <input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />
     1539        <label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label>
     1540    </td>
     1541    </tr>
     1542
     1543    <tr>
     1544    <th scope="row" class="label">
     1545        <label>
     1546        <span class="alignleft"><?php _e('Order images by:'); ?></span>
     1547        </label>
     1548    </th>
     1549    <td class="field">
     1550        <select id="orderby" name="orderby">
     1551            <option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option>
     1552            <option value="post_name"><?php _e('Name'); ?></option>
     1553            <option value="ID"><?php _e('Date/Time'); ?></option>
     1554        </select>
     1555    </td>
     1556    </tr>
     1557
     1558    <tr>
     1559    <th scope="row" class="label">
     1560        <label>
     1561        <span class="alignleft"><?php _e('Order:'); ?></span>
     1562        </label>
     1563    </th>
     1564    <td class="field">
     1565        <input type="radio" checked="checked" name="order" id="order-asc" value="asc" />
     1566        <label for="order-asc" class="radio"><?php _e('Ascending'); ?></label>
     1567
     1568        <input type="radio" name="order" id="order-desc" value="desc" />
     1569        <label for="order-desc" class="radio"><?php _e('Descending'); ?></label>
     1570    </td>
     1571    </tr>
     1572
     1573    <tr>
     1574    <th scope="row" class="label">
     1575        <label>
     1576        <span class="alignleft"><?php _e('Gallery columns:'); ?></span>
     1577        </label>
     1578    </th>
     1579    <td class="field">
     1580        <select id="columns" name="columns">
     1581            <option value="2"><?php _e('2'); ?></option>
     1582            <option value="3" selected="selected"><?php _e('3'); ?></option>
     1583            <option value="4"><?php _e('4'); ?></option>
     1584            <option value="5"><?php _e('5'); ?></option>
     1585            <option value="6"><?php _e('6'); ?></option>
     1586            <option value="7"><?php _e('7'); ?></option>
     1587            <option value="8"><?php _e('8'); ?></option>
     1588            <option value="9"><?php _e('9'); ?></option>
     1589        </select>
     1590    </td>
     1591    </tr>
     1592</tbody></table>
     1593
     1594<p class="ml-submit">
     1595<input type="button" class="button" style="display:none;" onmousedown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php echo attribute_escape( __( 'Insert gallery' ) ); ?>" />
     1596<input type="button" class="button" style="display:none;" onmousedown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php echo attribute_escape( __( 'Update gallery settings' ) ); ?>" />
     1597</p>
     1598</div>
    14711599</form>
    14721600<?php
     
    16351763 * @return unknown
    16361764 */
    1637 function type_form_image() {
     1765function type_url_form_image() {
    16381766
    16391767    if ( apply_filters( 'disable_captions', '' ) ) {
     
    17181846 * @return unknown
    17191847 */
    1720 function type_form_audio() {
     1848function type_url_form_audio() {
    17211849    return '
    17221850    <table class="describe"><tbody>
     
    17531881 * @return unknown
    17541882 */
    1755 function type_form_video() {
     1883function type_url_form_video() {
    17561884    return '
    17571885    <table class="describe"><tbody>
     
    17881916 * @return unknown
    17891917 */
    1790 function type_form_file() {
     1918function type_url_form_file() {
    17911919    return '
    17921920    <table class="describe"><tbody>
Note: See TracChangeset for help on using the changeset viewer.