Ignore:
Timestamp:
2017-06-29T16:27:37+12:00 (7 years ago)
Author:
ak19
Message:

Moved function generate_item_file that's shared between PowerPointPlugin and the new UnknownConverterPlugin into their shared base class ConvertBinaryFile.pm. 2. In UnknownConverterPlugin, removed unnecessary plugin uption, made the file return 1 as all other Plugin/pm files do, and now some debug stmts are only printed when the verbosity is >2.

File:
1 edited

Legend:

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

    r28381 r31761  
    496496
    497497}
     498
     499# This sub is shared across PowerPointPlugin and UnknownConverterPlugin,
     500# so it's been copied into here from the former.
     501sub generate_item_file {
     502    my $self = shift(@_);
     503    my ($input_filename) = @_;
     504    my $outhandle = $self->{'outhandle'};
     505    my ($tailname, $dirname, $suffix)
     506    = &File::Basename::fileparse($input_filename, "\\.[^\\.]+\$");
     507
     508    my $plugin_name = $self->{'plugin_type'}; # inherited from BaseImporter
     509
     510    # find all the files in the directory
     511    if (!opendir (DIR, $dirname)) {
     512    print $outhandle "$plugin_name: Couldn't read directory $dirname\n";
     513    return $input_filename;
     514    }
     515
     516    my @dir = readdir (DIR);
     517    closedir (DIR);
     518
     519    # start the item file
     520    my $itemfile_name = &util::filename_cat($dirname, "$tailname.item");
     521
     522    # encoding specification????
     523    if (!open (ITEMFILE, ">$itemfile_name")) {
     524    print $outhandle "$plugin_name: Couldn't open $itemfile_name for writing\n";
     525    }
     526    print ITEMFILE "<GeneratedBy>$plugin_name\n";
     527    # print the first page
     528    my @sorted_dir = sort alphanum_sort @dir;
     529    for (my $i = 0; $i < scalar(@sorted_dir); $i++) {
     530    my $file = $sorted_dir[$i];
     531    if ($file =~ /^img(\d+)\.jpg$/) {
     532        my $num = $1;
     533        $self->tidy_up_html(&util::filename_cat($dirname, "text$num.html"));
     534        print ITEMFILE "$num:img$num.jpg:text$num.html:\n";
     535    }
     536    }
     537    close ITEMFILE;
     538    return $itemfile_name;
     539
     540}
     541
    4985421;
    499543
Note: See TracChangeset for help on using the changeset viewer.