Changeset 3517 for trunk/wp-admin/import/textpattern.php
- Timestamp:
- 02/12/2006 07:53:23 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/textpattern.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 } … … 50 50 echo '</div>'; 51 51 } 52 52 53 53 function greet() 54 54 { … … 68 68 set_magic_quotes_runtime(0); 69 69 $prefix = get_option('tpre'); 70 70 71 71 // Get Categories 72 72 return $txpdb->get_results('SELECT … … 78 78 ARRAY_A); 79 79 } 80 80 81 81 function get_txp_users() 82 82 { … … 86 86 set_magic_quotes_runtime(0); 87 87 $prefix = get_option('tpre'); 88 88 89 89 // Get Users 90 90 91 91 return $txpdb->get_results('SELECT 92 92 user_id, … … 97 97 FROM '.$prefix.'txp_users', ARRAY_A); 98 98 } 99 99 100 100 function get_txp_posts() 101 101 { … … 104 104 set_magic_quotes_runtime(0); 105 105 $prefix = get_option('tpre'); 106 106 107 107 // Get Posts 108 108 return $txpdb->get_results('SELECT … … 123 123 ', ARRAY_A); 124 124 } 125 125 126 126 function get_txp_comments() 127 127 { … … 131 131 set_magic_quotes_runtime(0); 132 132 $prefix = get_option('tpre'); 133 133 134 134 // Get Comments 135 135 return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A); 136 136 } 137 137 138 138 function get_txp_links() 139 139 { … … 142 142 set_magic_quotes_runtime(0); 143 143 $prefix = get_option('tpre'); 144 144 145 145 return $txpdb->get_results('SELECT 146 146 id, … … 153 153 ARRAY_A); 154 154 } 155 155 156 156 function cat2wp($categories='') 157 157 { … … 168 168 $count++; 169 169 extract($category); 170 171 170 171 172 172 // Make Nice Variables 173 173 $name = $wpdb->escape($name); 174 174 $title = $wpdb->escape($title); 175 175 176 176 if($cinfo = category_exists($name)) 177 177 { … … 184 184 $txpcat2wpcat[$id] = $ret_id; 185 185 } 186 186 187 187 // Store category translation for future use 188 188 add_option('txpcat2wpcat',$txpcat2wpcat); … … 193 193 return false; 194 194 } 195 195 196 196 function users2wp($users='') 197 197 { … … 200 200 $count = 0; 201 201 $txpid2wpid = array(); 202 202 203 203 // Midnight Mojo 204 204 if(is_array($users)) … … 209 209 $count++; 210 210 extract($user); 211 211 212 212 // Make Nice Variables 213 213 $name = $wpdb->escape($name); 214 214 $RealName = $wpdb->escape($RealName); 215 215 216 216 if($uinfo = get_userdatabylogin($name)) 217 217 { 218 218 219 219 $ret_id = wp_insert_user(array( 220 220 'ID' => $uinfo->ID, … … 237 237 } 238 238 $txpid2wpid[$user_id] = $ret_id; 239 239 240 240 // Set Textpattern-to-WordPress permissions translation 241 241 $transperms = array(1 => '10', 2 => '9', 3 => '5', 4 => '4', 5 => '3', 6 => '2', 7 => '0'); 242 242 243 243 // Update Usermeta Data 244 244 $user = new WP_User($ret_id); … … 250 250 if('2' == $transperms[$privs]) { $user->set_role('contributor'); } 251 251 if('0' == $transperms[$privs]) { $user->set_role('subscriber'); } 252 252 253 253 update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] ); 254 254 update_usermeta( $ret_id, 'rich_editing', 'false'); 255 255 }// End foreach($users as $user) 256 256 257 257 // Store id translation array for future use 258 258 add_option('txpid2wpid',$txpid2wpid); 259 260 259 260 261 261 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>'; 262 262 return true; 263 263 }// End if(is_array($users) 264 264 265 265 echo __('No Users to Import!'); 266 266 return false; 267 267 268 268 }// End function user2wp() 269 269 270 270 function posts2wp($posts='') 271 271 { … … 284 284 $count++; 285 285 extract($post); 286 286 287 287 // Set Textpattern-to-WordPress status translation 288 288 $stattrans = array(1 => 'draft', 2 => 'private', 3 => 'draft', 4 => 'publish', 5 => 'publish'); 289 289 290 290 //Can we do this more efficiently? 291 291 $uinfo = ( get_userdatabylogin( $AuthorID ) ) ? get_userdatabylogin( $AuthorID ) : 1; … … 296 296 $Excerpt = $wpdb->escape($Excerpt); 297 297 $post_status = $stattrans[$Status]; 298 298 299 299 // Import Post data into WordPress 300 300 301 301 if($pinfo = post_exists($Title,$Body)) 302 302 { … … 333 333 } 334 334 $txpposts2wpposts[$ID] = $ret_id; 335 335 336 336 // Make Post-to-Category associations 337 337 $cats = array(); … … 344 344 // Store ID translation for later use 345 345 add_option('txpposts2wpposts',$txpposts2wpposts); 346 346 347 347 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>'; 348 return true; 349 } 350 348 return true; 349 } 350 351 351 function comments2wp($comments='') 352 352 { … … 356 356 $txpcm2wpcm = array(); 357 357 $postarr = get_option('txpposts2wpposts'); 358 358 359 359 // Magic Mojo 360 360 if(is_array($comments)) … … 365 365 $count++; 366 366 extract($comment); 367 367 368 368 // WordPressify Data 369 369 $comment_ID = ltrim($discussid, '0'); … … 374 374 $web = $wpdb->escape($web); 375 375 $message = $wpdb->escape($message); 376 376 377 377 if($cinfo = comment_exists($name, $posted)) 378 378 { … … 406 406 } 407 407 // Store Comment ID translation for future use 408 add_option('txpcm2wpcm', $txpcm2wpcm); 409 408 add_option('txpcm2wpcm', $txpcm2wpcm); 409 410 410 // Associate newly formed categories with posts 411 411 get_comment_count($ret_id); 412 413 412 413 414 414 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>'; 415 415 return true; … … 418 418 return false; 419 419 } 420 420 421 421 function links2wp($links='') 422 422 { … … 424 424 global $wpdb; 425 425 $count = 0; 426 426 427 427 // Deal with the links 428 428 if(is_array($links)) … … 433 433 $count++; 434 434 extract($link); 435 435 436 436 // Make nice vars 437 437 $category = $wpdb->escape($category); 438 438 $linkname = $wpdb->escape($linkname); 439 439 $description = $wpdb->escape($description); 440 440 441 441 if($linfo = link_exists($linkname)) 442 442 { … … 471 471 return false; 472 472 } 473 473 474 474 function import_categories() 475 { 476 // Category Import 475 { 476 // Category Import 477 477 $cats = $this->get_txp_cats(); 478 478 $this->cat2wp($cats); 479 479 add_option('txp_cats', $cats); 480 481 482 480 481 482 483 483 echo '<form action="admin.php?import=textpattern&step=2" method="post">'; 484 484 printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); … … 486 486 487 487 } 488 488 489 489 function import_users() 490 490 { … … 492 492 $users = $this->get_txp_users(); 493 493 $this->users2wp($users); 494 494 495 495 echo '<form action="admin.php?import=textpattern&step=3" method="post">'; 496 496 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); 497 497 echo '</form>'; 498 498 } 499 499 500 500 function import_posts() 501 501 { … … 503 503 $posts = $this->get_txp_posts(); 504 504 $this->posts2wp($posts); 505 505 506 506 echo '<form action="admin.php?import=textpattern&step=4" method="post">'; 507 507 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); 508 508 echo '</form>'; 509 509 } 510 510 511 511 function import_comments() 512 512 { … … 514 514 $comments = $this->get_txp_comments(); 515 515 $this->comments2wp($comments); 516 516 517 517 echo '<form action="admin.php?import=textpattern&step=5" method="post">'; 518 518 printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); 519 519 echo '</form>'; 520 520 } 521 521 522 522 function import_links() 523 523 { … … 526 526 $this->links2wp($links); 527 527 add_option('txp_links', $links); 528 528 529 529 echo '<form action="admin.php?import=textpattern&step=6" method="post">'; 530 530 printf('<input type="submit" name="submit" value="%s" />', __('Finish')); 531 531 echo '</form>'; 532 532 } 533 533 534 534 function cleanup_txpimport() 535 535 { … … 547 547 $this->tips(); 548 548 } 549 549 550 550 function tips() 551 551 { … … 566 566 echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>'; 567 567 } 568 568 569 569 function db_form() 570 570 { … … 577 577 echo '</ul>'; 578 578 } 579 579 580 580 function dispatch() 581 581 { … … 586 586 $step = (int) $_GET['step']; 587 587 $this->header(); 588 588 589 589 if ( $step > 0 ) 590 590 { … … 592 592 { 593 593 if(get_option('txpuser')) 594 delete_option('txpuser'); 594 delete_option('txpuser'); 595 595 add_option('txpuser',$_POST['dbuser']); 596 596 } … … 598 598 { 599 599 if(get_option('txppass')) 600 delete_option('txppass'); 600 delete_option('txppass'); 601 601 add_option('txppass',$_POST['dbpass']); 602 602 } 603 603 604 604 if($_POST['dbname']) 605 605 { 606 606 if(get_option('txpname')) 607 delete_option('txpname'); 607 delete_option('txpname'); 608 608 add_option('txpname',$_POST['dbname']); 609 609 } … … 619 619 delete_option('tpre'); 620 620 add_option('tpre',$_POST['dbprefix']); 621 } 621 } 622 622 623 623 … … 649 649 break; 650 650 } 651 651 652 652 $this->footer(); 653 653 } … … 655 655 function Textpattern_Import() 656 656 { 657 // Nothing. 657 // Nothing. 658 658 } 659 659 }
Note: See TracChangeset
for help on using the changeset viewer.