1 |
#____________________________________________________________________
|
2 |
# File: ActiveDoc::SimpleXMLURLDoc.pm
|
3 |
#____________________________________________________________________
|
4 |
#
|
5 |
# Author: Shaun Ashby <Shaun.Ashby@cern.ch>
|
6 |
# Update: 2005-12-02 17:44:08+0100
|
7 |
# Revision: $Id$
|
8 |
#
|
9 |
# Copyright: 2005 (C) Shaun Ashby
|
10 |
#
|
11 |
#--------------------------------------------------------------------
|
12 |
|
13 |
=head1 NAME
|
14 |
|
15 |
ActiveDoc::SimpleXMLURLDoc - Base class for URL-based SCRAM documents.
|
16 |
|
17 |
=head1 SYNOPSIS
|
18 |
|
19 |
my $obj = ActiveDoc::SimpleXMLURLDoc->new();
|
20 |
|
21 |
=head1 DESCRIPTION
|
22 |
|
23 |
Any document class inheriting from ActiveDoc::SimpleXMLURLDoc will have access to
|
24 |
URL handling.
|
25 |
|
26 |
=head1 METHODS
|
27 |
|
28 |
=over
|
29 |
|
30 |
=cut
|
31 |
|
32 |
package ActiveDoc::SimpleXMLURLDoc;
|
33 |
use ActiveDoc::SimpleXMLDoc;
|
34 |
use URL::URLhandler;
|
35 |
require 5.004;
|
36 |
use Exporter;
|
37 |
use vars qw(@ISA);
|
38 |
|
39 |
@ISA=qw(Exporter ActiveDoc::SimpleXMLDoc);
|
40 |
@EXPORT_OK=qw( );
|
41 |
|
42 |
sub new()
|
43 |
{
|
44 |
###############################################################
|
45 |
# new #
|
46 |
###############################################################
|
47 |
# modified : Fri Dec 2 17:44:11 2005 / SFA #
|
48 |
# params : #
|
49 |
# : #
|
50 |
# function : #
|
51 |
# : #
|
52 |
###############################################################
|
53 |
my $proto=shift;
|
54 |
my $class=ref($proto) || $proto;
|
55 |
my ($urlcache,$context,@defhandlers)=@_;
|
56 |
my $self= bless($proto->SUPER::new($context,@defhandlers),$class);
|
57 |
$self->{CONTEXT}=$context;
|
58 |
# Register supported tags for this doc class, and specify which
|
59 |
# attributes should be checked for:
|
60 |
my $nested = 1;
|
61 |
my $unnested = 0;
|
62 |
my %recognised_tags = ('base' => [ { 'url' => 'REQUIRED' }, $nested ],
|
63 |
'download' => [ { 'url' => 'REQUIRED', 'name' => 'OPTION' }, $unnested ]);
|
64 |
|
65 |
# Register these recognised tags to the base class (which registers them
|
66 |
# to the container class):
|
67 |
$self->register_handlers_(\%recognised_tags);
|
68 |
|
69 |
# Set up a URL cache:
|
70 |
$self->cache($urlcache);
|
71 |
|
72 |
return $self;
|
73 |
}
|
74 |
|
75 |
sub cache
|
76 |
{
|
77 |
my $self=shift;
|
78 |
|
79 |
if ( @_ )
|
80 |
{
|
81 |
$self->{cache}=shift;
|
82 |
# $self->{urlhandler}=URL::URLhandler->new($self->{cache});
|
83 |
}
|
84 |
|
85 |
return $self->{cache};
|
86 |
}
|
87 |
|
88 |
# sub expandurl
|
89 |
# {
|
90 |
# my $self=shift;
|
91 |
# my $urlstring=shift;
|
92 |
|
93 |
# return $self->{urlhandler}->expandurl($urlstring);
|
94 |
# }
|
95 |
|
96 |
# sub urldownload
|
97 |
# {
|
98 |
# my $self=shift;
|
99 |
# my $urlstring=shift;
|
100 |
|
101 |
# ($fullurl,$filename)=$self->{urlhandler}->download($urlstring, @_);
|
102 |
# if ( ( ! defined $filename ) || ( $filename eq "" ) )
|
103 |
# {
|
104 |
# $self->parseerror("Failed to get $fullurl");
|
105 |
# }
|
106 |
# return ($fullurl,$filename);
|
107 |
# }
|
108 |
|
109 |
# sub urlget
|
110 |
# {
|
111 |
# my $self=shift;
|
112 |
# my $urlstring=shift;
|
113 |
|
114 |
# ($fullurl,$filename)=$self->{urlhandler}->get($urlstring, @_);
|
115 |
|
116 |
# if ( ( ! defined $filename ) || ( $filename eq "" ) )
|
117 |
# {
|
118 |
# $self->parseerror("Failed to get $fullurl");
|
119 |
# }
|
120 |
# return ($fullurl,$filename);
|
121 |
# }
|
122 |
|
123 |
1;
|
124 |
|
125 |
=back
|
126 |
|
127 |
=head1 AUTHOR/MAINTAINER
|
128 |
|
129 |
Shaun ASHBY
|
130 |
|
131 |
=cut
|