File Coverage

blib/lib/HTML/EP/Wizard.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             # -*- perl -*-
2             #
3             # HTML::EP::Wizard - A Perl based HTML extension with supporting
4             # the Wizard Module
5             #
6             #
7             # Copyright (C) 1998 Jochen Wiedmann
8             # Am Eisteich 9
9             # 72555 Metzingen
10             # Germany
11             #
12             # Phone: +49 7123 14887
13             # Email: joe@ispsoft.de
14             #
15             # and
16             #
17             # Amarendran R. Subramanian
18             # Grundstr. 32
19             # 72810 Gomaringen
20             # Germany
21             #
22             # Phone: +49 7072 920696
23             # Email: amar@ispsoft.
24             #
25             # All rights reserved.
26             #
27             # You may distribute this module under the terms of either
28             # the GNU General Public License or the Artistic License, as
29             # specified in the Perl README file.
30             #
31             ############################################################################
32              
33             require 5.004;
34 1     1   741 use strict;
  1         2  
  1         38  
35              
36 1     1   445 use HTML::EP ();
  0            
  0            
37             use HTML::EP::Session ();
38             use Wizard::HTML ();
39              
40             use vars ();
41              
42             package HTML::EP::Wizard;
43              
44             $HTML::EP::Wizard::VERSION = '0.1127';
45             @HTML::EP::Wizard::ISA = qw(HTML::EP HTML::EP::Session);
46              
47             sub init {
48             my $self = shift;
49             $self->SUPER::init(@_);
50             }
51              
52             sub _ep_wizard {
53             my($self, $attr, $func) = @_;
54             my $class = $attr->{'class'} || die "Missing class definition";
55              
56             my $cl = "$class.pm";
57             $cl =~ s/\:\:/\//g;
58             require $cl;
59              
60             my $cgi = $self->{'cgi'};
61             my $wiz = Wizard::HTML->new({'ep' => $self});
62             my $session = $self->{'session'};
63             my $state = (ref($session->{'state'}) ?
64             $session->{'state'} : $class->new({}));
65             $state = $wiz->Run($state);
66             $self->{'htmlbody'} = $wiz->{'form'}->{'html-body'};
67             $self->{'htmltitle'} = $wiz->{'form'}->{'html-title'};
68              
69             $self->_ep_session_store({}) if($self->{'state_modified'});
70             '';
71             }
72              
73             sub _ep_form_object {
74             my $self = shift; my $attr = shift; my $func = shift;
75             my $debug = $self->{'debug'};
76             my $template;
77             if (!defined($template = delete $attr->{template})) {
78             $func->{'default'} ||= 'template';
79             return undef;
80             }
81             my $output = '';
82              
83             my $wiz = $self->{'_ep_wizard'};
84             my $form = $self->{'_ep_wizard_form'};
85             die "Error cannot use ep_form_object without having a wizard " unless($wiz && $form);
86             my $item = delete $attr->{item} or die "Missing item name";
87             my $obj = $form->object($attr->{'name'}) || die "No such object "
88             . $attr->{'name'};
89             my($key, $val);
90             while (($key, $val)= each %$attr) {
91             $obj->{$key} = $val;
92             }
93             $self->{$item} = $obj;
94             $output .= $self->ParseVars($template);
95             $output;
96             }
97              
98              
99