Ignore:
Timestamp:
2005-07-06T15:27:45+12:00 (19 years ago)
Author:
kjdon
Message:

Jeffrey's new parsing modifications, committed approx 6 July, 15.16

File:
1 edited

Legend:

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

    r9206 r10218  
    4343my $arguments =
    4444    [ { 'name' => "separator",
    45     'desc' => "{AutoHierarchy.separator}",
     45    'desc' => "{Hierarchy.separator}",
    4646    'type' => "regexp",
    4747    'deft' => "[\\\\\\\/|\\\\\\\|]",
    4848    'reqd' => "no" },
    4949      { 'name' => "suppresslastlevel",
    50     'desc' => "{AutoHierarchy.suppresslastlevel}",
     50    'desc' => "{Hierarchy.suppresslastlevel}",
    5151    'type' => "flag",
    5252    'reqd' => "no" } ];
    5353
    5454my $options = { 'name'     => "Hierarchy",
    55         'desc'     => "{AutoHierarchy.desc}",
     55        'desc'     => "{Hierarchy.desc}",
    5656        'abstract' => "no",
    5757        'inherits' => "yes",
     
    6060
    6161sub new {
    62     my $class = shift (@_);
    63     my $self = new HFileHierarchy($class, @_);
    64 
    65     # 14-05-02 To allow for proper inheritance of arguments - John Thompson
    66     my $option_list = $self->{'option_list'};
    67     push( @{$option_list}, $options );
    68 
    69     if ($self->{'info_only'}) {
    70     # created from classinfo.pl - don't need to parse the arguments
    71     return bless $self, $class;
    72     }
    73 
    74     my $separator;
    75     my $suppresslastlevel = 0;
    76 
    77     if (!parsargv::parse(\@_,
    78              q^separator/.*/^, \$separator,
    79              q^suppresslastlevel^, \$suppresslastlevel,
    80              "allow_extra_options")) {
    81    
    82     print STDERR "\nIncorrect options passed to $class, check your collect.cfg file\n";
    83     $self->print_txt_usage("");  # Use default resource bundle
    84     die "\n";
    85     }
    86 
    87    
    88     if (!$separator) {
    89     $separator = "[\\\/|\\\|]";
    90     }
    91     $self->{'separator'} = $separator;
    92     $self->{'suppresslastlevel'} = $suppresslastlevel;
     62    my ($class) = shift (@_);
     63    my ($classifierslist,$inputargs,$hashArgOptLists) = @_;
     64    push(@$classifierslist, $class);
     65
     66    if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
     67    if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
     68
     69    my $self = (defined $hashArgOptLists)? new HFileHierarchy($classifierslist,$inputargs,$hashArgOptLists): new HFileHierarchy($classifierslist,$inputargs);
    9370   
    9471    # the hash that we use to build up the hierarchy
     
    127104        push(@{$current_pos->{'docs'}}, $doc_OID);
    128105    } else {
    129         if (defined $sortmeta) {
    130         # can you ever get the same doc twice in one classification??
    131         $current_pos->{'docs'}->{$doc_OID} = $sortmeta;
    132         } else {
    133         $current_pos->{'docs'}->{$doc_OID} = $metavalue;
    134         }
     106        $current_pos->{'docs'}->{$doc_OID} = $sortmeta;
     107       
     108        #if (defined $sortmeta) {
     109    #   # can you ever get the same doc twice in one classification??
     110    #   $current_pos->{'docs'}->{$doc_OID} = $sortmeta;
     111    #    } else {
     112    #   $current_pos->{'docs'}->{$doc_OID} = $metavalue;
     113    #    }
    135114    }
    136115    } # foreach metadata
     
    146125    # are we sorting the list??
    147126    my $nosort = 0;
    148     if (defined $self->{'sortname'} && $self->{'sortname'} eq "nosort") {
     127    if (!defined $self->{'sort'}) {
    149128    $nosort = 1;
    150129    }
    151 
     130   
    152131    my $metavalues = [];
    153132    # find all the metadata values
     
    155134    my $mvalues = $doc_obj->get_metadata($doc_obj->get_top_section(), $m);
    156135    next unless (@{$mvalues});
    157     if ($self->{'onlyfirst'}) {
     136    if ($self->{'firstvalueonly'}) {
    158137        # we only want the first metadata value
    159138        push (@$metavalues, $mvalues[0]);
     
    169148    #check for a sort element other than our metadata
    170149    my $sortmeta = undef;
    171     if (!$nosort && defined $self->{'sortname'}) {
    172        
    173     if ($self->{'sortname'} =~ /^filename$/i) {
     150    if (!$nosort) {
     151    if ($self->{'sort'} =~ /^filename$/i) {
    174152        $sortmeta = $doc_obj->get_source_filename();
    175153    } else {
    176         $sortmeta = $doc_obj->get_metadata_element($doc_obj->get_top_section(), $self->{'sortname'});
     154        $sortmeta = $doc_obj->get_metadata_element($doc_obj->get_top_section(), $self->{'sort'});
    177155        if (defined $sortmeta) {
    178         $sortmeta = &sorttools::format_metadata_for_sorting($self->{'sortname'}, $sortmeta, $doc_obj);
     156        $sortmeta = &sorttools::format_metadata_for_sorting($self->{'sort'}, $sortmeta, $doc_obj);
    179157        }
    180158    }
     
    252230    my @doc_list;
    253231    # generate a sorted list of doc ids
    254     if ($nosort && scalar(@{$top_hash->{$key}->{'docs'}})) {
     232    if (not (defined ($self->{'sort'})) && scalar(@{$top_hash->{$key}->{'docs'}})) {
    255233        @doc_list = @{$top_hash->{$key}->{'docs'}};
    256     } elsif (!$nosort && (keys %{$top_hash->{$key}->{'docs'}})) {
     234    } elsif (defined ($self->{'sort'}) && (keys %{$top_hash->{$key}->{'docs'}})) {
    257235        @doc_list = sort {$top_hash->{$key}->{'docs'}->{$a}
    258236                  cmp $top_hash->{$key}->{'docs'}->{$b};} keys %{$top_hash->{$key}->{'docs'}};
     
    289267    if ($self->{'path_hash'}) {
    290268    if ($self->{'hlist_at_top'}) {
    291         $classification = $self->get_entry ($self->{'title'}, "HList", "Invisible");
     269        $classification = $self->get_entry ($self->{'buttonname'}, "HList", "Invisible");
    292270    }
    293271    else {
    294         $classification = $self->get_entry ($self->{'title'}, "VList", "Invisible");
     272        $classification = $self->get_entry ($self->{'buttonname'}, "VList", "Invisible");
    295273    }
    296274    }
     
    319297
    320298    if ($self->{'hlist_at_top'}) {
    321     $classifyinfo = $self->get_entry ($self->{'title'}, "HList", "Invisible");
     299    $classifyinfo = $self->get_entry ($self->{'buttonname'}, "HList", "Invisible");
    322300    }
    323301    else {
    324     $classifyinfo = $self->get_entry ($self->{'title'}, "VList", "Invisible");
     302    $classifyinfo = $self->get_entry ($self->{'buttonname'}, "VList", "Invisible");
    325303    }
    326304
Note: See TracChangeset for help on using the changeset viewer.