10 |
|
|
11 |
use XML::Parser; |
use XML::Parser; |
12 |
use common; |
use common; |
13 |
|
use Carp; |
14 |
|
|
15 |
$|=1; |
$|=1; |
16 |
|
|
67 |
# and users will see just "red" and "black" |
# and users will see just "red" and "black" |
68 |
my $remove_nrs_in_answers=0; |
my $remove_nrs_in_answers=0; |
69 |
|
|
70 |
|
# This defines files which will be included in various places to produce |
71 |
|
# design. You could desing them using your faviourite html editor (vim :-) |
72 |
|
# and then split them into separate files |
73 |
|
|
74 |
|
my %include_files = ( |
75 |
|
# this file is included at top of each paAge |
76 |
|
'header' => "header.html", |
77 |
|
# this file is used to separate questions |
78 |
|
'separator' => "separator.html", |
79 |
|
# this file is used to show "submit" button, which under multi-page |
80 |
|
# polls will also bring next page |
81 |
|
'submit' => "next.html", |
82 |
|
# this file is included at bottom of each page |
83 |
|
'footer' => "footer.html", |
84 |
|
# this file will be showen after poll is completed |
85 |
|
'thanks' => "thanks.html" |
86 |
|
); |
87 |
|
|
88 |
|
my %html; # buffer for suck(_file)ed html files |
89 |
|
|
90 |
#------------------------------------------------------------------ |
#------------------------------------------------------------------ |
91 |
|
|
92 |
sub suck_file { |
sub suck_file { |
93 |
my $file = shift @_; |
my $file = shift || croak "suck_file called without argument"; |
94 |
open(H,$file) || die "can't open '$file': $!"; |
open(H,$file) || die "can't open '$file': $!"; |
95 |
my $content; |
my $content; |
96 |
while (<H>) { $content .= $_; } ; |
while (<H>) { $content .= $_; } ; |
98 |
return $content; |
return $content; |
99 |
} |
} |
100 |
|
|
101 |
my $html_header=suck_file("header.html"); |
$html{'header'}=suck_file($include_files{'header'}); |
102 |
my $html_separator=suck_file("separator.html"); |
$html{'separator'}=suck_file($include_files{'separator'}); |
103 |
my $html_next=suck_file("next.html"); |
$html{'submit'}=suck_file($include_files{'submit'}); |
104 |
my $html_footer=suck_file("footer.html"); |
$html{'footer'}=suck_file($include_files{'footer'}); |
105 |
|
|
106 |
#------------------------------------------------------------------ |
#------------------------------------------------------------------ |
107 |
|
|
138 |
|
|
139 |
#------------------------------------------------------------------ |
#------------------------------------------------------------------ |
140 |
|
|
141 |
my $html_kraj=suck_file("thanks.html"); |
$html{'kraj'}=suck_file($include_files{'thanks'}); |
142 |
|
|
143 |
#------------------------------------------------------------------ |
#------------------------------------------------------------------ |
144 |
|
|
222 |
$page_nr++; |
$page_nr++; |
223 |
open(PAGE, ">$poll/$next_fn") or die "Couldn't open $next_fn for writing:\n$!"; |
open(PAGE, ">$poll/$next_fn") or die "Couldn't open $next_fn for writing:\n$!"; |
224 |
print PAGE php_header($page_nr,@last_sql_update); |
print PAGE php_header($page_nr,@last_sql_update); |
225 |
print PAGE "$html_header $html_kraj $html_footer"; |
print PAGE "$html{'header'} $html{'kraj'} $html{'footer'}"; |
226 |
close(PAGE); |
close(PAGE); |
227 |
|
|
228 |
# dump sql structure |
# dump sql structure |
504 |
@sql_update = (); |
@sql_update = (); |
505 |
|
|
506 |
$last_fn=sprintf("%02d.php",$page_nr); |
$last_fn=sprintf("%02d.php",$page_nr); |
507 |
$last_page="$html_header $body $html_next $html_footer"; |
$last_page="$html{'header'} $body $html{'submit'} $html{'footer'}"; |
508 |
# delete vars for next page |
# delete vars for next page |
509 |
$page_nr++; |
$page_nr++; |
510 |
$body=""; |
$body=""; |
536 |
|
|
537 |
|
|
538 |
sub hr { |
sub hr { |
539 |
$body .= "<br></td></tr>$html_separator<tr><td></td><td><br>"; |
$body .= "<br></td></tr>$html{'separator'}<tr><td></td><td><br>"; |
540 |
} |
} |
541 |
|
|
542 |
sub br { |
sub br { |
797 |
|
|
798 |
if (defined $text) { |
if (defined $text) { |
799 |
$body.=x($text); |
$body.=x($text); |
800 |
|
} elsif ($attref->{include}) { |
801 |
|
$body.=suck_file($attref->{include}); |
802 |
} else { |
} else { |
803 |
$body.="</p>"; |
$body.="</p>"; |
804 |
} |
} |
824 |
print "Pool is without need for unique ID (and invitation URLs).\n"; |
print "Pool is without need for unique ID (and invitation URLs).\n"; |
825 |
$remove_nrs_in_answers=x($attref->{$remove_nrs_in_answers}) && |
$remove_nrs_in_answers=x($attref->{$remove_nrs_in_answers}) && |
826 |
print "Numbers before answers will be removed.\n"; |
print "Numbers before answers will be removed.\n"; |
827 |
|
|
828 |
|
foreach my $file (qw(header separator submit footer thanks)) { |
829 |
|
if ($attref->{$file}) { |
830 |
|
$include_files{$file}=x($attref->{$file}); |
831 |
|
print "Using custom $file '$include_files{$file}'\n"; |
832 |
|
$html{$file} = suck_file($include_files{$file}); |
833 |
|
} |
834 |
|
} |
835 |
} |
} |
836 |
} |
} |
837 |
|
|