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

Last change on this file since 12970 was 12970, checked in by kjdon, 18 years ago

set_keepold and self->{'keepold'} have been changed to set_incremental and self->{'incremental'}

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