[Bio] / FigKernelPackages / TemplateObject.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/TemplateObject.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Fri Jul 28 02:01:33 2006 UTC revision 1.6, Fri Nov 3 18:22:31 2006 UTC
# Line 62  Line 62 
62  The template facility used is the PERL C<HTML::Template> facility, so  The template facility used is the PERL C<HTML::Template> facility, so
63  anything that follows the format of that facility will work. The  anything that follows the format of that facility will work. The
64  most common use of the facility is simple variable substition. In  most common use of the facility is simple variable substition. In
65  the fragment below, the variable is named Ctopic>.  the fragment below, the variable is named C<topic>.
66    
67      <p>This page tells how to do <TMPL_VAR NAME=TOPIC>.      <p>This page tells how to do <TMPL_VAR NAME=TOPIC>.
68    
# Line 149  Line 149 
149          # Here we're in Sprout, so we have a template. First, we compute          # Here we're in Sprout, so we have a template. First, we compute
150          # the template name.          # the template name.
151          my $requestPart = ($request ? "_$request" : "");          my $requestPart = ($request ? "_$request" : "");
152          $template = "${name}_tmpl$request.$type";          $template = "${name}_tmpl$requestPart.$type";
153          # Now we need to determine the template type and prefix the source location          # Now we need to determine the template type and prefix the source location
154          # onto it.          # onto it.
155          if ($FIG_Config::template_url) {          if ($FIG_Config::template_url) {
156              $template = "$FIG_Config::template_url/$template";              $template = "$FIG_Config::template_url/$template";
157          } else {          } else {
158              $template = "<<$FIG_Config::fig/CGI/Html";              $template = "<<$FIG_Config::fig/CGI/Html/$template";
159          }          }
160      }      }
161      # Now $template is either a null string (FALSE) or the name of the      # Now $template is either a null string (FALSE) or the name of the
162      # template (TRUE). We are ready to create the return object.      # template (TRUE). We are ready to create the return object.
163      my $retVal = { template => $template };      my $retVal = { template => $template,
164                       cgi => $cgi,
165                     };
166      # Next we add the object that will be accepting the HTML strings.      # Next we add the object that will be accepting the HTML strings.
167      if ($template) {      if ($template) {
168          $retVal->{varHash} = {};          $retVal->{varHash} = {};
# Line 252  Line 254 
254      }      }
255  }  }
256    
257    =head3 append
258    
259    C<< $to->append($name, $html); >>
260    
261    Append HTML to a named variable. Unlike L</add>, this method will not destroy a
262    variable's existing value; instead, it will concatenate the new data at the end of the
263    old.
264    
265    =over 4
266    
267    =item name
268    
269    Name of the variable to which the HTML text is to be appended.
270    
271    =item html
272    
273    HTML text to append.
274    
275    =back
276    
277    =cut
278    
279    sub append {
280        # Get the parameters.
281        my ($self, $name, $html) = @_;
282        # Check the mode.
283        if ($self->mode) {
284            # Template mode, so we check for the variable.
285            my $hash = $self->{varHash};
286            if (exists $hash->{$name}) {
287                $hash->{$name} .= $html;
288            } else {
289                $hash->{$name} = $html;
290            }
291        } else {
292            # Raw mode.
293            push @{$self->{html}}, $html;
294        }
295    }
296    
297  =head3 titles  =head3 titles
298    
299  C<< to->titles($parameters); >>  C<< to->titles($parameters); >>
# Line 268  Line 310 
310    
311  Reference to a hash containing the heading parameters. These are as follows.  Reference to a hash containing the heading parameters. These are as follows.
312    
313  =over 4  =over 8
314    
315  =item fig_object  =item fig_object
316    
# Line 299  Line 341 
341  sub titles {  sub titles {
342      # Get the parameters.      # Get the parameters.
343      my ($self, $parameters) = @_;      my ($self, $parameters) = @_;
344        my $cgi = $self->{cgi};
345      if ($self->{template}) {      if ($self->{template}) {
346          # In template mode, we get useful stuff from the framework. First, the message          # In template mode, we get useful stuff from the framework. First, the message
347          # of the day.          # of the day.
# Line 307  Line 350 
350          $self->add(version =>          $self->add(version =>
351                     FigWebServices::SeedComponents::Framework::get_version({fig => $parameters->{fig_object},                     FigWebServices::SeedComponents::Framework::get_version({fig => $parameters->{fig_object},
352                                                                             fig_disk => $parameters->{fig_disk}}));                                                                             fig_disk => $parameters->{fig_disk}}));
353            # Next, the location tag.
354            $self->add(location_tag => $self->{cgi}->url());
355          # Finally the protein (if any).          # Finally the protein (if any).
356          if (exists $parameters->{peg_id}) {          if (exists $parameters->{peg_id}) {
357              $self->add(feature_id => $parameters->{peg_id});              $self->add(feature_id => $parameters->{peg_id});
358          }          }
359      } else {      } else {
360          # No template, so we pull in the plain header.          # No template, so we pull in the plain header.
361            $self->add($cgi->start_html(-title => $parameters->{title}));
362          $self->add(header => FigWebServices::SeedComponents::Framework::get_plain_header($parameters));          $self->add(header => FigWebServices::SeedComponents::Framework::get_plain_header($parameters));
363      }      }
364  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3