Changeset 3098

Show
Ignore:
Timestamp:
11/16/05 02:07:56 (3 years ago)
Author:
ryan
Message:

Importer work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/admin-functions.php

    r3093 r3098  
    17311731} 
    17321732 
    1733 function wp_import_cleanup($file) { 
    1734     wp_delete_attachment($file['id']); 
     1733function wp_import_cleanup($id) { 
     1734    wp_delete_attachment($id); 
    17351735} 
    17361736 
  • trunk/wp-admin/import/mt.php

    r3062 r3098  
    99 
    1010    var $posts = array (); 
     11    var $file; 
     12    var $id; 
    1113    var $mtnames = array (); 
    1214    var $newauthornames = array (); 
     
    2527        $this->header(); 
    2628?> 
    27 <p>Howdy! We&#8217;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 (<code>import/mt.php</code>) and change one line so we know where to find your MT export file. To make this easy put the import file into the <code>wp-admin/import</code> directory. Look for the line that says:</p> 
    28 <p><code>define('MTEXPORT', '');</code></p> 
    29 <p>and change it to</p> 
    30 <p><code>define('MTEXPORT', 'import.txt');</code></p> 
    31 <p>You have to do this manually for security reasons.</p> 
    32 <p>If you've done that and you&#8217;re all ready, <a href="<?php echo add_query_arg('step', 1)  ?>">let's go</a>! 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. :)</p> 
     29<p>Howdy! We&#8217;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.</p> 
     30<?php wp_import_upload_form( add_query_arg('step', 1) ); ?> 
    3331<p>The importer is smart enough not to import duplicates, so you can run this multiple times without worry if&#8212;for whatever reason&#8212;it doesn't finish. If you get an <strong>out of memory</strong> error try splitting up the import file into pieces. </p> 
    3432<?php 
     
    8684    function get_entries() { 
    8785        set_magic_quotes_runtime(0); 
    88         $importdata = file(MTEXPORT); // Read the file into an array 
     86        $importdata = file($this->file); // Read the file into an array 
    8987        $importdata = implode('', $importdata); // squish it 
    9088        $importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata); 
     
    153151        $authors = $this->get_mt_authors(); 
    154152        echo '<ol id="authors">'; 
    155         echo '<form action="?import=mt&amp;step=2" method="post">'; 
     153        echo '<form action="?import=mt&amp;step=2&amp;id=' . $this->id . '" method="post">'; 
    156154        $j = -1; 
    157155        foreach ($authors as $author) { 
     
    170168 
    171169    function select_authors() { 
    172         if ('' != MTEXPORT && !file_exists(MTEXPORT)) 
    173             die("The file you specified does not seem to exist. Please check the path you've given."); 
    174         if ('' == MTEXPORT) 
    175             die("You must edit the MTEXPORT line as described on the <a href='import-mt.php'>previous page</a> to continue."); 
     170        $file = wp_import_handle_upload(); 
     171        if ( isset($file['error']) ) { 
     172            echo $file['error']; 
     173            return; 
     174        } 
     175        $this->file = $file['file']; 
     176        $this->id = $file['id']; 
    176177 
    177178        $this->get_entries(); 
    178179        $this->mt_authors_form(); 
     180        wp_import_cleanup($this->id); 
    179181    } 
    180182 
     
    402404                $this->select_authors(); 
    403405                break; 
     406            case 2: 
     407                echo "ID: {$_GET['id']}<br/>"; 
     408                break; 
    404409        } 
    405410    } 
  • trunk/wp-admin/import/rss.php

    r3093 r3098  
    138138        $this->get_posts(); 
    139139        $this->import_posts(); 
    140         wp_import_cleanup($file); 
     140        wp_import_cleanup($file['id']); 
    141141 
    142142        echo '<h3>All done. <a href="' . get_option('home') . '">Have fun!</a></h3>';