Changeset 2926
- Timestamp:
- 09/30/2005 10:42:26 PM (21 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 4 edited
-
admin-functions.php (modified) (1 diff)
-
edit-form-advanced.php (modified) (1 diff)
-
image-uploading.php (modified) (7 diffs)
-
wp-admin.css (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r2923 r2926 1790 1790 } 1791 1791 1792 $uploads = array('path' => $pathym, 'url' => get_bloginfo('home') . "/$dir/$y/$m", 'error' => false);1792 $uploads = array('path' => $pathym, 'url' => get_option('siteurl') . "/$dir/$y/$m", 'error' => false); 1793 1793 return apply_filters('upload_dir', $uploads); 1794 1794 } -
trunk/wp-admin/edit-form-advanced.php
r2921 r2926 173 173 <?php do_action('edit_form_advanced'); ?> 174 174 175 <iframe border="0" src="image-uploading.php?action=view&post=<?php echo 0 == $post_ID ? $temp_ID : $post_ID; ?>" id="imageup">This feature requires iframe support.</iframe> 176 175 177 <div id="advancedstuff" class="dbx-group" > 176 177 <fieldset id="imageuploading" class="dbx-box">178 <h3 class="dbx-handle"><?php _e('Image Uploading') ?></h3>179 <div class="dbx-content"><iframe src="image-uploading.php?action=view&post=<?php echo 0 == $post_ID ? $temp_ID : $post_ID; ?>" id="imageup"></iframe></div>180 </fieldset>181 178 182 179 <fieldset id="postexcerpt" class="dbx-box"> -
trunk/wp-admin/image-uploading.php
r2921 r2926 1 1 <?php 2 2 3 require_once('admin.php'); 3 4 … … 23 24 24 25 $post = (int) $post; 26 $images_width = 1; 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 else 34 return array((int) ($width / $height * 96), 96); 35 } 25 36 26 37 switch($action) { … … 114 125 $imagedata['width'] = $imagesize['0']; 115 126 $imagedata['height'] = $imagesize['1']; 116 if ( $imagedata['height'] < 96 && $imagedata['width'] < 128 ) { 117 $uheight = $imagedata['height']; 118 $uwidth = $imagedata['width']; 119 } elseif ( $imagedata['width'] / $imagedata['height'] > 4 / 3 ) { 120 $uwidth = 128; 121 $uheight = $imagedata['height'] / $imagedata['width'] * $uwidth; 122 } else { 123 $uheight = 96; 124 $uwidth = $imagedata['width'] / $imagedata['height'] * $uheight; 125 } 127 list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']); 126 128 $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'"; 127 129 $imagedata['file'] = $file; … … 134 136 135 137 case 'upload': 136 ?> 137 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 138 <html xmlns="http://www.w3.org/1999/xhtml"> 139 <head> 140 <script type="text/javascript"> 141 function validateImageName() { 142 /* This is more for convenience than security. Server-side validation is very thorough.*/ 143 obj = document.getElementById('upload'); 144 r = /.jpg$|.gif$|.png$/i; 145 if ( obj.value.match(r) ) 146 return true; 147 alert('Please select a JPG, PNG or GIF file.'); 148 obj.parentNode.reset(); 149 return false; 150 } 151 function cancelUpload() { 152 o = document.getElementById('uploadForm'); 153 o.method = 'GET'; 154 o.action.value = 'view'; 155 o.submit(); 156 } 157 </script> 158 <style type="text/css"> 159 label { 160 float: left; 161 width: 18%; 162 } 163 #title, #descr { 164 width: 80%; 165 margin-top: 2px; 166 } 167 #descr { 168 height: 3em; 169 v-align: top; 170 } 171 #buttons { 172 width: 98%; 173 text-align: right; 174 } 175 </style> 176 </head> 177 <body> 178 <form enctype="multipart/form-data" id="uploadForm" method="POST" action="image-uploading.php" onsubmit="return validateImageName()"> 179 <label for="upload">Image:</label><input type="file" id="upload" name="image" onchange="validateImageName()" /><br /> 180 <label for="title">Title:</label><input type="text" id="title" name="imgtitle" /><br /> 181 <label for="descr">Description:</label><input type="textarea" name="descr" id="descr" value="" /><br /> 182 <input type="hidden" name="action" value="save" /> 183 <input type="hidden" name="post" value="<?php echo $post; ?>" /> 184 <input type="hidden" name="all" value="<?php echo $all; ?>" /> 185 <div id="buttons"> 186 <input type="submit" value="Upload" /> 187 <input type="button" value="Cancel" onclick="cancelUpload()" /> 188 </div> 189 </form> 190 </body> 191 </html> 192 <?php 193 138 139 $current_1 = ' class="current"'; 140 $back = $next = false; 194 141 break; 195 142 196 143 case 'view': 197 144 198 if ( $post && empty($all) ) 145 // How many images do we show? How many do we query? 146 $num = 5; 147 $double = $num * 2; 148 149 if ( $post && empty($all) ) { 199 150 $and_post = "AND post_parent = '$post'"; 151 $current_2 = ' class="current"'; 152 } else { 153 $current_3 = ' class="current"'; 154 } 200 155 201 156 if ( $last ) 202 $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'object' AND left(post_type, 5) = 'image' $and_post") - 5;157 $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'object' AND left(post_type, 5) = 'image' $and_post") - $num; 203 158 else 204 159 $start = (int) $start; … … 210 165 $sort = "ID"; 211 166 212 $images = $wpdb->get_results("SELECT ID, post_date, post_title, guid FROM $wpdb->posts WHERE post_status = 'object' AND left(post_type, 5) = 'image' $and_post ORDER BY $sort LIMIT $start, 10", ARRAY_A); 213 214 //if ( count($images) == 0 ) 215 // header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=upload"); 216 217 if ( count($images) > 5 ) { 218 $next = $start + count($images) - 5; 167 $images = $wpdb->get_results("SELECT ID, post_date, post_title, guid FROM $wpdb->posts WHERE post_status = 'object' AND left(post_type, 5) = 'image' $and_post ORDER BY $sort LIMIT $start, $double", ARRAY_A); 168 169 if ( count($images) > $num ) { 170 $next = $start + count($images) - $num; 219 171 } else { 220 172 $next = false; … … 222 174 223 175 if ( $start > 0 ) { 224 $back = $start - 5;176 $back = $start - $num; 225 177 if ( $back < 1 ) 226 178 $back = '0'; … … 229 181 } 230 182 183 $uwidth_sum = 0; 184 $images_html = ''; 185 if ( count($images) > 0 ) { 186 $images = array_slice( $images, 0, $num ); 187 foreach ( $images as $key => $image ) { 188 $image = array_merge($image, get_post_meta($image['ID'], 'imagedata', true) ); 189 list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']); 190 $uwidth_sum += $image['uwidth']; 191 $images_html .= "<div class='image left'><a href='{$image['guid']}' onclick='return false;' title='{$image['post_title']}'><img src='{$image['guid']}' alt='{$image['post_title']}' {$image['hwstring_small']} /></a></div>\n"; 192 } 193 } 194 195 $images_width = $uwidth_sum + ( count($images) * 5 ) + 15; 196 197 break; 198 199 default: 200 die('This script was not meant to be called directly.'); 201 } 202 231 203 ?> 232 204 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 233 205 <html xmlns="http://www.w3.org/1999/xhtml"> 234 206 <head> 235 <style type="text/css"> 236 form { 237 display: inline; 238 } 239 #images, #buttons { 240 position: absolute; 241 left: 0px; 242 width: 98%; 243 text-align: center; 244 } 245 #images { 246 top: 0px; 247 } 248 #buttons { 249 top: 112px; 250 } 251 </style> 207 <meta http-equiv="imagetoolbar" content="no" /> 208 <script type="text/javascript"> 209 function validateImageName() { 210 /* This is more for convenience than security. Server-side validation is very thorough.*/ 211 obj = document.getElementById('upload'); 212 r = /.jpg$|.gif$|.png$/i; 213 if ( obj.value.match(r) ) 214 return true; 215 alert('Please select a JPG, PNG or GIF file.'); 216 return false; 217 } 218 function cancelUpload() { 219 o = document.getElementById('uploadForm'); 220 o.method = 'GET'; 221 o.action.value = 'view'; 222 o.submit(); 223 } 224 </script> 225 <style type="text/css"> 226 body { 227 font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana; 228 border: none; 229 margin: 0px; 230 height: 150px; 231 background: rgb(223, 232, 241); 232 } 233 form { 234 margin: 6px 2px 0px 6px; 235 } 236 #wrap { 237 clear: both; 238 margin: 0px; 239 padding: 0px; 240 height: 133px; 241 width: 100%; 242 overflow: auto; 243 } 244 #images { 245 clear: both; 246 margin: 0px; 247 padding: 5px 5px; 248 height: 100px; 249 width: <?php echo $images_width; ?>px; 250 } 251 .image { 252 margin-right: 5px; 253 } 254 .image * { 255 margin: 0px; 256 padding: 0px; 257 border: 0px; 258 } 259 .image a, .image a img, .image a:hover img, .image a:visited img, .image a:active img { 260 text-decoration: none; 261 float: left; 262 display: block; 263 text-align: center; 264 } 265 #menu { 266 margin: 0px; 267 list-style: none; 268 background: rgb(109, 166, 209); 269 padding: 4px 0px 0px 8px; 270 text-align: left; 271 border-bottom: 3px solid rgb(68, 138, 189); 272 } 273 #menu li { 274 display: inline; 275 margin: 0px; 276 } 277 #menu a, #menu a:visited, #menu a:active { 278 padding: 1px 3px 3px; 279 text-decoration: none; 280 color: #345; 281 background: transparent; 282 } 283 #menu a:hover { 284 background: rgb(203, 214, 228); 285 color: #000; 286 } 287 #menu .current a, #menu .current a:hover, #menu .current a:visited, #menu .current a:active { 288 background: rgb(223, 232, 241); 289 color: #000; 290 border-right: 2px solid rgb(20, 86, 138); 291 } 292 .tip { 293 color: rgb(109, 166, 209); 294 padding: 1px 3px; 295 } 296 .inactive { 297 color: #68a; 298 padding: 1px 3px; 299 } 300 .left { 301 float: left; 302 } 303 .right { 304 float: right; 305 } 306 .center { 307 text-align: center; 308 } 309 #menu li.spacer { 310 margin-left: 40px; 311 } 312 label { 313 float: left; 314 width: 18%; 315 } 316 #title, #descr { 317 width: 80%; 318 margin-top: 2px; 319 } 320 #descr { 321 height: 35px; 322 v-align: top; 323 } 324 #buttons { 325 width: 98%; 326 margin-top: 2px; 327 text-align: right; 328 } 329 </style> 252 330 </head> 253 331 <body> 254 <div id="images"> 255 <?php 256 if ( count($images) > 0 ) { 257 $imagerow = ''; 258 $i = 1; 259 foreach ( $images as $image ) { 260 if ( $i++ > 5 ) break; 261 $image = array_merge($image, get_post_meta($image['ID'], 'imagedata', true) ); 262 ?> 263 <a href="<?php echo $image['guid']; ?>" disabled="true"> 264 <img src="<?php echo $image['guid']; ?>" alt="<?php echo $image['post_title']; ?>" <?php echo $image['hwstring_small']; ?> /> 265 </a> 266 <?php 267 } 268 } 269 ?> 270 <div> 271 <div id="buttons"> 272 <form action="image-uploading.php" method="GET"> 273 <input type="hidden" name="action" value="view" /> 274 <input type="hidden" name="all" value="<?php echo $all; ?>" /> 275 <input type="hidden" name="post" value="<?php echo $post; ?>" /> 276 <input type="hidden" name="start" value="0" /> 277 <input type="submit" value="| < <" <?php if ( false === $back ) echo 'disabled="true" ' ?>/> 278 </form> 279 <form action="image-uploading.php" method="GET"> 280 <input type="hidden" name="action" value="view" /> 281 <input type="hidden" name="all" value="<?php echo $all; ?>" /> 282 <input type="hidden" name="post" value="<?php echo $post; ?>" /> 283 <input type="hidden" name="start" value="<?php echo $back; ?>" /> 284 <input type="submit" value="< < < < <" <?php if ( false === $back ) echo 'disabled="true" ' ?>/> 285 </form> 286 <form action="image-uploading.php" method="GET"> 287 <input type="hidden" name="action" value="upload" /> 288 <input type="hidden" name="all" value="<?php echo $all; ?>" /> 289 <input type="hidden" name="post" value="<?php echo $post; ?>" /> 290 <input type="submit" value="Upload New" /> 291 </form> 292 <?php if ( $all ) : ?> 293 <form action="image-uploading.php" method="GET"> 294 <input type="hidden" name="action" value="view" /> 295 <input type="hidden" name="all" value="" /> 296 <input type="hidden" name="post" value="<?php echo $post; ?>" /> 297 <input type="submit" value="Browse Attached" /> 298 </form> 332 <ul id="menu"> 333 <li<?php echo $current_1; ?>><a href="image-uploading.php?action=upload&post=<?php echo $post; ?>&all=<?php echo $all; ?>">Upload Photo</a></li> 334 <li<?php echo $current_2; ?>><a href="image-uploading.php?action=view&post=<?php echo $post; ?>">Browse Attached</a></li> 335 <li<?php echo $current_3; ?>><a href="image-uploading.php?action=view&post=<?php echo $post; ?>&all=true">Browse All</a></li> 336 <li> </li> 337 <?php if ( false !== $back ) : ?> 338 <li class="spacer"><a href="image-uploading.php?action=view&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=0" title="First">|<</a></li> 339 <li><a href="image-uploading.php?action=view&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=<?php echo $back; ?>" title="Back"><<</a></li> 299 340 <?php else : ?> 300 <form action="image-uploading.php" method="GET"> 301 <input type="hidden" name="action" value="view" /> 302 <input type="hidden" name="all" value="true" /> 303 <input type="hidden" name="post" value="<?php echo $post; ?>" /> 304 <input type="submit" value="Browse All" /> 305 </form> 341 <li class="inactive spacer">|<</li> 342 <li class="inactive"><<</li> 306 343 <?php endif; ?> 307 <form action="image-uploading.php" method="GET"> 308 <input type="hidden" name="action" value="view" /> 309 <input type="hidden" name="all" value="<?php echo $all; ?>" /> 310 <input type="hidden" name="post" value="<?php echo $post; ?>" /> 311 <input type="hidden" name="start" value="<?php echo $next; ?>" /> 312 <input type="submit" value="> > > > >" <?php if ( false === $next ) echo 'disabled="true" ' ?>/> 313 </form> 314 <form action="image-uploading.php" method="GET"> 315 <input type="hidden" name="action" value="view" /> 316 <input type="hidden" name="all" value="<?php echo $all; ?>" /> 317 <input type="hidden" name="post" value="<?php echo $post; ?>" /> 318 <input type="hidden" name="last" value="true" /> 319 <input type="submit" value="> > |" <?php if ( false === $next ) echo 'disabled="true" ' ?>/> 320 </form> 321 </div> 322 <?php // echo "<pre>".print_r($images,1)."</pre>"; 323 ?> 344 <?php if ( false !== $next ) : ?> 345 <li><a href="image-uploading.php?action=view&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=<?php echo $next; ?>" title="Next">>></a></li> 346 <li><a href="image-uploading.php?action=view&post=<?php echo $post; ?>&all=<?php echo $all; ?>&last=true" title="Last">>|</a></li> 347 <?php else : ?> 348 <li class="inactive">>></li> 349 <li class="inactive">>|</li> 350 <?php endif; ?> 351 </ul> 352 <?php if ( $action == 'view' ) : ?> 353 <span class="left tip">Drag and drop photos to post</span> 354 <span class="right tip">Click photos for more options</span> 355 <div id="wrap"> 356 <div id="images"> 357 <?php echo $images_html; ?> 358 </div> 359 </div> 360 <?php elseif ( $action = 'upload' ) : ?> 361 <div class="center tip">Duplicated filenames will be numbered (photo.jpg, photo1.jpg, etc.)</div> 362 <form enctype="multipart/form-data" id="uploadForm" method="POST" action="image-uploading.php" onsubmit="return validateImageName()"> 363 <label for="upload">Image:</label><input type="file" id="upload" name="image" onchange="validateImageName()" /> 364 <label for="title">Title:</label><input type="text" id="title" name="imgtitle" /> 365 <label for="descr">Description:</label><input type="textarea" name="descr" id="descr" value="" /> 366 <input type="hidden" name="action" value="save" /> 367 <input type="hidden" name="post" value="<?php echo $post; ?>" /> 368 <input type="hidden" name="all" value="<?php echo $all; ?>" /> 369 <div id="buttons"> 370 <input type="submit" value="Upload" /> 371 <input type="button" value="Cancel" onclick="cancelUpload()" /> 372 </div> 373 </form> 374 <?php endif; ?> 324 375 </body> 325 376 </html> 326 <?php327 die;328 329 default:330 die('This script was not meant to be called directly.');331 }332 ?> -
trunk/wp-admin/wp-admin.css
r2921 r2926 149 149 } 150 150 151 textarea, input, select , iframe#imageup{151 textarea, input, select { 152 152 background: #f4f4f4; 153 153 border: 1px solid #b2b2b2; … … 158 158 } 159 159 160 iframe#imageup {161 margin: 0px;160 #imageup { 161 border-style: none; 162 162 padding: 0px; 163 border: 1px solid #ccc; 164 height: 13em; 165 width: 98%; 163 margin-bottom: 16px; 164 height: 180px; 165 width: 100%; 166 overflow-y: hidden; 166 167 } 167 168
Note: See TracChangeset
for help on using the changeset viewer.