source: main/tags/2.30/gsdl/perllib/classify/AZSectionList.pm@ 23841

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

Minor bug fix

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1###########################################################################
2#
3# AZSectionList.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# classifier plugin for sorting sections alphabetically
27
28# this is very similar to AZList except it sorts by
29# section level metadata (excluding the top level)
30# instead of just top level metadata
31
32# the only change is to the classify() subroutine which
33# must now iterate through each section, adding each
34# to the classification
35
36package AZSectionList;
37
38use AZList;
39use sorttools;
40
41sub BEGIN {
42 @ISA = ('AZList');
43}
44
45sub new {
46 my ($class, @options) = @_;
47 my $self = new AZList ($class, @_);
48 return bless $self, $class;
49}
50
51sub classify {
52 my $self = shift (@_);
53 my ($doc_obj) = @_;
54
55 my $doc_OID = $doc_obj->get_OID();
56 my $thissection = $doc_obj->get_next_section ($doc_obj->get_top_section());
57
58 while (defined $thissection) {
59 $self->classify_section ($thissection, $doc_obj);
60 $thissection = $doc_obj->get_next_section ($thissection);
61 }
62}
63
64sub classify_section {
65 my $self = shift (@_);
66 my ($section, $doc_obj) = @_;
67
68 my $doc_OID = $doc_obj->get_OID();
69 my $metavalue = $doc_obj->get_metadata_element ($section, $self->{'metaname'});
70
71 # if this section doesn't contain the metadata element we're
72 # sorting by we won't include it in this classification
73 if (defined $metavalue && $metavalue ne "") {
74 if ($self->{'metaname'} eq 'Creator') {
75 &sorttools::format_string_name_english (\$metavalue);
76 } else {
77 &sorttools::format_string_english (\$metavalue);
78 }
79 if (defined $self->{'list'}->{"$doc_OID.$section"}) {
80 my $outhandle = $self->{'outhandle'};
81 print $outhandle "WARNING: AZSectionList::classify called multiple times " .
82 "for $doc_OID.$section\n";
83 }
84 $self->{'list'}->{"$doc_OID.$section"} = $metavalue;
85 }
86}
87
88
891;
Note: See TracBrowser for help on using the repository browser.