X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/177fd6fefd2e3d5a0ea6591c71d660cabdb3c1a4..refs/tags/wordpress-2.9:/wp-admin/import/mt.php?ds=sidebyside diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php index 6ab2f79c..548e9ede 100644 --- a/wp-admin/import/mt.php +++ b/wp-admin/import/mt.php @@ -1,5 +1,18 @@ '; + screen_icon(); echo '

'.__('Import Movable Type or TypePad').'

'; } @@ -22,27 +36,27 @@ class MT_Import { $this->header(); ?>
-

mt-export.txt in your /wp-content/ directory and then click "Import mt-export.txt"'); ?>

+

mt-export.txt in your /wp-content/ directory and then click "Import mt-export.txt"'); ?>

-
+

mt-export.txt in your /wp-content/ directory'); ?>

- +

-

out of memory error try splitting up the import file into pieces.'); ?>

+

out of memory error try splitting up the import file into pieces.'); ?>

footer(); } function users_form($n) { - global $wpdb, $testing; + global $wpdb; $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID"); ?> has_gzip() ) + return gzopen($filename, $mode); + return fopen($filename, $mode); + } + + function feof($fp) { + if ( $this->has_gzip() ) + return gzeof($fp); + return feof($fp); + } + function fgets($fp, $len=8192) { + if ( $this->has_gzip() ) + return gzgets($fp, $len); + return fgets($fp, $len); } + function fclose($fp) { + if ( $this->has_gzip() ) + return gzclose($fp); + return fclose($fp); + } + //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 = wp_generate_password(); if (!(in_array($author, $this->mtnames))) { //a new mt author name is found @@ -69,7 +109,7 @@ class MT_Import { $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 + if ($this->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 { @@ -90,12 +130,12 @@ class MT_Import { $temp = array(); $authors = array(); - $handle = fopen($this->file, 'r'); + $handle = $this->fopen($this->file, 'r'); if ( $handle == null ) return false; $in_comment = false; - while ( $line = fgets($handle) ) { + while ( $line = $this->fgets($handle) ) { $line = trim($line); if ( 'COMMENT:' == $line ) @@ -118,7 +158,7 @@ class MT_Import { array_push($authors, "$next"); } - fclose($handle); + $this->fclose($handle); return $authors; } @@ -152,10 +192,11 @@ class MT_Import { function mt_authors_form() { ?>
+

-

+

italics. 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.'); ?>

-

+

'.__('Current author:').' '.$author.'
'.sprintf(__('Create user %1$s or map to existing'), '
'); + echo '
  • '; + echo ''; } - echo ''.'
    '; + echo '

    '.'
    '; echo ''; echo '
    '; @@ -179,7 +220,7 @@ class MT_Import { function select_authors() { if ( $_POST['upload_type'] === 'ftp' ) { - $file['file'] = ABSPATH . 'wp-content/mt-export.txt'; + $file['file'] = WP_CONTENT_DIR . '/mt-export.txt'; if ( !file_exists($file['file']) ) $file['error'] = __('mt-export.txt does not exist'); } else { @@ -224,10 +265,10 @@ class MT_Import { if ( 0 != count($post->categories) ) { wp_create_categories($post->categories, $post_id); } - + // Add tags or keywords if ( 1 < strlen($post->post_keywords) ) { - // Keywords exist. + // Keywords exist. printf(__('
    Adding tags %s...'), stripslashes($post->post_keywords)); wp_add_post_tags($post_id, $post->post_keywords); } @@ -247,7 +288,7 @@ class MT_Import { } if ( $num_comments ) - printf(' '.__ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments); + printf(' '._n('(%s comment)', '(%s comments)', $num_comments), $num_comments); $num_pings = 0; foreach ( $pings as $ping ) { @@ -264,7 +305,7 @@ class MT_Import { } if ( $num_pings ) - printf(' '.__ngettext('(%s ping)', '(%s pings)', $num_pings), $num_pings); + printf(' '._n('(%s ping)', '(%s pings)', $num_pings), $num_pings); echo ""; //ob_flush();flush(); @@ -273,7 +314,7 @@ class MT_Import { function process_posts() { global $wpdb; - $handle = fopen($this->file, 'r'); + $handle = $this->fopen($this->file, 'r'); if ( $handle == null ) return false; @@ -286,7 +327,7 @@ class MT_Import { echo "
      "; - while ( $line = fgets($handle) ) { + while ( $line = $this->fgets($handle) ) { $line = trim($line); if ( '-----' == $line ) { @@ -398,7 +439,9 @@ class MT_Import { } else { // Processing multi-line field, check context. - $line .= "\n"; + if( !empty($line) ) + $line .= "\n"; + if ( 'body' == $context ) { $post->post_content .= $line; } else if ( 'extended' == $context ) { @@ -415,6 +458,8 @@ class MT_Import { } } + $this->fclose($handle); + echo '
    '; wp_import_cleanup($this->id); @@ -426,7 +471,7 @@ class MT_Import { function import() { $this->id = (int) $_GET['id']; if ( $this->id == 0 ) - $this->file = ABSPATH . 'wp-content/mt-export.txt'; + $this->file = WP_CONTENT_DIR . '/mt-export.txt'; else $this->file = get_attached_file($this->id); $this->get_authors_from_post(); @@ -465,5 +510,5 @@ class MT_Import { $mt_import = new MT_Import(); -register_importer('mt', __('Movable Type and TypePad'), __('Import posts and comments from a Movable Type or Typepad blog.'), array ($mt_import, 'dispatch')); +register_importer('mt', __('Movable Type and TypePad'), __('Import posts and comments from a Movable Type or TypePad blog.'), array ($mt_import, 'dispatch')); ?>