Changeset 7062
- Timestamp:
- 02/27/2008 08:31:10 AM (17 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/media.css
r7043 r7062 1 1 div#media-upload-header { 2 background-color: #e af3fa;2 background-color: #e4f2fd; 3 3 margin: 0; 4 padding: 1em 0.5em 0 .5em0.5em;4 padding: 1em 0.5em 0 0.5em; 5 5 font-weight: bold; 6 } 7 8 ul#media-upload-tabs { 9 display:inline; 6 position: relative; 7 border-bottom: 1px solid #c6d9e9; 8 } 9 10 ul#sidemenu { 11 font-weight: normal; 12 margin: 0 15px; 10 13 position: absolute; 11 14 right: 1em; 12 top: 1em; 13 font-size: 0.9em; 14 } 15 16 ul#media-upload-tabs li { 17 display:inline; 18 } 19 20 ul#media-upload-tabs li:after { 21 content: " | "; 22 } 23 24 ul#media-upload-tabs li.last:after { 25 content: ""; 26 } 27 28 15 bottom: -1px; 16 } 29 17 30 18 div#media-upload-error { … … 34 22 } 35 23 36 form .media-upload-form{24 form { 37 25 margin: 1em; 26 } 27 28 #search-filter { 29 text-align: right; 38 30 } 39 31 -
trunk/wp-admin/includes/media.php
r7043 r7062 30 30 31 31 if ( !empty($tabs) ) { 32 echo "<ul id=' media-upload-tabs'>\n";32 echo "<ul id='sidemenu'>\n"; 33 33 if ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) 34 34 $current = $_GET['tab']; … … 36 36 $current = array_shift(array_keys($tabs)); 37 37 foreach ( $tabs as $callback => $text ) { 38 if ( ++$i == count($tabs) ) 39 $class = ' class="last"'; 40 $href = add_query_arg('tab', $callback); 41 if ( $callback == $current ) 42 $link = $text; 43 else 44 $link = "<a href='$href'>$text</a>"; 45 echo "\t<li id='tab-$callback'$class>$link</li>\n"; 38 $class = ''; 39 if ( $current == $callback ) 40 $class = " class='current'"; 41 $href = add_query_arg(array('tab'=>$callback, 's'=>false, 'paged'=>false, 'post_mime_type'=>false, 'm'=>false)); 42 $link = "<a href='$href'$class>$text</a>"; 43 echo "\t<li id='tab-$callback'>$link</li>\n"; 46 44 } 47 45 echo "</ul>\n"; … … 262 260 263 261 function media_upload_library() { 264 if ( empty($_POST) ) 265 wp_iframe( 'media_upload_library_form', $errors ); 262 if ( !empty($_POST) ) { 263 $return = media_upload_form_handler(); 264 265 if ( is_string($return) ) 266 return $return; 267 if ( is_array($return) ) 268 $errors = $return; 269 } 270 271 return wp_iframe( 'media_upload_library_form', $errors ); 266 272 } 267 273 268 274 function get_media_items( $post_id, $errors ) { 269 if ( $post_id ) 275 if ( $post_id ) { 270 276 $attachments = get_children("post_parent=$post_id&post_type=attachment&orderby=menu_order ASC, ID&order=DESC"); 271 else 272 $attachments = get_paged_attachments(); 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 } 273 282 274 283 if ( empty($attachments) ) … … 708 717 709 718 function media_upload_library_form($errors) { 719 global $wpdb, $wp_query, $wp_locale; 720 710 721 media_upload_header(); 722 723 $post_id = intval($_REQUEST['post_id']); 724 725 $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type=media&tab=library&post_id=$post_id"; 726 727 $_GET['paged'] = intval($_GET['paged']); 728 if ( $_GET['paged'] < 1 ) 729 $_GET['paged'] = 1; 730 $start = ( $_GET['paged'] - 1 ) * 10; 731 if ( $start < 1 ) 732 $start = 0; 733 add_filter( 'post_limits', $limit_filter = create_function( '$a', "return 'LIMIT $start, 10';" ) ); 734 735 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); 736 737 ?> 738 739 <form id="filter" action="" method="get"> 740 <input type="hidden" name="type" value="media" /> 741 <input type="hidden" name="tab" value="library" /> 742 <input type="hidden" name="post_id" value="<?php echo $post_id; ?>" /> 743 <input type="hidden" name="post_mime_type" value="<?php echo $_GET['post_mime_type']; ?>" /> 744 745 <div id="search-filter"> 746 <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" /> 747 <input type="submit" value="<?php _e( 'Search Media' ); ?>" class="button" /> 748 </div> 749 750 <p> 751 <ul class="subsubsub"> 752 <?php 753 $type_links = array(); 754 $_num_posts = (array) wp_count_attachments(); 755 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); 756 foreach ( $matches as $type => $reals ) 757 foreach ( $reals as $real ) 758 $num_posts[$type] += $_num_posts[$real]; 759 foreach ( $post_mime_types as $mime_type => $label ) { 760 $class = ''; 761 762 if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) 763 continue; 764 765 if ( wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) 766 $class = ' class="current"'; 767 768 $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>'; 769 } 770 $class = empty($_GET['post_mime_type']) ? ' class="current"' : ''; 771 $type_links[] = "<li><a href='" . remove_query_arg(array('post_mime_type', 'paged', 'm')) . "'$class>".__('All Types')."</a>"; 772 echo implode(' | </li>', $type_links) . '</li>'; 773 unset($type_links); 774 ?> 775 </ul> 776 </p> 777 778 <div class="tablenav"> 779 780 <?php 781 $page_links = paginate_links( array( 782 'base' => add_query_arg( 'paged', '%#%' ), 783 'format' => '', 784 'total' => ceil($wp_query->found_posts / 10), 785 'current' => $_GET['paged'] 786 )); 787 788 if ( $page_links ) 789 echo "<div class='tablenav-pages'>$page_links</div>"; 790 ?> 791 792 <div style="float: left"> 793 <?php 794 795 $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"; 796 797 $arc_result = $wpdb->get_results( $arc_query ); 798 799 $month_count = count($arc_result); 800 801 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> 802 <select name='m'> 803 <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option> 804 <?php 805 foreach ($arc_result as $arc_row) { 806 if ( $arc_row->yyear == 0 ) 807 continue; 808 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); 809 810 if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) 811 $default = ' selected="selected"'; 812 else 813 $default = ''; 814 815 echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>"; 816 echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear"; 817 echo "</option>\n"; 818 } 819 ?> 820 </select> 821 <?php } ?> 822 823 <input type="submit" id="post-query-submit" value="<?php _e('Filter »'); ?>" class="button-secondary" /> 824 825 </div> 826 827 <br style="clear:both;" /> 828 </div> 829 </form> 830 831 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form" id="attachments-form"> 832 833 <script type="text/javascript"> 834 <!-- 835 jQuery(function($){ 836 var preloaded = $(".media-item.preloaded"); 837 if ( preloaded.length > 0 ) { 838 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); 839 updateMediaForm(); 840 } 841 }); 842 --> 843 </script> 844 845 <?php wp_nonce_field('media-form'); ?> 846 <?php //media_upload_form( $errors ); ?> 847 848 <div id="media-items"> 849 <?php echo get_media_items(null, $errors); ?> 850 </div> 851 <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" /> 852 </form> 853 <?php 711 854 } 712 855 -
trunk/wp-admin/upload.php
r7057 r7062 38 38 require_once('admin-header.php'); 39 39 40 add_filter( 'post_limits', $limit_filter = create_function( '$a', 'if ( empty($_GET["paged"]) ) $_GET["paged"] = 1; $start = ( intval($_GET["paged"]) - 1 ) * 15; return "LIMIT $start, 20";' ) ); 40 if ( isset($_GET['paged']) && $start = ( intval($_GET['paged']) - 1 ) * 15 ) 41 add_filter( 'post_limits', $limit_filter = create_function( '$a', "return 'LIMIT $start, 15';" ) ); 41 42 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); 42 43 $wp_query->max_num_pages = ceil( $wp_query->found_posts / 15 ); // We grab 20 but only show 15 ( 5 more for ajax extra ) … … 82 83 <ul class="subsubsub"> 83 84 <?php 84 $ status_links = array();85 $type_links = array(); 85 86 $_num_posts = (array) wp_count_attachments(); 86 87 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); … … 97 98 $class = ' class="current"'; 98 99 99 $ status_links[] = "<li><a href=\"upload.php?post_mime_type=$mime_type\"$class>" .100 $type_links[] = "<li><a href=\"upload.php?post_mime_type=$mime_type\"$class>" . 100 101 sprintf($label[2], $num_posts[$mime_type]) . '</a>'; 101 102 } 102 103 $class = empty($_GET['post_mime_type']) ? ' class="current"' : ''; 103 $ status_links[] = "<li><a href=\"upload.php\"$class>".__('All Types')."</a>";104 echo implode(' | </li>', $status_links) . '</li>';105 unset($ status_links);104 $type_links[] = "<li><a href=\"upload.php\"$class>".__('All Types')."</a>"; 105 echo implode(' | </li>', $type_links) . '</li>'; 106 unset($type_links); 106 107 ?> 107 108 </ul>
Note: See TracChangeset
for help on using the changeset viewer.