ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/ActiveDoc.pm
(Generate patch)

Comparing COMP/SCRAM/src/ActiveDoc/ActiveDoc.pm (file contents):
Revision 1.1 by williamc, Fri Aug 20 09:09:28 1999 UTC vs.
Revision 1.4 by williamc, Mon Sep 27 14:05:22 1999 UTC

# Line 5 | Line 5
5   # --------
6   # Interface
7   # ---------
8 < # new(filename, ObjectStoreCont): create a new object based on a file and
9 < #                                 associate with the given ObjectStoreCont
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
# Line 14 | Line 14
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;
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 (BaseTags);
30 > @ISA = qw(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->{OC}=$OC;
40 <        $self->{treenode)=TreeNode->new();
41 <        $self->{includeOS}=$self->{OC}->newStore();
42 <        $self->{dochandler}=DOChandler->new($self->{includeOS});
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 < # Include mechanism
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 <        $obj=$self->{dochandler}->newdoc($url);
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;
83 >        return $self->{treenode};
84   }
85  
86   sub getincludeObjectStore {
# Line 64 | Line 91 | sub getincludeObjectStore {
91   sub find($) {
92          my $self=shift;
93          my $string=shift;
94 +        my $tn;
95  
96 <        $self->{treenode}->find($string);
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 < # A default Include tag
138 > # The Include tag
139   #
140 +
141   sub Include_Start {
142 <        my $returnval;
143 <        # Just call the basic - this is only a default wrapper for the
144 <        # <INCLUDE> tag assuming with no futher processing of the DOCObjref
145 <        $returnval=_includetag(@_)
146 <        # dont return anything if its a basic tag
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 < # ----------------------- Support Routines ---------------------------
152 < #
85 < # the real workings of the include tag returns the ref
86 < #
87 < sub _includetag {
88 <        my $self=shift;
151 > sub Use_Start {
152 >        my $self=shift;
153          my $name=shift;
154          my $hashref=shift;
155  
156 <        $self->{switch}->checkparam( $name, "ref");
93 <        $url=$$hashref{'ref'};
94 <        return $self->include($url);
156 >        print "<Use> tag not yet implemented\n";
157   }
96

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines