WordPress.org

Make WordPress Core

Changeset 4355


Ignore:
Timestamp:
10/07/2006 06:31:39 PM (12 years ago)
Author:
ryan
Message:

Inline uploader styling from mdawaffe. fixes #3212

Location:
trunk/wp-admin
Files:
5 edited

Legend:

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

    r4325 r4355  
    19701970
    19711971    $icon = get_attachment_icon($post->ID);
    1972 
     1972    $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
     1973    $thumb = isset($attachment_data['thumb']);
    19731974?>
    19741975<form id="the-attachment-links">
    19751976<table>
     1977    <col />
     1978    <col class="widefat" />
    19761979    <tr>
    1977         <th scope="row"><?php _e('Text linked to file') ?></th>
    1978         <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>
    1979     </tr>
    1980     <tr>
    1981         <th scope="row"><?php _e('Text linked to subpost') ?></th>
    1982         <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>
     1980        <th scope="row"><?php _e('URL') ?></th>
     1981        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo $post->guid ?></textarea></td>
    19831982    </tr>
    19841983<?php if ( $icon ) : ?>
    19851984    <tr>
    1986         <th scope="row"><?php _e('Thumbnail linked to file') ?></th>
    1987         <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>
     1985        <th scope="row"><?php $thumb ? _e('Thumbnail linked to file') : _e('Image linked to file'); ?></th>
     1986        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid; ?>" id="<?php echo $post->ID ?>"><?php echo $icon ?></a></textarea></td>
    19881987    </tr>
    19891988    <tr>
    1990         <th scope="row"><?php _e('Thumbnail linked to subpost') ?></th>
     1989        <th scope="row"><?php $thumb ? _e('Thumbnail linked to page') : _e('Image linked to file'); ?></th>
    19911990        <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>
     1991    </tr>
     1992<?php else : ?>
     1993    <tr>
     1994        <th scope="row"><?php _e('Link to file') ?></th>
     1995        <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>
     1996    </tr>
     1997    <tr>
     1998        <th scope="row"><?php _e('Link to page') ?></th>
     1999        <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 the_title(); ?></a></textarea></td>
    19922000    </tr>
    19932001<?php endif; ?>
  • trunk/wp-admin/upload-functions.php

    r4353 r4355  
    1717        $image_src = explode('"', $image_src);
    1818        $image_src = $image_src[1];
    19         $thumb_src = wp_make_link_relative($image_src);
     19        $image_rel = wp_make_link_relative($image_src);
    2020        $class = 'image';
    21         $innerHTML = '&nbsp;' . str_replace($image_src, $thumb_src, $innerHTML);
     21        $innerHTML = '&nbsp;' . str_replace($image_src, $image_rel, $innerHTML);
     22        $image_base = str_replace($image_rel, '', $image_src);
    2223    }
    2324
    24     $src = wp_make_link_relative( get_the_guid() );
     25    $src_base = get_the_guid();
     26    $src = wp_make_link_relative( $src_base );
     27    $src_base = str_replace($src, '', $src_base);
    2528
    2629    $r = '';
     
    3437    $r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
    3538    $r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='$src' />\n";
    36 
    37     if ( $image_src )
    38         $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$thumb_src' />\n";
     39    $r .= "\t\t\t\t<input type='hidden' name='attachment-url-base-$id' id='attachment-url-base-$id' value='$src_base' />\n";
     40
     41    if ( isset($attachment_data['thumb']) ) {
     42        $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$image_rel' />\n";
     43        $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-$id' id='attachment-thumb-url-base-$id' value='$image_base' />\n";
     44    } elseif ( $image_rel )
     45        $r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-$id' id='attachment-is-image-$id' value='1' />\n";
    3946    if ( isset($width) ) {
    4047        $r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
     
    4956
    5057function wp_upload_view() {
    51     global $style, $post_id;
     58    global $style, $post_id, $style;
    5259    $id = get_the_ID();
    5360    $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
     
    5562    <div id="upload-file">
    5663        <div id="file-title">
    57             <h2><?php if ( !isset($attachment_data['width']) )
     64            <h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
    5865                    echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
    5966                the_title();
    60                 if ( !isset($attachment_data['width']) )
     67                if ( !isset($attachment_data['width']) && 'inline' != $style )
    6168                    echo '</a>';
    6269            ?></h2>
     
    7279
    7380        <div id="upload-file-view" class="alignleft">
    74 <?php       if ( isset($attachment_data['width']) )
     81<?php       if ( isset($attachment_data['width']) && 'inline' != $style )
    7582            echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
    7683        echo wp_upload_display( array(171, 128) );
    77         if ( isset($attachment_data['width']) )
     84        if ( isset($attachment_data['width']) && 'inline' != $style )
    7885            echo '</a>'; ?>
    7986        </div>
    8087        <?php the_attachment_links( $id ); ?>
    8188    </div>
    82 <?php
     89<?php   echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' )  . "' /></form>\n";
    8390}
    8491
     
    95102?>
    96103        <div id="file-title">
    97             <h2><?php if ( !isset($attachment_data['width']) )
     104            <h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
    98105                    echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
    99106                the_title();
    100                 if ( !isset($attachment_data['width']) )
     107                if ( !isset($attachment_data['width']) && 'inline' != $style )
    101108                    echo '</a>';
    102109            ?></h2>
     
    112119
    113120    <div id="upload-file-view" class="alignleft">
    114 <?php       if ( isset($attachment_data['width']) )
     121<?php       if ( isset($attachment_data['width']) && 'inline' != $style )
    115122            echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
    116123        echo wp_upload_display( array(171, 128) );
    117         if ( isset($attachment_data['width']) )
     124        if ( isset($attachment_data['width']) && 'inline' != $style )
    118125            echo '</a>'; ?>
    119126    </div>
    120127<?php   endif; ?>
    121         <table>
    122 <?php   if ( !$id ): ?>
     128        <table><col /><col class="widefat" />
     129<?php   if ( $id ): ?>
    123130            <tr>
    124                 <th scope="row"><label for="upload"><?php _e('File:'); ?></label></th>
     131                <th scope="row"><label for="url"><?php _e('URL'); ?></label></th>
     132                <td><input type="text" id="url" class="readonly" value="<?php the_guid(); ?>" readonly="readonly" /></td>
     133            </tr>
     134<?php   else : ?>
     135            <tr>
     136                <th scope="row"><label for="upload"><?php _e('File'); ?></label></th>
    125137                <td><input type="file" id="upload" name="image" /></td>
    126138            </tr>
    127139<?php   endif; ?>
    128140            <tr>
    129                 <th scope="row"><label for="post_title"><?php _e('Title:'); ?></label></th>
     141                <th scope="row"><label for="post_title"><?php _e('Title'); ?></label></th>
    130142                <td><input type="text" id="post_title" name="post_title" value="<?php echo $attachment->post_title; ?>" /></td>
    131143            </tr>
    132144            <tr>
    133                 <th scope="row"><label for="post_content"><?php _e('Description:'); ?></label></th>
     145                <th scope="row"><label for="post_content"><?php _e('Description'); ?></label></th>
    134146                <td><textarea name="post_content" id="post_content"><?php echo $attachment->post_content; ?></textarea></td>
    135147            </tr>
    136             <tr id="buttons">
    137                 <th></th>
    138                 <td>
     148            <tr id="buttons" class="submit">
     149                <td colspan='2'>
     150<?php   if ( $id ) : ?>
     151                    <input type="submit" name="delete" id="delete" class="delete alignleft" value="<?php _e('Delete File'); ?>" />
     152<?php   endif; ?>
    139153                    <input type="hidden" name="from_tab" value="<?php echo $tab; ?>" />
    140154                    <input type="hidden" name="action" value="<?php echo $id ? 'save' : 'upload'; ?>" />
     
    147161                    <div class="submit">
    148162                        <input type="submit" value="<?php $id ? _e('Save') : _e('Upload'); ?> &raquo;" />
    149 <?php   if ( $id ) : ?>
    150                         <input type="submit" name="delete" class="delete" value="<?php _e('Delete'); ?>" />
    151 <?php   endif; ?>
    152163                    </div>
    153164                </td>
     
    353364    if ( 'inline' == @$_GET['style'] ) {
    354365        echo "<style type='text/css'>\n";
    355         echo "\tbody { height: 14em; overflow: hidden; }\n";
     366        echo "\tbody { height: 15em; overflow: hidden; }\n";
    356367        echo "\t#upload-content { overflow-y: auto; }\n";
    357368        echo "\t#upload-file { position: absolute; }\n";
  • trunk/wp-admin/upload-js.php

    r4349 r4355  
    3838                return;
    3939            var thumbEl = $('attachment-thumb-url-' + id);
    40             if ( thumbEl )
     40            this.currentImage.isImage = true;
     41            if ( thumbEl ) {
    4142                this.currentImage.thumb = ( 0 == id ? '' : thumbEl.value );
    42             else
     43                this.currentImage.thumbBase = ( 0 == id ? '' : $('attachment-thumb-url-base-' + id).value );
     44            } else {
    4345                this.currentImage.thumb = false;
     46                var isImageEl = $('attachment-is-image-' + id);
     47                if ( !isImageEl )
     48                    this.currentImage.isImage = false;
     49            }
    4450            this.currentImage.src = ( 0 == id ? '' : $('attachment-url-' + id).value );
     51            this.currentImage.srcBase = ( 0 == id ? '' : $('attachment-url-base-' + id).value );
    4552            this.currentImage.page = ( 0 == id ? '' : $('attachment-page-url-' + id).value );
    4653            this.currentImage.title = ( 0 == id ? '' : $('attachment-title-' + id).value );
     
    6673                params.ID = '';
    6774                params.action = '';
    68                 h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "'  title='Browse your files' class='back'>&laquo; Back</a>";
     75                h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "' title='Browse your files' class='back'>&laquo; Back</a>";
    6976            } else {
    7077                h += "<a href='#' onclick='theFileList.cancelView()'  title='Browse your files' class='back'>&laquo; Back</a>";
    7178            }
    7279            h += "<div id='file-title'>"
    73             if ( !this.currentImage.thumb )
    74                 h += "<h2><a href='" + this.currentImage.src + "' title='Direct link to file'>" + this.currentImage.title + "</a></h2>";
     80            if ( !this.currentImage.isImage )
     81                h += "<h2><a href='" + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>" + this.currentImage.title + "</a></h2>";
    7582            else
    7683                h += "<h2>" + this.currentImage.title + "</h2>";
     
    8087            h += '</div>'
    8188            h += "<div id='upload-file-view' class='alignleft'>";
    82             if ( this.currentImage.thumb )
    83                 h += "<a href='" + this.currentImage.src + "' title='Direct link to file'><img src='" + this.currentImage.thumb + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' /></a>";
    84             else
     89            if ( this.currentImage.isImage ) {
     90                h += "<a href='" + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>";
     91                h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
     92                h += "</a>";
     93            } else
    8594                h += '&nbsp;';
    8695            h += "</div>";
     
    120129            if ( this.postID )
    121130                action += '&amp;post_id=' + this.postID;
     131
    122132            h += "<form id='upload-file' method='post' action='" + action + "'>";
    123133            if ( this.ID ) {
     
    130140            }
    131141            h += "<div id='file-title'>"
    132             if ( !this.currentImage.thumb )
    133                 h += "<h2><a href='" + this.currentImage.src + "' title='Direct link to file'>" + this.currentImage.title + "</a></h2>";
     142            if ( !this.currentImage.isImage )
     143                h += "<h2><a href='" + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>" + this.currentImage.title + "</a></h2>";
    134144            else
    135145                h += "<h2>" + this.currentImage.title + "</h2>";
     
    139149            h += '</div>'
    140150            h += "<div id='upload-file-view' class='alignleft'>";
    141             if ( this.currentImage.thumb )
    142                 h += "<a href='" + this.currentImage.src + "' title='Direct link to file'><img src='" + this.currentImage.thumb + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' /></a>";
    143             else
     151            if ( this.currentImage.isImage ) {
     152                h += "<a href='" + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>";
     153                h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
     154                h += "</a>";
     155            } else
    144156                h += '&nbsp;';
    145157            h += "</div>";
    146158
    147159
    148             h += "<table><tr>"
    149             h += "<th scope='row'><label for='post_title'>Title:</label></th>";
     160            h += "<table><col /><col class='widefat' /><tr>"
     161            h += "<th scope='row'><label for='url'>URL</label></th>";
     162            h += "<td><input type='text' id='url' class='readonly' value='" + this.currentImage.src + "' readonly='readonly' /></td>";
     163            h += "</tr><tr>";
     164            h += "<th scope='row'><label for='post_title'>Title</label></th>";
    150165            h += "<td><input type='text' id='post_title' name='post_title' value='" + this.currentImage.title + "' /></td>";
    151166            h += "</tr><tr>";
    152             h += "<th scope='row'><label for='post_content'>Description:</label></th>";
     167            h += "<th scope='row'><label for='post_content'>Description</label></th>";
    153168            h += "<td><textarea name='post_content' id='post_content'>" + this.currentImage.description + "</textarea></td>";
    154             h += "</tr><tr id='buttons'><th><input type='button' name='delete' class='delete button' value='Delete' onclick='theFileList.deleteFile(" + id + ");' /></th><td>";
     169            h += "</tr><tr id='buttons' class='submit'><td colspan='2'><input type='button' id='delete' name='delete' class='delete alignleft' value='Delete File' onclick='theFileList.deleteFile(" + id + ");' />";
    155170            h += "<input type='hidden' name='from_tab' value='" + this.tab + "' />";
    156171            h += "<input type='hidden' name='action' id='action-value' value='save' />";
    157172            h += "<input type='hidden' name='ID' value='" + id + "' />";
    158173            h += "<input type='hidden' name='_wpnonce' value='" + this.nonce + "' />";
    159             h += "<div class='submit'><input type='submit' value='Save &raquo;' />";
    160             h += "</div></td></tr></table></form>";
     174            h += "<div class='submit'><input type='submit' value='Save &raquo;' /></div>";
     175            h += "</td></tr></table></form>";
    161176
    162177            new Insertion.Top('upload-content', h);
     
    203218            if ( displayEl )
    204219                display = displayEl.value;
     220            else if ( this.currentImage.isImage )
     221                display = 'full';
    205222
    206223            if ( 'none' != link )
    207                 h += "<a href='" + ( 'file' == link ? this.currentImage.src : this.currentImage.page ) + "' title='" + this.currentImage.title + "'>";
     224                h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment" ) ) + "' title='" + this.currentImage.title + "'>";
    208225            if ( display )
    209                 h += "<img src='" + ( 'thumb' == display ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' />";
     226                h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />";
    210227            else
    211228                h += this.currentImage.title;
     
    221238            else
    222239                win.edInsertContent(win.edCanvas, h);
    223             this.cancelView();
     240            if ( !this.ID )
     241                this.cancelView();
    224242            return false;
    225243        },
  • trunk/wp-admin/upload.css

    r4349 r4355  
    5858    top: 0;
    5959    left: 0;
    60     width: 45em;
     60    width: 95%;
    6161    height: 100%;
    6262    background: #f9fcfe;
    6363}
    64 #upload-file th {
     64
     65#uupload-file th {
    6566    width: 8em;
    6667}
     
    6869form#upload-file input, form#upload-file textarea, div#upload-content.upload table { width: 100%; }
    6970
    70 form#upload-file div.submit input { width: auto; }
     71form#upload-file .submit input { width: auto; }
    7172
    7273#upload-file-view { padding: 0 0 0 75px; }
     
    135136#upload-files a.file-link img { vertical-align: middle; }
    136137
    137 #the-attachment-links { float: right; }
    138 
    139138#the-attachment-links textarea {
    140139    font-size: 10px;
     
    174173    width: 300px;
    175174}
     175
     176input.readonly { background-color: #ddd; }
  • trunk/wp-admin/wp-admin.css

    r4352 r4355  
    207207    padding: 0px;
    208208    margin-bottom: 16px;
    209     height: 16em;
     209    height: 17em;
    210210    width: 100%;
    211211/*  overflow-y: hidden;*/
Note: See TracChangeset for help on using the changeset viewer.