--- make_poll.pl 2003/10/11 11:40:36 1.10 +++ make_poll.pl 2003/10/21 16:55:06 1.14 @@ -10,6 +10,7 @@ use XML::Parser; use common; +use Carp; $|=1; @@ -66,10 +67,30 @@ # and users will see just "red" and "black" my $remove_nrs_in_answers=0; +# This defines files which will be included in various places to produce +# design. You could desing them using your faviourite html editor (vim :-) +# and then split them into separate files + +my %include_files = ( +# this file is included at top of each paAge + 'header' => "header.html", +# this file is used to separate questions + 'separator' => "separator.html", +# this file is used to show "submit" button, which under multi-page +# polls will also bring next page + 'submit' => "next.html", +# this file is included at bottom of each page + 'footer' => "footer.html", +# this file will be showen after poll is completed + 'thanks' => "thanks.html" +); + +my %html; # buffer for suck(_file)ed html files + #------------------------------------------------------------------ sub suck_file { - my $file = shift @_; + my $file = shift || croak "suck_file called without argument"; open(H,$file) || die "can't open '$file': $!"; my $content; while () { $content .= $_; } ; @@ -77,10 +98,10 @@ return $content; } -my $html_header=suck_file("header.html"); -my $html_separator=suck_file("separator.html"); -my $html_next=suck_file("next.html"); -my $html_footer=suck_file("footer.html"); +$html{'header'}=suck_file($include_files{'header'}); +$html{'separator'}=suck_file($include_files{'separator'}); +$html{'submit'}=suck_file($include_files{'submit'}); +$html{'footer'}=suck_file($include_files{'footer'}); #------------------------------------------------------------------ @@ -117,7 +138,7 @@ #------------------------------------------------------------------ -my $html_kraj=suck_file("thanks.html"); +$html{'kraj'}=suck_file($include_files{'thanks'}); #------------------------------------------------------------------ @@ -201,7 +222,7 @@ $page_nr++; open(PAGE, ">$poll/$next_fn") or die "Couldn't open $next_fn for writing:\n$!"; print PAGE php_header($page_nr,@last_sql_update); -print PAGE "$html_header $html_kraj $html_footer"; +print PAGE "$html{'header'} $html{'kraj'} $html{'footer'}"; close(PAGE); # dump sql structure @@ -483,7 +504,7 @@ @sql_update = (); $last_fn=sprintf("%02d.php",$page_nr); - $last_page="$html_header $body $html_next $html_footer"; + $last_page="$html{'header'} $body $html{'submit'} $html{'footer'}"; # delete vars for next page $page_nr++; $body=""; @@ -515,7 +536,7 @@ sub hr { - $body .= "
$html_separator
"; + $body .= "
$html{'separator'}
"; } sub br { @@ -604,6 +625,9 @@ my @dropdown_data; + my $default_value = x($attref->{default_value}) || 'null'; + my $default_text = x($attref->{default_text}) || '-'; + $$ncref = sub { my ($xp, $text) = @_; @@ -618,7 +642,7 @@ my $id=1; my $p=new_pit(); $body.="