Changes in trunk/wp-admin/import/textpattern.php [3424:4349]
- File:
-
- 1 edited
-
trunk/wp-admin/import/textpattern.php (modified) (43 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/textpattern.php
r3424 r4349 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 53 function greet() 54 {52 53 function greet() { 54 echo '<div class="narrow">'; 55 55 echo '<p>'.__('Howdy! This importer allows you to extract posts from any Textpattern 4.0.2+ into your blog. This has not been tested on previous versions of Textpattern. Mileage may vary.').'</p>'; 56 56 echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>'; 57 57 echo '<form action="admin.php?import=textpattern&step=1" method="post">'; 58 58 $this->db_form(); 59 echo '< input type="submit" name="submit" value="'.__('Import Categories').'" />';59 echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' »" /></p>'; 60 60 echo '</form>'; 61 echo '</div>'; 61 62 } 62 63 … … 68 69 set_magic_quotes_runtime(0); 69 70 $prefix = get_option('tpre'); 70 71 71 72 // Get Categories 72 73 return $txpdb->get_results('SELECT … … 78 79 ARRAY_A); 79 80 } 80 81 81 82 function get_txp_users() 82 83 { … … 86 87 set_magic_quotes_runtime(0); 87 88 $prefix = get_option('tpre'); 88 89 89 90 // Get Users 90 91 91 92 return $txpdb->get_results('SELECT 92 93 user_id, … … 97 98 FROM '.$prefix.'txp_users', ARRAY_A); 98 99 } 99 100 100 101 function get_txp_posts() 101 102 { … … 104 105 set_magic_quotes_runtime(0); 105 106 $prefix = get_option('tpre'); 106 107 107 108 // Get Posts 108 109 return $txpdb->get_results('SELECT … … 123 124 ', ARRAY_A); 124 125 } 125 126 126 127 function get_txp_comments() 127 128 { … … 131 132 set_magic_quotes_runtime(0); 132 133 $prefix = get_option('tpre'); 133 134 134 135 // Get Comments 135 136 return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A); 136 137 } 137 138 138 139 function get_txp_links() 139 140 { … … 142 143 set_magic_quotes_runtime(0); 143 144 $prefix = get_option('tpre'); 144 145 145 146 return $txpdb->get_results('SELECT 146 147 id, … … 153 154 ARRAY_A); 154 155 } 155 156 156 157 function cat2wp($categories='') 157 158 { … … 168 169 $count++; 169 170 extract($category); 170 171 171 172 172 173 // Make Nice Variables 173 174 $name = $wpdb->escape($name); 174 175 $title = $wpdb->escape($title); 175 176 176 177 if($cinfo = category_exists($name)) 177 178 { … … 184 185 $txpcat2wpcat[$id] = $ret_id; 185 186 } 186 187 187 188 // Store category translation for future use 188 189 add_option('txpcat2wpcat',$txpcat2wpcat); … … 193 194 return false; 194 195 } 195 196 196 197 function users2wp($users='') 197 198 { … … 200 201 $count = 0; 201 202 $txpid2wpid = array(); 202 203 203 204 // Midnight Mojo 204 205 if(is_array($users)) … … 209 210 $count++; 210 211 extract($user); 211 212 212 213 // Make Nice Variables 213 214 $name = $wpdb->escape($name); 214 215 $RealName = $wpdb->escape($RealName); 215 216 216 217 if($uinfo = get_userdatabylogin($name)) 217 218 { 218 219 219 220 $ret_id = wp_insert_user(array( 220 221 'ID' => $uinfo->ID, … … 237 238 } 238 239 $txpid2wpid[$user_id] = $ret_id; 239 240 240 241 // Set Textpattern-to-WordPress permissions translation 241 242 $transperms = array(1 => '10', 2 => '9', 3 => '5', 4 => '4', 5 => '3', 6 => '2', 7 => '0'); 242 243 243 244 // Update Usermeta Data 244 245 $user = new WP_User($ret_id); … … 250 251 if('2' == $transperms[$privs]) { $user->set_role('contributor'); } 251 252 if('0' == $transperms[$privs]) { $user->set_role('subscriber'); } 252 253 253 254 update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] ); 254 255 update_usermeta( $ret_id, 'rich_editing', 'false'); 255 256 }// End foreach($users as $user) 256 257 257 258 // Store id translation array for future use 258 259 add_option('txpid2wpid',$txpid2wpid); 259 260 260 261 261 262 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>'; 262 263 return true; 263 264 }// End if(is_array($users) 264 265 265 266 echo __('No Users to Import!'); 266 267 return false; 267 268 268 269 }// End function user2wp() 269 270 270 271 function posts2wp($posts='') 271 272 { … … 284 285 $count++; 285 286 extract($post); 286 287 287 288 // Set Textpattern-to-WordPress status translation 288 289 $stattrans = array(1 => 'draft', 2 => 'private', 3 => 'draft', 4 => 'publish', 5 => 'publish'); 289 290 290 291 //Can we do this more efficiently? 291 292 $uinfo = ( get_userdatabylogin( $AuthorID ) ) ? get_userdatabylogin( $AuthorID ) : 1; … … 296 297 $Excerpt = $wpdb->escape($Excerpt); 297 298 $post_status = $stattrans[$Status]; 298 299 299 300 // Import Post data into WordPress 300 301 301 302 if($pinfo = post_exists($Title,$Body)) 302 303 { … … 333 334 } 334 335 $txpposts2wpposts[$ID] = $ret_id; 335 336 336 337 // Make Post-to-Category associations 337 338 $cats = array(); … … 339 340 if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; } 340 341 341 if(!empty($cats)) { wp_set_post_cat s('',$ret_id, $cats); }342 if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); } 342 343 } 343 344 } 344 345 // Store ID translation for later use 345 346 add_option('txpposts2wpposts',$txpposts2wpposts); 346 347 347 348 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>'; 348 return true; 349 } 350 349 return true; 350 } 351 351 352 function comments2wp($comments='') 352 353 { … … 356 357 $txpcm2wpcm = array(); 357 358 $postarr = get_option('txpposts2wpposts'); 358 359 359 360 // Magic Mojo 360 361 if(is_array($comments)) … … 365 366 $count++; 366 367 extract($comment); 367 368 368 369 // WordPressify Data 369 370 $comment_ID = ltrim($discussid, '0'); … … 374 375 $web = $wpdb->escape($web); 375 376 $message = $wpdb->escape($message); 376 377 377 378 if($cinfo = comment_exists($name, $posted)) 378 379 { … … 406 407 } 407 408 // Store Comment ID translation for future use 408 add_option('txpcm2wpcm', $txpcm2wpcm); 409 409 add_option('txpcm2wpcm', $txpcm2wpcm); 410 410 411 // Associate newly formed categories with posts 411 412 get_comment_count($ret_id); 412 413 413 414 414 415 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>'; 415 416 return true; … … 418 419 return false; 419 420 } 420 421 421 422 function links2wp($links='') 422 423 { … … 424 425 global $wpdb; 425 426 $count = 0; 426 427 427 428 // Deal with the links 428 429 if(is_array($links)) … … 433 434 $count++; 434 435 extract($link); 435 436 436 437 // Make nice vars 437 438 $category = $wpdb->escape($category); 438 439 $linkname = $wpdb->escape($linkname); 439 440 $description = $wpdb->escape($description); 440 441 441 442 if($linfo = link_exists($linkname)) 442 443 { … … 471 472 return false; 472 473 } 473 474 474 475 function import_categories() 475 { 476 // Category Import 476 { 477 // Category Import 477 478 $cats = $this->get_txp_cats(); 478 479 $this->cat2wp($cats); 479 480 add_option('txp_cats', $cats); 480 481 482 481 482 483 483 484 echo '<form action="admin.php?import=textpattern&step=2" method="post">'; 484 485 printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); … … 486 487 487 488 } 488 489 489 490 function import_users() 490 491 { … … 492 493 $users = $this->get_txp_users(); 493 494 $this->users2wp($users); 494 495 495 496 echo '<form action="admin.php?import=textpattern&step=3" method="post">'; 496 497 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); 497 498 echo '</form>'; 498 499 } 499 500 500 501 function import_posts() 501 502 { … … 503 504 $posts = $this->get_txp_posts(); 504 505 $this->posts2wp($posts); 505 506 506 507 echo '<form action="admin.php?import=textpattern&step=4" method="post">'; 507 508 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); 508 509 echo '</form>'; 509 510 } 510 511 511 512 function import_comments() 512 513 { … … 514 515 $comments = $this->get_txp_comments(); 515 516 $this->comments2wp($comments); 516 517 517 518 echo '<form action="admin.php?import=textpattern&step=5" method="post">'; 518 519 printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); 519 520 echo '</form>'; 520 521 } 521 522 522 523 function import_links() 523 524 { … … 526 527 $this->links2wp($links); 527 528 add_option('txp_links', $links); 528 529 529 530 echo '<form action="admin.php?import=textpattern&step=6" method="post">'; 530 531 printf('<input type="submit" name="submit" value="%s" />', __('Finish')); 531 532 echo '</form>'; 532 533 } 533 534 534 535 function cleanup_txpimport() 535 536 { … … 547 548 $this->tips(); 548 549 } 549 550 550 551 function tips() 551 552 { … … 556 557 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>'; 557 558 echo '<h3>'.__('Textile').'</h3>'; 558 echo '<p>'.__('Also, since you\'re coming from Textpattern, 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>';559 echo '<p>'.__('Also, since you\'re coming from Textpattern, 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/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You\'ll want it.').'</p>'; 559 560 echo '<h3>'.__('WordPress Resources').'</h3>'; 560 561 echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>'; 561 562 echo '<ul>'; 562 563 echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>'; 563 echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums ').'</li>';564 echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>'; 564 565 echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>'; 565 566 echo '</ul>'; 566 567 echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>'; 567 568 } 568 569 569 570 function db_form() 570 571 { 571 echo '< ul>';572 printf('< li><label for="dbuser">%s</label> <input type="text" name="dbuser" /></li>', __('Textpattern Database User:'));573 printf('< li><label for="dbpass">%s</label> <input type="password" name="dbpass" /></li>', __('Textpattern Database Password:'));574 printf('< li><label for="dbname">%s</label> <input type="text" name="dbname" /></li>', __('Textpattern Database Name:'));575 printf('< li><label for="dbhost">%s</label> <input type="text" name="dbhost" value="localhost" /></li>', __('Textpattern Database Host:'));576 printf('< li><label for="dbprefix">%s</label> <input type="text" name="dbprefix" /></li>', __('Textpattern Table prefix (if any):'));577 echo '</ ul>';578 } 579 572 echo '<table class="editform">'; 573 printf('<tr><th scope="row"><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('Textpattern Database User:')); 574 printf('<tr><th scope="row"><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('Textpattern Database Password:')); 575 printf('<tr><th scope="row"><label for="dbname">%s</label></th><td><input type="text" id="dbname" name="dbname" /></td></tr>', __('Textpattern Database Name:')); 576 printf('<tr><th scope="row"><label for="dbhost">%s</label></th><td><input type="text" id="dbhost" name="dbhost" value="localhost" /></td></tr>', __('Textpattern Database Host:')); 577 printf('<tr><th scope="row"><label for="dbprefix">%s</label></th><td><input type="text" name="dbprefix" id="dbprefix" /></td></tr>', __('Textpattern Table prefix (if any):')); 578 echo '</table>'; 579 } 580 580 581 function dispatch() 581 582 { … … 586 587 $step = (int) $_GET['step']; 587 588 $this->header(); 588 589 589 590 if ( $step > 0 ) 590 591 { … … 592 593 { 593 594 if(get_option('txpuser')) 594 delete_option('txpuser'); 595 delete_option('txpuser'); 595 596 add_option('txpuser',$_POST['dbuser']); 596 597 } … … 598 599 { 599 600 if(get_option('txppass')) 600 delete_option('txppass'); 601 delete_option('txppass'); 601 602 add_option('txppass',$_POST['dbpass']); 602 603 } 603 604 604 605 if($_POST['dbname']) 605 606 { 606 607 if(get_option('txpname')) 607 delete_option('txpname'); 608 delete_option('txpname'); 608 609 add_option('txpname',$_POST['dbname']); 609 610 } … … 619 620 delete_option('tpre'); 620 621 add_option('tpre',$_POST['dbprefix']); 621 } 622 } 622 623 623 624 … … 649 650 break; 650 651 } 651 652 652 653 $this->footer(); 653 654 } … … 655 656 function Textpattern_Import() 656 657 { 657 // Nothing. 658 // Nothing. 658 659 } 659 660 } 660 661 661 662 $txp_import = new Textpattern_Import(); 662 register_importer('textpattern', 'Textpattern', __('Import posts from a Textpattern Blog'), array ($txp_import, 'dispatch'));663 register_importer('textpattern', __('Textpattern'), __('Import posts from a Textpattern Blog'), array ($txp_import, 'dispatch')); 663 664 ?>
Note: See TracChangeset
for help on using the changeset viewer.