]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/inline-uploading.php
Wordpress 2.0.11-scripts
[autoinstalls/wordpress.git] / wp-admin / inline-uploading.php
1 <?php
2
3 require_once('admin.php');
4
5 header('Content-Type: text/html; charset=' . get_option('blog_charset'));
6
7 if (!current_user_can('upload_files'))
8         die(__('You do not have permission to upload files.'));
9
10 $wpvarstoreset = array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment');
11
12 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
13         $wpvar = $wpvarstoreset[$i];
14         if (!isset($$wpvar)) {
15                 if (empty($_POST["$wpvar"])) {
16                         if (empty($_GET["$wpvar"])) {
17                                 $$wpvar = '';
18                         } else {
19                         $$wpvar = $_GET["$wpvar"];
20                         }
21                 } else {
22                         $$wpvar = $_POST["$wpvar"];
23                 }
24         }
25 }
26
27 $all = ( 'true' == $all ) ? 'true' : 'false';
28 $start = (int) $start;
29 $post = (int) $post;
30 $images_width = 1;
31
32 switch($action) {
33 case 'links':
34 // Do not pass GO.
35 break;
36
37 case 'delete':
38
39 check_admin_referer('inlineuploading');
40
41 if ( !current_user_can('edit_post', (int) $attachment) )
42         die(__('You are not allowed to delete this attachment.').' <a href="'.basename(__FILE__)."?post=$post&amp;all=$all&amp;action=upload\">".__('Go back').'</a>');
43
44 wp_delete_attachment($attachment);
45
46 wp_redirect(basename(__FILE__) ."?post=$post&all=$all&action=view&start=$start");
47 die;
48
49 case 'save':
50
51 check_admin_referer('inlineuploading');
52
53 $overrides = array('action'=>'save');
54
55 $file = wp_handle_upload($_FILES['image'], $overrides);
56
57 if ( isset($file['error']) )
58         die($file['error'] . '<br /><a href="' . basename(__FILE__) . '?action=upload&post=' . $post . '">'.__('Back to Image Uploading').'</a>');
59
60 $url = $file['url'];
61 $type = $file['type'];
62 $file = $file['file'];
63 $filename = basename($file);
64
65 // Construct the attachment array
66 $attachment = array(
67         'post_title' => $imgtitle ? $imgtitle : $filename,
68         'post_content' => $descr,
69         'post_status' => 'attachment',
70         'post_parent' => $post,
71         'post_mime_type' => $type,
72         'guid' => $url
73         );
74
75 // Save the data
76 $id = wp_insert_attachment($attachment, $file, $post);
77
78 if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
79         // Generate the attachment's postmeta.
80         $imagesize = getimagesize($file);
81         $imagedata['width'] = $imagesize['0'];
82         $imagedata['height'] = $imagesize['1'];
83         list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
84         $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
85         $imagedata['file'] = $file;
86
87         add_post_meta($id, '_wp_attachment_metadata', $imagedata);
88
89         if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
90                 if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
91                         $thumb = wp_create_thumbnail($file, 128);
92                 elseif ( $imagedata['height'] > 96 )
93                         $thumb = wp_create_thumbnail($file, 96);
94
95                 if ( @file_exists($thumb) ) {
96                         $newdata = $imagedata;
97                         $newdata['thumb'] = basename($thumb);
98                         update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata);
99                 } else {
100                         $error = $thumb;
101                 }
102         }
103 } else {
104         add_post_meta($id, '_wp_attachment_metadata', array());
105 }
106
107 wp_redirect(basename(__FILE__) . "?post=$post&all=$all&action=view&start=0");
108 die();
109
110 case 'upload':
111
112 $current_1 = ' class="current"';
113 $back = $next = false;
114 break;
115
116 case 'view':
117
118 // How many images do we show? How many do we query?
119 $num = 5;
120 $double = $num * 2;
121
122 if ( $post && (empty($all) || $all == 'false') ) {
123         $and_post = "AND post_parent = '$post'";
124         $current_2 = ' class="current"';
125 } else {
126         $current_3 = ' class="current"';
127 }
128
129 if (! current_user_can('edit_others_posts') )
130         $and_user = "AND post_author = " . $user_ID;
131
132 if ( $last )
133         $start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment' $and_user $and_post") - $num;
134 else
135         $start = (int) $start;
136
137 if ( $start < 0 )
138         $start = 0;
139
140 if ( '' == $sort )
141         $sort = "post_date_gmt DESC";
142
143 $attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_status = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
144
145 if ( count($attachments) == 0 ) {
146         wp_redirect( basename(__FILE__) ."?post=$post&action=upload" );
147         die;
148 } elseif ( count($attachments) > $num ) {
149         $next = $start + count($attachments) - $num;
150 } else {
151         $next = false;
152 }
153
154 if ( $start > 0 ) {
155         $back = $start - $num;
156         if ( $back < 1 )
157                 $back = '0';
158 } else {
159         $back = false;
160 }
161
162 $uwidth_sum = 0;
163 $html = '';
164 $popups = '';
165 $style = '';
166 $script = '';
167 if ( count($attachments) > 0 ) {
168         $attachments = array_slice( $attachments, 0, $num );
169         $__delete = __('Delete');
170         $__not_linked = __('Not Linked');
171         $__linked_to_page = __('Linked to Page');
172         $__linked_to_image = __('Linked to Image');
173         $__linked_to_file = __('Linked to File');
174         $__using_thumbnail = __('Using Thumbnail');
175         $__using_original = __('Using Original');
176         $__using_title = __('Using Title');
177         $__using_filename = __('Using Filename');
178         $__using_icon = __('Using Icon');
179         $__no_thumbnail = '<del>'.__('No Thumbnail').'</del>';
180         $__send_to_editor = __('Send to editor');
181         $__close = __('Close Options');
182         $__confirmdelete = __('Delete this file from the server?');
183         $__nothumb = __('There is no thumbnail associated with this photo.');
184         $script .= "notlinked = '$__not_linked';
185 linkedtoimage = '$__linked_to_image';
186 linkedtopage = '$__linked_to_page';
187 linkedtofile = '$__linked_to_file';
188 usingthumbnail = '$__using_thumbnail';
189 usingoriginal = '$__using_original';
190 usingtitle = '$__using_title';
191 usingfilename = '$__using_filename';
192 usingicon = '$__using_icon';
193 var aa = new Array();
194 var ab = new Array();
195 var imga = new Array();
196 var imgb = new Array();
197 var srca = new Array();
198 var srcb = new Array();
199 var title = new Array();
200 var filename = new Array();
201 var icon = new Array();
202 ";
203         foreach ( $attachments as $key => $attachment ) {
204                 $ID = $attachment['ID'];
205                 $href = get_attachment_link($ID);
206                 $meta = get_post_meta($ID, '_wp_attachment_metadata', true);
207                 if (!is_array($meta)) {
208                         $meta = get_post_meta($ID, 'imagedata', true); // Try 1.6 Alpha meta key
209                         if (!is_array($meta)) {
210                                 $meta = array();
211                         }
212                         add_post_meta($ID, '_wp_attachment_metadata', $meta);
213                 }
214                 $attachment = array_merge($attachment, $meta);
215                 $noscript = "<noscript>
216                 <div class='caption'><a href=\"".basename(__FILE__)."?action=links&amp;attachment={$ID}&amp;post={$post}&amp;all={$all}&amp;start={$start}\">Choose Links</a></div>
217                 </noscript>
218 ";
219                 $send_delete_cancel = "<a onclick=\"sendToEditor({$ID});return false;\" href=\"javascript:void()\">$__send_to_editor</a>
220 <a onclick=\"return confirm('$__confirmdelete')\" href=\"" . wp_nonce_url( basename(__FILE__) . "?action=delete&amp;attachment={$ID}&amp;all=$all&amp;start=$start&amp;post=$post", inlineuploading) . "\">$__delete</a>
221                 <a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
222 ";
223                 $uwidth_sum += 128;
224                 if ( preg_match('!^image/!', $attachment['post_mime_type'] ) ) {
225                         $image = & $attachment;
226                         if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) {
227                                 $src = str_replace(basename($image['guid']), $image['thumb'], $image['guid']);
228                                 $script .= "srca[{$ID}] = '$src';
229 srcb[{$ID}] = '{$image['guid']}';
230 ";
231                                 $thumb = 'true';
232                                 $thumbtext = $__using_thumbnail;
233                         } else {
234                                 $src = $image['guid'];
235                                 $thumb = 'false';
236                                 $thumbtext = $__no_thumbnail;
237                         }
238                         list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']);
239                         $height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"';
240                         $xpadding = (128 - $image['uwidth']) / 2;
241                         $ypadding = (96 - $image['uheight']) / 2;
242                         $style .= "#target{$ID} img { padding: {$ypadding}px {$xpadding}px; }\n";
243                         $title = attribute_escape($image['post_title']);
244                         $script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" class=\"imagelink\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
245 ab[{$ID}] = '<a class=\"imagelink\" href=\"{$image['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
246 imga[{$ID}] = '<img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />';
247 imgb[{$ID}] = '<img id=\"image{$ID}\" src=\"{$image['guid']}\" alt=\"{$title}\" $height_width />';
248 ";
249                         $html .= "<div id='target{$ID}' class='attwrap left'>
250         <div id='div{$ID}' class='imagewrap' onclick=\"doPopup({$ID});\">
251                 <img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />
252         </div>
253         {$noscript}
254 </div>
255 ";
256                         $popups .= "<div id='popup{$ID}' class='popup'>
257         <a id=\"I{$ID}\" onclick=\"if($thumb)toggleImage({$ID});else alert('$__nothumb');return false;\" href=\"javascript:void()\">$thumbtext</a>
258         <a id=\"L{$ID}\" onclick=\"toggleLink({$ID});return false;\" href=\"javascript:void()\">$__not_linked</a>
259         {$send_delete_cancel}
260 </div>
261 ";
262                 } else {
263                         $title = attribute_escape($attachment['post_title']);
264                         $filename = basename($attachment['guid']);
265                         $icon = get_attachment_icon($ID);
266                         $toggle_icon = "<a id=\"I{$ID}\" onclick=\"toggleOtherIcon({$ID});return false;\" href=\"javascript:void()\">$__using_title</a>";
267                         $script .= "aa[{$ID}] = '<a id=\"p{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
268 ab[{$ID}] = '<a id=\"p{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">';
269 title[{$ID}] = '{$title}';
270 filename[{$ID}] = '{$filename}';
271 icon[{$ID}] = '{$icon}';
272 ";
273                         $html .= "<div id='target{$ID}' class='attwrap left'>
274         <div id='div{$ID}' class='otherwrap usingtext' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">
275                 <a id=\"p{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$title}</a>
276         </div>
277         {$noscript}
278 </div>
279 ";
280                         $popups .= "<div id='popup{$ID}' class='popup'>
281         <div class='filetype'>".__('File Type:').' '.str_replace('/',"/\n",$attachment['post_mime_type'])."</div>
282         <a id=\"L{$ID}\" onclick=\"toggleOtherLink({$ID});return false;\" href=\"javascript:void()\">$__linked_to_file</a>
283         {$toggle_icon}
284         {$send_delete_cancel}
285 </div>
286 ";
287                 }
288         }
289 }
290
291 $images_width = $uwidth_sum + ( count($images) * 6 ) + 35;
292
293 break;
294
295 default:
296 die(__('This script was not meant to be called directly.'));
297 }
298
299 ?>
300 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
301 <html xmlns="http://www.w3.org/1999/xhtml">
302 <head>
303 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
304 <title></title>
305 <meta http-equiv="imagetoolbar" content="no" />
306 <script type="text/javascript">
307 // <![CDATA[
308 /* Define any variables we'll need, such as alternate URLs. */
309 <?php echo $script; ?>
310 function htmldecode(st) {
311         o = document.getElementById('htmldecode');
312         if (! o) {
313                 o = document.createElement("A");
314                 o.id = "htmldecode"
315         }
316         o.innerHTML = st;
317         r = o.innerHTML;
318         return r;
319 }
320 function cancelUpload() {
321         o = document.getElementById('uploadForm');
322         o.method = 'GET';
323         o.action.value = 'view';
324         o.submit();
325 }
326 function doPopup(i) {
327         if ( popup )
328         popup.style.display = 'none';
329         target = document.getElementById('target'+i);
330         popup = document.getElementById('popup'+i);
331         popup.style.left = (target.offsetLeft) + 'px';
332         popup.style.top = (target.offsetTop) + 'px';
333         popup.style.display = 'block';
334 }
335 popup = false;
336 function selectLink(n) {
337         o=document.getElementById('div'+n);
338         if ( typeof document.body.createTextRange == 'undefined' || typeof win.tinyMCE == 'undefined' || win.tinyMCE.configs.length < 1 )
339                 return;
340         r = document.body.createTextRange();
341         if ( typeof r != 'undefined' ) {
342                 r.moveToElementText(o);
343                 r.select();
344         }
345 }
346 function toggleLink(n) {
347         ol=document.getElementById('L'+n);
348         if ( ol.innerHTML == htmldecode(notlinked) ) {
349                 ol.innerHTML = linkedtoimage;
350         } else if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
351                 ol.innerHTML = linkedtopage;
352         } else {
353                 ol.innerHTML = notlinked;
354         }
355         updateImage(n);
356 }
357 function toggleOtherLink(n) {
358         ol=document.getElementById('L'+n);
359         if ( ol.innerHTML == htmldecode(linkedtofile) ) {
360                 ol.innerHTML = linkedtopage;
361         } else {
362                 ol.innerHTML = linkedtofile;
363         }
364         updateOtherIcon(n);
365 }
366 function toggleImage(n) {
367         oi = document.getElementById('I'+n);
368         if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
369                 oi.innerHTML = usingoriginal;
370         } else {
371                 oi.innerHTML = usingthumbnail;
372         }
373         updateImage(n);
374 }
375 function toggleOtherIcon(n) {
376         od = document.getElementById('div'+n);
377         oi = document.getElementById('I'+n);
378         if ( oi.innerHTML == htmldecode(usingtitle) ) {
379                 oi.innerHTML = usingfilename;
380                 od.className = 'otherwrap usingtext';
381         } else if ( oi.innerHTML == htmldecode(usingfilename) && icon[n] != '' ) {
382                 oi.innerHTML = usingicon;
383                 od.className = 'otherwrap usingicon';
384         } else {
385                 oi.innerHTML = usingtitle;
386                 od.className = 'otherwrap usingtext';
387         }
388         updateOtherIcon(n);
389 }
390 function updateImage(n) {
391         od=document.getElementById('div'+n);
392         ol=document.getElementById('L'+n);
393         oi=document.getElementById('I'+n);
394         if ( oi.innerHTML == htmldecode(usingthumbnail) ) {
395                 img = imga[n];
396         } else {
397                 img = imgb[n];
398         }
399         if ( ol.innerHTML == htmldecode(linkedtoimage) ) {
400                 od.innerHTML = ab[n]+img+'</a>';
401         } else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
402                 od.innerHTML = aa[n]+img+'</a>';
403         } else {
404                 od.innerHTML = img;
405         }
406 }
407 function updateOtherIcon(n) {
408         od=document.getElementById('div'+n);
409         ol=document.getElementById('L'+n);
410         oi=document.getElementById('I'+n);
411         if ( oi.innerHTML == htmldecode(usingfilename) ) {
412                 txt = filename[n];
413         } else if ( oi.innerHTML == htmldecode(usingicon) ) {
414                 txt = icon[n];
415         } else {
416                 txt = title[n];
417         }
418         if ( ol.innerHTML == htmldecode(linkedtofile) ) {
419                 od.innerHTML = ab[n]+txt+'</a>';
420         } else if ( ol.innerHTML == htmldecode(linkedtopage) ) {
421                 od.innerHTML = aa[n]+txt+'</a>';
422         } else {
423                 od.innerHTML = txt;
424         }
425 }
426
427 var win = window.opener ? window.opener : window.dialogArguments;
428 if (!win) win = top;
429 tinyMCE = win.tinyMCE;
430 richedit = ( typeof tinyMCE == 'object' && tinyMCE.configs.length > 0 );
431 function sendToEditor(n) {
432         o = document.getElementById('div'+n);
433         h = o.innerHTML.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // Trim
434         h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)(?=( |/|>))', 'g'), ' $1="$2"'); // Enclose attribs in quotes
435         h = h.replace(new RegExp(' (width|height)=".*?"', 'g'), ''); // Drop size constraints
436         h = h.replace(new RegExp(' on(click|mousedown)="[^"]*"', 'g'), ''); // Drop menu events
437         h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames
438         h = h.replace(new RegExp('<IMG', 'g'), '<img'); // Lowercase again
439         h = h.replace(new RegExp('(<img .+?")>', 'g'), '$1 />'); // XHTML
440         if ( richedit )
441                 win.tinyMCE.execCommand('mceInsertContent', false, h);
442         else
443                 win.edInsertContent(win.edCanvas, h);
444 }
445 // ]]>
446 </script>
447 <style type="text/css">
448 <?php if ( $action == 'links' ) : ?>
449 * html { overflow-x: hidden; }
450 <?php else : ?>
451 * html { overflow-y: hidden; }
452 <?php endif; ?>
453 body {
454         font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
455         border: none;
456         margin: 0px;
457         height: 150px;
458         background: #dfe8f1;
459 }
460 form {
461         margin: 3px 2px 0px 6px;
462 }
463 #wrap {
464         clear: both;
465         padding: 0px;
466         width: 100%;
467 }
468 #images {
469         position: absolute;
470         clear: both;
471         margin: 0px;
472         padding: 15px 15px;
473         width: <?php echo $images_width; ?>px;
474 }
475 #images img {
476         background-color: rgb(209, 226, 239);
477 }
478 <?php echo $style; ?>
479 .attwrap, .attwrap * {
480         margin: 0px;
481         padding: 0px;
482         border: 0px;
483 }
484 .imagewrap {
485         margin-right: 5px;
486         overflow: hidden;
487         width: 128px;
488 }
489 .otherwrap {
490         margin-right: 5px;
491         overflow: hidden;
492         background-color: #f9fcfe;
493 }
494 .otherwrap a {
495         display: block;
496 }
497 .otherwrap a, .otherwrap a:hover, .otherwrap a:active, .otherwrap a:visited {
498         color: blue;
499 }
500 .usingicon {
501         padding: 0px;
502         height: 96px;
503         text-align: center;
504         width: 128px;
505 }
506 .usingtext {
507         padding: 3px;
508         height: 90px;
509         text-align: left;
510         width: 122px;
511 }
512 .filetype {
513         font-size: 80%;
514         border-bottom: 3px double #89a
515 }
516 .imagewrap, .imagewrap img, .imagewrap a, .imagewrap a img, .imagewrap a:hover img, .imagewrap a:visited img, .imagewrap a:active img {
517         text-decoration: none;
518 }
519 #upload-menu {
520         background: #fff;
521         margin: 0px;
522         padding: 0;
523         list-style: none;
524         height: 2em;
525         border-bottom: 1px solid #448abd;
526         width: 100%;
527 }
528 #upload-menu li {
529         float: left;
530         margin: 0 0 0 .75em;
531 }
532 #upload-menu a {
533         display: block;
534         padding: 5px;
535         text-decoration: none;
536         color: #000;
537         border-top: 3px solid #fff;
538 }
539 #upload-menu .current a {
540         background: #dfe8f1;
541         border-right: 2px solid #448abd;
542 }
543 #upload-menu a:hover {
544         background: #dfe8f1;
545         color: #000;
546 }
547 .tip {
548         color: rgb(68, 138, 189);
549         padding: 2px 1em;
550 }
551 .inactive {
552         color: #fff;
553         padding: 1px 3px;
554 }
555 .left {
556         float: left;
557 }
558 .right {
559         float: right;
560 }
561 .center {
562         text-align: center;
563 }
564 #upload-menu li.spacer {
565         margin-left: 40px;
566 }
567 #title, #descr {
568         width: 99%;
569         margin-top: 1px;
570 }
571 th {
572         width: 4.5em;
573 }
574 #descr {
575         height: 36px;
576 }
577 #buttons {
578         margin-top: 2px;
579         text-align: right;
580 }
581 .popup {
582         margin: 4px 4px;
583         padding: 1px;
584         position: absolute;
585         width: 114px;
586         display: none;
587         background-color: rgb(240, 240, 238);
588         border-top: 2px solid #fff;
589         border-right: 2px solid #ddd;
590         border-bottom: 2px solid #ddd;
591         border-left: 2px solid #fff;
592         text-align: center;
593 }
594 .imagewrap .popup {
595         opacity: .90;
596         filter:alpha(opacity=90);
597 }
598 .otherwrap .popup {
599         padding-top: 20px;
600 }
601 .popup a, .popup a:visited, .popup a:active {
602         background-color: transparent;
603         display: block;
604         width: 100%;
605         text-decoration: none;
606         color: #246;
607 }
608 .popup a:hover {
609         background-color: #fff;
610         color: #000;
611 }
612 .caption {
613         text-align: center;
614 }
615 #submit {
616         margin: 1px;
617         width: 99%;
618 }
619 #submit input, #submit input:focus {
620         background: url( images/fade-butt.png );
621         border: 3px double #999;
622         border-left-color: #ccc;
623         border-top-color: #ccc;
624         color: #333;
625         padding: 0.25em;
626 }
627 #submit input:active {
628         background: #f4f4f4;
629         border: 3px double #ccc;
630         border-left-color: #999;
631         border-top-color: #999;
632 }
633 .zerosize {
634         width: 0px;
635         height: 0px;
636         overflow: hidden;
637         position: absolute;
638 }
639 #links {
640         margin: 3px 8px;
641         line-height: 2em;
642 }
643 #links textarea {
644         width: 95%;
645         height: 4.5em;
646 }
647 </style>
648 </head>
649 <body>
650 <ul id="upload-menu">
651 <li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__) . "?action=upload&amp;post=$post&amp;all=$all&amp;start=$start"; ?>"><?php _e('Upload'); ?></a></li>
652 <?php if ( $attachments = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post'") ) { ?>
653 <li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=false"; ?>"><?php _e('Browse'); ?></a></li>
654 <?php } ?>
655 <?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment'")) { ?>
656 <li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=true"; ?>"><?php _e('Browse All'); ?></a></li>
657 <?php } ?>
658 <li> </li>
659 <?php if ( $action == 'view' ) { ?>
660 <?php if ( false !== $back ) : ?>
661 <li class="spacer"><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=0"; ?>" title="<?php _e('First'); ?>">|&laquo;</a></li>
662 <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$back"; ?>">&laquo; <?php _e('Back'); ?></a></li>
663 <?php else : ?>
664 <li class="inactive spacer">|&laquo;</li>
665 <li class="inactive">&laquo; <?php _e('Back'); ?></li>
666 <?php endif; ?>
667 <?php if ( false !== $next ) : ?>
668 <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$next"; ?>"><?php _e('Next &raquo;'); ?></a></li>
669 <li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;last=true"; ?>" title="<?php _e('Last'); ?>">&raquo;|</a></li>
670 <?php else : ?>
671 <li class="inactive"><?php _e('Next'); ?> &raquo;</li>
672 <li class="inactive">&raquo;|</li>
673 <?php endif; ?>
674 <?php } // endif not upload?>
675 </ul>
676 <?php if ( $action == 'view' ) : ?>
677 <div id="wrap">
678 <!--<div class="tip"><?php _e('You can drag and drop these items into your post. Click on one for more options.'); ?></div>-->
679 <div id="images">
680 <?php echo $html; ?>
681 <?php echo $popups; ?>
682 </div>
683 </div>
684 <?php elseif ( $action == 'upload' ) : ?>
685 <div class="tip"></div>
686 <form enctype="multipart/form-data" id="uploadForm" method="post" action="<?php echo basename(__FILE__); ?>">
687 <table style="width:99%;">
688 <tr>
689 <th scope="row" align="right"><label for="upload"><?php _e('File:'); ?></label></th>
690 <td><input type="file" id="upload" name="image" /></td>
691 </tr>
692 <tr>
693 <th scope="row" align="right"><label for="title"><?php _e('Title:'); ?></label></th>
694 <td><input type="text" id="title" name="imgtitle" /></td>
695 </tr>
696 <tr>
697 <th scope="row" align="right"><label for="descr"><?php _e('Description:'); ?></label></th>
698 <td><input type="textarea" name="descr" id="descr" value="" /></td>
699 </tr>
700 <tr id="buttons">
701 <th></th>
702 <td>
703 <input type="hidden" name="action" value="save" />
704 <input type="hidden" name="post" value="<?php echo $post; ?>" />
705 <input type="hidden" name="all" value="<?php echo $all; ?>" />
706 <input type="hidden" name="start" value="<?php echo $start; ?>" />
707 <?php wp_nonce_field( 'inlineuploading' ); ?>
708 <div id="submit">
709 <input type="submit" value="<?php _e('Upload'); ?>" />
710 <?php if ( !empty($all) ) : ?>
711 <input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
712 <?php endif; ?>
713 </div>
714 </td>
715 </tr>
716 </table>
717 </form>
718 <?php elseif ( $action == 'links' ) : ?>
719 <div id="links">
720 <?php the_attachment_links($attachment); ?>
721 </div>
722 <?php endif; ?>
723 </body>
724 </html>