Changeset 6081
- Timestamp:
- 2003-12-02T15:05:23+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/classify/DateList.pm
r6065 r6081 37 37 # 23/09/03 Added some more options -kjdon. 38 38 # these include: 39 # -nogroup years, which makes each yearan individual entry in39 # -nogroup, which makes each year (or year+month) an individual entry in 40 40 # the horizontal list and prevents compaction 41 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 … … 57 57 'reqd' => "no" }, 58 58 59 { 'name' => "nogroup years",60 'desc' => "{DateList.nogroup years}",59 { 'name' => "nogroup", 60 'desc' => "{DateList.nogroup}", 61 61 'type' => "flag", 62 62 'reqd' => "no" }, … … 90 90 91 91 my ($datemeta, $sortmeta); 92 $self->{'nogroup years'}=0;92 $self->{'nogroup'}=0; 93 93 if (!parsargv::parse(\@_, 94 94 q^bymonth^, \$self->{'bymonth'}, 95 q^nogroup years^, \$self->{'nogroupyears'},95 q^nogroup^, \$self->{'nogroup'}, 96 96 q^datemeta/.*/^, \$datemeta, 97 97 q^sortmeta/.*/^, \$sortmeta, … … 177 177 178 178 if (scalar (@$classlistref) <= 39 && 179 !$self->{'nogroup years'}) {$childtype = "DateList";}179 !$self->{'nogroup'}) {$childtype = "DateList";} 180 180 my $classifyinfo = $self->get_entry ("Date", $childtype, "Invisible"); 181 181 182 182 # don't need to do any splitting if there are less than 39 (max + min -1) 183 # classifications, unless nogroup yearsis specified184 if ((scalar @$classlistref) <= 39 && !$self->{'nogroup years'}) {183 # classifications, unless nogroup is specified 184 if ((scalar @$classlistref) <= 39 && !$self->{'nogroup'}) { 185 185 foreach $subOID (@$classlistref) { 186 186 push (@{$classifyinfo->{'contains'}}, {'OID'=>$subOID}); … … 192 192 if ($self->{'bymonth'}) { 193 193 # first split up the list into separate year+month classifications 194 foreach $classification (@$classlistref) { 195 my $date = $self->{'list'}->{$classification}; 196 $date =~ s/^(\d\d\d\d)(\d\d).*$/$1 _textmonth$2_/; 197 # sanity check if month is zero 198 if ($date =~ /00_$/) { 199 $date =~ s/^(\d\d\d\d).*$/$1/g; 194 195 if (!$self->{'nogroup'}) { # hlist of year+month pairs 196 # single level of classifications 197 foreach $classification (@$classlistref) { 198 my $date = $self->{'list'}->{$classification}; 199 $date =~ s/^(\d\d\d\d)(\d\d).*$/$1 _textmonth$2_/; 200 # sanity check if month is zero 201 if ($date =~ /00_$/) { 202 $date =~ s/^(\d\d\d\d).*$/$1/g; 203 } 204 $classhash->{$date} = [] unless defined $classhash->{$date}; 205 push (@{$classhash->{$date}}, $classification); 200 206 } 201 $classhash->{$date} = [] unless defined $classhash->{$date}; 202 push (@{$classhash->{$date}}, $classification); 203 } 207 208 } else { # don't group - individual years and months 209 foreach $classification (@$classlistref) { 210 my $date = $self->{'list'}->{$classification}; 211 $date =~ s/^(\d\d\d\d)(\d\d).*$/$1 _textmonth$2_/; 212 my ($year, $month)=($1,$2); 213 # sanity check if month is zero 214 if ($date =~ /00_$/) { 215 $date =~ s/^(\d\d\d\d).*$/$1/g; 216 } 217 # create subclass if it doesn't already exist 218 $classhash->{$year} = () unless defined $classhash->{$year}; 219 $classhash->{$year}->{$month} = [] 220 unless defined $classhash->{$year}->{$month}; 221 push (@{$classhash->{$year}->{$month}}, $classification); 222 } 223 # create hlist of years containing hlists of months 224 225 foreach my $subclass (sort {$a <=> $b} keys %$classhash) { 226 my $yearclassify = $self->get_entry($subclass, "HList"); 227 foreach my $subsubclass (sort {$a <=> $b} 228 (keys %{$classhash->{$subclass}})) { 229 my $monthname=$subsubclass; 230 if ($monthname >= 1 && $monthname <= 12) { 231 $monthname="_textmonth" . $monthname . "_"; 232 } 233 my $monthclassify=$self->get_entry($monthname, "DateList"); 234 push (@{$yearclassify->{'contains'}}, $monthclassify); 235 236 foreach $subsubOID 237 (@{$classhash->{$subclass}->{$subsubclass}}) { 238 push (@{$monthclassify->{'contains'}}, 239 {'OID'=>$subsubOID}); 240 } 241 } 242 push (@{$classifyinfo->{'contains'}}, $yearclassify); 243 } 244 # not sure if this is needed... AZCompactList has it :p 245 $classifyinfo->{'mdtype'}=$self->{'datemeta'}; 246 return $classifyinfo; 247 } # nogroup 204 248 } else { 249 # not by month 205 250 # first split up the list into separate year classifications 206 251 foreach $classification (@$classlistref) { … … 211 256 } 212 257 } 213 214 # only compact the list if nogroup yearsnot specified215 if (!$self->{'nogroup years'}) {258 259 # only compact the list if nogroup not specified 260 if (!$self->{'nogroup'}) { 216 261 $classhash = $self->compactlist ($classhash); 217 262 }
Note:
See TracChangeset
for help on using the changeset viewer.