diff -r 000000000000 -r 03b0d1493584 web/wp-admin/import/wordpress.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-admin/import/wordpress.php Wed Dec 23 17:55:33 2009 +0000 @@ -0,0 +1,807 @@ +'; + screen_icon(); + echo '
'.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this blog.').'
'; + echo ''.__('Choose a WordPress WXR file to upload, then click Upload file and import.').'
'; + wp_import_upload_form("admin.php?import=wordpress&step=1"); + echo 'admins entries.'); ?>
+allow_create_users() ) { + echo ''.__('If a new user is created by WordPress, a password will be randomly generated. Manually change the user’s details if necessary.')."
\n"; + } + + + $authors = $this->get_wp_authors(); + echo ''; + + } + + function users_form($n, $author) { + + if ( $this->allow_create_users() ) { + printf(''.__('Please upload a valid WXR (WordPress eXtended RSS) export file.').'
'; + } + } + + // fetch the user ID for a given author name, respecting the mapping preferences + function checkauthor($author) { + global $current_user; + + if ( !empty($this->author_ids[$author]) ) + return $this->author_ids[$author]; + + // failsafe: map to the current user + return $current_user->ID; + } + + + + function process_categories() { + global $wpdb; + + $cat_names = (array) get_terms('category', 'fields=names'); + + while ( $c = array_shift($this->categories) ) { + $cat_name = trim($this->get_tag( $c, 'wp:cat_name' )); + + // If the category exists we leave it alone + if ( in_array($cat_name, $cat_names) ) + continue; + + $category_nicename = $this->get_tag( $c, 'wp:category_nicename' ); + $category_description = $this->get_tag( $c, 'wp:category_description' ); + $posts_private = (int) $this->get_tag( $c, 'wp:posts_private' ); + $links_private = (int) $this->get_tag( $c, 'wp:links_private' ); + + $parent = $this->get_tag( $c, 'wp:category_parent' ); + + if ( empty($parent) ) + $category_parent = '0'; + else + $category_parent = category_exists($parent); + + $catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name', 'category_description'); + + $cat_ID = wp_insert_category($catarr); + } + } + + function process_tags() { + global $wpdb; + + $tag_names = (array) get_terms('post_tag', 'fields=names'); + + while ( $c = array_shift($this->tags) ) { + $tag_name = trim($this->get_tag( $c, 'wp:tag_name' )); + + // If the category exists we leave it alone + if ( in_array($tag_name, $tag_names) ) + continue; + + $slug = $this->get_tag( $c, 'wp:tag_slug' ); + $description = $this->get_tag( $c, 'wp:tag_description' ); + + $tagarr = compact('slug', 'description'); + + $tag_ID = wp_insert_term($tag_name, 'post_tag', $tagarr); + } + } + + function process_author($post) { + $author = $this->get_tag( $post, 'dc:creator' ); + if ($author) + $this->allauthornames[] = $author; + } + + function process_posts() { + echo ''.__('Sorry, there has been an error.').'
'; + echo '' . $file['error'] . '
'; + return false; + } + $this->file = $file['file']; + $this->id = (int) $file['id']; + return true; + } + + function dispatch() { + if (empty ($_GET['step'])) + $step = 0; + else + $step = (int) $_GET['step']; + + $this->header(); + switch ($step) { + case 0 : + $this->greet(); + break; + case 1 : + check_admin_referer('import-upload'); + if ( $this->handle_upload() ) + $this->select_authors(); + break; + case 2: + check_admin_referer('import-wordpress'); + $result = $this->import( $_GET['id'], $_POST['attachments'] ); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); + break; + } + $this->footer(); + } + + function WP_Import() { + // Nothing. + } +} + +/** + * Register WordPress Importer + * + * @since unknown + * @var WP_Import + * @name $wp_import + */ +$wp_import = new WP_Import(); + +register_importer('wordpress', 'WordPress', __('Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), array ($wp_import, 'dispatch')); + +?>