| 1 | package QWizard::Generator::HTML::Vertical; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use QWizard::Generator::HTML; | ||
| 5 | use Exporter; | ||
| 6 | use CGI qw(escapeHTML); | ||
| 7 | |||
| 8 | our $VERSION = '3.15'; | ||
| 9 | |||
| 10 | @QWizard::Generator::HTML::Vertical::ISA = | ||
| 11 | qw(Exporter QWizard::Generator::HTML); | ||
| 12 | |||
| 13 | # | ||
| 14 | # we inherit everything from the HTML class... including the new() routine. | ||
| 15 | # | ||
| 16 | |||
| 17 | # | ||
| 18 | # functions to override the parent and change the layout. | ||
| 19 | # | ||
| 20 | sub do_question { | ||
| 21 | my ($self, $q, $wiz, $p, $text, $qcount) = @_; | ||
| 22 | return if (!$text && $q->{'type'} eq 'hidden'); | ||
| 23 | print " <p>\n"; | ||
| 24 | if ($q->{'helptext'}) { | ||
| 25 | print $wiz->make_help_link($p, $qcount), | ||
| 26 | escapeHTML($text), "</a>\n"; | ||
| 27 | } else { | ||
| 28 | print escapeHTML($text); | ||
| 29 | } | ||
| 30 | if ($q->{'helpdesc'}) { | ||
| 31 | |||
| 32 | # | ||
| 33 | # Get the actual help text, in case this is a subroutine. | ||
| 34 | # | ||
| 35 | my $helptext = $q->{'helpdesc'}; | ||
| 36 | if (ref($helptext) eq "CODE") { | ||
| 37 | $helptext = $helptext->(); | ||
| 38 | } | ||
| 39 | |||
| 40 | print "<br><small><i>" . escapeHTML($helptext) . "</i></small>"; | ||
| 41 | } | ||
| 42 | print "<ul>\n"; | ||
| 43 | } | ||
| 44 | |||
| 45 | sub do_question_end { | ||
| 46 | my ($self, $q, $wiz, $p, $qcount) = @_; | ||
| 47 | |||
| 48 | # | ||
| 49 | # help text | ||
| 50 | # | ||
| 51 | return if (!$q->{'text'} && $q->{'type'} eq 'hidden'); | ||
| 52 | print "</ul>\n"; | ||
| 53 | } | ||
| 54 | |||
| 55 | sub start_questions { | ||
| 56 | my ($self, $wiz, $p, $title, $intro) = @_; | ||
| 57 | if ($title) { | ||
| 58 | print $self->{'cgi'}->h1(escapeHTML($title)),"\n"; | ||
| 59 | } | ||
| 60 | if ($intro) { | ||
| 61 | $intro = escapeHTML($intro); | ||
| 62 | $intro =~ s/\n\n/\n<p>\n/g; | ||
| 63 | print "$intro\n</p><p>\n"; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | sub end_questions { | ||
| 68 | my ($self, $wiz, $p) = @_; | ||
| 69 | |||
| 70 | # | ||
| 71 | # This focus() call should allow the user to type directly into the | ||
| 72 | # first text box without having to click there first. | ||
| 73 | # | ||
| 74 | print "<script>\n"; | ||
| 75 | print "document.forms[0].elements[0].focus();\n"; | ||
| 76 | print "</script>\n"; | ||
| 77 | |||
| 78 | $self->{'started'} = $wiz->{'started'} = 0; | ||
| 79 | } | ||
| 80 | |||
| 81 | |||
| 82 | sub do_error { | ||
| 83 | my ($self, $q, $wiz, $p, $err) = @_; | ||
| 84 | print "<font color=red>" . escapeHTML($err) . "</font>\n"; | ||
| 85 | } | ||
| 86 | |||
| 87 | sub do_separator { | ||
| 88 | my ($self, $q, $wiz, $p, $text) = @_; | ||
| 89 | if ($text eq "") { | ||
| 90 | $text = " "; | ||
| 91 | } else { | ||
| 92 | $text = escapeHTML($text); | ||
| 93 | } | ||
| 94 | print " <p>$text</p>"; | ||
| 95 | } | ||
| 96 | |||
| 97 | 1; |