Make WordPress Core

Changeset 4274


Ignore:
Timestamp:
10/03/2006 07:15:13 AM (17 years ago)
Author:
ryan
Message:

Uploader improvements from mdawaffe. fixes #3191

Location:
trunk
Files:
4 added
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r4272 r4274  
    19741974
    19751975?>
    1976 <p><?php _e('Text linked to file') ?><br />
    1977 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid) ?></a></textarea></p>
    1978 <p><?php _e('Text linked to subpost') ?><br />
    1979 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $post->post_title ?></a></textarea></p>
     1976<form id="the-attachment-links">
     1977<table>
     1978    <tr>
     1979        <th scope="row"><?php _e('Text linked to file') ?></th>
     1980        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid) ?></a></textarea></td>
     1981    </tr>
     1982    <tr>
     1983        <th scope="row"><?php _e('Text linked to subpost') ?></th>
     1984        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $post->post_title ?></a></textarea></td>
     1985    </tr>
    19801986<?php if ( $icon ) : ?>
    1981 <p><?php _e('Thumbnail linked to file') ?><br />
    1982 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo $icon ?></a></textarea></p>
    1983 <p><?php _e('Thumbnail linked to subpost') ?><br />
    1984 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $icon ?></a></textarea></p>
     1987    <tr>
     1988        <th scope="row"><?php _e('Thumbnail linked to file') ?></th>
     1989        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo $icon ?></a></textarea></td>
     1990    </tr>
     1991    <tr>
     1992        <th scope="row"><?php _e('Thumbnail linked to subpost') ?></th>
     1993        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $icon ?></a></textarea></td>
     1994    </tr>
    19851995<?php endif; ?>
     1996</table>
     1997</form>
    19861998<?php
    19871999}
  • trunk/wp-admin/edit-form-advanced.php

    r4267 r4274  
    184184if (current_user_can('upload_files')) {
    185185    $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
    186     $uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&amp;post=$uploading_iframe_ID", 'inlineuploading');
     186    $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
    187187    $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
    188188    if ( false != $uploading_iframe_src )
  • trunk/wp-admin/edit-page-form.php

    r4267 r4274  
    157157if (current_user_can('upload_files')) {
    158158    $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
    159     $uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&amp;post=$uploading_iframe_ID", 'inlineuploading');
     159    $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
    160160    $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
    161161    if ( false != $uploading_iframe_src )
  • trunk/wp-admin/menu.php

    r4100 r4274  
    3131$submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php');
    3232$submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
     33$submenu['edit.php'][12] = array(__('Uploads'), 'upload_files', 'upload.php');
    3334$submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php');
    3435$submenu['edit.php'][20] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
     
    125126}
    126127
     128unset($id);
     129
    127130ksort($menu); // make it all pretty
    128131
  • trunk/wp-admin/upload.php

    r4272 r4274  
    11<?php
    22require_once('admin.php');
     3
    34@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    45
     
    67    wp_die(__('You do not have permission to upload files.'));
    78
    8 wp_reset_vars(array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment'));
     9wp_reset_vars(array('action', 'tab', 'from_tab', 'style', 'post_id', 'ID', 'paged', 'post_title', 'post_content', 'delete'));
    910
    10 $post = (int) $post;
    11 $images_width = 1;
     11require_once('upload-functions.php');
     12if ( !$tab )
     13    $tab = 'browse-all';
    1214
    13 switch($action) {
    14 case 'links':
    15 // Do not pass GO.
    16 break;
     15do_action( "upload_files_$tab" );
    1716
    18 case 'delete':
     17add_action( 'admin_head', 'wp_upload_admin_head' );
    1918
    20 check_admin_referer('inlineuploading');
     19$pid = 0;
     20if ( $post_id < 0 )
     21    $pid = $post_id;
     22elseif ( get_post( $post_id ) )
     23    $pid = $post_id;
     24$wp_upload_tabs = array();
     25$all_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'");
     26$post_atts = 0;
     27if ( $pid ) {
     28    $wp_upload_tabs['upload'] = array(__('Upload'), 'upload_files', 'wp_upload_tab_upload');
     29    if ( $all_atts && $post_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$post_id'") )
     30        $wp_upload_tabs['browse'] = array(__('Browse'), 'upload_files', "wp_upload_tab_browse");
     31    if ( $post_atts < $all_atts )
     32        $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse');
     33} else
     34    $wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse');
    2135
    22 if ( !current_user_can('edit_post', (int) $attachment) )
    23     wp_die(__('You are not allowed to delete this attachment.').' <a href="'.basename(__FILE__)."?post=$post&amp;all=$all&amp;action=upload\">".__('Go back').'</a>');
     36    $wp_upload_tabs = array_merge($wp_upload_tabs, apply_filters( 'wp_upload_tabs', array() ));
    2437
    25 wp_delete_attachment($attachment);
    26 
    27 wp_redirect(basename(__FILE__) ."?post=$post&all=$all&action=view&start=$start");
    28 die;
    29 
    30 case 'save':
    31 
    32 check_admin_referer('inlineuploading');
    33 
    34 $overrides = array('action'=>'save');
    35 
    36 $file = wp_handle_upload($_FILES['image'], $overrides);
    37 
    38 if ( isset($file['error']) )
    39     wp_die($file['error'] . '<br /><a href="' . basename(__FILE__) . '?action=upload&post=' . $post . '">'.__('Back to Image Uploading').'</a>');
    40 
    41 $url = $file['url'];
    42 $type = $file['type'];
    43 $file = $file['file'];
    44 $filename = basename($file);
    45 
    46 // Construct the attachment array
    47 $attachment = array(
    48     'post_title' => $imgtitle ? $imgtitle : $filename,
    49     'post_content' => $descr,
    50     'post_type' => 'attachment',
    51     'post_parent' => $post,
    52     'post_mime_type' => $type,
    53     'guid' => $url
    54     );
    55 
    56 // Save the data
    57 $id = wp_insert_attachment($attachment, $file, $post);
    58 
    59 if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
    60     // Generate the attachment's postmeta.
    61     $imagesize = getimagesize($file);
    62     $imagedata['width'] = $imagesize['0'];
    63     $imagedata['height'] = $imagesize['1'];
    64     list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
    65     $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
    66     $imagedata['file'] = $file;
    67 
    68     add_post_meta($id, '_wp_attachment_metadata', $imagedata);
    69 
    70     if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
    71         if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
    72             $thumb = wp_create_thumbnail($file, 128);
    73         elseif ( $imagedata['height'] > 96 )
    74             $thumb = wp_create_thumbnail($file, 96);
    75 
    76         if ( @file_exists($thumb) ) {
    77             $newdata = $imagedata;
    78             $newdata['thumb'] = basename($thumb);
    79             update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata);
    80         } else {
    81             $error = $thumb;
    82         }
    83     }
    84 } else {
    85     add_post_meta($id, '_wp_attachment_metadata', array());
     38if ( !function_exists($wp_upload_tabs[$tab][2]) ) {
     39    $to_tab = isset($wp_upload_tabs['upload']) ? 'upload' : 'browse-all';
     40    wp_redirect( add_query_arg( 'tab', $to_tab ) );
     41    exit;
    8642}
    8743
    88 wp_redirect(basename(__FILE__) . "?post=$post&all=$all&action=view&start=0");
    89 die();
    90 
    91 case 'upload':
    92 
    93 $current_1 = ' class="current"';
    94 $back = $next = false;
    95 break;
    96 
    97 case 'view':
    98 
    99 // How many images do we show? How many do we query?
    100 $num = 5;
    101 $double = $num * 2;
    102 
    103 if ( $post && (empty($all) || $all == 'false') ) {
    104     $and_post = "AND post_parent = '$post'";
    105     $current_2 = ' class="current"';
    106 } else {
    107     $current_3 = ' class="current"';
    108 }
    109 
    110 if (! current_user_can('edit_others_posts') )
    111     $and_user = "AND post_author = " . $user_ID;
    112 
    113 if ( $last )
    114     $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment' $and_user $and_post") - $num;
    115 else
    116     $start = (int) $start;
    117 
    118 if ( $start < 0 )
    119     $start = 0;
    120 
    121 if ( '' == $sort )
    122     $sort = "post_date_gmt DESC";
    123 
    124 $attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_type = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
    125 
    126 if ( count($attachments) == 0 ) {
    127     wp_redirect( basename(__FILE__) ."?post=$post&action=upload" );
    128     die;
    129 } elseif ( count($attachments) > $num ) {
    130     $next = $start + count($attachments) - $num;
    131 } else {
    132     $next = false;
    133 }
    134 
    135 if ( $start > 0 ) {
    136     $back = $start - $num;
    137     if ( $back < 1 )
    138         $back = '0';
    139 } else {
    140     $back = false;
    141 }
    142 
    143 $uwidth_sum = 0;
    144 $html = '';
    145 $popups = '';
    146 $style = '';
    147 $script = '';
    148 if ( count($attachments) > 0 ) {
    149     $attachments = array_slice( $attachments, 0, $num );
    150     $__delete = __('Delete');
    151     $__not_linked = __('Not Linked');
    152     $__linked_to_page = __('Linked to Page');
    153     $__linked_to_image = __('Linked to Image');
    154     $__linked_to_file = __('Linked to File');
    155     $__using_thumbnail = __('Using Thumbnail');
    156     $__using_original = __('Using Original');
    157     $__using_title = __('Using Title');
    158     $__using_filename = __('Using Filename');
    159     $__using_icon = __('Using Icon');
    160     $__no_thumbnail = '<del>'.__('No Thumbnail').'</del>';
    161     $__send_to_editor = __('Send to editor');
    162     $__close = __('Close Options');
    163     $__confirmdelete = __('Delete this file from the server?');
    164     $__nothumb = __('There is no thumbnail associated with this photo.');
    165     $script .= "notlinked = '$__not_linked';
    166 linkedtoimage = '$__linked_to_image';
    167 linkedtopage = '$__linked_to_page';
    168 linkedtofile = '$__linked_to_file';
    169 usingthumbnail = '$__using_thumbnail';
    170 usingoriginal = '$__using_original';
    171 usingtitle = '$__using_title';
    172 usingfilename = '$__using_filename';
    173 usingicon = '$__using_icon';
    174 var aa = new Array();
    175 var ab = new Array();
    176 var imga = new Array();
    177 var imgb = new Array();
    178 var srca = new Array();
    179 var srcb = new Array();
    180 var title = new Array();
    181 var filename = new Array();
    182 var icon = new Array();
    183 ";
    184     foreach ( $attachments as $key => $attachment ) {
    185         $ID = $attachment['ID'];
    186         $href = get_attachment_link($ID);
    187         $meta = get_post_meta($ID, '_wp_attachment_metadata', true);
    188         if (!is_array($meta)) {
    189             $meta = get_post_meta($ID, 'imagedata', true); // Try 1.6 Alpha meta key
    190             if (!is_array($meta)) {
    191                 $meta = array();
    192             }
    193             add_post_meta($ID, '_wp_attachment_metadata', $meta);
    194         }
    195         $attachment = array_merge($attachment, $meta);
    196         $noscript = "<noscript>
    197         <div class='caption'><a href=\"".basename(__FILE__)."?action=links&amp;attachment={$ID}&amp;post={$post}&amp;all={$all}&amp;start={$start}\">Choose Links</a></div>
    198         </noscript>
    199 ";
    200         $send_delete_cancel = "<a onclick=\"sendToEditor({$ID});return false;\" href=\"javascript:void()\">$__send_to_editor</a>
    201 <a onclick=\"return confirm('$__confirmdelete')\" href=\"" . wp_nonce_url( basename(__FILE__) . "?action=delete&amp;attachment={$ID}&amp;all=$all&amp;start=$start&amp;post=$post", inlineuploading) . "\">$__delete</a>
    202         <a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
    203 ";
    204         $uwidth_sum += 128;
    205         if ( preg_match('!^image/!', $attachment['post_mime_type'] ) ) {
    206             $image = & $attachment;
    207             if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) {
    208                 $src = str_replace(basename($image['guid']), $image['thumb'], $image['guid']);
    209                 $script .= "srca[{$ID}] = '$src';
    210 srcb[{$ID}] = '{$image['guid']}';
    211 ";
    212                 $thumb = 'true';
    213                 $thumbtext = $__using_thumbnail;
    214             } else {
    215                 $src = $image['guid'];
    216                 $thumb = 'false';
    217                 $thumbtext = $__no_thumbnail;
    218             }
    219             list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']);
    220             $height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"';
    221             $xpadding = (128 - $image['uwidth']) / 2;
    222             $ypadding = (96 - $image['uheight']) / 2;
    223             $style .= "#target{$ID} img { padding: {$ypadding}px {$xpadding}px; }\n";
    224             $title = wp_specialchars($image['post_title'], ENT_QUOTES);
    225             $script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" class=\"imagelink\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    226 ab[{$ID}] = '<a class=\"imagelink\" href=\"{$image['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    227 imga[{$ID}] = '<img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />';
    228 imgb[{$ID}] = '<img id=\"image{$ID}\" src=\"{$image['guid']}\" alt=\"{$title}\" $height_width />';
    229 ";
    230             $html .= "<div id='target{$ID}' class='attwrap left'>
    231     <div id='div{$ID}' class='imagewrap' onclick=\"doPopup({$ID});\">
    232         <img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />
    233     </div>
    234     {$noscript}
    235 </div>
    236 ";
    237             $popups .= "<div id='popup{$ID}' class='popup'>
    238     <a id=\"I{$ID}\" onclick=\"if($thumb)toggleImage({$ID});else alert('$__nothumb');return false;\" href=\"javascript:void()\">$thumbtext</a>
    239     <a id=\"L{$ID}\" onclick=\"toggleLink({$ID});return false;\" href=\"javascript:void()\">$__not_linked</a>
    240     {$send_delete_cancel}
    241 </div>
    242 ";
    243         } else {
    244             $title = wp_specialchars($attachment['post_title'], ENT_QUOTES);
    245             $filename = basename($attachment['guid']);
    246             $icon = get_attachment_icon($ID);
    247             $toggle_icon = "<a id=\"I{$ID}\" onclick=\"toggleOtherIcon({$ID});return false;\" href=\"javascript:void()\">$__using_title</a>";
    248             $script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    249 ab[{$ID}] = '<a id=\"p{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
    250 title[{$ID}] = '{$title}';
    251 filename[{$ID}] = '{$filename}';
    252 icon[{$ID}] = '{$icon}';
    253 ";
    254             $html .= "<div id='target{$ID}' class='attwrap left'>
    255     <div id='div{$ID}' class='otherwrap usingtext' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">
    256         <a id=\"p{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$title}</a>
    257     </div>
    258     {$noscript}
    259 </div>
    260 ";
    261             $popups .= "<div id='popup{$ID}' class='popup'>
    262     <div class='filetype'>".__('File Type:').' '.str_replace('/',"/\n",$attachment['post_mime_type'])."</div>
    263     <a id=\"L{$ID}\" onclick=\"toggleOtherLink({$ID});return false;\" href=\"javascript:void()\">$__linked_to_file</a>
    264     {$toggle_icon}
    265     {$send_delete_cancel}
    266 </div>
    267 ";
    268         }
     44foreach ( $wp_upload_tabs as $t => $tab_array ) {
     45    if ( !current_user_can( $tab_array[1] ) ) {
     46        unset($wp_upload_tabs[$t]);
     47        if ( $tab == $t )
     48            wp_die(__("You are not allowed to be here"));
    26949    }
    27050}
    27151
    272 $images_width = $uwidth_sum + ( count($images) * 6 ) + 35;
     52include_once('admin-header.php');
    27353
    274 break;
     54echo "<ul id='upload-menu'>\n";
     55foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the current_user_can check
     56    $class = 'upload-tab';
     57    $href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '') );
     58    if ( isset($tab_array[3]) && is_array($tab_array[3]) )
     59        add_query_arg( $tab_array[3], $href );
     60    $_href = wp_specialchars( $href, 1 );
     61    if ( $tab == $t )
     62        $class .= ' current';
     63    echo "\t<li class='$class left'><a href='$_href' title='{$tab_array[0]}'>{$tab_array[0]}</a></li>\n";
     64}
     65echo "</ul>\n\n";
    27566
    276 default:
    277     wp_die(__('This script was not meant to be called directly.'));
    278 }
     67echo "<div id='upload-content'>\n";
    27968
     69call_user_func( $wp_upload_tabs[$tab][2] );
     70
     71echo "</div>\n";
     72
     73include_once('admin-footer.php');
    28074?>
    281 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    282 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    283 <head>
    284 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
    285 <title></title>
    286 <meta http-equiv="imagetoolbar" content="no" />
    287 <script type="text/javascript">
    288 // <![CDATA[
    289 /* Define any variables we'll need, such as alternate URLs. */
    290 <?php echo $script; ?>
    291 function htmldecode(st) {
    292     o = document.getElementById('htmldecode');
    293     if (! o) {
    294         o = document.createElement("A");
    295         o.id = "htmldecode"
    296     }
    297     o.innerHTML = st;
    298     r = o.innerHTML;
    299     return r;
    300 }
    301 function cancelUpload() {
    302     o = document.getElementById('uploadForm');
    303     o.method = 'GET';
    304     o.action.value = 'view';
    305     o.submit();
    306 }
    307 function doPopup(i) {
    308     if ( popup )
    309     popup.style.display = 'none';
    310     target = document.getElementById('target'+i);
    311     popup = document.getElementById('popup'+i);
    312     popup.style.left = (target.offsetLeft) + 'px';
    313     popup.style.top = (target.offsetTop) + 'px';
    314     popup.style.display = 'block';
    315 }
    316 popup = false;
    317 function selectLink(n) {
    318     o=document.getElementById('div'+n);
    319     if ( typeof document.body.createTextRange == 'undefined' || typeof win.tinyMCE == 'undefined' || win.tinyMCE.configs.length < 1 )
    320         return;
    321     r = document.body.createTextRange();
    322     if ( typeof r != 'undefined' ) {
    323         r.moveToElementText(o);
    324         r.select();
    325     }
    326 }
    327 function toggleLink(n) {
    328     ol=document.getElementById('L'+n);
    329     if ( ol.innerHTML == htmldecode(notlinked) ) {
    330         ol.innerHTML = linkedtoimage;
    331     } else if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
    332         ol.innerHTML = linkedtopage;
    333     } else {
    334         ol.innerHTML = notlinked;
    335     }
    336     updateImage(n);
    337 }
    338 function toggleOtherLink(n) {
    339     ol=document.getElementById('L'+n);
    340     if ( ol.innerHTML == htmldecode(linkedtofile) ) {
    341         ol.innerHTML = linkedtopage;
    342     } else {
    343         ol.innerHTML = linkedtofile;
    344     }
    345     updateOtherIcon(n);
    346 }
    347 function toggleImage(n) {
    348     oi = document.getElementById('I'+n);
    349     if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
    350         oi.innerHTML = usingoriginal;
    351     } else {
    352         oi.innerHTML = usingthumbnail;
    353     }
    354     updateImage(n);
    355 }
    356 function toggleOtherIcon(n) {
    357     od = document.getElementById('div'+n);
    358     oi = document.getElementById('I'+n);
    359     if ( oi.innerHTML == htmldecode(usingtitle) ) {
    360         oi.innerHTML = usingfilename;
    361         od.className = 'otherwrap usingtext';
    362     } else if ( oi.innerHTML == htmldecode(usingfilename) && icon[n] != '' ) {
    363         oi.innerHTML = usingicon;
    364         od.className = 'otherwrap usingicon';
    365     } else {
    366         oi.innerHTML = usingtitle;
    367         od.className = 'otherwrap usingtext';
    368     }
    369     updateOtherIcon(n);
    370 }
    371 function updateImage(n) {
    372     od=document.getElementById('div'+n);
    373     ol=document.getElementById('L'+n);
    374     oi=document.getElementById('I'+n);
    375     if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
    376         img = imga[n];
    377     } else {
    378         img = imgb[n];
    379     }
    380     if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
    381         od.innerHTML = ab[n]+img+'</a>';
    382     } else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
    383         od.innerHTML = aa[n]+img+'</a>';
    384     } else {
    385         od.innerHTML = img;
    386     }
    387 }
    388 function updateOtherIcon(n) {
    389     od=document.getElementById('div'+n);
    390     ol=document.getElementById('L'+n);
    391     oi=document.getElementById('I'+n);
    392     if ( oi.innerHTML == htmldecode(usingfilename) ) {
    393         txt = filename[n];
    394     } else if ( oi.innerHTML == htmldecode(usingicon) ) {
    395         txt = icon[n];
    396     } else {
    397         txt = title[n];
    398     }
    399     if ( ol.innerHTML == htmldecode(linkedtofile) ) {
    400         od.innerHTML = ab[n]+txt+'</a>';
    401     } else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
    402         od.innerHTML = aa[n]+txt+'</a>';
    403     } else {
    404         od.innerHTML = txt;
    405     }
    406 }
    407 
    408 var win = window.opener ? window.opener : window.dialogArguments;
    409 if (!win) win = top;
    410 tinyMCE = win.tinyMCE;
    411 function sendToEditor(n) {
    412     o = document.getElementById('div'+n);
    413     h = o.innerHTML.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // Trim
    414     h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)', 'g'), ' $1="$2"$3'); // Enclose attribs in quotes
    415     h = h.replace(new RegExp(' (width|height)=".*?"', 'g'), ''); // Drop size constraints
    416     h = h.replace(new RegExp(' on(click|mousedown)="[^"]*"', 'g'), ''); // Drop menu events
    417     h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames
    418     h = h.replace(new RegExp('<IMG', 'g'), '<img'); // Lowercase again
    419     h = h.replace(new RegExp('(<img .+?")>', 'g'), '$1 />'); // XHTML
    420     if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') )
    421         win.tinyMCE.execCommand('mceInsertContent', false, h);
    422     else
    423         win.edInsertContent(win.edCanvas, h);
    424 }
    425 // ]]>
    426 </script>
    427 <style type="text/css">
    428     <?php if ( $action == 'links' ) : ?>
    429     * html { overflow-x: hidden; }
    430     <?php else : ?>
    431     * html { overflow-y: hidden; }
    432     <?php endif; ?>
    433 
    434     body {
    435         font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
    436         border: none;
    437         margin: 0px;
    438         height: 150px;
    439         background: #dfe8f1;
    440     }
    441 
    442     form { margin: 3px 2px 0px 6px; }
    443 
    444     #wrap {
    445         clear: both;
    446         padding: 0px;
    447         width: 100%;
    448     }
    449 
    450     #images {
    451         position: absolute;
    452         clear: both;
    453         margin: 0px;
    454         padding: 15px 15px;
    455         width: <?php echo $images_width; ?>px;
    456     }
    457 
    458     #images img { background-color: rgb(209, 226, 239); }
    459 
    460     <?php echo $style; ?>
    461 
    462     .attwrap, .attwrap * {
    463         margin: 0px;
    464         padding: 0px;
    465         border: 0px;
    466     }
    467 
    468     .imagewrap {
    469         margin-right: 5px;
    470         overflow: hidden;
    471         width: 128px;
    472     }
    473 
    474     .otherwrap {
    475         margin-right: 5px;
    476         overflow: hidden;
    477         background-color: #f9fcfe;
    478     }
    479 
    480     .otherwrap a { display: block; }
    481 
    482     .otherwrap a, .otherwrap a:hover, .otherwrap a:active, .otherwrap a:visited { color: blue; }
    483 
    484     .usingicon {
    485         padding: 0px;
    486         height: 96px;
    487         text-align: center;
    488         width: 128px;
    489     }
    490 
    491     .usingtext {
    492         padding: 3px;
    493         height: 90px;
    494         text-align: left;
    495         width: 122px;
    496     }
    497 
    498     .filetype {
    499         font-size: 80%;
    500         border-bottom: 3px double #89a;
    501     }
    502 
    503     .imagewrap, .imagewrap img, .imagewrap a, .imagewrap a img, .imagewrap a:hover img, .imagewrap a:visited img, .imagewrap a:active img { text-decoration: none; }
    504 
    505     #upload-menu {
    506         background: #fff;
    507         margin: 0px;
    508         padding: 0;
    509         list-style: none;
    510         height: 2em;
    511         border-bottom: 1px solid #448abd;
    512         width: 100%;
    513     }
    514 
    515     #upload-menu li {
    516         float: left;
    517         margin: 0 0 0 .75em;
    518     }
    519 
    520     #upload-menu a {
    521         display: block;
    522         padding: 5px;
    523         text-decoration: none;
    524         color: #000;
    525         border-top: 3px solid #fff;
    526     }
    527 
    528     #upload-menu .current a {
    529         background: #dfe8f1;
    530         border-right: 2px solid #448abd;
    531     }
    532 
    533     #upload-menu a:hover {
    534         background: #dfe8f1;
    535         color: #000;
    536     }
    537 
    538     .tip {
    539         color: rgb(68, 138, 189);
    540         padding: 2px 1em;
    541     }
    542 
    543     .inactive {
    544         color: #fff;
    545         padding: 1px 3px;
    546     }
    547 
    548     .left { float: left; }
    549 
    550     .right { float: right; }
    551 
    552     .center { text-align: center; }
    553 
    554     #upload-menu li.spacer { margin-left: 40px; }
    555 
    556     #title, #descr {
    557         width: 99%;
    558         margin-top: 1px;
    559     }
    560 
    561     th {
    562         text-align: right;
    563         width: 4.5em;
    564     }
    565 
    566     #descr { height: 36px; }
    567 
    568     #buttons {
    569         margin-top: 2px;
    570         text-align: right;
    571     }
    572 
    573     .popup {
    574         margin: 4px 4px;
    575         padding: 1px;
    576         position: absolute;
    577         width: 114px;
    578         display: none;
    579         background-color: rgb(240, 240, 238);
    580         border-top: 2px solid #fff;
    581         border-right: 2px solid #ddd;
    582         border-bottom: 2px solid #ddd;
    583         border-left: 2px solid #fff;
    584         text-align: center;
    585     }
    586 
    587     .imagewrap .popup {
    588         opacity: .90;
    589         filter:alpha(opacity=90);
    590     }
    591 
    592     .otherwrap .popup { padding-top: 20px; }
    593 
    594     .popup a, .popup a:visited, .popup a:active {
    595         background-color: transparent;
    596         display: block;
    597         width: 100%;
    598         text-decoration: none;
    599         color: #246;
    600     }
    601 
    602     .popup a:hover {
    603         background-color: #fff;
    604         color: #000;
    605     }
    606 
    607     .caption { text-align: center; }
    608 
    609     #submit {
    610         margin: 1px;
    611         width: 99%;
    612     }
    613 
    614     #submit input, #submit input:focus {
    615         background: url( images/fade-butt.png );
    616         border: 3px double #999;
    617         border-left-color: #ccc;
    618         border-top-color: #ccc;
    619         color: #333;
    620         padding: 0.25em;
    621     }
    622 
    623     #submit input:active {
    624         background: #f4f4f4;
    625         border: 3px double #ccc;
    626         border-left-color: #999;
    627         border-top-color: #999;
    628     }
    629 
    630     .zerosize {
    631         width: 0px;
    632         height: 0px;
    633         overflow: hidden;
    634         position: absolute;
    635     }
    636 
    637     #links {
    638         margin: 3px 8px;
    639         line-height: 2em;
    640     }
    641 
    642     #links textarea {
    643         width: 95%;
    644         height: 4.5em;
    645     }
    646 </style>
    647 <?php if ( ('rtl' == $wp_locale->text_direction) ): ?>
    648 <style type="text/css">
    649     body { font: 13px Tahoma, "Lucida Grande", "Lucida Sans Unicode", Verdana; }
    650 
    651     .usingtext { text-align: right; }
    652 
    653     th { text-align: left; }
    654 
    655     .left, #upload-menu li { float: right; }
    656 
    657     .right { float: left; }
    658 
    659     .popup {
    660         border-right: 2px solid #fff;
    661         border-left: 2px solid #ddd;
    662     }
    663 
    664     #upload-menu .current a {
    665         border-right: 0;
    666         border-left: 2px solid #448abd;
    667     }
    668 
    669     #submit input, #submit input:focus {
    670         border-left: 0;
    671         border-right-color: #ccc;
    672     }
    673 
    674     #submit input:active {
    675         border-left: 0;
    676         border-right-color: #999;
    677     }
    678 </style>
    679 <?php endif; ?>
    680 </head>
    681 <body>
    682 <ul id="upload-menu">
    683     <li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__) . "?action=upload&amp;post=$post&amp;all=$all&amp;start=$start"; ?>"><?php _e('Upload'); ?></a></li>
    684 
    685     <?php if ( $attachments = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post'") ): ?>
    686         <li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=false"; ?>"><?php _e('Browse'); ?></a></li>
    687     <?php endif; ?>
    688 
    689     <?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment'")): ?>
    690         <li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=true"; ?>"><?php _e('Browse All'); ?></a></li>
    691     <?php endif; ?>
    692 
    693     <li> </li>
    694 
    695     <?php if ( $action == 'view' ): ?>
    696         <?php if ( false !== $back ): ?>
    697             <li class="spacer"><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=0"; ?>" title="<?php _e('First'); ?>">|&laquo;</a></li>
    698             <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$back"; ?>">&laquo; <?php _e('Back'); ?></a></li>
    699         <?php else: ?>
    700             <li class="inactive spacer">|&laquo;</li>
    701             <li class="inactive">&laquo; <?php _e('Back'); ?></li>
    702         <?php endif; ?>
    703 
    704         <?php if ( false !== $next ): ?>
    705             <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$next"; ?>"><?php _e('Next &raquo;'); ?></a></li>
    706             <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;last=true"; ?>" title="<?php _e('Last'); ?>">&raquo;|</a></li>
    707         <?php else: ?>
    708             <li class="inactive"><?php _e('Next &raquo;'); ?></li>
    709             <li class="inactive">&raquo;|</li>
    710         <?php endif; ?>
    711     <?php endif; ?>
    712 </ul>
    713 
    714 <?php if ( $action == 'view' ): ?>
    715     <div id="wrap">
    716         <!--<div class="tip"><?php _e('You can drag and drop these items into your post. Click on one for more options.'); ?></div>-->
    717         <div id="images">
    718             <?php echo $html; ?>
    719             <?php echo $popups; ?>
    720         </div>
    721     </div>
    722 <?php elseif ( $action == 'upload' ): ?>
    723     <div class="tip"></div>
    724     <form enctype="multipart/form-data" id="uploadForm" method="post" action="<?php echo basename(__FILE__); ?>">
    725         <table style="width: 99%">
    726             <tr>
    727                 <th scope="row"><label for="upload"><?php _e('File:'); ?></label></th>
    728                 <td><input type="file" id="upload" name="image" /></td>
    729             </tr>
    730             <tr>
    731                 <th scope="row"><label for="title"><?php _e('Title:'); ?></label></th>
    732                 <td><input type="text" id="title" name="imgtitle" /></td>
    733             </tr>
    734             <tr>
    735                 <th scope="row"><label for="descr"><?php _e('Description:'); ?></label></th>
    736                 <td><input type="textarea" name="descr" id="descr" value="" /></td>
    737             </tr>
    738             <tr id="buttons">
    739                 <th></th>
    740                 <td>
    741                     <input type="hidden" name="action" value="save" />
    742                     <input type="hidden" name="post" value="<?php echo $post; ?>" />
    743                     <input type="hidden" name="all" value="<?php echo $all; ?>" />
    744                     <input type="hidden" name="start" value="<?php echo $start; ?>" />
    745                     <?php wp_nonce_field( 'inlineuploading' ); ?>
    746                     <div id="submit">
    747                         <input type="submit" value="<?php _e('Upload'); ?>" />
    748                         <?php if ( !empty($all) ): ?>
    749                             <input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
    750                         <?php endif; ?>
    751                     </div>
    752                 </td>
    753             </tr>
    754         </table>
    755     </form>
    756 <?php elseif ( $action == 'links' ): ?>
    757     <div id="links">
    758         <?php the_attachment_links($attachment); ?>
    759     </div>
    760 <?php endif; ?>
    761 </body>
    762 </html>
  • trunk/wp-admin/wp-admin.css

    r4267 r4274  
    187187    padding: 0px;
    188188    margin-bottom: 16px;
    189     height: 15em;
     189    height: 16em;
    190190    width: 100%;
    191191/*  overflow-y: hidden;*/
  • trunk/wp-includes/script-loader.php

    r4206 r4274  
    3030            $this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '3684' );
    3131            $this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
     32            $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), mt_rand() );
    3233        }
    3334    }
Note: See TracChangeset for help on using the changeset viewer.