Set eol style. fixes #3264

git-svn-id: http://svn.automattic.com/wordpress/trunk@4424 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-10-25 22:55:05 +00:00
parent ea1d50ffc3
commit c476029674
11 changed files with 2521 additions and 2521 deletions

View File

@ -1,220 +1,220 @@
<?php
require_once('admin.php');
$parent_file = 'edit.php';
$submenu_file = 'edit-comments.php';
wp_reset_vars(array('action'));
if ( isset( $_POST['deletecomment'] ) )
$action = 'deletecomment';
switch($action) {
case 'editcomment':
$title = __('Edit Comment');
require_once ('admin-header.php');
$comment = (int) $_GET['comment'];
if ( ! $comment = get_comment($comment) )
wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
wp_die( __('You are not allowed to edit comments on this post.') );
$comment = get_comment_to_edit($comment);
include('edit-form-comment.php');
break;
case 'confirmdeletecomment':
case 'mailapprovecomment':
require_once('./admin-header.php');
$comment = (int) $_GET['comment'];
$p = (int) $_GET['p'];
$formaction = 'confirmdeletecomment' == $action ? 'deletecomment' : 'approvecomment';
$nonce_action = 'confirmdeletecomment' == $action ? 'delete-comment_' : 'approve-comment_';
$nonce_action .= $comment;
if ( ! $comment = get_comment($comment) )
wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
wp_die( 'confirmdeletecomment' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
?>
<div class='wrap'>
<div class="narrow">
<?php if ( 'spam' == $_GET['delete_type'] ) { ?>
<p><?php _e('<strong>Caution:</strong> You are about to mark the following comment as spam:'); ?></p>
<?php } elseif ( 'confirmdeletecomment' == $action ) { ?>
<p><?php _e('<strong>Caution:</strong> You are about to delete the following comment:'); ?></p>
<?php } else { ?>
<p><?php _e('<strong>Caution:</strong> You are about to approve the following comment:'); ?></p>
<?php } ?>
<p><?php _e('Are you sure you want to do that?'); ?></p>
<form action='<?php echo get_option('siteurl'); ?>/wp-admin/comment.php' method='get'>
<table width="100%">
<tr>
<td><input type='button' value='<?php _e('No'); ?>' onclick="self.location='<?php echo get_option('siteurl'); ?>/wp-admin/edit-comments.php';" /></td>
<td align="right"><input type='submit' value='<?php _e('Yes'); ?>' /></td>
</tr>
</table>
<?php wp_nonce_field($nonce_action); ?>
<input type='hidden' name='action' value='<?php echo $formaction; ?>' />
<?php if ( 'spam' == $_GET['delete_type'] ) { ?>
<input type='hidden' name='delete_type' value='spam' />
<?php } ?>
<input type='hidden' name='p' value='<?php echo $comment->comment_post_ID; ?>' />
<input type='hidden' name='comment' value='<?php echo $comment->comment_ID; ?>' />
<input type='hidden' name='noredir' value='1' />
</form>
<table class="editform" cellpadding="5">
<tr class="alt">
<th scope="row"><?php _e('Author:'); ?></th>
<td><?php echo $comment->comment_author; ?></td>
</tr>
<?php if ( $comment->comment_author_email ) { ?>
<tr>
<th scope="row"><?php _e('E-mail:'); ?></th>
<td><?php echo $comment->comment_author_email; ?></td>
</tr>
<?php } ?>
<?php if ( $comment->comment_author_url ) { ?>
<tr>
<th scope="row"><?php _e('URL:'); ?></th>
<td><?php echo $comment->comment_author_url; ?></td>
</tr>
<?php } ?>
<tr>
<th scope="row" valign="top"><p><?php _e('Comment:'); ?></p></th>
<td><?php echo apply_filters( 'comment_text', $comment->comment_content ); ?></td>
</tr>
</table>
</div>
</div>
<?php
break;
case 'deletecomment':
$comment = (int) $_REQUEST['comment'];
check_admin_referer('delete-comment_' . $comment);
$p = (int) $_REQUEST['p'];
if ( isset($_REQUEST['noredir']) ) {
$noredir = true;
} else {
$noredir = false;
}
$postdata = get_post($p) or
wp_die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( ! $comment = get_comment($comment) )
wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
wp_die( __('You are not allowed to edit comments on this post.') );
if ( 'spam' == $_REQUEST['delete_type'] )
wp_set_comment_status($comment->comment_ID, 'spam');
else
wp_delete_comment($comment->comment_ID);
if ((wp_get_referer() != '') && (false == $noredir)) {
wp_redirect(wp_get_referer());
} else {
wp_redirect(get_option('siteurl') .'/wp-admin/edit-comments.php');
}
exit();
break;
case 'unapprovecomment':
$comment = (int) $_GET['comment'];
check_admin_referer('unapprove-comment_' . $comment);
$p = (int) $_GET['p'];
if (isset($_GET['noredir'])) {
$noredir = true;
} else {
$noredir = false;
}
if ( ! $comment = get_comment($comment) )
wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
wp_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
wp_set_comment_status($comment->comment_ID, "hold");
if ((wp_get_referer() != "") && (false == $noredir)) {
wp_redirect(wp_get_referer());
} else {
wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
}
exit();
break;
case 'approvecomment':
$comment = (int) $_GET['comment'];
check_admin_referer('approve-comment_' . $comment);
$p = (int) $_GET['p'];
if (isset($_GET['noredir'])) {
$noredir = true;
} else {
$noredir = false;
}
if ( ! $comment = get_comment($comment) )
wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
wp_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
wp_set_comment_status($comment->comment_ID, "approve");
if (get_option("comments_notify") == true) {
wp_notify_postauthor($comment->comment_ID);
}
if ((wp_get_referer() != "") && (false == $noredir)) {
wp_redirect(wp_get_referer());
} else {
wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
}
exit();
break;
case 'editedcomment':
$comment_ID = (int) $_POST['comment_ID'];
$comment_post_ID = (int) $_POST['comment_post_id'];
check_admin_referer('update-comment_' . $comment_ID);
edit_comment();
$location = ( empty($_POST['referredby']) ? "edit.php?p=$comment_post_ID&c=1" : $_POST['referredby'] ) . '#comment-' . $comment_ID;
$location = apply_filters('comment_edit_redirect', $location, $comment_ID);
wp_redirect($location);
break;
default:
break;
} // end switch
include('admin-footer.php');
?>
<?php
require_once('admin.php');
$parent_file = 'edit.php';
$submenu_file = 'edit-comments.php';
wp_reset_vars(array('action'));
if ( isset( $_POST['deletecomment'] ) )
$action = 'deletecomment';
switch($action) {
case 'editcomment':
$title = __('Edit Comment');
require_once ('admin-header.php');
$comment = (int) $_GET['comment'];
if ( ! $comment = get_comment($comment) )
wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
wp_die( __('You are not allowed to edit comments on this post.') );
$comment = get_comment_to_edit($comment);
include('edit-form-comment.php');
break;
case 'confirmdeletecomment':
case 'mailapprovecomment':
require_once('./admin-header.php');
$comment = (int) $_GET['comment'];
$p = (int) $_GET['p'];
$formaction = 'confirmdeletecomment' == $action ? 'deletecomment' : 'approvecomment';
$nonce_action = 'confirmdeletecomment' == $action ? 'delete-comment_' : 'approve-comment_';
$nonce_action .= $comment;
if ( ! $comment = get_comment($comment) )
wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
wp_die( 'confirmdeletecomment' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
?>
<div class='wrap'>
<div class="narrow">
<?php if ( 'spam' == $_GET['delete_type'] ) { ?>
<p><?php _e('<strong>Caution:</strong> You are about to mark the following comment as spam:'); ?></p>
<?php } elseif ( 'confirmdeletecomment' == $action ) { ?>
<p><?php _e('<strong>Caution:</strong> You are about to delete the following comment:'); ?></p>
<?php } else { ?>
<p><?php _e('<strong>Caution:</strong> You are about to approve the following comment:'); ?></p>
<?php } ?>
<p><?php _e('Are you sure you want to do that?'); ?></p>
<form action='<?php echo get_option('siteurl'); ?>/wp-admin/comment.php' method='get'>
<table width="100%">
<tr>
<td><input type='button' value='<?php _e('No'); ?>' onclick="self.location='<?php echo get_option('siteurl'); ?>/wp-admin/edit-comments.php';" /></td>
<td align="right"><input type='submit' value='<?php _e('Yes'); ?>' /></td>
</tr>
</table>
<?php wp_nonce_field($nonce_action); ?>
<input type='hidden' name='action' value='<?php echo $formaction; ?>' />
<?php if ( 'spam' == $_GET['delete_type'] ) { ?>
<input type='hidden' name='delete_type' value='spam' />
<?php } ?>
<input type='hidden' name='p' value='<?php echo $comment->comment_post_ID; ?>' />
<input type='hidden' name='comment' value='<?php echo $comment->comment_ID; ?>' />
<input type='hidden' name='noredir' value='1' />
</form>
<table class="editform" cellpadding="5">
<tr class="alt">
<th scope="row"><?php _e('Author:'); ?></th>
<td><?php echo $comment->comment_author; ?></td>
</tr>
<?php if ( $comment->comment_author_email ) { ?>
<tr>
<th scope="row"><?php _e('E-mail:'); ?></th>
<td><?php echo $comment->comment_author_email; ?></td>
</tr>
<?php } ?>
<?php if ( $comment->comment_author_url ) { ?>
<tr>
<th scope="row"><?php _e('URL:'); ?></th>
<td><?php echo $comment->comment_author_url; ?></td>
</tr>
<?php } ?>
<tr>
<th scope="row" valign="top"><p><?php _e('Comment:'); ?></p></th>
<td><?php echo apply_filters( 'comment_text', $comment->comment_content ); ?></td>
</tr>
</table>
</div>
</div>
<?php
break;
case 'deletecomment':
$comment = (int) $_REQUEST['comment'];
check_admin_referer('delete-comment_' . $comment);
$p = (int) $_REQUEST['p'];
if ( isset($_REQUEST['noredir']) ) {
$noredir = true;
} else {
$noredir = false;
}
$postdata = get_post($p) or
wp_die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( ! $comment = get_comment($comment) )
wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
wp_die( __('You are not allowed to edit comments on this post.') );
if ( 'spam' == $_REQUEST['delete_type'] )
wp_set_comment_status($comment->comment_ID, 'spam');
else
wp_delete_comment($comment->comment_ID);
if ((wp_get_referer() != '') && (false == $noredir)) {
wp_redirect(wp_get_referer());
} else {
wp_redirect(get_option('siteurl') .'/wp-admin/edit-comments.php');
}
exit();
break;
case 'unapprovecomment':
$comment = (int) $_GET['comment'];
check_admin_referer('unapprove-comment_' . $comment);
$p = (int) $_GET['p'];
if (isset($_GET['noredir'])) {
$noredir = true;
} else {
$noredir = false;
}
if ( ! $comment = get_comment($comment) )
wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
wp_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
wp_set_comment_status($comment->comment_ID, "hold");
if ((wp_get_referer() != "") && (false == $noredir)) {
wp_redirect(wp_get_referer());
} else {
wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
}
exit();
break;
case 'approvecomment':
$comment = (int) $_GET['comment'];
check_admin_referer('approve-comment_' . $comment);
$p = (int) $_GET['p'];
if (isset($_GET['noredir'])) {
$noredir = true;
} else {
$noredir = false;
}
if ( ! $comment = get_comment($comment) )
wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
wp_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
wp_set_comment_status($comment->comment_ID, "approve");
if (get_option("comments_notify") == true) {
wp_notify_postauthor($comment->comment_ID);
}
if ((wp_get_referer() != "") && (false == $noredir)) {
wp_redirect(wp_get_referer());
} else {
wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
}
exit();
break;
case 'editedcomment':
$comment_ID = (int) $_POST['comment_ID'];
$comment_post_ID = (int) $_POST['comment_post_id'];
check_admin_referer('update-comment_' . $comment_ID);
edit_comment();
$location = ( empty($_POST['referredby']) ? "edit.php?p=$comment_post_ID&c=1" : $_POST['referredby'] ) . '#comment-' . $comment_ID;
$location = apply_filters('comment_edit_redirect', $location, $comment_ID);
wp_redirect($location);
break;
default:
break;
} // end switch
include('admin-footer.php');
?>

View File

@ -1,108 +1,108 @@
<?php
require_once ('admin.php');
$title = __('Export');
$parent_file = 'edit.php';
if ( isset( $_GET['download'] ) )
export_wp();
require_once ('admin-header.php');
?>
<div class="wrap">
<h2><?php _e('Export'); ?></h2>
<div class="narrow">
<p><?php _e('When you click the button below WordPress will create a XML file for you to save to your computer.'); ?></p>
<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, comments, custom fields, and categories.'); ?></p>
<form action="" method="get">
<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> &raquo;" />
<input type="hidden" name="download" value="true" />
</p>
</form>
</div>
</div>
<?php
function export_wp() {
global $wpdb, $posts, $post;
$filename = 'wordpress.' . date('Y-m-d') . '.xml';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename=$filename");
header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
//$posts = query_posts('');
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts ORDER BY post_date_gmt ASC");
?>
<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"-->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.0/"
>
<channel>
<title><?php bloginfo_rss('name'); ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss("description") ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
<language><?php echo get_option('rss_language'); ?></language>
<?php do_action('rss2_head'); ?>
<?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
<item>
<title><?php the_title_rss() ?></title>
<link><?php permalink_single_rss() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
<dc:creator><?php the_author() ?></dc:creator>
<?php the_category_rss() ?>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<description></description>
<content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded>
<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
<wp:post_name><?php echo $post->post_name; ?></wp:post_name>
<wp:status><?php echo $post->post_status; ?></wp:status>
<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
<?php
$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
if ( $postmeta ) {
?>
<?php foreach( $postmeta as $meta ) { ?>
<wp:postmeta>
<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
<wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value>
</wp:postmeta>
<?php } ?>
<?php } ?>
<?php
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID");
if ( $comments ) { foreach ( $comments as $c ) { ?>
<wp:comment>
<wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
<wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url>
<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>
<wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date>
<wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt>
<wp:comment_content><?php echo $c->comment_content; ?></wp:comment_content>
<wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved>
<wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type>
<wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent>
</wp:comment>
<?php } } ?>
</item>
<?php } } ?>
</channel>
</rss>
<?php
die();
}
include ('admin-footer.php');
<?php
require_once ('admin.php');
$title = __('Export');
$parent_file = 'edit.php';
if ( isset( $_GET['download'] ) )
export_wp();
require_once ('admin-header.php');
?>
<div class="wrap">
<h2><?php _e('Export'); ?></h2>
<div class="narrow">
<p><?php _e('When you click the button below WordPress will create a XML file for you to save to your computer.'); ?></p>
<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, comments, custom fields, and categories.'); ?></p>
<form action="" method="get">
<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> &raquo;" />
<input type="hidden" name="download" value="true" />
</p>
</form>
</div>
</div>
<?php
function export_wp() {
global $wpdb, $posts, $post;
$filename = 'wordpress.' . date('Y-m-d') . '.xml';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename=$filename");
header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
//$posts = query_posts('');
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts ORDER BY post_date_gmt ASC");
?>
<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"-->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.0/"
>
<channel>
<title><?php bloginfo_rss('name'); ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss("description") ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
<language><?php echo get_option('rss_language'); ?></language>
<?php do_action('rss2_head'); ?>
<?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
<item>
<title><?php the_title_rss() ?></title>
<link><?php permalink_single_rss() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
<dc:creator><?php the_author() ?></dc:creator>
<?php the_category_rss() ?>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<description></description>
<content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded>
<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
<wp:post_name><?php echo $post->post_name; ?></wp:post_name>
<wp:status><?php echo $post->post_status; ?></wp:status>
<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
<?php
$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
if ( $postmeta ) {
?>
<?php foreach( $postmeta as $meta ) { ?>
<wp:postmeta>
<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
<wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value>
</wp:postmeta>
<?php } ?>
<?php } ?>
<?php
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID");
if ( $comments ) { foreach ( $comments as $c ) { ?>
<wp:comment>
<wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
<wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url>
<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>
<wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date>
<wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt>
<wp:comment_content><?php echo $c->comment_content; ?></wp:comment_content>
<wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved>
<wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type>
<wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent>
</wp:comment>
<?php } } ?>
</item>
<?php } } ?>
</channel>
</rss>
<?php
die();
}
include ('admin-footer.php');
?>

View File

@ -1,194 +1,194 @@
<?php
/* By Shayne Sweeney - http://www.theshayne.com/ */
class BW_Import {
var $file;
function header() {
echo '<div class="wrap">';
echo '<h2>'.__('Import Blogware').'</h2>';
}
function footer() {
echo '</div>';
}
function unhtmlentities($string) { // From php.net for < 4.3 compat
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
function greet() {
echo '<div class="narrow">';
echo '<p>'.__('Howdy! This importer allows you to extract posts from Blogware XML export file into your blog. Pick a Blogware file to upload and click Import.').'</p>';
wp_import_upload_form("admin.php?import=blogware&amp;step=1");
echo '</div>';
}
function import_posts() {
global $wpdb, $current_user;
set_magic_quotes_runtime(0);
$importdata = file($this->file); // Read the file into an array
$importdata = implode('', $importdata); // squish it
$importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata);
preg_match_all('|(<item[^>]+>(.*?)</item>)|is', $importdata, $posts);
$posts = $posts[1];
unset($importdata);
echo '<ol>';
foreach ($posts as $post) {
flush();
preg_match('|<item type=\"(.*?)\">|is', $post, $post_type);
$post_type = $post_type[1];
if($post_type == "photo") {
preg_match('|<photoFilename>(.*?)</photoFilename>|is', $post, $post_title);
} else {
preg_match('|<title>(.*?)</title>|is', $post, $post_title);
}
$post_title = $wpdb->escape(trim($post_title[1]));
preg_match('|<pubDate>(.*?)</pubDate>|is', $post, $post_date);
$post_date = strtotime($post_date[1]);
$post_date = gmdate('Y-m-d H:i:s', $post_date);
preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
$categories = $categories[1];
$cat_index = 0;
foreach ($categories as $category) {
$categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
$cat_index++;
}
if(strcasecmp($post_type, "photo") === 0) {
preg_match('|<sizedPhotoUrl>(.*?)</sizedPhotoUrl>|is', $post, $post_content);
$post_content = '<img src="'.trim($post_content[1]).'" />';
$post_content = $this->unhtmlentities($post_content);
} else {
preg_match('|<body>(.*?)</body>|is', $post, $post_content);
$post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
$post_content = $this->unhtmlentities($post_content);
}
// Clean up content
$post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
$post_content = $wpdb->escape($post_content);
$post_author = $current_user->ID;
preg_match('|<postStatus>(.*?)</postStatus>|is', $post, $post_status);
$post_status = trim($post_status[1]);
echo '<li>';
if ($post_id = post_exists($post_title, $post_content, $post_date)) {
printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
} else {
printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
$postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($postdata);
if (!$post_id) {
_e("Couldn't get post ID");
echo '</li>';
break;
}
if(0 != count($categories))
wp_create_categories($categories, $post_id);
}
preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments);
$comments = $comments[1];
if ( $comments ) {
$comment_post_ID = $post_id;
$num_comments = 0;
foreach ($comments as $comment) {
preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
$comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
$comment_content = $this->unhtmlentities($comment_content);
// Clean up content
$comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
$comment_content = str_replace('<br>', '<br />', $comment_content);
$comment_content = str_replace('<hr>', '<hr />', $comment_content);
$comment_content = $wpdb->escape($comment_content);
preg_match('|<pubDate>(.*?)</pubDate>|is', $comment, $comment_date);
$comment_date = trim($comment_date[1]);
$comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
preg_match('|<author>(.*?)</author>|is', $comment, $comment_author);
$comment_author = $wpdb->escape(trim($comment_author[1]));
$comment_author_email = NULL;
$comment_approved = 1;
// Check if it's already there
if (!comment_exists($comment_author, $comment_date)) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_date', 'comment_content', 'comment_approved');
$commentdata = wp_filter_comment($commentdata);
wp_insert_comment($commentdata);
$num_comments++;
}
}
}
if ( $num_comments ) {
echo ' ';
printf(__('(%s comments)'), $num_comments);
}
echo '</li>';
flush();
ob_flush();
}
echo '</ol>';
}
function import() {
$file = wp_import_handle_upload();
if ( isset($file['error']) ) {
echo $file['error'];
return;
}
$this->file = $file['file'];
$this->import_posts();
wp_import_cleanup($file['id']);
echo '<h3>';
printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
echo '</h3>';
}
function dispatch() {
if (empty ($_GET['step']))
$step = 0;
else
$step = (int) $_GET['step'];
$this->header();
switch ($step) {
case 0 :
$this->greet();
break;
case 1 :
$this->import();
break;
}
$this->footer();
}
function BW_Import() {
// Nothing.
}
}
$blogware_import = new BW_Import();
register_importer('blogware', __('Blogware'), __('Import posts from Blogware'), array ($blogware_import, 'dispatch'));
?>
<?php
/* By Shayne Sweeney - http://www.theshayne.com/ */
class BW_Import {
var $file;
function header() {
echo '<div class="wrap">';
echo '<h2>'.__('Import Blogware').'</h2>';
}
function footer() {
echo '</div>';
}
function unhtmlentities($string) { // From php.net for < 4.3 compat
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
function greet() {
echo '<div class="narrow">';
echo '<p>'.__('Howdy! This importer allows you to extract posts from Blogware XML export file into your blog. Pick a Blogware file to upload and click Import.').'</p>';
wp_import_upload_form("admin.php?import=blogware&amp;step=1");
echo '</div>';
}
function import_posts() {
global $wpdb, $current_user;
set_magic_quotes_runtime(0);
$importdata = file($this->file); // Read the file into an array
$importdata = implode('', $importdata); // squish it
$importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata);
preg_match_all('|(<item[^>]+>(.*?)</item>)|is', $importdata, $posts);
$posts = $posts[1];
unset($importdata);
echo '<ol>';
foreach ($posts as $post) {
flush();
preg_match('|<item type=\"(.*?)\">|is', $post, $post_type);
$post_type = $post_type[1];
if($post_type == "photo") {
preg_match('|<photoFilename>(.*?)</photoFilename>|is', $post, $post_title);
} else {
preg_match('|<title>(.*?)</title>|is', $post, $post_title);
}
$post_title = $wpdb->escape(trim($post_title[1]));
preg_match('|<pubDate>(.*?)</pubDate>|is', $post, $post_date);
$post_date = strtotime($post_date[1]);
$post_date = gmdate('Y-m-d H:i:s', $post_date);
preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
$categories = $categories[1];
$cat_index = 0;
foreach ($categories as $category) {
$categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
$cat_index++;
}
if(strcasecmp($post_type, "photo") === 0) {
preg_match('|<sizedPhotoUrl>(.*?)</sizedPhotoUrl>|is', $post, $post_content);
$post_content = '<img src="'.trim($post_content[1]).'" />';
$post_content = $this->unhtmlentities($post_content);
} else {
preg_match('|<body>(.*?)</body>|is', $post, $post_content);
$post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
$post_content = $this->unhtmlentities($post_content);
}
// Clean up content
$post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
$post_content = $wpdb->escape($post_content);
$post_author = $current_user->ID;
preg_match('|<postStatus>(.*?)</postStatus>|is', $post, $post_status);
$post_status = trim($post_status[1]);
echo '<li>';
if ($post_id = post_exists($post_title, $post_content, $post_date)) {
printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
} else {
printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
$postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($postdata);
if (!$post_id) {
_e("Couldn't get post ID");
echo '</li>';
break;
}
if(0 != count($categories))
wp_create_categories($categories, $post_id);
}
preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments);
$comments = $comments[1];
if ( $comments ) {
$comment_post_ID = $post_id;
$num_comments = 0;
foreach ($comments as $comment) {
preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
$comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
$comment_content = $this->unhtmlentities($comment_content);
// Clean up content
$comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
$comment_content = str_replace('<br>', '<br />', $comment_content);
$comment_content = str_replace('<hr>', '<hr />', $comment_content);
$comment_content = $wpdb->escape($comment_content);
preg_match('|<pubDate>(.*?)</pubDate>|is', $comment, $comment_date);
$comment_date = trim($comment_date[1]);
$comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
preg_match('|<author>(.*?)</author>|is', $comment, $comment_author);
$comment_author = $wpdb->escape(trim($comment_author[1]));
$comment_author_email = NULL;
$comment_approved = 1;
// Check if it's already there
if (!comment_exists($comment_author, $comment_date)) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_date', 'comment_content', 'comment_approved');
$commentdata = wp_filter_comment($commentdata);
wp_insert_comment($commentdata);
$num_comments++;
}
}
}
if ( $num_comments ) {
echo ' ';
printf(__('(%s comments)'), $num_comments);
}
echo '</li>';
flush();
ob_flush();
}
echo '</ol>';
}
function import() {
$file = wp_import_handle_upload();
if ( isset($file['error']) ) {
echo $file['error'];
return;
}
$this->file = $file['file'];
$this->import_posts();
wp_import_cleanup($file['id']);
echo '<h3>';
printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
echo '</h3>';
}
function dispatch() {
if (empty ($_GET['step']))
$step = 0;
else
$step = (int) $_GET['step'];
$this->header();
switch ($step) {
case 0 :
$this->greet();
break;
case 1 :
$this->import();
break;
}
$this->footer();
}
function BW_Import() {
// Nothing.
}
}
$blogware_import = new BW_Import();
register_importer('blogware', __('Blogware'), __('Import posts from Blogware'), array ($blogware_import, 'dispatch'));
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,313 +1,313 @@
<?php
class WP_Import {
var $posts = array ();
var $file;
var $id;
var $mtnames = array ();
var $newauthornames = array ();
var $j = -1;
function header() {
echo '<div class="wrap">';
echo '<h2>'.__('Import WordPress').'</h2>';
}
function footer() {
echo '</div>';
}
function unhtmlentities($string) { // From php.net for < 4.3 compat
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
function greet() {
echo '<div class="narrow">';
echo '<p>'.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import the posts, comments, custom fields, and categories into this blog.').'</p>';
wp_import_upload_form("admin.php?import=wordpress&amp;step=1");
echo '</div>';
}
function get_tag( $string, $tag ) {
preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
$return = addslashes( trim( $return[1] ) );
return $return;
}
function users_form($n) {
global $wpdb, $testing;
$users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID");
?><select name="userselect[<?php echo $n; ?>]">
<option value="#NONE#">- Select -</option>
<?php
foreach ($users as $user) {
echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
}
?>
</select>
<?php
}
//function to check the authorname and do the mapping
function checkauthor($author) {
global $wpdb;
//mtnames is an array with the names in the mt import file
$pass = 'changeme';
if (!(in_array($author, $this->mtnames))) { //a new mt author name is found
++ $this->j;
$this->mtnames[$this->j] = $author; //add that new mt author name to an array
$user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user
if (!$user_id) { //banging my head against the desk now.
if ($newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname
$user_id = wp_create_user($author, $pass);
$this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank.
} else {
$user_id = wp_create_user($this->newauthornames[$this->j], $pass);
}
} else {
return $user_id; // return pre-existing wp username if it exists
}
} else {
$key = array_search($author, $this->mtnames); //find the array key for $author in the $mtnames array
$user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames
}
return $user_id;
}
function get_entries() {
set_magic_quotes_runtime(0);
$importdata = file($this->file); // Read the file into an array
$importdata = implode('', $importdata); // squish it
$importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata);
preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts);
$this->posts = $this->posts[1];
}
function get_wp_authors() {
$temp = array ();
$i = -1;
foreach ($this->posts as $post) {
if ('' != trim($post)) {
++ $i;
$author = $this->get_tag( $post, 'dc:creator' );
array_push($temp, "$author"); //store the extracted author names in a temporary array
}
}
// We need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting.
$authors[0] = array_shift($temp);
$y = count($temp) + 1;
for ($x = 1; $x < $y; $x ++) {
$next = array_shift($temp);
if (!(in_array($next, $authors)))
array_push($authors, "$next");
}
return $authors;
}
function get_authors_from_post() {
$formnames = array ();
$selectnames = array ();
foreach ($_POST['user'] as $key => $line) {
$newname = trim(stripslashes($line));
if ($newname == '')
$newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form.
array_push($formnames, "$newname");
} // $formnames is the array with the form entered names
foreach ($_POST['userselect'] as $user => $key) {
$selected = trim(stripslashes($key));
array_push($selectnames, "$selected");
}
$count = count($formnames);
for ($i = 0; $i < $count; $i ++) {
if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form
array_push($this->newauthornames, "$selectnames[$i]");
} else {
array_push($this->newauthornames, "$formnames[$i]");
}
}
}
function wp_authors_form() {
?>
<h2><?php _e('Assign Authors'); ?></h2>
<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
<p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p>
<?php
$authors = $this->get_wp_authors();
echo '<ol id="authors">';
echo '<form action="?import=wordpress&amp;step=2&amp;id=' . $this->id . '" method="post">';
$j = -1;
foreach ($authors as $author) {
++ $j;
echo '<li>'.__('Current author:').' <strong>'.$author.'</strong><br />'.sprintf(__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br />');
$this->users_form($j);
echo '</li>';
}
echo '<input type="submit" value="Submit">'.'<br/>';
echo '</form>';
echo '</ol>';
}
function select_authors() {
$file = wp_import_handle_upload();
if ( isset($file['error']) ) {
$this->header();
echo '<p>'.__('Sorry, there has been an error.').'</p>';
echo '<p><strong>' . $file['error'] . '</strong></p>';
$this->footer();
return;
}
$this->file = $file['file'];
$this->id = $file['id'];
$this->get_entries();
$this->wp_authors_form();
}
function process_posts() {
global $wpdb;
$i = -1;
echo '<ol>';
foreach ($this->posts as $post) {
// There are only ever one of these
$post_title = $this->get_tag( $post, 'title' );
$post_date = $this->get_tag( $post, 'wp:post_date' );
$post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' );
$comment_status = $this->get_tag( $post, 'wp:comment_status' );
$ping_status = $this->get_tag( $post, 'wp:ping_status' );
$post_status = $this->get_tag( $post, 'wp:status' );
$post_parent = $this->get_tag( $post, 'wp:post_parent' );
$post_type = $this->get_tag( $post, 'wp:post_type' );
$guid = $this->get_tag( $post, 'guid' );
$post_author = $this->get_tag( $post, 'dc:creator' );
$post_content = $this->get_tag( $post, 'content:encoded' );
$post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content);
$post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
$categories = $categories[1];
$cat_index = 0;
foreach ($categories as $category) {
$categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
$cat_index++;
}
if ($post_id = post_exists($post_title, '', $post_date)) {
echo '<li>';
printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
} else {
echo '<li>';
printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
$post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor
$postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'post_type');
$comment_post_ID = $post_id = wp_insert_post($postdata);
// Add categories.
if (0 != count($categories)) {
wp_create_categories($categories, $post_id);
}
}
// Now for comments
preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments);
$comments = $comments[1];
$num_comments = 0;
if ( $comments) { foreach ($comments as $comment) {
$comment_author = $this->get_tag( $comment, 'wp:comment_author');
$comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email');
$comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP');
$comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url');
$comment_date = $this->get_tag( $comment, 'wp:comment_date');
$comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt');
$comment_content = $this->get_tag( $comment, 'wp:comment_content');
$comment_approved = $this->get_tag( $comment, 'wp:comment_approved');
$comment_type = $this->get_tag( $comment, 'wp:comment_type');
$comment_parent = $this->get_tag( $comment, 'wp:comment_parent');
if ( !comment_exists($comment_author, $comment_date) ) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent');
wp_insert_comment($commentdata);
$num_comments++;
}
} }
if ( $num_comments )
printf(' '.__('(%s comments)'), $num_comments);
// Now for post meta
preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta);
$postmeta = $postmeta[1];
if ( $postmeta) { foreach ($postmeta as $p) {
$key = $this->get_tag( $p, 'wp:meta_key' );
$value = $this->get_tag( $p, 'wp:meta_value' );
add_post_meta( $post_id, $key, $value );
} }
$index++;
}
echo '</ol>';
wp_import_cleanup($this->id);
echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>';
}
function import() {
$this->id = (int) $_GET['id'];
$this->file = get_attached_file($this->id);
$this->get_authors_from_post();
$this->get_entries();
$this->process_posts();
}
function dispatch() {
if (empty ($_GET['step']))
$step = 0;
else
$step = (int) $_GET['step'];
$this->header();
switch ($step) {
case 0 :
$this->greet();
break;
case 1 :
$this->select_authors();
break;
case 2:
$this->import();
break;
}
$this->footer();
}
function WP_Import() {
// Nothing.
}
}
$wp_import = new WP_Import();
register_importer('wordpress', 'WordPress', __('Import <strong>posts, comments, custom fields, and categories</strong> from a WordPress export file'), array ($wp_import, 'dispatch'));
?>
<?php
class WP_Import {
var $posts = array ();
var $file;
var $id;
var $mtnames = array ();
var $newauthornames = array ();
var $j = -1;
function header() {
echo '<div class="wrap">';
echo '<h2>'.__('Import WordPress').'</h2>';
}
function footer() {
echo '</div>';
}
function unhtmlentities($string) { // From php.net for < 4.3 compat
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
function greet() {
echo '<div class="narrow">';
echo '<p>'.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import the posts, comments, custom fields, and categories into this blog.').'</p>';
wp_import_upload_form("admin.php?import=wordpress&amp;step=1");
echo '</div>';
}
function get_tag( $string, $tag ) {
preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
$return = addslashes( trim( $return[1] ) );
return $return;
}
function users_form($n) {
global $wpdb, $testing;
$users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID");
?><select name="userselect[<?php echo $n; ?>]">
<option value="#NONE#">- Select -</option>
<?php
foreach ($users as $user) {
echo '<option value="'.$user->user_login.'">'.$user->user_login.'</option>';
}
?>
</select>
<?php
}
//function to check the authorname and do the mapping
function checkauthor($author) {
global $wpdb;
//mtnames is an array with the names in the mt import file
$pass = 'changeme';
if (!(in_array($author, $this->mtnames))) { //a new mt author name is found
++ $this->j;
$this->mtnames[$this->j] = $author; //add that new mt author name to an array
$user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user
if (!$user_id) { //banging my head against the desk now.
if ($newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname
$user_id = wp_create_user($author, $pass);
$this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank.
} else {
$user_id = wp_create_user($this->newauthornames[$this->j], $pass);
}
} else {
return $user_id; // return pre-existing wp username if it exists
}
} else {
$key = array_search($author, $this->mtnames); //find the array key for $author in the $mtnames array
$user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames
}
return $user_id;
}
function get_entries() {
set_magic_quotes_runtime(0);
$importdata = file($this->file); // Read the file into an array
$importdata = implode('', $importdata); // squish it
$importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata);
preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts);
$this->posts = $this->posts[1];
}
function get_wp_authors() {
$temp = array ();
$i = -1;
foreach ($this->posts as $post) {
if ('' != trim($post)) {
++ $i;
$author = $this->get_tag( $post, 'dc:creator' );
array_push($temp, "$author"); //store the extracted author names in a temporary array
}
}
// We need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting.
$authors[0] = array_shift($temp);
$y = count($temp) + 1;
for ($x = 1; $x < $y; $x ++) {
$next = array_shift($temp);
if (!(in_array($next, $authors)))
array_push($authors, "$next");
}
return $authors;
}
function get_authors_from_post() {
$formnames = array ();
$selectnames = array ();
foreach ($_POST['user'] as $key => $line) {
$newname = trim(stripslashes($line));
if ($newname == '')
$newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form.
array_push($formnames, "$newname");
} // $formnames is the array with the form entered names
foreach ($_POST['userselect'] as $user => $key) {
$selected = trim(stripslashes($key));
array_push($selectnames, "$selected");
}
$count = count($formnames);
for ($i = 0; $i < $count; $i ++) {
if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form
array_push($this->newauthornames, "$selectnames[$i]");
} else {
array_push($this->newauthornames, "$formnames[$i]");
}
}
}
function wp_authors_form() {
?>
<h2><?php _e('Assign Authors'); ?></h2>
<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
<p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p>
<?php
$authors = $this->get_wp_authors();
echo '<ol id="authors">';
echo '<form action="?import=wordpress&amp;step=2&amp;id=' . $this->id . '" method="post">';
$j = -1;
foreach ($authors as $author) {
++ $j;
echo '<li>'.__('Current author:').' <strong>'.$author.'</strong><br />'.sprintf(__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br />');
$this->users_form($j);
echo '</li>';
}
echo '<input type="submit" value="Submit">'.'<br/>';
echo '</form>';
echo '</ol>';
}
function select_authors() {
$file = wp_import_handle_upload();
if ( isset($file['error']) ) {
$this->header();
echo '<p>'.__('Sorry, there has been an error.').'</p>';
echo '<p><strong>' . $file['error'] . '</strong></p>';
$this->footer();
return;
}
$this->file = $file['file'];
$this->id = $file['id'];
$this->get_entries();
$this->wp_authors_form();
}
function process_posts() {
global $wpdb;
$i = -1;
echo '<ol>';
foreach ($this->posts as $post) {
// There are only ever one of these
$post_title = $this->get_tag( $post, 'title' );
$post_date = $this->get_tag( $post, 'wp:post_date' );
$post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' );
$comment_status = $this->get_tag( $post, 'wp:comment_status' );
$ping_status = $this->get_tag( $post, 'wp:ping_status' );
$post_status = $this->get_tag( $post, 'wp:status' );
$post_parent = $this->get_tag( $post, 'wp:post_parent' );
$post_type = $this->get_tag( $post, 'wp:post_type' );
$guid = $this->get_tag( $post, 'guid' );
$post_author = $this->get_tag( $post, 'dc:creator' );
$post_content = $this->get_tag( $post, 'content:encoded' );
$post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content);
$post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
$categories = $categories[1];
$cat_index = 0;
foreach ($categories as $category) {
$categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
$cat_index++;
}
if ($post_id = post_exists($post_title, '', $post_date)) {
echo '<li>';
printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
} else {
echo '<li>';
printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
$post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor
$postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'post_type');
$comment_post_ID = $post_id = wp_insert_post($postdata);
// Add categories.
if (0 != count($categories)) {
wp_create_categories($categories, $post_id);
}
}
// Now for comments
preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments);
$comments = $comments[1];
$num_comments = 0;
if ( $comments) { foreach ($comments as $comment) {
$comment_author = $this->get_tag( $comment, 'wp:comment_author');
$comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email');
$comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP');
$comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url');
$comment_date = $this->get_tag( $comment, 'wp:comment_date');
$comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt');
$comment_content = $this->get_tag( $comment, 'wp:comment_content');
$comment_approved = $this->get_tag( $comment, 'wp:comment_approved');
$comment_type = $this->get_tag( $comment, 'wp:comment_type');
$comment_parent = $this->get_tag( $comment, 'wp:comment_parent');
if ( !comment_exists($comment_author, $comment_date) ) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent');
wp_insert_comment($commentdata);
$num_comments++;
}
} }
if ( $num_comments )
printf(' '.__('(%s comments)'), $num_comments);
// Now for post meta
preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta);
$postmeta = $postmeta[1];
if ( $postmeta) { foreach ($postmeta as $p) {
$key = $this->get_tag( $p, 'wp:meta_key' );
$value = $this->get_tag( $p, 'wp:meta_value' );
add_post_meta( $post_id, $key, $value );
} }
$index++;
}
echo '</ol>';
wp_import_cleanup($this->id);
echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>';
}
function import() {
$this->id = (int) $_GET['id'];
$this->file = get_attached_file($this->id);
$this->get_authors_from_post();
$this->get_entries();
$this->process_posts();
}
function dispatch() {
if (empty ($_GET['step']))
$step = 0;
else
$step = (int) $_GET['step'];
$this->header();
switch ($step) {
case 0 :
$this->greet();
break;
case 1 :
$this->select_authors();
break;
case 2:
$this->import();
break;
}
$this->footer();
}
function WP_Import() {
// Nothing.
}
}
$wp_import = new WP_Import();
register_importer('wordpress', 'WordPress', __('Import <strong>posts, comments, custom fields, and categories</strong> from a WordPress export file'), array ($wp_import, 'dispatch'));
?>

View File

@ -1,35 +1,35 @@
<?php
require_once('./admin.php');
$title = __('Privacy Options');
$parent_file = 'options-general.php';
include('./admin-header.php');
?>
<div class="wrap">
<h2><?php _e('Privacy Options') ?></h2>
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<table class="optiontable">
<tr valign="top">
<th scope="row"><?php _e('Blog visibility:') ?> </th>
<td>
<p><input id="blog-public" type="radio" name="blog_public" value="1" <?php checked('1', get_option('blog_public')); ?> />
<label for="blog-public"><?php _e('I would like my blog to be visible to everyone, including search engines (like Google, Sphere, Technorati) and archivers');?></label></p>
<p><input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked('0', get_option('blog_public')); ?> />
<label for="blog-norobots"><?php _e('I would like to block search engines, but allow normal visitors'); ?></label></p>
<?php do_action('blog_privacy_selector'); ?>
</td>
</tr>
</table>
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="blog_public" />
</p>
</form>
</div>
<?php include('./admin-footer.php') ?>
<?php
require_once('./admin.php');
$title = __('Privacy Options');
$parent_file = 'options-general.php';
include('./admin-header.php');
?>
<div class="wrap">
<h2><?php _e('Privacy Options') ?></h2>
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<table class="optiontable">
<tr valign="top">
<th scope="row"><?php _e('Blog visibility:') ?> </th>
<td>
<p><input id="blog-public" type="radio" name="blog_public" value="1" <?php checked('1', get_option('blog_public')); ?> />
<label for="blog-public"><?php _e('I would like my blog to be visible to everyone, including search engines (like Google, Sphere, Technorati) and archivers');?></label></p>
<p><input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked('0', get_option('blog_public')); ?> />
<label for="blog-norobots"><?php _e('I would like to block search engines, but allow normal visitors'); ?></label></p>
<?php do_action('blog_privacy_selector'); ?>
</td>
</tr>
</table>
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="blog_public" />
</p>
</form>
</div>
<?php include('./admin-footer.php') ?>

View File

@ -1,160 +1,160 @@
<?php
require_once('admin.php');
$parent_file = 'edit.php';
$submenu_file = 'edit-pages.php';
wp_reset_vars(array('action'));
if (isset($_POST['deletepost'])) {
$action = "delete";
}
switch($action) {
case 'post':
check_admin_referer('add-page');
$page_ID = write_post();
// Redirect.
if (!empty($_POST['mode'])) {
switch($_POST['mode']) {
case 'bookmarklet':
$location = $_POST['referredby'];
break;
case 'sidebar':
$location = 'sidebar.php?a=b';
break;
default:
$location = 'page-new.php';
break;
}
} else {
$location = "page-new.php?posted=$page_ID";
}
if ( isset($_POST['save']) )
$location = "page.php?action=edit&post=$page_ID";
wp_redirect($location);
exit();
break;
case 'edit':
$title = __('Edit');
$editing = true;
$page_ID = $post_ID = $p = (int) $_GET['post'];
$post = get_post_to_edit($page_ID);
if($post->post_status == 'draft') {
wp_enqueue_script('prototype');
wp_enqueue_script('autosave');
}
require_once('admin-header.php');
if ( !current_user_can('edit_page', $page_ID) )
die ( __('You are not allowed to edit this page.') );
include('edit-page-form.php');
?>
<div id='preview' class='wrap'>
<h2 id="preview-post"><?php _e('Page Preview (updated when page is saved)'); ?></h2>
<iframe src="<?php echo wp_specialchars(apply_filters('preview_page_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>
</div>
<?php
break;
case 'editattachment':
$page_id = $post_ID = (int) $_POST['post_ID'];
check_admin_referer('update-attachment_' . $page_id);
// Don't let these be changed
unset($_POST['guid']);
$_POST['post_type'] = 'attachment';
// Update the thumbnail filename
$oldmeta = $newmeta = get_post_meta($page_id, '_wp_attachment_metadata', true);
$newmeta['thumb'] = $_POST['thumb'];
if ( '' !== $oldmeta )
update_post_meta($page_id, '_wp_attachment_metadata', $newmeta, $oldmeta);
else
add_post_meta($page_id, '_wp_attachment_metadata', $newmeta);
case 'editpost':
$page_ID = (int) $_POST['post_ID'];
check_admin_referer('update-page_' . $page_ID);
$page_ID = edit_post();
if ( 'post' == $_POST['originalaction'] ) {
if (!empty($_POST['mode'])) {
switch($_POST['mode']) {
case 'bookmarklet':
$location = $_POST['referredby'];
break;
case 'sidebar':
$location = 'sidebar.php?a=b';
break;
default:
$location = 'page-new.php';
break;
}
} else {
$location = "page-new.php?posted=$page_ID";
}
if ( isset($_POST['save']) )
$location = "page.php?action=edit&post=$page_ID";
} else {
if ($_POST['save']) {
$location = "page.php?action=edit&post=$page_ID";
} elseif ($_POST['updatemeta']) {
$location = wp_get_referer() . '&message=2#postcustom';
} elseif ($_POST['deletemeta']) {
$location = wp_get_referer() . '&message=3#postcustom';
} elseif (!empty($_POST['referredby']) && $_POST['referredby'] != wp_get_referer()) {
$location = $_POST['referredby'];
if ( $_POST['referredby'] == 'redo' )
$location = get_permalink( $page_ID );
} elseif ($action == 'editattachment') {
$location = 'attachments.php';
} else {
$location = 'page-new.php';
}
}
wp_redirect($location); // Send user on their way while we keep working
exit();
break;
case 'delete':
$page_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
check_admin_referer('delete-page_' . $page_id);
$page = & get_post($page_id);
if ( !current_user_can('delete_page', $page_id) )
wp_die( __('You are not allowed to delete this page.') );
if ( $page->post_type == 'attachment' ) {
if ( ! wp_delete_attachment($page_id) )
wp_die( __('Error in deleting...') );
} else {
if ( !wp_delete_post($page_id) )
wp_die( __('Error in deleting...') );
}
$sendback = wp_get_referer();
if (strstr($sendback, 'page.php')) $sendback = get_option('siteurl') .'/wp-admin/page.php';
elseif (strstr($sendback, 'attachments.php')) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
wp_redirect($sendback);
exit();
break;
default:
wp_redirect('edit-pages.php');
exit();
break;
} // end switch
include('admin-footer.php');
?>
<?php
require_once('admin.php');
$parent_file = 'edit.php';
$submenu_file = 'edit-pages.php';
wp_reset_vars(array('action'));
if (isset($_POST['deletepost'])) {
$action = "delete";
}
switch($action) {
case 'post':
check_admin_referer('add-page');
$page_ID = write_post();
// Redirect.
if (!empty($_POST['mode'])) {
switch($_POST['mode']) {
case 'bookmarklet':
$location = $_POST['referredby'];
break;
case 'sidebar':
$location = 'sidebar.php?a=b';
break;
default:
$location = 'page-new.php';
break;
}
} else {
$location = "page-new.php?posted=$page_ID";
}
if ( isset($_POST['save']) )
$location = "page.php?action=edit&post=$page_ID";
wp_redirect($location);
exit();
break;
case 'edit':
$title = __('Edit');
$editing = true;
$page_ID = $post_ID = $p = (int) $_GET['post'];
$post = get_post_to_edit($page_ID);
if($post->post_status == 'draft') {
wp_enqueue_script('prototype');
wp_enqueue_script('autosave');
}
require_once('admin-header.php');
if ( !current_user_can('edit_page', $page_ID) )
die ( __('You are not allowed to edit this page.') );
include('edit-page-form.php');
?>
<div id='preview' class='wrap'>
<h2 id="preview-post"><?php _e('Page Preview (updated when page is saved)'); ?></h2>
<iframe src="<?php echo wp_specialchars(apply_filters('preview_page_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>
</div>
<?php
break;
case 'editattachment':
$page_id = $post_ID = (int) $_POST['post_ID'];
check_admin_referer('update-attachment_' . $page_id);
// Don't let these be changed
unset($_POST['guid']);
$_POST['post_type'] = 'attachment';
// Update the thumbnail filename
$oldmeta = $newmeta = get_post_meta($page_id, '_wp_attachment_metadata', true);
$newmeta['thumb'] = $_POST['thumb'];
if ( '' !== $oldmeta )
update_post_meta($page_id, '_wp_attachment_metadata', $newmeta, $oldmeta);
else
add_post_meta($page_id, '_wp_attachment_metadata', $newmeta);
case 'editpost':
$page_ID = (int) $_POST['post_ID'];
check_admin_referer('update-page_' . $page_ID);
$page_ID = edit_post();
if ( 'post' == $_POST['originalaction'] ) {
if (!empty($_POST['mode'])) {
switch($_POST['mode']) {
case 'bookmarklet':
$location = $_POST['referredby'];
break;
case 'sidebar':
$location = 'sidebar.php?a=b';
break;
default:
$location = 'page-new.php';
break;
}
} else {
$location = "page-new.php?posted=$page_ID";
}
if ( isset($_POST['save']) )
$location = "page.php?action=edit&post=$page_ID";
} else {
if ($_POST['save']) {
$location = "page.php?action=edit&post=$page_ID";
} elseif ($_POST['updatemeta']) {
$location = wp_get_referer() . '&message=2#postcustom';
} elseif ($_POST['deletemeta']) {
$location = wp_get_referer() . '&message=3#postcustom';
} elseif (!empty($_POST['referredby']) && $_POST['referredby'] != wp_get_referer()) {
$location = $_POST['referredby'];
if ( $_POST['referredby'] == 'redo' )
$location = get_permalink( $page_ID );
} elseif ($action == 'editattachment') {
$location = 'attachments.php';
} else {
$location = 'page-new.php';
}
}
wp_redirect($location); // Send user on their way while we keep working
exit();
break;
case 'delete':
$page_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
check_admin_referer('delete-page_' . $page_id);
$page = & get_post($page_id);
if ( !current_user_can('delete_page', $page_id) )
wp_die( __('You are not allowed to delete this page.') );
if ( $page->post_type == 'attachment' ) {
if ( ! wp_delete_attachment($page_id) )
wp_die( __('Error in deleting...') );
} else {
if ( !wp_delete_post($page_id) )
wp_die( __('Error in deleting...') );
}
$sendback = wp_get_referer();
if (strstr($sendback, 'page.php')) $sendback = get_option('siteurl') .'/wp-admin/page.php';
elseif (strstr($sendback, 'attachments.php')) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
wp_redirect($sendback);
exit();
break;
default:
wp_redirect('edit-pages.php');
exit();
break;
} // end switch
include('admin-footer.php');
?>

View File

@ -1,96 +1,96 @@
<?php
require_once('admin.php');
$title = __('Create New Post');
$parent_file = 'post-new.php';
$editing = true;
wp_enqueue_script('prototype');
wp_enqueue_script('autosave');
require_once ('./admin-header.php');
if ( ! current_user_can('edit_posts') ) { ?>
<div class="wrap">
<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />
You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
When you&#8217;re promoted, just reload this page and you&#8217;ll be able to blog. :)'), get_option('admin_email')); ?>
</p>
</div>
<?php
include('admin-footer.php');
exit();
}
if ( isset($_GET['posted']) && $_GET['posted'] ) : ?>
<div id="message" class="updated fade"><p><strong><?php _e('Post saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?> &raquo;</a></p></div>
<?php
endif;
if ( $drafts = get_users_drafts( $user_ID ) ) { ?>
<div class="wrap">
<p><strong><?php _e('Your Drafts:') ?></strong>
<?php
// Show drafts.
$num_drafts = count($drafts);
if ( $num_drafts > 15 ) $num_drafts = 15;
for ( $i = 0; $i < $num_drafts; $i++ ) {
$draft = $drafts[$i];
if ( 0 != $i )
echo ', ';
if ( empty($draft->post_title) )
$draft->post_title = sprintf(__('Post # %s'), $draft->ID);
echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
}
if ( 15 < count($drafts) ) { ?>
, <a href="edit.php"><?php echo sprintf(__('and %s more'), (count($drafts) - 15) ); ?> &raquo;</a>
<?php } ?>
.</p>
</div>
<?php
}
// Show post form.
$post = get_default_post_to_edit();
include('edit-form-advanced.php');
?>
<?php if ( $is_NS4 || $is_gecko || $is_winIE ) { ?>
<div id="wp-bookmarklet" class="wrap">
<h3><?php _e('WordPress bookmarklet'); ?></h3>
<p><?php _e('Right click on the following link and choose "Add to favorites" to create a posting shortcut.'); ?></p>
<p>
<?php
if ($is_NS4 || $is_gecko) {
?>
<a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?></a>
<?php
} else if ($is_winIE) {
?>
<a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
<script type="text/javascript">
<!--
function oneclickbookmarklet(blah) {
window.open ("profile.php?action=IErightclick", "oneclickbookmarklet", "width=500, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=120, left=120, screenY=120, top=120");
}
// -->
</script>
<br />
<br />
<?php _e('One-click bookmarklet:') ?><br />
<a href="javascript:oneclickbookmarklet(0);"><?php _e('click here') ?></a>
<?php
} else if ($is_opera) {
?>
<a href="javascript:location.href='<?php echo get_option('siteurl'); ?>/wp-admin/post-new.php?popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
<?php
} else if ($is_macIE) {
?>
<a href="javascript:Q='';location.href='<?php echo get_option('siteurl'); ?>/wp-admin/bookmarklet.php?text='+escape(document.getSelection())+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
<?php
}
?>
</p>
</div>
<?php } ?>
<?php include('admin-footer.php'); ?>
<?php
require_once('admin.php');
$title = __('Create New Post');
$parent_file = 'post-new.php';
$editing = true;
wp_enqueue_script('prototype');
wp_enqueue_script('autosave');
require_once ('./admin-header.php');
if ( ! current_user_can('edit_posts') ) { ?>
<div class="wrap">
<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />
You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
When you&#8217;re promoted, just reload this page and you&#8217;ll be able to blog. :)'), get_option('admin_email')); ?>
</p>
</div>
<?php
include('admin-footer.php');
exit();
}
if ( isset($_GET['posted']) && $_GET['posted'] ) : ?>
<div id="message" class="updated fade"><p><strong><?php _e('Post saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?> &raquo;</a></p></div>
<?php
endif;
if ( $drafts = get_users_drafts( $user_ID ) ) { ?>
<div class="wrap">
<p><strong><?php _e('Your Drafts:') ?></strong>
<?php
// Show drafts.
$num_drafts = count($drafts);
if ( $num_drafts > 15 ) $num_drafts = 15;
for ( $i = 0; $i < $num_drafts; $i++ ) {
$draft = $drafts[$i];
if ( 0 != $i )
echo ', ';
if ( empty($draft->post_title) )
$draft->post_title = sprintf(__('Post # %s'), $draft->ID);
echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
}
if ( 15 < count($drafts) ) { ?>
, <a href="edit.php"><?php echo sprintf(__('and %s more'), (count($drafts) - 15) ); ?> &raquo;</a>
<?php } ?>
.</p>
</div>
<?php
}
// Show post form.
$post = get_default_post_to_edit();
include('edit-form-advanced.php');
?>
<?php if ( $is_NS4 || $is_gecko || $is_winIE ) { ?>
<div id="wp-bookmarklet" class="wrap">
<h3><?php _e('WordPress bookmarklet'); ?></h3>
<p><?php _e('Right click on the following link and choose "Add to favorites" to create a posting shortcut.'); ?></p>
<p>
<?php
if ($is_NS4 || $is_gecko) {
?>
<a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?></a>
<?php
} else if ($is_winIE) {
?>
<a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
<script type="text/javascript">
<!--
function oneclickbookmarklet(blah) {
window.open ("profile.php?action=IErightclick", "oneclickbookmarklet", "width=500, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=120, left=120, screenY=120, top=120");
}
// -->
</script>
<br />
<br />
<?php _e('One-click bookmarklet:') ?><br />
<a href="javascript:oneclickbookmarklet(0);"><?php _e('click here') ?></a>
<?php
} else if ($is_opera) {
?>
<a href="javascript:location.href='<?php echo get_option('siteurl'); ?>/wp-admin/post-new.php?popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
<?php
} else if ($is_macIE) {
?>
<a href="javascript:Q='';location.href='<?php echo get_option('siteurl'); ?>/wp-admin/bookmarklet.php?text='+escape(document.getSelection())+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
<?php
}
?>
</p>
</div>
<?php } ?>
<?php include('admin-footer.php'); ?>

View File

@ -1,372 +1,372 @@
<?php
function wp_upload_display( $dims = false, $href = '' ) {
global $post;
$id = get_the_ID();
$attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
if ( isset($attachment_data['width']) )
list($width,$height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128);
ob_start();
the_title();
$post_title = wp_specialchars( ob_get_contents(), 1 );
ob_end_clean();
$post_content = apply_filters( 'content_edit_pre', $post->post_content );
$class = 'text';
$innerHTML = get_attachment_innerHTML( $id, false, $dims );
if ( $image_src = strstr($innerHTML, 'src="') ) {
$image_src = explode('"', $image_src);
$image_src = $image_src[1];
$image_rel = wp_make_link_relative($image_src);
$class = 'image';
$innerHTML = '&nbsp;' . str_replace($image_src, $image_rel, $innerHTML);
$image_base = str_replace($image_rel, '', $image_src);
}
$src_base = get_the_guid();
$src = wp_make_link_relative( $src_base );
$src_base = str_replace($src, '', $src_base);
$r = '';
if ( $href )
$r .= "<a id='file-link-$id' href='$href' title='$post_title' class='file-link $class'>\n";
if ( $href || $image_src )
$r .= "\t\t\t$innerHTML";
if ( $href )
$r .= "</a>\n";
$r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='$src' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-url-base-$id' id='attachment-url-base-$id' value='$src_base' />\n";
if ( isset($attachment_data['thumb']) ) {
$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$image_rel' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-$id' id='attachment-thumb-url-base-$id' value='$image_base' />\n";
} elseif ( $image_rel )
$r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-$id' id='attachment-is-image-$id' value='1' />\n";
if ( isset($width) ) {
$r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-height-$id' id='attachment-height-$id' value='$height' />\n";
}
$r .= "\t\t\t\t<input type='hidden' name='attachment-page-url-$id' id='attachment-page-url-$id' value='" . get_attachment_link( $id ) . "' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-title-$id' id='attachment-title-$id' value='$post_title' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-description-$id' id='attachment-description-$id' value='$post_content' />\n";
$r .= "\t\t\t</p>\n\t\t</div>\n";
return $r;
}
function wp_upload_view() {
global $style, $post_id, $style;
$id = get_the_ID();
$attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
?>
<div id="upload-file">
<div id="file-title">
<h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
the_title();
if ( !isset($attachment_data['width']) && 'inline' != $style )
echo '</a>';
?></h2>
<span><?php
echo '[&nbsp;';
echo '<a href="' . get_permalink() . '">' . __('view') . '</a>';
echo '&nbsp;|&nbsp;';
echo '<a href="' . wp_specialchars( add_query_arg( 'action', 'edit' ), 1 ) . '" title="' . __('Edit this file') . '">' . __('edit') . '</a>';
echo '&nbsp;|&nbsp;';
echo '<a href="' . wp_specialchars( remove_query_arg( array('action', 'ID') ), 1 ) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
echo '&nbsp;]'; ?></span>
</div>
<div id="upload-file-view" class="alignleft">
<?php if ( isset($attachment_data['width']) && 'inline' != $style )
echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
echo wp_upload_display( array(171, 128) );
if ( isset($attachment_data['width']) && 'inline' != $style )
echo '</a>'; ?>
</div>
<?php the_attachment_links( $id ); ?>
</div>
<?php echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' ) . "' /></form>\n";
}
function wp_upload_form() {
$id = get_the_ID();
global $post_id, $tab, $style;
$enctype = $id ? '' : ' enctype="multipart/form-data"';
?>
<form<?php echo $enctype; ?> id="upload-file" method="post" action="<?php echo get_option('siteurl') . "/wp-admin/upload.php?style=$style&amp;tab=upload&amp;post_id=$post_id"; ?>">
<?php
if ( $id ) :
$attachment = get_post_to_edit( $id );
$attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
?>
<div id="file-title">
<h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
the_title();
if ( !isset($attachment_data['width']) && 'inline' != $style )
echo '</a>';
?></h2>
<span><?php
echo '[&nbsp;';
echo '<a href="' . get_permalink() . '">' . __('view') . '</a>';
echo '&nbsp;|&nbsp;';
echo '<a href="' . wp_specialchars( add_query_arg( 'action', 'view' ), 1 ) . '">' . __('links') . '</a>';
echo '&nbsp;|&nbsp;';
echo '<a href="' . wp_specialchars( remove_query_arg( array('action','ID') ), 1 ) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
echo '&nbsp;]'; ?></span>
</div>
<div id="upload-file-view" class="alignleft">
<?php if ( isset($attachment_data['width']) && 'inline' != $style )
echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
echo wp_upload_display( array(171, 128) );
if ( isset($attachment_data['width']) && 'inline' != $style )
echo '</a>'; ?>
</div>
<?php endif; ?>
<table><col /><col class="widefat" />
<?php if ( $id ): ?>
<tr>
<th scope="row"><label for="url"><?php _e('URL'); ?></label></th>
<td><input type="text" id="url" class="readonly" value="<?php the_guid(); ?>" readonly="readonly" /></td>
</tr>
<?php else : ?>
<tr>
<th scope="row"><label for="upload"><?php _e('File'); ?></label></th>
<td><input type="file" id="upload" name="image" /></td>
</tr>
<?php endif; ?>
<tr>
<th scope="row"><label for="post_title"><?php _e('Title'); ?></label></th>
<td><input type="text" id="post_title" name="post_title" value="<?php echo $attachment->post_title; ?>" /></td>
</tr>
<tr>
<th scope="row"><label for="post_content"><?php _e('Description'); ?></label></th>
<td><textarea name="post_content" id="post_content"><?php echo $attachment->post_content; ?></textarea></td>
</tr>
<tr id="buttons" class="submit">
<td colspan='2'>
<?php if ( $id ) : ?>
<input type="submit" name="delete" id="delete" class="delete alignleft" value="<?php _e('Delete File'); ?>" />
<?php endif; ?>
<input type="hidden" name="from_tab" value="<?php echo $tab; ?>" />
<input type="hidden" name="action" value="<?php echo $id ? 'save' : 'upload'; ?>" />
<?php if ( $post_id ) : ?>
<input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
<?php endif; if ( $id ) : ?>
<input type="hidden" name="ID" value="<?php echo $id; ?>" />
<?php endif; ?>
<?php wp_nonce_field( 'inlineuploading' ); ?>
<div class="submit">
<input type="submit" value="<?php $id ? _e('Save') : _e('Upload'); ?> &raquo;" />
</div>
</td>
</tr>
</table>
</form>
<?php
}
function wp_upload_tab_upload() {
wp_upload_form();
}
function wp_upload_tab_upload_action() {
global $action;
if ( isset($_POST['delete']) )
$action = 'delete';
switch ( $action ) :
case 'upload' :
global $from_tab, $post_id, $style;
if ( !$from_tab )
$from_tab = 'upload';
check_admin_referer( 'inlineuploading' );
global $post_id, $post_title, $post_content;
if ( !current_user_can( 'upload_files' ) )
wp_die( __('You are not allowed to upload files.')
. " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=$style&amp;tab=browse-all&amp;post_id=$post_id'>"
. __('Browse Files') . '</a>'
);
$overrides = array('action'=>'upload');
$file = wp_handle_upload($_FILES['image'], $overrides);
if ( isset($file['error']) )
wp_die($file['error'] . "<br /><a href='" . get_option('siteurl')
. "/wp-admin/upload.php?style=$style&amp;tab=$from_tab&amp;post_id=$post_id'>'" . __('Back to Image Uploading') . '</a>'
);
$url = $file['url'];
$type = $file['type'];
$file = $file['file'];
$filename = basename($file);
// Construct the attachment array
$attachment = array(
'post_title' => $post_title ? $post_title : $filename,
'post_content' => $post_content,
'post_type' => 'attachment',
'post_parent' => $post_id,
'post_mime_type' => $type,
'guid' => $url
);
// Save the data
$id = wp_insert_attachment($attachment, $file, $post_id);
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 )
$thumb = wp_create_thumbnail($file, 128);
elseif ( $imagedata['height'] > 96 )
$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;
}
}
} else {
add_post_meta($id, '_wp_attachment_metadata', array());
}
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id");
die;
break;
case 'save' :
global $from_tab, $post_id, $style;
if ( !$from_tab )
$from_tab = 'upload';
check_admin_referer( 'inlineuploading' );
wp_update_post($_POST);
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id");
die;
break;
case 'delete' :
global $ID, $post_id, $from_tab, $style;
if ( !$from_tab )
$from_tab = 'upload';
check_admin_referer( 'inlineuploading' );
if ( !current_user_can('edit_post', (int) $ID) )
wp_die( __('You are not allowed to delete this attachment.')
. " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=$style&amp;tab=$from_tab&amp;post_id=$post_id'>"
. __('Go back') . '</a>'
);
wp_delete_attachment($ID);
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id" );
die;
break;
endswitch;
}
add_action( 'upload_files_upload', 'wp_upload_tab_upload_action' );
function wp_upload_grab_attachments( $obj ) {
$obj->is_attachment = true;
}
function wp_upload_posts_where( $where ) {
global $post_id;
return $where . " AND post_parent = '" . (int) $post_id . "'";
}
function wp_upload_tab_browse() {
global $wpdb, $action, $paged;
$old_vars = compact( 'paged' );
switch ( $action ) :
case 'edit' :
case 'view' :
global $ID;
$attachments = query_posts("attachment_id=$ID");
if ( have_posts() ) : while ( have_posts() ) : the_post();
'edit' == $action ? wp_upload_form() : wp_upload_view();
endwhile; endif;
break;
default :
global $tab, $post_id, $style;
add_action( 'pre_get_posts', 'wp_upload_grab_attachments' );
if ( 'browse' == $tab && $post_id )
add_filter( 'posts_where', 'wp_upload_posts_where' );
$attachments = query_posts("what_to_show=posts&posts_per_page=10&paged=$paged");
$count_query = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'";
if ( $post_id )
$count_query .= " AND post_parent = '$post_id'";
$total = $wpdb->get_var($count_query);
echo "<ul id='upload-files'>\n";
if ( have_posts() ) : while ( have_posts() ) : the_post();
$href = wp_specialchars( add_query_arg( array(
'action' => 'inline' == $style ? 'view' : 'edit',
'ID' => get_the_ID())
), 1 );
echo "\t<li id='file-";
the_ID();
echo "' class='alignleft'>\n";
echo wp_upload_display( array(128,128), $href );
echo "\t</li>\n";
endwhile;
else :
echo "\t<li>" . __('There are no attachments to show.') . "</li>\n";
endif;
echo "</ul>\n\n";
echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' ) . "' /></form>\n";
break;
endswitch;
extract($old_vars);
}
function wp_upload_tab_browse_action() {
global $style;
if ( 'inline' == $style )
wp_enqueue_script('upload');
}
add_action( 'upload_files_browse', 'wp_upload_tab_browse_action' );
add_action( 'upload_files_browse-all', 'wp_upload_tab_browse_action' );
function wp_upload_admin_head() {
global $wp_locale;
echo "<link rel='stylesheet' href='" . get_option('siteurl') . '/wp-admin/upload.css?version=' . get_bloginfo('version') . "' type='text/css' />\n";
if ( 'rtl' == $wp_locale->text_direction )
echo "<link rel='stylesheet' href='" . get_option('siteurl') . '/wp-admin/upload-rtl.css?version=' . get_bloginfo('version') . "' type='text/css' />\n";
if ( 'inline' == @$_GET['style'] ) {
echo "<style type='text/css'>\n";
echo "\tbody { height: 15em; overflow: hidden; }\n";
echo "\t#upload-content { overflow-y: auto; }\n";
echo "\t#upload-file { position: absolute; }\n";
echo "</style>";
}
}
<?php
function wp_upload_display( $dims = false, $href = '' ) {
global $post;
$id = get_the_ID();
$attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
if ( isset($attachment_data['width']) )
list($width,$height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128);
ob_start();
the_title();
$post_title = wp_specialchars( ob_get_contents(), 1 );
ob_end_clean();
$post_content = apply_filters( 'content_edit_pre', $post->post_content );
$class = 'text';
$innerHTML = get_attachment_innerHTML( $id, false, $dims );
if ( $image_src = strstr($innerHTML, 'src="') ) {
$image_src = explode('"', $image_src);
$image_src = $image_src[1];
$image_rel = wp_make_link_relative($image_src);
$class = 'image';
$innerHTML = '&nbsp;' . str_replace($image_src, $image_rel, $innerHTML);
$image_base = str_replace($image_rel, '', $image_src);
}
$src_base = get_the_guid();
$src = wp_make_link_relative( $src_base );
$src_base = str_replace($src, '', $src_base);
$r = '';
if ( $href )
$r .= "<a id='file-link-$id' href='$href' title='$post_title' class='file-link $class'>\n";
if ( $href || $image_src )
$r .= "\t\t\t$innerHTML";
if ( $href )
$r .= "</a>\n";
$r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='$src' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-url-base-$id' id='attachment-url-base-$id' value='$src_base' />\n";
if ( isset($attachment_data['thumb']) ) {
$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$image_rel' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-$id' id='attachment-thumb-url-base-$id' value='$image_base' />\n";
} elseif ( $image_rel )
$r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-$id' id='attachment-is-image-$id' value='1' />\n";
if ( isset($width) ) {
$r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-height-$id' id='attachment-height-$id' value='$height' />\n";
}
$r .= "\t\t\t\t<input type='hidden' name='attachment-page-url-$id' id='attachment-page-url-$id' value='" . get_attachment_link( $id ) . "' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-title-$id' id='attachment-title-$id' value='$post_title' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-description-$id' id='attachment-description-$id' value='$post_content' />\n";
$r .= "\t\t\t</p>\n\t\t</div>\n";
return $r;
}
function wp_upload_view() {
global $style, $post_id, $style;
$id = get_the_ID();
$attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
?>
<div id="upload-file">
<div id="file-title">
<h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
the_title();
if ( !isset($attachment_data['width']) && 'inline' != $style )
echo '</a>';
?></h2>
<span><?php
echo '[&nbsp;';
echo '<a href="' . get_permalink() . '">' . __('view') . '</a>';
echo '&nbsp;|&nbsp;';
echo '<a href="' . wp_specialchars( add_query_arg( 'action', 'edit' ), 1 ) . '" title="' . __('Edit this file') . '">' . __('edit') . '</a>';
echo '&nbsp;|&nbsp;';
echo '<a href="' . wp_specialchars( remove_query_arg( array('action', 'ID') ), 1 ) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
echo '&nbsp;]'; ?></span>
</div>
<div id="upload-file-view" class="alignleft">
<?php if ( isset($attachment_data['width']) && 'inline' != $style )
echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
echo wp_upload_display( array(171, 128) );
if ( isset($attachment_data['width']) && 'inline' != $style )
echo '</a>'; ?>
</div>
<?php the_attachment_links( $id ); ?>
</div>
<?php echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' ) . "' /></form>\n";
}
function wp_upload_form() {
$id = get_the_ID();
global $post_id, $tab, $style;
$enctype = $id ? '' : ' enctype="multipart/form-data"';
?>
<form<?php echo $enctype; ?> id="upload-file" method="post" action="<?php echo get_option('siteurl') . "/wp-admin/upload.php?style=$style&amp;tab=upload&amp;post_id=$post_id"; ?>">
<?php
if ( $id ) :
$attachment = get_post_to_edit( $id );
$attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
?>
<div id="file-title">
<h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
the_title();
if ( !isset($attachment_data['width']) && 'inline' != $style )
echo '</a>';
?></h2>
<span><?php
echo '[&nbsp;';
echo '<a href="' . get_permalink() . '">' . __('view') . '</a>';
echo '&nbsp;|&nbsp;';
echo '<a href="' . wp_specialchars( add_query_arg( 'action', 'view' ), 1 ) . '">' . __('links') . '</a>';
echo '&nbsp;|&nbsp;';
echo '<a href="' . wp_specialchars( remove_query_arg( array('action','ID') ), 1 ) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
echo '&nbsp;]'; ?></span>
</div>
<div id="upload-file-view" class="alignleft">
<?php if ( isset($attachment_data['width']) && 'inline' != $style )
echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
echo wp_upload_display( array(171, 128) );
if ( isset($attachment_data['width']) && 'inline' != $style )
echo '</a>'; ?>
</div>
<?php endif; ?>
<table><col /><col class="widefat" />
<?php if ( $id ): ?>
<tr>
<th scope="row"><label for="url"><?php _e('URL'); ?></label></th>
<td><input type="text" id="url" class="readonly" value="<?php the_guid(); ?>" readonly="readonly" /></td>
</tr>
<?php else : ?>
<tr>
<th scope="row"><label for="upload"><?php _e('File'); ?></label></th>
<td><input type="file" id="upload" name="image" /></td>
</tr>
<?php endif; ?>
<tr>
<th scope="row"><label for="post_title"><?php _e('Title'); ?></label></th>
<td><input type="text" id="post_title" name="post_title" value="<?php echo $attachment->post_title; ?>" /></td>
</tr>
<tr>
<th scope="row"><label for="post_content"><?php _e('Description'); ?></label></th>
<td><textarea name="post_content" id="post_content"><?php echo $attachment->post_content; ?></textarea></td>
</tr>
<tr id="buttons" class="submit">
<td colspan='2'>
<?php if ( $id ) : ?>
<input type="submit" name="delete" id="delete" class="delete alignleft" value="<?php _e('Delete File'); ?>" />
<?php endif; ?>
<input type="hidden" name="from_tab" value="<?php echo $tab; ?>" />
<input type="hidden" name="action" value="<?php echo $id ? 'save' : 'upload'; ?>" />
<?php if ( $post_id ) : ?>
<input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
<?php endif; if ( $id ) : ?>
<input type="hidden" name="ID" value="<?php echo $id; ?>" />
<?php endif; ?>
<?php wp_nonce_field( 'inlineuploading' ); ?>
<div class="submit">
<input type="submit" value="<?php $id ? _e('Save') : _e('Upload'); ?> &raquo;" />
</div>
</td>
</tr>
</table>
</form>
<?php
}
function wp_upload_tab_upload() {
wp_upload_form();
}
function wp_upload_tab_upload_action() {
global $action;
if ( isset($_POST['delete']) )
$action = 'delete';
switch ( $action ) :
case 'upload' :
global $from_tab, $post_id, $style;
if ( !$from_tab )
$from_tab = 'upload';
check_admin_referer( 'inlineuploading' );
global $post_id, $post_title, $post_content;
if ( !current_user_can( 'upload_files' ) )
wp_die( __('You are not allowed to upload files.')
. " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=$style&amp;tab=browse-all&amp;post_id=$post_id'>"
. __('Browse Files') . '</a>'
);
$overrides = array('action'=>'upload');
$file = wp_handle_upload($_FILES['image'], $overrides);
if ( isset($file['error']) )
wp_die($file['error'] . "<br /><a href='" . get_option('siteurl')
. "/wp-admin/upload.php?style=$style&amp;tab=$from_tab&amp;post_id=$post_id'>'" . __('Back to Image Uploading') . '</a>'
);
$url = $file['url'];
$type = $file['type'];
$file = $file['file'];
$filename = basename($file);
// Construct the attachment array
$attachment = array(
'post_title' => $post_title ? $post_title : $filename,
'post_content' => $post_content,
'post_type' => 'attachment',
'post_parent' => $post_id,
'post_mime_type' => $type,
'guid' => $url
);
// Save the data
$id = wp_insert_attachment($attachment, $file, $post_id);
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 )
$thumb = wp_create_thumbnail($file, 128);
elseif ( $imagedata['height'] > 96 )
$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;
}
}
} else {
add_post_meta($id, '_wp_attachment_metadata', array());
}
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id");
die;
break;
case 'save' :
global $from_tab, $post_id, $style;
if ( !$from_tab )
$from_tab = 'upload';
check_admin_referer( 'inlineuploading' );
wp_update_post($_POST);
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id");
die;
break;
case 'delete' :
global $ID, $post_id, $from_tab, $style;
if ( !$from_tab )
$from_tab = 'upload';
check_admin_referer( 'inlineuploading' );
if ( !current_user_can('edit_post', (int) $ID) )
wp_die( __('You are not allowed to delete this attachment.')
. " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=$style&amp;tab=$from_tab&amp;post_id=$post_id'>"
. __('Go back') . '</a>'
);
wp_delete_attachment($ID);
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id" );
die;
break;
endswitch;
}
add_action( 'upload_files_upload', 'wp_upload_tab_upload_action' );
function wp_upload_grab_attachments( $obj ) {
$obj->is_attachment = true;
}
function wp_upload_posts_where( $where ) {
global $post_id;
return $where . " AND post_parent = '" . (int) $post_id . "'";
}
function wp_upload_tab_browse() {
global $wpdb, $action, $paged;
$old_vars = compact( 'paged' );
switch ( $action ) :
case 'edit' :
case 'view' :
global $ID;
$attachments = query_posts("attachment_id=$ID");
if ( have_posts() ) : while ( have_posts() ) : the_post();
'edit' == $action ? wp_upload_form() : wp_upload_view();
endwhile; endif;
break;
default :
global $tab, $post_id, $style;
add_action( 'pre_get_posts', 'wp_upload_grab_attachments' );
if ( 'browse' == $tab && $post_id )
add_filter( 'posts_where', 'wp_upload_posts_where' );
$attachments = query_posts("what_to_show=posts&posts_per_page=10&paged=$paged");
$count_query = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'";
if ( $post_id )
$count_query .= " AND post_parent = '$post_id'";
$total = $wpdb->get_var($count_query);
echo "<ul id='upload-files'>\n";
if ( have_posts() ) : while ( have_posts() ) : the_post();
$href = wp_specialchars( add_query_arg( array(
'action' => 'inline' == $style ? 'view' : 'edit',
'ID' => get_the_ID())
), 1 );
echo "\t<li id='file-";
the_ID();
echo "' class='alignleft'>\n";
echo wp_upload_display( array(128,128), $href );
echo "\t</li>\n";
endwhile;
else :
echo "\t<li>" . __('There are no attachments to show.') . "</li>\n";
endif;
echo "</ul>\n\n";
echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' ) . "' /></form>\n";
break;
endswitch;
extract($old_vars);
}
function wp_upload_tab_browse_action() {
global $style;
if ( 'inline' == $style )
wp_enqueue_script('upload');
}
add_action( 'upload_files_browse', 'wp_upload_tab_browse_action' );
add_action( 'upload_files_browse-all', 'wp_upload_tab_browse_action' );
function wp_upload_admin_head() {
global $wp_locale;
echo "<link rel='stylesheet' href='" . get_option('siteurl') . '/wp-admin/upload.css?version=' . get_bloginfo('version') . "' type='text/css' />\n";
if ( 'rtl' == $wp_locale->text_direction )
echo "<link rel='stylesheet' href='" . get_option('siteurl') . '/wp-admin/upload-rtl.css?version=' . get_bloginfo('version') . "' type='text/css' />\n";
if ( 'inline' == @$_GET['style'] ) {
echo "<style type='text/css'>\n";
echo "\tbody { height: 15em; overflow: hidden; }\n";
echo "\t#upload-content { overflow-y: auto; }\n";
echo "\t#upload-file { position: absolute; }\n";
echo "</style>";
}
}

View File

@ -1,257 +1,257 @@
<?php require_once('admin.php'); cache_javascript_headers(); ?>
addLoadEvent( function() {
theFileList = {
currentImage: {ID: 0},
nonce: '',
tab: '',
postID: 0,
initializeVars: function() {
this.urlData = document.location.href.split('?');
this.params = this.urlData[1].toQueryParams();
this.postID = this.params['post_id'];
this.tab = this.params['tab'];
this.style = this.params['style'];
this.ID = this.params['ID'];
if ( !this.style )
this.style = 'default';
var nonceEl = $('nonce-value');
if ( nonceEl )
this.nonce = nonceEl.value;
if ( this.ID ) {
this.grabImageData( this.ID );
this.imageView( this.ID );
}
},
initializeLinks: function() {
if ( this.ID )
return;
$$('a.file-link').each( function(i) {
var id = i.id.split('-').pop();
i.onclick = function(e) { theFileList[ 'inline' == theFileList.style ? 'imageView' : 'editView' ](id, e); }
} );
},
grabImageData: function(id) {
if ( id == this.currentImage.ID )
return;
var thumbEl = $('attachment-thumb-url-' + id);
this.currentImage.isImage = true;
if ( thumbEl ) {
this.currentImage.thumb = ( 0 == id ? '' : thumbEl.value );
this.currentImage.thumbBase = ( 0 == id ? '' : $('attachment-thumb-url-base-' + id).value );
} else {
this.currentImage.thumb = false;
var isImageEl = $('attachment-is-image-' + id);
if ( !isImageEl )
this.currentImage.isImage = false;
}
this.currentImage.src = ( 0 == id ? '' : $('attachment-url-' + id).value );
this.currentImage.srcBase = ( 0 == id ? '' : $('attachment-url-base-' + id).value );
this.currentImage.page = ( 0 == id ? '' : $('attachment-page-url-' + id).value );
this.currentImage.title = ( 0 == id ? '' : $('attachment-title-' + id).value );
this.currentImage.description = ( 0 == id ? '' : $('attachment-description-' + id).value );
var widthEl = $('attachment-width-' + id);
if ( widthEl ) {
this.currentImage.width = ( 0 == id ? '' : widthEl.value );
this.currentImage.height = ( 0 == id ? '' : $('attachment-height-' + id).value );
} else {
this.currentImage.width = false;
this.currentImage.height = false;
}
this.currentImage.ID = id;
},
imageView: function(id, e) {
this.prepView(id);
var h = '';
h += "<div id='upload-file'>"
if ( this.ID ) {
var params = $H(this.params);
params.ID = '';
params.action = '';
h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "' title='Browse your files' class='back'>&laquo; Back</a>";
} else {
h += "<a href='#' onclick='theFileList.cancelView()' title='Browse your files' class='back'>&laquo; Back</a>";
}
h += "<div id='file-title'>"
if ( !this.currentImage.isImage )
h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>" + this.currentImage.title + "</a></h2>";
else
h += "<h2>" + this.currentImage.title + "</h2>";
h += " &#8212; <span>";
h += "<a href='#' onclick='theFileList.editView(" + id + ")'>Edit</a>"
h += "</span>";
h += '</div>'
h += "<div id='upload-file-view' class='alignleft'>";
if ( this.currentImage.isImage ) {
h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>";
h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
h += "</a>";
} else
h += '&nbsp;';
h += "</div>";
h += "<form name='uploadoptions' id='uploadoptions' class='alignleft'>";
h += "<table>";
if ( this.currentImage.thumb ) {
h += "<tr><th style='padding-bottom:.5em'>Show:</th><td style='padding-bottom:.5em'>";
h += "<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' checked='checked' /> Thumbnail</label><br />";
h += "<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> Full size</label>";
h += "</td></tr>";
}
h += "<tr><th>Link to:</th><td>";
h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> File</label><br />";
h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> Page</label><br />";
h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> None</label>";
h += "</td></tr>";
h += "<tr><td colspan='2'><p class='submit'>";
h += "<input type='button' class='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='Send to editor &raquo;' />";
h += "</p></td></tr></table>";
h += "</form>";
h += "</div>";
new Insertion.Top('upload-content', h);
if (e) Event.stop(e);
return false;
},
editView: function(id, e) {
this.prepView(id);
var h = '';
var action = 'upload.php?style=' + this.style + '&amp;tab=upload';
if ( this.postID )
action += '&amp;post_id=' + this.postID;
h += "<form id='upload-file' method='post' action='" + action + "'>";
if ( this.ID ) {
var params = $H(this.params);
params.ID = '';
params.action = '';
h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "' title='Browse your files' class='back'>&laquo; Back</a>";
} else {
h += "<a href='#' onclick='theFileList.cancelView()' title='Browse your files' class='back'>&laquo; Back</a>";
}
h += "<div id='file-title'>"
if ( !this.currentImage.isImage )
h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>" + this.currentImage.title + "</a></h2>";
else
h += "<h2>" + this.currentImage.title + "</h2>";
h += " &#8212; <span>";
h += "<a href='#' onclick='theFileList.imageView(" + id + ")'>Insert</a>"
h += "</span>";
h += '</div>'
h += "<div id='upload-file-view' class='alignleft'>";
if ( this.currentImage.isImage ) {
h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>";
h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
h += "</a>";
} else
h += '&nbsp;';
h += "</div>";
h += "<table><col /><col class='widefat' /><tr>"
h += "<th scope='row'><label for='url'>URL</label></th>";
h += "<td><input type='text' id='url' class='readonly' value='" + this.currentImage.srcBase + this.currentImage.src + "' readonly='readonly' /></td>";
h += "</tr><tr>";
h += "<th scope='row'><label for='post_title'>Title</label></th>";
h += "<td><input type='text' id='post_title' name='post_title' value='" + this.currentImage.title + "' /></td>";
h += "</tr><tr>";
h += "<th scope='row'><label for='post_content'>Description</label></th>";
h += "<td><textarea name='post_content' id='post_content'>" + this.currentImage.description + "</textarea></td>";
h += "</tr><tr id='buttons' class='submit'><td colspan='2'><input type='button' id='delete' name='delete' class='delete alignleft' value='Delete File' onclick='theFileList.deleteFile(" + id + ");' />";
h += "<input type='hidden' name='from_tab' value='" + this.tab + "' />";
h += "<input type='hidden' name='action' id='action-value' value='save' />";
h += "<input type='hidden' name='ID' value='" + id + "' />";
h += "<input type='hidden' name='_wpnonce' value='" + this.nonce + "' />";
h += "<div class='submit'><input type='submit' value='Save &raquo;' /></div>";
h += "</td></tr></table></form>";
new Insertion.Top('upload-content', h);
if (e) Event.stop(e);
return false;
},
prepView: function(id) {
this.cancelView( true );
var filesEl = $('upload-files');
if ( filesEl )
filesEl.hide();
var navEl = $('current-tab-nav');
if ( navEl )
navEl.hide();
this.grabImageData(id);
},
cancelView: function( prep ) {
if ( !prep ) {
var filesEl = $('upload-files');
if ( filesEl )
filesEl.show();
var navEl = $('current-tab-nav');
if ( navEl )
navEl.show();
}
if ( !this.ID )
this.grabImageData(0);
var div = $('upload-file');
if ( div )
div.remove();
return false;
},
sendToEditor: function(id) {
this.grabImageData(id);
var link = '';
var display = '';
var h = '';
link = $A(document.forms.uploadoptions.elements.link).detect( function(i) { return i.checked; } ).value;
displayEl = $A(document.forms.uploadoptions.elements.display).detect( function(i) { return i.checked; } )
if ( displayEl )
display = displayEl.value;
else if ( this.currentImage.isImage )
display = 'full';
if ( 'none' != link )
h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment wp-att-" + this.currentImage.ID + "'" ) ) + "' title='" + this.currentImage.title + "'>";
if ( display )
h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />";
else
h += this.currentImage.title;
if ( 'none' != link )
h += "</a>";
var win = window.opener ? window.opener : window.dialogArguments;
if ( !win )
win = top;
tinyMCE = win.tinyMCE;
if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') )
win.tinyMCE.execCommand('mceInsertContent', false, h);
else
win.edInsertContent(win.edCanvas, h);
if ( !this.ID )
this.cancelView();
return false;
},
deleteFile: function(id) {
if ( confirm("Are you sure you want to delete the file '" + this.currentImage.title + "'?\nClick ok to delete or cancel to go back.") ) {
$('action-value').value = 'delete';
$('upload-file').submit();
return true;
}
return false;
}
};
theFileList.initializeVars();
theFileList.initializeLinks();
} );
<?php require_once('admin.php'); cache_javascript_headers(); ?>
addLoadEvent( function() {
theFileList = {
currentImage: {ID: 0},
nonce: '',
tab: '',
postID: 0,
initializeVars: function() {
this.urlData = document.location.href.split('?');
this.params = this.urlData[1].toQueryParams();
this.postID = this.params['post_id'];
this.tab = this.params['tab'];
this.style = this.params['style'];
this.ID = this.params['ID'];
if ( !this.style )
this.style = 'default';
var nonceEl = $('nonce-value');
if ( nonceEl )
this.nonce = nonceEl.value;
if ( this.ID ) {
this.grabImageData( this.ID );
this.imageView( this.ID );
}
},
initializeLinks: function() {
if ( this.ID )
return;
$$('a.file-link').each( function(i) {
var id = i.id.split('-').pop();
i.onclick = function(e) { theFileList[ 'inline' == theFileList.style ? 'imageView' : 'editView' ](id, e); }
} );
},
grabImageData: function(id) {
if ( id == this.currentImage.ID )
return;
var thumbEl = $('attachment-thumb-url-' + id);
this.currentImage.isImage = true;
if ( thumbEl ) {
this.currentImage.thumb = ( 0 == id ? '' : thumbEl.value );
this.currentImage.thumbBase = ( 0 == id ? '' : $('attachment-thumb-url-base-' + id).value );
} else {
this.currentImage.thumb = false;
var isImageEl = $('attachment-is-image-' + id);
if ( !isImageEl )
this.currentImage.isImage = false;
}
this.currentImage.src = ( 0 == id ? '' : $('attachment-url-' + id).value );
this.currentImage.srcBase = ( 0 == id ? '' : $('attachment-url-base-' + id).value );
this.currentImage.page = ( 0 == id ? '' : $('attachment-page-url-' + id).value );
this.currentImage.title = ( 0 == id ? '' : $('attachment-title-' + id).value );
this.currentImage.description = ( 0 == id ? '' : $('attachment-description-' + id).value );
var widthEl = $('attachment-width-' + id);
if ( widthEl ) {
this.currentImage.width = ( 0 == id ? '' : widthEl.value );
this.currentImage.height = ( 0 == id ? '' : $('attachment-height-' + id).value );
} else {
this.currentImage.width = false;
this.currentImage.height = false;
}
this.currentImage.ID = id;
},
imageView: function(id, e) {
this.prepView(id);
var h = '';
h += "<div id='upload-file'>"
if ( this.ID ) {
var params = $H(this.params);
params.ID = '';
params.action = '';
h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "' title='Browse your files' class='back'>&laquo; Back</a>";
} else {
h += "<a href='#' onclick='theFileList.cancelView()' title='Browse your files' class='back'>&laquo; Back</a>";
}
h += "<div id='file-title'>"
if ( !this.currentImage.isImage )
h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>" + this.currentImage.title + "</a></h2>";
else
h += "<h2>" + this.currentImage.title + "</h2>";
h += " &#8212; <span>";
h += "<a href='#' onclick='theFileList.editView(" + id + ")'>Edit</a>"
h += "</span>";
h += '</div>'
h += "<div id='upload-file-view' class='alignleft'>";
if ( this.currentImage.isImage ) {
h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>";
h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
h += "</a>";
} else
h += '&nbsp;';
h += "</div>";
h += "<form name='uploadoptions' id='uploadoptions' class='alignleft'>";
h += "<table>";
if ( this.currentImage.thumb ) {
h += "<tr><th style='padding-bottom:.5em'>Show:</th><td style='padding-bottom:.5em'>";
h += "<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' checked='checked' /> Thumbnail</label><br />";
h += "<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> Full size</label>";
h += "</td></tr>";
}
h += "<tr><th>Link to:</th><td>";
h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> File</label><br />";
h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> Page</label><br />";
h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> None</label>";
h += "</td></tr>";
h += "<tr><td colspan='2'><p class='submit'>";
h += "<input type='button' class='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='Send to editor &raquo;' />";
h += "</p></td></tr></table>";
h += "</form>";
h += "</div>";
new Insertion.Top('upload-content', h);
if (e) Event.stop(e);
return false;
},
editView: function(id, e) {
this.prepView(id);
var h = '';
var action = 'upload.php?style=' + this.style + '&amp;tab=upload';
if ( this.postID )
action += '&amp;post_id=' + this.postID;
h += "<form id='upload-file' method='post' action='" + action + "'>";
if ( this.ID ) {
var params = $H(this.params);
params.ID = '';
params.action = '';
h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "' title='Browse your files' class='back'>&laquo; Back</a>";
} else {
h += "<a href='#' onclick='theFileList.cancelView()' title='Browse your files' class='back'>&laquo; Back</a>";
}
h += "<div id='file-title'>"
if ( !this.currentImage.isImage )
h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>" + this.currentImage.title + "</a></h2>";
else
h += "<h2>" + this.currentImage.title + "</h2>";
h += " &#8212; <span>";
h += "<a href='#' onclick='theFileList.imageView(" + id + ")'>Insert</a>"
h += "</span>";
h += '</div>'
h += "<div id='upload-file-view' class='alignleft'>";
if ( this.currentImage.isImage ) {
h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='Direct link to file'>";
h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
h += "</a>";
} else
h += '&nbsp;';
h += "</div>";
h += "<table><col /><col class='widefat' /><tr>"
h += "<th scope='row'><label for='url'>URL</label></th>";
h += "<td><input type='text' id='url' class='readonly' value='" + this.currentImage.srcBase + this.currentImage.src + "' readonly='readonly' /></td>";
h += "</tr><tr>";
h += "<th scope='row'><label for='post_title'>Title</label></th>";
h += "<td><input type='text' id='post_title' name='post_title' value='" + this.currentImage.title + "' /></td>";
h += "</tr><tr>";
h += "<th scope='row'><label for='post_content'>Description</label></th>";
h += "<td><textarea name='post_content' id='post_content'>" + this.currentImage.description + "</textarea></td>";
h += "</tr><tr id='buttons' class='submit'><td colspan='2'><input type='button' id='delete' name='delete' class='delete alignleft' value='Delete File' onclick='theFileList.deleteFile(" + id + ");' />";
h += "<input type='hidden' name='from_tab' value='" + this.tab + "' />";
h += "<input type='hidden' name='action' id='action-value' value='save' />";
h += "<input type='hidden' name='ID' value='" + id + "' />";
h += "<input type='hidden' name='_wpnonce' value='" + this.nonce + "' />";
h += "<div class='submit'><input type='submit' value='Save &raquo;' /></div>";
h += "</td></tr></table></form>";
new Insertion.Top('upload-content', h);
if (e) Event.stop(e);
return false;
},
prepView: function(id) {
this.cancelView( true );
var filesEl = $('upload-files');
if ( filesEl )
filesEl.hide();
var navEl = $('current-tab-nav');
if ( navEl )
navEl.hide();
this.grabImageData(id);
},
cancelView: function( prep ) {
if ( !prep ) {
var filesEl = $('upload-files');
if ( filesEl )
filesEl.show();
var navEl = $('current-tab-nav');
if ( navEl )
navEl.show();
}
if ( !this.ID )
this.grabImageData(0);
var div = $('upload-file');
if ( div )
div.remove();
return false;
},
sendToEditor: function(id) {
this.grabImageData(id);
var link = '';
var display = '';
var h = '';
link = $A(document.forms.uploadoptions.elements.link).detect( function(i) { return i.checked; } ).value;
displayEl = $A(document.forms.uploadoptions.elements.display).detect( function(i) { return i.checked; } )
if ( displayEl )
display = displayEl.value;
else if ( this.currentImage.isImage )
display = 'full';
if ( 'none' != link )
h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment wp-att-" + this.currentImage.ID + "'" ) ) + "' title='" + this.currentImage.title + "'>";
if ( display )
h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />";
else
h += this.currentImage.title;
if ( 'none' != link )
h += "</a>";
var win = window.opener ? window.opener : window.dialogArguments;
if ( !win )
win = top;
tinyMCE = win.tinyMCE;
if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') )
win.tinyMCE.execCommand('mceInsertContent', false, h);
else
win.edInsertContent(win.edCanvas, h);
if ( !this.ID )
this.cancelView();
return false;
},
deleteFile: function(id) {
if ( confirm("Are you sure you want to delete the file '" + this.currentImage.title + "'?\nClick ok to delete or cancel to go back.") ) {
$('action-value').value = 'delete';
$('upload-file').submit();
return true;
}
return false;
}
};
theFileList.initializeVars();
theFileList.initializeLinks();
} );

View File

@ -1,21 +1,21 @@
<?php
// ** MySQL settings ** //
define('DB_NAME', 'wordpress'); // The name of the database
define('DB_USER', 'username'); // Your MySQL username
define('DB_PASSWORD', 'password'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
// You can have multiple installations in one database if you give each a unique prefix
$table_prefix = 'wp_'; // Only numbers, letters, and underscores please!
// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-includes/languages.
// For example, install de.mo to wp-includes/languages and set WPLANG to 'de'
// to enable German language support.
define ('WPLANG', '');
/* That's all, stop editing! Happy blogging. */
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
<?php
// ** MySQL settings ** //
define('DB_NAME', 'wordpress'); // The name of the database
define('DB_USER', 'username'); // Your MySQL username
define('DB_PASSWORD', 'password'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
// You can have multiple installations in one database if you give each a unique prefix
$table_prefix = 'wp_'; // Only numbers, letters, and underscores please!
// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-includes/languages.
// For example, install de.mo to wp-includes/languages and set WPLANG to 'de'
// to enable German language support.
define ('WPLANG', '');
/* That's all, stop editing! Happy blogging. */
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
?>