]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/press-this.php
Wordpress 2.7.1
[autoinstalls/wordpress.git] / wp-admin / press-this.php
1 <?php
2 /**
3  * Press This Display and Handler.
4  *
5  * @package WordPress
6  * @subpackage Press_This
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_once('admin.php');
11
12 if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin&#8217; uh?' ) );
13
14 /**
15  * Replace forward slash with backslash and slash.
16  *
17  * @package WordPress
18  * @subpackage Press_This
19  * @since 2.6.0
20  *
21  * @param string $string
22  * @return string
23  */
24 function preg_quote2($string) {
25         return str_replace('/', '\/', preg_quote($string));
26 }
27
28 /**
29  * Convert characters.
30  *
31  * @package WordPress
32  * @subpackage Press_This
33  * @since 2.6.0
34  *
35  * @param string $text
36  * @return string
37  */
38 function aposfix($text) {
39         $translation_table[chr(34)] = '&quot;';
40         $translation_table[chr(38)] = '&';
41         $translation_table[chr(39)] = '&apos;';
42         return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($text, $translation_table));
43 }
44
45 /**
46  * Press It form handler.
47  *
48  * @package WordPress
49  * @subpackage Press_This
50  * @since 2.6.0
51  *
52  * @return int Post ID
53  */
54 function press_it() {
55         // define some basic variables
56         $quick['post_status'] = 'draft'; // set as draft first
57         $quick['post_category'] = $_REQUEST['post_category'];
58         $quick['tags_input'] = $_REQUEST['tags_input'];
59         $quick['post_title'] = $_REQUEST['title'];
60         $quick['post_content'] = '';
61
62         // insert the post with nothing in it, to get an ID
63         $post_ID = wp_insert_post($quick, true);
64         $content = $_REQUEST['content'];
65
66         if($_REQUEST['photo_src'])
67                 foreach( (array) $_REQUEST['photo_src'] as $key => $image)
68                         // see if files exist in content - we don't want to upload non-used selected files.
69                         if( strpos($_REQUEST['content'], $image) !== false ) {
70                                 $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]);
71
72                                 // Replace the POSTED content <img> with correct uploaded ones.
73                                 // escape quote for matching
74                                 $quoted = preg_quote2($image);
75                                 if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content);
76                         }
77
78         // set the post_content and status
79         $quick['post_status'] = isset($_REQUEST['publish']) ? 'publish' : 'draft';
80         $quick['post_content'] = $content;
81         // error handling for $post
82         if ( is_wp_error($post_ID)) {
83                 wp_die($id);
84                 wp_delete_post($post_ID);
85         // error handling for media_sideload
86         } elseif ( is_wp_error($upload)) {
87                 wp_die($upload);
88                 wp_delete_post($post_ID);
89         } else {
90                 $quick['ID'] = $post_ID;
91                 wp_update_post($quick);
92         }
93         return $post_ID;
94 }
95
96 // For submitted posts.
97 if ( 'post' == $_REQUEST['action'] ) {
98         check_admin_referer('press-this');
99         $post_ID = press_it();
100         $posted =  $post_ID;
101 }
102
103 // Set Variables
104 $title = wp_specialchars(aposfix(stripslashes($_GET['t'])));
105 $selection = trim( aposfix( stripslashes($_GET['s']) ) );
106 if ( ! empty($selection) ) {
107         $selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
108         $selection = '<p>'.str_replace('<p></p>', '', $selection).'</p>';
109 }
110 $url = clean_url($_GET['u']);
111 $image = $_GET['i'];
112
113 if($_REQUEST['ajax']) {
114 switch ($_REQUEST['ajax']) {
115         case 'video': ?>
116                 <script type="text/javascript" charset="utf-8">
117                         jQuery('.select').click(function() {
118                                 append_editor(jQuery('#embed-code').val());
119                                 jQuery('#extra_fields').hide();
120                                 jQuery('#extra_fields').html('');
121                         });
122                         jQuery('.close').click(function() {
123                                 jQuery('#extra_fields').hide();
124                                 jQuery('#extra_fields').html('');
125                         });
126                 </script>
127                 <div class="postbox">
128                 <h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
129                 <div class="inside">
130                         <textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo format_to_edit($selection, true); ?></textarea>
131                         <p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p>
132                 </div>
133                 </div>
134                 <?php break;
135
136         case 'photo_thickbox': ?>
137                 <script type="text/javascript" charset="utf-8">
138                         jQuery('.cancel').click(function() {
139                                 tb_remove();
140                         });
141                         jQuery('.select').click(function() {
142                                 image_selector();
143                         });
144                 </script>
145                 <h3 class="tb"><label for="this_photo_description"><?php _e('Description') ?></label></h3>
146                 <div class="titlediv">
147                 <div class="titlewrap">
148                         <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/>
149                 </div>
150                 </div>
151
152                 <p class="centered"><input type="hidden" name="this_photo" value="<?php echo attribute_escape($image); ?>" id="this_photo" />
153                         <a href="#" class="select"><img src="<?php echo clean_url($image); ?>" alt="<?php echo attribute_escape(__('Click to insert.')); ?>" title="<?php echo attribute_escape(__('Click to insert.')); ?>" /></a></p>
154
155                 <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
156
157
158                 <?php break;
159
160         case 'photo_thickbox_url': ?>
161                 <script type="text/javascript" charset="utf-8">
162                         jQuery('.cancel').click(function() {
163                                 tb_remove();
164                         });
165
166                         jQuery('.select').click(function() {
167                                 image_selector();
168                         });
169                 </script>
170                 <h3 class="tb"><label for="this_photo"><?php _e('URL') ?></label></h3>
171                 <div class="titlediv">
172                         <div class="titlewrap">
173                         <input id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" />
174                         </div>
175                 </div>
176
177
178                 <h3 class="tb"><label for="photo_description"><?php _e('Description') ?></label></h3>
179                 <div id="titlediv">
180                         <div class="titlewrap">
181                         <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/>
182                         </div>
183                 </div>
184
185                 <p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p>
186                 <?php break;
187         case 'photo_images':
188                 /**
189                  * Retrieve all image URLs from given URI.
190                  *
191                  * @package WordPress
192                  * @subpackage Press_This
193                  * @since 2.6.0
194                  *
195                  * @param string $uri
196                  * @return string
197                  */
198                 function get_images_from_uri($uri) {
199                         if( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
200                                 return "'".$uri."'";
201                         $content = wp_remote_fopen($uri);
202                         if ( false === $content )
203                                 return '';
204                         $host = parse_url($uri);
205                         $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))[^<>\'\"]*(\2)([^>\/]*)\/*>/is';
206                         preg_match_all($pattern, $content, $matches);
207                         if ( empty($matches[0]) )
208                                 return '';
209                         $sources = array();
210                         foreach ($matches[3] as $src) {
211                                 // if no http in url
212                                 if(strpos($src, 'http') === false)
213                                         // if it doesn't have a relative uri
214                                         if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
215                                                 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
216                                         else
217                                                 $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
218                                 $sources[] = clean_url($src);
219                         }
220                         return "'" . implode("','", $sources) . "'";
221                 }
222                 $url = urldecode($url);
223                 $url = str_replace(' ', '%20', $url);
224                 echo 'new Array('.get_images_from_uri($url).')';
225
226                 break;
227
228         case 'photo_js': ?>
229                 // gather images and load some default JS
230                 var last = null
231                 var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
232                         var my_src = eval(
233                                 jQuery.ajax({
234                                         type: "GET",
235                                         url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
236                                         cache : false,
237                                         async : false,
238                                         data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
239                                         dataType : "script"
240                                 }).responseText
241                         );
242                         if(my_src.length == 0) {
243                                 var my_src = eval(
244                                 jQuery.ajax({
245                                         type: "GET",
246                                         url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
247                                         cache : false,
248                                         async : false,
249                                         data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
250                                         dataType : "script"
251                                 }).responseText
252                                 );
253                                 if(my_src.length == 0) {
254                                         strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
255                                 }
256                         }
257
258                 for (i = 0; i < my_src.length; i++) {
259                         img = new Image();
260                         img.src = my_src[i];
261                         img_attr = 'id="img' + i + '"';
262                         skip = false;
263
264                         maybeappend = '<a href="?ajax=photo_thickbox&amp;i=' + encodeURIComponent(img.src) + '&amp;u=<?php echo urlencode($url); ?>&amp;height=400&amp;width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
265
266                         if (img.width && img.height) {
267                                 if (img.width >= 30 && img.height >= 30) {
268                                         aspect = img.width / img.height;
269                                         scale = (aspect > 1) ? (71 / img.width) : (71 / img.height);
270
271                                         w = img.width;
272                                         h = img.height;
273
274                                         if (scale < 1) {
275                                                 w = parseInt(img.width * scale);
276                                                 h = parseInt(img.height * scale);
277                                         }
278                                         img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
279                                         strtoappend += maybeappend;
280                                 }
281                         } else {
282                                 strtoappend += maybeappend;
283                         }
284                 }
285
286                 function pick(img, desc) {
287                         if (img) {
288                                 if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
289                                 if(length == 0) length = 1;
290                                 jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
291                                 jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
292                                 insert_editor( "\n\n" + encodeURI('<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'));
293                         }
294                         return false;
295                 }
296
297                 function image_selector() {
298                         tb_remove();
299                         desc = jQuery('#this_photo_description').val();
300                         src = jQuery('#this_photo').val();
301                         pick(src, desc);
302                         jQuery('#extra_fields').hide();
303                         jQuery('#extra_fields').html('');
304                         return false;
305                 }
306
307                 jQuery(document).ready(function() {
308                         jQuery('#extra_fields').html('<div class="postbox"><h2>Photo <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul id="actions"><li><a href="#" id="photo_add_url" class="thickbox button"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
309                         jQuery('.close').click(function() {
310                                 jQuery('#extra_fields').hide();
311                                 jQuery('#extra_fields').html('');
312                         });
313                         jQuery('.refresh').click(function() {
314                                                 show('photo');
315                                         });
316                         jQuery('#img_container').html(strtoappend);
317                         jQuery('#photo_add_url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');
318                         tb_init('#extra_fields .thickbox');
319
320
321                 });
322                 <?php break;
323 }
324 die;
325 }
326
327 ?>
328 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
329 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
330 <head>
331         <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
332         <title><?php _e('Press This') ?></title>
333
334 <?php
335         add_thickbox();
336         wp_enqueue_style('press-this');
337         wp_enqueue_style('press-this-ie');
338         wp_enqueue_style( 'colors' );
339         wp_enqueue_script( 'post' );
340         wp_enqueue_script('editor');
341
342         do_action('admin_print_styles');
343         do_action('admin_print_scripts');
344         do_action('admin_head');
345
346         if ( user_can_richedit() ) {
347                 add_filter( 'teeny_mce_before_init', create_function( '$a', '$a["height"] = "400"; $a["onpageload"] = ""; $a["mode"] = "textareas"; $a["editor_selector"] = "mceEditor"; return $a;' ) );
348                 wp_tiny_mce( true );
349         }
350 ?>
351         <script type="text/javascript">
352     jQuery('#tags-input').hide();
353         tag_update_quickclicks();
354         // add the quickadd form
355         jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="submit" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" onclick="return false;" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>');
356
357         jQuery('#tagadd').click( tag_flush_to_text );
358         jQuery('#newtag').focus(function() {
359                 if ( this.value == postL10n.addTag )
360                         jQuery(this).val( '' ).removeClass( 'form-input-tip' );
361         });
362         jQuery('#newtag').blur(function() {
363                 if ( this.value == '' )
364                         jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' );
365         });
366         // auto-save tags on post save/publish
367         jQuery('#publish').click( tag_save_on_publish );
368         jQuery('#save').click( tag_save_on_publish );
369         function insert_plain_editor(text) {
370                 edCanvas = document.getElementById('content');
371                 edInsertContent(edCanvas, text);
372         }
373         function set_editor(text) {
374                 if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>';
375                 if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text);
376         }
377         function insert_editor(text) {
378                 if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
379                         tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
380                 } else {
381                         insert_plain_editor(decodeURI(text));
382                 }
383         }
384         function append_editor(text) {
385                 if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
386                         tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
387                         tinyMCE.execCommand('mceCleanup');
388                 } else {
389                         insert_plain_editor(text);
390                 }
391         }
392
393         function show(tab_name) {
394                 jQuery('#extra_fields').html('');
395                 jQuery('#extra_fields').show();
396                 switch(tab_name) {
397                         case 'video' :
398                                 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo attribute_escape($selection); ?>'}, function() {
399                                         <?php
400                                         $content = '';
401                                         if ( preg_match("/youtube\.com\/watch/i", $url) ) {
402                                                 list($domain, $video_id) = split("v=", $url);
403                                                 $content = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' . $video_id . '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $video_id . '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
404
405                                         } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
406                                                 list($domain, $video_id) = split(".com/", $url);
407                                                 $content = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" />      <embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>';
408
409                                                 if ( trim($selection) == '' )
410                                                         $selection = '<p><a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a></p>';
411
412                                         } elseif ( strpos( $selection, '<object' ) !== false ) {
413                                                 $content = $selection;
414                                         }
415                                         ?>
416                                         jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
417                                 });
418                                 return false;
419                                 break;
420                         case 'photo' :
421                                 jQuery('#extra_fields').before('<p id="waiting"><img src="images/loading.gif" alt="" /> <?php echo js_escape( __( 'Loading...' ) ); ?></p>');
422                                 jQuery.ajax({
423                                         type: "GET",
424                                         cache : false,
425                                         url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
426                                         data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
427                                         dataType : "script",
428                                         success : function() {
429                                                 jQuery('#waiting').remove();
430                                         }
431                                 });
432                                 return false;
433                                 break;
434                 }
435         }
436         jQuery(document).ready(function() {
437                 //resize screen
438                 window.resizeTo(720,570);
439                 // set button actions
440         jQuery('#photo_button').click(function() { show('photo'); return false; });
441                 jQuery('#video_button').click(function() { show('video'); return false; });
442                 // auto select
443                 <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
444                         show('video');
445                 <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
446                         show('video');
447                 <?php  } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
448                         show('photo');
449                 <?php } ?>
450                 jQuery('#title').unbind();
451                 jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
452         });
453 </script>
454 </head>
455 <body class="press-this">
456 <div id="wphead"></div>
457 <form action="press-this.php?action=post" method="post">
458 <div id="poststuff" class="metabox-holder">
459         <div id="side-info-column">
460                 <div class="sleeve">
461                         <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>
462
463                         <?php wp_nonce_field('press-this') ?>
464                         <input type="hidden" name="post_type" id="post_type" value="text"/>
465                         <input type="hidden" name="autosave" id="autosave" />
466                         <input type="hidden" id="original_post_status" name="original_post_status" value="draft" />
467                         <input type="hidden" id="prev_status" name="prev_status" value="draft" />
468
469                         <!-- This div holds the photo metadata -->
470                         <div class="photolist"></div>
471
472                         <div id="categorydiv" class="stuffbox">
473                                 <h2><?php _e('Categories') ?></h2>
474                                 <div class="inside">
475
476                                         <div id="categories-all" class="ui-tabs-panel">
477                                                 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
478                                                         <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
479                                                 </ul>
480                                         </div>
481
482                                         <div id="category-adder" class="wp-hidden-children">
483                                                 <a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a>
484                                                 <p id="category-add" class="wp-hidden-child">
485                                                         <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"/>
486                                                         <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 ) ); ?>
487                                                         <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
488                                                         <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
489                                                         <span id="category-ajax-response"></span>
490                                                 </p>
491                                         </div>
492                                 </div>
493                         </div>
494
495                         <div class="stuffbox">
496                                 <h2><?php _e('Tags') ?></h2>
497                                 <div class="inside">
498
499                                         <div id="jaxtag">
500                                                 <label class="hidden" for="newtag"><?php _e('Tags'); ?></label>
501                                                 <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 ); ?>" />
502                                         </div>
503                                         <div id="tagchecklist"></div>
504                                 </div>
505                         </div>
506                         <div id="submitdiv" class="postbox">
507                                 <h2><?php _e('Publish') ?></h2>
508                                 <div class="inside">
509                                         <p>
510                                                 <input class="button" type="submit" name="draft" value="<?php _e('Save Draft') ?>" id="save" />
511                                                 <input class="button-primary" type="submit" name="publish" value="<?php _e('Publish') ?>" id="publish" />
512                                                 <img src="images/loading-publish.gif" alt="" id="saving" style="display:none;"/>
513                                         </p>
514                                 </div>
515                         </div>
516                 </div>
517         </div>
518
519         <div class="posting">
520                 <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
521                 <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>
522                 <?php } ?>
523
524                 <div id="titlediv">
525                         <div class="titlewrap">
526                                 <input name="title" id="title" class="text" value="<?php echo attribute_escape($title);?>"/>
527                         </div>
528                 </div>
529
530                 <div id="extra_fields" style="display: none"></div>
531
532                 <div class="postdivrich">
533                         <ul id="actions">
534                                 <li id="photo_button">
535                                         Add: <a title="<?php _e('Insert an Image'); ?>" href="#">
536 <img alt="<?php _e('Insert an Image'); ?>" src="images/media-button-image.gif"/></a>
537                                 </li>
538                                 <li id="video_button">
539                                         <a title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="images/media-button-video.gif"/></a>
540                                 </li>
541                                 <?php if( user_can_richedit() ) { ?>
542                                 <li id="switcher">
543                                         <?php wp_print_scripts( 'quicktags' ); ?>
544                                         <?php add_filter('the_editor_content', 'wp_richedit_pre'); ?>
545                                         <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
546                                         <a id="edButtonPreview" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
547                                         <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
548                                 </li>
549                                 <?php } ?>
550                         </ul>
551                         <div id="quicktags"></div>
552                         <div class="editor-container">
553                                 <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15">
554                                         <?php if ($selection) echo wp_richedit_pre(htmlspecialchars_decode($selection)); ?>
555                                         <?php if ($url) { echo '<p>'; if($selection) _e('via '); echo "<a href='$url'>$title</a>."; echo '</p>'; } ?>
556                                 </textarea>
557                         </div>
558                 </div>
559         </div>
560 </div>
561 </form>
562 </body>
563 </html>