[9360] | 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 |
|
---|
| 26 | package MetadataPass;
|
---|
| 27 |
|
---|
[10254] | 28 | use strict;
|
---|
| 29 | no strict 'refs'; # allow filehandles to be variables and viceversa
|
---|
[9360] | 30 |
|
---|
[15872] | 31 | use PrintInfo; # uses PrintInfo, but is not inherited
|
---|
[9360] | 32 |
|
---|
| 33 |
|
---|
| 34 | my $options = { 'name' => "MetadataPass",
|
---|
[9361] | 35 | 'desc' => "{MetadataPass.desc}",
|
---|
[9360] | 36 | 'abstract' => "yes",
|
---|
| 37 | 'inherits' => "no" };
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | sub 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 |
|
---|
| 52 | sub init {
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | sub print_xml_usage
|
---|
| 56 | {
|
---|
[15872] | 57 | PrintInfo::print_xml_usage(@_);
|
---|
[9360] | 58 | }
|
---|
| 59 |
|
---|
| 60 | sub print_xml
|
---|
| 61 | {
|
---|
[15872] | 62 | PrintInfo::print_xml(@_);
|
---|
[9360] | 63 | }
|
---|
| 64 |
|
---|
[12970] | 65 | sub set_incremental
|
---|
[10501] | 66 | {
|
---|
[15872] | 67 | PrintInfo::set_incremental(@_);
|
---|
[10501] | 68 | }
|
---|
[9360] | 69 |
|
---|
| 70 | sub reset_saved_metadata {
|
---|
| 71 | my $self = shift(@_);
|
---|
| 72 |
|
---|
| 73 | $self->{'saved_metadata'} = {};
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 |
|
---|
| 77 | sub get_saved_metadata {
|
---|
| 78 | my $self = shift(@_);
|
---|
| 79 |
|
---|
| 80 | return $self->{'saved_metadata'};
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | sub 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 |
|
---|
| 93 | sub add_prettyprint_metadata_line
|
---|
| 94 | {
|
---|
| 95 | my $self = shift(@_);
|
---|
| 96 | my ($metaname, $metavalue_utf8) = @_;
|
---|
| 97 |
|
---|
[9959] | 98 | $metavalue_utf8 = &util::hyperlink_text($metavalue_utf8);
|
---|
| 99 |
|
---|
[9360] | 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 |
|
---|
| 111 | sub 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 |
|
---|
| 120 | sub 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 |
|
---|
| 140 | sub get_filere_metadata
|
---|
| 141 | {
|
---|
| 142 | my $self = shift(@_);
|
---|
| 143 | my ($full_mname) = @_;
|
---|
| 144 |
|
---|
| 145 | return $self->{'saved_metadata'}->{$full_mname};
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | sub 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 |
|
---|
| 158 | 1;
|
---|