Changeset 10453
- Timestamp:
- 2005-08-10T12:57:34+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/ConvertToPlug.pm
r10450 r10453 39 39 use PagedImgPlug; 40 40 41 #use strict;42 #no strict 'refs'; # allow filehandles to be variables and viceversa41 use strict; 42 no strict 'refs'; # allow filehandles to be variables and viceversa 43 43 44 44 sub BEGIN { … … 52 52 'desc' => "{ConvertToPlug.convert_to.html}" }, 53 53 { '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}" } 61 55 ]; 62 56 … … 97 91 { 98 92 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"; 102 95 for(my $intCounter = 0; $intCounter < scalar(@{$inputargs}) ; $intCounter++) 103 96 { … … 105 98 { 106 99 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 now108 #if($inputargs->[$intCounter+1] =~ /pagedimg.*/i || $inputargs->[$intCounter+1] eq "text" || $inputargs->[$intCounter+1] eq "html")109 100 { 110 $conver _to_type = $inputargs->[$intCounter+1];101 $convert_to_type = $inputargs->[$intCounter+1]; 111 102 } 112 103 } … … 116 107 } 117 108 } 118 return ($conver _to_type,$windows_scripting);109 return ($convert_to_type,$windows_scripting); 119 110 } 120 111 … … 125 116 126 117 my @convert_to_list = split(",",$self->{'convert_to'}); 127 $secondary_plugins = {};118 my $secondary_plugins = {}; 128 119 129 120 foreach my $convert_to (@convert_to_list) { … … 152 143 if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)}; 153 144 145 my $self = (defined $hashArgOptLists)? new BasPlug($pluginlist,$inputargs,$hashArgOptLists): new BasPlug($pluginlist,$inputargs); 146 147 154 148 if ($classPluginName eq "PDFPlug" && $strConvertTo eq "text" && 155 149 $ENV{'GSDLOS'} =~ /^windows$/i) { 156 150 print STDERR "Windows does not support pdf to text. PDFs will be converted to HTML instead\n"; 157 151 $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") { 178 167 $self->{'convert_to'} = "StructuredHTML"; 179 168 $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/) { 193 170 $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 216 176 return bless $self, $class; 217 177 }
Note:
See TracChangeset
for help on using the changeset viewer.