Changeset 10663


Ignore:
Timestamp:
2005-09-29T10:54:06+12:00 (19 years ago)
Author:
kjdon
Message:

added documents_last - display document nodes after classifier nodes in the lists

Location:
trunk/gsdl/perllib/classify
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify/HFileHierarchy.pm

    r10483 r10663  
    7474    'desc' => "{Hierarchy.hlist_at_top}",
    7575    'type' => "flag",
    76     'reqd' => "no" } ];
     76    'reqd' => "no" },
     77      { 'name' => "documents_last",
     78    'desc' => "{Hierarchy.documents_last}",
     79    'type' => "flag",
     80    'reqd' => "no"}
     81      ];
    7782
    7883my $options =
     
    273278
    274279    $classifyinfo->{'contains'} = [] unless defined $classifyinfo->{'contains'};
     280    if ($self->{'documents_last'}) {
     281    # documents should come after nodes in the classifier
     282
     283    my $doc_pos = 0;
     284    foreach my $thing (@{$classifyinfo->{'contains'}}) {
     285        last if defined $thing->{'OID'};
     286        $doc_pos++;
     287    }
     288   
     289    while ($doc_pos < $headOID) {
     290        splice(@{$classifyinfo->{'contains'}}, $doc_pos, 0, $self->get_entry("", $classifytype));
     291        $doc_pos++;
     292    }
     293
     294    return $self->get_OID_entry ($tailOID, $classifyinfo->{'contains'}->[($headOID-1)], $title, $classifytype);
     295
     296    }
     297   
     298    # else, documents come before nodes
    275299    my $offset = 0;
    276300    foreach my $thing (@{$classifyinfo->{'contains'}}) {
  • trunk/gsdl/perllib/classify/Hierarchy.pm

    r10630 r10663  
    248248       
    249249    }
    250     # if this key has documents, add them
    251     if (@doc_list) {
    252         $has_content = 1;
    253         foreach my $d (@doc_list) {
    254         push (@{$entry->{'contains'}}, {'OID'=>$d});
    255         }   
    256     }
    257     # if this key has nodes, add them
    258     if (scalar(keys %{$top_hash->{$key}->{'nodes'}})) {
    259         $has_content = 1;
    260         $self->process_hash($top_hash->{$key}->{'nodes'}, $entry);
    261     }
     250
     251    if ($self->{'documents_last'}) {
     252        # add nodes, then documents
     253        # if this key has nodes, add them
     254        if (scalar(keys %{$top_hash->{$key}->{'nodes'}})) {
     255        $has_content = 1;
     256        $self->process_hash($top_hash->{$key}->{'nodes'}, $entry);
     257        }
     258
     259        # if this key has documents, add them
     260        if (@doc_list) {
     261        $has_content = 1;
     262        foreach my $d (@doc_list) {
     263            push (@{$entry->{'contains'}}, {'OID'=>$d});
     264        }   
     265        }
     266
     267    } else {
     268        # add documents then nodes
     269        # if this key has documents, add them
     270        if (@doc_list) {
     271        $has_content = 1;
     272        foreach my $d (@doc_list) {
     273            push (@{$entry->{'contains'}}, {'OID'=>$d});
     274        }   
     275        }
     276        # if this key has nodes, add them
     277        if (scalar(keys %{$top_hash->{$key}->{'nodes'}})) {
     278        $has_content = 1;
     279        $self->process_hash($top_hash->{$key}->{'nodes'}, $entry);
     280        }
     281    }
     282   
    262283    # if we have found some content, add the new entry for this key into the parent node
    263284    if ($has_content) {
Note: See TracChangeset for help on using the changeset viewer.