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.8 by williamc, Tue Nov 23 17:31:10 1999 UTC vs.
Revision 1.11 by williamc, Fri Dec 17 15:29:01 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
26   # copydocquery(ActiveDoc) : Copy the basicquery from the ActiveDoc
27 + # userinterface()       : Return the defaullt userinterface
28 + # options(var)          : return the value of the option var
29   #
30   # -- error methods --
31   # error(string)       : Report an general error to the user
# Line 33 | Line 38 | require 5.004;
38   use ActiveDoc::Parse;
39   use ActiveDoc::ActiveConfig;
40   use ActiveDoc::PreProcessedFile;
41 < use ObjectUtilities::ObjectBase;
41 > use ObjectUtilities::StorableObject;
42   use URL::URLhandler;
43  
44 < @ISA = qw(ObjectUtilities::ObjectBase);
44 > @ISA = qw(ObjectUtilities::StorableObject);
45  
46   sub new {
47          my $class=shift;
# Line 47 | Line 52 | sub new {
52          # A URL handler per document
53          $self->{urlhandler}=URL::URLhandler->new($self->config()->cache());
54  
55 +        # A default UserInterface
56 +        $self->{userinterface}=ActiveDoc::SimpleUserInterface->new();
57          $self->init(@_);
58          return $self;
59   }
# Line 125 | Line 132 | sub config {
132  
133   sub basequery {
134          my $self=shift;
135 <        @_ ? $self->{UserQuery}=shift
136 <           : $self->{UserQuery};
135 >        @_ ? $self->{Query}=shift
136 >           : $self->{Query};
137 > }
138 >
139 > sub options {
140 >        my $self=shift;
141 >        my $param=shift;
142 >        $self->basequery()->getparam('option_'.$param);
143   }
144  
145   sub getfile() {
# Line 155 | Line 168 | sub getfile() {
168          return $fileref;
169   }
170  
171 + sub activatedoc {
172 +        my $self=shift;
173 +        my $url=shift;
174 +
175 +        # first get a preprocessed copy of the file
176 +        my $fileob=$self->getfile($url);
177 +
178 +        # now parse it for the <DocType> tag
179 +        $self->{doctypefound}=0;
180 +        $self->newparse("doctype");
181 +        $self->addtag("doctype","Doc", \&Doc_Start, $self,
182 +                                          "", $self, "", $self);
183 +        $self->parse("doctype");
184 +
185 +        if ( ! defined $self->{docobject} ) {
186 +          print "No <Doc type=> Specified in ".$fileob->url()."\n";
187 +          exit 1;
188 +        }
189 +        # Set up a new object of the specified type
190 +        my $newobj=$self->{docobject}->new($self->config());
191 +        $newobj->url($url);
192 +        return $newobj;
193 + }
194 +
195   # -------- Error Handling and Error services --------------
196  
197   sub error {
# Line 188 | Line 225 | sub checktag {
225  
226   sub line {
227          my $self=shift;
228 +
229          my ($line, $fileobj)=
230 <                $self->{File}->line($self->{currentparser}->line());
230 >                $self->{File}->realline($self->{currentparser}->line());
231          return ($line, $fileobj);
232   }
233  
# Line 246 | Line 284 | sub Base_end {
284            $self->{urlhandler}->unsetbase($type);
285          }
286   }
287 +
288 + sub Doc_Start {
289 +        my $self=shift;
290 +        my $name=shift;
291 +        my $hashref=shift;
292 +        
293 +        $self->checktag($name, $hashref, "type");
294 +        $self->{doctypefound}++;
295 +        if ( $self->{doctypefound} == 1 ) { # only take first doctype
296 +           $self->{docobject}=$$hashref{'type'};
297 +        }
298 + }
299 +
300 + sub userinterface {
301 +        my $self=shift;
302 +        @_?$self->{userinterface}=shift
303 +          :$self->{userinterface}
304 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines