Changeset 7092
- Timestamp:
- 02/28/2008 09:29:51 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/media.css
r7062 r7092 47 47 } 48 48 49 .media-upload-form input[type="text"], .media-upload-form input[type="file"] {50 width: 100%;51 }52 53 49 .media-upload-form fieldset { 54 50 width: 100%; … … 58 54 padding: 0; 59 55 } 60 56 /* 61 57 .media-upload-form button.button-ok { 62 58 float: right; … … 75 71 margin: 0.5em 1em; 76 72 } 77 73 */ 78 74 /* specific to the image upload form */ 79 75 .align .field label { … … 157 153 } 158 154 .describe { 159 display: none;160 155 border-top: 1px solid #d0d0d0; 161 156 padding: 5px; 162 157 width: 100%; 163 158 } 164 . startopen .describe{165 display: block;159 .describe.startopen, .describe.startclosed { 160 display: none; 166 161 } 167 162 .required abbr { … … 180 175 width: 132px; 181 176 } 182 .describe td.savesend {183 text-align: right;184 }185 177 .describe input[type="text"], .describe textarea { 186 178 width: 460px; 187 }188 a.delete {189 display: block;190 text-align: center;191 width: 100%;192 color: #246;193 179 } 194 180 .describe-toggle-on, .describe-toggle-off { … … 212 198 z-index: 10; 213 199 } 214 tr.submit input {215 width: 128px;216 }217 200 tr.align td.field { 218 201 text-align: center; 219 202 } 220 203 a.delete { 204 color: #666; 205 } 221 206 .hidden { 222 207 height: 0px; -
trunk/wp-admin/includes/media.php
r7067 r7092 3 3 function media_upload_tabs() { 4 4 $_default_tabs = array( 5 ' computer' => __('From Computer'), // handler action suffix => tab text6 ' attachments' => __('Attachments'),5 'type' => __('Choose File'), // handler action suffix => tab text 6 'gallery' => __('Gallery'), 7 7 'library' => __('Media Library'), 8 8 ); … … 11 11 } 12 12 13 function update_ attachments_tab($tabs) {13 function update_gallery_tab($tabs) { 14 14 global $wpdb; 15 15 if ( !isset($_REQUEST['post_id']) ) { 16 unset($tabs[' attachments']);16 unset($tabs['gallery']); 17 17 return $tabs; 18 18 } 19 19 if ( intval($_REQUEST['post_id']) ) 20 $attachments = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id']));21 22 $tabs[' attachments'] = sprintf(__('Attachments(%s)'), "<span id='attachments-count'>$attachments</span>");20 $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id']))); 21 22 $tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>$attachments</span>"); 23 23 24 24 return $tabs; 25 25 } 26 add_filter('media_upload_tabs', 'update_ attachments_tab');26 add_filter('media_upload_tabs', 'update_gallery_tab'); 27 27 28 28 function the_media_upload_tabs() { … … 56 56 elseif ( $size == 'thumb' || $size == 'medium' ) 57 57 $html = '<a href="'.get_attachment_link($id).'"'.$rel.'>'.$html.'</a>'; 58 58 59 59 $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url ); 60 60 … … 155 155 global $post_ID, $temp_ID; 156 156 $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); 157 $media_upload_iframe_src = "media-upload.php?type=media&post_id=$uploading_iframe_ID"; 158 $media_upload_iframe_src = apply_filters('media_upload_iframe_src', $media_upload_iframe_src); 159 echo "<a href='$media_upload_iframe_src&TB_iframe=true&height=500&width=640' class='button-secondary thickbox'>" . __('Add media'). '</a>'; 157 $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID"; 158 $media_title = __('Add Media'); 159 $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image"); 160 $image_title = __('Add an Image'); 161 $video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src&type=video"); 162 $video_title = __('Add Video'); 163 $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&type=audio"); 164 $audio_title = __('Add Audio'); 165 $out = <<<EOF 166 167 <a href="{$image_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox" title='$image_title'><img src='images/media-button-image.gif' alt='$image_title' /></a> 168 <a href="{$video_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox" title='$video_title'><img src='images/media-button-video.gif' alt='$video_title' /></a> 169 <a href="{$audio_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox" title='$audio_title'><img src='images/media-button-music.gif' alt='$audio_title' /></a> 170 <a href="{$media_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox" title='$media_title'><img src='images/media-button-other.gif' alt='$media_title' /></a> 171 172 EOF; 173 echo $out; 160 174 } 161 175 add_action( 'media_buttons', 'media_buttons' ); … … 192 206 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); 193 207 194 if ( is_wp_error($id) ) 208 if ( is_wp_error($id) ) { 195 209 $errors['upload_error'] = $id; 210 $id = false; 211 } 196 212 } 197 213 … … 233 249 } 234 250 235 function media_upload_computer() { 251 function media_upload_image() { 252 if ( !empty($_FILES) ) { 253 // Upload File button was clicked 254 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); 255 unset($_FILES); 256 if ( is_wp_error($id) ) { 257 $errors['upload_error'] = $id; 258 $id = false; 259 } 260 } 261 262 if ( !empty($_POST['insertonlybutton']) ) { 263 $src = $_POST['insertonly']['src']; 264 if ( !strpos($src, '://') ) 265 $src = "http://$src"; 266 $alt = attribute_escape($_POST['insertonly']['alt']); 267 if ( isset($_POST['insertonly']['align']) ) { 268 $align = attribute_escape($_POST['insertonly']['align']); 269 $class = " class='align-$align'"; 270 } 271 $html = "<img src='$src' alt='$alt'$class />"; 272 return media_send_to_editor($html); 273 } 274 275 if ( !empty($_POST) ) { 276 $return = media_upload_form_handler(); 277 278 if ( is_string($return) ) 279 return $return; 280 if ( is_array($return) ) 281 $errors = $return; 282 } 283 284 return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); 285 } 286 287 function media_upload_audio() { 288 if ( !empty($_FILES) ) { 289 // Upload File button was clicked 290 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); 291 unset($_FILES); 292 if ( is_wp_error($id) ) { 293 $errors['upload_error'] = $id; 294 $id = false; 295 } 296 } 297 298 if ( !empty($_POST['insertonlybutton']) ) { 299 $href = $_POST['insertonly']['href']; 300 if ( !strpos($href, '://') ) 301 $href = "http://$href"; 302 $title = attribute_escape($_POST['insertonly']['title']); 303 $html = "<a href='$href' >$title</a>"; 304 return media_send_to_editor($html); 305 } 306 307 if ( !empty($_POST) ) { 308 $return = media_upload_form_handler(); 309 310 if ( is_string($return) ) 311 return $return; 312 if ( is_array($return) ) 313 $errors = $return; 314 } 315 316 return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id ); 317 } 318 319 function media_upload_video() { 320 if ( !empty($_FILES) ) { 321 // Upload File button was clicked 322 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); 323 unset($_FILES); 324 if ( is_wp_error($id) ) { 325 $errors['upload_error'] = $id; 326 $id = false; 327 } 328 } 329 330 if ( !empty($_POST['insertonlybutton']) ) { 331 $href = $_POST['insertonly']['href']; 332 if ( !strpos($href, '://') ) 333 $href = "http://$href"; 334 $title = attribute_escape($_POST['insertonly']['title']); 335 $html = "<a href='$href' >$title</a>"; 336 return media_send_to_editor($html); 337 } 338 339 if ( !empty($_POST) ) { 340 $return = media_upload_form_handler(); 341 342 if ( is_string($return) ) 343 return $return; 344 if ( is_array($return) ) 345 $errors = $return; 346 } 347 348 return wp_iframe( 'media_upload_type_form', 'video', $errors, $id ); 349 } 350 351 function media_upload_file() { 352 if ( !empty($_FILES) ) { 353 // Upload File button was clicked 354 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); 355 unset($_FILES); 356 if ( is_wp_error($id) ) { 357 $errors['upload_error'] = $id; 358 $id = false; 359 } 360 } 361 362 if ( !empty($_POST['insertonlybutton']) ) { 363 $href = $_POST['insertonly']['href']; 364 if ( !strpos($href, '://') ) 365 $href = "http://$href"; 366 $title = attribute_escape($_POST['insertonly']['title']); 367 $html = "<a href='$href' >$title</a>"; 368 return media_send_to_editor($html); 369 } 370 371 if ( !empty($_POST) ) { 372 $return = media_upload_form_handler(); 373 374 if ( is_string($return) ) 375 return $return; 376 if ( is_array($return) ) 377 $errors = $return; 378 } 379 380 return wp_iframe( 'media_upload_type_form', 'file', $errors, $id ); 381 } 382 383 function media_upload_gallery() { 236 384 if ( !empty($_POST) ) { 237 385 $return = media_upload_form_handler(); … … 243 391 } 244 392 245 return wp_iframe( 'media_upload_computer_form', $errors ); 246 } 247 248 function media_upload_attachments() { 249 if ( !empty($_POST) ) { 250 $return = media_upload_form_handler(); 251 252 if ( is_string($return) ) 253 return $return; 254 if ( is_array($return) ) 255 $errors = $return; 256 } 257 258 return wp_iframe( 'media_upload_attachments_form', $errors ); 393 return wp_iframe( 'media_upload_gallery_form', $errors ); 259 394 } 260 395 … … 272 407 } 273 408 274 function get_media_items( $post_id, $errors ) {275 if ( $post_id ) {276 $attachments = get_children("post_parent=$post_id&post_type=attachment&orderby=menu_order ASC, ID&order=DESC");277 } else {278 if ( is_array($GLOBALS['wp_the_query']->posts) )279 foreach ( $GLOBALS['wp_the_query']->posts as $attachment )280 $attachments[$attachment->ID] = $attachment;281 }282 283 if ( empty($attachments) )284 return '';285 286 foreach ( $attachments as $id => $attachment )287 if ( $item = get_media_item($id, isset($errors[$id]) ? $errors[$id] : null) )288 $output .= "\n<div id='media-item-$id' class='media-item preloaded'><div id='media-upload-error-$id'></div><span class='filename'></span><div class='progress'><div class='bar'></div></div>$item<div class='progress clickmask'></div>\n</div>";289 290 return $output;291 }292 293 409 function get_attachment_taxonomies($attachment) { 294 410 if ( is_int( $attachment ) ) … … 332 448 $thumb = wp_get_attachment_thumb_url(); 333 449 334 $form_fields['_send']['url'] = array( 335 'label' => __('Link URL'), 336 'input' => 'html', 337 'html' => '', 338 'helps' => __('If filled, this will override the default link URL.'), 339 ); 340 $form_fields['_send']['align'] = array( 450 $form_fields['align'] = array( 341 451 'label' => __('Alignment'), 342 452 'input' => 'html', … … 351 461 <label for='image-align-right-$post->ID' class='align image-align-right-label'>" . __('Right') . "</label>\n", 352 462 ); 353 $form_fields[' _send']['image-size'] = array(463 $form_fields['image-size'] = array( 354 464 'label' => __('Size'), 355 465 'input' => 'html', … … 384 494 $post =& get_post($attachment_id); 385 495 if ( substr($post->post_mime_type, 0, 5) == 'image' ) { 386 if ( !empty($attachment['url']) ) 387 $url = $attachment['url']; 388 elseif ( $rel = strlen(trim($post->post_content)) ) 389 $url = get_attachment_link($attachment_id); 390 else 391 $url = wp_get_attachment_url($attachment_id); 496 $url = $attachment['url']; 392 497 393 498 if ( isset($attachment['align']) ) … … 416 521 417 522 $edit_post = sanitize_post($post, 'edit'); 523 $file = wp_get_attachment_url($post->ID); 524 $link = get_attachment_link($post->ID); 418 525 419 526 $form_fields = array( … … 421 528 'label' => __('Title'), 422 529 'value' => $edit_post->post_title, 530 'helps' => __(''), 423 531 ), 424 532 'post_excerpt' => array( … … 430 538 'value' => $edit_post->post_content, 431 539 'input' => 'textarea', 432 'helps' => array(__('If filled, the default link URL will be the attachment permalink.')), 540 ), 541 'url' => array( 542 'label' => __('Link URL'), 543 'input' => 'html', 544 'html' => " 545 <input type='text' name='attachments[$post->ID][url]' value='" . attribute_escape($file) . "' /> 546 <button type='button' class='button url-$post->ID' value=''>" . __('None') . "</button> 547 <button type='button' class='button url-$post->ID' value='" . attribute_escape($file) . "'>" . __('File URL') . "</button> 548 <button type='button' class='button url-$post->ID' value='" . attribute_escape($link) . "'>" . __('Post URL') . "</button> 549 <script type='text/javascript'> 550 jQuery('button.url-$post->ID').bind('click', function(){jQuery(this).siblings('input').val(this.value);}); 551 </script>\n", 552 'helps' => __('Enter a link URL or click above for presets.'), 433 553 ), 434 554 ); … … 463 583 } 464 584 465 function get_media_item( $attachment_id, $errors = null, $send = true ) { 585 function get_media_items( $post_id, $errors ) { 586 if ( $post_id && $post = get_post($post_id) ) { 587 if ( $post->post_type == 'attachment' ) 588 $attachments = array($post->ID => $post); 589 else 590 $attachments = get_children("post_parent=$post_id&post_type=attachment&orderby=menu_order ASC, ID&order=DESC"); 591 } else { 592 if ( is_array($GLOBALS['wp_the_query']->posts) ) 593 foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) 594 $attachments[$attachment->ID] = $attachment; 595 } 596 597 if ( empty($attachments) ) 598 return ''; 599 600 foreach ( $attachments as $id => $attachment ) 601 if ( $item = get_media_item($id, isset($errors[$id]) ? $errors[$id] : null) ) 602 $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div id='media-upload-error-$id'></div><span class='filename'></span><div class='progress'><div class='bar'></div></div>$item<div class='progress clickmask'></div>\n</div>"; 603 604 return $output; 605 } 606 607 function get_media_item( $attachment_id, $errors = null, $send = true, $delete = true ) { 608 global $post_mime_types; 466 609 if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) ) 467 610 $thumb_url = $thumb_url[0]; … … 487 630 } 488 631 632 if ( isset($post_mime_types) ) { 633 $type = array_shift(array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type))); 634 $type = "<input type='hidden' id='type-of-$attachment_id' value='$type' />"; 635 } 636 489 637 $form_fields = get_attachment_fields_to_edit($post, $errors); 490 638 491 639 $class = empty($errors) ? 'startclosed' : 'startopen'; 492 640 $item = " 641 $type 493 642 <a class='toggle describe-toggle-on' href='#'>$toggle_on</a> 494 643 <a class='toggle describe-toggle-off' href='#'>$toggle_off</a> … … 511 660 512 661 $delete_href = wp_nonce_url("post.php?action=delete-post&post=$attachment_id", 'delete-post_' . $attachment_id); 513 $delete = __('Delete'); 514 $save = "<input type='submit' value='" . wp_specialchars(__('Save'), 1) . "' />"; 515 $send = "<input type='submit' value='" . wp_specialchars(__('Send to Editor'), 1) . "' id='send[$attachment_id]' name='send[$attachment_id]' />"; 516 517 if ( empty($form_fields['save']) && empty($form_fields['_send']) ) { 518 $form_fields['save'] = array('tr' => "\t\t<tr class='submit'><td colspan='2' class='del'><a id='del[$attachment_id]' class='delete button' href='$delete_href'>$delete</a></td><td class='savesend'>$save$send</td></tr>\n"); 519 } elseif ( empty($form_fields['save']) ) { 520 $form_fields['save'] = array('tr' => "\t\t<tr class='submit'><td></td><td></td><td class='savesend'>$save</td></tr>\n"); 521 foreach ( $form_fields['_send'] as $id => $field ) 522 $form_fields[$id] = $field; 523 $form_fields['send'] = array('tr' => "\t\t<tr class='submit'><td colspan='2' class='del'><a id='del[$attachment_id]' class='delete button' href='$delete_href'>$delete</a></td><td class='savesend'>$send</td>"); 524 } 662 if ( $send ) 663 $send = "<button type='submit' class='button' value='1' name='send[$attachment_id]'>" . __('Insert into Post') . '</button>'; 664 if ( $delete ) 665 $delete = "<a href='$delete_href' id='del[$attachment_id]' disabled='disabled' class='delete'>" . __('Delete') . "</button>"; 666 if ( ( $send || $delete ) && !isset($form_fields['buttons']) ) 667 $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td colspan='2'></td><td class='savesend'>$send $delete</td></tr>\n"); 525 668 526 669 $hidden_fields = array(); … … 584 727 } 585 728 586 function media_upload_header() { 729 function media_upload_header($title = false) { 730 if ( empty($title) ) 731 $title = __('Choose a File'); 587 732 ?> 733 <script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script> 588 734 <div id="media-upload-header"> 589 <h3><?php _e('Add Media');?></h3>735 <h3><?php echo $title ?></h3> 590 736 <?php the_media_upload_tabs(); ?> 591 737 </div> … … 594 740 595 741 function media_upload_form( $errors = null ) { 596 $flash_action_url = get_option('siteurl') . '/wp-admin/async-upload.php?type=media'; 742 global $type, $tab; 743 744 $flash_action_url = get_option('siteurl') . "/wp-admin/async-upload.php"; 597 745 598 746 $post_id = intval($_REQUEST['post_id']); 599 747 600 748 ?> 749 <input type='hidden' name='post_id' value='<?php echo $post_id; ?>' /> 601 750 <div id="media-upload-error"> 602 751 <?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { ?> … … 615 764 "post_id" : "<?php echo $post_id; ?>", 616 765 "auth_cookie" : "<?php echo $_COOKIE[AUTH_COOKIE]; ?>", 617 "type" : "media" 766 "type" : "<?php echo $type; ?>", 767 "tab" : "<?php echo $tab; ?>" 618 768 }, 619 769 file_size_limit : "<?php echo wp_max_upload_size(); ?>b", … … 641 791 <div id="flash-upload-ui"> 642 792 <p><input id="flash-browse-button" type="button" value="<?php _e('Choose files to upload'); ?>" class="button" /></p> 643 <p><?php _e('After a file has been uploaded, you can add titles and descriptions below.'); ?></p>793 <p><?php _e('After a file has been uploaded, you can add titles and descriptions.'); ?></p> 644 794 </div> 645 795 646 796 <div id="html-upload-ui"> 647 <p><label for="async-upload"><?php _e('Choose image'); ?></label>648 <input type="file" name="async-upload" id="async-upload" />649 <label for="image-file" class="form-help"><?php _e('Only PNG, JPG, GIF'); ?></label>650 </p>651 797 <p> 652 <button id="upload-button" name="upload-button" value="1" class="button-ok"><?php _e('Add Image'); ?></button> 653 <a href="#" onClick="return top.tb_remove();" id="image-cancel" class="button-cancel"><?php _e('Cancel'); ?></a> 798 <input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" value="<?php echo attribute_escape(__('Upload')); ?>" /> <a href="#" onClick="return top.tb_remove();"><?php _e('Cancel'); ?></a> 654 799 </p> 655 800 <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" /> … … 659 804 } 660 805 661 function media_upload_ computer_form( $errors = null) {806 function media_upload_type_form($type = 'file', $errors = null, $id = null) { 662 807 media_upload_header(); 663 808 664 809 $post_id = intval($_REQUEST['post_id']); 665 810 666 $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type=media&tab=computer&post_id=$post_id"; 667 811 $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type=$type&tab=type&post_id=$post_id"; 812 813 $callback = "type_form_$type"; 668 814 ?> 669 815 670 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form" id="computer-form"> 816 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form type-form" id="<?php echo $type; ?>-form"> 817 <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" /> 671 818 <?php wp_nonce_field('media-form'); ?> 819 <h3><?php _e('From Computer'); ?></h3> 672 820 <?php media_upload_form( $errors ); ?> 673 821 674 <div id="media-items"></div> 675 <p class="submit"> 676 <input type="submit" class="submit insert-gallery" name="insert-media" value="<?php _e('Insert gallery into post'); ?>" /> 677 </p> 678 </form> 679 680 <?php 681 } 682 683 function media_upload_attachments_form($errors) { 684 media_upload_header(); 685 686 $post_id = intval($_REQUEST['post_id']); 687 688 $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type=media&tab=attachments&post_id=$post_id"; 689 690 ?> 691 822 <?php if ( $id && !is_wp_error($id) ) : ?> 692 823 <script type="text/javascript"> 693 824 <!-- … … 701 832 --> 702 833 </script> 703 704 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form" id="attachments-form"> 834 <div id="media-items"> 835 <?php echo get_media_items( $id, $errors ); ?> 836 </div> 837 838 <?php elseif ( is_callable($callback) ) : ?> 839 840 <div class="media-blank"> 841 <p style="text-align:center"><?php _e('— OR —'); ?></p> 842 <h3><?php _e('From URL'); ?></h3> 843 </div> 844 845 <div id="media-items"> 846 <div class="media-item media-blank"> 847 <?php echo call_user_func($callback); ?> 848 </div> 849 </div> 850 <?php 851 endif; 852 } 853 854 function media_upload_gallery_form($errors) { 855 media_upload_header(__('Browse attached files')); 856 857 $post_id = intval($_REQUEST['post_id']); 858 859 $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type=media&tab=gallery&post_id=$post_id"; 860 861 ?> 862 863 <script type="text/javascript"> 864 <!-- 865 jQuery(function($){ 866 var preloaded = $(".media-item.preloaded"); 867 if ( preloaded.length > 0 ) { 868 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); 869 updateMediaForm(); 870 } 871 }); 872 --> 873 </script> 874 875 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form" id="gallery-form"> 705 876 <?php wp_nonce_field('media-form'); ?> 706 877 <?php //media_upload_form( $errors ); ?> … … 718 889 719 890 function media_upload_library_form($errors) { 720 global $wpdb, $wp_query, $wp_locale ;721 722 media_upload_header( );891 global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types; 892 893 media_upload_header(__('Browse Media Library')); 723 894 724 895 $post_id = intval($_REQUEST['post_id']); 725 896 726 $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php ?type=media&tab=library&post_id=$post_id";897 $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php"; 727 898 728 899 $_GET['paged'] = intval($_GET['paged']); … … 739 910 740 911 <form id="filter" action="" method="get"> 741 <input type="hidden" name="type" value=" media" />742 <input type="hidden" name="tab" value=" library" />912 <input type="hidden" name="type" value="<?php echo $type; ?>" /> 913 <input type="hidden" name="tab" value="<?php echo $tab; ?>" /> 743 914 <input type="hidden" name="post_id" value="<?php echo $post_id; ?>" /> 744 <input type="hidden" name="post_mime_type" value="<?php echo $_GET['post_mime_type']; ?>" />915 <input type="hidden" name="post_mime_type" value="<?php echo wp_specialchars($_GET['post_mime_type'], true); ?>" /> 745 916 746 917 <div id="search-filter"> … … 767 938 $class = ' class="current"'; 768 939 769 $type_links[] = "<li><a href='" . add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false)) . "'$class>" . sprintf($label[2], $num_posts[$mime_type]) . '</a>';940 $type_links[] = "<li><a href='" . add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false)) . "'$class>" . sprintf($label[2], "<span id='$mime_type-counter'>{$num_posts[$mime_type]}</span>") . '</a>'; 770 941 } 771 942 $class = empty($_GET['post_mime_type']) ? ' class="current"' : ''; … … 808 979 continue; 809 980 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); 810 981 811 982 if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) 812 983 $default = ' selected="selected"'; 813 984 else 814 985 $default = ''; 815 986 816 987 echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>"; 817 988 echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear"; … … 830 1001 </form> 831 1002 832 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form" id="attachments-form"> 1003 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form" id="library-form"> 1004 1005 <?php wp_nonce_field('media-form'); ?> 1006 <?php //media_upload_form( $errors ); ?> 833 1007 834 1008 <script type="text/javascript"> … … 844 1018 </script> 845 1019 846 <?php wp_nonce_field('media-form'); ?>847 <?php //media_upload_form( $errors ); ?>848 849 1020 <div id="media-items"> 850 1021 <?php echo get_media_items(null, $errors); ?> … … 855 1026 } 856 1027 857 add_filter('async_upload_media', 'get_media_item', 10, 2); 858 859 add_filter('media_upload_computer', 'media_upload_computer'); 860 add_action('admin_head_media_upload_computer_form', 'media_admin_css'); 861 862 add_filter('media_upload_attachments', 'media_upload_attachments'); 863 add_action('admin_head_media_upload_attachments_form', 'media_admin_css'); 1028 function type_form_image() { 1029 return ' 1030 <table class="describe"><tbody> 1031 <tr> 1032 <td class="label"><label for="insertonly[src]">' . __('Image URL') . '</label></td> 1033 <td class="required"><abbr title="required">*</abbr></td> 1034 <td class="field"><input id="insertonly[src]" name="insertonly[src]" value="" type="text"></td> 1035 </tr> 1036 <tr> 1037 <td class="label"><label for="insertonly[alt]">' . __('Description') . '</label></td> 1038 <td class="required"><abbr title="required">*</abbr></td> 1039 <td class="field"><input id="insertonly[alt]" name="insertonly[alt]" value="" type="text"></td> 1040 </tr> 1041 <tr><td colspan="2"></td><td class="help">' . __('Alternate text, e.g. "The Mona Lisa"') . '</td></tr> 1042 <tr class="align"> 1043 <td class="label"><label for="insertonly[align]">' . __('Alignment') . '</label></td> 1044 <td class="required"></td> 1045 <td class="field"> 1046 <input name="insertonly[align]" id="image-align-none-0" value="none" type="radio"> 1047 <label for="image-align-none-0" class="align image-align-none-label">' . __('None') . '</label> 1048 <input name="insertonly[align]" id="image-align-left-0" value="left" type="radio"> 1049 <label for="image-align-left-0" class="align image-align-left-label">' . __('Left') . '</label> 1050 <input name="insertonly[align]" id="image-align-center-0" value="center" type="radio"> 1051 <label for="image-align-center-0" class="align image-align-center-label">' . __('Center') . '</label> 1052 <input name="insertonly[align]" id="image-align-right-0" value="right" type="radio"> 1053 <label for="image-align-right-0" class="align image-align-right-label">' . __('Right') . '</label> 1054 </td> 1055 </tr> 1056 <tr> 1057 <td colspan="2"></td> 1058 <td> 1059 <input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" /> 1060 </td> 1061 </tr> 1062 </tbody></table> 1063 '; 1064 } 1065 1066 function type_form_audio() { 1067 return ' 1068 <table class="describe"><tbody> 1069 <tr> 1070 <td class="label"><label for="insertonly[href]">' . __('Audio File URL') . '</label></td> 1071 <td class="required"><abbr title="required">*</abbr></td> 1072 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text"></td> 1073 </tr> 1074 <tr> 1075 <td class="label"><label for="insertonly[title]">' . __('Title') . '</label></td> 1076 <td class="required"><abbr title="required">*</abbr></td> 1077 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text"></td> 1078 </tr> 1079 <tr><td colspan="2"></td><td class="help">' . __('Link text, e.g. "Still Alive by Jonathan Coulton"') . '</td></tr> 1080 <tr> 1081 <td colspan="2"></td> 1082 <td> 1083 <input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" /> 1084 </td> 1085 </tr> 1086 </tbody></table> 1087 '; 1088 } 1089 1090 function type_form_video() { 1091 return ' 1092 <table class="describe"><tbody> 1093 <tr> 1094 <td class="label"><label for="insertonly[href]">' . __('Video URL') . '</label></td> 1095 <td class="required"><abbr title="required">*</abbr></td> 1096 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text"></td> 1097 </tr> 1098 <tr> 1099 <td class="label"><label for="insertonly[title]">' . __('Title') . '</label></td> 1100 <td class="required"><abbr title="required">*</abbr></td> 1101 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text"></td> 1102 </tr> 1103 <tr><td colspan="2"></td><td class="help">' . __('Link text, e.g. "Lucy on YouTube"') . '</td></tr> 1104 <tr> 1105 <td colspan="2"></td> 1106 <td> 1107 <input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" /> 1108 </td> 1109 </tr> 1110 </tbody></table> 1111 '; 1112 } 1113 1114 function type_form_file() { 1115 return ' 1116 <table class="describe"><tbody> 1117 <tr> 1118 <td class="label"><label for="insertonly[href]">' . __('URL') . '</label></td> 1119 <td class="required"><abbr title="required">*</abbr></td> 1120 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text"></td> 1121 </tr> 1122 <tr> 1123 <td class="label"><label for="insertonly[title]">' . __('Title') . '</label></td> 1124 <td class="required"><abbr title="required">*</abbr></td> 1125 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text"></td> 1126 </tr> 1127 <tr><td colspan="2"></td><td class="help">' . __('Link text, e.g. "Ransom Demands (PDF)"') . '</td></tr> 1128 <tr> 1129 <td colspan="2"></td> 1130 <td> 1131 <input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" /> 1132 </td> 1133 </tr> 1134 </tbody></table> 1135 '; 1136 } 1137 1138 add_filter('async_upload_image', 'get_media_item', 10, 2); 1139 add_filter('async_upload_audio', 'get_media_item', 10, 2); 1140 add_filter('async_upload_video', 'get_media_item', 10, 2); 1141 add_filter('async_upload_file', 'get_media_item', 10, 2); 1142 1143 add_action('media_upload_image', 'media_upload_image'); 1144 add_action('media_upload_audio', 'media_upload_audio'); 1145 add_action('media_upload_video', 'media_upload_video'); 1146 add_action('media_upload_file', 'media_upload_file'); 1147 add_action('admin_head_media_upload_type_form', 'media_admin_css'); 1148 1149 add_filter('media_upload_gallery', 'media_upload_gallery'); 1150 add_action('admin_head_media_upload_gallery_form', 'media_admin_css'); 864 1151 865 1152 add_filter('media_upload_library', 'media_upload_library'); -
trunk/wp-admin/media-upload.php
r7043 r7092 20 20 21 21 // upload type: image, video, file, ..? 22 if ( isset($_GET['type']) ) 23 $type = strval($_GET['type']); 24 else 25 $type = apply_filters('media_upload_default_type', 'file'); 26 27 // tab: gallery, library, or type-specific 22 28 if ( isset($_GET['tab']) ) 23 29 $tab = strval($_GET['tab']); 24 30 else 25 $tab = apply_filters('media_upload_default_tab', ' computer');31 $tab = apply_filters('media_upload_default_tab', 'type'); 26 32 27 33 // let the action code decide how to handle the request 28 do_action("media_upload_$tab"); 34 if ( $tab == 'type' ) 35 do_action("media_upload_$type"); 36 else 37 do_action("media_upload_$tab"); 29 38 30 39 ?> -
trunk/wp-includes/js/swfupload/handlers.js
r7067 r7092 10 10 // progress and success handlers for media multi uploads 11 11 function fileQueued(fileObj) { 12 // Get rid of unused form 13 jQuery('.media-blank').remove(); 12 14 // Create a progress bar containing the filename 13 jQuery('#media-items').prepend('<div id="media-item-' + fileObj.id + '" class="media-item "><span class="filename original">' + fileObj.name + '</span><div class="progress"><div class="bar"></div></div></div>');15 jQuery('#media-items').prepend('<div id="media-item-' + fileObj.id + '" class="media-item child-of-' + post_id + '"><span class="filename original">' + fileObj.name + '</span><div class="progress"><div class="bar"></div></div></div>'); 14 16 15 17 // Disable the submit button … … 51 53 _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')} 52 54 }); 53 // Decrement the counter. 54 jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1); 55 56 // Decrement the counters. 57 if ( type = jQuery('#type-of-' + this.id.replace(/[^0-9]/g,'')).val() ) 58 jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-1); 59 if ( jQuery(this).parents('.media-item').eq(0).hasClass('child-of-'+post_id) ) 60 jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1); 61 55 62 // Vanish it. 56 63 jQuery(this).parents(".media-item").eq(0).slideToggle(300,function(){jQuery(this).remove();if(jQuery('.media-item').length==0)jQuery('.insert-gallery').hide();updateMediaForm();}); … … 67 74 function updateMediaForm() { 68 75 // Just one file, no need for collapsible part 69 if ( jQuery(' #computer-form #media-items>*').length == 1 ) {76 if ( jQuery('.type-form #media-items>*').length == 1 ) { 70 77 jQuery('#media-items .slidetoggle').slideDown(500).parent().eq(0).children('.toggle').toggle(); 71 jQuery(' #computer-form .slidetoggle').siblings().addClass('hidden');78 jQuery('.type-form .slidetoggle').siblings().addClass('hidden'); 72 79 } else { 73 jQuery(' #computer-form .slidetoggle').siblings().removeClass('hidden');80 jQuery('.type-form .slidetoggle').siblings().removeClass('hidden'); 74 81 } 75 82 … … 89 96 prepareMediaItem(fileObj, serverData); 90 97 updateMediaForm(); 91 jQuery('#attachments-count').text(1 * jQuery('#attachments-count').text() + 1); 98 99 // Increment the counter. 100 if ( jQuery('#media-item-' + fileObj.id).hasClass('child-of-' + post_id) ) 101 jQuery('#attachments-count').text(1 * jQuery('#attachments-count').text() + 1); 92 102 } 93 103 … … 117 127 } 118 128 else if ( error_code == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT ) { 119 wp QueueError(swfuploadL10n.file_exceeds_size_limit);129 wpFileError(fileObj, swfuploadL10n.file_exceeds_size_limit); 120 130 } 121 131 else if ( error_code == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE ) { 122 wp QueueError(swfuploadL10n.zero_byte_file);132 wpFileError(fileObj, swfuploadL10n.zero_byte_file); 123 133 } 124 134 else if ( error_code == SWFUpload.QUEUE_ERROR.INVALID_FILETYPE ) { 125 wp QueueError(swfuploadL10n.invalid_filetype);135 wpFileError(fileObj, swfuploadL10n.invalid_filetype); 126 136 } 127 137 else { -
trunk/wp-includes/script-loader.php
r7082 r7092 89 89 $this->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2'); 90 90 $this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2'); 91 $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-2008022 5');91 $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080227'); 92 92 // these error messages came from the sample swfupload js, they might need changing. 93 93 $this->localize( 'swfupload-handlers', 'swfuploadL10n', array(
Note: See TracChangeset
for help on using the changeset viewer.