| [ Index ] |
|
Code source de WordPress 2.1.2 |
1 <?php 2 require_once ('admin.php'); 3 4 @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); 5 6 if (!current_user_can('upload_files')) 7 wp_die(__('You do not have permission to upload files.')); 8 9 wp_reset_vars(array('action', 'tab', 'from_tab', 'style', 'post_id', 'ID', 'paged', 'post_title', 'post_content', 'delete')); 10 11 // IDs should be integers 12 $ID = (int) $ID; 13 $post_id = (int) $post_id; 14 15 // Require an ID for the edit screen 16 if ( $action == 'edit' && !$ID ) 17 wp_die(__("You are not allowed to be here")); 18 19 require_once ('upload-functions.php'); 20 if ( !$tab ) 21 $tab = 'browse-all'; 22 23 do_action( "upload_files_$tab" ); 24 25 $pid = 0; 26 if ( $post_id < 0 ) 27 $pid = $post_id; 28 elseif ( get_post( $post_id ) ) 29 $pid = $post_id; 30 $wp_upload_tabs = array(); 31 $all_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'"); 32 $post_atts = 0; 33 34 if ( $pid ) { 35 // 0 => tab display name, 1 => required cap, 2 => function that produces tab content, 3 => total number objects OR array(total, objects per page), 4 => add_query_args 36 $wp_upload_tabs['upload'] = array(__('Upload'), 'upload_files', 'wp_upload_tab_upload', 0); 37 if ( $all_atts && $post_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$post_id'") ) 38 $wp_upload_tabs['browse'] = array(__('Browse'), 'upload_files', "wp_upload_tab_browse", $action ? 0 : $post_atts); 39 if ( $post_atts < $all_atts ) 40 $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts); 41 } else 42 $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts); 43 44 $wp_upload_tabs = array_merge($wp_upload_tabs, apply_filters( 'wp_upload_tabs', array() )); 45 46 if ( !is_callable($wp_upload_tabs[$tab][2]) ) { 47 $to_tab = isset($wp_upload_tabs['upload']) ? 'upload' : 'browse-all'; 48 wp_redirect( add_query_arg( 'tab', $to_tab ) ); 49 exit; 50 } 51 52 foreach ( $wp_upload_tabs as $t => $tab_array ) { 53 if ( !current_user_can( $tab_array[1] ) ) { 54 unset($wp_upload_tabs[$t]); 55 if ( $tab == $t ) 56 wp_die(__("You are not allowed to be here")); 57 } 58 } 59 60 if ( 'inline' == $style ) : ?> 61 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 62 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> 63 <head> 64 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 65 <title><?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — WordPress</title> 66 <link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" /> 67 <?php if ( ('rtl' == $wp_locale->text_direction) ) : ?> 68 <link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" /> 69 <?php endif; ?> 70 <script type="text/javascript"> 71 //<![CDATA[ 72 function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}} 73 //]]> 74 </script> 75 <?php do_action('admin_print_scripts'); wp_upload_admin_head(); ?> 76 </head> 77 <body> 78 <?php 79 else : 80 add_action( 'admin_head', 'wp_upload_admin_head' ); 81 include_once ('admin-header.php'); 82 ?> 83 <div class='wrap'> 84 <h2><?php _e('Uploads'); ?></h2> 85 <?php 86 endif; 87 88 echo "<ul id='upload-menu'>\n"; 89 foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check 90 $href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '', 'paged' => '') ); 91 if ( isset($tab_array[4]) && is_array($tab_array[4]) ) 92 add_query_arg( $tab_array[4], $href ); 93 $_href = attribute_escape( $href); 94 $page_links = ''; 95 $class = 'upload-tab alignleft'; 96 if ( $tab == $t ) { 97 $class .= ' current'; 98 if ( $tab_array[3] ) { 99 if ( is_array($tab_array[3]) ) { 100 $total = $tab_array[3][0]; 101 $per = $tab_array[3][1]; 102 } else { 103 $total = $tab_array[3]; 104 $per = 10; 105 } 106 $page_links = paginate_links( array( 107 'base' => add_query_arg( 'paged', '%#%' ), 108 'format' => '', 109 'total' => ceil($total / $per), 110 'current' => $paged ? $paged : 1, 111 'prev_text' => '«', 112 'next_text' => '»' 113 )); 114 if ( $page_links ) 115 $page_links = "<span id='current-tab-nav'>: $page_links</span>"; 116 } 117 } 118 119 echo "\t<li class='$class'><a href='$_href' class='upload-tab-link' title='{$tab_array[0]}'>{$tab_array[0]}</a>$page_links</li>\n"; 120 } 121 unset($t, $tab_array, $href, $_href, $page_links, $total, $per, $class); 122 echo "</ul>\n\n"; 123 124 echo "<div id='upload-content' class='$tab'>\n"; 125 126 call_user_func( $wp_upload_tabs[$tab][2] ); 127 128 echo "</div>\n"; 129 130 if ( 'inline' != $style ) : 131 echo "<div class='clear'></div></div>"; 132 include_once ('admin-footer.php'); 133 else : ?> 134 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> 135 136 </body> 137 </html> 138 <?php endif; ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Fri Mar 30 19:41:27 2007 | par Balluche grâce à PHPXref 0.7 |