DBIx-HTMLinterface

 view release on metacpan or  search on metacpan

HTMLinterface.pm  view on Meta::CPAN

}

# Internal function to call the user defined security check
sub _checkAccess {
    my $self     = shift;
    my $callback = $self->{ACCESSCALLBACK};

    if (ref($callback) eq 'CODE') {
    	&$callback(); # nicer to perl 5.003 users
    }
}

# 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 print table cells, start and finish tables, 
print form fields, print back links and add user defined form parameters to 
allow state keeping such as password protection etc.

=item B<set_printheader>

  sub printheader {
      my $title    = shift;
      my $headtext = shift;

      print $cgi->start_html(-title=>"$title_txt");

      if ($headtext ne "") {
          print $cgi->h3($headtext);
      }
  }
  $DBinterface->set_printheader(\&printheader);

Transfers the header HTML outputting function to a user defined function 
to allow HTML customisation.

=cut
sub set_printheader {
#   $self                  &printheader;
    $_[0]->{PRINTHEADER} = $_[1];
}

# 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();

    print $self->{CGI}->header;

    if (defined $self->{PRINTHEADER}) {
        &{$self->{PRINTHEADER}} ($title, $headtext);
    } else {
        print $self->{CGI}->start_html(-title=>"$title",
                                       -bgcolor=>"#FFFFFF",
                                       -text=>"#000077"
                                      );
        if ($headtext ne "") {
            print $self->{CGI}->h3($headtext);
        }
    }

    print "\n<!-- DBIx::HTMLinterface.pm V$VERSION. Page generated by $package [$filename:$line] -->\n\n";
}

=item B<set_printfooter>

  sub printfooter {
      print $cgi->end_html;
  }
  $DBinterface->set_printfooter(\&printfooter);

Transfers the footer HTML outputting function to a user defined function 
to allow HTML customisation.



( run in 1.269 second using v1.01-cache-2.11-cpan-140bd7fdf52 )