1 |
williamc |
1.1 |
#
|
2 |
|
|
# The base functionality for the ActiveDocument - inherits from Basetags
|
3 |
|
|
#
|
4 |
|
|
# Inherits from BaseTags
|
5 |
|
|
# --------
|
6 |
|
|
# Interface
|
7 |
|
|
# ---------
|
8 |
williamc |
1.2 |
# new(filename, DOChandler): create a new object based on a file and
|
9 |
|
|
# associate with a base DOChandler
|
10 |
williamc |
1.1 |
# 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 |
williamc |
1.2 |
# _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 |
williamc |
1.1 |
use ObjectStoreCont;
|
29 |
|
|
|
30 |
williamc |
1.2 |
@ISA = qw(BaseTags);
|
31 |
williamc |
1.1 |
|
32 |
|
|
# Initialise
|
33 |
|
|
sub _init {
|
34 |
|
|
my $self=shift;
|
35 |
williamc |
1.2 |
my $DOChandler=shift;
|
36 |
williamc |
1.1 |
my $OC=shift;
|
37 |
|
|
|
38 |
|
|
$self->_addurl();
|
39 |
williamc |
1.2 |
$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 |
williamc |
1.1 |
# Add the minimal functionality tag - feel free to override
|
45 |
|
|
$self->{tags}->addtag("Include", \&Include_Start, "", "");
|
46 |
williamc |
1.2 |
$self->init();
|
47 |
williamc |
1.1 |
}
|
48 |
|
|
|
49 |
williamc |
1.2 |
sub init {
|
50 |
|
|
# Dummy Routine - override for derrived classes
|
51 |
|
|
}
|
52 |
williamc |
1.1 |
#
|
53 |
williamc |
1.2 |
# use mechanism
|
54 |
williamc |
1.1 |
#
|
55 |
|
|
sub include {
|
56 |
|
|
my $self=shift;
|
57 |
|
|
my $url=shift;
|
58 |
williamc |
1.2 |
my $linkfile=shift;
|
59 |
|
|
my $filename;
|
60 |
williamc |
1.1 |
my $obj;
|
61 |
|
|
|
62 |
williamc |
1.2 |
$file=$self->{urlhandler}->get($url);
|
63 |
|
|
if ( $linkfile ne "" ) {
|
64 |
|
|
$filename=$file."/".$linkfile;
|
65 |
|
|
}
|
66 |
|
|
$obj=$self->{dochandler}->newdoc($filename);
|
67 |
|
|
|
68 |
williamc |
1.1 |
# Now Extend our tree
|
69 |
|
|
$self->{treenode}->grow($obj->treenode());
|
70 |
|
|
return $obj;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
williamc |
1.2 |
sub userinterface {
|
74 |
|
|
my $self=shift;
|
75 |
|
|
return $self->{dochandler}->{UserInterface};
|
76 |
|
|
}
|
77 |
|
|
|
78 |
williamc |
1.1 |
sub treenode {
|
79 |
|
|
my $self=shift;
|
80 |
williamc |
1.2 |
return $self->{treenode};
|
81 |
williamc |
1.1 |
}
|
82 |
|
|
|
83 |
|
|
sub getincludeObjectStore {
|
84 |
|
|
my $self=shift;
|
85 |
|
|
return $self->{includeOS};
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
sub find($) {
|
89 |
|
|
my $self=shift;
|
90 |
|
|
my $string=shift;
|
91 |
williamc |
1.2 |
my $tn;
|
92 |
williamc |
1.1 |
|
93 |
williamc |
1.2 |
$tn=$self->{treenode}->find($string);
|
94 |
|
|
if ( $tn eq "" ) {
|
95 |
|
|
$self->parseerror("Unable to find $string");
|
96 |
|
|
}
|
97 |
|
|
return $tn->associate();
|
98 |
|
|
}
|
99 |
|
|
|
100 |
williamc |
1.3 |
sub line {
|
101 |
|
|
my $self=shift;
|
102 |
|
|
return $self->{switch}->line();
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
sub error {
|
106 |
|
|
my $self=shift;
|
107 |
|
|
my $string=shift;
|
108 |
|
|
|
109 |
|
|
die $string."\n";
|
110 |
|
|
|
111 |
|
|
}
|
112 |
williamc |
1.2 |
sub parseerror {
|
113 |
|
|
my $self=shift;
|
114 |
|
|
my $string=shift;
|
115 |
|
|
|
116 |
williamc |
1.3 |
print "Parse Error in $self->{url}, line ".
|
117 |
|
|
$self->line()."\n";
|
118 |
williamc |
1.2 |
print $string."\n";
|
119 |
|
|
die;
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
sub checktag {
|
123 |
|
|
my $self=shift;
|
124 |
|
|
my $hashref=shift;
|
125 |
|
|
my $param=shift;
|
126 |
|
|
my $tagname=shift;
|
127 |
|
|
|
128 |
|
|
if ( ! exists $$hashref{$param} ) {
|
129 |
|
|
$self->parseerror("Incomplete Tag <$tagname> : $param required");
|
130 |
|
|
}
|
131 |
williamc |
1.1 |
}
|
132 |
|
|
|
133 |
|
|
# ------------------------ Tag Routines ------------------------------
|
134 |
|
|
#
|
135 |
williamc |
1.2 |
# The Include tag
|
136 |
williamc |
1.1 |
#
|
137 |
williamc |
1.2 |
|
138 |
williamc |
1.1 |
sub Include_Start {
|
139 |
williamc |
1.2 |
my $self=shift;
|
140 |
|
|
my $name=shift;
|
141 |
|
|
my $hashref=shift;
|
142 |
|
|
|
143 |
|
|
$self->{switch}->checkparam( $name, "ref");
|
144 |
|
|
print "<Include> tag not yet implemented\n";
|
145 |
|
|
# $self->include($$hashref{'ref'},$$hashref{'linkdoc'});
|
146 |
williamc |
1.1 |
}
|
147 |
|
|
|
148 |
williamc |
1.2 |
sub Use_Start {
|
149 |
|
|
my $self=shift;
|
150 |
williamc |
1.1 |
my $name=shift;
|
151 |
|
|
my $hashref=shift;
|
152 |
|
|
|
153 |
williamc |
1.2 |
print "<Use> tag not yet implemented\n";
|
154 |
williamc |
1.1 |
}
|