source: main/trunk/greenstone2/perllib/plugins/ConvertBinaryFile.pm

Last change on this file was 38749, checked in by davidb, 2 months ago

Code introduced to set SourceDirectory as a piece of metadata for all plugins. Done in read_into_doc_obj(), and so with the inheritance we have across plugins, this needed in be added into 4-5 of our existing plugins. In doing so, it was noticed that not all of them called the post_process_doc_obj() and/or the newer apply_metadata_mapping() subroutine. These were fixed up as part of this coding change, along with improved consistency of declaring the top_section local variable

  • Property svn:keywords set to Author Date Id Revision
File size: 21.0 KB
Line 
1###########################################################################
2#
3# ConvertBinaryFile.pm -- plugin that facilitates conversion of binary files
4# through gsConvert.pl
5#
6# A component of the Greenstone digital library software
7# from the New Zealand Digital Library Project at the
8# University of Waikato, New Zealand.
9#
10# Copyright (C) 1999 New Zealand Digital Library Project
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26###########################################################################
27
28# This plugin is inherited by such plugins as WordPlugin, PowerPointPlugin,
29# PostScriptPlugin,
30# RTFPlugin and PDFPlugin. It facilitates the conversion of these document types
31# to either HTML, Text or a series of images. It works by dynamically loading
32# an appropriate secondary plugin (HTMLPlug, StructuredHTMLPlug,
33# PagedImagePlugin or TextPlugin) based on the plugin argument 'convert_to'.
34
35package ConvertBinaryFile;
36
37use AutoExtractMetadata;
38use ghtml;
39use HTMLPlugin;
40use TextPlugin;
41use PagedImagePlugin;
42
43use strict;
44no strict 'refs'; # allow filehandles to be variables and viceversa
45no strict 'subs';
46use util;
47use FileUtils;
48
49
50sub BEGIN {
51 @ConvertBinaryFile::ISA = ('AutoExtractMetadata');
52}
53
54my $convert_to_list =
55 [ { 'name' => "auto",
56 'desc' => "{ConvertBinaryFile.convert_to.auto}" },
57 { 'name' => "html",
58 'desc' => "{ConvertBinaryFile.convert_to.html}" },
59 { 'name' => "text",
60 'desc' => "{ConvertBinaryFile.convert_to.text}" }
61 ];
62
63my $arguments =
64 [ { 'name' => "convert_to",
65 'desc' => "{ConvertBinaryFile.convert_to}",
66 'type' => "enum",
67 'reqd' => "yes",
68 'list' => $convert_to_list,
69 'deft' => "auto" },
70 { 'name' => "keep_original_filename",
71 'desc' => "{ConvertBinaryFile.keep_original_filename}",
72 'type' => "flag" },
73 { 'name' => "title_sub",
74 'desc' => "{HTMLPlugin.title_sub}",
75 'type' => "string",
76 #'type' => "regexp",
77 'deft' => "" },
78 { 'name' => "apply_fribidi",
79 'desc' => "{ConvertBinaryFile.apply_fribidi}",
80 'type' => "flag",
81 'reqd' => "no" },
82 { 'name' => "use_strings",
83 'desc' => "{ConvertBinaryFile.use_strings}",
84 'type' => "flag",
85 'reqd' => "no" },
86 ];
87
88my $options = { 'name' => "ConvertBinaryFile",
89 'desc' => "{ConvertBinaryFile.desc}",
90 'abstract' => "yes",
91 'inherits' => "yes",
92 'args' => $arguments };
93
94
95sub load_secondary_plugins
96{
97 my $self = shift (@_);
98 my ($class,$input_args,$hashArgOptLists) = @_;
99
100 my @convert_to_list = split(",",$self->{'convert_to_plugin'});
101 my $secondary_plugins = {};
102 # find the plugin
103
104 foreach my $convert_to (@convert_to_list) {
105 # load in "convert_to" plugin package
106 my $plugin_class = $convert_to;
107 my $plugin_package = $plugin_class.".pm";
108
109 my $colplugname = undef;
110 if (defined $ENV{'GSDLCOLLECTDIR'}) {
111 $colplugname = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'},
112 "perllib","plugins",
113 $plugin_package);
114 }
115
116 my $mainplugname = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},
117 "perllib","plugins",
118 $plugin_package);
119
120 if ((defined $colplugname) && (-e $colplugname)) { require $colplugname;}
121 elsif (-e $mainplugname) { require $mainplugname; }
122 else {
123 &gsprintf(STDERR, "{plugin.could_not_find_plugin}\n",
124 $plugin_class);
125 die "\n";
126 }
127
128 # call its constructor with extra options that we've worked out!
129 my $arglist = $input_args->{$plugin_class};
130
131# The following turns out not to be needed, as the primary plugin will actually
132# get called to apply the metadata_mapping_file if set in its plugin options
133# via post_process_doc_obj()
134# if ($self->{'metadata_mapping_file'}) {
135# # If this plugin option has been set in the primary plugin, then
136# # we always want to pass this on to the secondary plugin
137# my $metadata_mapping_file = $self->{'metadata_mapping_file'};
138# push(@$arglist, "-metadata_mapping_file", $metadata_mapping_file);
139# }
140
141 my ($secondary_plugin);
142 eval("\$secondary_plugin = new $plugin_class([],\$arglist)");
143 die "$@" if $@;
144 $secondary_plugins->{$plugin_class} = $secondary_plugin;
145 }
146 $self->{'secondary_plugins'} = $secondary_plugins;
147}
148
149sub new {
150 my ($class) = shift (@_);
151 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
152 push(@$pluginlist, $class);
153 my $classPluginName = (defined $pluginlist->[0]) ? $pluginlist->[0] : $class;
154 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
155 push(@{$hashArgOptLists->{"OptList"}},$options);
156
157 my $self = new AutoExtractMetadata($pluginlist, $inputargs, $hashArgOptLists);
158
159 return bless $self, $class;
160}
161
162# should be called by subclasses after checking and setting
163# $self->{'convert_to'}
164sub set_standard_convert_settings {
165 my $self =shift (@_);
166
167 my $convert_to = $self->{'convert_to'};
168 if ($convert_to eq "auto") {
169 $convert_to = "html";
170 $self->{'convert_to'} = "html";
171 }
172
173 if ($convert_to =~ /^html/ || $convert_to =~ /pretty_html$/) { # may be html or html_multi, or )paged_)pretty_html with the new Xpdf's own pdftohtml
174 $self->{'convert_to_plugin'} = "HTMLPlugin";
175 $self->{'convert_to_ext'} = "html";
176 } elsif ($convert_to eq "text") {
177 $self->{'convert_to_plugin'} = "TextPlugin";
178 $self->{'convert_to_ext'} = "txt";
179 } elsif ($convert_to eq "structuredhtml") {
180 $self->{'convert_to_plugin'} = "StructuredHTMLPlugin";
181 $self->{'convert_to_ext'} = "html";
182 } elsif ($convert_to =~ /^pagedimg/ || $convert_to eq "paged_text") {
183 $self->{'convert_to_plugin'} = "PagedImagePlugin";
184 if($convert_to eq "paged_text") {
185 $self->{'convert_to_ext'} = "txt";
186 } else {
187 my ($convert_to_ext) = $convert_to =~ /pagedimg(?:txt)?\_(jpg|gif|png)/i; # the ?: prefix avoids capturing or else discards the optional 'txt' in 'pagedimgtxt',
188 # so that we can consider the actual portion we want to capture: the img type
189 $convert_to_ext = 'jpg' unless defined $convert_to_ext;
190 $self->{'convert_to_ext'} = $convert_to_ext;
191 }
192 }
193}
194sub init {
195 my $self = shift (@_);
196 my ($verbosity, $outhandle, $failhandle) = @_;
197
198 $self->SUPER::init($verbosity,$outhandle,$failhandle);
199
200 my $secondary_plugins = $self->{'secondary_plugins'};
201
202 foreach my $plug_name (keys %$secondary_plugins) {
203 my $plugin = $secondary_plugins->{$plug_name};
204 $plugin->init($verbosity,$outhandle,$failhandle);
205 }
206}
207
208sub deinit {
209 # called only once, after all plugin passes have been done
210
211 my ($self) = @_;
212
213 my $secondary_plugins = $self->{'secondary_plugins'};
214
215 foreach my $plug_name (keys %$secondary_plugins) {
216 my $plugin = $secondary_plugins->{$plug_name};
217 $plugin->deinit();
218 }
219}
220
221sub convert_post_process
222{
223 # by default do no post processing
224 return;
225}
226
227
228# Run conversion utility on the input file.
229#
230# The conversion takes place in a collection specific 'tmp' directory so
231# that we don't accidentally damage the input.
232#
233# The desired output type is indicated by $output_ext. This is usually
234# something like "html" or "word", but can be "best" (or the empty string)
235# to indicate that the conversion utility should do the best it can.
236sub tmp_area_convert_file {
237 my $self = shift (@_);
238 my ($output_ext, $input_filename, $textref) = @_;
239
240 my $outhandle = $self->{'outhandle'};
241 my $convert_to = $self->{'convert_to'};
242 my $failhandle = $self->{'failhandle'};
243 my $convert_to_ext = $self->{'convert_to_ext'};
244
245
246 my $upgraded_input_filename = &util::upgrade_if_dos_filename($input_filename);
247
248 # derive tmp filename from input filename
249 my ($tailname, $dirname, $suffix)
250 = &File::Basename::fileparse($upgraded_input_filename, "\\.[^\\.]+\$");
251
252 # softlink to collection tmp dir
253 my $tmp_dirname = &util::get_timestamped_tmp_folder();
254 if (defined $tmp_dirname) {
255 $self->{'tmp_dir'} = $tmp_dirname;
256 } else {
257 $tmp_dirname = $dirname;
258 }
259
260# # convert to utf-8 otherwise we have problems with the doc.xml file later on
261# my $utf8_tailname = (&unicode::check_is_utf8($tailname)) ? $tailname : $self->filepath_to_utf8($tailname);
262
263 # make sure filename to be used can be stored OK in a UTF-8 compliant doc.xml file
264 my $utf8_tailname = &unicode::raw_filename_to_utf8_url_encoded($tailname);
265
266
267 # URLEncode this since htmls with images where the html filename is utf8 don't seem
268 # to work on Windows (IE or Firefox), as browsers are looking for filesystem-encoded
269 # files on the filesystem.
270 $utf8_tailname = &util::rename_file($utf8_tailname, $self->{'file_rename_method'}, "without_suffix");
271
272 my $lc_suffix = lc($suffix);
273 my $tmp_filename = &FileUtils::filenameConcatenate($tmp_dirname, "$utf8_tailname$lc_suffix");
274
275 # If gsdl is remote, we're given relative path to input file, of the form import/utf8_tailname.suffix
276 # But we can't softlink to relative paths. Therefore, we need to ensure that
277 # the input_filename is the absolute path, see http://perldoc.perl.org/File/Spec.html
278 my $ensure_path_absolute = 1; # true
279 &FileUtils::softLink($input_filename, $tmp_filename, $ensure_path_absolute);
280
281 my $output_filename = $self->run_conversion_command($tmp_dirname, $tmp_filename,
282 $utf8_tailname, $lc_suffix, $tailname, $suffix);
283
284 return $output_filename;
285}
286
287# The latter half of tmp_area_convert_file: runs the conversion command and returns the output file name
288# Split from tmp_area_convert_file because UnknownConverterPlugin can then inherit all of
289# tmp_area_convert_file and only needs to override this part:
290sub run_conversion_command {
291 my $self = shift (@_);
292 my ($tmp_dirname, $tmp_filename, $utf8_tailname, $lc_suffix, $tailname, $suffix) = @_;
293
294 my $outhandle = $self->{'outhandle'};
295 my $convert_to = $self->{'convert_to'};
296 my $failhandle = $self->{'failhandle'};
297
298 my $verbosity = $self->{'verbosity'};
299 if ($verbosity > 0) {
300 print $outhandle "Converting $tailname$suffix to $convert_to format\n";
301 }
302
303 my $errlog = &FileUtils::filenameConcatenate($tmp_dirname, "err.log");
304
305 # Execute the conversion command and get the type of the result,
306 # making sure the converter gives us the appropriate output type
307 my $output_type=$self->{'convert_to'};
308# if ($convert_to =~ m/PagedImage/i) {
309# $output_type = lc($convert_to)."_".lc($convert_to_ext);
310# } else {
311# $output_type = lc($convert_to);
312# }
313
314 my $cmd = "\"".&util::get_perl_exec()."\" -S gsConvert.pl -verbosity $verbosity ";
315 if (defined $self->{'convert_options'}) {
316 $cmd .= $self->{'convert_options'} . " ";
317 }
318 if ($self->{'use_strings'}) {
319 $cmd .= "-use_strings ";
320 }
321 $cmd .= "-errlog \"$errlog\" -output $output_type \"$tmp_filename\"";
322 print STDERR "calling cmd $cmd\n";
323 $output_type = `$cmd`;
324
325 # remove symbolic link to original file
326 &FileUtils::removeFiles($tmp_filename);
327
328 # Check STDERR here
329 chomp $output_type;
330 if ($output_type eq "fail") {
331 print $outhandle "Could not convert $tailname$suffix to $convert_to format\n";
332 print $failhandle "$tailname$suffix: " . ref($self) . " failed to convert to $convert_to\n";
333 # The following meant that if a conversion failed, the document would be counted twice - do we need it for anything?
334 #$self->{'num_not_processed'} ++;
335 if (-s "$errlog") {
336 open(ERRLOG, "$errlog");
337 while (<ERRLOG>) {
338 print $outhandle "$_";
339 }
340 print $outhandle "\n";
341 close ERRLOG;
342 }
343 &FileUtils::removeFiles("$errlog") if (-e "$errlog");
344 return "";
345 }
346
347 # store the *actual* output type and return the output filename
348 # it's possible we requested conversion to html, but only to text succeeded
349 #$self->{'convert_to_ext'} = $output_type;
350 if ($output_type =~ /html/i) {
351 $self->{'converted_to'} = "HTML";
352 } elsif ($output_type =~ /te?xt/i) {
353 $self->{'converted_to'} = "Text";
354 } elsif ($output_type =~ /item/i){
355 $self->{'converted_to'} = "PagedImage";
356 }
357
358 my $output_filename = $tmp_filename;
359 if ($output_type =~ /item/i) {
360 # running under windows
361 if ($ENV{'GSDLOS'} =~ /^windows$/i) {
362 $output_filename = $tmp_dirname . "\\$utf8_tailname\\" . $utf8_tailname . ".$output_type";
363 } else {
364 $output_filename = $tmp_dirname . "\/$utf8_tailname\/" . $utf8_tailname . ".$output_type";
365 }
366 } else {
367 $output_filename =~ s/$lc_suffix$/.$output_type/;
368 }
369
370 return $output_filename;
371}
372
373
374# Override BasPlug read_into_doc_obj - we need to call secondary plugin stuff
375sub read_into_doc_obj {
376 my $self = shift (@_);
377 my ($pluginfo, $base_dir, $file, $block_hash, $metadata, $processor, $maxdocs, $total_count, $gli) = @_;
378
379 my $outhandle = $self->{'outhandle'};
380
381 my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
382
383 my $output_ext = $self->{'convert_to_ext'};
384 my $conv_filename = "";
385 $conv_filename = $self->tmp_area_convert_file($output_ext, $filename_full_path);
386
387 if ("$conv_filename" eq "") {return -1;} # had an error, will be passed down pipeline
388
389 my $output_type=$self->{'convert_to'};
390 if (!&FileUtils::fileExists($conv_filename)) {return -1;}
391 $self->{'conv_filename'} = $conv_filename;
392 $self->convert_post_process($conv_filename);
393
394 # Check if, after post-processing, the final expected output file has changed
395 # And if it has, check that the final output file now exists after post processing
396 if(defined $self->{'conv_filename_after_post_process'}) {
397 $conv_filename = $self->{'conv_filename_after_post_process'};
398 if (!&FileUtils::fileExists($conv_filename)) {return -1;}
399 }
400
401 # Run the "fribidi" (http://fribidi.org) Unicode Bidirectional Algorithm program over the converted file
402 # Added for fixing up Persian PDFs after being processed by pdftohtml, but may be useful in other cases too
403 if ($self->{'apply_fribidi'} && $self->{'converted_to'} =~ /(HTML|Text)/) {
404 my $fribidi_command = "fribidi \"$conv_filename\" >\"${conv_filename}.tmp\"";
405 if (system($fribidi_command) != 0) {
406 print STDERR "ERROR: Cannot run fribidi on \"$conv_filename\".\n";
407 }
408 else {
409 &FileUtils::moveFiles("${conv_filename}.tmp", $conv_filename);
410 }
411 }
412
413 my $secondary_plugins = $self->{'secondary_plugins'};
414 my $num_secondary_plugins = scalar(keys %$secondary_plugins);
415
416 if ($num_secondary_plugins == 0) {
417 print $outhandle "Warning: No secondary plugin to use in conversion. Skipping $file\n";
418 return 0; # effectively block it
419 }
420
421 my @plugin_names = keys %$secondary_plugins;
422 my $plugin_name = shift @plugin_names;
423
424 if ($num_secondary_plugins > 1) {
425 print $outhandle "Warning: Multiple secondary plugins not supported yet! Choosing $plugin_name\n.";
426 }
427
428 my $secondary_plugin = $secondary_plugins->{$plugin_name};
429
430 # note: metadata is not carried on to the next level
431## **** I just replaced $metadata with {} in following
432 my ($rv,$doc_obj)
433 = $secondary_plugin->read_into_doc_obj ($pluginfo,"", $conv_filename, $block_hash, {}, $processor, $maxdocs, $total_count, $gli);
434
435 if ((!defined $rv) || ($rv<1)) {
436 # wasn't processed
437 return $rv;
438 }
439
440 # Override previous gsdlsourcefilename set by secondary plugin
441 my $collect_file = &util::filename_within_collection($filename_full_path);
442 my $collect_conv_file = &util::filename_within_collection($conv_filename);
443 $doc_obj->set_source_filename ($collect_file, $self->{'file_rename_method'});
444 ## set_source_filename does not set the doc_obj source_path which is used in archives dbs for incremental
445 # build. so set it manually.
446 $doc_obj->set_source_path($filename_full_path);
447 $doc_obj->set_converted_filename($collect_conv_file);
448
449 my $plugin_filename_encoding = $self->{'filename_encoding'};
450 my $filename_encoding = $self->deduce_filename_encoding($file,$metadata,$plugin_filename_encoding);
451 $self->set_Source_metadata($doc_obj, $filename_full_path, $filename_encoding);
452
453 my $top_section = $doc_obj->get_top_section();
454
455 $doc_obj->set_utf8_metadata_element($top_section, "Plugin", "$self->{'plugin_type'}");
456 $doc_obj->set_utf8_metadata_element($top_section, "FileSize", (-s $filename_full_path));
457
458 my $file_dirname = &File::Basename::dirname($file);
459 $doc_obj->add_utf8_metadata($top_section, "SourceDirectory", $file_dirname);
460
461 # ****
462 my ($tailname, $dirname, $suffix)
463 = &File::Basename::fileparse($filename_full_path, "\\.[^\\.]+\$");
464 $doc_obj->set_utf8_metadata_element($top_section, "FilenameRoot", $tailname);
465
466 # do plugin specific processing of doc_obj
467 unless (defined ($self->process($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli))) {
468 print STDERR "<ProcessingError n='$file'>\n" if ($gli);
469 return -1;
470 }
471
472 $self->add_associated_files($doc_obj, $filename_full_path);
473
474 # extra_metadata is already called by sec plugin in process??
475 $self->extra_metadata($doc_obj, $top_section, $metadata); # do we need this here??
476 # do any automatic metadata extraction
477 $self->auto_extract_metadata ($doc_obj);
478
479 # have we found a Title??
480 $self->title_fallback($doc_obj,$top_section,$filename_no_path);
481
482 if ($self->{'metadata_mapping_rules'}) {
483 $self->apply_metadata_mapping_file($doc_obj);
484 }
485
486 # force a new OID - this will use OIDtype option set for this plugin.
487 $self->add_OID($doc_obj, 1);
488
489 $self->post_process_doc_obj($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli);
490 return (1, $doc_obj);
491
492}
493
494sub process {
495 my $self = shift (@_);
496 my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
497
498 return $self->process_type($base_dir, $file, $doc_obj);
499}
500
501# do plugin specific processing of doc_obj for doc_ext type
502sub process_type {
503 my $self = shift (@_);
504 my ($base_dir, $file, $doc_obj) = @_;
505
506 # need to check that not empty
507 my ($doc_ext) = $file =~ /\.(\w+)$/;
508 $doc_ext = lc($doc_ext);
509 my $file_type = "unknown";
510 $file_type = $self->{'file_type'} if defined $self->{'file_type'};
511
512 # associate original file with doc object
513 my $cursection = $doc_obj->get_top_section();
514 my $filename = &FileUtils::filenameConcatenate($base_dir, $file);
515 my $assocfilename = "doc.$doc_ext";
516 if ($self->{'keep_original_filename'} == 1) {
517 # this should be the same filename that was used for the Source and SourceFile metadata,
518 # as we will use SourceFile in the srclink (below)
519 $assocfilename = $doc_obj->get_assocfile_from_sourcefile();
520 }
521
522 $doc_obj->associate_file($filename, $assocfilename, undef, $cursection);
523
524 # We use set instead of add here because we only want one value
525 $doc_obj->set_utf8_metadata_element($cursection, "FileFormat", $file_type);
526 my $srclink_filename = "doc.$doc_ext";
527 if ($self->{'keep_original_filename'} == 1) {
528 $srclink_filename = $doc_obj->get_sourcefile();
529 }
530 # srclink_file is now deprecated because of the "_" in the metadataname. Use srclinkFile
531 $doc_obj->add_utf8_metadata ($cursection, "srcicon", "_icon".$doc_ext."_");
532 $doc_obj->add_utf8_metadata ($cursection, "srclink_file", $srclink_filename);
533 $doc_obj->add_utf8_metadata ($cursection, "srclinkFile", $srclink_filename);
534 return 1;
535}
536
537sub clean_up_after_doc_obj_processing {
538 my $self = shift(@_);
539
540 my $tmp_dir = $self->{'tmp_dir'};
541 if (defined $tmp_dir && -d $tmp_dir) {
542 ##print STDERR "**** Suppressing clean up of tmp dir\n";
543 &FileUtils::removeFilesRecursive($tmp_dir);
544 $self->{'tmp_dir'} = undef;
545 }
546
547
548}
549
550# This sub is shared across PowerPointPlugin and UnknownConverterPlugin,
551# so it's been copied into here from the former.
552sub generate_item_file {
553 my $self = shift(@_);
554 my ($input_filename) = @_;
555 my $outhandle = $self->{'outhandle'};
556 my ($tailname, $dirname, $suffix)
557 = &File::Basename::fileparse($input_filename, "\\.[^\\.]+\$");
558
559 my $plugin_name = $self->{'plugin_type'}; # inherited from BaseImporter
560
561 # find all the files in the directory
562 if (!opendir (DIR, $dirname)) {
563 print $outhandle "$plugin_name: Couldn't read directory $dirname\n";
564 return $input_filename;
565 }
566
567 my @dir = readdir (DIR);
568 closedir (DIR);
569
570 # start the item file
571 my $itemfile_name = &util::filename_cat($dirname, "$tailname.item");
572
573 # encoding specification????
574 if (!open (ITEMFILE, ">$itemfile_name")) {
575 print $outhandle "$plugin_name: Couldn't open $itemfile_name for writing\n";
576 }
577 print ITEMFILE "<GeneratedBy>$plugin_name\n";
578 # print the first page
579 my @sorted_dir = sort alphanum_sort @dir;
580 for (my $i = 0; $i < scalar(@sorted_dir); $i++) {
581 my $file = $sorted_dir[$i];
582 if ($file =~ /^img(\d+)\.jpg$/) {
583 my $num = $1;
584 $self->tidy_up_html(&util::filename_cat($dirname, "text$num.html"));
585 print ITEMFILE "$num:img$num.jpg:text$num.html:\n";
586 }
587 }
588 close ITEMFILE;
589 return $itemfile_name;
590
591}
592
5931;
594
595
596
597
598
599
600
Note: See TracBrowser for help on using the repository browser.