Make WordPress Core


Ignore:
Timestamp:
11/25/2008 01:16:00 AM (16 years ago)
Author:
azaozz
Message:

PressThis updates from Noel, see #7949

File:
1 edited

Legend:

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

    r9857 r9866  
    214214
    215215            $sources = array();
     216           
    216217            foreach ($matches[3] as $src) {
    217218                // if no http in url
     
    224225                $sources[] = clean_url($src);
    225226            }
     227           
    226228            return "'" . implode("','", $sources) . "'";
    227229        }
     
    258260                );
    259261                if(my_src.length == 0) {
    260    
    261262                    strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
    262263                }
    263264            }
    264265       
    265 
    266266        for (i = 0; i < my_src.length; i++) {
    267267            img = new Image();
     
    269269            img_attr = 'id="img' + i + '"';
    270270            skip = false;
     271           
     272            maybeappend = '<a href="?ajax=photo_thickbox&amp;i=' + encodeURI(img.src) + '&amp;u=<?php echo urlencode($url); ?>&amp;height=400&amp;width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
     273           
    271274            if (img.width && img.height) {
    272275                if (img.width >= 30 && img.height >= 30) {
     
    282285                    }
    283286                    img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
    284                     strtoappend += '<a href="?ajax=photo_thickbox&amp;i=' + encodeURI(img.src) + '&amp;u=<?php echo $url; ?>&amp;height=400&amp;width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
     287                    strtoappend += maybeappend;
    285288                }
     289            } else {
     290                strtoappend += maybeappend;
    286291            }
    287292        }
    288 
     293       
    289294        function pick(img, desc) {
    290295            if (img) {
     
    293298                jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
    294299                jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
    295                 insert_editor("\n\n" + '<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>');
     300                insert_editor( "\n\n" + '<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>');
    296301            }
    297302            return false;
     
    371376    jQuery('#publish').click( tag_save_on_publish );
    372377    jQuery('#save').click( tag_save_on_publish );
    373 
    374 
     378    function insert_plain_editor(text) {
     379        edCanvas = document.getElementById('content');
     380        edInsertContent(edCanvas, text);
     381    }
    375382    function set_editor(text) {
    376383        if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>';
     
    378385    }
    379386    function insert_editor(text) {
    380         if ( '' != text && tinyMCE.activeEditor ) tinyMCE.execCommand('mceInsertContent', false, '<p>' + tinymce.DOM.decode(text) + '</p>');
     387        if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
     388            tinyMCE.execCommand('mceInsertContent', false, '<p>' + tinymce.DOM.decode(text) + '</p>', {format : 'raw'});
     389        } else {
     390            insert_plain_editor(text);
     391        }
    381392    }
    382393    function append_editor(text) {
    383         if ( '' != text && tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
    384         tinyMCE.execCommand('mceCleanup');
     394        if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
     395            tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
     396            tinyMCE.execCommand('mceCleanup');
     397        } else {
     398            insert_plain_editor(text);
     399        }
    385400    }
    386401
    387402    function show(tab_name) {
    388        
     403        jQuery('#extra_fields').html('');
     404        jQuery('#extra_fields').show();
    389405        switch(tab_name) {
    390406            case 'video' :
    391                 jQuery('#extra_fields').html('');
    392                 jQuery('#extra_fields').show();
    393407                jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo attribute_escape($selection); ?>'}, function() {
    394408                    <?php
     
    410424                    ?>
    411425                    jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
    412 
    413426                });
    414427                return false;
    415428                break;
    416429            case 'photo' :
    417                     jQuery('#extra_fields').html('');
    418                     jQuery('#extra_fields').show();
    419                     jQuery('#extra_fields').before('<p id="waiting"><img src="images/loading.gif" alt="" /> <?php echo js_escape( __( 'Loading...' ) ); ?></p>');
    420                     jQuery.ajax({
    421                         type: "GET",
    422                         cache : false,
    423                         url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
    424                         data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
    425                         dataType : "script",
    426                         success : function() {
    427                             jQuery('#waiting').remove();
    428                         }
    429                     });
    430 
     430                jQuery('#extra_fields').before('<p id="waiting"><img src="images/loading.gif" alt="" /> <?php echo js_escape( __( 'Loading...' ) ); ?></p>');
     431                jQuery.ajax({
     432                    type: "GET",
     433                    cache : false,
     434                    url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
     435                    data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
     436                    dataType : "script",
     437                    success : function() {
     438                        jQuery('#waiting').remove();
     439                    }
     440                });
    431441                return false;
    432442                break;
     
    436446        //resize screen
    437447        window.resizeTo(720,570);
    438        
     448        // set button actions
    439449        jQuery('#photo_button').click(function() { show('photo'); return false; });
    440450        jQuery('#video_button').click(function() { show('video'); return false; });
    441         jQuery('#visual_mode_button').click(function() {
    442            
    443         });
    444         // Set default tabs
     451        // auto select
    445452        <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
    446453            show('video');
     
    451458        <?php } ?>
    452459       
    453         jQuery('#submit').click(function() { jQuery('saving').css('display', 'block'); });
     460        jQuery('#publish, #save').click(function() { alert('test'); jQuery('#saving').css('display', 'inline'); });
    454461    });
    455462</script>
    456463</head>
    457464<body class="press-this">
    458 <div id="wphead">
    459 </div>
    460 
     465<div id="wphead"></div>
    461466<form action="press-this.php?action=post" method="post">
    462    
    463    
    464     <div id="poststuff" class="metabox-holder">
     467<div id="poststuff" class="metabox-holder">
    465468    <div id="side-info-column">
    466469        <div class="sleeve">
     
    469472            <?php wp_nonce_field('press-this') ?>
    470473            <input type="hidden" name="post_type" id="post_type" value="text"/>
    471         <input type="hidden" name="autosave" id="autosave" />
     474            <input type="hidden" name="autosave" id="autosave" />
     475           
    472476            <!-- This div holds the photo metadata -->
    473477            <div class="photolist"></div>
    474478       
    475479            <div id="categorydiv" class="stuffbox">
    476             <h2><?php _e('Categories') ?></h2>
     480                <h2><?php _e('Categories') ?></h2>
    477481                <div class="inside">
    478482           
    479             <div id="categories-all" class="ui-tabs-panel">
    480                 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
    481                     <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
    482                 </ul>
    483                
     483                    <div id="categories-all" class="ui-tabs-panel">
     484                        <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
     485                            <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
     486                        </ul>
     487                    </div>
     488
     489                    <div id="category-adder" class="wp-hidden-children">
     490                        <a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a>
     491                        <p id="category-add" class="wp-hidden-child">
     492                            <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
     493                            <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
     494                            <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
     495                            <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
     496                            <span id="category-ajax-response"></span>
     497                        </p>
     498                    </div>
     499                </div>
    484500            </div>
    485 
    486             <div id="category-adder" class="wp-hidden-children">
    487                 <a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a>
    488                 <p id="category-add" class="wp-hidden-child">
    489                     <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
    490                     <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
    491                     <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
    492                     <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
    493                     <span id="category-ajax-response"></span>
    494                 </p>
    495             </div>
    496             </div>
    497             </div>
    498501           
    499502            <div class="stuffbox">
    500             <h2><?php _e('Tags') ?></h2>
     503                <h2><?php _e('Tags') ?></h2>
    501504                <div class="inside">
    502505           
    503             <div 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 ); ?>" /></div>
    504            
    505             <div id="tagchecklist"></div>
     506                    <div id="jaxtag">
     507                        <label class="hidden" for="newtag"><?php _e('Tags'); ?></label>
     508                        <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 ); ?>" />
     509                    </div>
     510                    <div id="tagchecklist"></div>
    506511                </div>
    507512            </div>
     
    509514                <h2><?php _e('Publish') ?></h2>
    510515                <div class="inside">
    511                 <p>
    512                     <input class="button" type="submit" name="draft" value="<?php _e('Save Draft') ?>" id="save" />
    513                     <input class="button-primary" type="submit" name="publish" value="<?php _e('Publish') ?>" id="publish" />
    514                     <img src="images/loading-publish.gif" alt="" id="saving" style="display:none;"/>
    515                 </p>
     516                    <p>
     517                        <input class="button" type="submit" name="draft" value="<?php _e('Save Draft') ?>" id="save" />
     518                        <input class="button-primary" type="submit" name="publish" value="<?php _e('Publish') ?>" id="publish" />
     519                        <img src="images/loading-publish.gif" alt="" id="saving" style="display:none;"/>
     520                    </p>
    516521                </div>
    517522            </div>
     
    519524    </div>
    520525   
    521         <div class="posting">
    522             <?php
    523             if ( isset($posted) && intval($posted) ) {
    524                 $post_ID = intval($posted);
    525             ?>
    526             <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="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div>
    527             <?php
    528             }
    529             ?>
    530            
    531            
    532                 <div id="titlediv">
    533                     <div class="titlewrap">
    534                         <input name="title" id="title" class="text" value="<?php echo attribute_escape($title);?>"/>
    535                     </div>
    536                 </div>
    537            
    538             <div id="extra_fields" style="display: none"></div>
    539            
    540             <div class="postdivrich">
    541                 <ul id="actions">
    542                     <li id="photo_button">
    543                        
    544                         Add: <a title="<?php _e('Insert an Image'); ?>" href="#">
     526    <div class="posting">
     527        <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
     528        <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="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div>
     529        <?php } ?>
     530
     531        <div id="titlediv">
     532            <div class="titlewrap">
     533                <input name="title" id="title" class="text" value="<?php echo attribute_escape($title);?>"/>
     534            </div>
     535        </div>
     536           
     537        <div id="extra_fields" style="display: none"></div>
     538           
     539        <div class="postdivrich">
     540            <ul id="actions">
     541                <li id="photo_button"> 
     542                    Add: <a title="<?php _e('Insert an Image'); ?>" href="#">
    545543<img alt="<?php _e('Insert an Image'); ?>" src="images/media-button-image.gif"/></a>
    546                     </li>
    547                     <li id="video_button">
    548                         <a title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="images/media-button-video.gif"/></a>
    549                         </li>
    550                     <li id="switcher">
    551                         <?php wp_print_scripts( 'quicktags' ); ?>
    552        
    553             <?php add_filter('the_editor_content', 'wp_richedit_pre'); ?>
    554             <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
    555             <a id="edButtonPreview" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
    556             <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
    557         </li>
    558                 </ul>
     544                </li>
     545                <li id="video_button">
     546                    <a title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="images/media-button-video.gif"/></a>
     547                </li>
     548                <li id="switcher">
     549                    <?php wp_print_scripts( 'quicktags' ); ?>
     550                    <?php add_filter('the_editor_content', 'wp_richedit_pre'); ?>
     551                    <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
     552                    <a id="edButtonPreview" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
     553                    <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
     554                </li>
     555            </ul>
    559556            <div id="quicktags"></div>
    560    
    561                
    562            
    563                 <div class="editor-container">
    564                     <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15">
     557            <div class="editor-container">
     558                <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15">
    565559                    <?php if ($selection) echo wp_richedit_pre(htmlspecialchars_decode($selection)); ?>
    566560                    <?php if ($url) { echo '<p>'; if($selection) _e('via '); echo "<a href='$url'>$title</a>."; echo '</p>'; } ?>
    567                     </textarea>
    568                 </div>
    569            
    570             </div>
     561                </textarea>
     562            </div>         
    571563        </div>
    572564    </div>
     565</div>
    573566</form>
    574567</body>
Note: See TracChangeset for help on using the changeset viewer.