2005-11-12 23:40:18 -05:00
< ? php
require_once ( 'admin.php' );
if ( ! current_user_can ( 'edit_posts' ))
die ( __ ( 'You do not have permission to edit posts.' ));
2005-11-28 18:13:35 -05:00
$wpvarstoreset = array ( 'action' , 'post' , 'all' , 'last' , 'link' , 'sort' , 'start' , 'imgtitle' , 'descr' , 'attachment' );
2005-11-12 23:40:18 -05:00
for ( $i = 0 ; $i < count ( $wpvarstoreset ); $i += 1 ) {
$wpvar = $wpvarstoreset [ $i ];
if ( ! isset ( $$wpvar )) {
if ( empty ( $_POST [ " $wpvar " ])) {
if ( empty ( $_GET [ " $wpvar " ])) {
$$wpvar = '' ;
} else {
$$wpvar = $_GET [ " $wpvar " ];
}
} else {
$$wpvar = $_POST [ " $wpvar " ];
}
}
}
$post = ( int ) $post ;
$images_width = 1 ;
switch ( $action ) {
2005-12-14 03:29:43 -05:00
case 'links' :
// Do not pass GO.
break ;
2005-11-12 23:40:18 -05:00
case 'delete' :
2006-01-02 15:55:45 -05:00
if ( ! current_user_can ( 'edit_post' , ( int ) $attachment ) )
2005-12-13 23:24:05 -05:00
die ( __ ( 'You are not allowed to delete this attachment.' ) . ' <a href="' . basename ( __FILE__ ) . " ?post= $post &all= $all &action=upload \" > " . __ ( 'Go back' ) . '</a>' );
2005-11-28 18:13:35 -05:00
2005-11-15 17:55:24 -05:00
wp_delete_attachment ( $attachment );
2005-11-12 23:40:18 -05:00
header ( " Location: " . basename ( __FILE__ ) . " ?post= $post &all= $all &action=view&start= $start " );
die ;
case 'save' :
$overrides = array ( 'action' => 'save' );
$file = wp_handle_upload ( $_FILES [ 'image' ], $overrides );
if ( isset ( $file [ 'error' ]) )
2005-12-13 23:24:05 -05:00
die ( $file [ 'error' ] . '<br /><a href="' . basename ( __FILE__ ) . '?action=upload&post=' . $post . '">' . __ ( 'Back to Image Uploading' ) . '</a>' );
2005-11-12 23:40:18 -05:00
$url = $file [ 'url' ];
2005-12-13 14:19:56 -05:00
$type = $file [ 'type' ];
2005-11-12 23:40:18 -05:00
$file = $file [ 'file' ];
$filename = basename ( $file );
2005-11-15 17:55:24 -05:00
// Construct the attachment array
$attachment = array (
2005-11-12 23:40:18 -05:00
'post_title' => $imgtitle ? $imgtitle : $filename ,
'post_content' => $descr ,
2005-11-15 17:55:24 -05:00
'post_status' => 'attachment' ,
2005-11-12 23:40:18 -05:00
'post_parent' => $post ,
2005-12-13 14:19:56 -05:00
'post_mime_type' => $type ,
2005-11-12 23:40:18 -05:00
'guid' => $url
);
// Save the data
2005-11-15 17:55:24 -05:00
$id = wp_insert_attachment ( $attachment , $file , $post );
2005-11-12 23:40:18 -05:00
2005-11-28 18:13:35 -05:00
if ( preg_match ( '!^image/!' , $attachment [ 'post_mime_type' ]) ) {
// Generate the attachment's postmeta.
$imagesize = getimagesize ( $file );
$imagedata [ 'width' ] = $imagesize [ '0' ];
$imagedata [ 'height' ] = $imagesize [ '1' ];
list ( $uwidth , $uheight ) = get_udims ( $imagedata [ 'width' ], $imagedata [ 'height' ]);
$imagedata [ 'hwstring_small' ] = " height=' $uheight ' width=' $uwidth ' " ;
$imagedata [ 'file' ] = $file ;
add_post_meta ( $id , '_wp_attachment_metadata' , $imagedata );
if ( $imagedata [ 'width' ] * $imagedata [ 'height' ] < 3 * 1024 * 1024 ) {
if ( $imagedata [ 'width' ] > 128 && $imagedata [ 'width' ] >= $imagedata [ 'height' ] * 4 / 3 )
2005-12-13 14:19:56 -05:00
$thumb = wp_create_thumbnail ( $file , 128 );
2005-11-28 18:13:35 -05:00
elseif ( $imagedata [ 'height' ] > 96 )
2005-12-13 14:19:56 -05:00
$thumb = wp_create_thumbnail ( $file , 96 );
if ( @ file_exists ( $thumb ) ) {
$newdata = $imagedata ;
$newdata [ 'thumb' ] = basename ( $thumb );
update_post_meta ( $id , '_wp_attachment_metadata' , $newdata , $imagedata );
} else {
$error = $thumb ;
}
2005-11-28 18:13:35 -05:00
}
} else {
add_post_meta ( $id , '_wp_attachment_metadata' , array ());
2005-11-12 23:40:18 -05:00
}
2005-12-13 23:24:05 -05:00
header ( " Location: " . basename ( __FILE__ ) . " ?post= $post &all= $all &action=view&start=0 " );
2005-12-02 17:37:02 -05:00
die ();
2005-11-12 23:40:18 -05:00
case 'upload' :
$current_1 = ' class="current"' ;
$back = $next = false ;
break ;
case 'view' :
// How many images do we show? How many do we query?
$num = 5 ;
$double = $num * 2 ;
2005-12-13 23:24:05 -05:00
if ( $post && ( empty ( $all ) || $all == 'false' ) ) {
2005-11-12 23:40:18 -05:00
$and_post = " AND post_parent = ' $post ' " ;
$current_2 = ' class="current"' ;
} else {
$current_3 = ' class="current"' ;
}
2005-11-28 18:13:35 -05:00
if ( ! current_user_can ( 'edit_others_posts' ) )
$and_user = " AND post_author = " . $user_ID ;
2005-11-12 23:40:18 -05:00
if ( $last )
2005-11-28 18:13:35 -05:00
$start = $wpdb -> get_var ( " SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment' $and_user $and_post " ) - $num ;
2005-11-12 23:40:18 -05:00
else
$start = ( int ) $start ;
if ( $start < 0 )
$start = 0 ;
if ( '' == $sort )
2005-11-16 22:19:19 -05:00
$sort = " post_date_gmt DESC " ;
2005-11-12 23:40:18 -05:00
2005-11-28 18:13:35 -05:00
$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 );
2005-11-12 23:40:18 -05:00
2005-11-28 18:13:35 -05:00
if ( count ( $attachments ) == 0 ) {
2005-11-18 04:28:37 -05:00
header ( " Location: " . basename ( __FILE__ ) . " ?post= $post &action=upload " );
die ;
2005-11-28 18:13:35 -05:00
} elseif ( count ( $attachments ) > $num ) {
$next = $start + count ( $attachments ) - $num ;
2005-11-12 23:40:18 -05:00
} else {
$next = false ;
}
if ( $start > 0 ) {
$back = $start - $num ;
if ( $back < 1 )
$back = '0' ;
} else {
$back = false ;
}
$uwidth_sum = 0 ;
2005-11-28 18:13:35 -05:00
$html = '' ;
2005-12-09 14:24:14 -05:00
$popups = '' ;
2005-11-28 18:13:35 -05:00
$style = '' ;
$script = '' ;
if ( count ( $attachments ) > 0 ) {
$attachments = array_slice ( $attachments , 0 , $num );
2005-11-16 22:19:19 -05:00
$__delete = __ ( 'Delete' );
2005-11-28 18:13:35 -05:00
$__not_linked = __ ( 'Not Linked' );
$__linked_to_page = __ ( 'Linked to Page' );
$__linked_to_image = __ ( 'Linked to Image' );
2005-11-30 17:44:00 -05:00
$__linked_to_file = __ ( 'Linked to File' );
2005-11-28 18:13:35 -05:00
$__using_thumbnail = __ ( 'Using Thumbnail' );
$__using_original = __ ( 'Using Original' );
2005-12-13 14:19:56 -05:00
$__using_title = __ ( 'Using Title' );
$__using_filename = __ ( 'Using Filename' );
$__using_icon = __ ( 'Using Icon' );
2005-12-02 17:37:02 -05:00
$__no_thumbnail = '<del>' . __ ( 'No Thumbnail' ) . '</del>' ;
2005-12-09 14:24:14 -05:00
$__send_to_editor = __ ( 'Send to editor' );
2005-11-16 22:19:19 -05:00
$__close = __ ( 'Close Options' );
2005-11-28 18:13:35 -05:00
$__confirmdelete = __ ( 'Delete this file from the server?' );
2005-11-12 23:40:18 -05:00
$__nothumb = __ ( 'There is no thumbnail associated with this photo.' );
2005-11-28 18:13:35 -05:00
$script .= " notlinked = ' $__not_linked ';
linkedtoimage = '$__linked_to_image' ;
linkedtopage = '$__linked_to_page' ;
2005-11-30 17:44:00 -05:00
linkedtofile = '$__linked_to_file' ;
2005-11-28 18:13:35 -05:00
usingthumbnail = '$__using_thumbnail' ;
usingoriginal = '$__using_original' ;
2005-12-13 14:19:56 -05:00
usingtitle = '$__using_title' ;
usingfilename = '$__using_filename' ;
usingicon = '$__using_icon' ;
2005-12-02 17:39:41 -05:00
var aa = new Array ();
var ab = new Array ();
var imga = new Array ();
var imgb = new Array ();
var srca = new Array ();
var srcb = new Array ();
2005-12-13 14:19:56 -05:00
var title = new Array ();
var filename = new Array ();
var icon = new Array ();
2005-11-28 18:13:35 -05:00
" ;
foreach ( $attachments as $key => $attachment ) {
$ID = $attachment [ 'ID' ];
2005-11-30 17:44:00 -05:00
$href = get_attachment_link ( $ID );
2005-11-28 18:13:35 -05:00
$meta = get_post_meta ( $ID , '_wp_attachment_metadata' , true );
2005-11-12 23:40:18 -05:00
if ( ! is_array ( $meta )) {
2005-11-28 18:13:35 -05:00
$meta = get_post_meta ( $ID , 'imagedata' , true ); // Try 1.6 Alpha meta key
2005-11-18 04:25:47 -05:00
if ( ! is_array ( $meta )) {
2005-11-28 18:13:35 -05:00
$meta = array ();
2005-11-18 04:25:47 -05:00
}
2005-11-28 18:13:35 -05:00
add_post_meta ( $ID , '_wp_attachment_metadata' , $meta );
2005-11-12 23:40:18 -05:00
}
2005-11-28 18:13:35 -05:00
$attachment = array_merge ( $attachment , $meta );
2005-12-14 03:29:43 -05:00
$noscript = " <noscript>
< div class = 'caption' >< a href = \ " " . basename ( __FILE__ ) . " ?action=links&attachment= { $ID } &post= { $post } &all= { $all } &start= { $start } \" >Choose Links</a></div>
</ noscript >
" ;
2005-12-09 14:24:14 -05:00
$send_delete_cancel = " <a onclick= \" sendToEditor( { $ID } );return false; \" href= \" javascript:void() \" > $__send_to_editor </a>
2005-12-13 23:24:05 -05:00
< a onclick = \ " return confirm(' $__confirmdelete ') \" href= \" " . basename ( __FILE__ ) . " ?action=delete&attachment= { $ID } &all= $all &start= $start &post= $post\ " > $__delete </ a >
2005-11-12 23:40:18 -05:00
< a onclick = \ " popup.style.display='none';return false; \" href= \" javascript:void() \" > $__close </a>
2005-11-28 18:13:35 -05:00
" ;
$uwidth_sum += 128 ;
if ( preg_match ( '!^image/!' , $attachment [ 'post_mime_type' ] ) ) {
$image = & $attachment ;
if ( ( $image [ 'width' ] > 128 || $image [ 'height' ] > 96 ) && ! empty ( $image [ 'thumb' ]) && file_exists ( dirname ( $image [ 'file' ]) . '/' . $image [ 'thumb' ]) ) {
$src = str_replace ( basename ( $image [ 'guid' ]), $image [ 'thumb' ], $image [ 'guid' ]);
2005-12-02 17:39:41 -05:00
$script .= " srca[ { $ID } ] = ' $src ';
srcb [{ $ID }] = '{$image[' guid ']}' ;
2005-11-28 18:13:35 -05:00
" ;
$thumb = 'true' ;
$thumbtext = $__using_thumbnail ;
} else {
$src = $image [ 'guid' ];
$thumb = 'false' ;
$thumbtext = $__no_thumbnail ;
}
list ( $image [ 'uwidth' ], $image [ 'uheight' ]) = get_udims ( $image [ 'width' ], $image [ 'height' ]);
$height_width = 'height="' . $image [ 'uheight' ] . '" width="' . $image [ 'uwidth' ] . '"' ;
$xpadding = ( 128 - $image [ 'uwidth' ]) / 2 ;
$ypadding = ( 96 - $image [ 'uheight' ]) / 2 ;
$style .= " #target { $ID } img { padding: { $ypadding } px { $xpadding } px; } \n " ;
2006-01-04 20:43:30 -05:00
$title = htmlentities ( $image [ 'post_title' ], ENT_QUOTES );
$script .= " aa[ { $ID } ] = '<a id= \" p { $ID } \" rel= \" attachment \" class= \" imagelink \" href= \" $href\ " onclick = \ " doPopup( { $ID } );return false; \" title= \" { $title } \" >';
ab [{ $ID }] = '<a class=\"imagelink\" href=\"{$image[' guid ']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">' ;
imga [{ $ID }] = '<img id=\"image{$ID}\" src=\"$src\" alt=\"{$title}\" $height_width />' ;
imgb [{ $ID }] = '<img id=\"image{$ID}\" src=\"{$image[' guid ']}\" alt=\"{$title}\" $height_width />' ;
2005-11-28 18:13:35 -05:00
" ;
$html .= " <div id='target { $ID } ' class='attwrap left'>
< div id = 'div{$ID}' class = 'imagewrap' onclick = \ " doPopup( { $ID } ); \" >
2006-01-04 20:43:30 -05:00
< img id = \ " image { $ID } \" src= \" $src\ " alt = \ " { $title } \" $height_width />
2005-11-28 18:13:35 -05:00
</ div >
2005-12-14 03:29:43 -05:00
{ $noscript }
2005-11-28 18:13:35 -05:00
</ div >
2005-12-09 14:24:14 -05:00
" ;
$popups .= " <div id='popup { $ID } ' class='popup'>
< a id = \ " I { $ID } \" onclick= \" if( $thumb )toggleImage( { $ID } );else alert(' $__nothumb ');return false; \" href= \" javascript:void() \" > $thumbtext </a>
< a id = \ " L { $ID } \" onclick= \" toggleLink( { $ID } );return false; \" href= \" javascript:void() \" > $__not_linked </a>
{ $send_delete_cancel }
</ div >
2005-11-28 18:13:35 -05:00
" ;
} else {
2006-01-04 20:43:30 -05:00
$title = htmlentities ( $attachment [ 'post_title' ], ENT_QUOTES );
2005-12-13 14:19:56 -05:00
$filename = basename ( $attachment [ 'guid' ]);
2005-12-13 23:24:05 -05:00
$icon = get_attachment_icon ( $ID );
$toggle_icon = " <a id= \" I { $ID } \" onclick= \" toggleOtherIcon( { $ID } );return false; \" href= \" javascript:void() \" > $__using_title </a> " ;
2006-01-04 20:43:30 -05:00
$script .= " aa[ { $ID } ] = '<a id= \" p { $ID } \" rel= \" attachment \" href= \" $href\ " onclick = \ " doPopup( { $ID } );return false; \" title= \" { $title } \" > { $title } </a>';
ab [{ $ID }] = '<a id=\"p{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">{$title}</a>' ;
title [{ $ID }] = '{$title}' ;
2005-12-13 14:19:56 -05:00
filename [{ $ID }] = '{$filename}' ;
icon [{ $ID }] = '{$icon}' ;
2005-11-30 17:44:00 -05:00
" ;
2005-11-28 18:13:35 -05:00
$html .= " <div id='target { $ID } ' class='attwrap left'>
2005-12-13 14:19:56 -05:00
< div id = 'div{$ID}' class = 'otherwrap usingtext' onmousedown = \ " selectLink( { $ID } ) \" onclick= \" doPopup( { $ID } );return false; \" >
2006-01-04 20:43:30 -05:00
< a id = \ " p { $ID } \" href= \" { $attachment [ 'guid' ] } \" onmousedown= \" selectLink( { $ID } ); \" onclick= \" return false; \" > { $title } </a>
2005-11-12 23:40:18 -05:00
</ div >
2005-12-14 03:29:43 -05:00
{ $noscript }
2005-11-12 23:40:18 -05:00
</ div >
2005-12-09 14:24:14 -05:00
" ;
$popups .= " <div id='popup { $ID } ' class='popup'>
2005-12-12 17:48:30 -05:00
< div class = 'filetype' > " .__('File Type:').' '.str_replace('/', " / \n " , $attachment['post_mime_type'] ). " </ div >
2005-12-09 14:24:14 -05:00
< a id = \ " L { $ID } \" onclick= \" toggleOtherLink( { $ID } );return false; \" href= \" javascript:void() \" > $__linked_to_file </a>
2005-12-13 14:19:56 -05:00
{ $toggle_icon }
2005-12-09 14:24:14 -05:00
{ $send_delete_cancel }
</ div >
2005-11-12 23:40:18 -05:00
" ;
2005-11-28 18:13:35 -05:00
}
2005-11-12 23:40:18 -05:00
}
}
2005-11-28 18:13:35 -05:00
$images_width = $uwidth_sum + ( count ( $images ) * 6 ) + 35 ;
2005-11-12 23:40:18 -05:00
break ;
default :
2005-12-02 17:37:02 -05:00
die ( __ ( 'This script was not meant to be called directly.' ));
2005-11-12 23:40:18 -05:00
}
?>
<! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head >
2005-11-14 04:45:13 -05:00
< meta http - equiv = " Content-Type " content = " <?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?> " />
2005-11-12 23:40:18 -05:00
< meta http - equiv = " imagetoolbar " content = " no " />
< script type = " text/javascript " >
/* Define any variables we'll need, such as alternate URLs. */
2005-11-28 18:13:35 -05:00
< ? php echo $script ; ?>
2006-01-02 15:55:45 -05:00
function htmldecode ( st ) {
o = document . getElementById ( 'htmldecode' );
if ( ! o ) {
o = document . createElement ( " A " );
o . id = " htmldecode "
}
o . innerHTML = st ;
r = o . innerHTML ;
return r ;
}
2005-11-12 23:40:18 -05:00
function cancelUpload () {
2005-11-28 18:13:35 -05:00
o = document . getElementById ( 'uploadForm' );
o . method = 'GET' ;
o . action . value = 'view' ;
o . submit ();
}
function doPopup ( i ) {
if ( popup )
popup . style . display = 'none' ;
target = document . getElementById ( 'target' + i );
popup = document . getElementById ( 'popup' + i );
popup . style . left = ( target . offsetLeft ) + 'px' ;
2005-12-09 14:24:14 -05:00
popup . style . top = ( target . offsetTop ) + 'px' ;
2005-11-28 18:13:35 -05:00
popup . style . display = 'block' ;
2005-11-12 23:40:18 -05:00
}
2005-12-09 14:24:14 -05:00
popup = false ;
2005-11-28 18:13:35 -05:00
function selectLink ( n ) {
o = document . getElementById ( 'div' + n );
2005-12-09 14:24:14 -05:00
if ( typeof document . body . createTextRange == 'undefined' || typeof win . tinyMCE == 'undefined' || win . tinyMCE . configs . length < 1 )
return ;
2005-11-28 18:13:35 -05:00
r = document . body . createTextRange ();
if ( typeof r != 'undefined' ) {
r . moveToElementText ( o );
r . select ();
}
2005-11-12 23:40:18 -05:00
}
function toggleLink ( n ) {
2005-11-28 18:13:35 -05:00
ol = document . getElementById ( 'L' + n );
2006-01-02 15:55:45 -05:00
if ( ol . innerHTML == htmldecode ( notlinked ) ) {
2005-11-28 18:13:35 -05:00
ol . innerHTML = linkedtoimage ;
2006-01-02 15:55:45 -05:00
} else if ( ol . innerHTML == htmldecode ( linkedtoimage ) ) {
2005-11-28 18:13:35 -05:00
ol . innerHTML = linkedtopage ;
} else {
ol . innerHTML = notlinked ;
2005-11-12 23:40:18 -05:00
}
2006-01-05 18:33:50 -05:00
updateImage ( n );
2005-11-12 23:40:18 -05:00
}
2005-11-30 17:44:00 -05:00
function toggleOtherLink ( n ) {
od = document . getElementById ( 'div' + n );
ol = document . getElementById ( 'L' + n );
2005-12-19 14:10:09 -05:00
oi = document . getElementById ( 'p' + n );
2005-12-13 14:19:56 -05:00
ih = oi . innerHTML ;
2006-01-02 15:55:45 -05:00
if ( ol . innerHTML == htmldecode ( linkedtofile ) ) {
2005-12-02 17:39:41 -05:00
od . innerHTML = aa [ n ];
2005-11-30 17:44:00 -05:00
ol . innerHTML = linkedtopage ;
} else {
2005-12-02 17:39:41 -05:00
od . innerHTML = ab [ n ];
2005-11-30 17:44:00 -05:00
ol . innerHTML = linkedtofile ;
}
2005-12-19 14:10:09 -05:00
oi = document . getElementById ( 'p' + n );
2005-12-13 14:19:56 -05:00
oi . innerHTML = ih ;
2005-11-30 17:44:00 -05:00
}
2005-11-12 23:40:18 -05:00
function toggleImage ( n ) {
oi = document . getElementById ( 'I' + n );
2006-01-02 15:55:45 -05:00
if ( oi . innerHTML == htmldecode ( usingthumbnail ) ) {
2005-11-28 18:13:35 -05:00
oi . innerHTML = usingoriginal ;
2005-11-12 23:40:18 -05:00
} else {
2005-11-28 18:13:35 -05:00
oi . innerHTML = usingthumbnail ;
2005-11-12 23:40:18 -05:00
}
2006-01-05 18:33:50 -05:00
updateImage ( n );
2005-11-12 23:40:18 -05:00
}
2005-12-13 14:19:56 -05:00
function toggleOtherIcon ( n ) {
od = document . getElementById ( 'div' + n );
2005-12-19 14:10:09 -05:00
o = document . getElementById ( 'p' + n );
2005-12-13 14:19:56 -05:00
oi = document . getElementById ( 'I' + n );
2006-01-02 15:55:45 -05:00
if ( oi . innerHTML == htmldecode ( usingtitle ) ) {
2005-12-13 14:19:56 -05:00
o . innerHTML = filename [ n ];
oi . innerHTML = usingfilename ;
2006-01-02 15:55:45 -05:00
} else if ( oi . innerHTML == htmldecode ( usingfilename ) && icon [ n ] != '' ) {
2005-12-13 14:19:56 -05:00
o . innerHTML = icon [ n ];
oi . innerHTML = usingicon ;
} else {
o . innerHTML = title [ n ];
oi . innerHTML = usingtitle ;
}
if ( oi . innerHTML == usingicon )
od . className = 'otherwrap usingicon' ;
else
2005-12-13 23:24:05 -05:00
od . className = 'otherwrap usingtext' ;
2005-12-13 14:19:56 -05:00
}
2006-01-05 18:33:50 -05:00
function updateImage ( n ) {
od = document . getElementById ( 'div' + n );
ol = document . getElementById ( 'L' + n );
oi = document . getElementById ( 'I' + n );
if ( oi . innerHTML == htmldecode ( usingthumbnail ) ) {
img = imga [ n ];
} else {
img = imgb [ n ];
}
if ( ol . innerHTML == htmldecode ( linkedtoimage ) ) {
od . innerHTML = ab [ n ] + img + '</a>' ;
} else if ( ol . innerHTML == htmldecode ( linkedtopage ) ) {
od . innerHTML = aa [ n ] + img + '</a>' ;
} else {
od . innerHTML = img ;
}
}
2005-12-09 14:24:14 -05:00
var win = window . opener ? window . opener : window . dialogArguments ;
if ( ! win ) win = top ;
tinyMCE = win . tinyMCE ;
richedit = ( typeof tinyMCE == 'object' && tinyMCE . configs . length > 0 );
function sendToEditor ( n ) {
o = document . getElementById ( 'div' + n );
h = o . innerHTML . replace ( new RegExp ( '^\\s*(.*?)\\s*$' , '' ), '$1' ); // Trim
h = h . replace ( new RegExp ( ' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)' , 'g' ), ' $1="$2"$3' ); // Enclose attribs in quotes
2006-01-05 18:33:50 -05:00
h = h . replace ( new RegExp ( ' (width|height)=".*?"' , 'g' ), '' ); // Drop size constraints
2005-12-09 14:24:14 -05:00
h = h . replace ( new RegExp ( ' on(click|mousedown)="[^"]*"' , 'g' ), '' ); // Drop menu events
h = h . replace ( new RegExp ( '<(/?)A' , 'g' ), '<$1a' ); // Lowercase tagnames
h = h . replace ( new RegExp ( '<IMG' , 'g' ), '<img' ); // Lowercase again
h = h . replace ( new RegExp ( '(<img .+?")>' , 'g' ), '$1 />' ); // XHTML
if ( richedit )
win . tinyMCE . execCommand ( 'mceInsertContent' , false , h );
else
win . edInsertContent ( win . edCanvas , h );
}
2005-11-12 23:40:18 -05:00
</ script >
< style type = " text/css " >
2005-12-14 03:29:43 -05:00
< ? php if ( $action == 'links' ) : ?>
* html { overflow - x : hidden ; }
< ? php else : ?>
* html { overflow - y : hidden ; }
< ? php endif ; ?>
2005-11-12 23:40:18 -05:00
body {
2005-11-16 22:19:19 -05:00
font : 13 px " Lucida Grande " , " Lucida Sans Unicode " , Tahoma , Verdana ;
border : none ;
margin : 0 px ;
height : 150 px ;
background : #dfe8f1;
2005-11-12 23:40:18 -05:00
}
form {
2005-11-28 18:13:35 -05:00
margin : 3 px 2 px 0 px 6 px ;
2005-11-12 23:40:18 -05:00
}
#wrap {
2005-11-16 22:19:19 -05:00
clear : both ;
padding : 0 px ;
width : 100 % ;
2005-11-12 23:40:18 -05:00
}
#images {
2005-12-09 14:24:14 -05:00
position : absolute ;
2005-11-16 22:19:19 -05:00
clear : both ;
margin : 0 px ;
2005-12-09 14:24:14 -05:00
padding : 15 px 15 px ;
2005-11-16 22:19:19 -05:00
width : < ? php echo $images_width ; ?> px;
2005-11-12 23:40:18 -05:00
}
#images img {
2005-11-16 22:19:19 -05:00
background - color : rgb ( 209 , 226 , 239 );
2005-11-12 23:40:18 -05:00
}
2005-11-28 18:13:35 -05:00
< ? php echo $style ; ?>
. attwrap , . attwrap * {
margin : 0 px ;
padding : 0 px ;
border : 0 px ;
}
2005-11-12 23:40:18 -05:00
. imagewrap {
2005-11-16 22:19:19 -05:00
margin - right : 5 px ;
overflow : hidden ;
2005-12-14 03:29:43 -05:00
width : 128 px ;
2005-11-12 23:40:18 -05:00
}
2005-11-28 18:13:35 -05:00
. otherwrap {
margin - right : 5 px ;
2005-12-14 03:29:43 -05:00
overflow : hidden ;
2005-11-28 18:13:35 -05:00
background - color : #f9fcfe;
}
. otherwrap a {
display : block ;
}
. otherwrap a , . otherwrap a : hover , . otherwrap a : active , . otherwrap a : visited {
color : blue ;
}
2005-12-13 14:19:56 -05:00
. usingicon {
padding : 0 px ;
height : 96 px ;
text - align : center ;
2005-12-14 03:29:43 -05:00
width : 128 px ;
2005-12-13 14:19:56 -05:00
}
. usingtext {
padding : 3 px ;
height : 90 px ;
text - align : left ;
2005-12-14 03:29:43 -05:00
width : 122 px ;
2005-12-13 14:19:56 -05:00
}
2005-11-28 18:13:35 -05:00
. filetype {
font - size : 80 % ;
border - bottom : 3 px double #89a
2005-11-12 23:40:18 -05:00
}
2005-11-28 18:13:35 -05:00
. imagewrap , . imagewrap img , . imagewrap a , . imagewrap a img , . imagewrap a : hover img , . imagewrap a : visited img , . imagewrap a : active img {
2005-11-16 22:19:19 -05:00
text - decoration : none ;
2005-11-12 23:40:18 -05:00
}
2005-11-16 22:19:19 -05:00
#upload-menu {
background : #fff;
2005-11-28 18:13:35 -05:00
margin : 0 px ;
2005-11-16 22:19:19 -05:00
padding : 0 ;
list - style : none ;
height : 2 em ;
border - bottom : 1 px solid #448abd;
2005-11-28 18:13:35 -05:00
width : 100 % ;
2005-11-16 22:19:19 -05:00
}
#upload-menu li {
float : left ;
2005-11-28 18:13:35 -05:00
margin : 0 0 0 . 75 em ;
2005-11-16 22:19:19 -05:00
}
#upload-menu a {
display : block ;
padding : 5 px ;
text - decoration : none ;
color : #000;
border - top : 3 px solid #fff;
}
#upload-menu .current a {
background : #dfe8f1;
border - right : 2 px solid #448abd;
}
#upload-menu a:hover {
background : #dfe8f1;
color : #000;
}
2005-11-12 23:40:18 -05:00
. tip {
2005-11-16 22:19:19 -05:00
color : rgb ( 68 , 138 , 189 );
padding : 2 px 1 em ;
2005-11-12 23:40:18 -05:00
}
. inactive {
2005-11-16 22:19:19 -05:00
color : #fff;
padding : 1 px 3 px ;
2005-11-12 23:40:18 -05:00
}
. left {
2005-11-16 22:19:19 -05:00
float : left ;
2005-11-12 23:40:18 -05:00
}
. right {
2005-11-16 22:19:19 -05:00
float : right ;
2005-11-12 23:40:18 -05:00
}
. center {
2005-11-16 22:19:19 -05:00
text - align : center ;
2005-11-12 23:40:18 -05:00
}
2005-11-16 22:19:19 -05:00
#upload-menu li.spacer {
margin - left : 40 px ;
2005-11-12 23:40:18 -05:00
}
#title, #descr {
2005-12-13 23:24:05 -05:00
width : 99 % ;
2005-11-28 18:13:35 -05:00
margin - top : 1 px ;
2005-11-12 23:40:18 -05:00
}
2005-12-13 23:24:05 -05:00
th {
width : 4.5 em ;
}
2005-11-12 23:40:18 -05:00
#descr {
2005-11-28 18:13:35 -05:00
height : 36 px ;
2005-11-12 23:40:18 -05:00
}
#buttons {
2005-11-16 22:19:19 -05:00
margin - top : 2 px ;
text - align : right ;
2005-11-12 23:40:18 -05:00
}
. popup {
2005-11-16 22:19:19 -05:00
margin : 4 px 4 px ;
2005-12-13 23:24:05 -05:00
padding : 1 px ;
2005-11-16 22:19:19 -05:00
position : absolute ;
width : 114 px ;
display : none ;
2005-12-13 23:24:05 -05:00
background - color : rgb ( 240 , 240 , 238 );
border - top : 2 px solid #fff;
border - right : 2 px solid #ddd;
border - bottom : 2 px solid #ddd;
border - left : 2 px solid #fff;
2005-11-28 18:13:35 -05:00
text - align : center ;
}
. imagewrap . popup {
2005-11-16 22:19:19 -05:00
opacity : . 90 ;
filter : alpha ( opacity = 90 );
2005-11-28 18:13:35 -05:00
}
. otherwrap . popup {
padding - top : 20 px ;
2005-11-12 23:40:18 -05:00
}
. popup a , . popup a : visited , . popup a : active {
2005-11-16 22:19:19 -05:00
background - color : transparent ;
display : block ;
width : 100 % ;
text - decoration : none ;
color : #246;
2005-11-12 23:40:18 -05:00
}
. popup a : hover {
2005-11-16 22:19:19 -05:00
background - color : #fff;
color : #000;
2005-11-12 23:40:18 -05:00
}
2005-12-14 03:29:43 -05:00
. caption {
text - align : center ;
}
2005-12-13 23:24:05 -05:00
#submit {
margin : 1 px ;
width : 99 % ;
}
#submit input, #submit input:focus {
background : url ( images / fade - butt . png );
border : 3 px double #999;
border - left - color : #ccc;
border - top - color : #ccc;
color : #333;
padding : 0.25 em ;
}
#submit input:active {
background : #f4f4f4;
border : 3 px double #ccc;
border - left - color : #999;
border - top - color : #999;
}
2005-12-14 03:29:43 -05:00
. zerosize {
width : 0 px ;
height : 0 px ;
overflow : hidden ;
position : absolute ;
}
#links {
margin : 3 px 8 px ;
line - height : 2 em ;
}
#links textarea {
width : 95 % ;
height : 4.5 em ;
}
2005-11-12 23:40:18 -05:00
</ style >
</ head >
2005-12-09 14:24:14 -05:00
< body >
2005-11-16 22:19:19 -05:00
< ul id = " upload-menu " >
2005-12-13 23:24:05 -05:00
< 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>
2005-11-16 22:19:19 -05:00
< ? php if ( $attachments = $wpdb -> get_results ( " SELECT ID FROM $wpdb->posts WHERE post_parent = ' $post ' " ) ) { ?>
2005-12-13 23:24:05 -05:00
< li < ? php echo $current_2 ; ?> ><a href="<?php echo basename(__FILE__); ?>?action=view&post=<?php echo $post; ?>&all=false"><?php _e('Browse'); ?></a></li>
2005-11-16 22:19:19 -05:00
< ? php } ?>
2005-11-28 18:13:35 -05:00
< ? php if ( $wpdb -> get_var ( " SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'attachment' " )) { ?>
< 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>
2005-11-21 03:44:38 -05:00
< ? php } ?>
2005-11-12 23:40:18 -05:00
< li > </ li >
2005-12-14 03:29:43 -05:00
< ? php if ( $action == 'view' ) { ?>
2005-11-12 23:40:18 -05:00
< ? php if ( false !== $back ) : ?>
2005-11-16 22:19:19 -05:00
< 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'); ?> " >|& laquo ; </ a ></ li >
< 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>
2005-11-12 23:40:18 -05:00
< ? php else : ?>
2005-11-28 18:13:35 -05:00
< li class = " inactive spacer " >|& laquo ; </ li >
< li class = " inactive " >& laquo ; < ? php _e ( 'Back' ); ?> </li>
2005-11-12 23:40:18 -05:00
< ? php endif ; ?>
< ? php if ( false !== $next ) : ?>
2005-11-16 22:19:19 -05:00
< 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>
< 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'); ?> " >& raquo ; |</ a ></ li >
2005-11-12 23:40:18 -05:00
< ? php else : ?>
2005-11-28 18:13:35 -05:00
< li class = " inactive " >< ? php _e ( 'Next' ); ?> »</li>
< li class = " inactive " >& raquo ; |</ li >
2005-11-12 23:40:18 -05:00
< ? php endif ; ?>
2005-11-16 22:19:19 -05:00
< ? php } // endif not upload?>
2005-11-12 23:40:18 -05:00
</ ul >
< ? php if ( $action == 'view' ) : ?>
< div id = " wrap " >
2005-12-09 14:24:14 -05:00
<!--< div class = " tip " >< ? php _e ( 'You can drag and drop these items into your post. Click on one for more options.' ); ?> </div>-->
2005-11-12 23:40:18 -05:00
< div id = " images " >
2005-11-28 18:13:35 -05:00
< ? php echo $html ; ?>
2005-12-09 14:24:14 -05:00
< ? php echo $popups ; ?>
2005-11-12 23:40:18 -05:00
</ div >
</ div >
< ? php elseif ( $action == 'upload' ) : ?>
< div class = " tip " ></ div >
2005-11-28 18:13:35 -05:00
< form enctype = " multipart/form-data " id = " uploadForm " method = " POST " action = " <?php echo basename(__FILE__); ?> " >
< table style = " width:99%; " >
2005-11-16 22:19:19 -05:00
< tr >
2005-12-13 23:24:05 -05:00
< th scope = " row " align = " right " >< label for = " upload " >< ? php _e ( 'File:' ); ?> </label></th>
2005-11-28 18:13:35 -05:00
< td >< input type = " file " id = " upload " name = " image " /></ td >
2005-11-16 22:19:19 -05:00
</ tr >
< tr >
2005-12-13 23:24:05 -05:00
< th scope = " row " align = " right " >< label for = " title " >< ? php _e ( 'Title:' ); ?> </label></th>
2005-11-16 22:19:19 -05:00
< td >< input type = " text " id = " title " name = " imgtitle " /></ td >
</ tr >
< tr >
2005-12-13 23:24:05 -05:00
< th scope = " row " align = " right " >< label for = " descr " >< ? php _e ( 'Description:' ); ?> </label></th>
2005-11-16 22:19:19 -05:00
< td >< input type = " textarea " name = " descr " id = " descr " value = " " /></ td >
</ tr >
2005-11-28 18:13:35 -05:00
< tr id = " buttons " >
< th ></ th >
< td >
2005-11-12 23:40:18 -05:00
< input type = " hidden " name = " action " value = " save " />
< input type = " hidden " name = " post " value = " <?php echo $post ; ?> " />
< input type = " hidden " name = " all " value = " <?php echo $all ; ?> " />
2005-12-13 23:24:05 -05:00
< input type = " hidden " name = " start " value = " <?php echo $start ; ?> " />
< div id = " submit " >
2005-11-12 23:40:18 -05:00
< input type = " submit " value = " <?php _e('Upload'); ?> " />
2005-12-13 23:24:05 -05:00
< ? php if ( ! empty ( $all ) ) : ?>
2005-11-12 23:40:18 -05:00
< input type = " button " value = " <?php _e('Cancel'); ?> " onclick = " cancelUpload() " />
2005-12-13 23:24:05 -05:00
< ? php endif ; ?>
</ div >
2005-11-28 18:13:35 -05:00
</ td >
</ tr >
</ table >
2005-11-12 23:40:18 -05:00
</ div >
</ form >
2005-12-14 03:29:43 -05:00
< ? php elseif ( $action == 'links' ) : ?>
< div id = " links " >
< ? php the_attachment_links ( $attachment ); ?>
</ div >
2005-11-12 23:40:18 -05:00
< ? php endif ; ?>
</ body >
2005-11-28 18:13:35 -05:00
</ html >