Changeset 2832
- Timestamp:
- 07/23/08 02:12:23 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/release-41/plugins/WXRImporter/lib/WXRImporter/WXRHandler.pm
r2731 r2832 37 37 my $self = shift; 38 38 my $data = shift; 39 my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 39 40 40 41 my $name = $data->{LocalName}; … … 56 57 57 58 if ($self->{start}) { 58 die MT->translate("File is not in WXR format.")59 die $plugin->translate("File is not in WXR format.") 59 60 unless (('rss' eq $name) && ('2.0' eq $attrs->{'{}version'}->{Value})); ## FIXME: This is checking RSS2. 60 61 $self->{start} = 0; … … 204 205 my $self = shift; 205 206 my $data = shift; 207 my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 206 208 207 209 my $cb = $self->{callback}; … … 253 255 $cat->author_id($self->{parent}->id); 254 256 } 255 $cb->( MT->translate("Creating new category ('[_1]')...", $cat->label));257 $cb->($plugin->translate("Creating new category ('[_1]')...", $cat->label)); 256 258 if ($cat->save) { 257 $cb->( MT->translate("ok") . "\n");259 $cb->($plugin->translate("ok") . "\n"); 258 260 } else { 259 $cb->( MT->translate("failed") . "\n");260 return die MT->translate(261 $cb->($plugin->translate("failed") . "\n"); 262 return die $plugin->translate( 261 263 "Saving category failed: [_1]", $cat->errstr); 262 264 } … … 267 269 my $self = shift; 268 270 my $data = shift; 271 my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 269 272 270 273 my $cb = $self->{callback}; … … 290 293 return if ( MT::Tag->load( { name => $name } ) ); 291 294 $tag->name($name); 292 $cb->( MT->translate( "Creating new tag ('[_1]')...", $tag->name ) );295 $cb->( $plugin->translate( "Creating new tag ('[_1]')...", $tag->name ) ); 293 296 if ( $tag->save ) { 294 $cb->( MT->translate("ok") . "\n" );297 $cb->( $plugin->translate("ok") . "\n" ); 295 298 } 296 299 else { 297 $cb->( MT->translate("failed") . "\n" );298 return die MT->translate( "Saving tag failed: [_1]", $tag->errstr );300 $cb->( $plugin->translate("failed") . "\n" ); 301 return die $plugin->translate( "Saving tag failed: [_1]", $tag->errstr ); 299 302 } 300 303 } … … 354 357 my $self = shift; 355 358 my ($hashes) = @_; 359 my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 356 360 357 361 my $blog = $self->{blog}; … … 445 449 )) 446 450 { 447 $cb->( MT->translate("Duplicate asset ('[_1]') found. Skipping.", $asset_values->{label}));451 $cb->($plugin->translate("Duplicate asset ('[_1]') found. Skipping.", $asset_values->{label})); 448 452 $cb->("\n"); 449 453 return 1; … … 466 470 $asset->image_height($h); 467 471 } 468 $cb->( MT->translate("Saving asset ('[_1]')...", $asset->label));472 $cb->($plugin->translate("Saving asset ('[_1]')...", $asset->label)); 469 473 $asset->add_tags(@tags) if 0 < scalar(@tags); 470 $cb->( MT->translate(" and asset will be tagged ('[_1]')...", join(',', @tags)));474 $cb->($plugin->translate(" and asset will be tagged ('[_1]')...", join(',', @tags))); 471 475 if ($asset->save) { 472 $cb->( MT->translate("ok (ID [_1])", $asset->id) . "\n");476 $cb->($plugin->translate("ok (ID [_1])", $asset->id) . "\n"); 473 477 if ( exists($self->{'wp_download'}) && $self->{'wp_download'} ) { 474 478 _get_item_via_http($asset->id, $old_url); 475 479 } 476 480 } else { 477 $cb->( MT->translate("failed") . "\n");478 die MT->translate(481 $cb->($plugin->translate("failed") . "\n"); 482 die $plugin->translate( 479 483 "Saving entry failed: [_1]", $asset->errstr); 480 484 } … … 484 488 my $self = shift; 485 489 my ($class_type, $hashes) = @_; 490 my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 486 491 487 492 my $blog = $self->{blog}; … … 643 648 )) 644 649 { 645 $cb->( MT->translate("Duplicate entry ('[_1]') found. Skipping.", $post->title));650 $cb->($plugin->translate("Duplicate entry ('[_1]') found. Skipping.", $post->title)); 646 651 $cb->("\n"); 647 652 return 1; … … 655 660 # Now save the entry/page. 656 661 if ('entry' eq $class_type) { 657 $cb->( MT->translate("Saving entry ('[_1]')...", $post->title));662 $cb->($plugin->translate("Saving entry ('[_1]')...", $post->title)); 658 663 } elsif ('page' eq $class_type) { 659 $cb->( MT->translate("Saving page ('[_1]')...", $post->title));664 $cb->($plugin->translate("Saving page ('[_1]')...", $post->title)); 660 665 } 661 666 if ($post->save) { 662 $cb->( MT->translate("ok (ID [_1])", $post->id) . "\n");667 $cb->($plugin->translate("ok (ID [_1])", $post->id) . "\n"); 663 668 } else { 664 $cb->( MT->translate("failed") . "\n");665 die MT->translate(669 $cb->($plugin->translate("failed") . "\n"); 670 die $plugin->translate( 666 671 "Save failed: [_1]", $post->errstr); 667 672 } … … 676 681 $place->category_id($primary_cat_id); 677 682 $place->save 678 or die MT->translate(683 or die $plugin->translate( 679 684 "Saving placement failed: [_1]", $place->errstr); 680 685 delete $cat_ids{$primary_cat_id}; … … 688 693 $place->category_id($cat_id); 689 694 $place->save 690 or die MT->translate(695 or die $plugin->translate( 691 696 "Saving placement failed: [_1]", $place->errstr); 692 697 } … … 695 700 for my $comment (@{$feedbacks->{comments}}) { 696 701 $comment->entry_id($post->id); 697 $cb->( MT->translate("Creating new comment (from '[_1]')...", $comment->author));702 $cb->($plugin->translate("Creating new comment (from '[_1]')...", $comment->author)); 698 703 if ($comment->save) { 699 $cb->( MT->translate("ok (ID [_1])", $comment->id) . "\n");704 $cb->($plugin->translate("ok (ID [_1])", $comment->id) . "\n"); 700 705 } else { 701 $cb->( MT->translate("failed") . "\n");702 die MT->translate(706 $cb->($plugin->translate("failed") . "\n"); 707 die $plugin->translate( 703 708 "Saving comment failed: [_1]", $comment->errstr); 704 709 } … … 720 725 $tb->save; 721 726 unless ($tb) { 722 die MT->translate("Entry has no MT::Trackback object!");727 die $plugin->translate("Entry has no MT::Trackback object!"); 723 728 } 724 729 $post->trackback($tb); 725 730 for my $ping (@{$feedbacks->{trackbacks}}) { 726 731 $ping->tb_id($tb->id); 727 $cb->( MT->translate("Creating new ping ('[_1]')...", $ping->title));732 $cb->($plugin->translate("Creating new ping ('[_1]')...", $ping->title)); 728 733 if ($ping->save) { 729 $cb->( MT->translate("ok (ID [_1])", $ping->id) . "\n");734 $cb->($plugin->translate("ok (ID [_1])", $ping->id) . "\n"); 730 735 } else { 731 $cb->( MT->translate("failed") . "\n");732 die MT->translate(736 $cb->($plugin->translate("failed") . "\n"); 737 die $plugin->translate( 733 738 "Saving ping failed: [_1]", $ping->errstr); 734 739 } … … 741 746 my $self = shift; 742 747 my ($cb, $value) = @_; 748 my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 743 749 744 750 my $author = $self->{author}; … … 759 765 $author->password('(none)'); 760 766 } 761 $cb->( MT->translate("Creating new user ('[_1]')...", $value));767 $cb->($plugin->translate("Creating new user ('[_1]')...", $value)); 762 768 if ($author->save) { 763 $cb->( MT->translate("ok") . "\n");769 $cb->($plugin->translate("ok") . "\n"); 764 770 } else { 765 $cb->( MT->translate("failed") . "\n");766 die MT->translate(771 $cb->($plugin->translate("failed") . "\n"); 772 die $plugin->translate( 767 773 "Saving user failed: [_1]", $author->errstr); 768 774 } 769 $cb->( MT->translate("Assigning permissions for new user..."));775 $cb->($plugin->translate("Assigning permissions for new user...")); 770 776 require MT::Role; 771 777 require MT::Association; … … 774 780 my $assoc; 775 781 if ($assoc = MT::Association->link($author => $role => $self->{blog})) { 776 $cb->( MT->translate("ok") . "\n");782 $cb->($plugin->translate("ok") . "\n"); 777 783 } else { 778 $cb->( MT->translate("failed") . "\n");779 die MT->translate(784 $cb->($plugin->translate("failed") . "\n"); 785 die $plugin->translate( 780 786 "Saving permission failed: [_1]", $assoc->errstr); 781 787 }
