Make WordPress Core

Ticket #2234: dotclear.php

File dotclear.php, 22.0 KB (added by thomasq, 21 years ago)

Dotclear import plugin

Line 
1<?php
2/**
3 Add These Functions to make our lives easier
4**/
5if(!function_exists('get_catbynicename'))
6{
7 function get_catbynicename($category_nicename)
8 {
9 global $wpdb;
10
11 $cat_id -= 0; // force numeric
12 $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
13
14 return $name;
15 }
16}
17
18if(!function_exists('get_comment_count'))
19{
20 function get_comment_count($post_ID)
21 {
22 global $wpdb;
23 return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID);
24 }
25}
26
27if(!function_exists('link_cat_exists'))
28{
29 function link_cat_exists($catname)
30 {
31 global $wpdb;
32 return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"');
33 }
34}
35
36if(!function_exists('link_exists'))
37{
38 function link_exists($linkname)
39 {
40 global $wpdb;
41 return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$linkname.'"');
42 }
43}
44
45/*
46 Identify UTF-8 text
47 Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087
48*/
49//
50// utf8 encoding validation developed based on Wikipedia entry at:
51// http://en.wikipedia.org/wiki/UTF-8
52//
53// Implemented as a recursive descent parser based on a simple state machine
54// copyright 2005 Maarten Meijer
55//
56// This cries out for a C-implementation to be included in PHP core
57//
58 function valid_1byte($char) {
59 if(!is_int($char)) return false;
60 return ($char & 0x80) == 0x00;
61 }
62
63 function valid_2byte($char) {
64 if(!is_int($char)) return false;
65 return ($char & 0xE0) == 0xC0;
66 }
67
68 function valid_3byte($char) {
69 if(!is_int($char)) return false;
70 return ($char & 0xF0) == 0xE0;
71 }
72
73 function valid_4byte($char) {
74 if(!is_int($char)) return false;
75 return ($char & 0xF8) == 0xF0;
76 }
77
78 function valid_nextbyte($char) {
79 if(!is_int($char)) return false;
80 return ($char & 0xC0) == 0x80;
81 }
82
83 function valid_utf8($string) {
84 $len = strlen($string);
85 $i = 0;
86 while( $i < $len ) {
87 $char = ord(substr($string, $i++, 1));
88 if(valid_1byte($char)) { // continue
89 continue;
90 } else if(valid_2byte($char)) { // check 1 byte
91 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
92 return false;
93 } else if(valid_3byte($char)) { // check 2 bytes
94 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
95 return false;
96 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
97 return false;
98 } else if(valid_4byte($char)) { // check 3 bytes
99 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
100 return false;
101 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
102 return false;
103 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
104 return false;
105 } // goto next char
106 }
107 return true; // done
108 }
109
110function csc ($s) {
111 if (valid_utf8 ($s)) {
112 return $s;
113 } else {
114 return iconv(get_option ("dccharset"),"UTF-8",$s);
115 }
116}
117
118function textconv ($s) {
119 return csc (preg_replace ('|(?<!<br />)\s*\n|', ' ', $s));
120}
121
122/**
123 The Main Importer Class
124**/
125class Dotclear_Import {
126
127 function header()
128 {
129 echo '<div class="wrap">';
130 echo '<h2>'.__('Import Dotclear').'</h2>';
131 echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
132 }
133
134 function footer()
135 {
136 echo '</div>';
137 }
138
139 function greet()
140 {
141 echo '<p>'.__('Howdy! This importer allows you to extract posts from a Dotclear database into your blog. Mileage may vary.').'</p>';
142 echo '<p>'.__('Your Dotclear Configuration settings are as follows:').'</p>';
143 echo '<form action="admin.php?import=dotclear&amp;step=1" method="post">';
144 $this->db_form();
145 echo '<input type="submit" name="submit" value="Import Categories" />';
146 echo '</form>';
147 }
148
149 function get_dc_cats()
150 {
151 global $wpdb;
152 // General Housekeeping
153 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
154 set_magic_quotes_runtime(0);
155 $prefix = get_option('tpre');
156
157 // Get Categories
158 return $dcdb->get_results('SELECT * FROM dc_categorie', ARRAY_A);
159 }
160
161 function get_dc_users()
162 {
163 global $wpdb;
164 // General Housekeeping
165 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
166 set_magic_quotes_runtime(0);
167 $prefix = get_option('tpre');
168
169 // Get Users
170
171 return $dcdb->get_results('SELECT * FROM dc_user', ARRAY_A);
172 }
173
174 function get_dc_posts()
175 {
176 // General Housekeeping
177 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
178 set_magic_quotes_runtime(0);
179 $prefix = get_option('tpre');
180
181 // Get Posts
182 return $dcdb->get_results('SELECT dc_post.*, dc_categorie.cat_libelle_url AS post_cat_name
183 FROM dc_post INNER JOIN dc_categorie
184 ON dc_post.cat_id = dc_categorie.cat_id', ARRAY_A);
185 }
186
187 function get_dc_comments()
188 {
189 global $wpdb;
190 // General Housekeeping
191 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
192 set_magic_quotes_runtime(0);
193 $prefix = get_option('tpre');
194
195 // Get Comments
196 return $dcdb->get_results('SELECT * FROM dc_comment', ARRAY_A);
197 }
198
199 function get_dc_links()
200 {
201 //General Housekeeping
202 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
203 set_magic_quotes_runtime(0);
204 $prefix = get_option('tpre');
205
206 return $dcdb->get_results('SELECT * FROM dc_link ORDER BY position', ARRAY_A);
207 }
208
209 function cat2wp($categories='')
210 {
211 // General Housekeeping
212 global $wpdb;
213 $count = 0;
214 $dccat2wpcat = array();
215 // Do the Magic
216 if(is_array($categories))
217 {
218 echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
219 foreach ($categories as $category)
220 {
221 $count++;
222 extract($category);
223
224 // Make Nice Variables
225 $name = $wpdb->escape($cat_libelle_url);
226 $title = $wpdb->escape(csc ($cat_libelle));
227 $desc = $wpdb->escape(csc ($cat_desc));
228
229 if($cinfo = category_exists($name))
230 {
231 $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
232 }
233 else
234 {
235 $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
236 }
237 $dccat2wpcat[$id] = $ret_id;
238 }
239
240 // Store category translation for future use
241 add_option('dccat2wpcat',$dccat2wpcat);
242 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
243 return true;
244 }
245 echo __('No Categories to Import!');
246 return false;
247 }
248
249 function users2wp($users='')
250 {
251 // General Housekeeping
252 global $wpdb;
253 $count = 0;
254 $dcid2wpid = array();
255
256 // Midnight Mojo
257 if(is_array($users))
258 {
259 echo '<p>'.__('Importing Users...').'<br /><br /></p>';
260 foreach($users as $user)
261 {
262 $count++;
263 extract($user);
264
265 // Make Nice Variables
266 $name = $wpdb->escape(csc ($name));
267 $RealName = $wpdb->escape(csc ($user_pseudo));
268
269 if($uinfo = get_userdatabylogin($name))
270 {
271
272 $ret_id = wp_insert_user(array(
273 'ID' => $uinfo->ID,
274 'user_login' => $user_id,
275 'user_nicename' => $Realname,
276 'user_email' => $user_email,
277 'user_url' => 'http://',
278 'display_name' => $Realname)
279 );
280 }
281 else
282 {
283 $ret_id = wp_insert_user(array(
284 'user_login' => $user_id,
285 'user_nicename' => csc ($user_pseudo),
286 'user_email' => $user_email,
287 'user_url' => 'http://',
288 'display_name' => $Realname)
289 );
290 }
291 $dcid2wpid[$user_id] = $ret_id;
292
293 // Set Dotclear-to-WordPress permissions translation
294
295 // Update Usermeta Data
296 $user = new WP_User($ret_id);
297 $wp_perms = $user_level + 1;
298 if(10 == $wp_perms) { $user->set_role('administrator'); }
299 else if(9 == $wp_perms) { $user->set_role('editor'); }
300 else if(5 <= $wp_perms) { $user->set_role('editor'); }
301 else if(4 <= $wp_perms) { $user->set_role('author'); }
302 else if(3 <= $wp_perms) { $user->set_role('contributor'); }
303 else if(2 <= $wp_perms) { $user->set_role('contributor'); }
304 else { $user->set_role('subscriber'); }
305
306 update_usermeta( $ret_id, 'wp_user_level', $wp_perms);
307 update_usermeta( $ret_id, 'rich_editing', 'false');
308 update_usermeta( $ret_id, 'first_name', csc ($user_prenom));
309 update_usermeta( $ret_id, 'last_name', csc ($user_nom));
310 }// End foreach($users as $user)
311
312 // Store id translation array for future use
313 add_option('dcid2wpid',$dcid2wpid);
314
315
316 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
317 return true;
318 }// End if(is_array($users)
319
320 echo __('No Users to Import!');
321 return false;
322
323 }// End function user2wp()
324
325 function posts2wp($posts='')
326 {
327 // General Housekeeping
328 global $wpdb;
329 $count = 0;
330 $dcposts2wpposts = array();
331 $cats = array();
332
333 // Do the Magic
334 if(is_array($posts))
335 {
336 echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
337 foreach($posts as $post)
338 {
339 $count++;
340 extract($post);
341
342 // Set Dotclear-to-WordPress status translation
343 $stattrans = array(0 => 'draft', 1 => 'publish');
344 $comment_status_map = array (0 => 'closed', 1 => 'open');
345
346 //Can we do this more efficiently?
347 $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1;
348 $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ;
349
350 $Title = $wpdb->escape(csc ($post_titre));
351 $Body = $wpdb->escape(textconv ($post_content));
352 if ($post_chapo != "") {
353 $Excerpt = $wpdb->escape(textconv ($post_chapo));
354 $Body = $Excerpt . "\n< !--more-->\n".$Body;
355 }
356 $post_status = $stattrans[$post_pub];
357
358 // Import Post data into WordPress
359
360 if($pinfo = post_exists($Title,$Body))
361 {
362 $ret_id = wp_insert_post(array(
363 'ID' => $pinfo,
364 'post_author' => $authorid,
365 'post_date' => $post_dt,
366 'post_date_gmt' => $post_dt,
367 'post_modified' => $post_upddt,
368 'post_modified_gmt' => $post_upddt,
369 'post_title' => $Title,
370 'post_content' => $Body,
371 'post_excerpt' => $Excerpt,
372 'post_status' => $post_status,
373 'post_name' => $post_titre_url,
374 'comment_status' => $comment_status_map[$post_open_comment],
375 'ping_status' => $comment_status_map[$post_open_tb],
376 'comment_count' => $post_nb_comment + $post_nb_trackback)
377 );
378 }
379 else
380 {
381 $ret_id = wp_insert_post(array(
382 'post_author' => $authorid,
383 'post_date' => $post_dt,
384 'post_date_gmt' => $post_dt,
385 'post_modified' => $post_modified_gmt,
386 'post_modified_gmt' => $post_modified_gmt,
387 'post_title' => $Title,
388 'post_content' => $Body,
389 'post_excerpt' => $Excerpt,
390 'post_status' => $post_status,
391 'post_name' => $post_titre_url,
392 'comment_status' => $comment_status_map[$post_open_comment],
393 'ping_status' => $comment_status_map[$post_open_tb],
394 'comment_count' => $post_nb_comment + $post_nb_trackback)
395 );
396 }
397 $dcposts2wpposts[$post_id] = $ret_id;
398
399 // Make Post-to-Category associations
400 $cats = array();
401 if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; }
402
403 if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); }
404 }
405 }
406 // Store ID translation for later use
407 add_option('dcposts2wpposts',$dcposts2wpposts);
408
409 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
410 return true;
411 }
412
413 function comments2wp($comments='')
414 {
415 // General Housekeeping
416 global $wpdb;
417 $count = 0;
418 $dccm2wpcm = array();
419 $postarr = get_option('dcposts2wpposts');
420
421 // Magic Mojo
422 if(is_array($comments))
423 {
424 echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
425 foreach($comments as $comment)
426 {
427 $count++;
428 extract($comment);
429
430 // WordPressify Data
431 $comment_ID = ltrim($comment_id, '0');
432 $comment_post_ID = $postarr[$post_id];
433 $comment_approved = "$comment_pub";
434 $name = $wpdb->escape(csc ($comment_auteur));
435 $email = $wpdb->escape($comment_email);
436 $web = "http://".$wpdb->escape($comment_site);
437 $message = $wpdb->escape(textconv ($comment_content));
438
439 if($cinfo = comment_exists($name, $comment_dt))
440 {
441 // Update comments
442 $ret_id = wp_update_comment(array(
443 'comment_ID' => $cinfo,
444 'comment_post_ID' => $comment_post_ID,
445 'comment_author' => $name,
446 'comment_author_email' => $email,
447 'comment_author_url' => $web,
448 'comment_author_IP' => $comment_ip,
449 'comment_date' => $comment_dt,
450 'comment_date_gmt' => $comment_dt,
451 'comment_content' => $message,
452 'comment_approved' => $comment_approved)
453 );
454 }
455 else
456 {
457 // Insert comments
458 $ret_id = wp_insert_comment(array(
459 'comment_post_ID' => $comment_post_ID,
460 'comment_author' => $name,
461 'comment_author_email' => $email,
462 'comment_author_url' => $web,
463 'comment_author_IP' => $comment_ip,
464 'comment_date' => $comment_dt,
465 'comment_date_gmt' => $comment_dt,
466 'comment_content' => $message,
467 'comment_approved' => $comment_approved)
468 );
469 }
470 $dccm2wpcm[$comment_ID] = $ret_id;
471 }
472 // Store Comment ID translation for future use
473 add_option('dccm2wpcm', $dccm2wpcm);
474
475 // Associate newly formed categories with posts
476 get_comment_count($ret_id);
477
478
479 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
480 return true;
481 }
482 echo __('No Comments to Import!');
483 return false;
484 }
485
486 function links2wp($links='')
487 {
488 // General Housekeeping
489 global $wpdb;
490 $count = 0;
491
492 // Deal with the links
493 if(is_array($links))
494 {
495 echo '<p>'.__('Importing Links...').'<br /><br /></p>';
496 foreach($links as $link)
497 {
498 $count++;
499 extract($link);
500
501 if ($title != "") {
502 if ($cinfo = link_cat_exists (csc ($title))) {
503 $category = $cinfo;
504 } else {
505 $wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('".
506 $wpdb->escape (csc ($title))."')");
507 $category = $wpdb->insert_id;
508 }
509 } else {
510 $linkname = $wpdb->escape(csc ($label));
511 $description = $wpdb->escape(csc ($title));
512
513 if($linfo = link_exists($linkname)) {
514 $ret_id = wp_insert_link(array(
515 'link_id' => $linfo,
516 'link_url' => $href,
517 'link_name' => $linkname,
518 'link_category' => $category,
519 'link_description' => $description)
520 );
521 } else {
522 $ret_id = wp_insert_link(array(
523 'link_url' => $url,
524 'link_name' => $linkname,
525 'link_category' => $category,
526 'link_description' => $description)
527 );
528 }
529 $dclinks2wplinks[$link_id] = $ret_id;
530 }
531 }
532 add_option('dclinks2wplinks',$dclinks2wplinks);
533 echo '<p>';
534 printf(__('Done! <strong>%s</strong>Links or link categories imported'), $count);
535 echo '<br /><br /></p>';
536 return true;
537 }
538 echo __('No Links to Import!');
539 return false;
540 }
541
542 function import_categories()
543 {
544 // Category Import
545 $cats = $this->get_dc_cats();
546 $this->cat2wp($cats);
547 add_option('dc_cats', $cats);
548
549
550
551 echo '<form action="admin.php?import=dotclear&amp;step=2" method="post">';
552 printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
553 echo '</form>';
554
555 }
556
557 function import_users()
558 {
559 // User Import
560 $users = $this->get_dc_users();
561 $this->users2wp($users);
562
563 echo '<form action="admin.php?import=dotclear&amp;step=3" method="post">';
564 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
565 echo '</form>';
566 }
567
568 function import_posts()
569 {
570 // Post Import
571 $posts = $this->get_dc_posts();
572 $this->posts2wp($posts);
573
574 echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
575 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
576 echo '</form>';
577 }
578
579 function import_comments()
580 {
581 // Comment Import
582 $comments = $this->get_dc_comments();
583 $this->comments2wp($comments);
584
585 echo '<form action="admin.php?import=dotclear&amp;step=5" method="post">';
586 printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
587 echo '</form>';
588 }
589
590 function import_links()
591 {
592 //Link Import
593 $links = $this->get_dc_links();
594 $this->links2wp($links);
595 add_option('dc_links', $links);
596
597 echo '<form action="admin.php?import=dotclear&amp;step=6" method="post">';
598 printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
599 echo '</form>';
600 }
601
602 function cleanup_dcimport()
603 {
604 delete_option('tpre');
605 delete_option('dc_cats');
606 delete_option('dcid2wpid');
607 delete_option('dccat2wpcat');
608 delete_option('dcposts2wpposts');
609 delete_option('dccm2wpcm');
610 delete_option('dclinks2wplinks');
611 delete_option('dcuser');
612 delete_option('dcpass');
613 delete_option('dcname');
614 delete_option('dchost');
615 delete_option('dccharset');
616 $this->tips();
617 }
618
619 function tips()
620 {
621 echo '<p>'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Dotclear, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'</p>';
622 echo '<h3>'.__('Users').'</h3>';
623 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 Dotclear, 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 Dotclear 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>';
624 echo '<h3>'.__('Preserving Authors').'</h3>';
625 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>';
626 echo '<h3>'.__('Textile').'</h3>';
627 echo '<p>'.__('Also, since you\'re coming from Dotclear, 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/2004/04/19/wordpress-plugin-textile-20/">Textile for WordPress</a>. Trust me... You\'ll want it.').'</p>';
628 echo '<h3>'.__('WordPress Resources').'</h3>';
629 echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>';
630 echo '<ul>';
631 echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
632 echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums').'</li>';
633 echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
634 echo '</ul>';
635 echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
636 }
637
638 function db_form()
639 {
640 echo '<ul>';
641 printf('<li><label for="dbuser">%s</label> <input type="text" name="dbuser" /></li>', __('Dotclear Database User:'));
642 printf('<li><label for="dbpass">%s</label> <input type="password" name="dbpass" /></li>', __('Dotclear Database Password:'));
643 printf('<li><label for="dbname">%s</label> <input type="text" name="dbname" /></li>', __('Dotclear Database Name:'));
644 printf('<li><label for="dbhost">%s</label> <input type="text" name="dbhost" value="localhost" /></li>', __('Dotclear Database Host:'));
645 /* printf('<li><label for="dbprefix">%s</label> <input type="text" name="dbprefix" /></li>', __('Dotclear Table prefix (if any):')); */
646 printf('<li><label for="dccharset">%s</label> <input type="text" name="dccharset" value="ISO-8859-15"/></li>', __('Originating character set:'));
647 echo '</ul>';
648 }
649
650 function dispatch()
651 {
652
653 if (empty ($_GET['step']))
654 $step = 0;
655 else
656 $step = (int) $_GET['step'];
657 $this->header();
658
659 if ( $step > 0 )
660 {
661 if($_POST['dbuser'])
662 {
663 if(get_option('dcuser'))
664 delete_option('dcuser');
665 add_option('dcuser',$_POST['dbuser']);
666 }
667 if($_POST['dbpass'])
668 {
669 if(get_option('dcpass'))
670 delete_option('dcpass');
671 add_option('dcpass',$_POST['dbpass']);
672 }
673
674 if($_POST['dbname'])
675 {
676 if(get_option('dcname'))
677 delete_option('dcname');
678 add_option('dcname',$_POST['dbname']);
679 }
680 if($_POST['dbhost'])
681 {
682 if(get_option('dchost'))
683 delete_option('dchost');
684 add_option('dchost',$_POST['dbhost']);
685 }
686 if($_POST['dccharset'])
687 {
688 if(get_option('dccharset'))
689 delete_option('dccharset');
690 add_option('dccharset',$_POST['dccharset']);
691 }
692 if($_POST['dbprefix'])
693 {
694 if(get_option('tpre'))
695 delete_option('tpre');
696 add_option('tpre',$_POST['dbprefix']);
697 }
698
699
700 }
701
702 switch ($step)
703 {
704 default:
705 case 0 :
706 $this->greet();
707 break;
708 case 1 :
709 $this->import_categories();
710 break;
711 case 2 :
712 $this->import_users();
713 break;
714 case 3 :
715 $this->import_posts();
716 break;
717 case 4 :
718 $this->import_comments();
719 break;
720 case 5 :
721 $this->import_links();
722 break;
723 case 6 :
724 $this->cleanup_dcimport();
725 break;
726 }
727
728 $this->footer();
729 }
730
731 function Dotclear_Import()
732 {
733 // Nothing.
734 }
735}
736
737$dc_import = new Dotclear_Import();
738register_importer('dotclear', 'Dotclear', __('Import posts from a Dotclear Blog'), array ($dc_import, 'dispatch'));
739?>