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

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

Record text now scanned and any URLS turned into HTML hyperlinks.

  • 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
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 $metavalue_utf8 = &util::hyperlink_text($metavalue_utf8);
93
94 $self->{'ppmd_table'} .= " <tr bgcolor=#b5d3cd>\n";
95 $self->{'ppmd_table'} .= " <td width=30%>\n";
96 $self->{'ppmd_table'} .= " $metaname\n";
97 $self->{'ppmd_table'} .= " </td>\n";
98 $self->{'ppmd_table'} .= " <td>\n";
99 $self->{'ppmd_table'} .= " $metavalue_utf8\n";
100 $self->{'ppmd_table'} .= " </td>\n";
101 $self->{'ppmd_table'} .= " </tr>\n";
102
103}
104
105sub close_prettyprint_metadata_table
106{
107 my $self = shift(@_);
108 $self->{'ppmd_table'} .= "</table>\n";
109
110 $self->set_filere_metadata("prettymd",$self->{'ppmd_table'});
111 $self->{'ppmd_table'} = undef;
112}
113
114sub set_filere_metadata
115{
116 my $self = shift(@_);
117 my ($full_mname,$md_content) = @_;
118
119 if (defined $self->{'saved_metadata'}->{$full_mname}) {
120 # accumulate - add value to existing value(s)
121 if (ref ($self->{'saved_metadata'}->{$full_mname}) eq "ARRAY") {
122 push (@{$self->{'saved_metadata'}->{$full_mname}}, $md_content);
123 } else {
124 $self->{'saved_metadata'}->{$full_mname} =
125 [$self->{'saved_metadata'}->{$full_mname}, $md_content];
126 }
127 } else {
128 # accumulate - add value into (currently empty) array
129 $self->{'saved_metadata'}->{$full_mname} = [$md_content];
130 }
131}
132
133
134sub get_filere_metadata
135{
136 my $self = shift(@_);
137 my ($full_mname) = @_;
138
139 return $self->{'saved_metadata'}->{$full_mname};
140}
141
142sub get_filere_metadata_head
143{
144 my $self = shift(@_);
145 my ($full_mname) = @_;
146
147 return $self->{'saved_metadata'}->{$full_mname}->[0];
148}
149
150
151
1521;
Note: See TracBrowser for help on using the repository browser.