Changeset 3303
- Timestamp:
- 12/13/2005 07:19:56 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r3295 r3303 743 743 @ imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1]); 744 744 745 // If no filters change the filename, we'll do a default transformation. 746 if ( basename($file) == $thumb = apply_filters('thumbnail_filename', basename($file)) ) 747 $thumb = preg_replace('!(\.[^.]+)?$!', __('.thumbnail').'$1', basename($file), 1); 748 749 $thumbpath = str_replace(basename($file), $thumb, $file); 750 745 751 // move the thumbnail to it's final destination 746 747 $path = explode('/', $file);748 $thumbpath = substr($file, 0, strrpos($file, '/')).'/thumb-'.$path[count($path) - 1];749 750 752 if ($type[2] == 1) { 751 753 if (!imagegif($thumbnail, $thumbpath)) { … … 772 774 return $error; 773 775 } else { 774 return 1;776 return $thumbpath; 775 777 } 776 778 } … … 1634 1636 function wp_handle_upload(&$file, $overrides = false) { 1635 1637 // The default error handler. 1636 function wp_handle_upload_error(&$file, $message) { 1637 return array('error'=>$message); 1638 if (! function_exists('wp_handle_upload_error') ) { 1639 function wp_handle_upload_error(&$file, $message) { 1640 return array('error'=>$message); 1641 } 1638 1642 } 1639 1643 … … 1654 1658 1655 1659 // Accepted MIME types are set here as PCRE. Override with $override['mimes']. 1656 $mimes = apply_filters('upload_mimes', array (1657 'image/jpeg' => 'jpg|jpeg|jpe',1658 'image/gif' => 'gif',1659 'image/(png|x-png)' => 'png',1660 'image/(bmp|x-bmp|x-ms-bmp)' => 'bmp',1661 'image/(tiff|x-tiff)' => 'tif|tiff',1662 'image/(ico|x-ico)' => 'ico',1663 'video/(asf|x-asf|x-ms-asf)' => 'asf|asx|wma|wax|wmv|wmx',1664 'video/(wmv|x-wmv|x-ms-wmv)' => 'wmv',1665 'video/(msvideo|x-msvideo)' => 'avi',1666 'video/(quicktime|x-quicktime)' => 'mov|qt',1667 'video/(mpeg|x-mpeg)' => 'mpeg|mpg|mpe',1668 'text/plain' => 'txt|c|cc|h|php',1669 'text/richtext' => 'rtx',1670 'text/css' => 'css',1671 'text/html' => 'htm|html',1672 'text/javascript' => 'js',1673 'audio/(mpeg|x-mpeg|mpeg3|x-mpeg3)' => 'mp3',1674 'audio/x-realaudio' => 'ra|ram',1675 'audio/(wav|x-wav)' => 'wav',1676 'audio/(ogg|x-ogg)' => 'ogg',1677 'audio/(midi|x-midi)' => 'mid|midi',1678 'application/pdf' => 'pdf',1679 'application/msword' => 'doc',1680 'application/mspowerpoint' => 'pot|pps|ppt',1681 'application/mswrite' => 'wri',1682 'application/(msexcel|vnd.ms-excel)' => 'xla|xls|xlt|xlw',1683 'application/msaccess' => 'mdb',1684 'application/msproject' => 'mpp',1685 'application/x-shockwave-flash' => 'swf',1686 'application/java' => 'class',1687 'application/x-tar' => 'tar',1688 'application/(zip|x-zip-compressed)' => 'zip',1689 'application/(x-gzip|x-gzip-compressed)' => 'gz|gzip'));1690 1691 // For security, we never trust HTTP Content-Type headers unless the user overrides this.1692 $trust_content_type = false;1660 $mimes = apply_filters('upload_mimes', array ( 1661 'jpg|jpeg|jpe' => 'image/jpeg', 1662 'gif' => 'image/gif', 1663 'png' => 'image/png', 1664 'bmp' => 'image/bmp', 1665 'tif|tiff' => 'image/tiff', 1666 'ico' => 'image/x-icon', 1667 'asf|asx|wax|wmv|wmx' => 'video/asf', 1668 'avi' => 'video/avi', 1669 'mov|qt' => 'video/quicktime', 1670 'mpeg|mpg|mpe' => 'video/mpeg', 1671 'txt|c|cc|h|php' => 'text/plain', 1672 'rtx' => 'text/richtext', 1673 'css' => 'text/css', 1674 'htm|html' => 'text/html', 1675 'mp3|mp4' => 'audio/mpeg', 1676 'ra|ram' => 'audio/x-realaudio', 1677 'wav' => 'audio/wav', 1678 'ogg' => 'audio/ogg', 1679 'mid|midi' => 'audio/midi', 1680 'wma' => 'audio/wma', 1681 'rtf' => 'application/rtf', 1682 'js' => 'application/javascript', 1683 'pdf' => 'application/pdf', 1684 'doc' => 'application/msword', 1685 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 1686 'wri' => 'application/vnd.ms-write', 1687 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', 1688 'mdb' => 'application/vnd.ms-access', 1689 'mpp' => 'application/vnd.ms-project', 1690 'swf' => 'application/x-shockwave-flash', 1691 'class' => 'application/java', 1692 'tar' => 'application/x-tar', 1693 'zip' => 'application/zip', 1694 'gz|gzip' => 'application/x-gzip', 1695 'exe' => 'application/x-msdownload' 1696 )); 1693 1697 1694 1698 // All tests are on by default. Most can be turned off by $override[{test_name}] = false; 1695 1699 $test_form = true; 1696 1700 $test_size = true; 1701 1702 // If you override this, you must provide $ext and $type!!!! 1697 1703 $test_type = true; 1698 1704 … … 1717 1723 return $upload_error_handler($file, __('Specified file failed upload test.')); 1718 1724 1719 // A correct MIME type will pass this test. We can't always determine it programatically, so we'll trust the HTTP headers.1725 // A correct MIME type will pass this test. 1720 1726 if ( $test_type ) { 1721 1727 $type = false; 1722 1728 $ext = false; 1723 foreach ($mimes as $mime_preg => $ext_preg) { 1724 $mime_preg = '!^' . $mime_preg . '$!i'; 1729 foreach ($mimes as $ext_preg => $mime_match) { 1725 1730 $ext_preg = '![^.]\.(' . $ext_preg . ')$!i'; 1726 if ( preg_match($mime_preg, $file['type'], $type) ) { 1727 if ( preg_match($ext_preg, $file['name'], $ext) ) { 1728 break; 1729 } else { 1730 return $upload_error_handler($file, __('File extension does not match file type. Try another.')); 1731 } 1732 } 1733 } 1734 if (! $type && $ext ) 1731 if ( preg_match($ext_preg, $file['name'], $ext_matches) ) { 1732 $type = $mime_match; 1733 $ext = $ext_matches[1]; 1734 } 1735 } 1736 1737 if ( !$type || !$ext ) 1735 1738 return $upload_error_handler($file, __('File type does not meet security guidelines. Try another.')); 1736 $type = $type[0];1737 $ext = $ext[1];1738 1739 } 1739 1740 … … 1755 1756 $new_file = $uploads['path'] . "/$filename"; 1756 1757 if ( false === move_uploaded_file($file['tmp_name'], $new_file) ) 1757 die( __('The uploaded file could not be moved to $file.'));1758 die(printf(__('The uploaded file could not be moved to %s.'), $file['path'])); 1758 1759 1759 1760 // Set correct file permissions … … 1765 1766 $url = $uploads['url'] . "/$filename"; 1766 1767 1767 return array('file' => $new_file, 'url' => $url );1768 return array('file' => $new_file, 'url' => $url, 'type' => $type); 1768 1769 } 1769 1770 … … 1837 1838 } 1838 1839 1840 function the_attachment_links($id = false) { 1841 $id = (int) $id; 1842 $post = & get_post($id); 1843 1844 if ( $post->post_status != 'attachment' ) 1845 return false; 1846 1847 $icon = get_attachment_icon($post->ID); 1848 1839 1849 ?> 1850 <?php _e('Text linked to file') ?><br/> 1851 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid) ?></a></textarea> 1852 <?php _e('Text linked to subpost') ?><br/> 1853 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $post->post_title ?></a></textarea> 1854 <?php if ( $icon ) : ?> 1855 <?php _e('Thumbnail linked to file') ?><br/> 1856 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><img src="<?php echo $thumb ?>" class="attachmentthumb" alt="<?php echo $post->post_title ?>" /></a></textarea> 1857 <?php _e('Thumbnail linked to subpost') ?><br/> 1858 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" class="attachmentlink"><img src="<?php echo $icon ?>" class="attachmentthumb" alt="<?php echo $post->post_title ?>" /></a></textarea> 1859 <?php endif; ?> 1860 <?php 1861 } 1862 1863 function get_udims($width, $height) { 1864 if ( $height <= 96 && $width <= 128 ) 1865 return array($width, $height); 1866 elseif ( $width / $height > 4 / 3 ) 1867 return array(128, (int) ($height / $width * 128)); 1868 else 1869 return array((int) ($width / $height * 96), 96); 1870 } 1871 1872 ?> -
trunk/wp-admin/edit-pages.php
r2832 r3303 10 10 <p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page'); ?> »</a></p> 11 11 12 <form name="searchform" action="" method="get"> 13 <fieldset> 14 <legend><?php _e('Search Pages…') ?></legend> 15 <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo wp_specialchars($_GET['s'], 1); ?>" size="17" /> 16 <input type="submit" name="submit" value="<?php _e('Search') ?>" /> 17 </fieldset> 18 </form> 19 12 20 <?php 13 $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'"); 21 22 $show_post_type = 'page'; 23 24 if ( isset($_GET['s']) ) 25 wp(); 26 else 27 $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'"); 14 28 15 29 if ($posts) { … … 25 39 <th scope="col"></th> 26 40 </tr> 27 <?php page_rows(); ?> 41 <?php 42 if ( isset($_GET['s']) ) { 43 foreach ( $posts as $post ) : 44 $class = ('alternate' != $class) ? 'alternate' : ''; ?> 45 <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'> 46 <th scope="row"><?php echo $post->ID; ?></th> 47 <td> 48 <?php echo $pad; ?><?php the_title() ?> 49 </td> 50 <td><?php the_author() ?></td> 51 <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td> 52 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> 53 <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td> 54 <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td> 55 </tr> 56 <?php 57 endforeach; 58 } else { 59 page_rows(); 60 } 61 ?> 28 62 </table> 29 63 -
trunk/wp-admin/edit.php
r3202 r3303 66 66 printf(__('Search for “%s”'), wp_specialchars($_GET['s']) ); 67 67 } else { 68 if ( ! is_paged() || get_query_var('paged') == 1 ) 68 if ( is_single() ) 69 printf(__('Comments on %s'), $post->post_title); 70 elseif ( ! is_paged() || get_query_var('paged') == 1 ) 69 71 _e('Last 15 Posts'); 70 72 else -
trunk/wp-admin/inline-uploading.php
r3295 r3303 26 26 $images_width = 1; 27 27 28 function get_udims($width, $height) {29 if ( $height <= 96 && $width <= 128 )30 return array($width, $height);31 elseif ( $width / $height > 4 / 3 )32 return array(128, (int) ($height / $width * 128));33 else34 return array((int) ($width / $height * 96), 96);35 }36 37 28 switch($action) { 38 29 case 'delete': … … 56 47 57 48 $url = $file['url']; 49 $type = $file['type']; 58 50 $file = $file['file']; 59 51 $filename = basename($file); … … 65 57 'post_status' => 'attachment', 66 58 'post_parent' => $post, 67 'post_mime_type' => $ _FILES['image']['type'],59 'post_mime_type' => $type, 68 60 'guid' => $url 69 61 ); … … 80 72 $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'"; 81 73 $imagedata['file'] = $file; 82 $imagedata['thumb'] = "thumb-$filename";83 74 84 75 add_post_meta($id, '_wp_attachment_metadata', $imagedata); … … 86 77 if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) { 87 78 if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 ) 88 $ error= wp_create_thumbnail($file, 128);79 $thumb = wp_create_thumbnail($file, 128); 89 80 elseif ( $imagedata['height'] > 96 ) 90 $error = wp_create_thumbnail($file, 96); 81 $thumb = wp_create_thumbnail($file, 96); 82 83 if ( @file_exists($thumb) ) { 84 $newdata = $imagedata; 85 $newdata['thumb'] = basename($thumb); 86 update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata); 87 } else { 88 $error = $thumb; 89 } 91 90 } 92 91 } else { … … 163 162 $__using_thumbnail = __('Using Thumbnail'); 164 163 $__using_original = __('Using Original'); 164 $__using_title = __('Using Title'); 165 $__using_filename = __('Using Filename'); 166 $__using_icon = __('Using Icon'); 165 167 $__no_thumbnail = '<del>'.__('No Thumbnail').'</del>'; 166 168 $__send_to_editor = __('Send to editor'); … … 174 176 usingthumbnail = '$__using_thumbnail'; 175 177 usingoriginal = '$__using_original'; 178 usingtitle = '$__using_title'; 179 usingfilename = '$__using_filename'; 180 usingicon = '$__using_icon'; 176 181 var aa = new Array(); 177 182 var ab = new Array(); … … 180 185 var srca = new Array(); 181 186 var srcb = new Array(); 187 var title = new Array(); 188 var filename = new Array(); 189 var icon = new Array(); 182 190 "; 183 191 foreach ( $attachments as $key => $attachment ) { … … 194 202 $attachment = array_merge($attachment, $meta); 195 203 $send_delete_cancel = "<a onclick=\"sendToEditor({$ID});return false;\" href=\"javascript:void()\">$__send_to_editor</a> 196 < a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&attachment={$ID}&all=$all&start=$start&post=$post\">$__delete</a>204 <!--<a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&attachment={$ID}&all=$all&start=$start&post=$post\">$__delete</a>--> 197 205 <a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a> 198 206 "; … … 235 243 "; 236 244 } else { 237 $script .= "aa[{$ID}] = '<a id=\"{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$attachment['post_title']}\">{$attachment['post_title']}</a>'; 238 ab[{$ID}] = '<a id=\"{$ID}\" href=\"{$attachment['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$attachment['post_title']}\">{$attachment['post_title']}</a>'; 245 $title = $attachment['post_title']; 246 $filename = basename($attachment['guid']); 247 if ( $icon = get_attachment_icon($ID) ) 248 $toggle_icon = "<a id=\"I{$ID}\" onclick=\"toggleOtherIcon({$ID});return false;\" href=\"javascript:void()\">$__using_title</a>"; 249 $script .= "aa[{$ID}] = '<a id=\"{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">{$attachment['post_title']}</a>'; 250 ab[{$ID}] = '<a id=\"{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">{$attachment['post_title']}</a>'; 251 title[{$ID}] = '{$attachment['post_title']}'; 252 filename[{$ID}] = '{$filename}'; 253 icon[{$ID}] = '{$icon}'; 239 254 "; 240 255 $html .= "<div id='target{$ID}' class='attwrap left'> 241 <div id='div{$ID}' class='otherwrap ' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">256 <div id='div{$ID}' class='otherwrap usingtext' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\"> 242 257 <a id=\"{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$attachment['post_title']}</a> 243 258 </div> … … 247 262 <div class='filetype'>".__('File Type:').' '.str_replace('/',"/\n",$attachment['post_mime_type'])."</div> 248 263 <a id=\"L{$ID}\" onclick=\"toggleOtherLink({$ID});return false;\" href=\"javascript:void()\">$__linked_to_file</a> 264 {$toggle_icon} 249 265 {$send_delete_cancel} 250 266 </div> … … 321 337 od=document.getElementById('div'+n); 322 338 ol=document.getElementById('L'+n); 339 oi=document.getElementById(n); 340 ih=oi.innerHTML; 323 341 if ( ol.innerHTML == linkedtofile ) { 324 342 od.innerHTML = aa[n]; … … 328 346 ol.innerHTML = linkedtofile; 329 347 } 348 oi=document.getElementById(n); 349 oi.innerHTML = ih; 330 350 } 331 351 function toggleImage(n) { … … 339 359 oi.innerHTML = usingthumbnail; 340 360 } 361 } 362 function toggleOtherIcon(n) { 363 od = document.getElementById('div'+n); 364 o = document.getElementById(n); 365 oi = document.getElementById('I'+n); 366 if ( oi.innerHTML == usingtitle ) { 367 o.innerHTML = filename[n]; 368 oi.innerHTML = usingfilename; 369 } else if ( oi.innerHTML == usingfilename ) { 370 o.innerHTML = icon[n]; 371 oi.innerHTML = usingicon; 372 } else { 373 o.innerHTML = title[n]; 374 oi.innerHTML = usingtitle; 375 } 376 if ( oi.innerHTML == usingicon ) 377 od.className = 'otherwrap usingicon'; 378 else 379 od.classname = 'otherwrap usingtext'; 341 380 } 342 381 … … 402 441 .otherwrap { 403 442 margin-right: 5px; 404 height: 90px;405 443 overflow: hidden; 406 444 background-color: #f9fcfe; 407 445 float: left; 408 padding: 3px;409 446 } 410 447 .otherwrap a { 411 448 display: block; 412 width: 122px;413 449 } 414 450 .otherwrap a, .otherwrap a:hover, .otherwrap a:active, .otherwrap a:visited { 415 451 color: blue; 452 } 453 .usingicon { 454 padding: 0px; 455 height: 96px; 456 text-align: center; 457 } 458 .usingicon a { 459 width: 128px; 460 } 461 .usingtext { 462 padding: 3px; 463 height: 90px; 464 text-align: left; 465 } 466 .usingtext a { 467 width: 122px; 416 468 } 417 469 .filetype { -
trunk/wp-admin/post.php
r3262 r3303 75 75 if ($post->post_status == 'static') 76 76 include('edit-page-form.php'); 77 elseif ($post->post_status == 'attachment') 78 include('edit-attachment-form.php'); 77 79 else 78 80 include('edit-form-advanced.php'); … … 85 87 <?php 86 88 break; 89 90 case 'editattachment': 91 $post_id = (int) $_POST['post_ID']; 92 93 // Don't let these be changed 94 unset($_POST['guid']); 95 $_POST['post_status'] = 'attachment'; 96 97 // Update the thumbnail filename 98 $oldmeta = $newmeta = get_post_meta($post_id, '_wp_attachment_metadata', true); 99 $newmeta['thumb'] = $_POST['thumb']; 100 101 if ( '' !== $oldmeta ) 102 update_post_meta($post_id, '_wp_attachment_metadata', $newmeta, $oldmeta); 103 else 104 add_post_meta($post_id, '_wp_attachment_metadata', $newmeta); 87 105 88 106 case 'editpost': … … 99 117 if ( $_POST['referredby'] == 'redo' ) 100 118 $location = get_permalink( $post_ID ); 119 } elseif ($action == 'editattachment') { 120 $location = 'attachments.php'; 101 121 } else { 102 122 $location = 'post.php'; … … 111 131 112 132 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 133 134 $post = & get_post($post_id); 113 135 114 136 if ( !current_user_can('edit_post', $post_id) ) 115 137 die( __('You are not allowed to delete this post.') ); 116 138 117 if ( ! wp_delete_post($post_id))139 if ( (($post->post_status != 'attachment') && !wp_delete_post($post_id)) || !wp_delete_attachment($post_id)) 118 140 die( __('Error in deleting...') ); 119 141 120 142 $sendback = $_SERVER['HTTP_REFERER']; 121 143 if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php'; 144 elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php'; 122 145 $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); 123 146 header ('Location: ' . $sendback); -
trunk/wp-admin/wp-admin.css
r3283 r3303 162 162 width: 100%; 163 163 overflow-y: hidden; 164 } 165 166 form#upload th { 167 text-align: right; 168 } 169 170 form#upload #post_content, form#upload #post_title { 171 width: 250px; 172 } 173 174 form#upload #post_content { 175 height: 50px; 176 } 177 178 .attpreview { 179 width: 1px; /* hug */ 180 text-align: center; 164 181 } 165 182 … … 390 407 } 391 408 392 #titlediv {409 #titlediv, #guiddiv { 393 410 margin: 0 8px 0 0; 394 411 padding: 0px; … … 410 427 } 411 428 412 #titlediv input {429 #titlediv input, #guiddiv input { 413 430 margin: 0px; 414 431 width: 100%; … … 457 474 } 458 475 459 #postexcerpt div {476 #postexcerpt div, #attachmentlinks div { 460 477 margin-right: 8px; 461 478 } 462 479 463 * html #postexcerpt .dbx-toggle-open { 480 #attachmentlinks textarea { 481 width: 100%; 482 height: 2.5em; 483 margin-bottom: 6px; 484 } 485 486 * html #postexcerpt .dbx-toggle-open, * html #postexcerpt .dbx-toggle-open { 464 487 padding-right: 8px; 465 488 } 466 489 467 #excerpt {490 #excerpt, .attachmentlinks { 468 491 margin: 0px; 469 492 height: 4em; … … 734 757 } 735 758 736 #slugdiv input, #passworddiv input, #authordiv select {759 #slugdiv input, #passworddiv input, #authordiv select, #thumbdiv input, #parentdiv input { 737 760 margin-top: .5em; 738 761 width: 90%; -
trunk/wp-content/themes/default/attachment.php
r3251 r3303 12 12 <h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> » <a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2> 13 13 <div class="entrytext"> 14 <?php $type = explode('/', $post->post_mime_type); 15 switch ( $type[0] ) { 16 case 'image' : 17 $meta = get_post_meta($post->ID, '_wp_attachment_metadata', true); 18 if ($meta['width'] > 450) : ?> 19 <p><a href="<?php echo $post->guid; ?>" title="<?php echo $post->post_title.': '.$meta['width'].'x'.$meta['height'] ?>"><img class="centered" src="<?php echo $post->guid; ?>" alt="<?php the_title(); ?>" style="width:450px;" /></a></p> 20 <?php else : ?> 21 <p><img class="centered" src="<?php echo $post->guid; ?>" alt="<?php the_title(); ?>" /></p> 22 <?php endif; 23 break; 24 default : 25 ?> 26 <p><a href="<?php echo $post->guid; ?>"><?php echo basename($post->guid); ?></a></p> 27 <?php 28 } 29 ?> 14 <p class="<?php $link = get_the_attachment_link($post->ID, true, array(450, 800)); /* Doing this now populates the imagesize stuff */ echo $post->iconsize[0] <= 128 ? 'small' : ''; ?>attachment"><?php echo get_the_attachment_link($post->ID, true, array(450, 800)); ?><br /><?php echo basename($post->guid); ?></p> 15 30 16 <?php the_content('<p class="serif">Read the rest of this entry »</p>'); ?> 31 17 -
trunk/wp-content/themes/default/style.css
r2274 r3303 264 264 margin: 30px 0; 265 265 } 266 266 267 .widecolumn .smallattachment { 268 text-align: center; 269 float: left; 270 width: 128px; 271 margin: 5px 5px 5px 0px; 272 } 273 274 .widecolumn .attachment { 275 text-align: center; 276 margin: 5px 0px; 277 } 278 279 .postmetadata { 280 clear: left; 281 } 282 267 283 #footer { 268 284 padding: 0 0 0 1px; -
trunk/wp-includes/classes.php
r3300 r3303 98 98 $qv['attachment_id'] = $qv['subpost_id']; 99 99 100 if ( ('' != $qv['attachment']) || $qv['attachment_id'] ) {100 if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) { 101 101 $this->is_single = true; 102 102 $this->is_attachment = true; 103 } 104 105 if ('' != $qv['name']) { 103 } elseif ('' != $qv['name']) { 106 104 $this->is_single = true; 107 105 } elseif ( $qv['p'] ) { … … 116 114 } elseif (!empty($qv['s'])) { 117 115 $this->is_search = true; 116 switch ($qv['show_post_type']) { 117 case 'page' : 118 $this->is_page = true; 119 break; 120 case 'attachment' : 121 $this->is_attachment = true; 122 break; 123 } 118 124 } else { 119 125 // Look for archive queries. Dates, categories, authors. … … 198 204 if ( ($this->is_date || $this->is_author || $this->is_category)) { 199 205 $this->is_archive = true; 206 } 207 208 if ( 'attachment' == $qv['show_post_type'] ) { 209 $this->is_attachment = true; 200 210 } 201 211 } … … 1414 1424 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id'); 1415 1425 1416 var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging' );1426 var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'show_post_type'); 1417 1427 1418 1428 var $query_vars; -
trunk/wp-includes/functions-post.php
r3291 r3303 209 209 } 210 210 211 function wp_insert_attachment($object, $file , $post_parent = 0) {211 function wp_insert_attachment($object, $file = false, $post_parent = 0) { 212 212 global $wpdb, $user_ID; 213 213 214 214 if ( is_object($object) ) 215 215 $object = get_object_vars($object); 216 216 217 217 // Export array as variables 218 218 extract($object); … … 321 321 wp_set_post_cats('', $post_ID, $post_category); 322 322 323 add_post_meta($post_ID, '_wp_attached_file', $file); 323 if ( $file ) 324 add_post_meta($post_ID, '_wp_attached_file', $file); 324 325 325 326 clean_post_cache($post_ID); … … 344 345 return false; 345 346 346 $meta = get_post_meta($postid, ' imagedata', true);347 $meta = get_post_meta($postid, '_wp_attachment_metadata', true); 347 348 $file = get_post_meta($postid, '_wp_attached_file', true); 348 349 … … 355 356 $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid"); 356 357 357 if ( ! empty($meta['file']) ) 358 @ unlink($meta['file']); 358 if ( ! empty($meta['thumb']) ) { 359 // Don't delete the thumb if another attachment uses it 360 if (! $foo = $wpdb->get_row("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%".$wpdb->escape($meta['thumb'])."%' AND post_id <> $postid")) 361 @ unlink(str_replace(basename($file), $meta['thumb'], $file)); 362 } 359 363 360 364 if ( ! empty($file) ) … … 429 433 $postarr['post_date_gmt'] = ''; 430 434 } 435 436 if ($postarr['post_status'] == 'attachment') 437 return wp_insert_attachment($postarr); 431 438 432 439 return wp_insert_post($postarr); … … 511 518 if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") ) 512 519 return $post; 520 521 if ( 'attachment' == $post->post_status ) 522 return wp_delete_attachment($postid); 513 523 514 524 do_action('delete_post', $postid); -
trunk/wp-includes/functions.php
r3298 r3303 504 504 $original_prev = $prev_value; 505 505 if ( is_array($prev_value) || is_object($prev_value) ) 506 $prev_value = serialize($value);506 $prev_value = $wpdb->escape(serialize($prev_value)); 507 507 508 508 if (! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key -
trunk/wp-includes/template-functions-links.php
r3122 r3303 210 210 get_currentuserinfo(); 211 211 212 if ( !user_can_edit_post($user_ID, $post->ID) || is_attachment()) {212 if ( !user_can_edit_post($user_ID, $post->ID) ) { 213 213 return; 214 214 } 215 215 216 $location = get_settings('siteurl') . "/wp-admin/post.php?action=edit&post=$post->ID"; 216 if ( is_attachment() ) 217 $file = 'attachments'; 218 else 219 $file = 'post'; 220 221 $location = get_settings('siteurl') . "/wp-admin/{$file}.php?action=edit&post=$post->ID"; 217 222 echo $before . "<a href=\"$location\">$link</a>" . $after; 218 223 } -
trunk/wp-includes/template-functions-post.php
r3229 r3303 440 440 } 441 441 442 function prepend_attachment($content) { 443 global $post; 444 445 $p = '<p class="attachment">'; 446 447 if ( '' != $post->guid ) { 448 if ( substr($post->post_mime_type, 0, 6) == 'image/' ) 449 $p .= '<a href="' . $post->guid . '" title="Click for full-size image" ><img class="attachmentimage" src="' . $post->guid . '" alt="' . $post->post_title . '" /></a>'; 450 else 451 $p .= __('Attachment') . ' (' . $post->post_mime_type . ')'; 442 function the_attachment_link($id = 0, $fullsize = false, $max_dims = false) { 443 echo get_the_attachment_link($id, $fullsize, $max_dims); 444 } 445 446 function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false) { 447 $id = (int) $id; 448 $_post = & get_post($id); 449 450 if ( ('attachment' != $_post->post_status) || ('' == $_post->guid) ) 451 return __('Missing Attachment'); 452 453 if (! empty($_post->guid) ) { 454 $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims); 455 456 return "<a href=\"{$_post->guid}\" title=\"{$_post->post_title}\" >{$innerHTML}</a>"; 457 452 458 } else { 453 459 $p .= __('Missing attachment'); 454 460 } 455 461 return $p; 462 } 463 464 function get_attachment_icon($id = 0, $fullsize = false, $max_dims = false) { 465 $id = (int) $id; 466 $post = & get_post($id); 467 468 $mime = $post->post_mime_type; 469 470 $imagedata = get_post_meta($post->ID, '_wp_attachment_metadata', true); 471 472 $file = get_post_meta($post->ID, '_wp_attached_file', true); 473 474 if ( !$fullsize && !empty($imagedata['thumb']) 475 && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) 476 && file_exists($thumbfile) ) { 477 478 // We have a thumbnail desired, specified and existing 479 480 $src = str_replace(basename($post->guid), $imagedata['thumb'], $post->guid); 481 $src_file = $thumbfile; 482 $class = 'attachmentthumb'; 483 484 } elseif ( substr($mime, 0, 6) == 'image/' 485 && file_exists($file) ) { 486 487 // We have an image without a thumbnail 488 489 $src = $post->guid; 490 $src_file = & $file; 491 $class = 'attachmentimage'; 492 } elseif (! empty($mime) ) { 493 494 // No thumb, no image. We'll look for a mime-related icon instead. 495 $icon_dir = apply_filters('icon_dir', get_template_directory().'/images'); 496 $icon_dir_uri = apply_filters('icon_dir_uri', get_template_directory_uri().'/images'); 497 498 $types = array(substr($mime, 0, strpos($mime, '/')), substr($mime, strpos($mime, '/') + 1), str_replace('/', '_', $mime)); 499 $exts = array('jpg', 'gif', 'png'); 500 foreach ($types as $type) { 501 foreach ($exts as $ext) { 502 $src_file = "$icon_dir/$type.$ext"; 503 if ( file_exists($src_file) ) { 504 $src = "$icon_dir_uri/$type.$ext"; 505 break 2; 506 } 507 } 508 } 509 } 510 511 if (! isset($src) ) 512 return false; 513 514 // Do we need to constrain the image? 515 if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) { 516 517 $imagesize = getimagesize($src_file); 518 519 if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) { 520 $actual_aspect = $imagesize[0] / $imagesize[1]; 521 $desired_aspect = $max_dims[0] / $max_dims[1]; 522 523 if ( $actual_aspect >= $desired_aspect ) { 524 $height = $actual_aspect * $max_dims[0]; 525 $constraint = "width=\"{$max_dims[0]}\" "; 526 $post->iconsize = array($max_dims[0], $height); 527 } else { 528 $width = $max_dims[1] / $actual_aspect; 529 $constraint = "height=\"{$max_dims[1]}\" "; 530 $post->iconsize = array($width, $max_dims[1]); 531 } 532 } else { 533 $post->iconsize = array($imagesize[0], $imagesize[1]); 534 } 535 } 536 537 $icon = "<img src=\"{$src}\" title=\"{$post->post_title}\" {$constraint}/>"; 538 539 return apply_filters('attachment_icon', $icon, $post->ID); 540 } 541 542 function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { 543 $id = (int) $id; 544 545 if ( $innerHTML = get_attachment_icon($id, $fullsize, $max_dims)) 546 return $innerHTML; 547 548 $post = & get_post($id); 549 550 $innerHTML = $post->post_title; 551 552 return apply_filters('attachment_innerHTML', $innerHTML, $post->ID); 553 } 554 555 function prepend_attachment($content) { 556 $p = '<p class="attachment">'; 557 $p .= get_the_attachment_link(false, true, array(400, 300)); 456 558 $p .= '</p>'; 559 $p = apply_filters('prepend_attachment', $p); 457 560 458 561 return "$p\n$content"; 459 562 } 563 460 564 ?>
Note: See TracChangeset
for help on using the changeset viewer.