]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/import/mt.php
Wordpress 2.0.11
[autoinstalls/wordpress.git] / wp-admin / import / mt.php
index 3281f0877963d4ee382778d38dffba7e8b6d1d6d..f02b06976457396856e099db001a56e14643c840 100644 (file)
@@ -11,7 +11,7 @@ class MT_Import {
 
        function header() {
                echo '<div class="wrap">';
-               echo '<h2>'.__('Import Movable Type').'</h2>';
+               echo '<h2>'.__('Import Movable Type and Typepad').'</h2>';
        }
 
        function footer() {
@@ -32,7 +32,7 @@ class MT_Import {
                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>
+       <option value="#NONE#"><?php _e('- Select -') ?></option>
        <?php
 
 
@@ -134,6 +134,8 @@ class MT_Import {
 
        function mt_authors_form() {
 ?>
+<div class="wrap">
+<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('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>
 <p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p>
@@ -143,29 +145,32 @@ class MT_Import {
                $authors = $this->get_mt_authors();
                echo '<ol id="authors">';
                echo '<form action="?import=mt&amp;step=2&amp;id=' . $this->id . '" method="post">';
+               wp_nonce_field('import-mt');
                $j = -1;
                foreach ($authors as $author) {
                        ++ $j;
-                       echo '<li><i>'.$author.'</i><br />'.'<input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30">';
+                       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 '<input type="submit" value="'.__('Submit').'">'.'<br/>';
                echo '</form>';
-               echo '</ol>';
+               echo '</ol></div>';
 
-               flush();
        }
 
        function select_authors() {
                $file = wp_import_handle_upload();
                if ( isset($file['error']) ) {
-                       echo $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->id = (int) $file['id'];
 
                $this->get_entries();
                $this->mt_authors_form();
@@ -174,7 +179,7 @@ class MT_Import {
        function process_posts() {
                global $wpdb;
                $i = -1;
-               echo "<ol>";
+               echo "<div class='wrap'><ol>";
                foreach ($this->posts as $post) {
                        if ('' != trim($post)) {
                                ++ $i;
@@ -193,7 +198,7 @@ class MT_Import {
 
                                // We want the excerpt
                                preg_match("|-----\nEXCERPT:(.*)|s", $post, $excerpt);
-                               $excerpt = $wpdb->escape(trim($excerpt[1]));
+                               $post_excerpt = $wpdb->escape(trim($excerpt[1]));
                                $post = preg_replace("|(-----\nEXCERPT:.*)|s", '', $post);
 
                                // We're going to put extended body into main body with a more tag
@@ -289,7 +294,7 @@ class MT_Import {
                                        }
                                }
 
-                               $comment_post_ID = $post_id;
+                               $comment_post_ID = (int) $post_id;
                                $comment_approved = 1;
 
                                // Now for comments
@@ -330,7 +335,7 @@ class MT_Import {
                                        }
                                }
                                if ( $num_comments )
-                                       printf(__('(%s comments)'), $num_comments);
+                                       printf(' '.__('(%s comments)'), $num_comments);
 
                                // Finally the pings
                                // fix the double newline on the first one
@@ -378,22 +383,22 @@ class MT_Import {
                                        }
                                }
                                if ( $num_pings )
-                                       printf(__('(%s pings)'), $num_pings);
-                               
+                                       printf(' '.__('(%s pings)'), $num_pings);
+
                                echo "</li>";
                        }
-                       flush();
                }
 
                echo '</ol>';
 
                wp_import_cleanup($this->id);
 
-               echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3>';
+               echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3></div>';
        }
 
        function import() {
                $this->id = (int) $_GET['id'];
+               
                $this->file = get_attached_file($this->id);
                $this->get_authors_from_post();
                $this->get_entries();
@@ -411,20 +416,22 @@ class MT_Import {
                                $this->greet();
                                break;
                        case 1 :
+                               check_admin_referer('import-upload');
                                $this->select_authors();
                                break;
                        case 2:
+                               check_admin_referer('import-mt');
                                $this->import();
                                break;
                }
        }
 
        function MT_Import() {
-               // Nothing.     
+               // Nothing.
        }
 }
 
 $mt_import = new MT_Import();
 
-register_importer('mt', 'Movable Type', __('Import posts and comments from your Movable Type blog'), array ($mt_import, 'dispatch'));
+register_importer('mt', __('Movable Type and Typepad'), __('Imports <strong>posts and comments</strong> from your Movable Type or Typepad blog'), array ($mt_import, 'dispatch'));
 ?>