summaryrefslogtreecommitdiffstats
path: root/wp-admin/import/mt.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-09-08 10:57:32 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-09-08 10:57:32 +0000
commite30516b2ee40c1c45c8f288c20a3d4372e478624 (patch)
treebd6b8bcc4c06697f50e6985a6b08620e25bc572e /wp-admin/import/mt.php
parente20c9aa016d6885c6e3fc7425525b4090f05ac2a (diff)
downloadwordpress-mu-e30516b2ee40c1c45c8f288c20a3d4372e478624.tar.gz
wordpress-mu-e30516b2ee40c1c45c8f288c20a3d4372e478624.tar.xz
wordpress-mu-e30516b2ee40c1c45c8f288c20a3d4372e478624.zip
WP Merge to #4124
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@734 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/import/mt.php')
-rw-r--r--wp-admin/import/mt.php47
1 files changed, 37 insertions, 10 deletions
diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php
index 59259ea..bf33718 100644
--- a/wp-admin/import/mt.php
+++ b/wp-admin/import/mt.php
@@ -32,7 +32,7 @@ class MT_Import {
global $wpdb, $testing;
$users = get_users_of_blog($wpdb->blogid);
?><select name="userselect[<?php echo $n; ?>]">
- <option value="#NONE#">- Select -</option>
+ <option value="#NONE#"><?php _e('- Select -') ?></option>
<?php
@@ -50,8 +50,25 @@ class MT_Import {
function checkauthor($author) {
global $wpdb;
//mtnames is an array with the names in the mt import file
- $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
+ $pass = 'changeme';
+ 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;
}
@@ -93,6 +110,13 @@ class MT_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");
@@ -124,12 +148,12 @@ class MT_Import {
$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></div>';
@@ -138,7 +162,10 @@ class MT_Import {
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'];
@@ -170,7 +197,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
@@ -307,7 +334,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
@@ -355,7 +382,7 @@ class MT_Import {
}
}
if ( $num_pings )
- printf(__(' (%s pings)'), $num_pings);
+ printf(' '.__('(%s pings)'), $num_pings);
echo "</li>";
}
@@ -403,5 +430,5 @@ class MT_Import {
$mt_import = new MT_Import();
-register_importer('mt', 'Movable Type and Typepad', __('Imports <strong>posts and comments</strong> from your Movable Type or Typepad 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'));
?>