source: gsdl/trunk/perllib/plugouts/GAPlugout.pm@ 17200

Last change on this file since 17200 was 13172, checked in by kjdon, 17 years ago

Moved all printing stuff out of doc.pm.
docprint now prints a GA representation of a doc obj - use &docprint::get_section_xml instead of $doc_obj->buffer_section_xml or $doc_obj->output_section.
Most of the code has been moved into plugouts, except for the bit thats gone to docprint.pm.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1###########################################################################
2#
3# GAPlugout.pm -- the plugout module for Greenstone Archives
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) 2006 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 GAPlugout;
27
28use strict;
29no strict 'refs';
30no strict 'subs';
31
32eval {require bytes};
33use util;
34use BasPlugout;
35use docprint;
36
37sub BEGIN {
38 @GAPlugout::ISA = ('BasPlugout');
39}
40
41my $arguments = [];
42
43my $options = { 'name' => "GAPlugout",
44 'desc' => "{GAPlugout.desc}",
45 'abstract' => "no",
46 'inherits' => "yes" };
47
48sub new {
49 my ($class) = shift (@_);
50 my ($plugoutlist, $inputargs,$hashArgOptLists) = @_;
51 push(@$plugoutlist, $class);
52
53 if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
54 if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
55
56 my $self = (defined $hashArgOptLists)? new BasPlugout($plugoutlist,$inputargs,$hashArgOptLists): new BasPlugout($plugoutlist,$inputargs);
57
58 return bless $self, $class;
59}
60
61sub saveas {
62 my $self = shift (@_);
63 my ($doc_obj,$doc_dir) = @_;
64
65 my $outhandler;
66 if ($self->{'debug'}) {
67 $outhandler = STDOUT;
68 # can we do the xslt and still do debug mode?
69 }
70 else {
71 my $output_dir = $self->get_output_dir();
72 &util::mk_all_dir ($output_dir) unless -e $output_dir;
73
74 my $working_dir = &util::filename_cat ($output_dir, $doc_dir);
75 &util::mk_all_dir ($working_dir) unless -e $working_dir;
76
77 $self->process_assoc_files ($doc_obj, $doc_dir, '');
78
79 my $output_file = util::filename_cat ($working_dir, "doc.xml");
80
81 $self->open_xslt_pipe($output_file, $self->{'xslt_file'});
82
83
84 if (defined $self->{'xslt_writer'}){
85 $outhandler = $self->{'xslt_writer'};
86 }
87 else{
88 $outhandler = $self->get_output_handler($output_file);
89 }
90 }
91
92 $self->output_xml_header($outhandler,"Archive");
93 my $section_output = &docprint::get_section_xml($doc_obj, $doc_obj->get_top_section());
94 print $outhandler $section_output;
95 $self->output_xml_footer($outhandler,"Archive");
96
97 if (!$self->{'debug'}) {
98 if (defined $self->{'xslt_writer'}){
99 $self->close_xslt_pipe();
100 }
101 else {
102 close($outhandler);
103 }
104
105 $self->{'short_doc_file'} = util::filename_cat ($doc_dir, "doc.xml");
106
107 $self->store_output_info_reference($doc_obj);
108 }
109}
110
111
112
1131;
114
Note: See TracBrowser for help on using the repository browser.