diff -ruN dotclear-importer/dotclear-importer.php dotclear-importer.patched//dotclear-importer.php
|
old
|
new
|
|
| 129 | 129 | $dbprefix = get_option('dcdbprefix'); |
| 130 | 130 | |
| 131 | 131 | // Get Categories |
| 132 | | return $dcdb->get_results('SELECT * FROM '.$dbprefix.'categorie', ARRAY_A); |
| | 132 | return $dcdb->get_results('SELECT * FROM '.$dbprefix.'category', ARRAY_A); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | function get_dc_users() |
| … |
… |
|
| 141 | 141 | $dbprefix = get_option('dcdbprefix'); |
| 142 | 142 | |
| 143 | 143 | // Get Users |
| 144 | | |
| 145 | 144 | return $dcdb->get_results('SELECT * FROM '.$dbprefix.'user', ARRAY_A); |
| 146 | 145 | } |
| 147 | 146 | |
| … |
… |
|
| 153 | 152 | $dbprefix = get_option('dcdbprefix'); |
| 154 | 153 | |
| 155 | 154 | // Get Posts |
| 156 | | return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name |
| 157 | | FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie |
| 158 | | ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A); |
| | 155 | return $dcdb->get_results('SELECT '.$dbprefix.'post.* FROM '.$dbprefix.'post', ARRAY_A); |
| 159 | 156 | } |
| 160 | 157 | |
| 161 | 158 | function get_dc_comments() |
| … |
… |
|
| 177 | 174 | set_magic_quotes_runtime(0); |
| 178 | 175 | $dbprefix = get_option('dcdbprefix'); |
| 179 | 176 | |
| 180 | | return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY position', ARRAY_A); |
| | 177 | return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY link_position', ARRAY_A); |
| 181 | 178 | } |
| 182 | 179 | |
| 183 | 180 | function cat2wp($categories='') |
| … |
… |
|
| 194 | 191 | extract($category); |
| 195 | 192 | |
| 196 | 193 | // Make Nice Variables |
| 197 | | $name = $wpdb->escape($cat_libelle_url); |
| 198 | | $title = $wpdb->escape(csc ($cat_libelle)); |
| | 194 | $name = $wpdb->escape($cat_url); |
| | 195 | $title = $wpdb->escape(csc ($cat_title)); |
| 199 | 196 | $desc = $wpdb->escape(csc ($cat_desc)); |
| 200 | 197 | |
| 201 | 198 | if ($cinfo = category_exists($name)) { |
| … |
… |
|
| 223 | 220 | |
| 224 | 221 | // Midnight Mojo |
| 225 | 222 | if (is_array($users)) { |
| 226 | | echo '<p>'.__('Importing Users...', 'dotclear-importer').'<br /><br /></p>'; |
| | 223 | echo '<p>'.__('Importing Users...', 'dotclear-importer').'</p>'; |
| | 224 | echo '<p>'.__('( if you see any error (WP_Error): maybe you have a conflict with your current users from your wordpress and your imported users from dotclear. )', 'dotclear-importer').'<br /><br /></p>'; |
| 227 | 225 | foreach ($users as $user) { |
| 228 | 226 | $count++; |
| 229 | 227 | extract($user); |
| … |
… |
|
| 292 | 290 | $dcposts2wpposts = array(); |
| 293 | 291 | $cats = array(); |
| 294 | 292 | |
| | 293 | foreach($this->get_dc_cats() as $buffer) { |
| | 294 | $categories[$buffer["cat_id"]] = $buffer["cat_title"]; |
| | 295 | } |
| | 296 | |
| 295 | 297 | // Do the Magic |
| 296 | 298 | if (is_array($posts)) { |
| 297 | 299 | echo '<p>'.__('Importing Posts...', 'dotclear-importer').'<br /><br /></p>'; |
| … |
… |
|
| 308 | 310 | $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1; |
| 309 | 311 | $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ; |
| 310 | 312 | |
| 311 | | $Title = $wpdb->escape(csc ($post_titre)); |
| | 313 | $Title = $wpdb->escape(csc ($post_title)); |
| 312 | 314 | $post_content = textconv ($post_content); |
| 313 | 315 | $post_excerpt = ""; |
| 314 | 316 | if ($post_chapo != "") { |
| … |
… |
|
| 320 | 322 | $post_status = $stattrans[$post_pub]; |
| 321 | 323 | |
| 322 | 324 | // Import Post data into WordPress |
| 323 | | |
| 324 | 325 | if ($pinfo = post_exists($Title,$post_content)) { |
| 325 | 326 | $ret_id = wp_insert_post(array( |
| 326 | 327 | 'ID' => $pinfo, |
| … |
… |
|
| 359 | 360 | if ( is_wp_error( $ret_id ) ) |
| 360 | 361 | return $ret_id; |
| 361 | 362 | } |
| | 363 | |
| | 364 | // print "Dotclear($post_id) => Wordpress($ret_id)<br/>"; |
| 362 | 365 | $dcposts2wpposts[$post_id] = $ret_id; |
| 363 | 366 | |
| 364 | 367 | // Make Post-to-Category associations |
| 365 | 368 | $cats = array(); |
| 366 | | $category1 = get_category_by_slug($post_cat_name); |
| | 369 | $category1 = get_category_by_slug($categories[$cat_id]); |
| 367 | 370 | $category1 = $category1->term_id; |
| 368 | 371 | |
| 369 | 372 | if ($cat1 = $category1) { $cats[1] = $cat1; } |
| … |
… |
|
| 372 | 375 | } |
| 373 | 376 | } |
| 374 | 377 | // Store ID translation for later use |
| 375 | | add_option('dcposts2wpposts',$dcposts2wpposts); |
| | 378 | // add_option('dcposts2wpposts', $dcposts2wpposts); // after storing, all datas are altered ôO |
| | 379 | // bug into add_option ?!! |
| 376 | 380 | |
| 377 | 381 | echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.', 'dotclear-importer'), $count).'<br /><br /></p>'; |
| 378 | | return true; |
| | 382 | |
| | 383 | return $dcposts2wpposts; |
| 379 | 384 | } |
| 380 | 385 | |
| 381 | | function comments2wp($comments='') { |
| | 386 | function comments2wp($comments='', $linker) { |
| 382 | 387 | // General Housekeeping |
| 383 | 388 | global $wpdb; |
| 384 | 389 | $count = 0; |
| 385 | 390 | $dccm2wpcm = array(); |
| 386 | | $postarr = get_option('dcposts2wpposts'); |
| | 391 | |
| | 392 | //$postarr = get_option('dcposts2wpposts'); // after storing, all datas are altered ôO |
| | 393 | // bug into add_option ?!! |
| | 394 | $postarr = $linker; |
| 387 | 395 | |
| 388 | 396 | // Magic Mojo |
| 389 | 397 | if (is_array($comments)) { |
| … |
… |
|
| 395 | 403 | // WordPressify Data |
| 396 | 404 | $comment_ID = (int) ltrim($comment_id, '0'); |
| 397 | 405 | $comment_post_ID = (int) $postarr[$post_id]; |
| 398 | | $comment_approved = $comment_pub; |
| 399 | | $name = $wpdb->escape(csc ($comment_auteur)); |
| | 406 | $comment_approved = ($comment_status == 1) ? 1 : 0; |
| | 407 | $name = $wpdb->escape(csc ($comment_author)); |
| 400 | 408 | $email = $wpdb->escape($comment_email); |
| 401 | 409 | $web = "http://".$wpdb->escape($comment_site); |
| 402 | 410 | $message = $wpdb->escape(textconv ($comment_content)); |
| … |
… |
|
| 449 | 457 | $count++; |
| 450 | 458 | extract($link); |
| 451 | 459 | |
| 452 | | if ($title != "") { |
| 453 | | if ($cinfo = term_exists(csc ($title), 'link_category')) { |
| 454 | | $category = $cinfo['term_id']; |
| 455 | | } else { |
| 456 | | $category = wp_insert_term($wpdb->escape (csc ($title)), 'link_category'); |
| 457 | | $category = $category['term_id']; |
| 458 | | } |
| 459 | | } else { |
| 460 | | $linkname = $wpdb->escape(csc ($label)); |
| 461 | | $description = $wpdb->escape(csc ($title)); |
| | 460 | $linkname = $wpdb->escape(csc ($link_title)); |
| | 461 | $description = $wpdb->escape(csc ($link_desc)); |
| 462 | 462 | |
| 463 | | if ($linfo = link_exists($linkname)) { |
| 464 | | $ret_id = wp_insert_link(array( |
| 465 | | 'link_id' => $linfo, |
| 466 | | 'link_url' => $href, |
| 467 | | 'link_name' => $linkname, |
| 468 | | 'link_category' => $category, |
| 469 | | 'link_description' => $description) |
| 470 | | ); |
| 471 | | } else { |
| 472 | | $ret_id = wp_insert_link(array( |
| 473 | | 'link_url' => $url, |
| 474 | | 'link_name' => $linkname, |
| 475 | | 'link_category' => $category, |
| 476 | | 'link_description' => $description) |
| 477 | | ); |
| 478 | | } |
| 479 | | $dclinks2wplinks[$link_id] = $ret_id; |
| | 463 | if ( ($linfo = link_exists($linkname)) == NULL ) { |
| | 464 | $ret_id = wp_insert_link(array( |
| | 465 | 'link_url' => $link_href, |
| | 466 | 'link_name' => $link_title, |
| | 467 | 'link_description' => $link_desc |
| | 468 | )); |
| | 469 | } else { |
| | 470 | $ret_id = link_exists($linkname); |
| 480 | 471 | } |
| | 472 | $dclinks2wplinks[$link_id] = $ret_id; |
| 481 | 473 | } |
| 482 | 474 | add_option('dclinks2wplinks',$dclinks2wplinks); |
| 483 | 475 | echo '<p>'; |
| … |
… |
|
| 511 | 503 | |
| 512 | 504 | echo '<form action="admin.php?import=dotclear&step=3" method="post">'; |
| 513 | 505 | wp_nonce_field('import-dotclear'); |
| 514 | | printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', esc_attr__('Import Posts', 'dotclear-importer')); |
| | 506 | printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', esc_attr__('Import Posts and Comments', 'dotclear-importer')); |
| 515 | 507 | echo '</form>'; |
| 516 | 508 | } |
| 517 | 509 | |
| | 510 | function import_posts_and_comments() { |
| | 511 | $posts = $this->get_dc_posts(); |
| | 512 | $comments = $this->get_dc_comments(); |
| | 513 | |
| | 514 | $link_between_posts_and_comments = $this->posts2wp($posts); |
| | 515 | $this->comments2wp($comments, $link_between_posts_and_comments); |
| | 516 | |
| | 517 | echo '<form action="admin.php?import=dotclear&step=5" method="post">'; |
| | 518 | wp_nonce_field('import-dotclear'); |
| | 519 | printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', esc_attr__('Import Links', 'dotclear-importer')); |
| | 520 | echo '</form>'; |
| | 521 | } |
| | 522 | /* |
| 518 | 523 | function import_posts() { |
| 519 | 524 | // Post Import |
| 520 | 525 | $posts = $this->get_dc_posts(); |
| … |
… |
|
| 538 | 543 | printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', esc_attr__('Import Links', 'dotclear-importer')); |
| 539 | 544 | echo '</form>'; |
| 540 | 545 | } |
| | 546 | */ |
| 541 | 547 | |
| 542 | 548 | function import_links() |
| 543 | 549 | { |
| … |
… |
|
| 656 | 662 | $this->import_users(); |
| 657 | 663 | break; |
| 658 | 664 | case 3 : |
| | 665 | $result = $this->import_posts_and_comments(); |
| | 666 | if ( is_wp_error( $result ) ) |
| | 667 | echo $result->get_error_message(); |
| | 668 | // goto directly to 5 |
| | 669 | break; |
| | 670 | /* |
| | 671 | // ------ previous code ------ |
| | 672 | case 3 : |
| 659 | 673 | $result = $this->import_posts(); |
| 660 | 674 | if ( is_wp_error( $result ) ) |
| 661 | 675 | echo $result->get_error_message(); |
| … |
… |
|
| 663 | 677 | case 4 : |
| 664 | 678 | $this->import_comments(); |
| 665 | 679 | break; |
| | 680 | */ |
| 666 | 681 | case 5 : |
| 667 | 682 | $this->import_links(); |
| 668 | 683 | break; |