/[wopi]/make_poll.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /make_poll.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by dpavlin, Tue Oct 21 15:15:08 2003 UTC revision 1.14 by dpavlin, Tue Oct 21 16:55:06 2003 UTC
# Line 10  use strict; Line 10  use strict;
10    
11  use XML::Parser;  use XML::Parser;
12  use common;  use common;
13    use Carp;
14    
15  $|=1;  $|=1;
16    
# Line 66  my $without_invitation=0; Line 67  my $without_invitation=0;
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 .= $_; } ;
# Line 77  sub suck_file { Line 98  sub suck_file {
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    
# Line 117  my $head_php=suck_file("head.php"); Line 138  my $head_php=suck_file("head.php");
138    
139  #------------------------------------------------------------------  #------------------------------------------------------------------
140    
141  my $html_kraj=suck_file("thanks.html");  $html{'kraj'}=suck_file($include_files{'thanks'});
142    
143  #------------------------------------------------------------------  #------------------------------------------------------------------
144    
# Line 201  close(PAGE); Line 222  close(PAGE);
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
# Line 483  sub page { Line 504  sub page {
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="";
# Line 515  sub nr { Line 536  sub nr {
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 {
# Line 776  sub html { Line 797  sub html {
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                  }                  }
# Line 801  sub config { Line 824  sub config {
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    

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.26