PressThis updates from Noel, see #7949

git-svn-id: http://svn.automattic.com/wordpress/trunk@9866 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-11-25 01:16:00 +00:00
parent 141eb9777e
commit 9c3332c2d2
2 changed files with 105 additions and 112 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -213,6 +213,7 @@ switch ($_REQUEST['ajax']) {
if ( empty($matches[0]) ) return ''; if ( empty($matches[0]) ) return '';
$sources = array(); $sources = array();
foreach ($matches[3] as $src) { foreach ($matches[3] as $src) {
// if no http in url // if no http in url
if(strpos($src, 'http') === false) if(strpos($src, 'http') === false)
@ -223,6 +224,7 @@ switch ($_REQUEST['ajax']) {
$src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src); $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
$sources[] = clean_url($src); $sources[] = clean_url($src);
} }
return "'" . implode("','", $sources) . "'"; return "'" . implode("','", $sources) . "'";
} }
@ -257,17 +259,18 @@ switch ($_REQUEST['ajax']) {
}).responseText }).responseText
); );
if(my_src.length == 0) { if(my_src.length == 0) {
strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>'; strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
} }
} }
for (i = 0; i < my_src.length; i++) { for (i = 0; i < my_src.length; i++) {
img = new Image(); img = new Image();
img.src = my_src[i]; img.src = my_src[i];
img_attr = 'id="img' + i + '"'; img_attr = 'id="img' + i + '"';
skip = false; skip = false;
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>';
if (img.width && img.height) { if (img.width && img.height) {
if (img.width >= 30 && img.height >= 30) { if (img.width >= 30 && img.height >= 30) {
aspect = img.width / img.height; aspect = img.width / img.height;
@ -281,8 +284,10 @@ switch ($_REQUEST['ajax']) {
h = parseInt(img.height * scale); h = parseInt(img.height * scale);
} }
img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"'; img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
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>'; strtoappend += maybeappend;
} }
} else {
strtoappend += maybeappend;
} }
} }
@ -292,7 +297,7 @@ switch ($_REQUEST['ajax']) {
if(length == 0) length = 1; if(length == 0) length = 1;
jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>'); jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>'); jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
insert_editor("\n\n" + '<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'); insert_editor( "\n\n" + '<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>');
} }
return false; return false;
} }
@ -370,26 +375,35 @@ die;
// auto-save tags on post save/publish // auto-save tags on post save/publish
jQuery('#publish').click( tag_save_on_publish ); jQuery('#publish').click( tag_save_on_publish );
jQuery('#save').click( tag_save_on_publish ); jQuery('#save').click( tag_save_on_publish );
function insert_plain_editor(text) {
edCanvas = document.getElementById('content');
edInsertContent(edCanvas, text);
}
function set_editor(text) { function set_editor(text) {
if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>'; if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>';
if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text); if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text);
} }
function insert_editor(text) { function insert_editor(text) {
if ( '' != text && tinyMCE.activeEditor ) tinyMCE.execCommand('mceInsertContent', false, '<p>' + tinymce.DOM.decode(text) + '</p>'); if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
tinyMCE.execCommand('mceInsertContent', false, '<p>' + tinymce.DOM.decode(text) + '</p>', {format : 'raw'});
} else {
insert_plain_editor(text);
}
} }
function append_editor(text) { function append_editor(text) {
if ( '' != text && tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>'); if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
tinyMCE.execCommand('mceCleanup'); tinyMCE.execCommand('mceCleanup');
} else {
insert_plain_editor(text);
}
} }
function show(tab_name) { function show(tab_name) {
switch(tab_name) {
case 'video' :
jQuery('#extra_fields').html(''); jQuery('#extra_fields').html('');
jQuery('#extra_fields').show(); jQuery('#extra_fields').show();
switch(tab_name) {
case 'video' :
jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo attribute_escape($selection); ?>'}, function() { jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo attribute_escape($selection); ?>'}, function() {
<?php <?php
$content = ''; $content = '';
@ -409,13 +423,10 @@ die;
} }
?> ?>
jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>'); jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
}); });
return false; return false;
break; break;
case 'photo' : case 'photo' :
jQuery('#extra_fields').html('');
jQuery('#extra_fields').show();
jQuery('#extra_fields').before('<p id="waiting"><img src="images/loading.gif" alt="" /> <?php echo js_escape( __( 'Loading...' ) ); ?></p>'); jQuery('#extra_fields').before('<p id="waiting"><img src="images/loading.gif" alt="" /> <?php echo js_escape( __( 'Loading...' ) ); ?></p>');
jQuery.ajax({ jQuery.ajax({
type: "GET", type: "GET",
@ -427,7 +438,6 @@ die;
jQuery('#waiting').remove(); jQuery('#waiting').remove();
} }
}); });
return false; return false;
break; break;
} }
@ -435,13 +445,10 @@ die;
jQuery(document).ready(function() { jQuery(document).ready(function() {
//resize screen //resize screen
window.resizeTo(720,570); window.resizeTo(720,570);
// set button actions
jQuery('#photo_button').click(function() { show('photo'); return false; }); jQuery('#photo_button').click(function() { show('photo'); return false; });
jQuery('#video_button').click(function() { show('video'); return false; }); jQuery('#video_button').click(function() { show('video'); return false; });
jQuery('#visual_mode_button').click(function() { // auto select
});
// Set default tabs
<?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?> <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
show('video'); show('video');
<?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?> <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
@ -450,18 +457,14 @@ die;
show('photo'); show('photo');
<?php } ?> <?php } ?>
jQuery('#submit').click(function() { jQuery('saving').css('display', 'block'); }); jQuery('#publish, #save').click(function() { alert('test'); jQuery('#saving').css('display', 'inline'); });
}); });
</script> </script>
</head> </head>
<body class="press-this"> <body class="press-this">
<div id="wphead"> <div id="wphead"></div>
</div>
<form action="press-this.php?action=post" method="post"> <form action="press-this.php?action=post" method="post">
<div id="poststuff" class="metabox-holder">
<div id="poststuff" class="metabox-holder">
<div id="side-info-column"> <div id="side-info-column">
<div class="sleeve"> <div class="sleeve">
<h1 id="viewsite"><a class="button" href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> &rsaquo; <?php _e('Press This') ?></a></span></h1> <h1 id="viewsite"><a class="button" href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> &rsaquo; <?php _e('Press This') ?></a></span></h1>
@ -469,6 +472,7 @@ die;
<?php wp_nonce_field('press-this') ?> <?php wp_nonce_field('press-this') ?>
<input type="hidden" name="post_type" id="post_type" value="text"/> <input type="hidden" name="post_type" id="post_type" value="text"/>
<input type="hidden" name="autosave" id="autosave" /> <input type="hidden" name="autosave" id="autosave" />
<!-- This div holds the photo metadata --> <!-- This div holds the photo metadata -->
<div class="photolist"></div> <div class="photolist"></div>
@ -480,7 +484,6 @@ die;
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
<?php wp_category_checklist($post->ID, false, false, $popular_ids) ?> <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
</ul> </ul>
</div> </div>
<div id="category-adder" class="wp-hidden-children"> <div id="category-adder" class="wp-hidden-children">
@ -500,8 +503,10 @@ die;
<h2><?php _e('Tags') ?></h2> <h2><?php _e('Tags') ?></h2>
<div class="inside"> <div class="inside">
<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> <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>
<div id="tagchecklist"></div> <div id="tagchecklist"></div>
</div> </div>
</div> </div>
@ -519,15 +524,9 @@ die;
</div> </div>
<div class="posting"> <div class="posting">
<?php <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
if ( isset($posted) && intval($posted) ) {
$post_ID = intval($posted);
?>
<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> <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>
<?php <?php } ?>
}
?>
<div id="titlediv"> <div id="titlediv">
<div class="titlewrap"> <div class="titlewrap">
@ -540,7 +539,6 @@ die;
<div class="postdivrich"> <div class="postdivrich">
<ul id="actions"> <ul id="actions">
<li id="photo_button"> <li id="photo_button">
Add: <a title="<?php _e('Insert an Image'); ?>" href="#"> Add: <a title="<?php _e('Insert an Image'); ?>" href="#">
<img alt="<?php _e('Insert an Image'); ?>" src="images/media-button-image.gif"/></a> <img alt="<?php _e('Insert an Image'); ?>" src="images/media-button-image.gif"/></a>
</li> </li>
@ -549,7 +547,6 @@ die;
</li> </li>
<li id="switcher"> <li id="switcher">
<?php wp_print_scripts( 'quicktags' ); ?> <?php wp_print_scripts( 'quicktags' ); ?>
<?php add_filter('the_editor_content', 'wp_richedit_pre'); ?> <?php add_filter('the_editor_content', 'wp_richedit_pre'); ?>
<a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a> <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
<a id="edButtonPreview" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a> <a id="edButtonPreview" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
@ -557,19 +554,15 @@ die;
</li> </li>
</ul> </ul>
<div id="quicktags"></div> <div id="quicktags"></div>
<div class="editor-container"> <div class="editor-container">
<textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15"> <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15">
<?php if ($selection) echo wp_richedit_pre(htmlspecialchars_decode($selection)); ?> <?php if ($selection) echo wp_richedit_pre(htmlspecialchars_decode($selection)); ?>
<?php if ($url) { echo '<p>'; if($selection) _e('via '); echo "<a href='$url'>$title</a>."; echo '</p>'; } ?> <?php if ($url) { echo '<p>'; if($selection) _e('via '); echo "<a href='$url'>$title</a>."; echo '</p>'; } ?>
</textarea> </textarea>
</div> </div>
</div>
</div> </div>
</div> </div>
</div>
</form> </form>
</body> </body>
</html> </html>