1 |
#
|
2 |
# The base functionality for the ActiveDocument - inherits from Basetags
|
3 |
#
|
4 |
# Inherits from BaseTags
|
5 |
# --------
|
6 |
# Interface
|
7 |
# ---------
|
8 |
# new(filename, ObjectStoreCont): create a new object based on a file and
|
9 |
# associate with the given ObjectStoreCont
|
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 |
|
18 |
|
19 |
package ActiveDoc;
|
20 |
use BaseTags;
|
21 |
use DOChandler;
|
22 |
use ObjectStoreCont;
|
23 |
|
24 |
@ISA = qw (BaseTags);
|
25 |
|
26 |
# Initialise
|
27 |
sub _init {
|
28 |
my $self=shift;
|
29 |
my $OC=shift;
|
30 |
|
31 |
$self->_addurl();
|
32 |
$self->{OC}=$OC;
|
33 |
$self->{treenode)=TreeNode->new();
|
34 |
$self->{includeOS}=$self->{OC}->newStore();
|
35 |
$self->{dochandler}=DOChandler->new($self->{includeOS});
|
36 |
# Add the minimal functionality tag - feel free to override
|
37 |
$self->{tags}->addtag("Include", \&Include_Start, "", "");
|
38 |
}
|
39 |
|
40 |
#
|
41 |
# Include mechanism
|
42 |
#
|
43 |
sub include {
|
44 |
my $self=shift;
|
45 |
my $url=shift;
|
46 |
my $obj;
|
47 |
|
48 |
$obj=$self->{dochandler}->newdoc($url);
|
49 |
# Now Extend our tree
|
50 |
$self->{treenode}->grow($obj->treenode());
|
51 |
return $obj;
|
52 |
}
|
53 |
|
54 |
sub treenode {
|
55 |
my $self=shift;
|
56 |
return $self->treenode;
|
57 |
}
|
58 |
|
59 |
sub getincludeObjectStore {
|
60 |
my $self=shift;
|
61 |
return $self->{includeOS};
|
62 |
}
|
63 |
|
64 |
sub find($) {
|
65 |
my $self=shift;
|
66 |
my $string=shift;
|
67 |
|
68 |
$self->{treenode}->find($string);
|
69 |
}
|
70 |
|
71 |
# ------------------------ Tag Routines ------------------------------
|
72 |
#
|
73 |
# A default Include tag
|
74 |
#
|
75 |
sub Include_Start {
|
76 |
my $returnval;
|
77 |
# Just call the basic - this is only a default wrapper for the
|
78 |
# <INCLUDE> tag assuming with no futher processing of the DOCObjref
|
79 |
$returnval=_includetag(@_)
|
80 |
# dont return anything if its a basic tag
|
81 |
}
|
82 |
|
83 |
# ----------------------- Support Routines ---------------------------
|
84 |
#
|
85 |
# the real workings of the include tag returns the ref
|
86 |
#
|
87 |
sub _includetag {
|
88 |
my $self=shift;
|
89 |
my $name=shift;
|
90 |
my $hashref=shift;
|
91 |
|
92 |
$self->{switch}->checkparam( $name, "ref");
|
93 |
$url=$$hashref{'ref'};
|
94 |
return $self->include($url);
|
95 |
}
|
96 |
|