Make WordPress Core

Changeset 5531


Ignore:
Timestamp:
05/23/2007 07:36:35 PM (18 years ago)
Author:
markjaquith
Message:

Allow MT Importer to use FTP-uploaded file (to get around php.ini-set file upload size limit). fixes #4284

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import/mt.php

    r5404 r5531  
    2323?>
    2424<div class="narrow">
    25 <p><?php _e('Howdy! We&#8217;re about to begin importing all of your Movable Type or Typepad entries into WordPress. To begin, choose a file to upload and click Upload file and import.'); ?></p>
     25<p><?php _e('Howdy! We&#8217;re about to begin importing all of your Movable Type or Typepad entries into WordPress. To begin, either choose a file to upload and click "Upload file and import," or use FTP to upload your MT export file as <code>mt-export.txt</code> in your <code>/wp-content/</code> directory and then click "Import mt-export.txt"'); ?></p>
    2626<?php wp_import_upload_form( add_query_arg('step', 1) ); ?>
    27     <p><?php _e('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>
     27<form method="post" action="<?php echo add_query_arg('step', 1); ?>" class="import-upload-form">
     28<?php wp_nonce_field('import-upload'); ?>
     29<p>
     30    <input type="hidden" name="upload_type" value="ftp" />
     31<?php _e('Or use <code>mt-export.txt</code> in your <code>/wp-content/</code> directory'); ?></p>
     32<p class="submit">
     33<input type="submit" value="<?php _e(sprintf('Import %s', 'mt-export.txt &raquo;')); ?>" />
     34</p>
     35</form>
     36<p><?php _e('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>
    2837</div>
    2938<?php
     
    139148<div class="wrap">
    140149<h2><?php _e('Assign Authors'); ?></h2>
    141 <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>
     150<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 admin\'s entries.'); ?></p>
    142151<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <i>italics</i>. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?></p>
    143152<p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p>
     
    164173
    165174    function select_authors() {
    166         $file = wp_import_handle_upload();
     175        if ( $_POST['upload_type'] === 'ftp' ) {
     176            $file['file'] = @file(ABSPATH . '/wp-content/mt-export.txt');
     177            if ( !$file['file'] || !count($file['file']) )
     178                $file['error'] = __('<code>mt-export.txt</code> does not exist</code>');
     179            else
     180                $file['file'] = ABSPATH . '/wp-content/mt-export.txt';
     181        } else {
     182            $file = wp_import_handle_upload();
     183        }
    167184        if ( isset($file['error']) ) {
    168185            $this->header();
     
    401418    function import() {
    402419        $this->id = (int) $_GET['id'];
    403 
    404         $this->file = get_attached_file($this->id);
     420        if ( $this->id == 0 )
     421            $this->file = ABSPATH . '/wp-content/mt-export.txt';
     422        else
     423            $this->file = get_attached_file($this->id);
    405424        $this->get_authors_from_post();
    406425        $this->get_entries();
Note: See TracChangeset for help on using the changeset viewer.