X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/76aea3697c6043c1613370f172395b4f65ee71f0..11be8dc178e77d0b46189bbd8e33a216a9b90942:/wp-admin/import/mt.php diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php index 5968095c..48d4de3b 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').'

'; } @@ -32,7 +46,7 @@ class MT_Import { mt-export.txt in your /wp-content/ directory'); ?>

- +

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

@@ -42,7 +56,7 @@ class MT_Import { } 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,6 +192,7 @@ 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.'); ?>

@@ -171,7 +212,7 @@ class MT_Import { echo ''; } - echo ''.'
'; + echo '

'.'
'; echo ''; echo '
'; @@ -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); } @@ -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 ) { @@ -397,8 +438,10 @@ class MT_Import { $ping->comment_author = $blog; } 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);