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