Ignore:
Timestamp:
2000-02-03T10:06:40+13:00 (24 years ago)
Author:
sjboddie
Message:

tweaked the way associated files are handled at build time - some
individual plugins may still need catching up.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/mgbuildproc.pm

    r810 r900  
    3434use docproc;
    3535use util;
    36 
    3736
    3837BEGIN {
     
    187186sub assoc_files {
    188187    my $self = shift (@_);
    189     my ($doc_obj) = @_;
     188    my ($doc_obj, $archivedir) = @_;
     189    my ($afile);
    190190   
    191     foreach $assoc_file (@{$doc_obj->get_assoc_files()}) {
    192     $afile = &util::filename_cat($self->{'assocdir'}, $assoc_file->[1]);
     191    foreach my $assoc_file (@{$doc_obj->get_assoc_files()}) {
     192    # if assoc file contains directory structure of
     193    # its own use it, otherwise use HASH... directory
     194    if ($assoc_file->[1] =~ /[\/\\]/) {
     195        $afile = &util::filename_cat($self->{'assocdir'}, $assoc_file->[1]);
     196    } else {
     197        $afile = &util::filename_cat($self->{'assocdir'}, $archivedir, $assoc_file->[1]);
     198    }
    193199    &util::hard_link ($assoc_file->[0], $afile);
    194200    }
     
    201207#    $handle = "main::STDOUT";
    202208
    203     $self->assoc_files ($doc_obj);
    204 
    205209    my $doctype = $doc_obj->get_doc_type();
    206210
    207211    # only output this document if it is one to be indexed
    208212    return if ($doctype ne "indexed_doc");
     213
     214    my ($archivedir) = $filename =~ /^(.*?)(?:\/|\\)[^\/\\]*$/;
     215    $archivedir = "" unless defined $archivedir;
     216    $archivedir =~ s/\\/\//g;
     217    $archivedir =~ s/^\/+//;
     218    $archivedir =~ s/\/+$//;
     219
     220    $self->assoc_files ($doc_obj, $archivedir);
    209221
    210222    # this is another document
     
    239251    # output all the section metadata
    240252    my $metadata = $doc_obj->get_all_metadata ($section);
    241     foreach $pair (@$metadata) {
     253    foreach my $pair (@$metadata) {
    242254        my ($field, $value) = (@$pair);
    243255
     
    266278    # output archivedir if at top level
    267279    if ($section eq $doc_obj->get_top_section()) {
    268         my ($archivedir) = $filename =~ /^(.*?)(?:\/|\\)[^\/\\]*$/;
    269         $archivedir = "" unless defined $archivedir;
    270         $archivedir =~ s/\\/\//g;
    271         $archivedir =~ s/^\/+//;
    272         $archivedir =~ s/\/+$//;
    273280        print $handle "<archivedir>$archivedir\n";
    274281    }
     
    285292        print $handle "<contains>";
    286293        my $firstchild = 1;
    287         foreach $child (@$children) {
     294        foreach my $child (@$children) {
    288295        print $handle ";" unless $firstchild;
    289296        $firstchild = 0;
     
    348355
    349356    # see if this document belongs to this subcollection
    350     foreach $indexexp (@{$self->{'indexexparr'}}) {
     357    foreach my $indexexp (@{$self->{'indexexparr'}}) {
    351358    $indexed_doc = 0;
    352359    my ($field, $exp, $options) = split /\//, $indexexp;
     
    397404    if ($indexed_doc) {
    398405        $self->{'num_bytes'} += $doc_obj->get_text_length ($section);
    399         foreach $field (split (/,/, $fields)) {
     406        foreach my $field (split (/,/, $fields)) {
    400407        # only deal with this field if it doesn't start with top or
    401408        # this is the first section
Note: See TracChangeset for help on using the changeset viewer.