[Bio] / WebApplication / WebLayout.pm Repository:
ViewVC logotype

View of /WebApplication/WebLayout.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Fri Apr 27 16:02:14 2007 UTC (13 years, 2 months ago) by paczian
Branch: MAIN
Changes since 1.2: +47 -7 lines
*** empty log message ***

package WebLayout;

use strict;
use warnings;

use WebConfig;

use HTML::Template;

1;

sub new {
  my ($class, $tmpl_path) = @_;
  
  my $tmpl  = $tmpl_path || TMPL_PATH.'WebLayoutDefault.tmpl';
  my $frame = TMPL_PATH.'WebLayoutFrame.tmpl';

  my $self = { 'template'   => HTML::Template->new(filename => $tmpl,
						   die_on_bad_params => 0),
	       'frame'      => HTML::Template->new(filename => $frame),
	       'title'      => '',
	       'javascript' => [], 
	       'css'        => [],
	       
	     };

  bless($self, $class);

  return $self;
}


sub set_content {
  $_[0]->frame->param( TITLE => $_[1]->{'title'} );

  my @warn = map { { MSG => $_ } } @{$_[1]->{'warnings'}};
  my @info = map { { MSG => $_ } } @{$_[1]->{'info'}};

  $_[0]->template->param( CONTENT  => $_[1]->{'content'});
  $_[0]->template->param( MENU     => $_[1]->{'menu'});
  $_[0]->template->param( WARNINGS => \@warn );
  $_[0]->template->param( INFO     => \@info );
}


sub add_javascript {
  if ($_[1]) {
    push @{$_[0]->{'javascript'}}, { 'JSFILE' => $_[1] };
  }
}

sub add_css {
  if ($_[1]) {
    push @{$_[0]->{'css'}}, { 'CSSFILE' => $_[1] };
  }
}

sub output {
  my $self = shift;

  $self->frame->param( BODY => $self->template->output() );
  $self->frame->param( JAVASCRIPT => $self->{'javascript'} );
  $self->frame->param( CSS => $self->{'css'} );

  return $self->frame->output();
}

sub template {
  return $_[0]->{'template'};
}

sub frame {
  return $_[0]->{'frame'};
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3