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