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.6 by williamc, Fri Nov 19 15:27:46 1999 UTC vs.
Revision 1.9 by williamc, Mon Nov 29 17:32:14 1999 UTC

# Line 15 | Line 15
15   # newparse(parselabel) : Create a new parse type
16   # addtag(parselabel,tagname,start,obj,text,obj,end,obj)
17   #                               : Add tags to the parse given by label
18 + # checktag(tagname, hashref, param) : check for existence of param in
19 + #                                       hashref from a tag call
20   # newdoc(file)  : Return an new object of the appropriate type
21   # getfile(url)  : get a processedfile object given a url
22 + # activatedoc(url) : Return the object ref for a doc described by the given url
23   # config([ActiveConfig]) : Set up/return Configuration for the document
24   # basequery([ActiveConfig]) : Set up/return UserQuery for the doc
25   # copydocconfig(ActiveDoc) : Copy the basic configuration from the ActiveDoc
# Line 57 | Line 60 | sub parse {
60          $parselabel=shift;
61  
62          my $file=$self->file();
60        print "Parse called on file $file\n";
63          if ( $file ) {
64 +          $self->{currentparser}=$self->{parsers}{$parselabel};
65            $self->{parsers}{$parselabel}->parse($file,@_);
66 +          delete $self->{currentparser};
67          }
68          else {
69            print "Cannot parse - file not known\n";
# Line 96 | Line 100 | sub addurltags {
100  
101   sub url {
102          my $self=shift;
103 <        @_ ?$self->{File}=$self->getfile(shift)
104 <            : $self->{File};
103 >        # get file & preprocess
104 >        if ( @_  ) {$self->{File}=$self->getfile(shift)}
105 >        $self->{File}->url();
106   }
107  
108   sub copydocconfig {
# Line 132 | Line 137 | sub getfile() {
137          my $origurl=shift;
138  
139          my $fileref;
135        print "GETFILE called\n";
140          my ($url, $file)=$self->{urlhandler}->get($origurl);
141          # do we already have an appropriate object?
142 <        #my ($fileref)=$self->config()->find("__preprocessed",$url);
143 <        undef $fileref;
142 >        ($fileref)=$self->config()->find($url);
143 >        #undef $fileref;
144          if (  defined $fileref ) {
145           print "found $url in database ----\n";
146           $fileref->update();
# Line 150 | Line 154 | sub getfile() {
154           $fileref=ActiveDoc::PreProcessedFile->new($self->config());
155           $fileref->url($url);
156           $fileref->update();
153         $self->config()->store($fileref,"__preprocessed",$url);
157          }
155        print "---------- returning".$fileref."\n";
158          return $fileref;
159   }
160  
161 + sub activatedoc {
162 +        my $self=shift;
163 +        my $url=shift;
164 +
165 +        # first get a preprocessed copy of the file
166 +        my $fileob=$self->getfile($url);
167 +
168 +        # now parse it for the <DocType> tag
169 +        $self->newparse("doctype");
170 +        $self->addtag("doctype","Doc", \&Doc_Start, $self,
171 +                                          "", $self, "", $self);
172 +        $self->parse("doctype");
173 +
174 +        if ( ! defined $self->{docobject} ) {
175 +          print "No <Doc type=> Specified in ".$fileob->url()."\n";
176 +          exit 1;
177 +        }
178 +        # Set up a new object of the specified type
179 +        my $newobj=$self->{docobject}->new($self->config());
180 +        return $newobj;
181 + }
182 +
183   # -------- Error Handling and Error services --------------
184  
185   sub error {
# Line 182 | Line 206 | sub checktag {
206          my $hashref=shift;
207          my $param=shift;
208  
209 +        print keys %$hashref;
210 +        print "-----------------------------------\n";
211          if ( ! exists $$hashref{$param} ) {
212            $self->parseerror("Incomplete Tag <$tagname> : $param required");
213          }
214   }
215  
216   sub line {
217 <        $self=shift;
217 >        my $self=shift;
218 >
219          my ($line, $fileobj)=
220 <                $self->{Processedfile}->line($self->{switch}->line());
220 >                $self->{File}->realline($self->{currentparser}->line());
221          return ($line, $fileobj);
222   }
223  
224 + sub tagstartline {
225 +        my $self=shift;
226 +        my ($line, $fileobj)=$self->{File}->line(
227 +                $self->{currentparser}->tagstartline());
228 +        return ($line, $fileobj);
229 + }
230 +
231   sub file {
232          my $self=shift;
233  
234 <        $self->{PPf}->file();
234 >        $self->{File}->file();
235   }
236  
237   # --------------- Initialisation Methods ---------------------------
238  
205 sub preprocess_init {
206        my $self=shift;
207        $self->{PPfile}=PreProcessedFile->new($self->config());
208 }
209
239   sub init {
240          # Dummy Routine - override for derived classes
241   }
# Line 245 | Line 274 | sub Base_end {
274            $self->{urlhandler}->unsetbase($type);
275          }
276   }
277 +
278 + sub Doc_Start {
279 +        my $self=shift;
280 +        my $name=shift;
281 +        my $hashref=shift;
282 +        
283 +        $self->checktag($name, $hashref, "type");
284 +        $self->{docobject}=$$hashref{'type'};
285 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines