From 82e3412256dfe59f22d0c4ff008d995872b969b0 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 16 Nov 2005 02:07:56 +0000 Subject: [PATCH] Importer work. git-svn-id: http://svn.automattic.com/wordpress/trunk@3098 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-functions.php | 4 ++-- wp-admin/import/mt.php | 29 +++++++++++++++++------------ wp-admin/import/rss.php | 2 +- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 0f23f76be4..1228731e46 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -1730,8 +1730,8 @@ function wp_shrink_dimensions($width, $height, $wmax = 128, $hmax = 96) { return array((int) ($width / $height * $hmax), $hmax); } -function wp_import_cleanup($file) { - wp_delete_attachment($file['id']); +function wp_import_cleanup($id) { + wp_delete_attachment($id); } function wp_import_upload_form($action) { diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php index 688a2373bd..fb10d5789b 100644 --- a/wp-admin/import/mt.php +++ b/wp-admin/import/mt.php @@ -8,6 +8,8 @@ define('MTEXPORT', 'import.txt'); class MT_Import { var $posts = array (); + var $file; + var $id; var $mtnames = array (); var $newauthornames = array (); var $j = -1; @@ -24,12 +26,8 @@ class MT_Import { function greet() { $this->header(); ?> -

Howdy! We’re about to begin the process to import all of your Movable Type entries into WordPress. Before we get started, you need to edit this file (import/mt.php) and change one line so we know where to find your MT export file. To make this easy put the import file into the wp-admin/import directory. Look for the line that says:

-

define('MTEXPORT', '');

-

and change it to

-

define('MTEXPORT', 'import.txt');

-

You have to do this manually for security reasons.

-

If you've done that and you’re all ready, let's go! Remember that the import process may take a minute or so if you have a large number of entries and comments. Think of all the rebuilding time you'll be saving once it's done. :)

+

Howdy! We’re about to begin the process to import all of your Movable Type entries into WordPress. To begin, select a file to upload and click Import.

+

The importer is smart enough not to import duplicates, so you can run this multiple times without worry if—for whatever reason—it doesn't finish. If you get an out of memory error try splitting up the import file into pieces.

file); // Read the file into an array $importdata = implode('', $importdata); // squish it $importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata); $importdata = preg_replace("/\n--------\n/", "--MT-ENTRY--\n", $importdata); @@ -152,7 +150,7 @@ class MT_Import { $authors = $this->get_mt_authors(); echo '
    '; - echo '
    '; + echo ''; $j = -1; foreach ($authors as $author) { ++ $j; @@ -169,13 +167,17 @@ class MT_Import { } function select_authors() { - if ('' != MTEXPORT && !file_exists(MTEXPORT)) - die("The file you specified does not seem to exist. Please check the path you've given."); - if ('' == MTEXPORT) - die("You must edit the MTEXPORT line as described on the previous page to continue."); + $file = wp_import_handle_upload(); + if ( isset($file['error']) ) { + echo $file['error']; + return; + } + $this->file = $file['file']; + $this->id = $file['id']; $this->get_entries(); $this->mt_authors_form(); + wp_import_cleanup($this->id); } function process_posts() { @@ -401,6 +403,9 @@ class MT_Import { case 1 : $this->select_authors(); break; + case 2: + echo "ID: {$_GET['id']}
    "; + break; } } diff --git a/wp-admin/import/rss.php b/wp-admin/import/rss.php index 796148c414..07487bf528 100644 --- a/wp-admin/import/rss.php +++ b/wp-admin/import/rss.php @@ -137,7 +137,7 @@ class RSS_Import { $this->file = $file['file']; $this->get_posts(); $this->import_posts(); - wp_import_cleanup($file); + wp_import_cleanup($file['id']); echo '

    All done. Have fun!

    '; }