- Timestamp:
- 2000-07-13T10:21:53+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New_Config_Format-branch/gsdl/perllib/classify/SectionList.pm
r838 r1279 27 27 # (excluding top level) rather than just top level document 28 28 # itself 29 # options are:30 # metadata=Metaname -- (optional) all documents with Metaname metadata31 # will be included in list. if not included all documents32 # will be included in list.33 # sort=Meta -- (optional) sort documents in list alphabetically by34 # Meta. by default it will sort by Metaname, if neither35 # are set documents will be in build (random) order.36 # Meta may be Filename to sort by original filename or37 # nosort to force not to sort38 # title=Title -- (optional) the title field for this classification.39 # if not included title field will be Metaname.40 # if metadata is also not included title will be 'List'41 29 42 30 package SectionList; 43 31 32 use List; 44 33 use sorttools; 45 34 46 sub new { 47 my ($class, @options) = @_; 48 49 my $list = []; 50 my ($metaname, $title, $sortname); 51 52 foreach $option (@options) { 53 if ($option =~ /^metadata=(.*)$/i) { 54 $metaname = $1; 55 $list = {}; 56 } elsif ($option =~ /^title=(.*)$/i) { 57 $title = $1; 58 } elsif ($option =~ /^sort=(.*)$/i) { 59 $sortname = $1; 60 } 61 } 62 63 if (!defined $title) { 64 if (defined $metaname) { 65 $title = $metaname; 66 } else { 67 $title = 'List'; 68 } 69 } 70 71 if (defined $sortname && $sortname =~ /^nosort$/i) { 72 $sortname = undef; 73 } elsif (!defined $sortname && defined $metaname) { 74 $sortname = $metaname; 75 } 76 77 return bless { 78 'list'=>$list, 79 'metaname' => $metaname, 80 'title' => $title, 81 'sortname' => $sortname 82 }, $class; 83 } 84 85 sub init { 86 my $self = shift (@_); 87 88 if (defined $self->{'sortname'}) { 89 $self->{'list'} = {}; 90 } else { 91 $self->{'list'} = []; 92 } 35 sub BEGIN { 36 @ISA = ('List'); 93 37 } 94 38 95 39 sub classify { 96 40 my $self = shift (@_); 97 my ($doc_obj, @options) = @_;41 my ($doc_obj, @options) = @_; 98 42 99 43 my $thissection = undef; … … 175 119 } 176 120 177 sub get_classify_info {178 my $self = shift (@_);179 180 my @list = ();181 if (defined $self->{'sortname'}) {182 if (keys %{$self->{'list'}}) {183 @list = sort {$self->{'list'}->{$a}184 cmp $self->{'list'}->{$b};} keys %{$self->{'list'}};185 }186 } else {187 @list = @{$self->{'list'}};188 }189 190 # organise into classification structure191 my %classifyinfo = ('thistype'=>'Invisible',192 'childtype'=>'VList',193 'Title'=>$self->{'title'},194 'contains'=>[]);195 foreach $OID (@list) {196 push (@{$classifyinfo{'contains'}}, {'OID'=>$OID});197 }198 199 return \%classifyinfo;200 }201 202 203 121 1;
Note:
See TracChangeset
for help on using the changeset viewer.