Changeset 8113

Show
Ignore:
Timestamp:
06/17/08 19:36:29 (5 months ago)
Author:
ryan
Message:

Press This changes from noel. see #6813

Files:

Legend:

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

    r8093 r8113  
    112112font-size: 11px; 
    113113} 
    114 #newtag { padding: 3px; } 
     114#newtag { width: 60%; padding: 3px; } 
    115115 
    116116#wphead { 
     
    453453margin-bottom: 8px; 
    454454} 
     455 
     456#post_status { 
     457margin-left: 10px; 
     458margin-bottom: 1em; 
     459display: block; 
     460} 
  • trunk/wp-admin/press-this.php

    r8093 r8113  
    77function press_it() { 
    88    #define some basic variables 
    9     $quick['post_status'] = 'publish'
     9    $quick['post_status'] = $_REQUEST['post_status']
    1010    $quick['post_category'] = $_REQUEST['post_category']; 
    1111    $quick['tags_input'] = $_REQUEST['tags_input']; 
     
    4343        } 
    4444    # set the post_content 
    45     $quick['post_content'] = $content
     45    $quick['post_content'] = str_replace('<br />', "\n", preg_replace('/<\/?p>/','',$content))
    4646 
    4747    #error handling for $post 
     
    5757    return $post_ID; 
    5858} 
    59  
    60  
    61 function category_div() { ?> 
    62     <div id="categories"> 
    63         <div class="submitbox" id="submitpost"> 
    64             <div id="previewview"></div> 
    65             <div class="inside"> 
    66                 <h2><?php _e('Categories') ?></h2> 
    67                 <div id="categories-all"> 
    68                     <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 
    69                         <?php wp_category_checklist() ?> 
    70                     </ul> 
    71                 </div> 
    72                 <h2><?php _e('Tags') ?></h2> 
    73                 <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p> 
    74                 <div id="tagchecklist"></div> 
    75                  
    76             </div> 
    77             <p class="submit">          
    78             <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 
    79             <img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/> 
    80             </p> 
    81         </div>   
    82 <?php } 
    8359 
    8460# For submitted posts. 
     
    11187// Ajax Requests 
    11288$title = wp_specialchars(stripslashes($_GET['t'])); 
    113 $selection = trim(wp_specialchars(str_replace("\n", ' ',stripslashes($_GET['s'])))); 
    114 $url = $_GET['u']
     89$selection = trim(str_replace('\\n', "<br />", wp_specialchars(js_escape($_GET['s'])))); 
     90$url = clean_url($_GET['u'])
    11591$image = $_GET['i']; 
    11692if($_REQUEST['ajax'] == 'thickbox') { ?> 
     
    131107            image_selector(); 
    132108        }); 
    133  
    134109    </script> 
    135110    <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3> 
     
    155130 
    156131if($_REQUEST['ajax'] == 'photo_images') { 
    157     error_log('photo images'); 
    158132    function get_images_from_uri($uri) { 
    159133        if(preg_match('/\.(jpg|png|gif)/', $uri))  
    160134            return "'".$uri."'"; 
    161          
     135            
    162136        $content = wp_remote_fopen($uri); 
     137        if ( false === $content ) return ''; 
     138         
    163139        $host = parse_url($uri); 
    164          
    165         if ( false === $content ) return ''; 
    166140         
    167141        $pattern = '/<img ([^>]*)src=(\"|\')(.+?)(\2)([^>\/]*)\/*>/is'; 
    168142        preg_match_all($pattern, $content, $matches); 
    169         if ( empty($matches[1]) ) { error_log('empty'); return ''; }; 
     143         
     144        if ( empty($matches[1]) ) return ''; 
     145         
    170146        $sources = array(); 
    171  
    172147        foreach ($matches[3] as $src) { 
    173             error_log($src); 
    174             #if ( false !== strpos($src, '&') ) continue; 
    175                 if(strpos($src, 'http') === false) { 
    176                     if(strpos($src, '../') === false && strpos($src, './') === false) { 
    177                         $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 
    178                     } else { 
    179                         $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); 
    180                     } 
    181                 } 
    182                  
    183                 $sources[] = $src; 
     148            if(strpos($src, 'http') === false) 
     149                if(strpos($src, '../') === false && strpos($src, './') === false) 
     150                    $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 
     151                else 
     152                    $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); 
     153                                         
     154            $sources[] = $src; 
    184155        } 
    185156        return "'" . implode("','", $sources) . "'"; 
     
    227198                    if (img.width * img.height < 2500) skip = true; 
    228199                    aspect = img.width / img.height; 
    229                     if (aspect > 1) { // Image is wide 
    230                         scale = 75 / img.width; 
    231                     } else { // Image is tall or square 
    232                         scale = 75 / img.height; 
    233                     } 
     200                    scale = (aspect > 1) ? (75 / img.width) : (75 / img.height); 
     201                     
    234202                    if (scale < 1) { 
    235203                        w = parseInt(img.width * scale); 
     
    253221 
    254222if($_REQUEST['ajax'] == 'photo') { ?> 
    255      
    256223        <div class="photolist"></div> 
    257      
    258224        <small><?php _e('Click images to select:') ?></small> 
    259225        <div class="titlewrap"> 
     
    261227        </div> 
    262228<?php die; } 
    263  
    264229?> 
    265230<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    318283                tab_focus : ":next", 
    319284                plugins : "safari,inlinepopups", 
    320                 entities : "38,amp,60,lt,62,gt" 
     285                entities : "38,amp,60,lt,62,gt", 
     286                force_p_newlines : true 
    321287            }); 
    322288    <?php } ?> 
     
    350316    } 
    351317    function set_editor(text) { 
     318 
    352319        if(tinyMCE.activeEditor) tinyMCE.activeEditor.setContent(''); 
    353320        if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text); 
     
    370337                set_menu('text'); 
    371338                set_title('<?php _e('Text') ?>'); 
    372                 <?php if($selection) { ?> 
    373                 set_editor('<?php echo '<p><a href="'.$url.'">'.$selection.'</a> </p> '; ?>'); 
    374                 <?php } else { ?> 
    375                 set_editor('<?php echo '<p><a href="'.$url.'">'.$title.'</a> </p> '; ?>'); 
    376                 <?php } ?> 
     339 
    377340                return false; 
    378341            break; 
     
    500463                     
    501464                </div> 
    502                 <?php category_div(); ?> 
     465                <div id="categories"> 
     466                    <div class="submitbox" id="submitpost"> 
     467                    <div id="previewview"></div> 
     468                    <div class="inside"> 
     469                        <h2><?php _e('Categories') ?></h2> 
     470                        <div id="categories-all"> 
     471                            <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 
     472                                <?php wp_category_checklist() ?> 
     473                            </ul> 
     474                        </div> 
     475                        <h2><?php _e('Tags') ?></h2> 
     476                        <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p> 
     477                        <div id="tagchecklist"></div> 
     478                    </div> 
     479                    <label for="post_status" id="post_status"><input type="radio" name="post_status" value="publish" checked="checked" id="published" />Published <input type="radio" name="post_status" value="draft" id="unpubplished" /> Unpublished</label> 
     480                     
     481                    <p class="submit">          
     482                        <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 
     483                        <img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/> 
     484                    </p> 
     485                </div> 
     486                 
     487                 
    503488            </form>      
    504489