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

Last change on this file since 10254 was 10254, checked in by kjdon, 19 years ago

added 'use strict' to all plugins, and made modifications (mostly adding 'my') to make them compile

  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 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
65
66sub reset_saved_metadata {
67 my $self = shift(@_);
68
69 $self->{'saved_metadata'} = {};
70}
71
72
73sub get_saved_metadata {
74 my $self = shift(@_);
75
76 return $self->{'saved_metadata'};
77}
78
79sub open_prettyprint_metadata_table
80{
81 my $self = shift(@_);
82
83 my $att = "width=100% cellspacing=2";
84 my $style = "style=\'border-bottom: 4px solid #000080\'";
85
86 $self->{'ppmd_table'} = "\n<table $att $style>";
87}
88
89sub add_prettyprint_metadata_line
90{
91 my $self = shift(@_);
92 my ($metaname, $metavalue_utf8) = @_;
93
94 $metavalue_utf8 = &util::hyperlink_text($metavalue_utf8);
95
96 $self->{'ppmd_table'} .= " <tr bgcolor=#b5d3cd>\n";
97 $self->{'ppmd_table'} .= " <td width=30%>\n";
98 $self->{'ppmd_table'} .= " $metaname\n";
99 $self->{'ppmd_table'} .= " </td>\n";
100 $self->{'ppmd_table'} .= " <td>\n";
101 $self->{'ppmd_table'} .= " $metavalue_utf8\n";
102 $self->{'ppmd_table'} .= " </td>\n";
103 $self->{'ppmd_table'} .= " </tr>\n";
104
105}
106
107sub close_prettyprint_metadata_table
108{
109 my $self = shift(@_);
110 $self->{'ppmd_table'} .= "</table>\n";
111
112 $self->set_filere_metadata("prettymd",$self->{'ppmd_table'});
113 $self->{'ppmd_table'} = undef;
114}
115
116sub set_filere_metadata
117{
118 my $self = shift(@_);
119 my ($full_mname,$md_content) = @_;
120
121 if (defined $self->{'saved_metadata'}->{$full_mname}) {
122 # accumulate - add value to existing value(s)
123 if (ref ($self->{'saved_metadata'}->{$full_mname}) eq "ARRAY") {
124 push (@{$self->{'saved_metadata'}->{$full_mname}}, $md_content);
125 } else {
126 $self->{'saved_metadata'}->{$full_mname} =
127 [$self->{'saved_metadata'}->{$full_mname}, $md_content];
128 }
129 } else {
130 # accumulate - add value into (currently empty) array
131 $self->{'saved_metadata'}->{$full_mname} = [$md_content];
132 }
133}
134
135
136sub get_filere_metadata
137{
138 my $self = shift(@_);
139 my ($full_mname) = @_;
140
141 return $self->{'saved_metadata'}->{$full_mname};
142}
143
144sub get_filere_metadata_head
145{
146 my $self = shift(@_);
147 my ($full_mname) = @_;
148
149 return $self->{'saved_metadata'}->{$full_mname}->[0];
150}
151
152
153
1541;
Note: See TracBrowser for help on using the repository browser.