From 545644ebc8ca4f5eb92e04d86e6de4b3dffba383 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 30 Nov 2005 07:13:20 +0000 Subject: [PATCH] Textpattern importer changes from Aaron Brazell. fixes #1944 git-svn-id: https://develop.svn.wordpress.org/trunk@3240 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/import/textpattern.php | 163 ++++++++++++++------------------ 1 file changed, 71 insertions(+), 92 deletions(-) diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php index 0944c290a3..db591ddc03 100644 --- a/wp-admin/import/textpattern.php +++ b/wp-admin/import/textpattern.php @@ -1,26 +1,4 @@ '; echo '

'.__('Import Textpattern').'

'; + echo '

'.__('Steps may take a few minutes depending on the size of your database. Please be patient.

'); } function footer() @@ -76,17 +52,10 @@ class Textpattern_Import { function greet() { - global $txpcfg; - _e('

Howdy! This importer allows you to extract posts from any Textpattern 4.0.2+ into your blog. This has not been tested on previous versions of Textpattern. Mileage may vary.

'); _e('

Your Textpattern Configuration settings are as follows:

'); - _e(''); - _e('

If this is incorrect, please modify settings in wp-admin/import/textpattern.php

'); _e('
'); + $this->db_form(); _e(''); _e('
'); } @@ -94,7 +63,7 @@ class Textpattern_Import { function get_txp_links() { //General Housekeeping - global $txpdb; + $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); set_magic_quotes_runtime(0); $prefix = get_option('tpre'); @@ -107,21 +76,13 @@ class Textpattern_Import { description FROM '.$prefix.'txp_link', ARRAY_A); - echo'SELECT - id, - date, - category, - url, - linkname, - description - FROM '.$prefix.'txp_link'; } function get_txp_cats() { - + global $wpdb; // General Housekeeping - global $txpdb; + $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); set_magic_quotes_runtime(0); $prefix = get_option('tpre'); @@ -135,10 +96,29 @@ class Textpattern_Import { ARRAY_A); } + function get_txp_users() + { + global $wpdb; + // General Housekeeping + $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); + set_magic_quotes_runtime(0); + $prefix = get_option('tpre'); + + // Get Users + + return $txpdb->get_results('SELECT + user_id, + name, + RealName, + email, + privs + FROM '.$prefix.'txp_users', ARRAY_A); + } + function get_txp_posts() { // General Housekeeping - global $txpdb; + $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); set_magic_quotes_runtime(0); $prefix = get_option('tpre'); @@ -156,17 +136,16 @@ class Textpattern_Import { Status, Keywords, url_title, - comments_count, - ADDDATE(Posted, "INTERVAL '.get_settings('gmt_offset').' HOURS") AS post_date_gmt, - ADDDATE(LastMod, "INTERVAL '.get_settings('gmt_offset').' HOURS") AS post_modified_gmt + comments_count FROM '.$prefix.'textpattern ', ARRAY_A); } function get_txp_comments() { + global $wpdb; // General Housekeeping - global $txpdb; + $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); set_magic_quotes_runtime(0); $prefix = get_option('tpre'); @@ -174,23 +153,6 @@ class Textpattern_Import { return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A); } - function get_txp_users() - { - // General Housekeeping - global $txpdb; - set_magic_quotes_runtime(0); - $prefix = get_option('tpre'); - - // Get Users - $users = $txpdb->get_results('SELECT - user_id, - name, - RealName, - email, - privs - FROM '.$prefix.'txp_users', ARRAY_A); - return $users; - } function links2wp($links='') { @@ -239,7 +201,7 @@ class Textpattern_Import { echo __('

Done! '.$count.' Links imported.

'); return true; } - echo 'No Links to Import!'; + echo __('No Links to Import!'); return false; } @@ -312,7 +274,7 @@ class Textpattern_Import { return true; }// End if(is_array($users) - echo 'No Users to Import!'; + echo __('No Users to Import!'); return false; }// End function user2wp() @@ -323,7 +285,6 @@ class Textpattern_Import { global $wpdb; $count = 0; $txpcat2wpcat = array(); - // Do the Magic if(is_array($categories)) { @@ -354,7 +315,7 @@ class Textpattern_Import { echo __('

Done! '.$count.' categories imported.

'); return true; } - echo 'No Categories to Import!'; + echo __('No Categories to Import!'); return false; } @@ -504,7 +465,7 @@ class Textpattern_Import { echo __('

Done! '.$count.' comments imported.

'); return true; } - echo 'No Comments to Import!'; + echo __('No Comments to Import!'); return false; } @@ -577,42 +538,60 @@ class Textpattern_Import { delete_option('txpposts2wpposts'); delete_option('txpcm2wpcm'); delete_option('txplinks2wplinks'); + delete_option('txpuser'); + delete_option('txppass'); + delete_option('txpname'); + delete_option('txphost'); $this->tips(); } function tips() { - echo'

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.

'; - echo'

Users

'; - echo'

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. Every user has the same username, but their passwords are reset to password123. This includes you. So Login and change it.

'; - echo'

Preserving Authors

'; - echo'

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.

'; - echo'

Textile

'; - echo'

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 Textile for WordPress. Trust me... You\'ll want it.

'; - echo'

WordPress Resources

'; - echo'

Finally, there are numerous WordPress resources around the internet. Some of them are:

'; - echo''; - echo'

That\'s it! What are you waiting for? Go login!

'; + echo __('

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.

'); + echo __('

Users

'); + echo __('

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. Every user has the same username, but their passwords are reset to password123. So Login and change it.

'); + echo __('

Preserving Authors

'); + echo __('

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.

'); + echo __('

Textile

'); + echo __('

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 Textile for WordPress. Trust me... You\'ll want it.

'); + echo __('

WordPress Resources

'); + echo __('

Finally, there are numerous WordPress resources around the internet. Some of them are:

'); + echo __(''); + echo __('

That\'s it! What are you waiting for? Go login!

'); + } + + function db_form() + { + _e(''); } function dispatch() { - global $txpdb, $txpcfg; if (empty ($_GET['step'])) $step = 0; else $step = (int) $_GET['step']; - $this->header(); - if ( $step > 0 ) { - add_option('tpre',$txpcfg['table_prefix']); - $txpdb = new wpdb($txpcfg['user'], $txpcfg['pass'], $txpcfg['db'], $txpcfg['host']); + if ( $step == 1 ) + { + if(false !== get_option('txpuser')) {add_option('txpuser',$_POST['dbuser']); } + if(false !== get_option('txppass')) {add_option('txppass',$_POST['dbpass']); } + if(false !== get_option('txpname')) {add_option('txpname',$_POST['dbname']); } + if(false !== get_option('txphost')) {add_option('txphost',$_POST['dbhost']); } + if(false !== get_option('tpre')) { add_option('tpre', $tpre); } + } switch ($step) @@ -652,4 +631,4 @@ class Textpattern_Import { $txp_import = new Textpattern_Import(); register_importer('textpattern', 'Textpattern', __('Import posts from a Textpattern Blog'), array ($txp_import, 'dispatch')); -?> +?> \ No newline at end of file