Changeset 10453


Ignore:
Timestamp:
2005-08-10T12:57:34+12:00 (19 years ago)
Author:
kjdon
Message:

fixed up some mistakes from previous merging of davids new code and jeffreys new code

File:
1 edited

Legend:

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

    r10450 r10453  
    3939use PagedImgPlug;
    4040
    41 #use strict;
    42 #no strict 'refs'; # allow filehandles to be variables and viceversa
     41use strict;
     42no strict 'refs'; # allow filehandles to be variables and viceversa
    4343
    4444sub BEGIN {
     
    5252    'desc' => "{ConvertToPlug.convert_to.html}" },
    5353      { 'name' => "text",
    54     'desc' => "{ConvertToPlug.convert_to.text}" },
    55       { 'name' => "pagedimg_jpg",
    56     'desc' => "{ConvertToPlug.convert_to.pagedimg_jpg}"},
    57       { 'name' => "pagedimg_gif",
    58     'desc' => "{ConvertToPlug.convert_to.pagedimg_gif}"},
    59       { 'name' => "pagedimg_png",
    60     'desc' => "{ConvertToPlug.convert_to.pagedimg_png}"},
     54    'desc' => "{ConvertToPlug.convert_to.text}" }
    6155      ];
    6256
     
    9791{
    9892    my ($inputargs) = @_;
    99     my ($convert_to_type,$windows_scripting);
    100     $conver_to_type = "html";
    101     $windows_scripting = "false";
     93    my $convert_to_type = "html";
     94    my $windows_scripting = "false";
    10295    for(my $intCounter = 0; $intCounter < scalar(@{$inputargs}) ; $intCounter++)
    10396    {
     
    10598    {
    10699        if($inputargs->[$intCounter+1] eq "auto" || $inputargs->[$intCounter+1] =~ /pagedimg.*/i || $inputargs->[$intCounter+1] eq "text" || $inputargs->[$intCounter+1] eq "html")
    107         # if the setting is "auto" then refer to html for now
    108         #if($inputargs->[$intCounter+1] =~ /pagedimg.*/i || $inputargs->[$intCounter+1] eq "text" || $inputargs->[$intCounter+1] eq "html")
    109100        {
    110         $conver_to_type = $inputargs->[$intCounter+1];
     101        $convert_to_type = $inputargs->[$intCounter+1];
    111102        }
    112103    }
     
    116107    }
    117108    }
    118     return ($conver_to_type,$windows_scripting);
     109    return ($convert_to_type,$windows_scripting);
    119110}
    120111
     
    125116
    126117    my @convert_to_list = split(",",$self->{'convert_to'});
    127     $secondary_plugins = {};
     118    my $secondary_plugins = {};
    128119
    129120    foreach my $convert_to (@convert_to_list) {
     
    152143    if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
    153144
     145    my $self = (defined $hashArgOptLists)? new BasPlug($pluginlist,$inputargs,$hashArgOptLists): new BasPlug($pluginlist,$inputargs);
     146   
     147   
    154148    if ($classPluginName eq "PDFPlug" && $strConvertTo eq "text" &&
    155149    $ENV{'GSDLOS'} =~ /^windows$/i) {
    156150    print STDERR "Windows does not support pdf to text. PDFs will be converted to HTML instead\n";
    157151    $strConvertTo = "html";
    158     }
    159     my $self = {};
    160     my $plugin_class ="";
    161     if ($classPluginName eq "WordPlug" && $blnWindowsScripting eq "true" &&
    162     $ENV{'GSDLOS'} =~ /^windows$/i) {
    163     $plugin_class = "StructuredHTML"."Plug";
    164     } elsif ($strConvertTo =~ /pagedimg.*/i){
    165     $plugin_class = "PagedImg"."Plug";
    166     } else {
    167     $plugin_class = uc($strConvertTo)."Plug";
    168     }
    169    
    170     my $plugin_package = $plugin_class.".pm";
    171     require $plugin_package;
    172 
    173     #call its constructor with extra options that we've worked out!
    174     my $arglist = $plugin_options->{$plugin_class};
    175     $self = (defined $hashArgOptLists)? new $plugin_class($pluginlist,$inputargs,$hashArgOptLists): new $plugin_class($pluginlist,$inputargs);
    176 
    177     if ($plugin_class eq "StructuredHTMLPlug") {
     152    } elsif ($classPluginName eq "WordPlug" && $blnWindowsScripting eq "true" && $ENV{'GSDLOS'} =~ /^windows$/i) {
     153    # we use structured HTML
     154    $strConvertTo = "structuredhtml";
     155    } elsif ($strConvertTo eq "auto") {
     156    # choose html for now - should choose a format based on doc type
     157    $strConvertTo = "html";
     158    }
     159   
     160    if ($strConvertTo eq "html") {
     161    $self->{'convert_to'} = "HTML";
     162    $self->{'convert_to_ext'} = "html";
     163    } elsif ($strConvertTo eq "text") {
     164    $self->{'convert_to'} = "TEXT";
     165    $self->{'convert_to_ext'} = "txt";
     166    } elsif ($strConvertTo eq "structuredhtml") {
    178167    $self->{'convert_to'} = "StructuredHTML";
    179168    $self->{'convert_to_ext'} = "html";
    180 #   my $structhtml_options = [];
    181 #   push(@$structhtml_options,"-metadata_fields","Title,GENERATOR");
    182 #   $secondary_plugin_options->{'StructuredHTMLPlug'} = $structhtml_options;
    183     }
    184     elsif ($strConvertTo eq "text")
    185     {
    186     $self->{'convert_to'} = "TEXT";
    187     $self->{'convert_to_ext'} = "txt";
    188 #   my $text_options = [];
    189 #   push(@$text_options,"-metadata_fields","Title,GENERATOR");
    190 #   $secondary_plugin_options->{'TextPlug'} = $text_options;
    191     }
    192     elsif ($strConvertTo =~ /pagedimg.*/i){
     169    } elsif ($strConvertTo =~ /^pagedimg/) {
    193170    $self->{'convert_to'} = "PagedImg";
    194     my $convert_to_ext = $strConvertTo;
    195     $convert_to_ext =~ s/.*\_(.*)/$1/i;
    196     if ($convert_to_ext eq "gif"){
    197         $self->{'convert_to_ext'} = "gif";
    198     } elsif ($convert_to_ext eq "jpg"){
    199         $self->{'convert_to_ext'} = "jpg";
    200     } elsif ($convert_to_ext eq "png") {
    201         $self->{'convert_to_ext'} = "png";
    202     }
    203 #       my $pagedimg_options = [];
    204 #   push(@$pagedimg_options,"-metadata_fields","Title,GENERATOR");
    205 #   $secondary_plugin_options->{'PagedImgPlug'} = $pagedimg_options;
    206     } else {
    207     # HTML or auto
    208     $self = (defined $hashArgOptLists)? new HTMLPlug($pluginlist,$inputargs,$hashArgOptLists): new HTMLPlug($pluginlist,$inputargs);
    209     $self->{'convert_to'} = "HTML";
    210     $self->{'convert_to_ext'} = "html";
    211 #   my $html_options = [];
    212 #   push(@$html_options,"-rename_assoc_files","1");
    213 #   push(@$html_options,"-metadata_fields","Title,GENERATOR");
    214 #   $secondary_plugin_options->{'HTMLPlug'} = $html_options;
    215     }
     171    my ($convert_to_ext) = $strConvertTo =~ /pagedimg\_(jpg|gif|png)/i;
     172    $convert_to_ext = 'jpg' unless defined $convert_to_ext;
     173    $self->{'convert_to_ext'} = $convert_to_ext;
     174    }
     175
    216176    return bless $self, $class;
    217177}
Note: See TracChangeset for help on using the changeset viewer.