-sub template_args { {} }
-
-sub fill_template {
- my ($self, $step, $outref, $fill) = @_;
-
- return if ! $fill;
-
- my $args = $self->run_hook('fill_args', $step);
- local $args->{'text'} = $outref;
- local $args->{'form'} = $fill;
-
- require CGI::Ex::Fill;
- CGI::Ex::Fill::fill($args);
-}
-
-sub fill_args { {} }
-
-sub pre_step { 0 } # success indicates we handled step (don't continue step or loop)
-sub skip { 0 } # success indicates to skip the step (and continue loop)
-sub prepare { 1 } # failure means show step
-sub finalize { 1 } # failure means show step
-sub post_print { 0 }
-sub post_step { 0 } # success indicates we handled step (don't continue step or loop)
-
-sub name_step {
- my ($self, $step) = @_;
- return $step;
-}
-
-sub morph_package {
- my $self = shift;
- my $step = shift || '';
- my $cur = ref $self; # default to using self as the base for morphed modules
- my $new = $cur .'::'. $step;
- $new =~ s/(\b|_+)(\w)/\u$2/g; # turn Foo::my_step_name into Foo::MyStepName
- return $new;
-}
-
-sub name_module {
- my $self = shift;
- my $step = shift || '';
-
- return $self->{'name_module'} ||= do {
- # allow for cgi-bin/foo or cgi-bin/foo.pl to resolve to "foo"
- my $script = $ENV{'SCRIPT_NAME'} || $0;
- $script =~ m/ (\w+) (?:\.\w+)? $/x || die "Couldn't determine module name from \"name_module\" lookup ($step)";
- $1; # return of the do
- };
-}
-
-sub file_print {
- my $self = shift;
- my $step = shift;
-
- my $base_dir = $self->base_dir_rel;
- my $module = $self->run_hook('name_module', $step);
- my $_step = $self->run_hook('name_step', $step) || die "Missing name_step";
- $_step .= '.'. $self->ext_print if $_step !~ /\.\w+$/;
-
- foreach ($base_dir, $module) { $_ .= '/' if length($_) && ! m|/$| }
-
- return $base_dir . $module . $_step;
-}
-
-sub file_val {
- my $self = shift;
- my $step = shift;
-
- my $abs = $self->base_dir_abs || return {};
- my $base_dir = $self->base_dir_rel;
- my $module = $self->run_hook('name_module', $step);
- my $_step = $self->run_hook('name_step', $step);
- $_step .= '.'. $self->ext_val if $_step !~ /\.\w+$/;
-
- foreach ($abs, $base_dir, $module) { $_ .= '/' if length($_) && ! m|/$| }
-
- return $abs . $base_dir . $module . $_step;
-}
-
-sub info_complete {
- my ($self, $step) = @_;
- return 0 if ! $self->run_hook('ready_validate', $step);
- return 0 if ! $self->run_hook('validate', $step, $self->form);
- return 1;
-}
-
-sub ready_validate {
- my ($self, $step) = @_;
- return ($ENV{'REQUEST_METHOD'} && $ENV{'REQUEST_METHOD'} eq 'POST') ? 1 : 0;
-}
-
-sub set_ready_validate { # hook and method
- my $self = shift;
- my ($step, $is_ready) = (@_ == 2) ? @_ : (undef, shift);
- $ENV{'REQUEST_METHOD'} = ($is_ready) ? 'POST' : 'GET';
- return $is_ready;
-}
-