]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/import/textpattern.php
Wordpress 2.3.2
[autoinstalls/wordpress.git] / wp-admin / import / textpattern.php
index 2d2b145e9e5577b7b07252afd2f9090ecf1951cf..1fe54c8ce0d44a0a23ea017b403ea5e01c359fa9 100644 (file)
@@ -2,18 +2,6 @@
 /**
        Add These Functions to make our lives easier
 **/
-if(!function_exists('get_catbynicename'))
-{
-       function get_catbynicename($category_nicename)
-       {
-       global $wpdb;
-
-       $cat_id -= 0;   // force numeric
-       $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
-
-       return $name;
-       }
-}
 
 if(!function_exists('get_comment_count'))
 {
@@ -38,14 +26,14 @@ if(!function_exists('link_exists'))
 **/
 class Textpattern_Import {
 
-       function header() 
+       function header()
        {
                echo '<div class="wrap">';
                echo '<h2>'.__('Import Textpattern').'</h2>';
                echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
        }
 
-       function footer() 
+       function footer()
        {
                echo '</div>';
        }
@@ -317,6 +305,8 @@ class Textpattern_Import {
                                                'post_name'                     => $url_title,
                                                'comment_count'         => $comments_count)
                                                );
+                                       if ( is_wp_error( $ret_id ) )
+                                               return $ret_id;
                                }
                                else
                                {
@@ -333,13 +323,19 @@ class Textpattern_Import {
                                                'post_name'                     => $url_title,
                                                'comment_count'         => $comments_count)
                                                );
+                                       if ( is_wp_error( $ret_id ) )
+                                               return $ret_id;
                                }
                                $txpposts2wpposts[$ID] = $ret_id;
 
                                // Make Post-to-Category associations
                                $cats = array();
-                               if($cat1 = get_catbynicename($Category1)) { $cats[1] = $cat1; }
-                               if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; }
+                               $category1 = get_category_by_slug($Category1);
+                               $category1 = $category1->term_id;
+                               $category2 = get_category_by_slug($Category2);
+                               $category2 = $category1->term_id;
+                               if($cat1 = $category1) { $cats[1] = $cat1; }
+                               if($cat2 = $category2) { $cats[2] = $cat2; }
 
                                if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
                        }
@@ -506,7 +502,9 @@ class Textpattern_Import {
        {
                // Post Import
                $posts = $this->get_txp_posts();
-               $this->posts2wp($posts);
+               $result = $this->posts2wp($posts);
+               if ( is_wp_error( $result ) )
+                       return $result;
 
                echo '<form action="admin.php?import=textpattern&amp;step=4" method="post">';
                wp_nonce_field('import-textpattern');
@@ -559,11 +557,11 @@ class Textpattern_Import {
        {
                echo '<p>'.__('Welcome to WordPress.  We hope (and expect!) that you will find this platform incredibly rewarding!  As a new WordPress user coming from Textpattern, there are some things that we would like to point out.  Hopefully, they will help your transition go as smoothly as possible.').'</p>';
                echo '<h3>'.__('Users').'</h3>';
-               echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password.  Forget it.  You didn\'t have that login in Textpattern, why should you have it here?  Instead we have taken care to import all of your users into our system.  Unfortunately there is one downside.  Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users.  <strong>Every user has the same username, but their passwords are reset to password123.</strong>  So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>';
+               echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password.  Forget it.  You didn&#8217;t have that login in Textpattern, why should you have it here?  Instead we have taken care to import all of your users into our system.  Unfortunately there is one downside.  Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users.  <strong>Every user has the same username, but their passwords are reset to password123.</strong>  So <a href="%1$s">Login</a> and change it.'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'</p>';
                echo '<h3>'.__('Preserving Authors').'</h3>';
                echo '<p>'.__('Secondly, we have attempted to preserve post authors.  If you are the only author or contributor to your blog, then you are safe.  In most cases, we are successful in this preservation endeavor.  However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>';
                echo '<h3>'.__('Textile').'</h3>';
-               echo '<p>'.__('Also, since you\'re coming from Textpattern, you probably have been using Textile to format your comments and posts.  If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>.  Trust me... You\'ll want it.').'</p>';
+               echo '<p>'.__('Also, since you&#8217;re coming from Textpattern, you probably have been using Textile to format your comments and posts.  If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>.  Trust me... You&#8217;ll want it.').'</p>';
                echo '<h3>'.__('WordPress Resources').'</h3>';
                echo '<p>'.__('Finally, there are numerous WordPress resources around the internet.  Some of them are:').'</p>';
                echo '<ul>';
@@ -571,7 +569,7 @@ class Textpattern_Import {
                echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
                echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
                echo '</ul>';
-               echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
+               echo '<p>'.sprintf(__('That&#8217;s it! What are you waiting for? Go <a href="%1$s">login</a>!'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'</p>';
        }
 
        function db_form()
@@ -646,7 +644,9 @@ class Textpattern_Import {
                                $this->import_users();
                                break;
                        case 3 :
-                               $this->import_posts();
+                               $result = $this->import_posts();
+                               if ( is_wp_error( $result ) ) 
+                                       echo $result->get_error_message();
                                break;
                        case 4 :
                                $this->import_comments();