DBIx-glueHTML
view release on metacpan or search on metacpan
glueHTML.pm view on Meta::CPAN
to remain visible. If no changes are to be made, (undef, 0) must be returned.
NOTE: check_params() MUST be called or glueHTML will not function correctly.
=cut
sub set_fieldvaluecallback {
my $self = shift;
my $callback = shift;
$self->{FORMFIELDCALLBACK} = $callback;
}
# Internal function to output errors and exit the program
sub _die {
my $self = shift;
my $errstr = shift;
if (defined $self->{ERRHDL}) {
&{$self->{ERRHDL}} ($errstr);
}
# Call die whether or not the user defined error handler has been called
# - the error is fatal and we should not get here if the user defined
# handler operates correctly anyway.
die $errstr;
}
=item B<set_timezone> B<(>I<UseGMT (1/0)>B<,> I<Time change (hours)>B<);>
$DBinterface->set_timezone(1, 0); # Set time to GMT +0000
$DBinterface->set_timezone(0, -5); # Set time to server time -0500
$DBinterface->set_timezone(1, -8); # Set time to GMT -0800
$DBinterface->set_timezone(0, 2); # Set time to server time +0200
Changes the time zone used for timestamps inserted into database records. The
first parameter specifies whether to use GMT time or to use the server time,
i.e the computer running this script's internal clock. The second parameter
allows time to be added or subtracted in hours.
=cut
sub set_timezone {
# $self $usegmttime;
$_[0]->{USEGMTTIME} = $_[1];
# $self $timemod;
$_[0]->{TIMEMOD} = $_[2];
}
# ------------------------------------------------------------------------
# HTML formatting functions
# ------------------------------------------------------------------------
=pod
=back
=head2 Optional HTML Customisation Methods
=over 4
=item Future Additions
In a later version, callbacks to add user defined form parameters to
allow state keeping such as password protection etc.
=item B<set_printheader> B<(>I<Callback function address>B<,> I<Print content type header (1/0)>B<);>
sub printheader {
my $title = shift;
my $headtext = shift;
print $cgi->header;
print $cgi->start_html(-title=>"$headtext");
if ($headtext ne "") {
print $cgi->h3($headtext);
}
}
$DBinterface->set_printheader(\&printheader, 1);
Transfers the header HTML outputting function to a user defined function
to allow HTML customisation. (This is printed at the top of every page
outputed by this module)
The first parameter is a function reference, the second parameter is 1 to
allow this module to print the HTTP Content-Type header automatically, 0
to suppress this.
=cut
sub set_printheader {
# $self &printheader;
$_[0]->{PRINTHEADER} = $_[1];
# $self $printcontenttype
$_[0]->{PRINTCONTENTTYPE} = $_[2] || 0;
}
# Internal function to start the output in the user's desired style
sub _printHeader {
my $self = shift;
my $title = shift;
my $headtext = shift;
my ($package, $filename, $line) = caller();
if ($self->{PRINTCONTENTTYPE} == 1) {
print $self->{CGI}->header;
}
if (defined $self->{PRINTHEADER}) {
&{$self->{PRINTHEADER}} ($title, $headtext);
} else {
# Just incase it got missed
if ($self->{PRINTCONTENTTYPE} != 1) {
print $self->{CGI}->header;
}
print $self->{CGI}->start_html(-title=>"$title",
-bgcolor=>"#FFFFFF",
-text=>"#000077"
);
if ($headtext ne "") {
print $self->{CGI}->h3($headtext);
}
}
( run in 2.441 seconds using v1.01-cache-2.11-cpan-bbb979687b5 )