source: trunk/gsdl/perllib/plugins/MetadataPass.pm@ 9823

Last change on this file since 9823 was 9361, checked in by davidb, 19 years ago

Tidied up code, removed commented out lines etc.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1###########################################################################
2#
3# MetadataPass.pm -- class to enhance plugins with generic metadata capabilities
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
26package MetadataPass;
27
28
29use BasPlug; # uses BasPlug, but is not inherited
30
31
32my $options = { 'name' => "MetadataPass",
33 'desc' => "{MetadataPass.desc}",
34 'abstract' => "yes",
35 'inherits' => "no" };
36
37
38sub new {
39 my $class = shift (@_);
40 my $plugin_name = shift (@_);
41
42 my $self = {};
43 $self->{'plugin_type'} = "MetadataPass";
44
45 $self->{'option_list'} = [ $options ];
46
47 return bless $self, $class;
48}
49
50sub init {
51}
52
53sub print_xml_usage
54{
55 BasPlug::print_xml_usage(@_);
56}
57
58sub print_xml
59{
60 BasPlug::print_xml(@_);
61}
62
63
64sub reset_saved_metadata {
65 my $self = shift(@_);
66
67 $self->{'saved_metadata'} = {};
68}
69
70
71sub get_saved_metadata {
72 my $self = shift(@_);
73
74 return $self->{'saved_metadata'};
75}
76
77sub open_prettyprint_metadata_table
78{
79 my $self = shift(@_);
80
81 my $att = "width=100% cellspacing=2";
82 my $style = "style=\'border-bottom: 4px solid #000080\'";
83
84 $self->{'ppmd_table'} = "\n<table $att $style>";
85}
86
87sub add_prettyprint_metadata_line
88{
89 my $self = shift(@_);
90 my ($metaname, $metavalue_utf8) = @_;
91
92 $self->{'ppmd_table'} .= " <tr bgcolor=#b5d3cd>\n";
93 $self->{'ppmd_table'} .= " <td width=30%>\n";
94 $self->{'ppmd_table'} .= " $metaname\n";
95 $self->{'ppmd_table'} .= " </td>\n";
96 $self->{'ppmd_table'} .= " <td>\n";
97 $self->{'ppmd_table'} .= " $metavalue_utf8\n";
98 $self->{'ppmd_table'} .= " </td>\n";
99 $self->{'ppmd_table'} .= " </tr>\n";
100
101}
102
103sub close_prettyprint_metadata_table
104{
105 my $self = shift(@_);
106 $self->{'ppmd_table'} .= "</table>\n";
107
108 $self->set_filere_metadata("prettymd",$self->{'ppmd_table'});
109 $self->{'ppmd_table'} = undef;
110}
111
112sub set_filere_metadata
113{
114 my $self = shift(@_);
115 my ($full_mname,$md_content) = @_;
116
117 if (defined $self->{'saved_metadata'}->{$full_mname}) {
118 # accumulate - add value to existing value(s)
119 if (ref ($self->{'saved_metadata'}->{$full_mname}) eq "ARRAY") {
120 push (@{$self->{'saved_metadata'}->{$full_mname}}, $md_content);
121 } else {
122 $self->{'saved_metadata'}->{$full_mname} =
123 [$self->{'saved_metadata'}->{$full_mname}, $md_content];
124 }
125 } else {
126 # accumulate - add value into (currently empty) array
127 $self->{'saved_metadata'}->{$full_mname} = [$md_content];
128 }
129}
130
131
132sub get_filere_metadata
133{
134 my $self = shift(@_);
135 my ($full_mname) = @_;
136
137 return $self->{'saved_metadata'}->{$full_mname};
138}
139
140sub get_filere_metadata_head
141{
142 my $self = shift(@_);
143 my ($full_mname) = @_;
144
145 return $self->{'saved_metadata'}->{$full_mname}->[0];
146}
147
148
149
1501;
Note: See TracBrowser for help on using the repository browser.