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.2 by williamc, Mon Sep 20 16:27:57 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 ( $linkfile ne "" ) {
64 >          $filename=$file."/".$linkfile;
65 >        }
66 >        $obj=$self->{dochandler}->newdoc($filename);
67 >
68          # Now Extend our tree
69          $self->{treenode}->grow($obj->treenode());
70          return $obj;
71   }
72  
73 + sub userinterface {
74 +        my $self=shift;
75 +        return $self->{dochandler}->{UserInterface};
76 + }
77 +
78   sub treenode {
79          my $self=shift;
80 <        return $self->treenode;
80 >        return $self->{treenode};
81   }
82  
83   sub getincludeObjectStore {
# Line 64 | Line 88 | sub getincludeObjectStore {
88   sub find($) {
89          my $self=shift;
90          my $string=shift;
91 +        my $tn;
92  
93 <        $self->{treenode}->find($string);
93 >        $tn=$self->{treenode}->find($string);
94 >        if ( $tn eq "" ) {
95 >          $self->parseerror("Unable to find $string");
96 >        }
97 >        return $tn->associate();
98 > }
99 >
100 > sub parseerror {
101 >        my $self=shift;
102 >        my $string=shift;
103 >
104 >        print "Parse Error in $self->{url}, line $self-{switch}->line()\n";
105 >        print $string."\n";
106 >        die;
107 > }
108 >
109 > sub checktag {
110 >        my $self=shift;
111 >        my $hashref=shift;
112 >        my $param=shift;
113 >        my $tagname=shift;
114 >
115 >        if ( ! exists $$hashref{$param} ) {
116 >          $self->parseerror("Incomplete Tag <$tagname> : $param required");  
117 >        }
118   }
119  
120   # ------------------------ Tag Routines ------------------------------
121   #
122 < # A default Include tag
122 > # The Include tag
123   #
124 +
125   sub Include_Start {
126 <        my $returnval;
127 <        # Just call the basic - this is only a default wrapper for the
128 <        # <INCLUDE> tag assuming with no futher processing of the DOCObjref
129 <        $returnval=_includetag(@_)
130 <        # dont return anything if its a basic tag
126 >        my $self=shift;
127 >        my $name=shift;
128 >        my $hashref=shift;
129 >
130 >        $self->{switch}->checkparam( $name, "ref");
131 >        print "<Include> tag not yet implemented\n";
132 > #        $self->include($$hashref{'ref'},$$hashref{'linkdoc'});
133   }
134  
135 < # ----------------------- Support Routines ---------------------------
136 < #
85 < # the real workings of the include tag returns the ref
86 < #
87 < sub _includetag {
88 <        my $self=shift;
135 > sub Use_Start {
136 >        my $self=shift;
137          my $name=shift;
138          my $hashref=shift;
139  
140 <        $self->{switch}->checkparam( $name, "ref");
93 <        $url=$$hashref{'ref'};
94 <        return $self->include($url);
140 >        print "<Use> tag not yet implemented\n";
141   }
96

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines