Ignore:
Timestamp:
2010-08-10T14:31:53+12:00 (14 years ago)
Author:
kjdon
Message:

code tidy up. rearranged how convertbinaryfile plugins set up their secondary plugins - now only set up the options for the one they are using. all subclass specific code moved out of convertbinaryfile.new into the appropriate plugin file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/RTFPlugin.pm

    r20790 r22597  
    3535}
    3636
     37# currently only converts to HTML
     38my $convert_to_list =
     39    [ { 'name' => "html",
     40    'desc' => "{ConvertBinaryFile.convert_to.html}" } ];
     41
    3742my $arguments =
    38     [ { 'name' => "process_exp",
     43    [ { 'name' => "convert_to",
     44    'desc' => "{ConvertBinaryFile.convert_to}",
     45    'type' => "enum",
     46    'reqd' => "yes",
     47    'list' => $convert_to_list,
     48    'deft' => "html" },
     49      { 'name' => "process_exp",
    3950    'desc' => "{BasePlugin.process_exp}",
    4051    'type' => "regexp",
     
    7182    $self->{'file_type'} = "RTF";
    7283
     84    # set convert_to_plugin and convert_to_ext
     85    $self->ConvertBinaryFile::set_standard_convert_settings();
     86    my $secondary_plugin_name = $self->{'convert_to_plugin'};
    7387    my $secondary_plugin_options = $self->{'secondary_plugin_options'};
    74     if (!defined $secondary_plugin_options->{'TextPlugin'}) {
    75     $secondary_plugin_options->{'TextPlugin'} = [];
     88
     89    if (!defined $secondary_plugin_options->{$secondary_plugin_name}) {
     90    $secondary_plugin_options->{$secondary_plugin_name} = [];
    7691    }
    77     if (!defined $secondary_plugin_options->{'HTMLPlugin'}) {
    78     $secondary_plugin_options->{'HTMLPlugin'} = [];
     92    my $specific_options = $secondary_plugin_options->{$secondary_plugin_name};
     93   
     94    push(@$specific_options, "-file_rename_method", "none");
     95    push(@$specific_options, "-extract_language") if $self->{'extract_language'};
     96    if ($secondary_plugin_name eq "TextPlugin") {
     97    push(@$specific_options, "-input_encoding", "utf8");
    7998    }
    80     my $text_options = $secondary_plugin_options->{'TextPlugin'};
    81     my $html_options = $secondary_plugin_options->{'HTMLPlugin'};
    82    
    83     #$self->{'input_encoding'} = "utf8";
    84     #$self->{'extract_language'} = 1;
    85     push(@$text_options, "-input_encoding", "utf8");
    86     push(@$text_options,"-extract_language") if $self->{'extract_language'};
    87     push(@$html_options, "-description_tags") if $self->{'description_tags'};
    88     push(@$html_options,"-extract_language") if $self->{'extract_language'};
    89 
    90     push(@$html_options, "-file_rename_method", "none");
    91     push(@$text_options, "-file_rename_method", "none");
    92 
    93     # tell the secondary plugins that they are processing tmp files
    94     push(@$html_options, "-processing_tmp_files");
     99    elsif ($secondary_plugin_name eq "HTMLPlugin") {
     100    push(@$specific_options, "-description_tags") if $self->{'description_tags'};
     101    push(@$specific_options, "-processing_tmp_files");
     102    }
    95103
    96104    $self = bless $self, $class;
Note: See TracChangeset for help on using the changeset viewer.