Changeset 1973 for trunk/gsdl


Ignore:
Timestamp:
2001-02-14T16:32:45+13:00 (23 years ago)
Author:
kjm18
Message:

fixed up language stuff

File:
1 edited

Legend:

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

    r1803 r1973  
    103103    foreach $language (@{$self->{'collect_cfg'}->{'languages'}}) {
    104104        foreach $index (@$indexes) {
    105         push (@{$self->{'collect_cfg'}->{'indexes'}}, "$index:$language");
     105        if (defined ($self->{'collect_cfg'}->{'indexsubcollections'})) {
     106            push (@{$self->{'collect_cfg'}->{'indexes'}}, "$index:$language");
     107        }
     108        else { # add in an empty subcollection field
     109            push (@{$self->{'collect_cfg'}->{'indexes'}}, "$index\:\:$language");
     110        }
    106111        }
    107112    }
     
    351356        $dirname = $self->make_unique (\%pnames, $index, \$pindex, \$psub, \$plang);
    352357    }
     358    $mapping{$index} = $dirname;
    353359
    354360    # store the mapping orders as well as the maps
     361    # also put index, subcollection and language fields into the mapping thing -
     362    # (the full index name (eg document:text:subcol:lang) is not used on
     363    # the query page) -these are used for collectionmeta later on
    355364    if (!defined $mapping{'indexmap'}{"$level:$gran"}) {
    356365        $mapping{'indexmap'}{"$level:$gran"} = $pindex;
    357366        push (@{$mapping{'indexmaporder'}}, "$level:$gran");
     367        if (!defined $mapping{"$level:$gran"}) {
     368        $mapping{"$level:$gran"} = $pindex;
     369        }
    358370    }
    359371    if ($psub =~ /\w/ && !defined ($mapping{'subcollectionmap'}{$subcollection})) {
    360372        $mapping{'subcollectionmap'}{$subcollection} = $psub;
    361373        push (@{$mapping{'subcollectionmaporder'}}, $subcollection);
     374        $mapping{$subcollection} = $psub;
    362375    }
    363376    if ($plang =~ /\w/ && !defined ($mapping{'languagemap'}{$languages})) {
    364377        $mapping{'languagemap'}{$languages} = $plang;
    365         push (@{$mapping{'languagemaporder'}}, $language);
    366     }
    367     $mapping{$index} = $dirname;
     378        push (@{$mapping{'languagemaporder'}}, $languages);
     379        $mapping{$languages} = $plang;
     380    }
    368381    $dirnames{$dirname} = $index;
    369382    $pnames{'index'}{$pindex} = "$level:$gran";
     
    471484    # to a subcollection
    472485    my $indexexparr = [];
    473     my ($level, $fields, $subcollection) = split (":", $index);
     486
     487    # there may be subcollection info, and language info.
     488    my ($level, $fields, $subcollection, $language) = split (":", $index);
    474489    my @subcollections = ();
    475490    @subcollections = split /,/, $subcollection if (defined $subcollection);
     
    482497   
    483498    # add expressions for languages if this index belongs to
    484     # a language subcollection
    485     foreach $language (@{$self->{'collect_cfg'}->{'languages'}}) {
     499    # a language subcollection - only put languages expressions for the
     500    # ones we want in the index
     501
     502    my @languages = ();
     503    @languages = split /,/, $language if (defined $language);
     504    foreach $language (@languages) {
     505    my $not=0;
    486506    if ($language =~ s/^\!//) {
    487         push (@$indexexparr, "!Language/$language/");
    488     } else {
    489         push (@$indexexparr, "Language/$language/");
     507        $not = 1;
     508    }
     509    foreach $lang (@{$self->{'collect_cfg'}->{'languages'}}) {
     510        if ($lang eq $language) {
     511        if($not) {
     512            push (@$indexexparr, "!Language/$language/");
     513        } else {
     514            push (@$indexexparr, "Language/$language/");
     515        }
     516        last;
     517        }
    490518    }
    491519    }
     
    654682            print $handle "<$self->{'index_mapping'}->{$cmeta}>" .
    655683            $self->{'collect_cfg'}->{'collectionmeta'}->{".$cmeta"} . "\n";
    656         } else {
     684        }
     685        else {
    657686            print $outhandle "mgbuilder: warning bad collectionmeta option '$cmeta' - ignored\n";
    658687        }
Note: See TracChangeset for help on using the changeset viewer.