Ignore:
Timestamp:
2005-11-14T14:26:10+13:00 (18 years ago)
Author:
kjdon
Message:

changed convetr_to default to auto (was html), got rid of findType method - just use the result of parsing to work this out. changed blnWindowsScripting to windows_scripting, and strConvertTo to convert_to_type

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/ConvertToPlug.pm

    r10609 r10890  
    6161    'reqd' => "yes",
    6262    'list' => $convert_to_list,
    63     'deft' => "html" },
     63    'deft' => "auto" },
    6464      { 'name' => "title_sub",
    6565    'desc' => "{HTMLPlug.title_sub}",
     
    8888        'args'     => $arguments };
    8989
    90 sub findType
    91 {
    92     my ($inputargs) = @_;
    93     my $convert_to_type = "html";
    94     my $windows_scripting = "false";
    95     for(my $intCounter = 0; $intCounter < scalar(@{$inputargs}) ; $intCounter++)
    96     {
    97     if($inputargs->[$intCounter] eq "-convert_to")
    98     {
    99         if($inputargs->[$intCounter+1] eq "auto" || $inputargs->[$intCounter+1] =~ /pagedimg.*/i || $inputargs->[$intCounter+1] eq "text" || $inputargs->[$intCounter+1] eq "html")
    100         {
    101         $convert_to_type = $inputargs->[$intCounter+1];
    102         }
    103     }
    104     if ($inputargs->[$intCounter] eq "-windows_scripting")
    105     {
    106         $windows_scripting = "true";
    107     }
    108     }
    109     return ($convert_to_type,$windows_scripting);
    110 }
    11190
    11291sub load_secondary_plugins
     
    127106    # call its constructor with extra options that we've worked out!
    128107    my $arglist = $input_args->{$plugin_class};
    129     my $secondary_plugin = new $plugin_class([],$arglist, $hashArgOptLists);
     108#   my $secondary_plugin = new $plugin_class([],$arglist, $hashArgOptLists);
     109    # secondary plugins don';t need to know their calling plugin's options
     110    my $secondary_plugin = new $plugin_class([],$arglist);
    130111    $secondary_plugins->{$plugin_class} = $secondary_plugin;
    131112    }
     
    138119    push(@$pluginlist, $class);
    139120    my $classPluginName = (defined $pluginlist->[0]) ? $pluginlist->[0] : $class;
    140     my ($strConvertTo,$blnWindowsScripting) = findType($inputargs);
    141 
    142121    if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
    143122    if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
     
    145124    my $self = (defined $hashArgOptLists)? new BasPlug($pluginlist,$inputargs,$hashArgOptLists): new BasPlug($pluginlist,$inputargs);
    146125   
    147    
     126    my $convert_to_type = $self->{'convert_to'};
     127    if (!defined $convert_to_type || $convert_to_type eq "") {
     128    $convert_to_type = "auto";
     129    }
     130    my $windows_scripting = $self->{'windows_scripting'};
    148131    if ($classPluginName eq "PDFPlug") {
    149     if ($strConvertTo eq "text" &&
     132    if ($convert_to_type eq "text" &&
    150133        $ENV{'GSDLOS'} =~ /^windows$/i) {
    151134        print STDERR "Windows does not support pdf to text. PDFs will be converted to HTML instead\n";
    152         $strConvertTo = "html";
     135        $convert_to_type = "html";
    153136    }
    154137    } elsif ($classPluginName eq "WordPlug") {
    155     if ($blnWindowsScripting eq "true" && $ENV{'GSDLOS'} =~ /^windows$/i && $strConvertTo =~ /^(html|auto)$/) {
     138    if (defined $self->{'windows_scripting'} && $ENV{'GSDLOS'} =~ /^windows$/i && $convert_to_type =~ /^(html|auto)$/) {
    156139        # we use structured HTML, not normal html
    157         $strConvertTo = "structuredhtml";
     140        $convert_to_type = "structuredhtml";
    158141    }
    159142    } elsif ($classPluginName eq "PPTPlug") {
    160     if ($blnWindowsScripting eq "true" && $ENV{'GSDLOS'} =~ /^windows$/i && $strConvertTo eq "auto") {
     143    if (defined $self->{'windows_scripting'} && $ENV{'GSDLOS'} =~ /^windows$/i && $convert_to_type eq "auto") {
    161144        # we use paged img
    162         $strConvertTo = "pagedimg_jpg";
     145        $convert_to_type = "pagedimg_jpg";
    163146    }
    164147    } elsif ($classPluginName eq "PSPlug") {
    165     if ($strConvertTo eq "auto") {
     148    if ($convert_to_type eq "auto") {
    166149        # we use text
    167         $strConvertTo = "text";
     150        $convert_to_type = "text";
    168151    }
    169152    }
    170153   
    171     if ($strConvertTo eq "auto") {
     154    if ($convert_to_type eq "auto") {
    172155    # choose html for now - should choose a format based on doc type
    173     $strConvertTo = "html";
    174     }
    175    
    176     if ($strConvertTo eq "html") {
     156    $convert_to_type = "html";
     157    }
     158   
     159    if ($convert_to_type eq "html") {
    177160    $self->{'convert_to'} = "HTML";
    178161    $self->{'convert_to_ext'} = "html";
    179     } elsif ($strConvertTo eq "text") {
     162    } elsif ($convert_to_type eq "text") {
    180163    $self->{'convert_to'} = "TEXT";
    181164    $self->{'convert_to_ext'} = "txt";
    182     } elsif ($strConvertTo eq "structuredhtml") {
     165    } elsif ($convert_to_type eq "structuredhtml") {
    183166    $self->{'convert_to'} = "StructuredHTML";
    184167    $self->{'convert_to_ext'} = "html";
    185     } elsif ($strConvertTo =~ /^pagedimg/) {
     168    } elsif ($convert_to_type =~ /^pagedimg/) {
    186169    $self->{'convert_to'} = "PagedImg";
    187     my ($convert_to_ext) = $strConvertTo =~ /pagedimg\_(jpg|gif|png)/i;
     170    my ($convert_to_ext) = $convert_to_type =~ /pagedimg\_(jpg|gif|png)/i;
    188171    $convert_to_ext = 'jpg' unless defined $convert_to_ext;
    189172    $self->{'convert_to_ext'} = $convert_to_ext;
Note: See TracChangeset for help on using the changeset viewer.