Changeset 6806
- Timestamp:
- 2004-02-16T17:22:58+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/classify/AZList.pm
r6761 r6806 35 35 @ISA = ('BasClas'); 36 36 } 37 38 use strict; 37 39 38 40 my $arguments = … … 230 232 # don't need to do any splitting if there are less than 39 (max + min -1) classifications 231 233 if ((scalar @$classlistref) <= 39) { 232 foreach $subOID (@$classlistref) {234 foreach my $subOID (@$classlistref) { 233 235 push (@{$classifyinfo->{'contains'}}, {'OID'=>$subOID}); 234 236 } … … 237 239 238 240 # first split up the list into separate A-Z and 0-9 classifications 239 foreach $classification (@$classlistref) {241 foreach my $classification (@$classlistref) { 240 242 my $title = $self->{'list'}->{$classification}; 241 243 … … 255 257 256 258 my @tmparr = (); 257 foreach $subsection (sort keys (%$classhash)) {259 foreach my $subsection (sort keys (%$classhash)) { 258 260 push (@tmparr, $subsection); 259 261 } … … 266 268 } 267 269 268 foreach $subclass (@tmparr) {270 foreach my $subclass (@tmparr) { 269 271 my $tempclassify = $self->get_entry($subclass, "VList"); 270 foreach $subsubOID (@{$classhash->{$subclass}}) {272 foreach my $subsubOID (@{$classhash->{$subclass}}) { 271 273 push (@{$tempclassify->{'contains'}}, {'OID'=>$subsubOID}); 272 274 } … … 282 284 my $compactedhash = {}; 283 285 my @currentOIDs = (); 284 my $currentfirstletter = ""; 285 my $currentlastletter = ""; 286 my $lastkey = ""; 286 my $currentfirstletter = ""; # start of working bin 287 my $currentlastletter = ""; # end of working bin 288 my $lastkey = ""; # the name of the last completed key 287 289 288 290 # minimum and maximum documents to be displayed per page. … … 294 296 my $max = 30; 295 297 296 foreach $subsection (sort keys %$classhashref) {298 foreach my $subsection (sort keys %$classhashref) { 297 299 if ($subsection eq '0-9') { 300 # leave this bin as-is... copy it straight across 298 301 @{$compactedhash->{$subsection}} = @{$classhashref->{$subsection}}; 299 302 next; … … 302 305 if ((scalar (@currentOIDs) < $min) || 303 306 ((scalar (@currentOIDs) + scalar (@{$classhashref->{$subsection}})) <= $max)) { 307 # add this letter to the bin and continue 304 308 push (@currentOIDs, @{$classhashref->{$subsection}}); 305 309 $currentlastletter = $subsection; 306 310 } else { 307 311 # too many or too few for a separate bin 308 312 if ($currentfirstletter eq $currentlastletter) { 309 313 @{$compactedhash->{$currentfirstletter}} = @currentOIDs; … … 314 318 } 315 319 if (scalar (@{$classhashref->{$subsection}}) >= $max) { 320 # this key is now complete. Start a new one 316 321 $compactedhash->{$subsection} = $classhashref->{$subsection}; 317 322 @currentOIDs = (); … … 329 334 # add final sub-classification 330 335 # BUG FIX: don't add anything if there are no currentOIDs (thanks to Don Gourley) 331 if (@currentOIDS) { 332 if (scalar (@currentOIDs) < $min) { 333 my ($newkey) = $lastkey =~ /^(.)/; 334 @currentOIDs = (@{$compactedhash->{$lastkey}}, @currentOIDs); 335 delete $compactedhash->{$lastkey}; 336 @{$compactedhash->{"$newkey-$currentlastletter"}} = @currentOIDs; 336 if (! scalar(@currentOIDs)) {return $compactedhash;} 337 338 if (scalar (@currentOIDs) < $min) { 339 my ($newkey) = $lastkey =~ /^(.)/; 340 @currentOIDs = (@{$compactedhash->{$lastkey}}, @currentOIDs); 341 delete $compactedhash->{$lastkey}; 342 @{$compactedhash->{"$newkey-$currentlastletter"}} = @currentOIDs; 343 } else { 344 if ($currentfirstletter eq $currentlastletter) { 345 @{$compactedhash->{$currentfirstletter}} = @currentOIDs; 337 346 } 338 347 else { 339 if ($currentfirstletter eq $currentlastletter) { 340 @{$compactedhash->{$currentfirstletter}} = @currentOIDs; 341 } 342 else { 343 @{$compactedhash->{"$currentfirstletter-$currentlastletter"}} = @currentOIDs; 344 } 348 @{$compactedhash->{"$currentfirstletter-$currentlastletter"}} = 349 @currentOIDs; 345 350 } 346 351 }
Note:
See TracChangeset
for help on using the changeset viewer.