Changeset 12752 for trunk/wp-admin/import/dotclear.php
- Timestamp:
- 01/18/2010 08:34:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/dotclear.php
r12513 r12752 13 13 **/ 14 14 15 if(!function_exists('get_comment_count')) 16 { 15 if (!function_exists('get_comment_count')) { 17 16 /** 18 17 * Get the comment count for posts. … … 31 30 } 32 31 33 if(!function_exists('link_exists')) 34 { 32 if (!function_exists('link_exists')) { 35 33 /** 36 34 * Check whether link already exists. … … 181 179 $dccat2wpcat = array(); 182 180 // Do the Magic 183 if(is_array($categories)) 184 { 181 if (is_array($categories)) { 185 182 echo '<p>'.__('Importing Categories...').'<br /><br /></p>'; 186 foreach ($categories as $category) 187 { 183 foreach ($categories as $category) { 188 184 $count++; 189 185 extract($category); … … 194 190 $desc = $wpdb->escape(csc ($cat_desc)); 195 191 196 if($cinfo = category_exists($name)) 197 { 192 if ($cinfo = category_exists($name)) { 198 193 $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc)); 199 } 200 else 201 { 194 } else { 202 195 $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc)); 203 196 } … … 214 207 } 215 208 216 function users2wp($users='') 217 { 209 function users2wp($users='') { 218 210 // General Housekeeping 219 211 global $wpdb; … … 222 214 223 215 // Midnight Mojo 224 if(is_array($users)) 225 { 216 if (is_array($users)) { 226 217 echo '<p>'.__('Importing Users...').'<br /><br /></p>'; 227 foreach($users as $user) 228 { 218 foreach ($users as $user) { 229 219 $count++; 230 220 extract($user); … … 234 224 $RealName = $wpdb->escape(csc ($user_pseudo)); 235 225 236 if($uinfo = get_userdatabylogin($name)) 237 { 226 if ($uinfo = get_userdatabylogin($name)) { 238 227 239 228 $ret_id = wp_insert_user(array( … … 245 234 'display_name' => $Realname) 246 235 ); 247 } 248 else 249 { 236 } else { 250 237 $ret_id = wp_insert_user(array( 251 238 'user_login' => $user_id, … … 263 250 $user = new WP_User($ret_id); 264 251 $wp_perms = $user_level + 1; 265 if (10 == $wp_perms) { $user->set_role('administrator'); }266 else if (9 == $wp_perms) { $user->set_role('editor'); }267 else if (5 <= $wp_perms) { $user->set_role('editor'); }268 else if (4 <= $wp_perms) { $user->set_role('author'); }269 else if (3 <= $wp_perms) { $user->set_role('contributor'); }270 else if (2 <= $wp_perms) { $user->set_role('contributor'); }252 if (10 == $wp_perms) { $user->set_role('administrator'); } 253 else if (9 == $wp_perms) { $user->set_role('editor'); } 254 else if (5 <= $wp_perms) { $user->set_role('editor'); } 255 else if (4 <= $wp_perms) { $user->set_role('author'); } 256 else if (3 <= $wp_perms) { $user->set_role('contributor'); } 257 else if (2 <= $wp_perms) { $user->set_role('contributor'); } 271 258 else { $user->set_role('subscriber'); } 272 259 … … 290 277 }// End function user2wp() 291 278 292 function posts2wp($posts='') 293 { 279 function posts2wp($posts='') { 294 280 // General Housekeeping 295 281 global $wpdb; … … 299 285 300 286 // Do the Magic 301 if(is_array($posts)) 302 { 287 if (is_array($posts)) { 303 288 echo '<p>'.__('Importing Posts...').'<br /><br /></p>'; 304 289 foreach($posts as $post) … … 328 313 // Import Post data into WordPress 329 314 330 if($pinfo = post_exists($Title,$post_content)) 331 { 315 if ($pinfo = post_exists($Title,$post_content)) { 332 316 $ret_id = wp_insert_post(array( 333 317 'ID' => $pinfo, … … 348 332 if ( is_wp_error( $ret_id ) ) 349 333 return $ret_id; 350 } 351 else 352 { 334 } else { 353 335 $ret_id = wp_insert_post(array( 354 336 'post_author' => $authorid, … … 376 358 $category1 = $category1->term_id; 377 359 378 if ($cat1 = $category1) { $cats[1] = $cat1; }379 380 if (!empty($cats)) { wp_set_post_categories($ret_id, $cats); }360 if ($cat1 = $category1) { $cats[1] = $cat1; } 361 362 if (!empty($cats)) { wp_set_post_categories($ret_id, $cats); } 381 363 } 382 364 } … … 388 370 } 389 371 390 function comments2wp($comments='') 391 { 372 function comments2wp($comments='') { 392 373 // General Housekeeping 393 374 global $wpdb; … … 397 378 398 379 // Magic Mojo 399 if(is_array($comments)) 400 { 380 if (is_array($comments)) { 401 381 echo '<p>'.__('Importing Comments...').'<br /><br /></p>'; 402 foreach($comments as $comment) 403 { 382 foreach ($comments as $comment) { 404 383 $count++; 405 384 extract($comment); … … 450 429 } 451 430 452 function links2wp($links='') 453 { 431 function links2wp($links='') { 454 432 // General Housekeeping 455 433 global $wpdb; … … 457 435 458 436 // Deal with the links 459 if(is_array($links)) 460 { 437 if (is_array($links)) { 461 438 echo '<p>'.__('Importing Links...').'<br /><br /></p>'; 462 foreach($links as $link) 463 { 439 foreach ($links as $link) { 464 440 $count++; 465 441 extract($link); … … 476 452 $description = $wpdb->escape(csc ($title)); 477 453 478 if ($linfo = link_exists($linkname)) {454 if ($linfo = link_exists($linkname)) { 479 455 $ret_id = wp_insert_link(array( 480 456 'link_id' => $linfo, … … 505 481 } 506 482 507 function import_categories() 508 { 483 function import_categories() { 509 484 // Category Import 510 485 $cats = $this->get_dc_cats(); … … 521 496 } 522 497 523 function import_users() 524 { 498 function import_users() { 525 499 // User Import 526 500 $users = $this->get_dc_users(); … … 533 507 } 534 508 535 function import_posts() 536 { 509 function import_posts() { 537 510 // Post Import 538 511 $posts = $this->get_dc_posts(); … … 547 520 } 548 521 549 function import_comments() 550 { 522 function import_comments() { 551 523 // Comment Import 552 524 $comments = $this->get_dc_comments(); … … 572 544 } 573 545 574 function cleanup_dcimport() 575 { 546 function cleanup_dcimport() { 576 547 delete_option('dcdbprefix'); 577 548 delete_option('dc_cats'); … … 590 561 } 591 562 592 function tips() 593 { 563 function tips() { 594 564 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>'; 595 565 echo '<h3>'.__('Users').'</h3>'; … … 609 579 } 610 580 611 function db_form() 612 { 581 function db_form() { 613 582 echo '<table class="form-table">'; 614 583 printf('<tr><th><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('DotClear Database User:')); … … 621 590 } 622 591 623 function dispatch() 624 { 592 function dispatch() { 625 593 626 594 if (empty ($_GET['step'])) … … 630 598 $this->header(); 631 599 632 if ( $step > 0 ) 633 { 600 if ( $step > 0 ) { 634 601 check_admin_referer('import-dotclear'); 635 602 636 if($_POST['dbuser']) 637 { 603 if ($_POST['dbuser']) { 638 604 if(get_option('dcuser')) 639 605 delete_option('dcuser'); 640 606 add_option('dcuser', sanitize_user($_POST['dbuser'], true)); 641 607 } 642 if($_POST['dbpass']) 643 { 608 if ($_POST['dbpass']) { 644 609 if(get_option('dcpass')) 645 610 delete_option('dcpass'); … … 647 612 } 648 613 649 if($_POST['dbname']) 650 { 651 if(get_option('dcname')) 614 if ($_POST['dbname']) { 615 if (get_option('dcname')) 652 616 delete_option('dcname'); 653 617 add_option('dcname', sanitize_user($_POST['dbname'], true)); 654 618 } 655 if($_POST['dbhost']) 656 { 619 if ($_POST['dbhost']) { 657 620 if(get_option('dchost')) 658 621 delete_option('dchost'); 659 622 add_option('dchost', sanitize_user($_POST['dbhost'], true)); 660 623 } 661 if($_POST['dccharset']) 662 { 663 if(get_option('dccharset')) 624 if ($_POST['dccharset']) { 625 if (get_option('dccharset')) 664 626 delete_option('dccharset'); 665 627 add_option('dccharset', sanitize_user($_POST['dccharset'], true)); 666 628 } 667 if($_POST['dbprefix']) 668 { 669 if(get_option('dcdbprefix')) 629 if ($_POST['dbprefix']) { 630 if (get_option('dcdbprefix')) 670 631 delete_option('dcdbprefix'); 671 632 add_option('dcdbprefix', sanitize_user($_POST['dbprefix'], true)); … … 675 636 } 676 637 677 switch ($step) 678 { 638 switch ($step) { 679 639 default: 680 640 case 0 : … … 706 666 } 707 667 708 function Dotclear_Import() 709 { 668 function Dotclear_Import() { 710 669 // Nothing. 711 670 }
Note: See TracChangeset
for help on using the changeset viewer.