Make WordPress Core

Changeset 8128


Ignore:
Timestamp:
06/19/2008 05:03:23 PM (17 years ago)
Author:
ryan
Message:

Press This: Fixes for unicode/ascii/apostrophe problems. Upgrades to the Photo tab. Props noel. see #6813

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/press-this.css

    r8113 r8128  
    450450    padding-bottom: 2px;
    451451}
     452
     453#photo_directions {
     454margin-top: .25em;
     455display: block;
     456position: relative;
     457}
     458#photo_directions span {
     459display: block;
     460position: absolute;
     461top: 0;
     462right: 3px;
     463}
    452464#photo_saving {
    453465margin-bottom: 8px;
     
    459471display: block;
    460472}
     473
     474#footer {
     475    height: 65px;
     476    display: block;
     477    width: 640px;
     478    padding: 10px 0 0 60px;
     479    margin: 0;
     480    position: absolute;
     481    bottom: 0;
     482    font-size: 12px;
     483}
     484
     485#footer p {
     486    margin: 0;
     487    padding: 7px 0;
     488}
     489
     490#footer p a {
     491    text-decoration: none;
     492}
     493
     494#footer p a:hover {
     495    text-decoration: underline;
  • trunk/wp-admin/press-this.php

    r8113 r8128  
    8080    <body class="press-this">
    8181        <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&amp;post=<?php echo $post_ID; ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();">Close Window</a></p></div>
     82       
     83        <div id="footer">
     84        <p><?php
     85        do_action('in_admin_footer', '');
     86        $upgrade = apply_filters( 'update_footer', '' );
     87        echo __('Thank you for creating with <a href="http://wordpress.org/">WordPress</a>');
     88        ?></p>
     89        </div>
     90        <?php do_action('admin_footer', ''); ?>
     91       
    8292    </body>
    8393    </html>
     
    8595}
    8696
     97
     98function aposfix($text) {
     99    $translation_table[chr(34)] = '&quot;';
     100    $translation_table[chr(38)] = '&';
     101    $translation_table[chr(39)] = '&apos;';
     102    return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($text, $translation_table));   
     103}
     104
    87105// Ajax Requests
    88106$title = wp_specialchars(stripslashes($_GET['t']));
    89 $selection = trim(str_replace('\\n', "<br />", wp_specialchars(js_escape($_GET['s']))));
     107
     108$selection = str_replace("\n", "<br />", aposfix( stripslashes($_GET['s']) ) );
    90109$url = clean_url($_GET['u']);
    91110$image = $_GET['i'];
     111
    92112if($_REQUEST['ajax'] == 'thickbox') { ?>
    93     <script type="text/javascript" charset="utf-8">
    94         jQuery('.cancel').click(function() {
    95             tb_remove();
    96         });
    97        
    98         function image_selector() {
    99             desc = jQuery('#this_photo_description').val();
    100             src = jQuery('#this_photo').val();
    101             pick(src, desc);
    102             tb_remove();
    103             return false;
    104         }
    105        
    106         jQuery('.select').click(function() {
    107             image_selector();
    108         });
    109     </script>
    110113    <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3>
    111114    <div class="titlewrap">
     
    114117       
    115118    <p><input type="hidden" name="this_photo" value="<?php echo $image; ?>" id="this_photo" />
    116         <a href="#" class="select" rel="<?php echo $image; ?>"><img src="<?php echo $image; ?>" width="475" alt="Click to insert." title="Click to insert." /></a></p>
    117    
    118     <p id="options"><a href="#" class="select" rel="<?php echo $image; ?>">Insert Image</a> | <a href="#" class="cancel">Cancel</a></p>
     119        <a href="#" class="select"><img src="<?php echo $image; ?>" width="475" alt="Click to insert." title="Click to insert." /></a></p>
     120   
     121    <p id="options"><a href="#" class="select">Insert Image</a> | <a href="#" class="cancel">Cancel</a></p>
    119122<?php die;
    120123}
    121124
     125if($_REQUEST['ajax'] == 'thickbox_url') { ?>
     126    <h3 id="title"><label for="post_title"><?php _e('URL') ?></label></h3>
     127    <div class="titlewrap">
     128        <input id="this_photo" name="this_photo" class="text" onkeypress="if(event.keyCode==13) image_selector();" />
     129    </div>
     130   
     131   
     132    <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3>
     133    <div class="titlewrap">
     134        <input id="this_photo_description" name="photo_description" class="text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/>
     135    </div>
     136   
     137    <p id="options"><a href="#" class="select">Insert Image</a> | <a href="#" class="cancel">Cancel</a></p>
     138<?php die;
     139}
    122140
    123141if($_REQUEST['ajax'] == 'video') { ?>
     
    131149if($_REQUEST['ajax'] == 'photo_images') {
    132150    function get_images_from_uri($uri) {
    133         if(preg_match('/\.(jpg|png|gif)/', $uri))
     151        if(preg_match('/\.(jpg|png|gif)/', $uri) && !strpos($uri,'blogger.com'))
    134152            return "'".$uri."'";
    135            
     153
    136154        $content = wp_remote_fopen($uri);
    137155        if ( false === $content ) return '';
     
    164182
    165183if($_REQUEST['ajax'] == 'photo_js') { ?>
    166    
    167             var last = null
     184
     185            tb_init('a.thickbox, area.thickbox, input.thickbox'); //pass where to apply thickbox
     186           
     187            function image_selector() {
     188                desc = jQuery('#this_photo_description').val();
     189                src = jQuery('#this_photo').val();
     190                pick(src, desc);
     191                tb_remove();
     192                return false;
     193            }
     194           
     195            jQuery(document).ready(function() {
     196                jQuery('#this_photo').focus();
     197
     198                jQuery('.cancel').click(function() {
     199                    tb_remove();
     200                });
     201               
     202                jQuery('.select').click(function() {
     203                    image_selector();
     204                });
     205               
     206                jQuery('#photo_add_url').attr('href', '?ajax=thickbox_url&height=200&width=500');
     207               
     208            });
     209           
    168210           
    169211            function pick(img, desc) {
     
    174216                    jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
    175217                    append_editor('<img src="' + img +'" alt="' + desc + '" />'); }
     218                    tinyMCE.activeEditor.resizeToContent();
    176219                return false;
    177220            }
    178221
     222            var last = null
    179223            var my_src, img, img_tag, aspect, w, h, skip, i, strtoappend = "";
    180            
    181224            var my_src = eval(
    182225            jQuery.ajax({
     
    190233
    191234            for (i = 0; i < my_src.length; i++) {
    192                 img = new Image();
    193                 img.src = my_src[i];
    194                 img_attr = 'id="img' + i;
    195                 skip = false;
     235                img = new Image(); img.src = my_src[i]; img_attr = 'id="img' + i; skip = false;
    196236
    197237                if (img.width && img.height) {
    198                     if (img.width * img.height < 2500) skip = true;
     238                    if (img.width * img.height < 2500)
     239                        skip = true;
    199240                    aspect = img.width / img.height;
    200241                    scale = (aspect > 1) ? (75 / img.width) : (75 / img.height);
     
    213254
    214255            }
    215 
    216256            jQuery('#img_container').html(strtoappend);
    217 
    218             tb_init('a.thickbox, area.thickbox, input.thickbox'); //pass where to apply thickbox
    219257
    220258<?php die; }
     
    222260if($_REQUEST['ajax'] == 'photo') { ?>
    223261        <div class="photolist"></div>
    224         <small><?php _e('Click images to select:') ?></small>
     262
     263        <small id="photo_directions"><?php _e('Click images to select:') ?> <span><a href="#" id="photo_add_url" class="thickbox"><?php _e('Add from URL') ?> +</a></span></small>
     264
    225265        <div class="titlewrap">
    226266            <div id="img_container"></div>
     
    324364    }
    325365    function set_title(title) { jQuery("#content_type").text(title); }
    326     function reset_height() {
    327         tinyMCE.height = '170px';
    328     }
     366
    329367    function show(tab_name) {
    330368        jQuery('body').removeClass('video_split');
     
    332370        switch(tab_name) {
    333371            case 'text' :
    334                 reset_height();
    335                 jQuery('.editor-container').show();
    336                 jQuery('#content_type').show();
    337372                set_menu('text');
    338                 set_title('<?php _e('Text') ?>');
     373                set_title('<?php _e('Post') ?>');
    339374
    340375                return false;
    341376            break;
    342377            case 'quote' :
    343                 reset_height();
    344                 jQuery('.editor-container').show();
    345                 jQuery('#content_type').show();
    346378                set_menu('quote');
    347379                set_title('<?php _e('Quote') ?>');
    348                 set_editor("<blockquote><p><?php echo $selection; ?> </p><p><cite><a href='<?php echo $url; ?>'><?php echo $title; ?></a></cite> </p></blockquote>");
    349 
     380                set_editor("<blockquote><p><?php echo $selection; ?> </p><p><cite><a href='<?php echo $url; ?>'><?php echo $title; ?> </a> </cite> </p></blockquote>");
    350381                return false;
    351382            break;
    352383            case 'video' :
    353                 reset_height();
    354                 jQuery('.editor-container').show();
    355                 jQuery('#content_type').show();
     384
    356385                set_menu('video');
    357386                set_title('<?php _e('Caption') ?>');
     
    359388                jQuery('#extra_fields').show();
    360389                jQuery('body').addClass('video_split');
    361            
    362                
    363390                jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo attribute_escape($selection); ?>'}, function() {
    364391                   
     
    378405                    } ?>
    379406                    jQuery('#embed_code').prepend('<?php echo htmlentities($content); ?>');
     407                   
    380408                    set_editor("<?php echo $title; ?>");
    381                    
    382409                });
    383 
    384410               
    385411                return false;
     
    387413           
    388414            case 'photo' :
    389                 reset_height();
    390415                set_menu('photo');
    391416                set_title('Post');
Note: See TracChangeset for help on using the changeset viewer.