Changeset 10979
- Timestamp:
- 2005-12-09T10:52:21+13:00 (18 years ago)
- Location:
- trunk/gsdl/perllib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/classify/DateList.pm
r10630 r10979 102 102 $self->{'metadata'} = "Date"; 103 103 } 104 104 # now can have comma separated list of Dates - we just use the first one (for now) 105 my @meta_list = split(/,/, $self->{"metadata"}); 106 $self->{'meta_list'} = \@meta_list; 107 105 108 return bless $self, $class; 106 109 } … … 117 120 118 121 my $doc_OID = $doc_obj->get_OID(); 119 my $date = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), $self->{'metadata'}); 122 123 # find the first available metadata 124 my $date; 125 foreach my $m (@{$self->{'meta_list'}}) { 126 $date = $doc_obj->get_metadata_element($doc_obj->get_top_section(), $m); 127 last if defined $date; 128 } 129 130 #my $date = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), $self->{'metadata'}); 131 if (!defined $date || $date eq "") { 132 # if this document doesn't contain Date element we won't 133 # include it in this classification 134 return; 135 } 120 136 121 137 my $sort_other = ""; … … 124 140 $sort_other = &sorttools::format_metadata_for_sorting($self->{'sort'}, $sort_other, $doc_obj) unless $self->{'no_metadata_formatting'}; 125 141 } 126 # if this document doesn't contain Date element we won't 127 # include it in this classification 128 if (defined $date && $date =~ /\d/) { 129 if (defined $self->{'list'}->{$doc_OID}) { 130 my $outhandle = $self->{'outhandle'}; 131 print $outhandle "WARNING: DateList::classify called multiple times for $doc_OID\n"; 132 } 133 134 $self->{'list'}->{$doc_OID} = "$date$sort_other"; 135 } 142 143 if (defined $self->{'list'}->{$doc_OID}) { 144 my $outhandle = $self->{'outhandle'}; 145 print $outhandle "WARNING: DateList::classify called multiple times for $doc_OID\n"; 146 } 147 148 $self->{'list'}->{$doc_OID} = "$date$sort_other"; 149 136 150 } 137 151 -
trunk/gsdl/perllib/strings.rb
r10978 r10979 428 428 DateList.desc:Classifier plugin for sorting by date. By default, sorts by 'Date' metadata. Date is assumed to be in the form yyyymmdd. 429 429 430 DateList.metadata:The metadata that contains the dates to classify by. The format is expected to be yyyymmdd. 430 DateList.metadata:The metadata that contains the dates to classify by. The format is expected to be yyyymmdd. Can be a comma separated list, in which case the first date found will be used. 431 431 432 432 DateList.reverse_sort:Sort the documents in reverse chronological order (newest first).
Note:
See TracChangeset
for help on using the changeset viewer.