1 |
#
|
2 |
# The base functionality for the ActiveDocument - inherits from Basetags
|
3 |
#
|
4 |
# Inherits from BaseTags
|
5 |
# --------
|
6 |
# Interface
|
7 |
# ---------
|
8 |
# new(filename, DOChandler): create a new object based on a file and
|
9 |
# associate with a base DOChandler
|
10 |
# parse() : parse the input file
|
11 |
# include(url) : Activate include file mechanism, returns the object ref if OK
|
12 |
# treenode() : return the associated TreeNode object reference
|
13 |
# getincludeObjectStore : Return a pointer to the ObectStore that contains all
|
14 |
# included objects
|
15 |
# find(string) : find the object reference related to string in the associated
|
16 |
# tree. Mechanism for getting object references
|
17 |
# _addgroup() : Add group functionality to document
|
18 |
# parseerror(String) : Report an error to the user
|
19 |
# userinterface() : return the default User Interface object
|
20 |
# checktag($hashref, param , tagname) : Check a hash returned from switcher
|
21 |
# for a given parameter
|
22 |
|
23 |
package ActiveDoc::ActiveDoc;
|
24 |
require 5.001;
|
25 |
use ActiveDoc::DOChandler;
|
26 |
use ActiveDoc::TreeNode;
|
27 |
use ActiveDoc::UserQuery;
|
28 |
use ObjectStoreCont;
|
29 |
|
30 |
@ISA = qw(ActiveDoc::BaseTags);
|
31 |
|
32 |
# Initialise
|
33 |
sub _init {
|
34 |
my $self=shift;
|
35 |
my $DOChandler=shift;
|
36 |
my $OC=shift;
|
37 |
|
38 |
$self->_addurl();
|
39 |
$self->{urlhandler}->setcache($DOChandler->defaultcache());
|
40 |
$self->{treenode}=ActiveDoc::TreeNode->new();
|
41 |
$self->{dochandler}=$DOChandler;
|
42 |
$self->{UserQuery}=$DOChandler->{UserQuery};
|
43 |
$self->{tags}->addtag("Use", \&Use_Start, "", "");
|
44 |
# Add the minimal functionality tag - feel free to override
|
45 |
$self->{tags}->addtag("Include", \&Include_Start, "", "");
|
46 |
$self->init();
|
47 |
}
|
48 |
|
49 |
sub init {
|
50 |
# Dummy Routine - override for derrived classes
|
51 |
}
|
52 |
#
|
53 |
# use mechanism
|
54 |
#
|
55 |
sub include {
|
56 |
my $self=shift;
|
57 |
my $url=shift;
|
58 |
my $linkfile=shift;
|
59 |
my $filename;
|
60 |
my $obj;
|
61 |
|
62 |
$file=$self->{urlhandler}->get($url);
|
63 |
if ( ( defined $linkfile) && ( $linkfile ne "" ) ) {
|
64 |
$filename=$file."/".$linkfile;
|
65 |
}
|
66 |
else {
|
67 |
$filename=$file;
|
68 |
}
|
69 |
$obj=$self->{dochandler}->newdoc($filename);
|
70 |
|
71 |
# Now Extend our tree
|
72 |
$self->{treenode}->grow($obj->treenode());
|
73 |
return $obj;
|
74 |
}
|
75 |
|
76 |
sub userinterface {
|
77 |
my $self=shift;
|
78 |
return $self->{dochandler}->{UserInterface};
|
79 |
}
|
80 |
|
81 |
sub treenode {
|
82 |
my $self=shift;
|
83 |
return $self->{treenode};
|
84 |
}
|
85 |
|
86 |
sub getincludeObjectStore {
|
87 |
my $self=shift;
|
88 |
return $self->{includeOS};
|
89 |
}
|
90 |
|
91 |
sub find($) {
|
92 |
my $self=shift;
|
93 |
my $string=shift;
|
94 |
my $tn;
|
95 |
|
96 |
$tn=$self->{treenode}->find($string);
|
97 |
if ( $tn eq "" ) {
|
98 |
$self->parseerror("Unable to find $string");
|
99 |
}
|
100 |
return $tn->associate();
|
101 |
}
|
102 |
|
103 |
sub line {
|
104 |
my $self=shift;
|
105 |
return $self->{switch}->line();
|
106 |
}
|
107 |
|
108 |
sub error {
|
109 |
my $self=shift;
|
110 |
my $string=shift;
|
111 |
|
112 |
die $string."\n";
|
113 |
|
114 |
}
|
115 |
sub parseerror {
|
116 |
my $self=shift;
|
117 |
my $string=shift;
|
118 |
|
119 |
print "Parse Error in $self->{url}, line ".
|
120 |
$self->line()."\n";
|
121 |
print $string."\n";
|
122 |
die;
|
123 |
}
|
124 |
|
125 |
sub checktag {
|
126 |
my $self=shift;
|
127 |
my $hashref=shift;
|
128 |
my $param=shift;
|
129 |
my $tagname=shift;
|
130 |
|
131 |
if ( ! exists $$hashref{$param} ) {
|
132 |
$self->parseerror("Incomplete Tag <$tagname> : $param required");
|
133 |
}
|
134 |
}
|
135 |
|
136 |
# ------------------------ Tag Routines ------------------------------
|
137 |
#
|
138 |
# The Include tag
|
139 |
#
|
140 |
|
141 |
sub Include_Start {
|
142 |
my $self=shift;
|
143 |
my $name=shift;
|
144 |
my $hashref=shift;
|
145 |
|
146 |
$self->{switch}->checkparam( $name, "ref");
|
147 |
print "<Include> tag not yet implemented\n";
|
148 |
# $self->include($$hashref{'ref'},$$hashref{'linkdoc'});
|
149 |
}
|
150 |
|
151 |
sub Use_Start {
|
152 |
my $self=shift;
|
153 |
my $name=shift;
|
154 |
my $hashref=shift;
|
155 |
|
156 |
print "<Use> tag not yet implemented\n";
|
157 |
}
|