CGI-WebToolkit

 view release on metacpan or  search on metacpan

lib/CGI/WebToolkit.pm  view on Meta::CPAN

package CGI::WebToolkit;

use 5.008006;
use strict;
use warnings;

use CGI qw(param header);
use CGI::Carp qw(fatalsToBrowser);
use Data::Dump qw(dump);
use DBI;
use Digest::MD5 qw(md5_hex);

our $VERSION = '0.08';

our $WTK = undef;

our @XHTML_TAGS
	= qw(a abbr acronym address applet area b base bdo big blockquote
		 body br button caption cite code col colgroup dd del dfn div
		 dl DOCTYPE dt em fieldset form frame frameset h1 h2 h3 h4 h5
		 h6 head hr html i iframe img input ins kbd label legend li
		 link map meta noframes noscript object ol optgroup option p
		 param pre q samp script select small span strong style sub sup
		 table tbody td textarea tfoot th thead title tr tt ul var marquee
		 section header footer nav article
		 emph);

# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# constructor

sub new
{
	my ($class, @args) = @_;
	my $self = bless {}, $class;
	return $self->__init( @args );
}

# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# methods

sub handle
{
	my ($self) = __parse_args(@_);
	
	# clear cache
	$self->__clear_cache()
		if $self->{'allowclearcache'} == 1
			&& defined param($self->{'clearcacheparam'});
	
	# determine name of workflow function
	my $workflow_function_name = param($self->{'workflowparam'});
	   $workflow_function_name = $self->{'entryaction'}
	   		unless defined $workflow_function_name;
	
	my $mimetype = '';
	my $message = '';
	my $function_name = $workflow_function_name;
	my $args = [];
	while (1) {
		
		my $result = $self->call( $function_name, @{$args} );
		
		__die("function '$function_name' returned invalid result.".
			 " Use the methods output() or followup() to generate a valid result.")
			if ref $result ne 'HASH' || !exists $result->{'type'};
		
		if ($result->{'type'} eq 'output') {
			if (exists $result->{'status'} && $result->{'status'} == 1) {
				
				__die("missing mimetype in result from function '$function_name'")
					unless exists $result->{'mimetype'};			
				__die("missing content in result from function '$function_name'")
					unless exists $result->{'content'};
					
				$mimetype = $result->{'mimetype'};
				$message  = $result->{'content'};

				if ($mimetype eq 'text/html') {
					# replace any {...:...} placeholders with their default values



( run in 0.861 second using v1.01-cache-2.11-cpan-df04353d9ac )