Wordpress 2.3.2
[autoinstalls/wordpress.git] / wp-admin / import / textpattern.php
1 <?php
2 /**
3         Add These Functions to make our lives easier
4 **/
5
6 if(!function_exists('get_comment_count'))
7 {
8         function get_comment_count($post_ID)
9         {
10                 global $wpdb;
11                 return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID);
12         }
13 }
14
15 if(!function_exists('link_exists'))
16 {
17         function link_exists($linkname)
18         {
19                 global $wpdb;
20                 return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$wpdb->escape($linkname).'"');
21         }
22 }
23
24 /**
25         The Main Importer Class
26 **/
27 class Textpattern_Import {
28
29         function header()
30         {
31                 echo '<div class="wrap">';
32                 echo '<h2>'.__('Import Textpattern').'</h2>';
33                 echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
34         }
35
36         function footer()
37         {
38                 echo '</div>';
39         }
40
41         function greet() {
42                 echo '<div class="narrow">';
43                 echo '<p>'.__('Howdy! This imports categories, users, posts, comments, and links from any Textpattern 4.0.2+ into this blog.').'</p>';
44                 echo '<p>'.__('This has not been tested on previous versions of Textpattern.  Mileage may vary.').'</p>';
45                 echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>';
46                 echo '<form action="admin.php?import=textpattern&amp;step=1" method="post">';
47                 wp_nonce_field('import-textpattern');
48                 $this->db_form();
49                 echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories &raquo;')).'" /></p>';
50                 echo '</form>';
51                 echo '</div>';
52         }
53
54         function get_txp_cats()
55         {
56                 global $wpdb;
57                 // General Housekeeping
58                 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
59                 set_magic_quotes_runtime(0);
60                 $prefix = get_option('tpre');
61
62                 // Get Categories
63                 return $txpdb->get_results('SELECT
64                         id,
65                         name,
66                         title
67                         FROM '.$prefix.'txp_category
68                         WHERE type = "article"',
69                         ARRAY_A);
70         }
71
72         function get_txp_users()
73         {
74                 global $wpdb;
75                 // General Housekeeping
76                 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
77                 set_magic_quotes_runtime(0);
78                 $prefix = get_option('tpre');
79
80                 // Get Users
81
82                 return $txpdb->get_results('SELECT
83                         user_id,
84                         name,
85                         RealName,
86                         email,
87                         privs
88                         FROM '.$prefix.'txp_users', ARRAY_A);
89         }
90
91         function get_txp_posts()
92         {
93                 // General Housekeeping
94                 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
95                 set_magic_quotes_runtime(0);
96                 $prefix = get_option('tpre');
97
98                 // Get Posts
99                 return $txpdb->get_results('SELECT
100                         ID,
101                         Posted,
102                         AuthorID,
103                         LastMod,
104                         Title,
105                         Body,
106                         Excerpt,
107                         Category1,
108                         Category2,
109                         Status,
110                         Keywords,
111                         url_title,
112                         comments_count
113                         FROM '.$prefix.'textpattern
114                         ', ARRAY_A);
115         }
116
117         function get_txp_comments()
118         {
119                 global $wpdb;
120                 // General Housekeeping
121                 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
122                 set_magic_quotes_runtime(0);
123                 $prefix = get_option('tpre');
124
125                 // Get Comments
126                 return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A);
127         }
128
129                 function get_txp_links()
130         {
131                 //General Housekeeping
132                 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
133                 set_magic_quotes_runtime(0);
134                 $prefix = get_option('tpre');
135
136                 return $txpdb->get_results('SELECT
137                         id,
138                         date,
139                         category,
140                         url,
141                         linkname,
142                         description
143                         FROM '.$prefix.'txp_link',
144                         ARRAY_A);
145         }
146
147         function cat2wp($categories='')
148         {
149                 // General Housekeeping
150                 global $wpdb;
151                 $count = 0;
152                 $txpcat2wpcat = array();
153                 // Do the Magic
154                 if(is_array($categories))
155                 {
156                         echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
157                         foreach ($categories as $category)
158                         {
159                                 $count++;
160                                 extract($category);
161
162
163                                 // Make Nice Variables
164                                 $name = $wpdb->escape($name);
165                                 $title = $wpdb->escape($title);
166
167                                 if($cinfo = category_exists($name))
168                                 {
169                                         $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title));
170                                 }
171                                 else
172                                 {
173                                         $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title));
174                                 }
175                                 $txpcat2wpcat[$id] = $ret_id;
176                         }
177
178                         // Store category translation for future use
179                         add_option('txpcat2wpcat',$txpcat2wpcat);
180                         echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
181                         return true;
182                 }
183                 echo __('No Categories to Import!');
184                 return false;
185         }
186
187         function users2wp($users='')
188         {
189                 // General Housekeeping
190                 global $wpdb;
191                 $count = 0;
192                 $txpid2wpid = array();
193
194                 // Midnight Mojo
195                 if(is_array($users))
196                 {
197                         echo '<p>'.__('Importing Users...').'<br /><br /></p>';
198                         foreach($users as $user)
199                         {
200                                 $count++;
201                                 extract($user);
202
203                                 // Make Nice Variables
204                                 $name = $wpdb->escape($name);
205                                 $RealName = $wpdb->escape($RealName);
206
207                                 if($uinfo = get_userdatabylogin($name))
208                                 {
209
210                                         $ret_id = wp_insert_user(array(
211                                                                 'ID'                    => $uinfo->ID,
212                                                                 'user_login'    => $name,
213                                                                 'user_nicename' => $RealName,
214                                                                 'user_email'    => $email,
215                                                                 'user_url'              => 'http://',
216                                                                 'display_name'  => $name)
217                                                                 );
218                                 }
219                                 else
220                                 {
221                                         $ret_id = wp_insert_user(array(
222                                                                 'user_login'    => $name,
223                                                                 'user_nicename' => $RealName,
224                                                                 'user_email'    => $email,
225                                                                 'user_url'              => 'http://',
226                                                                 'display_name'  => $name)
227                                                                 );
228                                 }
229                                 $txpid2wpid[$user_id] = $ret_id;
230
231                                 // Set Textpattern-to-WordPress permissions translation
232                                 $transperms = array(1 => '10', 2 => '9', 3 => '5', 4 => '4', 5 => '3', 6 => '2', 7 => '0');
233
234                                 // Update Usermeta Data
235                                 $user = new WP_User($ret_id);
236                                 if('10' == $transperms[$privs]) { $user->set_role('administrator'); }
237                                 if('9'  == $transperms[$privs]) { $user->set_role('editor'); }
238                                 if('5'  == $transperms[$privs]) { $user->set_role('editor'); }
239                                 if('4'  == $transperms[$privs]) { $user->set_role('author'); }
240                                 if('3'  == $transperms[$privs]) { $user->set_role('contributor'); }
241                                 if('2'  == $transperms[$privs]) { $user->set_role('contributor'); }
242                                 if('0'  == $transperms[$privs]) { $user->set_role('subscriber'); }
243
244                                 update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] );
245                                 update_usermeta( $ret_id, 'rich_editing', 'false');
246                         }// End foreach($users as $user)
247
248                         // Store id translation array for future use
249                         add_option('txpid2wpid',$txpid2wpid);
250
251
252                         echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
253                         return true;
254                 }// End if(is_array($users)
255
256                 echo __('No Users to Import!');
257                 return false;
258
259         }// End function user2wp()
260
261         function posts2wp($posts='')
262         {
263                 // General Housekeeping
264                 global $wpdb;
265                 $count = 0;
266                 $txpposts2wpposts = array();
267                 $cats = array();
268
269                 // Do the Magic
270                 if(is_array($posts))
271                 {
272                         echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
273                         foreach($posts as $post)
274                         {
275                                 $count++;
276                                 extract($post);
277
278                                 // Set Textpattern-to-WordPress status translation
279                                 $stattrans = array(1 => 'draft', 2 => 'private', 3 => 'draft', 4 => 'publish', 5 => 'publish');
280
281                                 //Can we do this more efficiently?
282                                 $uinfo = ( get_userdatabylogin( $AuthorID ) ) ? get_userdatabylogin( $AuthorID ) : 1;
283                                 $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ;
284
285                                 $Title = $wpdb->escape($Title);
286                                 $Body = $wpdb->escape($Body);
287                                 $Excerpt = $wpdb->escape($Excerpt);
288                                 $post_status = $stattrans[$Status];
289
290                                 // Import Post data into WordPress
291
292                                 if($pinfo = post_exists($Title,$Body))
293                                 {
294                                         $ret_id = wp_insert_post(array(
295                                                 'ID'                            => $pinfo,
296                                                 'post_date'                     => $Posted,
297                                                 'post_date_gmt'         => $post_date_gmt,
298                                                 'post_author'           => $authorid,
299                                                 'post_modified'         => $LastMod,
300                                                 'post_modified_gmt' => $post_modified_gmt,
301                                                 'post_title'            => $Title,
302                                                 'post_content'          => $Body,
303                                                 'post_excerpt'          => $Excerpt,
304                                                 'post_status'           => $post_status,
305                                                 'post_name'                     => $url_title,
306                                                 'comment_count'         => $comments_count)
307                                                 );
308                                         if ( is_wp_error( $ret_id ) )
309                                                 return $ret_id;
310                                 }
311                                 else
312                                 {
313                                         $ret_id = wp_insert_post(array(
314                                                 'post_date'                     => $Posted,
315                                                 'post_date_gmt'         => $post_date_gmt,
316                                                 'post_author'           => $authorid,
317                                                 'post_modified'         => $LastMod,
318                                                 'post_modified_gmt' => $post_modified_gmt,
319                                                 'post_title'            => $Title,
320                                                 'post_content'          => $Body,
321                                                 'post_excerpt'          => $Excerpt,
322                                                 'post_status'           => $post_status,
323                                                 'post_name'                     => $url_title,
324                                                 'comment_count'         => $comments_count)
325                                                 );
326                                         if ( is_wp_error( $ret_id ) )
327                                                 return $ret_id;
328                                 }
329                                 $txpposts2wpposts[$ID] = $ret_id;
330
331                                 // Make Post-to-Category associations
332                                 $cats = array();
333                                 $category1 = get_category_by_slug($Category1);
334                                 $category1 = $category1->term_id;
335                                 $category2 = get_category_by_slug($Category2);
336                                 $category2 = $category1->term_id;
337                                 if($cat1 = $category1) { $cats[1] = $cat1; }
338                                 if($cat2 = $category2) { $cats[2] = $cat2; }
339
340                                 if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
341                         }
342                 }
343                 // Store ID translation for later use
344                 add_option('txpposts2wpposts',$txpposts2wpposts);
345
346                 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
347                 return true;
348         }
349
350         function comments2wp($comments='')
351         {
352                 // General Housekeeping
353                 global $wpdb;
354                 $count = 0;
355                 $txpcm2wpcm = array();
356                 $postarr = get_option('txpposts2wpposts');
357
358                 // Magic Mojo
359                 if(is_array($comments))
360                 {
361                         echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
362                         foreach($comments as $comment)
363                         {
364                                 $count++;
365                                 extract($comment);
366
367                                 // WordPressify Data
368                                 $comment_ID = ltrim($discussid, '0');
369                                 $comment_post_ID = $postarr[$parentid];
370                                 $comment_approved = (1 == $visible) ? 1 : 0;
371                                 $name = $wpdb->escape($name);
372                                 $email = $wpdb->escape($email);
373                                 $web = $wpdb->escape($web);
374                                 $message = $wpdb->escape($message);
375
376                                 if($cinfo = comment_exists($name, $posted))
377                                 {
378                                         // Update comments
379                                         $ret_id = wp_update_comment(array(
380                                                 'comment_ID'                    => $cinfo,
381                                                 'comment_post_ID'               => $comment_post_ID,
382                                                 'comment_author'                => $name,
383                                                 'comment_author_email'  => $email,
384                                                 'comment_author_url'    => $web,
385                                                 'comment_date'                  => $posted,
386                                                 'comment_content'               => $message,
387                                                 'comment_approved'              => $comment_approved)
388                                                 );
389                                 }
390                                 else
391                                 {
392                                         // Insert comments
393                                         $ret_id = wp_insert_comment(array(
394                                                 'comment_post_ID'               => $comment_post_ID,
395                                                 'comment_author'                => $name,
396                                                 'comment_author_email'  => $email,
397                                                 'comment_author_url'    => $web,
398                                                 'comment_author_IP'             => $ip,
399                                                 'comment_date'                  => $posted,
400                                                 'comment_content'               => $message,
401                                                 'comment_approved'              => $comment_approved)
402                                                 );
403                                 }
404                                 $txpcm2wpcm[$comment_ID] = $ret_id;
405                         }
406                         // Store Comment ID translation for future use
407                         add_option('txpcm2wpcm', $txpcm2wpcm);
408
409                         // Associate newly formed categories with posts
410                         get_comment_count($ret_id);
411
412
413                         echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
414                         return true;
415                 }
416                 echo __('No Comments to Import!');
417                 return false;
418         }
419
420         function links2wp($links='')
421         {
422                 // General Housekeeping
423                 global $wpdb;
424                 $count = 0;
425
426                 // Deal with the links
427                 if(is_array($links))
428                 {
429                         echo '<p>'.__('Importing Links...').'<br /><br /></p>';
430                         foreach($links as $link)
431                         {
432                                 $count++;
433                                 extract($link);
434
435                                 // Make nice vars
436                                 $category = $wpdb->escape($category);
437                                 $linkname = $wpdb->escape($linkname);
438                                 $description = $wpdb->escape($description);
439
440                                 if($linfo = link_exists($linkname))
441                                 {
442                                         $ret_id = wp_insert_link(array(
443                                                                 'link_id'                       => $linfo,
444                                                                 'link_url'                      => $url,
445                                                                 'link_name'                     => $linkname,
446                                                                 'link_category'         => $category,
447                                                                 'link_description'      => $description,
448                                                                 'link_updated'          => $date)
449                                                                 );
450                                 }
451                                 else
452                                 {
453                                         $ret_id = wp_insert_link(array(
454                                                                 'link_url'                      => $url,
455                                                                 'link_name'                     => $linkname,
456                                                                 'link_category'         => $category,
457                                                                 'link_description'      => $description,
458                                                                 'link_updated'          => $date)
459                                                                 );
460                                 }
461                                 $txplinks2wplinks[$link_id] = $ret_id;
462                         }
463                         add_option('txplinks2wplinks',$txplinks2wplinks);
464                         echo '<p>';
465                         printf(__('Done! <strong>%s</strong> Links imported'), $count);
466                         echo '<br /><br /></p>';
467                         return true;
468                 }
469                 echo __('No Links to Import!');
470                 return false;
471         }
472
473         function import_categories()
474         {
475                 // Category Import
476                 $cats = $this->get_txp_cats();
477                 $this->cat2wp($cats);
478                 add_option('txp_cats', $cats);
479
480
481
482                 echo '<form action="admin.php?import=textpattern&amp;step=2" method="post">';
483                 wp_nonce_field('import-textpattern');
484                 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users')));
485                 echo '</form>';
486
487         }
488
489         function import_users()
490         {
491                 // User Import
492                 $users = $this->get_txp_users();
493                 $this->users2wp($users);
494
495                 echo '<form action="admin.php?import=textpattern&amp;step=3" method="post">';
496                 wp_nonce_field('import-textpattern');
497                 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
498                 echo '</form>';
499         }
500
501         function import_posts()
502         {
503                 // Post Import
504                 $posts = $this->get_txp_posts();
505                 $result = $this->posts2wp($posts);
506                 if ( is_wp_error( $result ) )
507                         return $result;
508
509                 echo '<form action="admin.php?import=textpattern&amp;step=4" method="post">';
510                 wp_nonce_field('import-textpattern');
511                 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
512                 echo '</form>';
513         }
514
515         function import_comments()
516         {
517                 // Comment Import
518                 $comments = $this->get_txp_comments();
519                 $this->comments2wp($comments);
520
521                 echo '<form action="admin.php?import=textpattern&amp;step=5" method="post">';
522                 wp_nonce_field('import-textpattern');
523                 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links')));
524                 echo '</form>';
525         }
526
527         function import_links()
528         {
529                 //Link Import
530                 $links = $this->get_txp_links();
531                 $this->links2wp($links);
532                 add_option('txp_links', $links);
533
534                 echo '<form action="admin.php?import=textpattern&amp;step=6" method="post">';
535                 wp_nonce_field('import-textpattern');
536                 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish')));
537                 echo '</form>';
538         }
539
540         function cleanup_txpimport()
541         {
542                 delete_option('tpre');
543                 delete_option('txp_cats');
544                 delete_option('txpid2wpid');
545                 delete_option('txpcat2wpcat');
546                 delete_option('txpposts2wpposts');
547                 delete_option('txpcm2wpcm');
548                 delete_option('txplinks2wplinks');
549                 delete_option('txpuser');
550                 delete_option('txppass');
551                 delete_option('txpname');
552                 delete_option('txphost');
553                 $this->tips();
554         }
555
556         function tips()
557         {
558                 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>';
559                 echo '<h3>'.__('Users').'</h3>';
560                 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>';
561                 echo '<h3>'.__('Preserving Authors').'</h3>';
562                 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>';
563                 echo '<h3>'.__('Textile').'</h3>';
564                 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>';
565                 echo '<h3>'.__('WordPress Resources').'</h3>';
566                 echo '<p>'.__('Finally, there are numerous WordPress resources around the internet.  Some of them are:').'</p>';
567                 echo '<ul>';
568                 echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
569                 echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
570                 echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
571                 echo '</ul>';
572                 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>';
573         }
574
575         function db_form()
576         {
577                 echo '<table class="editform">';
578                 printf('<tr><th scope="row"><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('Textpattern Database User:'));
579                 printf('<tr><th scope="row"><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('Textpattern Database Password:'));
580                 printf('<tr><th scope="row"><label for="dbname">%s</label></th><td><input type="text" id="dbname" name="dbname" /></td></tr>', __('Textpattern Database Name:'));
581                 printf('<tr><th scope="row"><label for="dbhost">%s</label></th><td><input type="text" id="dbhost" name="dbhost" value="localhost" /></td></tr>', __('Textpattern Database Host:'));
582                 printf('<tr><th scope="row"><label for="dbprefix">%s</label></th><td><input type="text" name="dbprefix" id="dbprefix"  /></td></tr>', __('Textpattern Table prefix (if any):'));
583                 echo '</table>';
584         }
585
586         function dispatch()
587         {
588
589                 if (empty ($_GET['step']))
590                         $step = 0;
591                 else
592                         $step = (int) $_GET['step'];
593                 $this->header();
594
595                 if ( $step > 0 )
596                 {
597                         check_admin_referer('import-textpattern');
598
599                         if($_POST['dbuser'])
600                         {
601                                 if(get_option('txpuser'))
602                                         delete_option('txpuser');
603                                 add_option('txpuser', sanitize_user($_POST['dbuser'], true));
604                         }
605                         if($_POST['dbpass'])
606                         {
607                                 if(get_option('txppass'))
608                                         delete_option('txppass');
609                                 add_option('txppass',  sanitize_user($_POST['dbpass'], true));
610                         }
611
612                         if($_POST['dbname'])
613                         {
614                                 if(get_option('txpname'))
615                                         delete_option('txpname');
616                                 add_option('txpname',  sanitize_user($_POST['dbname'], true));
617                         }
618                         if($_POST['dbhost'])
619                         {
620                                 if(get_option('txphost'))
621                                         delete_option('txphost');
622                                 add_option('txphost',  sanitize_user($_POST['dbhost'], true));
623                         }
624                         if($_POST['dbprefix'])
625                         {
626                                 if(get_option('tpre'))
627                                         delete_option('tpre');
628                                 add_option('tpre',  sanitize_user($_POST['dbprefix']));
629                         }
630
631
632                 }
633
634                 switch ($step)
635                 {
636                         default:
637                         case 0 :
638                                 $this->greet();
639                                 break;
640                         case 1 :
641                                 $this->import_categories();
642                                 break;
643                         case 2 :
644                                 $this->import_users();
645                                 break;
646                         case 3 :
647                                 $result = $this->import_posts();
648                                 if ( is_wp_error( $result ) ) 
649                                         echo $result->get_error_message();
650                                 break;
651                         case 4 :
652                                 $this->import_comments();
653                                 break;
654                         case 5 :
655                                 $this->import_links();
656                                 break;
657                         case 6 :
658                                 $this->cleanup_txpimport();
659                                 break;
660                 }
661
662                 $this->footer();
663         }
664
665         function Textpattern_Import()
666         {
667                 // Nothing.
668         }
669 }
670
671 $txp_import = new Textpattern_Import();
672 register_importer('textpattern', __('Textpattern'), __('Import categories, users, posts, comments, and links from a Textpattern blog'), array ($txp_import, 'dispatch'));
673 ?>