Changeset 3517 for trunk/wp-admin/import/dotclear.php
- Timestamp:
- 02/12/2006 07:53:23 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/dotclear.php
r3424 r3517 8 8 { 9 9 global $wpdb; 10 10 11 11 $cat_id -= 0; // force numeric 12 12 $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"'); 13 13 14 14 return $name; 15 15 } … … 136 136 echo '</div>'; 137 137 } 138 138 139 139 function greet() 140 140 { … … 154 154 set_magic_quotes_runtime(0); 155 155 $prefix = get_option('tpre'); 156 156 157 157 // Get Categories 158 158 return $dcdb->get_results('SELECT * FROM dc_categorie', ARRAY_A); 159 159 } 160 160 161 161 function get_dc_users() 162 162 { … … 166 166 set_magic_quotes_runtime(0); 167 167 $prefix = get_option('tpre'); 168 168 169 169 // Get Users 170 170 171 171 return $dcdb->get_results('SELECT * FROM dc_user', ARRAY_A); 172 172 } 173 173 174 174 function get_dc_posts() 175 175 { … … 178 178 set_magic_quotes_runtime(0); 179 179 $prefix = get_option('tpre'); 180 180 181 181 // Get Posts 182 182 return $dcdb->get_results('SELECT dc_post.*, dc_categorie.cat_libelle_url AS post_cat_name … … 184 184 ON dc_post.cat_id = dc_categorie.cat_id', ARRAY_A); 185 185 } 186 186 187 187 function get_dc_comments() 188 188 { … … 192 192 set_magic_quotes_runtime(0); 193 193 $prefix = get_option('tpre'); 194 194 195 195 // Get Comments 196 196 return $dcdb->get_results('SELECT * FROM dc_comment', ARRAY_A); 197 197 } 198 198 199 199 function get_dc_links() 200 200 { … … 206 206 return $dcdb->get_results('SELECT * FROM dc_link ORDER BY position', ARRAY_A); 207 207 } 208 208 209 209 function cat2wp($categories='') 210 210 { … … 221 221 $count++; 222 222 extract($category); 223 223 224 224 // Make Nice Variables 225 225 $name = $wpdb->escape($cat_libelle_url); … … 237 237 $dccat2wpcat[$id] = $ret_id; 238 238 } 239 239 240 240 // Store category translation for future use 241 241 add_option('dccat2wpcat',$dccat2wpcat); … … 246 246 return false; 247 247 } 248 248 249 249 function users2wp($users='') 250 250 { … … 253 253 $count = 0; 254 254 $dcid2wpid = array(); 255 255 256 256 // Midnight Mojo 257 257 if(is_array($users)) … … 262 262 $count++; 263 263 extract($user); 264 264 265 265 // Make Nice Variables 266 266 $name = $wpdb->escape(csc ($name)); 267 267 $RealName = $wpdb->escape(csc ($user_pseudo)); 268 268 269 269 if($uinfo = get_userdatabylogin($name)) 270 270 { 271 271 272 272 $ret_id = wp_insert_user(array( 273 273 'ID' => $uinfo->ID, … … 290 290 } 291 291 $dcid2wpid[$user_id] = $ret_id; 292 292 293 293 // Set Dotclear-to-WordPress permissions translation 294 294 295 295 // Update Usermeta Data 296 296 $user = new WP_User($ret_id); … … 303 303 else if(2 <= $wp_perms) { $user->set_role('contributor'); } 304 304 else { $user->set_role('subscriber'); } 305 305 306 306 update_usermeta( $ret_id, 'wp_user_level', $wp_perms); 307 307 update_usermeta( $ret_id, 'rich_editing', 'false'); … … 309 309 update_usermeta( $ret_id, 'last_name', csc ($user_nom)); 310 310 }// End foreach($users as $user) 311 311 312 312 // Store id translation array for future use 313 313 add_option('dcid2wpid',$dcid2wpid); 314 315 314 315 316 316 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>'; 317 317 return true; 318 318 }// End if(is_array($users) 319 319 320 320 echo __('No Users to Import!'); 321 321 return false; 322 322 323 323 }// End function user2wp() 324 324 325 325 function posts2wp($posts='') 326 326 { … … 339 339 $count++; 340 340 extract($post); 341 341 342 342 // Set Dotclear-to-WordPress status translation 343 343 $stattrans = array(0 => 'draft', 1 => 'publish'); 344 344 $comment_status_map = array (0 => 'closed', 1 => 'open'); 345 345 346 346 //Can we do this more efficiently? 347 347 $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1; … … 357 357 $post_content = $wpdb->escape ($post_content); 358 358 $post_status = $stattrans[$post_pub]; 359 359 360 360 // Import Post data into WordPress 361 361 362 362 if($pinfo = post_exists($Title,$post_content)) 363 363 { … … 398 398 } 399 399 $dcposts2wpposts[$post_id] = $ret_id; 400 400 401 401 // Make Post-to-Category associations 402 402 $cats = array(); … … 408 408 // Store ID translation for later use 409 409 add_option('dcposts2wpposts',$dcposts2wpposts); 410 410 411 411 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>'; 412 return true; 413 } 414 412 return true; 413 } 414 415 415 function comments2wp($comments='') 416 416 { … … 420 420 $dccm2wpcm = array(); 421 421 $postarr = get_option('dcposts2wpposts'); 422 422 423 423 // Magic Mojo 424 424 if(is_array($comments)) … … 429 429 $count++; 430 430 extract($comment); 431 431 432 432 // WordPressify Data 433 433 $comment_ID = ltrim($comment_id, '0'); … … 438 438 $web = "http://".$wpdb->escape($comment_site); 439 439 $message = $wpdb->escape(textconv ($comment_content)); 440 440 441 441 if($cinfo = comment_exists($name, $comment_dt)) 442 442 { … … 473 473 } 474 474 // Store Comment ID translation for future use 475 add_option('dccm2wpcm', $dccm2wpcm); 476 475 add_option('dccm2wpcm', $dccm2wpcm); 476 477 477 // Associate newly formed categories with posts 478 478 get_comment_count($ret_id); 479 480 479 480 481 481 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>'; 482 482 return true; … … 485 485 return false; 486 486 } 487 487 488 488 function links2wp($links='') 489 489 { … … 491 491 global $wpdb; 492 492 $count = 0; 493 493 494 494 // Deal with the links 495 495 if(is_array($links)) … … 500 500 $count++; 501 501 extract($link); 502 502 503 503 if ($title != "") { 504 504 if ($cinfo = link_cat_exists (csc ($title))) { … … 512 512 $linkname = $wpdb->escape(csc ($label)); 513 513 $description = $wpdb->escape(csc ($title)); 514 514 515 515 if($linfo = link_exists($linkname)) { 516 516 $ret_id = wp_insert_link(array( … … 541 541 return false; 542 542 } 543 543 544 544 function import_categories() 545 { 546 // Category Import 545 { 546 // Category Import 547 547 $cats = $this->get_dc_cats(); 548 548 $this->cat2wp($cats); 549 549 add_option('dc_cats', $cats); 550 551 552 550 551 552 553 553 echo '<form action="admin.php?import=dotclear&step=2" method="post">'; 554 554 printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); … … 556 556 557 557 } 558 558 559 559 function import_users() 560 560 { … … 562 562 $users = $this->get_dc_users(); 563 563 $this->users2wp($users); 564 564 565 565 echo '<form action="admin.php?import=dotclear&step=3" method="post">'; 566 566 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); 567 567 echo '</form>'; 568 568 } 569 569 570 570 function import_posts() 571 571 { … … 573 573 $posts = $this->get_dc_posts(); 574 574 $this->posts2wp($posts); 575 575 576 576 echo '<form action="admin.php?import=dotclear&step=4" method="post">'; 577 577 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); 578 578 echo '</form>'; 579 579 } 580 580 581 581 function import_comments() 582 582 { … … 584 584 $comments = $this->get_dc_comments(); 585 585 $this->comments2wp($comments); 586 586 587 587 echo '<form action="admin.php?import=dotclear&step=5" method="post">'; 588 588 printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); 589 589 echo '</form>'; 590 590 } 591 591 592 592 function import_links() 593 593 { … … 596 596 $this->links2wp($links); 597 597 add_option('dc_links', $links); 598 598 599 599 echo '<form action="admin.php?import=dotclear&step=6" method="post">'; 600 600 printf('<input type="submit" name="submit" value="%s" />', __('Finish')); 601 601 echo '</form>'; 602 602 } 603 603 604 604 function cleanup_dcimport() 605 605 { … … 618 618 $this->tips(); 619 619 } 620 620 621 621 function tips() 622 622 { … … 637 637 echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>'; 638 638 } 639 639 640 640 function db_form() 641 641 { … … 649 649 echo '</ul>'; 650 650 } 651 651 652 652 function dispatch() 653 653 { … … 658 658 $step = (int) $_GET['step']; 659 659 $this->header(); 660 660 661 661 if ( $step > 0 ) 662 662 { … … 664 664 { 665 665 if(get_option('dcuser')) 666 delete_option('dcuser'); 666 delete_option('dcuser'); 667 667 add_option('dcuser',$_POST['dbuser']); 668 668 } … … 670 670 { 671 671 if(get_option('dcpass')) 672 delete_option('dcpass'); 672 delete_option('dcpass'); 673 673 add_option('dcpass',$_POST['dbpass']); 674 674 } 675 675 676 676 if($_POST['dbname']) 677 677 { 678 678 if(get_option('dcname')) 679 delete_option('dcname'); 679 delete_option('dcname'); 680 680 add_option('dcname',$_POST['dbname']); 681 681 } … … 691 691 delete_option('dccharset'); 692 692 add_option('dccharset',$_POST['dccharset']); 693 } 693 } 694 694 if($_POST['dbprefix']) 695 695 { … … 697 697 delete_option('tpre'); 698 698 add_option('tpre',$_POST['dbprefix']); 699 } 699 } 700 700 701 701 … … 727 727 break; 728 728 } 729 729 730 730 $this->footer(); 731 731 } … … 733 733 function Dotclear_Import() 734 734 { 735 // Nothing. 735 // Nothing. 736 736 } 737 737 }
Note: See TracChangeset
for help on using the changeset viewer.