source: branches/New_Config_Format-branch/gsdl/perllib/classify/SectionList.pm@ 1279

Last change on this file since 1279 was 1279, checked in by sjboddie, 24 years ago

merged changes to trunk into New_Config_Format branch

  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1###########################################################################
2#
3# SectionList.pm --
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26# Same as List classifier but includes all sections of document
27# (excluding top level) rather than just top level document
28# itself
29
30package SectionList;
31
32use List;
33use sorttools;
34
35sub BEGIN {
36 @ISA = ('List');
37}
38
39sub classify {
40 my $self = shift (@_);
41 my ($doc_obj, @options) = @_;
42
43 my $thissection = undef;
44
45 my $option;
46 foreach $option (@options)
47 {
48 if ($option =~ m/^section=(\d+)$/i)
49 {
50 $thissection = $1;
51 }
52 }
53
54 my $sortmeta = "";
55 if (defined $self->{'sortname'}) {
56 if ($self->{'sortname'} =~ /^filename$/i) {
57 $sortmeta = $doc_obj->get_source_filename();
58 } else {
59 $sortmeta = $doc_obj->get_metadata_element($doc_obj->get_top_section(),
60 $self->{'sortname'});
61 if ($self->{'sortname'} eq "Creator") {
62 &sorttools::format_string_name_english (\$sortmeta);
63 } else {
64 &sorttools::format_string_english (\$sortmeta);
65 }
66 }
67 $sortmeta = "" unless defined $sortmeta;
68 }
69
70 if (!defined $thissection)
71 {
72 $thissection = $doc_obj->get_next_section ($doc_obj->get_top_section());
73 while (defined $thissection) {
74 $self->classify_section($thissection, $doc_obj, $sortmeta);
75 $thissection = $doc_obj->get_next_section ($thissection);
76 }
77 }
78 else
79 {
80 $self->classify_section($thissection, $doc_obj, $sortmeta);
81 }
82}
83
84sub classify_section {
85 my $self = shift (@_);
86 my ($section, $doc_obj, $sortmeta) = @_;
87
88 my $doc_OID = $doc_obj->get_OID();
89 $sortmeta = "" unless defined $sortmeta;
90
91 if (defined $self->{'sortname'}) {
92 if (defined $self->{'metaname'}) {
93
94 my $metavalue = $doc_obj->get_metadata_element ($section, $self->{'metaname'});
95 if (defined $metavalue) {
96 if (defined $self->{'list'}->{"$doc_OID.$section"}) {
97 print STDERR "WARNING: SectionList::classify called multiple times for $doc_OID.$section\n";
98 }
99 $self->{'list'}->{"$doc_OID.$section"} = $sortmeta;
100 }
101 } else {
102 if (defined $self->{'list'}->{"$doc_OID.$section"}) {
103 print STDERR "WARNING: SectionList::classify called multiple times for $doc_OID.$section\n";
104 }
105 $self->{'list'}->{"$doc_OID.$section"} = $sortmeta;
106 }
107
108 } else {
109 if (defined $self->{'metaname'}) {
110
111 my $metavalue = $doc_obj->get_metadata_element ($section, $self->{'metaname'});
112 if (defined $metavalue) {
113 push (@{$self->{'list'}}, "$doc_OID.$section");
114 }
115 } else {
116 push (@{$self->{'list'}}, "$doc_OID.$section");
117 }
118 }
119}
120
1211;
Note: See TracBrowser for help on using the repository browser.