Make WordPress Core


Ignore:
Timestamp:
08/19/2008 11:01:36 PM (18 years ago)
Author:
ryan
Message:

Merge cleanup

File:
1 edited

Legend:

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

    r8620 r8677  
    6868function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) {
    6969
    70 <<<<<<< .working
    71     if ( empty($alt) ) return $html;
    72 =======
    7370    if ( empty($alt) || apply_filters( 'disable_captions', '' ) ) return $html;
    74 >>>>>>> .merge-right.r8619
    7571    $id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
    7672
     
    182178    return $id;
    183179}
     180
    184181
    185182// wrap iframe content (produced by $content_func) in a doctype, html head/body etc
     
    246243    printf($context, $out);
    247244}
    248 //add_action( 'media_buttons', 'media_buttons' ); // crazyhorse
     245add_action( 'media_buttons', 'media_buttons' );
    249246add_action('media_upload_media', 'media_upload_handler');
    250247
     
    252249    check_admin_referer('media-form');
    253250
    254     if ( !empty($_POST['attachments']) )
    255         foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
    256             $post = $_post = get_post($attachment_id, ARRAY_A);
    257             if ( isset($attachment['post_content']) )
    258                 $post['post_content'] = $attachment['post_content'];
    259             if ( isset($attachment['post_title']) )
    260                 $post['post_title'] = $attachment['post_title'];
    261             if ( isset($attachment['post_excerpt']) )
    262                 $post['post_excerpt'] = $attachment['post_excerpt'];
    263             if ( isset($attachment['menu_order']) )
    264                 $post['menu_order'] = $attachment['menu_order'];
    265 
    266             $post = apply_filters('attachment_fields_to_save', $post, $attachment);
    267 
    268             if ( isset($post['errors']) ) {
    269                 $errors[$attachment_id] = $post['errors'];
    270                 unset($post['errors']);
    271             }
    272 
    273             if ( $post != $_post )
    274                 wp_update_post($post);
    275 
    276             foreach ( get_attachment_taxonomies($post) as $t )
    277                 if ( isset($attachment[$t]) )
    278                     wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
    279         }
     251    if ( !empty($_POST['attachments']) ) 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    }
    280276
    281277    if ( isset($_POST['insert-gallery']) )
     
    299295}
    300296
    301 // crazyhorse
    302297function media_upload_image() {
    303 <<<<<<< .working
    304 
    305 =======
    306298    $errors = array();
    307299    $id = 0;
    308300
    309 >>>>>>> .merge-right.r8619
    310301    if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
    311302        // Upload File button was clicked
    312         if ( $_FILES['async-upload']['name'] == '' )
    313             return wp_iframe( 'media_error_nofile' );
    314 
    315303        $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
    316304        unset($_FILES);
     
    349337    }
    350338
    351     return wp_iframe( 'media_edit_single_form', $id, $errors );
     339    return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
    352340}
    353341
     
    533521}
    534522
    535 <<<<<<< .working
    536 // crazyhorse
    537 =======
     523// produce HTML for the image alignment radio buttons with the specified one checked
     524function image_align_input_fields($post, $checked='') {
     525   
     526    $alignments = array('none' => 'None', 'left' => 'Left', 'center' => 'Center', 'right' => 'Right');
     527    if ( !array_key_exists($checked, $alignments) )
     528        $checked = 'none';
     529   
     530    $out = array();
     531    foreach ($alignments as $name => $label) {
     532   
     533        $out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='none'".
     534            ( $checked == $name ? " checked='checked'" : "" ) .
     535            " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>" . __($label) . "</label>";
     536    }
     537    return join("\n", $out);
     538}
     539
     540// produce HTML for the size radio buttons with the specified one checked
    538541function image_size_input_fields($post, $checked='') {
    539542       
    540543        // get a list of the actual pixel dimensions of each possible intermediate version of this image
    541         $sizes = array();
    542544        $size_names = array('thumbnail' => 'Thumbnail', 'medium' => 'Medium', 'large' => 'Large', 'full' => 'Full size');
    543545       
     
    548550            $enabled = ( $downsize[3] || 'full' == $size );
    549551            $css_id = "image-size-{$size}-{$post->ID}";
     552            // if this size is the default but that's not available, don't select it
     553            if ( $checked && !$enabled )
     554                $checked = '';
    550555            // if $checked was not specified, default to the first available size that's bigger than a thumbnail
    551556            if ( !$checked && $enabled && 'thumbnail' != $size )
     
    571576}
    572577
    573 >>>>>>> .merge-right.r8619
     578// produce HTML for the Link URL buttons with the default link type as specified
     579function image_link_input_fields($post, $url_type='') {
     580
     581    $file = wp_get_attachment_url($post->ID);
     582    $link = get_attachment_link($post->ID);
     583
     584    $url = '';
     585    if ( $url_type == 'file' )
     586        $url = $file;
     587    elseif ( $url_type == 'post' )
     588        $url = $link;
     589   
     590    return "<input type='text' name='attachments[$post->ID][url]' value='" . attribute_escape($url) . "' /><br />
     591                <button type='button' class='button url-$post->ID' value=''>" . __('None') . "</button>
     592                <button type='button' class='button url-$post->ID' value='" . attribute_escape($file) . "'>" . __('File URL') . "</button>
     593                <button type='button' class='button url-$post->ID' value='" . attribute_escape($link) . "'>" . __('Post URL') . "</button>
     594                <script type='text/javascript'>
     595                jQuery('button.url-$post->ID').bind('click', function(){jQuery(this).siblings('input').val(this.value);});
     596                </script>\n";
     597}
     598
    574599function image_attachment_fields_to_edit($form_fields, $post) {
    575600    if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
    576601        $form_fields['post_title']['required'] = true;
    577602
    578 <<<<<<< .working
    579         $form_fields['post_excerpt']['label'] = __('Caption');
    580         $form_fields['post_excerpt']['helps'][] = __('Alternate text (e.g. Blue skies)');
    581 =======
    582603        $form_fields['post_excerpt']['label'] = __('Caption');
    583604        $form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image');
    584 >>>>>>> .merge-right.r8619
    585 
    586 //      $form_fields['post_content']['label'] = __('Description');
    587 
    588 <<<<<<< .working
    589 //      $thumb = wp_get_attachment_thumb_url($post->ID);
    590 
    591 =======
    592 >>>>>>> .merge-right.r8619
     605
     606        $form_fields['post_content']['label'] = __('Description');
     607
    593608        $form_fields['align'] = array(
    594609            'label' => __('Alignment'),
    595610            'input' => 'html',
    596             'html'  => "
    597                 <input type='radio' name='attachments[$post->ID][align]' id='image-align-none-$post->ID' value='none' checked='checked' />
    598                 <label for='image-align-none-$post->ID' class='align image-align-none-label'>" . __('None') . "</label>
    599                 <input type='radio' name='attachments[$post->ID][align]' id='image-align-left-$post->ID' value='left' />
    600                 <label for='image-align-left-$post->ID' class='align image-align-left-label'>" . __('Left') . "</label>
    601                 <input type='radio' name='attachments[$post->ID][align]' id='image-align-center-$post->ID' value='center' />
    602                 <label for='image-align-center-$post->ID' class='align image-align-center-label'>" . __('Center') . "</label>
    603                 <input type='radio' name='attachments[$post->ID][align]' id='image-align-right-$post->ID' value='right' />
    604                 <label for='image-align-right-$post->ID' class='align image-align-right-label'>" . __('Right') . "</label>\n",
     611            'html'  => image_align_input_fields($post, get_option('image_default_align')),
    605612        );
    606 <<<<<<< .working
    607 /*
    608         $form_fields['image-size'] = array(
    609             'label' => __('Size'),
    610             'input' => 'html',
    611             'html'  => "
    612                 " . ( $thumb ? "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-thumb-$post->ID' value='thumbnail' />
    613                 <label for='image-size-thumb-$post->ID'>" . __('Thumbnail') . "</label>
    614                 " : '' ) . "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-medium-$post->ID' value='medium' checked='checked' />
    615                 <label for='image-size-medium-$post->ID'>" . __('Medium') . "</label>
    616                 <input type='radio' name='attachments[$post->ID][image-size]' id='image-size-full-$post->ID' value='full' />
    617                 <label for='image-size-full-$post->ID'>" . __('Full size') . "</label>",
    618         );
    619 =======
    620         $form_fields['image-size'] = image_size_input_fields($post);
    621 >>>>>>> .merge-right.r8619
    622 */
     613       
     614        $form_fields['image-size'] = image_size_input_fields($post, get_option('image_default_size'));
    623615    }
    624616    return $form_fields;
     
    670662add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3);
    671663
    672 // crazyhorse
    673664function get_attachment_fields_to_edit($post, $errors = null) {
    674665    if ( is_int($post) )
     
    679670    $edit_post = sanitize_post($post, 'edit');
    680671    $file = wp_get_attachment_url($post->ID);
    681 //  $link = get_attachment_link($post->ID);
     672    $link = get_attachment_link($post->ID);
    682673
    683674    $form_fields = array(
    684675        'post_title'   => array(
    685676            'label'      => __('Title'),
    686             'value'      => $edit_post->post_title
     677            'value'      => $edit_post->post_title,
    687678        ),
    688679        'post_excerpt' => array(
    689 <<<<<<< .working
    690             'label'      => __('Caption'),
    691             'value'      => $edit_post->post_excerpt
    692 =======
    693680            'label'      => __('Caption'),
    694681            'value'      => $edit_post->post_excerpt,
    695 >>>>>>> .merge-right.r8619
    696682        ),
    697 /*
    698683        'post_content' => array(
    699684            'label'      => __('Description'),
     
    701686            'input'      => 'textarea',
    702687        ),
    703 */
    704688        'url'          => array(
    705             'label'      => __('Path'),
    706             'value'      => attribute_escape($file)
    707         )
    708 /*
     689            'label'      => __('Link URL'),
     690            'input'      => 'html',
     691            'html'       => image_link_input_fields($post, get_option('image_default_link_type')),
     692            'helps'      => __('Enter a link URL or click above for presets.'),
     693        ),
    709694        'menu_order'   => array(
    710695            'label'      => __('Order'),
    711696            'value'      => $edit_post->menu_order
    712         ),*/
     697        ),
    713698    );
    714 /*
     699
    715700    foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
    716701        $t = (array) get_taxonomy($taxonomy);
     
    732717        $form_fields[$taxonomy] = $t;
    733718    }
    734 */
     719
    735720    // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default
    736721    // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing )
     
    742727}
    743728
    744 // crazyhorse
    745 function get_media_items( $post_id ) {
     729function get_media_items( $post_id, $errors ) {
    746730    if ( $post_id ) {
    747731        $post = get_post($post_id);
     
    759743        return '';
    760744
    761     $ins = isset($_REQUEST['ins']) ? 1 : 0;
    762 
    763745    foreach ( $attachments as $id => $attachment )
    764         if ( $item = get_media_item_link( $id, $ins ) )
    765             $output .= $item;
    766 
    767         //  $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>";
     746        if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
     747            $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>";
    768748
    769749    return $output;
    770 }
    771 
    772 // crazyhorse
    773 function get_media_item_link( $attachment_id, $ins ) {
    774 
    775     if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
    776         $thumb_url = $thumb_url[0];
    777     else
    778         return false;
    779 
    780     $post = get_post($attachment_id);
    781     $mime = $post->post_mime_type;
    782 
    783     if ( false !== strpos($mime, 'image') ) $type = 'image';
    784     elseif ( false !== strpos($mime, 'audio') ) $type = 'audio';
    785     elseif ( false !== strpos($mime, 'video') ) $type = 'video';
    786     else $type = 'file';
    787 
    788     $ins = $ins ? '&amp;ins=1' : '';
    789     $filename = basename($post->guid);
    790     $title = attribute_escape($post->post_title);
    791     $link = 'media-upload.php?att_id='.$attachment_id.'&amp;tab=single&amp;type='.$type.$ins;
    792 
    793     $item = '<div class="filelink">
    794         <a href="'.$link.'">
    795         <img class="thumbnail" src="'.$thumb_url.'" alt="'.$title.'" title="'.$title.'" /></a>
    796         <p class="filelink-caption">'.$filename.'</p></div>'."\n";
    797 
    798 
    799     return $item;
    800 }
    801 
    802 // crazyhorse
    803 function media_edit_single_form($attachment_id = 0, $errors = null) {
    804     global $redir_tab;
    805 
    806     $redir_tab = 'gallery';
    807     $ins = isset($_REQUEST['ins']) ? true : false;
    808 
    809     if ( ! $attachment_id )
    810        $attachment_id = (int) $_REQUEST['att_id'];
    811 
    812     $class = '';
    813     if ( isset($_REQUEST['type']) )
    814         $class = ' class="type-'.$_REQUEST['type'].'"';
    815 
    816     $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    817     $form_action_url = admin_url("media-upload.php?type=single&tab=gallery&post_id=$post_id");
    818 
    819     $post = get_post($attachment_id);
    820     $filename = basename($post->guid);
    821 
    822     media_upload_header();
    823 
    824     if ( $errors ) :
    825 ?>
    826 
    827 <div id="media-upload-notice">
    828 <?php if (isset($errors['upload_notice']) ) { ?>
    829     <?php echo $errors['upload_notice']; ?>
    830 <?php } ?>
    831 </div>
    832 <div id="media-upload-error">
    833 <?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { ?>
    834     <?php echo $errors['upload_error']->get_error_message(); ?>
    835 <?php } ?>
    836 </div>
    837 
    838 <?php
    839     return;
    840     endif; // errors
    841 ?>
    842 
    843 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">
    844 <?php wp_nonce_field('media-form'); ?>
    845 
    846 <div id="att-info"><p<?php echo $class; ?>>
    847 <?php echo $filename; ?> &nbsp;
    848 (<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>)
    849 </p></div>
    850 
    851 <?php echo media_edit_single($attachment_id); ?>
    852 
    853 <p class="ml-submit">
    854 <?php if ( $ins ) { ?>
    855    <input type="submit" class="button" name="send[<?php echo $attachment_id; ?>]" value="<?php echo attribute_escape( __( 'Insert into Post' ) ) ?>" />
    856    <input type="hidden" name="ins" value="1" />
    857 <?php } ?>
    858 
    859 <input type="submit" class="button-link button" name="save" value="<?php echo attribute_escape( __( 'Save and Add Another' ) ); ?>" />
    860 
    861 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
    862 <input type="hidden" name="type" value="<?php echo attribute_escape( $GLOBALS['type'] ); ?>" />
    863 <input type="hidden" name="tab" value="<?php echo attribute_escape( $GLOBALS['tab'] ); ?>" />
    864 </p>
    865 </form>
    866 <?php
    867 }
    868 
    869 // crazyhorse
    870 function media_edit_single($attachment_id = null) {
    871     global $post_mime_types;
    872 
    873     $post = get_post($attachment_id);
    874 
    875     $filename = basename($post->guid);
    876     $title_label = __('Title');
    877     $title = attribute_escape($post->post_title);
    878 
    879     if ( isset($post_mime_types) ) {
    880         $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
    881         $type = array_shift($keys);
    882         $type = "<input type='hidden' id='type-of-$attachment_id' value='" . attribute_escape( $type ) . "' />";
    883     }
    884 
    885     $form_fields = get_attachment_fields_to_edit($post);
    886 
    887     $defaults = array(
    888         'input'      => 'text',
    889         'required'   => false,
    890         'value'      => '',
    891         'extra_rows' => array(),
    892     );
    893 
    894     $hidden_fields = array();
    895 
    896     $item = "<table class='slidetoggle describe $class'>
    897         <thead class='media-item-info'>";
    898 
    899     foreach ( $form_fields as $id => $field ) {
    900         if ( $id{0} == '_' )
    901             continue;
    902 
    903         if ( !empty($field['tr']) ) {
    904             $item .= $field['tr'];
    905             continue;
    906         }
    907 
    908         $field = array_merge($defaults, $field);
    909         $name = "attachments[$attachment_id][$id]";
    910 
    911         if ( $field['input'] == 'hidden' ) {
    912             $hidden_fields[$name] = $field['value'];
    913             continue;
    914         }
    915 
    916         $required = $field['required'] ? '<abbr title="required" class="required">*</abbr>' : '';
    917         $aria_required = $field['required'] ? " aria-required='true' " : '';
    918         $class  = $id;
    919         $class .= $field['required'] ? ' form-required' : '';
    920 
    921         $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'>";
    922         if ( !empty($field[$field['input']]) )
    923             $item .= $field[$field['input']];
    924         elseif ( $field['input'] == 'textarea' ) {
    925             $item .= "<textarea type='text' id='$name' name='$name'>" . attribute_escape( $field['value'] ) . $aria_required . "</textarea>";
    926         } else {
    927             $item .= "<input type='text' id='$name' name='$name' value='" . attribute_escape( $field['value'] ) . "'" . $aria_required . "/>";
    928         }
    929         if ( !empty($field['helps']) )
    930             $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique((array) $field['helps']) ) . '</p>';
    931         $item .= "</td>\n\t\t</tr>\n";
    932 
    933         $extra_rows = array();
    934 
    935         if ( !empty($field['errors']) )
    936             foreach ( array_unique((array) $field['errors']) as $error )
    937                 $extra_rows['error'][] = $error;
    938 
    939         if ( !empty($field['extra_rows']) )
    940             foreach ( $field['extra_rows'] as $class => $rows )
    941                 foreach ( (array) $rows as $html )
    942                     $extra_rows[$class][] = $html;
    943 
    944         foreach ( $extra_rows as $class => $rows )
    945             foreach ( $rows as $html )
    946                 $item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n";
    947     }
    948 
    949     if ( !empty($form_fields['_final']) )
    950         $item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
    951     $item .= "\t</tbody>\n";
    952     $item .= "\t</table>\n";
    953 
    954     foreach ( $hidden_fields as $name => $value )
    955         $item .= "\t<input type='hidden' name='$name' id='$name' value='" . attribute_escape( $value ) . "' />\n";
    956 
    957     return $item;
    958 
    959750}
    960751
     
    1126917    ?>
    1127918    <script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script>
     919    <div id="media-upload-header">
     920    <?php the_media_upload_tabs(); ?>
     921    </div>
    1128922    <?php
    1129923}
     
    12791073        if ( f.alt.value ) {
    12801074            alt = f.alt.value.replace(/['"<>]+/g, '');
    1281 <<<<<<< .working
    1282 =======
    12831075<?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
    1284 >>>>>>> .merge-right.r8619
    12851076            caption = f.alt.value.replace(/'/g, '&#39;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
     1077<?php } ?>
    12861078        }
    12871079
     
    13921184}
    13931185
    1394 // crazyhorse
    13951186function media_upload_library_form($errors) {
    13961187    global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
     
    13981189    media_upload_header();
    13991190
    1400     $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    1401 
    1402     $form_action_url = admin_url("media-upload.php?type=single&tab=library&post_id=$post_id");
     1191    $post_id = intval($_REQUEST['post_id']);
     1192
     1193    $form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=library&post_id=$post_id");
    14031194
    14041195    $_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0;
     
    14081199    if ( $start < 1 )
    14091200        $start = 0;
    1410     add_filter( 'post_limits', $limit_filter = create_function( '$a', "return 'LIMIT $start, 8';" ) );
     1201    add_filter( 'post_limits', $limit_filter = create_function( '$a', "return 'LIMIT $start, 10';" ) );
    14111202
    14121203    list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
    1413     $ins = isset($_REQUEST['ins']) ? '<input type="hidden" name="ins" value="1" />' : '';
     1204
    14141205?>
    14151206
    1416 <div id="html-upload-ui">
    1417     <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate">
    1418     <input type="file" name="async-upload" id="async-upload" />
    1419     <input type="submit" class="button" name="html-upload" value="<?php echo attribute_escape(__('Upload')); ?>" />
    1420 
    1421     <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
    1422     <?php echo $ins; ?>
    1423     <?php wp_nonce_field('media-form'); ?>
    1424     </form>
     1207<form id="filter" action="" method="get">
     1208<input type="hidden" name="type" value="<?php echo attribute_escape( $type ); ?>" />
     1209<input type="hidden" name="tab" value="<?php echo attribute_escape( $tab ); ?>" />
     1210<input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
     1211<input type="hidden" name="post_mime_type" value="<?php echo attribute_escape( $_GET['post_mime_type'] ); ?>" />
     1212
     1213<div id="search-filter">
     1214    <label class="hidden" for="post-search-input"><?php _e('Search Media');?>:</label>
     1215    <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
     1216    <input type="submit" value="<?php echo attribute_escape( __( 'Search Media' ) ); ?>" class="button" />
    14251217</div>
    14261218
    1427 <?php if ( 'false' !== $_GET['library'] ) : ?>
    1428 
    1429 <div id="html-upload-help"><?php _e('Or select from your Media Library'); ?></div>
     1219<ul class="subsubsub">
     1220<?php
     1221$type_links = array();
     1222$_num_posts = (array) wp_count_attachments();
     1223$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
     1224foreach ( $matches as $_type => $reals )
     1225    foreach ( $reals as $real )
     1226        $num_posts[$_type] += $_num_posts[$real];
     1227// If available type specified by media button clicked, filter by that type
     1228if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) {
     1229    $_GET['post_mime_type'] = $type;
     1230    list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
     1231}
     1232if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' )
     1233    $class = ' class="current"';
     1234$type_links[] = "<li><a href='" . clean_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))) . "'$class>".__('All Types')."</a>";
     1235foreach ( $post_mime_types as $mime_type => $label ) {
     1236    $class = '';
     1237
     1238    if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
     1239        continue;
     1240
     1241    if ( wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
     1242        $class = ' class="current"';
     1243
     1244    $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>';
     1245}
     1246echo implode(' | </li>', $type_links) . '</li>';
     1247unset($type_links);
     1248?>
     1249</ul>
    14301250
    14311251<div class="tablenav">
     1252
    14321253<?php
    14331254$page_links = paginate_links( array(
     
    14411262    echo "<div class='tablenav-pages'>$page_links</div>";
    14421263?>
     1264
     1265<div class="alignleft">
     1266<?php
     1267
     1268$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";
     1269
     1270$arc_result = $wpdb->get_results( $arc_query );
     1271
     1272$month_count = count($arc_result);
     1273
     1274if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>
     1275<select name='m'>
     1276<option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
     1277<?php
     1278foreach ($arc_result as $arc_row) {
     1279    if ( $arc_row->yyear == 0 )
     1280        continue;
     1281    $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
     1282
     1283    if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] )
     1284        $default = ' selected="selected"';
     1285    else
     1286        $default = '';
     1287
     1288    echo "<option$default value='" . attribute_escape( $arc_row->yyear . $arc_row->mmonth ) . "'>";
     1289    echo wp_specialchars( $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear" );
     1290    echo "</option>\n";
     1291}
     1292?>
     1293</select>
     1294<?php } ?>
     1295
     1296<input type="submit" id="post-query-submit" value="<?php echo attribute_escape( __( 'Filter &#187;' ) ); ?>" class="button-secondary" />
     1297
    14431298</div>
    14441299
    1445 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="library-form">
    1446 
    1447 <?php wp_nonce_field('media-form'); ?>
    1448 
    1449 <div id="media-items">
    1450 <?php echo get_media_items(null, $errors); ?>
    14511300<br class="clear" />
    14521301</div>
    14531302</form>
     1303
     1304<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="library-form">
     1305
     1306<?php wp_nonce_field('media-form'); ?>
     1307<?php //media_upload_form( $errors ); ?>
     1308
     1309<script type="text/javascript">
     1310<!--
     1311jQuery(function($){
     1312    var preloaded = $(".media-item.preloaded");
     1313    if ( preloaded.length > 0 ) {
     1314        preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
     1315        updateMediaForm();
     1316    }
     1317});
     1318-->
     1319</script>
     1320
     1321<div id="media-items">
     1322<?php echo get_media_items(null, $errors); ?>
     1323</div>
     1324<p class="ml-submit">
     1325<input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
     1326<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
     1327</p>
     1328</form>
    14541329<?php
    1455 
    1456 endif; // library
    1457 }
    1458 
    1459 function media_error_nofile() { ?>
    1460     <div style="text-align:center;"><h3>Please choose a file to upload</h3>
    1461     <p><button onclick="history.back();" class="button">Go Back</button></p></div>
    1462 <?php }
     1330}
    14631331
    14641332function type_form_image() {
     
    14721340    }
    14731341
     1342    $default_align = get_option('image_default_align');
     1343    if ( empty($default_align) )
     1344        $default_align = 'none';
     1345       
    14741346    return '
    14751347    <table class="describe"><tbody>
     
    14891361            <td class="field"><p><input id="title" name="title" value="" type="text" aria-required="true" /></p></td>
    14901362        </tr>
    1491 <<<<<<< .working
    1492 =======
    14931363
    14941364        <tr>
     
    14991369            <p class="help">' . $alt_help . '</p></td>
    15001370        </tr>
    1501 >>>>>>> .merge-right.r8619
    1502 
    1503 <<<<<<< .working
    1504         <tr>
    1505             <th valign="top" scope="row" class="label">
    1506                 <span class="alignleft"><label for="alt">' . __('Image Caption') . '</label></span>
    1507             </th>
    1508             <td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
    1509             <p class="help">' . __('Also used as alternate text for the image') . '</p></td>
    1510         </tr>
    1511 
    1512 =======
    1513 >>>>>>> .merge-right.r8619
     1371
    15141372        <tr class="align">
    15151373            <th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
    15161374            <td class="field">
    1517                 <input name="align" id="align-none" value="alignnone" onclick="addExtImage.align=this.value" type="radio" checked="checked" />
     1375                <input name="align" id="align-none" value="alignnone" onclick="addExtImage.align=this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' />
    15181376                <label for="align-none" class="align image-align-none-label">' . __('None') . '</label>
    1519                 <input name="align" id="align-left" value="alignleft" onclick="addExtImage.align=this.value" type="radio" />
     1377                <input name="align" id="align-left" value="alignleft" onclick="addExtImage.align=this.value" type="radio"' . ($default_align == 'left' ? ' checked="checked"' : '').' />
    15201378                <label for="align-left" class="align image-align-left-label">' . __('Left') . '</label>
    1521                 <input name="align" id="align-center" value="aligncenter" onclick="addExtImage.align=this.value" type="radio" />
     1379                <input name="align" id="align-center" value="aligncenter" onclick="addExtImage.align=this.value" type="radio"' . ($default_align == 'center' ? ' checked="checked"' : '').' />
    15221380                <label for="align-center" class="align image-align-center-label">' . __('Center') . '</label>
    1523                 <input name="align" id="align-right" value="alignright" onclick="addExtImage.align=this.value" type="radio" />
     1381                <input name="align" id="align-right" value="alignright" onclick="addExtImage.align=this.value" type="radio"' . ($default_align == 'right' ? ' checked="checked"' : '').' />
    15241382                <label for="align-right" class="align image-align-right-label">' . __('Right') . '</label>
    15251383            </td>
Note: See TracChangeset for help on using the changeset viewer.