Changeset 8048
- Timestamp:
- 06/04/2008 04:13:55 PM (18 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 4 edited
-
css/press-this.css (modified) (7 diffs)
-
includes/file.php (modified) (1 diff)
-
includes/media.php (modified) (1 diff)
-
press-this.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/press-this.css
r8007 r8048 92 92 } 93 93 94 .submit input { 95 96 } 94 .button { 95 font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; 96 padding: 3px 5px; 97 font-size: 12px; 98 line-height: 1.5em; 99 border-width: 1px; 100 border-style: solid; 101 -moz-border-radius: 3px; 102 -khtml-border-radius: 3px; 103 -webkit-border-radius: 3px; 104 border-radius: 3px; 105 cursor: pointer; 106 margin-left: 5px; 107 text-decoration: none; 108 } 109 110 .howto { 111 font-size: 11px; 112 } 113 #newtag { padding: 3px; } 97 114 98 115 #wphead { … … 190 207 font-size: 85%; 191 208 position: absolute; 192 209 top: 50px; 193 210 right: 16px; 194 211 width: 27%; … … 270 287 #img_container { 271 288 background-color: #fff; 272 margin-top: 10px;273 289 overflow: auto; 274 290 height: 100px; … … 284 300 cursor: pointer; 285 301 } 286 302 .submit { 303 -moz-border-radius-bottomleft: 3px; 304 -khtml-border-bottom-left-radius: 3px; 305 -webkit-border-bottom-left-radius: 3px; 306 border-bottom-left-radius: 3px; 307 -moz-border-radius-bottomright: 3px; 308 -khtml-border-bottom-right-radius: 3px; 309 -webkit-border-bottom-right-radius: 3px; 310 border-bottom-right-radius: 3px; 311 margin: 0; 312 padding: 0; 313 } 287 314 .submitbox { 288 315 width: 100%; … … 290 317 } 291 318 292 .submitbox .submit {293 text-align: left;294 padding: 12px 10px 10px 10px;295 font-size: 11px;296 }297 298 .submit {299 border-top: 1px solid #ccc;300 padding: 1.5em 0 0 0;301 margin: 10px 0 0 0;302 -moz-border-radius-bottomleft: 3px;303 -khtml-border-bottom-left-radius: 3px;304 -webkit-border-bottom-left-radius: 3px;305 border-bottom-left-radius: 3px;306 -moz-border-radius-bottomright: 3px;307 -khtml-border-bottom-right-radius: 3px;308 -webkit-border-bottom-right-radius: 3px;309 border-bottom-right-radius: 3px;310 }311 312 319 .submitbox .submit a:hover { 313 320 border-bottom-width: 1px; … … 316 323 317 324 .submitbox .submit input { 318 margin-bottom: 8px;319 margin-right: 3px;320 padding: 6px 4px;321 325 border: none; 326 text-align: left; 327 padding: 12px 10px 10px 10px; 328 font-size: 12px; 329 margin: 10px; 330 331 -moz-border-radius: 3px; 332 -khtml-border-radius: 3px; 333 -webkit-border-radius: 3px; 334 border-radius: 3px; 322 335 cursor: pointer; 323 336 } … … 338 351 display: none; 339 352 } 353 354 .video_split #extra_fields { 355 width: 27%; 356 height: 300px; 357 float: left; 358 } 359 #embed_code { 360 border: 0; 361 width: 99%; 362 height: 200px; 363 } 364 .video_split .editor_area { 365 width: 70%; 366 float: right; 367 } 368 369 #jaxtag { 370 clear: both; 371 } -
trunk/wp-admin/includes/file.php
r8009 r8048 170 170 $new_file = $uploads['path'] . "/$filename"; 171 171 if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) { 172 return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) ); 173 } 174 175 // Set correct file permissions 176 $stat = stat( dirname( $new_file )); 177 $perms = $stat['mode'] & 0000666; 178 @ chmod( $new_file, $perms ); 179 180 // Compute the URL 181 $url = $uploads['url'] . "/$filename"; 182 183 $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) ); 184 185 return $return; 186 } 187 // Pass this function an array similar to that of a $_FILES POST array. 188 function wp_handle_sideload( &$file, $overrides = false ) { 189 // The default error handler. 190 if (! function_exists( 'wp_handle_upload_error' ) ) { 191 function wp_handle_upload_error( &$file, $message ) { 192 return array( 'error'=>$message ); 193 } 194 } 195 196 // You may define your own function and pass the name in $overrides['upload_error_handler'] 197 $upload_error_handler = 'wp_handle_upload_error'; 198 199 // $_POST['action'] must be set and its value must equal $overrides['action'] or this: 200 $action = 'wp_handle_sideload'; 201 202 // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. 203 $upload_error_strings = array( false, 204 __( "The file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>." ), 205 __( "The file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form." ), 206 __( "The file was only partially uploaded." ), 207 __( "No file was sent." ), 208 __( "Missing a temporary folder." ), 209 __( "Failed to write file to disk." )); 210 211 // All tests are on by default. Most can be turned off by $override[{test_name}] = false; 212 $test_form = true; 213 $test_size = true; 214 215 // If you override this, you must provide $ext and $type!!!! 216 $test_type = true; 217 $mimes = false; 218 219 // Install user overrides. Did we mention that this voids your warranty? 220 if ( is_array( $overrides ) ) 221 extract( $overrides, EXTR_OVERWRITE ); 222 223 // A correct form post will pass this test. 224 if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) ) 225 return $upload_error_handler( $file, __( 'Invalid form submission.' )); 226 227 // A successful upload will pass this test. It makes no sense to override this one. 228 if ( $file['error'] > 0 ) 229 return $upload_error_handler( $file, $upload_error_strings[$file['error']] ); 230 231 // A non-empty file will pass this test. 232 if ( $test_size && !(filesize($file['tmp_name']) > 0 ) ) 233 return $upload_error_handler( $file, __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini.' )); 234 235 // A properly uploaded file will pass this test. There should be no reason to override this one. 236 if (! @ is_file( $file['tmp_name'] ) ) 237 return $upload_error_handler( $file, __( 'Specified file does not exist.' )); 238 239 // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. 240 if ( $test_type ) { 241 $wp_filetype = wp_check_filetype( $file['name'], $mimes ); 242 243 extract( $wp_filetype ); 244 245 if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) 246 return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' )); 247 248 if ( !$ext ) 249 $ext = ltrim(strrchr($file['name'], '.'), '.'); 250 251 if ( !$type ) 252 $type = $file['type']; 253 } 254 255 // A writable uploads dir will pass this test. Again, there's no point overriding this one. 256 if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) 257 return $upload_error_handler( $file, $uploads['error'] ); 258 259 $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); 260 261 // Move the file to the uploads dir 262 $new_file = $uploads['path'] . "/$filename"; 263 if ( false === @ rename( $file['tmp_name'], $new_file ) ) { 172 264 return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) ); 173 265 } -
trunk/wp-admin/includes/media.php
r8038 r8048 113 113 114 114 return $id; 115 116 } 117 118 119 function media_sideload_image($file, $post_id) { 120 121 if (!empty($file) ) { 122 // Upload File button was clicked 123 124 $file_array['name'] = basename($file); 125 $file_array['tmp_name'] = download_url($file); 126 127 $sideload = media_handle_sideload($file_array, $post_id); 128 129 $id = $sideload['id']; 130 $src = $sideload['src']; 131 132 unset($file_array['tmp_name']); 133 unset($file_array); 134 135 if ( is_wp_error($id) ) { 136 $errors['upload_error'] = $id; 137 $id = false; 138 } 139 } 140 141 if ( !empty($src) && !strpos($src, '://') ) 142 143 $src = "http://$src"; 144 /*$alt = attribute_escape($_POST['insertonly']['alt']); 145 if ( isset($_POST['insertonly']['align']) ) { 146 $align = attribute_escape($_POST['insertonly']['align']); 147 $class = " class='align$align'"; 148 } */ 149 if ( !empty($src) ) 150 $html = "<img src='$src' alt='$alt'$class />"; 151 return $html; 152 153 } 154 155 function media_handle_sideload($file_array, $post_id, $post_data = array()) { 156 $overrides = array('test_form'=>false); 157 $file = wp_handle_sideload($file_array, $overrides); 158 159 if ( isset($file['error']) ) 160 return new wp_error( 'upload_error', $file['error'] ); 161 162 $url = $file['url']; 163 $type = $file['type']; 164 $file = $file['file']; 165 $title = preg_replace('/\.[^.]+$/', '', basename($file)); 166 $content = ''; 167 168 // use image exif/iptc data for title and caption defaults if possible 169 if ( $image_meta = @wp_read_image_metadata($file) ) { 170 if ( trim($image_meta['title']) ) 171 $title = $image_meta['title']; 172 if ( trim($image_meta['caption']) ) 173 $content = $image_meta['caption']; 174 } 175 176 // Construct the attachment array 177 $attachment = array_merge( array( 178 'post_mime_type' => $type, 179 'guid' => $url, 180 'post_parent' => $post_id, 181 'post_title' => $title, 182 'post_content' => $content, 183 ), $post_data ); 184 185 // Save the data 186 $id = wp_insert_attachment($attachment, $file, $post_parent); 187 if ( !is_wp_error($id) ) { 188 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 189 } 190 191 return array('id' => $id, 'src' => $url); 115 192 116 193 } -
trunk/wp-admin/press-this.php
r8028 r8048 2 2 require_once('admin.php'); 3 3 4 if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' )); 5 6 if ( 'post' == $_REQUEST['action'] ) { 7 check_admin_referer('press-this'); 8 $post_ID = press_it(); ?> 9 <script>if(confirm("<?php _e('Your post is saved. Do you want to view the post?') ?>")) {window.opener.location.replace("<?php echo get_permalink($post_ID);?>");}window.close();</script> 4 if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' )); ?> 5 10 6 <?php 11 die;12 }13 14 7 function press_it() { 15 $quick['post_status'] = 'publish'; 16 $quick['post_category'] = $_REQUEST['post_category']; 17 $quick['tags_input'] = $_REQUEST['tags_input']; 18 $quick['post_title'] = $_REQUEST['post_title']; 19 20 $content = ''; 21 switch ( $_REQUEST['post_type'] ) { 22 case 'text': 23 $content = $_REQUEST['content']; 24 25 case 'quote': 26 $content = $_REQUEST['content']; 27 break; 28 29 case 'photo': 30 31 // http_post_data(); 32 33 if ($_REQUEST['photo_link']) 34 $content = '<a href="' . $_REQUEST['photo_link'] . '">'; 35 36 $content .= '<img src="' . $_REQUEST['photo_src'] . '" alt=""/>'; 37 38 if ($_REQUEST['photo_link']) 39 $content .= '</a> 40 '; 41 42 if ($_REQUEST['content']) 43 $content = $content . "\n".$_REQUEST['content']; 44 45 break; 46 case "video": 47 $content = $_REQUEST['content']; 48 49 break; 50 } 8 $quick['post_status'] = 'publish'; 9 $quick['post_category'] = $_REQUEST['post_category']; 10 $quick['tags_input'] = $_REQUEST['tags_input']; 11 $quick['post_title'] = $_REQUEST['post_title']; 12 $quick['post_content'] = ''; 13 14 // insert the post with nothing in it, to get an ID 15 $post_ID = wp_insert_post($quick, true); 16 17 $content = ''; 18 switch ( $_REQUEST['post_type'] ) { 19 case 'text': 20 $content .= $_REQUEST['content']; 21 22 case 'quote': 23 $content .= $_REQUEST['content']; 24 break; 25 26 case 'photo': 27 if ($_REQUEST['photo_link']) 28 $content .= '<a href="' . $_REQUEST['photo_link'] . '">'; 29 30 $content .= media_sideload_image($_REQUEST['photo_src'], $post_ID); 31 32 if ($_REQUEST['photo_link']) 33 $content .= '</a>'; 34 35 if ($_REQUEST['content']) 36 $content .= $content . "\n\n".$_REQUEST['content']; 37 38 break; 39 case "video": 40 if($_REQUEST['embed_code']) 41 $content .= $_REQUEST['embed_code']."\n\n"; 42 $content .= $_REQUEST['content']; 43 break; 44 } 51 45 52 46 $quick['post_content'] = $content; 53 47 54 $post_ID = wp_insert_post($quick, true); 55 56 if ( is_wp_error($post_ID) ) 57 wp_die($wp_error); 58 48 if ( is_wp_error($post_ID) ) { 49 wp_die($id); 50 wp_delete_post($post_ID); 51 } else { 52 $quick['ID'] = $post_ID; 53 wp_update_post($quick); 54 } 59 55 return $post_ID; 60 56 } 61 57 62 function tag_div() { ?> 63 <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> 64 <div id="tagchecklist"></div> 65 <?php 58 function tag_div() { ?> 59 <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> 60 <div id="tagchecklist"></div> 61 <?php 62 } 63 64 function category_div() { 65 ?> 66 <div id="categories"> 67 <div class="submitbox" id="submitpost"> 68 <div id="previewview"> <h2><?php _e('Categories') ?></h2></div> 69 <div class="inside"> 70 <div id="categories-all"> 71 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 72 <?php wp_category_checklist() ?> 73 </ul> 74 </div> 75 </div> 76 <p class="submit"> 77 <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 78 <img src="images/loading.gif" alt="" id="photo_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> 79 </p> 80 </div> 81 <?php 82 } 83 84 // For posts submitted 85 if ( 'post' == $_REQUEST['action'] ) { 86 check_admin_referer('press-this'); $post_ID = press_it(); ?> 87 <script>if(confirm("<?php _e('Your post is saved. Do you want to view the post?') ?>")){window.opener.location.replace("<?php echo get_permalink($post_ID);?>");}window.close();</script> 88 <?php die; 66 89 } 67 90 68 function category_div() { 69 ?> 70 <div id="categories"> 71 <div class="submitbox" id="submitpost"> 72 <div id="previewview"> <h2><?php _e('Categories') ?></h2></div> 73 <div class="inside"> 74 <div id="categories-all"> 75 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 76 <?php wp_category_checklist() ?> 77 </ul> 78 </div> 91 // Ajax Requests 92 $url = $_REQUEST['url']; 93 $selection = $_REQUEST['selection']; 94 95 if($_REQUEST['ajax'] == 'video') { ?> 96 <h2 id="embededcode"><label for="embed_code"><?php _e('Embed Code') ?></label></h2> 97 <div class="titlewrap" > 98 <textarea name="embed_code" id="embed_code" rows="8" cols="40"><?php echo $selection; ?></textarea> 99 </div> 100 <?php die; 101 } 102 103 if($_REQUEST['ajax'] == 'photo_images') { 104 function get_images_from_uri($uri) { 105 $content = wp_remote_fopen($uri); 106 $host = parse_url($uri); 107 if ( false === $content ) return ''; 108 109 $pattern = '/<img[^>]+src=[\'"]([^\'" >]+?)[\'" >]/is'; 110 preg_match_all($pattern, $content, $matches); 111 if ( empty($matches[1]) ) return ''; 112 113 $sources = array(); 114 115 foreach ($matches[1] as $src) { 116 if ( false !== strpos($src, '&') ) continue; 117 if(strpos($src, 'http') === false) { 118 if(strpos($src, '../') === false && strpos($src, './') === false) { 119 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 120 } else { 121 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); 122 } 123 } 124 $sources[] = $src; 125 } 126 return "'" . implode("','", $sources) . "'"; 127 } 128 129 echo 'new Array('.get_images_from_uri($url).')'; 130 die; 131 } 132 133 if($_REQUEST['ajax'] == 'photo_js') { ?> 134 135 var last = null 136 function pick(img) { 137 138 if (last) last.style.backgroundColor = '#f4f4f4'; 139 if (img) { 140 jQuery('#photo_src').val(img.src); 141 img.style.backgroundColor = '#44f'; 142 } 143 last = img; 144 145 /*noel's code to select more than one image.... 146 jQuery('.photolist').append('<h2><?php _e("Photo URL") ?></h2>' + 147 '<div class="titlewrap">' + 148 '<a href="#" class="remove">remove <input name="photo_src" id="photo_src[]" value ="'+ img.src +'" class="text" onkeydown="pick(0);"/></a>' + 149 '</div>');*/ 150 151 return false; 152 } 153 154 jQuery('.remove').click(function() { 155 jQuery(this).remove; 156 }); 157 158 159 var my_src, img, img_tag, aspect, w, h, skip, i, strtoappend = ""; 160 161 var my_src =eval( 162 jQuery.ajax({ 163 type: "GET", 164 url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>", 165 cache : false, 166 async : false, 167 data: "ajax=photo_images&url=<?php echo $url?>", 168 dataType : "script" 169 }).responseText); 170 171 for (i = 0; i < my_src.length; i++) { 172 img = new Image(); 173 img.src = my_src[i]; 174 img_attr = 'id="img' + i + '" onclick="pick(this);"'; 175 skip = false; 176 177 if (img.width && img.height) { 178 if (img.width * img.height < 2500) skip = true; 179 aspect = img.width / img.height; 180 if (aspect > 1) { // Image is wide 181 scale = 75 / img.width; 182 } else { // Image is tall or square 183 scale = 75 / img.height; 184 } 185 if (scale < 1) { 186 w = parseInt(img.width * scale); 187 h = parseInt(img.height * scale); 188 } else { 189 w = img.width; 190 h = img.height; 191 } 192 img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"'; 193 } 194 195 if (!skip) strtoappend += '<a href="' + img.src + '" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>'; 196 197 } 198 199 jQuery('#img_container').html(strtoappend); 200 201 tb_init('a.thickbox, area.thickbox, input.thickbox'); //pass where to apply thickbox 202 203 <?php die; } 204 205 if($_REQUEST['ajax'] == 'photo') { ?> 206 <h2><?php _e('Photo URL') ?></h2> 207 <div class="titlewrap"> 208 <input name="photo_src" id="photo_src" class="text" onkeydown="pick(0);"/> 79 209 </div> 80 <p class="submit"> 81 <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 82 <img src="images/loading.gif" alt="" id="photo_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> 83 </p> 84 </div> 85 <?php 86 } 87 88 function get_images_from_uri($uri) { 89 90 $content = wp_remote_fopen($uri); 91 $uri = str_replace(basename($uri), '', $uri); 92 $host = parse_url($uri); 93 94 if ( false === $content ) return ''; 95 96 $pattern = '/<img[^>]+src=[\'"]([^\'" >]+?)[\'" >]/is'; 97 preg_match_all($pattern, $content, $matches); 98 if ( empty($matches[1]) ) return ''; 99 100 $sources = array(); 101 foreach ($matches[1] as $src) { 102 if ( false !== strpos($src, '&') ) 103 continue; 104 if ( !strstr( $src, 'http://' ) ) 105 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); 106 107 $sources[] = $src; 108 } 109 return "'" . implode("','", $sources) . "'"; 110 } 210 211 <div class="photolist"></div> 212 213 <h2><?php _e('Link Photo to following URL') ?></h2><?php _e('(leave blank to leave the photo unlinked)') ?> 214 <div class="titlewrap"> 215 <input name="photo_link" id="photo_link" class="text" value="<?php echo attribute_escape($url);?>"/> 216 </div> 217 218 <small><?php _e('Click images to select:') ?></small> 219 <div class="titlewrap"> 220 <div id="img_container">Loading Images...</div> 221 </div> 222 <?php die; } 111 223 112 224 // Clean up the data being passed in … … 123 235 <script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce.js"></script> 124 236 <?php 125 wp_enqueue_script('jquery-ui-tabs');126 237 add_thickbox(); 127 238 wp_enqueue_style('press-this'); … … 154 265 theme : "advanced", 155 266 theme_advanced_buttons1 : "bold,italic,underline,blockquote,separator,strikethrough,bullist,numlist,undo,redo,link,unlink", 267 extended_valid_elements : "object[width|height],param[name|value],embed[src|type|wmode|width|height], a[name|href|target|title|onclick], img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name], hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", 156 268 theme_advanced_buttons2 : "", 157 269 theme_advanced_buttons3 : "", … … 175 287 <?php } ?> 176 288 177 jQuery('#tags-input').hide();178 179 tag_update_quickclicks();180 181 // add the quickadd form182 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>');183 184 jQuery('#tagadd').click( tag_flush_to_text );185 jQuery('#newtag').focus(function() {186 if ( this.value == postL10n.addTag )187 jQuery(this).val( '' ).removeClass( 'form-input-tip' );188 });189 jQuery('#newtag').blur(function() {190 if ( this.value == '' )191 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' );192 });193 194 // auto-save tags on post save/publish195 jQuery('#publish').click( tag_save_on_publish );196 jQuery('#save-post').click( tag_save_on_publish );289 jQuery('#tags-input').hide(); 290 291 tag_update_quickclicks(); 292 293 // add the quickadd form 294 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>'); 295 296 jQuery('#tagadd').click( tag_flush_to_text ); 297 jQuery('#newtag').focus(function() { 298 if ( this.value == postL10n.addTag ) 299 jQuery(this).val( '' ).removeClass( 'form-input-tip' ); 300 }); 301 jQuery('#newtag').blur(function() { 302 if ( this.value == '' ) 303 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); 304 }); 305 306 // auto-save tags on post save/publish 307 jQuery('#publish').click( tag_save_on_publish ); 308 jQuery('#save-post').click( tag_save_on_publish ); 197 309 198 310 function set_menu(type) { … … 203 315 } 204 316 function set_editor(text) { 205 tinyMCE.activeEditor.setContent('');206 tinyMCE.execCommand('mceInsertContent' ,false, text);317 if(tinyMCE.activeEditor) tinyMCE.activeEditor.setContent(''); 318 if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text); 207 319 } 208 320 function set_title(title) { jQuery("#content_type").text(title); } 209 210 var last = null; 211 function pick(img) { 212 if (last) last.style.backgroundColor = '#f4f4f4'; 213 if (img) { 214 document.getElementById('photo_src').value = img.src; 215 img.style.backgroundColor = '#44f'; 321 function reset_height() { 322 tinyMCE.height = '170px'; 323 } 324 function show(tab_name) { 325 jQuery('body').removeClass('video_split'); 326 jQuery('#extra_fields').hide(); 327 switch(tab_name) { 328 case 'text' : 329 reset_height(); 330 jQuery('.editor-container').show(); 331 jQuery('#content_type').show(); 332 set_menu('text'); 333 set_title('<?php _e('Text') ?>'); 334 set_editor('<?php echo $selection; ?>'); 335 return false; 336 break; 337 case 'quote' : 338 reset_height(); 339 jQuery('.editor-container').show(); 340 jQuery('#content_type').show(); 341 set_menu('quote'); 342 set_title('<?php _e('Quote') ?>'); 343 set_editor('<blockquote><p><?php echo $selection; ?> </p><p><cite><a href="<?php echo $url; ?>"><?php echo $title; ?></a></cite> </p></blockquote>'); 344 345 return false; 346 break; 347 case 'video' : 348 reset_height(); 349 jQuery('.editor-container').show(); 350 jQuery('#content_type').show(); 351 set_menu('video'); 352 set_title('<?php _e('Caption') ?>'); 353 354 jQuery('#extra_fields').show(); 355 jQuery('body').addClass('video_split'); 356 357 358 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', selection: '<?php echo attribute_escape($selection); ?>'}, function() { 359 360 <?php 361 if ( preg_match("/youtube\.com\/watch/i", $url) ) { 362 list($domain, $video_id) = split("v=", $url); 363 $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>'; ?> 364 365 <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { 366 367 list($domain, $video_id) = split(".com/", $url); 368 $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 . '&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /> <embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>'; 369 370 if(trim($selection) == '') $selection = '<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>'; 371 }else { 372 $content = $selection; 373 } ?> 374 jQuery('#embed_code').prepend('<?php echo htmlentities($content); ?>'); 375 set_editor('<?php echo $title; ?>'); 376 377 }); 378 379 380 return false; 381 break; 382 383 case 'photo' : 384 reset_height(); 385 set_menu('photo'); 386 set_title('Caption'); 387 set_editor('<a href="<?php echo $url; ?>"><?php echo $title; ?></a>'); 388 389 jQuery('#extra_fields').show(); 390 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']).'/?ajax=photo&url='.attribute_escape($url); ?>'); 391 jQuery('#extra_fields').prepend('<h2><img src="images/loading.gif" alt="" /> Loading...</h2>'); 392 jQuery.ajax({ 393 type: "GET", 394 cache : false, 395 url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>", 396 data: "ajax=photo_js&url=<?php echo $url?>", 397 dataType : "script", 398 success : function() { 399 } 400 }); 401 return false; 402 break; 403 216 404 } 217 last = img; 218 219 /*noel's code to select more than one image.... 220 jQuery('.photolist').append('<h2><?php _e("Photo URL") ?></h2>' + 221 '<div class="titlewrap">' + 222 '<a href="#" class="remove">remove <input name="photo_src" id="photo_src[]" value ="'+ img.src +'" class="text" onkeydown="pick(0);"/></a>' + 223 '</div>');*/ 224 225 return false; 226 } 227 405 406 } 407 228 408 jQuery(document).ready(function() { 229 230 409 jQuery('#menu li').click(function (){ 410 tab_name = this.id.split('_'); 411 tab_name = tab_name[0]; 412 show(tab_name); 413 }); 414 231 415 <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?> 232 233 <?php } elseif ( preg_match("/ flickr\.com/i", $url) ) { ?>234 235 <?php } else{ ?>236 416 show('video'); 417 <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?> 418 show('video'); 419 <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?> 420 show('photo'); 237 421 <?php } ?> 238 239 240 jQuery("#text_button").click(function () {241 jQuery('.editor-container').show();242 jQuery('#content_type').show();243 jQuery('#photo_fields').hide();244 set_menu('text');245 set_title('<?php _e('Text') ?>');246 set_editor('<?php echo $selection; ?>');247 return false;248 });249 250 jQuery("#quote_button").click(function () {251 jQuery('.editor-container').show();252 jQuery('#content_type').show();253 jQuery('#photo_fields').hide();254 set_menu('quote');255 set_title('<?php _e('Quote') ?>');256 set_editor('<blockquote><p><?php echo $selection; ?> </p><p><cite><a href="<?php echo $url; ?>"><?php echo $title; ?></a></cite> </p></blockquote>');257 258 return false;259 });260 261 262 jQuery("#video_button").click(function () {263 jQuery('.editor-container').show();264 jQuery('#content_type').show();265 jQuery('#photo_fields').hide();266 set_menu('video');267 set_title('<?php _e('Video') ?>');268 set_editor('<a href="<?php echo $url; ?>"><?php echo $title; ?></a>');269 <?php /*270 <!--list($garbage,$video_id) = split("v=", $_REQUEST['content']);271 $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>';-->272 */?>273 return false;274 });275 276 277 jQuery("#photo_button").click(function () {278 set_menu('photo');279 set_title('Caption');280 set_editor('<a href="<?php echo $url; ?>"><?php echo $title; ?></a>');281 jQuery('#photo_fields').show();282 jQuery('.remove').click(function() {283 jQuery(this).remove;284 285 });286 287 288 var img, img_tag, aspect, w, h, skip, i, strtoappend = "";289 var my_src = [<?php echo get_images_from_uri($url); ?>];290 291 for (i = 0; i < my_src.length; i++) {292 img = new Image();293 img.src = my_src[i];294 img_attr = 'id="img' + i + '" onclick="pick(this);"';295 skip = false;296 297 if (img.width && img.height) {298 if (img.width * img.height < 2500) skip = true;299 aspect = img.width / img.height;300 if (aspect > 1) { // Image is wide301 scale = 75 / img.width;302 } else { // Image is tall or square303 scale = 75 / img.height;304 }305 if (scale < 1) {306 w = parseInt(img.width * scale);307 h = parseInt(img.height * scale);308 } else {309 w = img.width;310 h = img.height;311 }312 img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';313 }314 315 if (!skip) strtoappend += '<a href="' + img.src + '" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';316 317 }318 319 jQuery('#img_container').html(strtoappend);320 321 tb_init('a.thickbox, area.thickbox, input.thickbox'); //pass where to apply thickbox322 323 });324 422 }); 325 </script> 326 327 423 </script> 328 424 </head> 329 425 <body class="press-this"> … … 340 436 341 437 <form action="press-this.php?action=post" method="post"> 438 342 439 <?php wp_nonce_field('press-this') ?> 343 <input type="hidden" name="source" value="bookmarklet"/>344 440 <input type="hidden" name="post_type" id="post_type" value="text"/> 345 441 <div id="posting"> … … 349 445 <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> 350 446 </div> 351 <div id="photo_fields" style="display: none;"> 352 <h2><label for="photo_src"><?php _e('Photo URL') ?></label></h2> 353 <div class="titlewrap"> 354 <input name="photo_src" id="photo_src" class="text" onkeydown="pick(0);"/> 355 </div> 356 357 <div class="photolist"></div> 358 359 <h2><label for="photo_link"><?php _e('Link Photo to following URL') ?></label></h2><?php _e('(leave blank to leave the photo unlinked)') ?> 360 <div class="titlewrap"> 361 <input name="photo_link" id="photo_link" class="text" value="<?php echo attribute_escape($url);?>"/> 362 </div> 363 364 <small><?php _e('Click images to select:') ?></small> 365 <div class="titlewrap"> 366 <div id="img_container"></div> 367 </div> 368 369 </div> 370 447 448 <div id="extra_fields" style="display: none"></div> 449 <div class="editor_area"> 371 450 <h2 id="content_type"><label for="content"><?php _e('Post') ?></label></h2> 372 451 <div class="editor-container"> 373 <textarea name="content" id="content" style=" height:170px;width:100%;" class="mceEditor">452 <textarea name="content" id="content" style="width:100%;" class="mceEditor"> 374 453 <?php echo $selection; ?> 375 454 </textarea> 376 455 </div> 377 456 </div> 378 457 <?php tag_div(); ?> 379 380 458 </div> 381 459 <?php category_div(); ?> 382 460 </form> 383 <?php /*384 if ( preg_match("/youtube\.com\/watch/i", $url) ) {385 list($domain, $video_id) = split("v=", $url);386 ?>387 <input type="hidden" name="content" value="<?php echo attribute_escape($url); ?>" />388 <img src="http://img.youtube.com/vi/<?php echo $video_id; ?>/default.jpg" align="right" style="border:solid 1px #aaa;" width="130" height="97"/>389 <?php } else { ?>390 391 <h2><label for="video_post_one"><?php _e('Embed Code') ?></label></h2>392 <textarea name="content" id="video_post_one" style="height:80px;width:100%;"></textarea>393 <?php } */?>394 461 395 462 </body>
Note: See TracChangeset
for help on using the changeset viewer.