From e30516b2ee40c1c45c8f288c20a3d4372e478624 Mon Sep 17 00:00:00 2001 From: donncha Date: Fri, 8 Sep 2006 10:57:32 +0000 Subject: WP Merge to #4124 git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@734 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-admin/import/wordpress.php | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'wp-admin/import/wordpress.php') diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php index 997628b..ded4b94 100644 --- a/wp-admin/import/wordpress.php +++ b/wp-admin/import/wordpress.php @@ -54,8 +54,24 @@ class WP_Import { global $wpdb; //mtnames is an array with the names in the mt import file $pass = 'changeme'; - $key = array_search($author, $this->mtnames); //find the array key for $author in the $mtnames array - $user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames + if (!(in_array($author, $this->mtnames))) { //a new mt author name is found + ++ $this->j; + $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 + $user_id = wp_create_user($author, $pass); + $this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank. + } else { + $user_id = wp_create_user($this->newauthornames[$this->j], $pass); + } + } else { + return $user_id; // return pre-existing wp username if it exists + } + } else { + $key = array_search($author, $this->mtnames); //find the array key for $author in the $mtnames array + $user_id = username_exists($this->newauthornames[$key]); //use that key to get the value of the author's name from $newauthornames + } return $user_id; } @@ -96,6 +112,13 @@ class WP_Import { $formnames = array (); $selectnames = array (); + foreach ($_POST['user'] as $key => $line) { + $newname = trim(stripslashes($line)); + if ($newname == '') + $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form. + array_push($formnames, "$newname"); + } // $formnames is the array with the form entered names + foreach ($_POST['userselect'] as $user => $key) { $selected = trim(stripslashes($key)); array_push($selectnames, "$selected"); @@ -125,7 +148,7 @@ class WP_Import { $j = -1; foreach ($authors as $author) { ++ $j; - echo '
  • Current author: '.$author.'
    '.'Map to existing: '; + echo '
  • '.__('Current author:').' '.$author.'
    '.sprintf(__('Create user %1$s or map to existing'), '
    '); $this->users_form($j); echo '
  • '; } @@ -140,7 +163,7 @@ class WP_Import { $file = wp_import_handle_upload(); if ( isset($file['error']) ) { $this->header(); - echo '

    Sorry, there has been an error.

    '; + echo '

    '.__('Sorry, there has been an error.').'

    '; echo '

    ' . $file['error'] . '

    '; $this->footer(); return; @@ -225,7 +248,7 @@ class WP_Import { } } } if ( $num_comments ) - printf(__(' (%s comments)'), $num_comments); + printf(' '.__('(%s comments)'), $num_comments); // Now for post meta preg_match_all('|(.*?)|is', $post, $postmeta); @@ -243,7 +266,7 @@ class WP_Import { wp_import_cleanup($this->id); - echo '

    '.sprintf(__('All done. Have fun!'), get_option('home')).'

    '; + echo '

    '.sprintf(__('All done.').' '.__('Have fun!').'', get_option('home')).'

    '; } function import() { -- cgit