Changeset 22372
- Timestamp:
- 2010-07-09T18:30:29+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugouts/FedoraMETSPlugout.pm
r22338 r22372 155 155 } 156 156 157 158 #sub adjust_text_before_saving() 159 sub adjust_links() 157 sub adjust_links 160 158 { 161 159 my $self = shift(@_); … … 163 161 164 162 ## change links to be Fedora cognant: 165 # 1. retrieve txt $$textref ???163 # 1. retrieve txt of section - $$textref 166 164 # 2. change it: 167 165 # /$ENV{'FEDORA_PREFIX'}/objects/$greenstone-docobj-hash-xxx/datastreams/FG<orig-img-name>/content 168 # (Note that the first image is always "url", instead of FG<orig-img-name>)169 166 # 3. only replace it back in doc_obj if we didn't get a ref in the first place 170 167 171 168 my $OID = $doc_obj->get_OID(); 172 169 my $fnamespace = $self->{'fedora_namespace'}; 173 my $replace_img_name = 1;174 170 if($OID ne "collection" && defined $fnamespace) { 175 171 my $fed_id = "$fnamespace:".$ENV{'GSDLCOLLECTION'}."-$OID"; #oid_namespace:collection-OID 176 my $fedora_url_prefix = $ENV{'FEDORA_PREFIX'}."/objects/$fed_id/datastreams/ ";172 my $fedora_url_prefix = $ENV{'FEDORA_PREFIX'}."/objects/$fed_id/datastreams/FG"; 177 173 my $fedora_url_suffix = "/content"; 178 174 179 $$textref =~ s/(<(?:img|embed|table|tr|td|link|script)[^>]*?(?:src|background|href)\s*=\s*)((?:[\"][^\"]+[\"])|(?:[\'][^\']+[\'])|(?:[^\s\/>]+))([^>]*>)/$self->replace_rel_link($1, $2, $3, $fedora_url_prefix, $fedora_url_suffix , $replace_img_name--)/isge;175 $$textref =~ s/(<(?:img|embed|table|tr|td|link|script)[^>]*?(?:src|background|href)\s*=\s*)((?:[\"][^\"]+[\"])|(?:[\'][^\']+[\'])|(?:[^\s\/>]+))([^>]*>)/$self->replace_rel_link($1, $2, $3, $fedora_url_prefix, $fedora_url_suffix)/isge; 180 176 # print STDERR "*** all text after: $$textref\n\n"; 181 177 } … … 188 184 { 189 185 my $self = shift (@_); 190 my ($front, $link, $back, $url_prefix, $url_suffix , $replace_img_name) = @_;186 my ($front, $link, $back, $url_prefix, $url_suffix) = @_; 191 187 192 188 # only process relative links. Return if absolute link … … 203 199 } 204 200 205 # remove any _httpdocimg / that greenstone may have prefixed to the image201 # remove any _httpdocimg_/ that greenstone may have prefixed to the image 206 202 $link =~ s/^_httpdocimg_(?:\/|\\)//; 207 208 # the datastream of the first image of each section is always called "url" 209 if($replace_img_name) { 210 return "$front$url_prefix"."url"."$url_suffix$back"; 211 } 212 # else 213 return "$front$url_prefix"."FG"."$link$url_suffix$back"; 203 204 return "$front$url_prefix$link$url_suffix$back"; 214 205 } 215 206 … … 683 674 684 675 685 my $first_assocfile = 1;686 687 676 foreach my $data (@{$section_ptr->{'metadata'}}){ 688 677 my $escaped_value = &docprint::escape_text($data->[1]); … … 695 684 my $assoc_dir = $3; 696 685 697 if ($first_assocfile) { 698 $id_root = "url"; 699 $first_assocfile = 0; 700 } 701 else { 702 $id_root = "FG$assoc_file"; 703 } 686 $id_root = "FG$assoc_file"; 704 687 705 688 $id_root =~ s/\//_/g;
Note:
See TracChangeset
for help on using the changeset viewer.