Changeset 10218 for trunk/gsdl/perllib/classify/Hierarchy.pm
- Timestamp:
- 2005-07-06T15:27:45+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/classify/Hierarchy.pm
r9206 r10218 43 43 my $arguments = 44 44 [ { 'name' => "separator", 45 'desc' => "{ AutoHierarchy.separator}",45 'desc' => "{Hierarchy.separator}", 46 46 'type' => "regexp", 47 47 'deft' => "[\\\\\\\/|\\\\\\\|]", 48 48 'reqd' => "no" }, 49 49 { 'name' => "suppresslastlevel", 50 'desc' => "{ AutoHierarchy.suppresslastlevel}",50 'desc' => "{Hierarchy.suppresslastlevel}", 51 51 'type' => "flag", 52 52 'reqd' => "no" } ]; 53 53 54 54 my $options = { 'name' => "Hierarchy", 55 'desc' => "{ AutoHierarchy.desc}",55 'desc' => "{Hierarchy.desc}", 56 56 'abstract' => "no", 57 57 'inherits' => "yes", … … 60 60 61 61 sub 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); 93 70 94 71 # the hash that we use to build up the hierarchy … … 127 104 push(@{$current_pos->{'docs'}}, $doc_OID); 128 105 } 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 # } 135 114 } 136 115 } # foreach metadata … … 146 125 # are we sorting the list?? 147 126 my $nosort = 0; 148 if ( defined $self->{'sortname'} && $self->{'sortname'} eq "nosort") {127 if (!defined $self->{'sort'}) { 149 128 $nosort = 1; 150 129 } 151 130 152 131 my $metavalues = []; 153 132 # find all the metadata values … … 155 134 my $mvalues = $doc_obj->get_metadata($doc_obj->get_top_section(), $m); 156 135 next unless (@{$mvalues}); 157 if ($self->{' onlyfirst'}) {136 if ($self->{'firstvalueonly'}) { 158 137 # we only want the first metadata value 159 138 push (@$metavalues, $mvalues[0]); … … 169 148 #check for a sort element other than our metadata 170 149 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) { 174 152 $sortmeta = $doc_obj->get_source_filename(); 175 153 } else { 176 $sortmeta = $doc_obj->get_metadata_element($doc_obj->get_top_section(), $self->{'sort name'});154 $sortmeta = $doc_obj->get_metadata_element($doc_obj->get_top_section(), $self->{'sort'}); 177 155 if (defined $sortmeta) { 178 $sortmeta = &sorttools::format_metadata_for_sorting($self->{'sort name'}, $sortmeta, $doc_obj);156 $sortmeta = &sorttools::format_metadata_for_sorting($self->{'sort'}, $sortmeta, $doc_obj); 179 157 } 180 158 } … … 252 230 my @doc_list; 253 231 # 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'}})) { 255 233 @doc_list = @{$top_hash->{$key}->{'docs'}}; 256 } elsif ( !$nosort&& (keys %{$top_hash->{$key}->{'docs'}})) {234 } elsif (defined ($self->{'sort'}) && (keys %{$top_hash->{$key}->{'docs'}})) { 257 235 @doc_list = sort {$top_hash->{$key}->{'docs'}->{$a} 258 236 cmp $top_hash->{$key}->{'docs'}->{$b};} keys %{$top_hash->{$key}->{'docs'}}; … … 289 267 if ($self->{'path_hash'}) { 290 268 if ($self->{'hlist_at_top'}) { 291 $classification = $self->get_entry ($self->{' title'}, "HList", "Invisible");269 $classification = $self->get_entry ($self->{'buttonname'}, "HList", "Invisible"); 292 270 } 293 271 else { 294 $classification = $self->get_entry ($self->{' title'}, "VList", "Invisible");272 $classification = $self->get_entry ($self->{'buttonname'}, "VList", "Invisible"); 295 273 } 296 274 } … … 319 297 320 298 if ($self->{'hlist_at_top'}) { 321 $classifyinfo = $self->get_entry ($self->{' title'}, "HList", "Invisible");299 $classifyinfo = $self->get_entry ($self->{'buttonname'}, "HList", "Invisible"); 322 300 } 323 301 else { 324 $classifyinfo = $self->get_entry ($self->{' title'}, "VList", "Invisible");302 $classifyinfo = $self->get_entry ($self->{'buttonname'}, "VList", "Invisible"); 325 303 } 326 304
Note:
See TracChangeset
for help on using the changeset viewer.