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

-

+

'; @@ -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);