File: Caution.pm

package info (click to toggle)
sporum 1.8b1-3.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,108 kB
  • ctags: 676
  • sloc: perl: 14,300; makefile: 52
file content (56 lines) | stat: -rw-r--r-- 1,162 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package Templates::Admin::Caution;

use SmallPigVars qw($config);
use SmallPig;

use CGI qw(:standard *table :cgi-lib);

use strict;
use vars qw(@ISA $DBH);

@ISA = qw(Templates::Admin::OptBlock);

my %CACHE;

sub new{
  my ($class, $theme, $header, $cellpadding, $btitle, 
      $bdrcolor, $bgcolor) = @_;
  $bdrcolor ||= $theme->{'inbgcolor'};
  $bgcolor ||=  $theme->{'inbgcolor'};
  
  my $classvars = {('title' => $btitle,
		    'bdrcolor' => $bdrcolor,
		    'bgcolor' => $bgcolor)};

  my $self = Templates::Admin::OptBlock->new($classvars, $theme);
  $self->{'cellpadding'} = $cellpadding || 10;
  $self->{'header'} = $header;

  my $id = join '', sort values %$self, "caution";
  return $CACHE{$id} if $CACHE{$id};
  return $CACHE{$id} = bless $self, $class;
}

sub set_header{
  my ($self, $header) = @_;
  $self->{'header'} = $header;
}

sub get{
  my ($self, $content) = @_;
  my $cp = $self->{'cellpadding'};
  my $hdr = $self->{'header'};
  $self->{'content'} = 
    CGI::Tr({},
    [CGI::td({},
    [table({-border=>0, -cellpadding=>$cp},
     CGI::Tr({},
    [CGI::td({-class=>$hdr}, [$content])]))])]); 
  $self->SUPER::get();
}
 
return 1;