Ignore:
Timestamp:
2010-11-26T09:43:59+13:00 (13 years ago)
Author:
davidb
Message:

Tidy up of debugging statements for handline filename encodings, plus finishing off the 'deduce_filename_encoding' routine

File:
1 edited

Legend:

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

    r23335 r23347  
    112112    my $outhandle = $self->{'outhandle'};
    113113    my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
    114 
     114   
    115115    if ($self->{'image_conversion_available'} == 1)
    116116    {
    117     my $filename_encoding = $self->deduce_filename_encoding($file,$metadata);
    118 
    119 #   my $utf8_filename_no_path = $self->filepath_to_utf8($filename_no_path);
    120 #   my $url_encoded_filename = &util::rename_file($utf8_filename_no_path, $self->{'file_rename_method'});
    121 
    122 #   $self->generate_images($filename_full_path, $url_encoded_filename,
    123 #                  $doc_obj, $doc_obj->get_top_section()); # should we check the return value?
    124 
    125     $filename_no_path = &unicode::raw_filename_to_url_encoded($filename_no_path);
    126 
    127     # should we check the return value?
    128     $self->generate_images($filename_full_path, $filename_no_path,
    129                    $doc_obj, $doc_obj->get_top_section(),$filename_encoding);
    130 
     117        my $plugin_filename_encoding = $self->{'filename_encoding'};
     118        my $filename_encoding = $self->deduce_filename_encoding($file,$metadata,$plugin_filename_encoding);
     119       
     120        my $url_encoded_filename = &unicode::raw_filename_to_url_encoded($filename_no_path);
     121       
     122        # should we check the return value?
     123        $self->generate_images($filename_full_path, $url_encoded_filename,
     124                               $doc_obj, $doc_obj->get_top_section(),$filename_encoding);
     125       
    131126    }
    132127    else
    133128    {
    134     if ($gli) {
    135         &gsprintf(STDERR, "<Warning p='ImagePlugin' r='{ImageConverter.noconversionavailable}: {ImageConverter.".$self->{'no_image_conversion_reason'}."}'>");
    136     }
    137     # all we do is add the original image as an associated file, and set up srclink etc
    138     my $assoc_file = $doc_obj->get_assocfile_from_sourcefile();
    139     my $section = $doc_obj->get_top_section();
    140 
    141     $doc_obj->associate_file($filename_full_path, $assoc_file, "", $section);
    142 
    143     $doc_obj->add_metadata ($section, "srclink_file", $doc_obj->get_sourcefile());
    144     # We don't know the size of the image, but the browser should display it at full size
    145     $doc_obj->add_metadata ($section, "srcicon", "<img src=\"_httpprefix_/collect/[collection]/index/assoc/[assocfilepath]/[srclink_file]\">");
    146 
    147     # Add a fake thumbnail icon with the full-sized image scaled down by the browser
    148     $doc_obj->add_metadata ($section, "thumbicon", "<img src=\"_httpprefix_/collect/[collection]/index/assoc/[assocfilepath]/[srclink_file]\" width=\"" . $self->{'thumbnailsize'} . "\">");
     129        if ($gli) {
     130            &gsprintf(STDERR, "<Warning p='ImagePlugin' r='{ImageConverter.noconversionavailable}: {ImageConverter.".$self->{'no_image_conversion_reason'}."}'>");
     131        }
     132        # all we do is add the original image as an associated file, and set up srclink etc
     133        my $assoc_file = $doc_obj->get_assocfile_from_sourcefile();
     134        my $section = $doc_obj->get_top_section();
     135       
     136        $doc_obj->associate_file($filename_full_path, $assoc_file, "", $section);
     137       
     138        $doc_obj->add_metadata ($section, "srclink_file", $doc_obj->get_sourcefile());
     139        # We don't know the size of the image, but the browser should display it at full size
     140        $doc_obj->add_metadata ($section, "srcicon", "<img src=\"_httpprefix_/collect/[collection]/index/assoc/[assocfilepath]/[srclink_file]\">");
     141       
     142        # Add a fake thumbnail icon with the full-sized image scaled down by the browser
     143        $doc_obj->add_metadata ($section, "thumbicon", "<img src=\"_httpprefix_/collect/[collection]/index/assoc/[assocfilepath]/[srclink_file]\" width=\"" . $self->{'thumbnailsize'} . "\">");
    149144    }
    150145    #we have no text - adds dummy text and NoText metadata
    151146    $self->add_dummy_text($doc_obj, $doc_obj->get_top_section());
    152 
     147   
    153148    return 1;
    154 
     149   
    155150}
    156151
Note: See TracChangeset for help on using the changeset viewer.