Changeset 5532 for trunk/gsdl/perllib/classify/DateList.pm
- Timestamp:
- 2003-09-25T04:32:58+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/classify/DateList.pm
r4873 r5532 35 35 # 12/05/02 Added usage datastructure - John Thompson 36 36 37 # 23/09/03 Added some more options -kjdon. 38 # these include: 39 # -nogroupyears, which makes each year an individual entry in 40 # the horizontal list and prevents compaction 41 # -datemeta, use a different metadata for the date (instead of Date), still expects yyyymmdd format. this affects display cos greenstone displays Date metadata as dd month yyyy, whereas any other date metadata is displayed as yyyymmdd - this needs fixing 42 # -sortmeta specifies an additional metadata to use in sorting, will take affect when two docs have the same date. 43 37 44 package DateList; 38 45 … … 48 55 'desc' => "{DateList.bymonth}", 49 56 'type' => "flag", 50 'reqd' => "no" } ]; 57 'reqd' => "no" }, 58 59 { 'name' => "nogroupyears", 60 'desc' => "{DateList.nogroupyears}", 61 'type' => "flag", 62 'reqd' => "no" }, 63 { 'name' => "datemeta", 64 'desc' => "{DateList.datemeta}", 65 'type' => "metadata", 66 'deft' => "Date", 67 'reqd' => "no" } , 68 { 'name' => "sortmeta", 69 'desc' => "{DateList.sortmeta}", 70 'type' => "metadata", 71 'reqd' => "no" } , 72 73 ]; 51 74 52 75 my $options = { 'name' => "DateList", 53 'desc' => "Classifier plugin for sorting by date. Alwayssorts by 'Date' metadata. Date is assumed to be in the form yyyymmdd.",76 'desc' => "Classifier plugin for sorting by date. By default, sorts by 'Date' metadata. Date is assumed to be in the form yyyymmdd.", 54 77 'inherits' => "Yes", 55 78 'args' => $arguments }; … … 79 102 80 103 $self->{'list'} = {}; 104 105 my ($datemeta, $sortmeta); 81 106 if (!parsargv::parse(\@_, 82 107 q^bymonth^, \$self->{'bymonth'}, 108 q^nogroupyears^, \$self->{'nogroupyears'}, 109 q^datemeta/.*/^, \$datemeta, 110 q^sortmeta/.*/^, \$sortmeta, 83 111 "allow_extra_options")) { 84 112 $self->print_txt_usage(""); # Use default resource bundle 85 113 die "\n"; 86 114 } 115 116 if (!defined $datemeta || $datemeta eq "") { 117 $datemeta = "Date"; 118 } 119 $self->{'datemeta'} = $datemeta; 120 121 if (defined $sortmeta && $sortmeta ne "") { 122 $self->{'sortmeta'} = $sortmeta; 123 } 87 124 return bless $self, $class; 88 125 } … … 99 136 100 137 my $doc_OID = $doc_obj->get_OID(); 101 my $date = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), 'Date'); 102 138 my $date = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), $self->{'datemeta'}); 139 140 my $sort_other = ""; 141 if (defined $self->{'sortmeta'} && $self->{'sortmeta'} ne "") { 142 $sort_other = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), $self->{'sortmeta'}); 143 } 103 144 # if this document doesn't contain Date element we won't 104 145 # include it in this classification … … 108 149 print $outhandle "WARNING: DateList::classify called multiple times for $doc_OID\n"; 109 150 } 110 $self->{'list'}->{$doc_OID} = $date; 151 152 153 $self->{'list'}->{$doc_OID} = "$date$sort_other"; 111 154 } 112 155 } … … 145 188 # top level 146 189 my $childtype = "HList"; 147 if (scalar (@$classlistref) <= 39 ) {$childtype = "DateList";}190 if (scalar (@$classlistref) <= 39 && !defined $self->{'nogroupyears'}) {$childtype = "DateList";} 148 191 my $classifyinfo = $self->get_entry ("Date", $childtype, "Invisible"); 149 192 150 # don't need to do any splitting if there are less than 39 (max + min -1) classifications 151 if ((scalar @$classlistref) <= 39 ) {193 # don't need to do any splitting if there are less than 39 (max + min -1) classifications, unless nogroupyears is specified 194 if ((scalar @$classlistref) <= 39 && !defined $self->{'nogroupyears'}) { 152 195 foreach $subOID (@$classlistref) { 153 196 push (@{$classifyinfo->{'contains'}}, {'OID'=>$subOID}); … … 178 221 } 179 222 } 180 $classhash = $self->compactlist ($classhash); 181 223 224 # only compact the list if nogroupyears not specified 225 if ( !defined $self->{'nogroupyears'}) { 226 $classhash = $self->compactlist ($classhash); 227 } 182 228 foreach $subclass (sort keys %$classhash) { 183 229 my $tempclassify = $self->get_entry($subclass, "DateList");
Note:
See TracChangeset
for help on using the changeset viewer.