WordPress.org

Make WordPress Core

Changeset 8422


Ignore:
Timestamp:
07/23/2008 09:20:53 PM (10 years ago)
Author:
azaozz
Message:

crazyhorse: changed the media uploader according to the wireframes

Location:
branches/crazyhorse
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/crazyhorse/wp-admin/css/colors-fresh.css

    r8379 r8422  
    712712
    713713
    714 #adminmenu {
     714#adminmenu,
     715#html-upload-ui,
     716#att-info {
    715717    background-color: #E4F2FD;
    716718}
     
    723725}
    724726
     727#html-upload-help {
     728    color: #328AB2;
     729}
     730
    725731#fixedbar #last-edit {
    726732   
  • branches/crazyhorse/wp-admin/css/media.css

    r8335 r8422  
    2323
    2424form {
    25     margin: 1em;
     25    margin: 2px;
    2626}
    2727
     
    3232.media-upload-form label, .media-upload-form legend {
    3333    display:block;
    34     font-weight: bold;
    35     font-size: 13px;
     34    font-size: 10px;
    3635    margin-bottom: 0.5em;
    3736    margin: 0 0 0.5em 0;
     
    6059/* specific to the image upload form */
    6160.align .field label {
    62     display: inline;
    63     padding: 0 0 0 28px;
    64     margin: 0 1em 0 0;
    65 }
    66 .image-align-none-label {
    67     background: url(../images/align-none.png) no-repeat center left;
    68 }
    69 
    70 .image-align-left-label {
    71     background: url(../images/align-left.png) no-repeat center left;
    72 }
    73 
    74 .image-align-center-label {
    75     background: url(../images/align-center.png) no-repeat center left;
    76 }
    77 
    78 .image-align-right-label {
    79     background: url(../images/align-right.png) no-repeat center left;
     61    display:inline;
     62    margin:0pt 8px 0pt -2px;
     63    vertical-align:top;
     64}
     65
     66.image-align-none-label input {
     67    background: url(../images/align-none.png) no-repeat center -5px;
     68}
     69
     70.image-align-left-label input {
     71    background: url(../images/align-left.png) no-repeat center -5px;
     72}
     73
     74.image-align-center-label input {
     75    background: url(../images/align-center.png) no-repeat center -5px;
     76}
     77
     78.image-align-right-label input {
     79    background: url(../images/align-right.png) no-repeat center -5px;
    8080}
    8181
     
    171171}
    172172.describe input[type="text"], .describe textarea {
    173     width: 460px;
     173    font-size:10px;
     174    width:245px;
     175    padding:2px;
     176    margin:0pt 0pt 10px;
    174177}
    175178.describe-toggle-on, .describe-toggle-off {
     
    200203
    201204#media-upload .media-upload-form p.ml-submit {
    202     padding: 1em 0;
     205    font-size:11px;
     206    margin:0pt;
     207    padding:1em 0pt 1em 68px;
    203208}
    204209
    205210#media-upload p.help {
    206     font-style: italic;
    207     font-weight: normal;
     211    font-size:10px;
     212    font-style:italic;
     213    font-weight:normal;
     214    margin-top:-8px;
    208215}
    209216#media-upload tr.image-size td.field {
     
    211218}
    212219#media-upload #media-items {
    213     border-width: 1px;
    214     border-style: solid;
    215     border-bottom: none;
    216     width: 623px;
     220    border-style:solid;
     221    border-width:1px;
     222    margin:0pt auto;
     223    width:315px;
     224
    217225}
    218226
     
    237245}
    238246#media-upload .describe {
    239     border-top-width: 1px;
    240     border-top-style: solid;
    241247    padding: 5px;
    242248    width: 100%;
     
    245251}
    246252#media-upload .describe th.label {
    247     padding-top: .5em;
    248     text-align: left;
     253    font-size:10px;
     254    padding-top:4px;
     255    text-align:left;
     256    width:57px;
    249257}
    250258#media-upload tr.align td.field {
     
    271279}
    272280
    273 #media-upload a.delete,
    274 #media-upload a.del-link {
    275     padding: 0 3px 1px;
    276 }
    277 
    278281#media-upload .del-attachment {
    279282    display: none;
     
    314317    z-index: -1;
    315318}
     319
     320#media-single-form .filename {
     321    float: none;
     322}
     323
     324.filelink {
     325    float:left;
     326    max-width:65px;
     327    padding:7px;
     328    text-align:center;
     329}
     330
     331.filelink img.thumbnail {
     332    width: 45px;
     333    max-height: 45px;
     334}
     335
     336#media-upload .filelink p.filelink-caption {
     337    cursor:default;
     338    font-size:10px;
     339    height:13px;
     340    margin:0pt 3px 4px;
     341    overflow:hidden;
     342}
     343
     344body#media-upload {
     345    height: auto;
     346}
     347
     348#media-upload .tablenav,
     349#media-upload .page-numbers {
     350    background-color: #fff;
     351    border: 0 none;
     352    color: #328AB2;
     353    font-weight:normal;
     354}
     355
     356#media-upload .page-numbers {
     357    padding: 0;
     358}
     359
     360#media-upload .tablenav {
     361    margin: 0;
     362    height:1em;
     363    text-align:right;
     364    padding: 4px 10px;
     365}
     366
     367#media-upload .tablenav .tablenav-pages {
     368    float: none;
     369    height: 12px;
     370    padding: 0;
     371}
     372
     373#html-upload-ui {
     374    margin:10px 5px;
     375    padding:5px 0 5px 8px;
     376}
     377
     378#html-upload-help {
     379    font-size:10px;
     380    font-weight:bold;
     381    padding:4px 0 0 15px;
     382}
     383
     384#async-upload {
     385    font-size: 10px;
     386}
     387
     388#html-upload-ui input {
     389    padding: 1px;
     390    font-size:10px;
     391}
     392
     393#html-upload-ui a {
     394    padding: 1px;
     395    font-size:10px;
     396}
     397
     398#att-info {
     399    margin:10px 5px;
     400    padding:4px;
     401}
     402
     403#att-info a,
     404#att-info p {
     405    font-size: 11px;
     406    text-decoration: none;
     407}
     408
     409.button-link {
     410    font-size: 11px;
     411    padding: 2px;
     412    border: 0;
     413    background: transparent;
     414}
     415
     416#media-upload  #att-info p {
     417    margin:3px 6px 4px 2px;
     418    padding:0pt 0pt 0pt 17px;
     419    height:16px;
     420}
     421
     422#media-upload  #att-info p.type-image {
     423    background: url(../images/media-button-image.gif) no-repeat center left;
     424}
     425
     426#media-upload  #att-info p.type-audio {
     427    background: url(../images/media-button-music.gif) no-repeat center left;
     428}
     429
     430#media-upload  #att-info p.type-video {
     431    background: url(../images/media-button-video.gif) no-repeat center left;
     432}
     433
     434#media-upload  #att-info p.type-file {
     435    background: url(../images/media-button-other.gif) no-repeat center left;
     436}
     437
     438.ml-submit .button {
     439    font-size: 11px;
     440    padding: 1px 2px 2px;
     441}
  • branches/crazyhorse/wp-admin/includes/media.php

    r8335 r8422  
    6868function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) {
    6969
    70     // CAPTIONS_OFF is temporary. Do not use it.
    71     if ( empty($alt) || ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) ) return $html;
     70    if ( empty($alt) ) return $html;
    7271    $id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
    7372
     
    179178    return $id;
    180179}
    181 
    182180
    183181// wrap iframe content (produced by $content_func) in a doctype, html head/body etc
     
    250248    check_admin_referer('media-form');
    251249
    252     if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
    253         $post = $_post = get_post($attachment_id, ARRAY_A);
    254         if ( isset($attachment['post_content']) )
    255             $post['post_content'] = $attachment['post_content'];
    256         if ( isset($attachment['post_title']) )
    257             $post['post_title'] = $attachment['post_title'];
    258         if ( isset($attachment['post_excerpt']) )
    259             $post['post_excerpt'] = $attachment['post_excerpt'];
    260         if ( isset($attachment['menu_order']) )
    261             $post['menu_order'] = $attachment['menu_order'];
    262 
    263         $post = apply_filters('attachment_fields_to_save', $post, $attachment);
    264 
    265         if ( isset($post['errors']) ) {
    266             $errors[$attachment_id] = $post['errors'];
    267             unset($post['errors']);
    268         }
    269 
    270         if ( $post != $_post )
    271             wp_update_post($post);
    272 
    273         foreach ( get_attachment_taxonomies($post) as $t )
    274             if ( isset($attachment[$t]) )
    275                 wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
    276     }
     250    if ( !empty($_POST['attachments']) )
     251        foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
     252            $post = $_post = get_post($attachment_id, ARRAY_A);
     253            if ( isset($attachment['post_content']) )
     254                $post['post_content'] = $attachment['post_content'];
     255            if ( isset($attachment['post_title']) )
     256                $post['post_title'] = $attachment['post_title'];
     257            if ( isset($attachment['post_excerpt']) )
     258                $post['post_excerpt'] = $attachment['post_excerpt'];
     259            if ( isset($attachment['menu_order']) )
     260                $post['menu_order'] = $attachment['menu_order'];
     261
     262            $post = apply_filters('attachment_fields_to_save', $post, $attachment);
     263
     264            if ( isset($post['errors']) ) {
     265                $errors[$attachment_id] = $post['errors'];
     266                unset($post['errors']);
     267            }
     268
     269            if ( $post != $_post )
     270                wp_update_post($post);
     271
     272            foreach ( get_attachment_taxonomies($post) as $t )
     273                if ( isset($attachment[$t]) )
     274                    wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
     275        }
    277276
    278277    if ( isset($_POST['insert-gallery']) )
     
    296295}
    297296
     297// crazyhorse
    298298function media_upload_image() {
     299
    299300    if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
    300301        // Upload File button was clicked
     302        if ( $_FILES['async-upload']['name'] == '' )
     303            return wp_iframe( 'media_error_nofile' );
     304
    301305        $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
    302306        unset($_FILES);
     
    335339    }
    336340
    337     return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
     341    return wp_iframe( 'media_edit_single_form', $id );
    338342}
    339343
     
    507511}
    508512
     513// crazyhorse
    509514function image_attachment_fields_to_edit($form_fields, $post) {
    510515    if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
    511516        $form_fields['post_title']['required'] = true;
    512517
    513         // CAPTIONS_OFF is temporary. Do not use it.
    514         if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) {
    515             $form_fields['post_excerpt']['label'] = __('Alternate Text');
    516             $form_fields['post_excerpt']['helps'][] = __('Alt text for the image, e.g. "The Mona Lisa"');
    517         } else {
    518             $form_fields['post_excerpt']['label'] = __('Caption');
    519             $form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image');
    520         }
    521 
    522         $form_fields['post_content']['label'] = __('Description');
    523 
    524         $thumb = wp_get_attachment_thumb_url($post->ID);
     518        $form_fields['post_excerpt']['label'] = __('Caption');
     519        $form_fields['post_excerpt']['helps'][] = __('Alternate text (e.g. Blue skies)');
     520
     521//      $form_fields['post_content']['label'] = __('Description');
     522
     523//      $thumb = wp_get_attachment_thumb_url($post->ID);
    525524
    526525        $form_fields['align'] = array(
     
    537536                <label for='image-align-right-$post->ID' class='align image-align-right-label'>" . __('Right') . "</label>\n",
    538537        );
     538/*
    539539        $form_fields['image-size'] = array(
    540540            'label' => __('Size'),
     
    548548                <label for='image-size-full-$post->ID'>" . __('Full size') . "</label>",
    549549        );
     550*/
    550551    }
    551552    return $form_fields;
     
    597598add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3);
    598599
     600// crazyhorse
    599601function get_attachment_fields_to_edit($post, $errors = null) {
    600602    if ( is_int($post) )
     
    605607    $edit_post = sanitize_post($post, 'edit');
    606608    $file = wp_get_attachment_url($post->ID);
    607     $link = get_attachment_link($post->ID);
    608 
    609     // CAPTIONS_OFF is temporary. Do not use it.
    610     if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF )
    611         $alt = __('Alternate Text');
    612     else
    613         $alt = __('Caption');
     609//  $link = get_attachment_link($post->ID);
    614610
    615611    $form_fields = array(
    616612        'post_title'   => array(
    617613            'label'      => __('Title'),
    618             'value'      => $edit_post->post_title,
     614            'value'      => $edit_post->post_title
    619615        ),
    620616        'post_excerpt' => array(
    621             'label'      => $alt,
    622             'value'      => $edit_post->post_excerpt,
     617            'label'      => __('Caption'),
     618            'value'      => $edit_post->post_excerpt
    623619        ),
     620/*
    624621        'post_content' => array(
    625622            'label'      => __('Description'),
     
    627624            'input'      => 'textarea',
    628625        ),
     626*/
    629627        'url'          => array(
    630             'label'      => __('Link URL'),
    631             'input'      => 'html',
    632             'html'       => "
    633                 <input type='text' name='attachments[$post->ID][url]' value='" . attribute_escape($file) . "' /><br />
    634                 <button type='button' class='button url-$post->ID' value=''>" . __('None') . "</button>
    635                 <button type='button' class='button url-$post->ID' value='" . attribute_escape($file) . "'>" . __('File URL') . "</button>
    636                 <button type='button' class='button url-$post->ID' value='" . attribute_escape($link) . "'>" . __('Post URL') . "</button>
    637                 <script type='text/javascript'>
    638                 jQuery('button.url-$post->ID').bind('click', function(){jQuery(this).siblings('input').val(this.value);});
    639                 </script>\n",
    640             'helps'      => __('Enter a link URL or click above for presets.'),
    641         ),
     628            'label'      => __('Path'),
     629            'value'      => attribute_escape($file)
     630        )
     631/*
    642632        'menu_order'   => array(
    643633            'label'      => __('Order'),
    644634            'value'      => $edit_post->menu_order
    645         ),
     635        ),*/
    646636    );
    647 
     637/*
    648638    foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
    649639        $t = (array) get_taxonomy($taxonomy);
     
    665655        $form_fields[$taxonomy] = $t;
    666656    }
    667 
     657*/
    668658    // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default
    669659    // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing )
     
    675665}
    676666
    677 function get_media_items( $post_id, $errors ) {
     667// crazyhorse
     668function get_media_items( $post_id ) {
    678669    if ( $post_id ) {
    679670        $post = get_post($post_id);
     
    691682        return '';
    692683
     684    $ins = isset($_REQUEST['ins']) ? 1 : 0;
     685
    693686    foreach ( $attachments as $id => $attachment )
    694         if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
    695             $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress'><div class='bar'></div></div><div id='media-upload-error-$id'></div><div class='filename'></div>$item\n</div>";
     687        if ( $item = get_media_item_link( $id, $ins ) )
     688            $output .= $item;
     689
     690        //  $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent'><div class='progress'><div class='bar'></div></div><div id='media-upload-error-$id'></div>$item\n</div>";
    696691
    697692    return $output;
     693}
     694
     695// crazyhorse
     696function get_media_item_link( $attachment_id, $ins ) {
     697
     698    if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
     699        $thumb_url = $thumb_url[0];
     700    else
     701        return false;
     702
     703    $post = get_post($attachment_id);
     704    $mime = $post->post_mime_type;
     705
     706    if ( false !== strpos($mime, 'image') ) $type = 'image';
     707    elseif ( false !== strpos($mime, 'audio') ) $type = 'audio';
     708    elseif ( false !== strpos($mime, 'video') ) $type = 'video';
     709    else $type = 'file';
     710
     711    $ins = $ins ? '&amp;ins=1' : '';
     712    $filename = basename($post->guid);
     713    $title = attribute_escape($post->post_title);
     714    $link = 'media-upload.php?att_id='.$attachment_id.'&amp;tab=single&amp;type='.$type.$ins;
     715
     716    $item = '<div class="filelink">
     717        <a href="'.$link.'">
     718        <img class="thumbnail" src="'.$thumb_url.'" alt="'.$title.'" title="'.$title.'" /></a>
     719        <p class="filelink-caption">'.$filename.'</p></div>'."\n";
     720
     721
     722    return $item;
     723}
     724
     725// crazyhorse
     726function media_edit_single_form($attachment_id = 0) {
     727    global $redir_tab;
     728
     729    $redir_tab = 'gallery';
     730    $ins = isset($_REQUEST['ins']) ? true : false;
     731
     732    if ( ! $attachment_id )
     733       $attachment_id = (int) $_REQUEST['att_id'];
     734
     735    $class = '';
     736    if ( isset($_REQUEST['type']) )
     737        $class = ' class="type-'.$_REQUEST['type'].'"';
     738
     739    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
     740    $form_action_url = admin_url("media-upload.php?type=single&tab=gallery&post_id=$post_id");
     741
     742    $post = get_post($attachment_id);
     743    $filename = basename($post->guid);
     744
     745    media_upload_header();
     746?>
     747
     748<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">
     749<?php wp_nonce_field('media-form'); ?>
     750
     751<div id="att-info"><p<?php echo $class; ?>>
     752<?php echo $filename; ?> &nbsp;
     753(<a href="<?php echo wp_nonce_url("post.php?action=delete-post&amp;post=$attachment_id", 'delete-post_' . $attachment_id); ?>" class="del-link" onclick="return confirm('<?php echo js_escape( __("You are about to delete this file\n  'Cancel' to stop, 'OK' to delete.")); ?>');"><?php _e('Remove'); ?></a> | <a href="media-upload.php?tab=gallery<?php if ( $ins ) echo '&amp;ins=1'; ?>"><?php _e('Change'); ?></a>)
     754</p></div>
     755
     756<?php echo media_edit_single($attachment_id); ?>
     757
     758<p class="ml-submit">
     759<?php if ( $ins ) { ?>
     760   <input type="submit" class="button" name="send[<?php echo $attachment_id; ?>]" value="<?php echo attribute_escape( __( 'Insert into Post' ) ) ?>" />
     761   <input type="hidden" name="ins" value="1" />
     762<?php } ?>
     763
     764<input type="submit" class="button-link button" name="save" value="<?php echo attribute_escape( __( 'Save and Add Another' ) ); ?>" />
     765
     766<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
     767<input type="hidden" name="type" value="<?php echo attribute_escape( $GLOBALS['type'] ); ?>" />
     768<input type="hidden" name="tab" value="<?php echo attribute_escape( $GLOBALS['tab'] ); ?>" />
     769</p>
     770</form>
     771<?php
     772}
     773
     774// crazyhorse
     775function media_edit_single($attachment_id = null) {
     776    global $post_mime_types;
     777
     778    $post = get_post($attachment_id);
     779
     780    $filename = basename($post->guid);
     781    $title_label = __('Title');
     782    $title = attribute_escape($post->post_title);
     783
     784    if ( isset($post_mime_types) ) {
     785        $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
     786        $type = array_shift($keys);
     787        $type = "<input type='hidden' id='type-of-$attachment_id' value='" . attribute_escape( $type ) . "' />";
     788    }
     789
     790    $form_fields = get_attachment_fields_to_edit($post);
     791
     792    $defaults = array(
     793        'input'      => 'text',
     794        'required'   => false,
     795        'value'      => '',
     796        'extra_rows' => array(),
     797    );
     798
     799    $hidden_fields = array();
     800
     801    $item = "<table class='slidetoggle describe $class'>
     802        <thead class='media-item-info'>";
     803
     804    foreach ( $form_fields as $id => $field ) {
     805        if ( $id{0} == '_' )
     806            continue;
     807
     808        if ( !empty($field['tr']) ) {
     809            $item .= $field['tr'];
     810            continue;
     811        }
     812
     813        $field = array_merge($defaults, $field);
     814        $name = "attachments[$attachment_id][$id]";
     815
     816        if ( $field['input'] == 'hidden' ) {
     817            $hidden_fields[$name] = $field['value'];
     818            continue;
     819        }
     820
     821        $required = $field['required'] ? '<abbr title="required" class="required">*</abbr>' : '';
     822        $aria_required = $field['required'] ? " aria-required='true' " : '';
     823        $class  = $id;
     824        $class .= $field['required'] ? ' form-required' : '';
     825
     826        $item .= "\t\t<tr class='$class'>\n\t\t\t<th valign='top' scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}</span><span class='alignright'>$required</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>";
     827        if ( !empty($field[$field['input']]) )
     828            $item .= $field[$field['input']];
     829        elseif ( $field['input'] == 'textarea' ) {
     830            $item .= "<textarea type='text' id='$name' name='$name'>" . attribute_escape( $field['value'] ) . $aria_required . "</textarea>";
     831        } else {
     832            $item .= "<input type='text' id='$name' name='$name' value='" . attribute_escape( $field['value'] ) . "'" . $aria_required . "/>";
     833        }
     834        if ( !empty($field['helps']) )
     835            $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique((array) $field['helps']) ) . '</p>';
     836        $item .= "</td>\n\t\t</tr>\n";
     837
     838        $extra_rows = array();
     839
     840        if ( !empty($field['errors']) )
     841            foreach ( array_unique((array) $field['errors']) as $error )
     842                $extra_rows['error'][] = $error;
     843
     844        if ( !empty($field['extra_rows']) )
     845            foreach ( $field['extra_rows'] as $class => $rows )
     846                foreach ( (array) $rows as $html )
     847                    $extra_rows[$class][] = $html;
     848
     849        foreach ( $extra_rows as $class => $rows )
     850            foreach ( $rows as $html )
     851                $item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n";
     852    }
     853
     854    if ( !empty($form_fields['_final']) )
     855        $item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
     856    $item .= "\t</tbody>\n";
     857    $item .= "\t</table>\n";
     858
     859    foreach ( $hidden_fields as $name => $value )
     860        $item .= "\t<input type='hidden' name='$name' id='$name' value='" . attribute_escape( $value ) . "' />\n";
     861
     862    return $item;
     863
    698864}
    699865
     
    8651031    ?>
    8661032    <script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script>
    867     <div id="media-upload-header">
    868     <?php the_media_upload_tabs(); ?>
    869     </div>
    8701033    <?php
    8711034}
     
    10221185        if ( f.alt.value ) {
    10231186            alt = f.alt.value.replace(/['"<>]+/g, '');
    1024 <?php if ( ! defined('CAPTIONS_OFF') || true != CAPTIONS_OFF ) { // CAPTIONS_OFF is temporary. Do not use it. ?>
    10251187            caption = f.alt.value.replace(/'/g, '&#39;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    1026 <?php } ?>
    10271188        }
    10281189
     
    11321293}
    11331294
     1295// crazyhorse
    11341296function media_upload_library_form($errors) {
    11351297    global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
     
    11371299    media_upload_header();
    11381300
    1139     $post_id = intval($_REQUEST['post_id']);
    1140 
    1141     $form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=library&post_id=$post_id");
     1301    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
     1302
     1303    $form_action_url = admin_url("media-upload.php?type=single&tab=library&post_id=$post_id");
    11421304
    11431305    $_GET['paged'] = intval($_GET['paged']);
     
    11471309    if ( $start < 1 )
    11481310        $start = 0;
    1149     add_filter( 'post_limits', $limit_filter = create_function( '$a', "return 'LIMIT $start, 10';" ) );
     1311    add_filter( 'post_limits', $limit_filter = create_function( '$a', "return 'LIMIT $start, 8';" ) );
    11501312
    11511313    list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
    1152 
     1314    $ins = isset($_REQUEST['ins']) ? '<input type="hidden" name="ins" value="1" />' : '';
    11531315?>
    11541316
    1155 <form id="filter" action="" method="get">
    1156 <input type="hidden" name="type" value="<?php echo attribute_escape( $type ); ?>" />
    1157 <input type="hidden" name="tab" value="<?php echo attribute_escape( $tab ); ?>" />
    1158 <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
    1159 <input type="hidden" name="post_mime_type" value="<?php echo attribute_escape( $_GET['post_mime_type'] ); ?>" />
    1160 
    1161 <div id="search-filter">
    1162     <label class="hidden" for="post-search-input"><?php _e('Search Media');?>:</label>
    1163     <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
    1164     <input type="submit" value="<?php echo attribute_escape( __( 'Search Media' ) ); ?>" class="button" />
     1317<div id="html-upload-ui">
     1318    <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate">
     1319    <input type="file" name="async-upload" id="async-upload" />
     1320    <input type="submit" class="button" name="html-upload" value="<?php echo attribute_escape(__('Upload')); ?>" />
     1321
     1322    <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
     1323    <?php echo $ins; ?>
     1324    <?php wp_nonce_field('media-form'); ?>
     1325    </form>
    11651326</div>
    11661327
    1167 <ul class="subsubsub">
    1168 <?php
    1169 $type_links = array();
    1170 $_num_posts = (array) wp_count_attachments();
    1171 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
    1172 foreach ( $matches as $_type => $reals )
    1173     foreach ( $reals as $real )
    1174         $num_posts[$_type] += $_num_posts[$real];
    1175 // If available type specified by media button clicked, filter by that type
    1176 if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) {
    1177     $_GET['post_mime_type'] = $type;
    1178     list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
    1179 }
    1180 if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' )
    1181     $class = ' class="current"';
    1182 $type_links[] = "<li><a href='" . clean_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))) . "'$class>".__('All Types')."</a>";
    1183 foreach ( $post_mime_types as $mime_type => $label ) {
    1184     $class = '';
    1185 
    1186     if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
    1187         continue;
    1188 
    1189     if ( wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
    1190         $class = ' class="current"';
    1191 
    1192     $type_links[] = "<li><a href='" . clean_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))) . "'$class>" . sprintf(__ngettext($label[2][0], $label[2][1], $num_posts[$mime_type]), "<span id='$mime_type-counter'>" . number_format_i18n( $num_posts[$mime_type] ) . '</span>') . '</a>';
    1193 }
    1194 echo implode(' | </li>', $type_links) . '</li>';
    1195 unset($type_links);
    1196 ?>
    1197 </ul>
     1328<div id="html-upload-help"><?php _e('Or select from your Media Library'); ?></div>
    11981329
    11991330<div class="tablenav">
    1200 
    12011331<?php
    12021332$page_links = paginate_links( array(
     
    12101340    echo "<div class='tablenav-pages'>$page_links</div>";
    12111341?>
    1212 
    1213 <div class="alignleft">
    1214 <?php
    1215 
    1216 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
    1217 
    1218 $arc_result = $wpdb->get_results( $arc_query );
    1219 
    1220 $month_count = count($arc_result);
    1221 
    1222 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>
    1223 <select name='m'>
    1224 <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
    1225 <?php
    1226 foreach ($arc_result as $arc_row) {
    1227     if ( $arc_row->yyear == 0 )
    1228         continue;
    1229     $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
    1230 
    1231     if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] )
    1232         $default = ' selected="selected"';
    1233     else
    1234         $default = '';
    1235 
    1236     echo "<option$default value='" . attribute_escape( $arc_row->yyear . $arc_row->mmonth ) . "'>";
    1237     echo wp_specialchars( $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear" );
    1238     echo "</option>\n";
    1239 }
    1240 ?>
    1241 </select>
    1242 <?php } ?>
    1243 
    1244 <input type="submit" id="post-query-submit" value="<?php echo attribute_escape( __( 'Filter &#187;' ) ); ?>" class="button-secondary" />
    1245 
    12461342</div>
    12471343
     1344<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="library-form">
     1345
     1346<?php wp_nonce_field('media-form'); ?>
     1347
     1348<div id="media-items">
     1349<?php echo get_media_items(null, $errors); ?>
    12481350<br class="clear" />
    12491351</div>
    12501352</form>
    1251 
    1252 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="library-form">
    1253 
    1254 <?php wp_nonce_field('media-form'); ?>
    1255 <?php //media_upload_form( $errors ); ?>
    1256 
    1257 <script type="text/javascript">
    1258 <!--
    1259 jQuery(function($){
    1260     var preloaded = $(".media-item.preloaded");
    1261     if ( preloaded.length > 0 ) {
    1262         preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
    1263         updateMediaForm();
    1264     }
    1265 });
    1266 -->
    1267 </script>
    1268 
    1269 <div id="media-items">
    1270 <?php echo get_media_items(null, $errors); ?>
    1271 </div>
    1272 <p class="ml-submit">
    1273 <input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
    1274 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
    1275 </p>
    1276 </form>
    12771353<?php
    12781354}
     1355
     1356function media_error_nofile() { ?>
     1357    <div style="text-align:center;"><h3>Please choose a file to upload</h3>
     1358    <p><button onclick="history.back();" class="button">Go Back</button></p></div>
     1359<?php }
    12791360
    12801361function type_form_image() {
     
    12961377            <td class="field"><p><input id="title" name="title" value="" type="text" aria-required="true" /></p></td>
    12971378        </tr>
    1298 ';
    1299     // CAPTIONS_OFF is temporary. Do not use it.
    1300     if ( defined('CAPTIONS_OFF') && true == CAPTIONS_OFF ) {
    1301         $form .= '
    1302         <tr>
    1303             <th valign="top" scope="row" class="label">
    1304                 <span class="alignleft"><label for="alt">' . __('Alternate Text') . '</label></span>
    1305             </th>
    1306             <td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
    1307             <p class="help">' . __('Alt text for the image, e.g. "The Mona Lisa"') . '</p></td>
    1308         </tr>
    1309 ';
    1310 
    1311     } else {
    1312         $form .= '
     1379
    13131380        <tr>
    13141381            <th valign="top" scope="row" class="label">
     
    13181385            <p class="help">' . __('Also used as alternate text for the image') . '</p></td>
    13191386        </tr>
    1320 ';
    1321     }
    1322         $form .= '
     1387
    13231388        <tr class="align">
    13241389            <th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
  • branches/crazyhorse/wp-admin/js/media-upload.js

    r8335 r8422  
    2020    tb_position = function() {
    2121        var tbWindow = $('#TB_window');
    22         var width = $(window).width();
    23         var H = $(window).height();
    24         var W = ( 720 < width ) ? 720 : width;
     22        var w = $(window).width();
     23        var h = $(window).height();
     24        var H = ( 340 < h ) ? 340 : h;
     25        var W = ( 385 < w ) ? 385 : w;
    2526
    2627        if ( tbWindow.size() ) {
     
    2930            tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
    3031            if ( typeof document.body.style.maxWidth != 'undefined' )
    31                 tbWindow.css({'top':'20px','margin-top':'0'});
     32                tbWindow.css({'margin-top': '-' + parseInt((( H - 10 ) / 2),10) + 'px'});
    3233            $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
     34            $('#TB_ajaxWindowTitle').text('Add Media').css({'fontSize':'16px','fontWeight':'bold','paddingTop':'3px'});
    3335        };
    3436
     
    4951    });
    5052
    51     $(window).resize( function() { tb_position() } );
     53//  $(window).resize( function() { tb_position() } );
    5254});
    5355
  • branches/crazyhorse/wp-admin/media-upload.php

    r7213 r8422  
    2929    $tab = strval($_GET['tab']);
    3030else
    31     $tab = apply_filters('media_upload_default_tab', 'type');
     31    $tab = apply_filters('media_upload_default_tab', 'library');
    3232
    3333$body_id = 'media-upload';
    3434
    3535// let the action code decide how to handle the request
    36 if ( $tab == 'type' )
    37     do_action("media_upload_$type");
     36if ( isset($_POST['html-upload']) || 'single' == $tab )
     37    do_action("media_upload_image");
    3838else
    39     do_action("media_upload_$tab");
     39    do_action("media_upload_library");
    4040
    4141?>
  • branches/crazyhorse/wp-admin/wp-admin.css

    r8379 r8422  
    17551755    width: 2.7em;
    17561756}
    1757 
    1758 
    1759 
    1760 
    1761 
    1762 
    1763 
  • branches/crazyhorse/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html

    r8335 r8422  
    99
    1010<link rel="stylesheet" href="css/editimage.css?ver=311d" type="text/css" media="all" />
    11 <link rel="stylesheet" href="../../../../../wp-admin/css/media.css?ver=2.6-beta3" type="text/css" media="all" />
     11<link rel="stylesheet" href="css/media26.css?ver=2.6" type="text/css" media="all" />
    1212<script type="text/javascript">
    1313if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
  • branches/crazyhorse/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js

    r8335 r8422  
    1111            // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
    1212            ed.addCommand('WP_EditImage', function() {
    13                 var el = ed.selection.getNode();
     13                var el = ed.selection.getNode(), vp = tinymce.DOM.getViewPort(), H = vp.h, W = ( 720 < vp.w ) ? 720 : vp.w;
    1414
    1515                if ( ed.dom.getAttrib(el, 'class').indexOf('mceItem') != -1 || el.nodeName != 'IMG' )
     
    1717
    1818                tb_show('', url + '/editimage.html?ver=311c&TB_iframe=true');
     19                tinymce.DOM.setStyles('TB_window', {
     20                    'top':'20px',
     21                    'marginTop':'0',
     22                    'width':( W - 50 )+'px',
     23                    'height':( H - 45 )+'px',
     24                    'margin-left':'-'+parseInt((( W - 50 ) / 2),10) + 'px'
     25                });
     26                tinymce.DOM.setStyles('TB_iframeContent', {
     27                    'width':( W - 50 )+'px',
     28                    'height':( H - 75 )+'px'
     29                });
    1930                tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
    2031            });
  • branches/crazyhorse/wp-includes/js/tinymce/tiny_mce_config.php

    r8335 r8422  
    226226if ( $disk_cache ) {
    227227
    228     $cacheKey = apply_filters('tiny_mce_version', '20080710');
     228    $cacheKey = apply_filters('tiny_mce_version', '20080723');
    229229
    230230    foreach ( $initArray as $v )
  • branches/crazyhorse/wp-includes/script-loader.php

    r8335 r8422  
    3838
    3939    // Modify this version when tinyMCE plugins are changed.
    40     $mce_version = apply_filters('tiny_mce_version', '20080710');
     40    $mce_version = apply_filters('tiny_mce_version', '20080723');
    4141    $scripts->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version );
    4242
     
    160160        ) );
    161161        $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080709' );
    162         $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080710' );
     162        $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080723' );
    163163        $scripts->localize( 'upload', 'uploadL10n', array(
    164164            'browseTitle' => attribute_escape(__('Browse your files')),
Note: See TracChangeset for help on using the changeset viewer.