/[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.1 by dpavlin, Tue Apr 8 17:53:46 2003 UTC revision 1.3 by dpavlin, Thu Apr 24 16:43:09 2003 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2  #  #
3    
4    use strict;
5    
6  use XML::Parser;  use XML::Parser;
7    use Text::Iconv;
8    
9  use strict;  # output charset
10    my $charset='ISO-8859-2';
11    
12    Text::Iconv->raise_error(0);    # Conversion errors raise exceptions
13    my $from_utf8 = Text::Iconv->new('UTF8', $charset);
14    sub x {
15            return $from_utf8->convert($_[0]);
16    }
17    
18  $|=1;  $|=1;
19    
# Line 64  my $db_user="dpavlin"; Line 74  my $db_user="dpavlin";
74    
75  #------------------------------------------------------------------  #------------------------------------------------------------------
76    
77  my $html_header.=<<'End_of_header;';  sub suck_file {
78  <html>          my $file = shift @_;
79  <head>          open(H,$file) || die "can't open '$file': $!";
80  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">          my $content;
81          <title>proof.anketa</title><link rel="STYLESHEET" type="text/css" href="../stil.css">          while (<H>) { $content .= $_; } ;
82  </head>          close(H);
83            return $content;
84  <body background="../beki.gif" bgcolor="White" leftmargin=0 topmargin=0 marginwidth="0" marginheight="0">  }
   
 <table width="460" cellspacing="0" cellpadding="0" border="0">  
 <tr>  
     <td colspan="2"><img src="head.php" width=460 height=72 alt="" border="0"><br><br></td>  
 </tr>  
 <tr>  
     <td><img src="../klir.gif" width=20 height=1 alt="" border="0"><br>  
         </td>  
     <td><img src="../klir.gif" width=332 height=1 alt="" border="0"><br>        </td>  
 </tr>  
 <form method=post action="##NEXTPAGE##">  
 <input type=hidden name=a value="<?= $a ?>">  
 <input type=hidden name=id value="<?= $id ?>">  
   
 <tr>  
     <td> </td>  
     <td>  
 End_of_header;  
   
 #------------------------------------------------------------------  
   
 my $html_separator=<<'End_of_separator;';  
 <tr>  
     <td></td>  
     <td bgcolor="#006699"><img src="../klir.gif" width=1 height=1 alt="" border="0"><br></td>  
 </tr>  
 End_of_separator;  
   
 #------------------------------------------------------------------  
85    
86  my $html_footer=<<'End_of_footer;';  my $html_header=suck_file("header.html");
87  </td>  my $html_separator=suck_file("separator.html");
88  </tr>  my $html_next=suck_file("next.html");
89    my $html_footer=suck_file("footer.html");
 <tr>  
     <td> </td>  
     <td align="right"><br>  
 <input type=submit name="update" value="dalje.">&nbsp;&nbsp;  
 <br><br><br>  
 </td>  
 </tr>  
 </table>  
   
 </body>  
 </html>  
 End_of_footer;  
90    
91  #------------------------------------------------------------------  #------------------------------------------------------------------
92    
93  sub php_header {  sub php_header {
94  my ($page_nr,@sql_update) = @_;  my ($page_nr,@sql_update) = @_;
95  my $out='<?  my $out='<?php
96          include("common.inc");          include("common.php");
97          if (isset($update)) {          if (isset($update)) {
98                  $member_id=id_decode($a);                  $member_id=id_decode($a);
99                  ';                  ';
# Line 146  return $out; Line 115  return $out;
115  #------------------------------------------------------------------  #------------------------------------------------------------------
116    
117  # first, define some constants  # first, define some constants
118  my $common_inc='  my $common_php = suck_file("common.php");
 $PREFIX="'.$prefix.'";  
 $DB_USER="'.$db_user.'";  
 $MEMBERS_DB="'.$prefix.'_members";  
 ';  
   
 # then append rest of text  
   
 $common_inc.=<<'End_of_common;';  
   
 $conn = pg_connect("dbname=$PREFIX$db user=$DB_USER");  
 $result=pg_Exec($conn,"set datestyle = 'german'");  
   
 set_magic_quotes_runtime(1);  
   
 // return number of true answers  
   
 function fix_checkboxes($var,$nr) {  
         for($i=1; $i<=$nr; $i++) {  
                 if (isset($GLOBALS[$var."_".$i])) {  
                         $GLOBALS[$var."_".$i]="true";  
                         $nr++;  
                 } else {  
                         $GLOBALS[$var."_".$i]="false";  
                 }  
         }  
         return $nr;  
   
 }  
   
 function checked($var) {  
         if ($var == "true" || $var == "t") return 1;  
         return 0;  
 }  
   
 function id_encode($id) {  
         return md5($id).strtr($id,"1234567890","abcdef1234");  
 }  
   
 function id_decode($eid) {  
         $id=substr(strtr($eid,"abcdef1234","1234567890"),32);  
         if (md5($id) == substr($eid,0,32)) {  
                 return $id;  
         } else {  
                 return 0;  
         }  
 }  
   
 function fix_sql($sql) {  
         $sql=ereg_replace(",([ \t\n\r]*),",",null\\1,",$sql);  
         $sql=ereg_replace(",([ \t\n\r]*),",",null\\1,",$sql);  
         $sql=ereg_replace(",([ \t\n\r]*),",",null\\1,",$sql);  
         $sql=ereg_replace("=([ \t\n\r,]+)","=null\\1",$sql);  
         $sql=ereg_replace("=([ \t\n\r,]*)$","=null\\1",$sql);  
         return $sql;  
 }  
   
 function get_answer($p) {  
         global $conn,$id,$db;  
         $result = pg_Exec ($conn,"select $p from $db where id=$id");  
         if ($result && pg_numrows($result) > 0) {  
                 $row=pg_fetch_row($result,0);  
                 if (isset($row[0]) && $row[0] != "") {  
                         $GLOBALS[$p]=$row[0];  
                         return $row[0];  
                 }  
         }  
         $GLOBALS[$p]=0;  
         return 0;  
 }  
   
 function get_answers($p) {  
         global $conn,$id,$db;  
         $result = pg_Exec ($conn,"select $p from $db where id=$id");  
         if ($result && pg_numrows($result) > 0) {  
                 $row=pg_fetch_array($result,0);  
                 $pit=split(",",$p);  
                 while(list($key,$val) = each($row)) {  
                         $GLOBALS[$key]=$val;  
                 }  
         }  
 }  
 function get_member($pitanja,$uvjet) {  
         global $member_id;  
         $p_conn = pg_connect("dbname=$MEMBERS_DB user=$DB_USER");  
         if ($uvjet == "") $uvjet="true";  
         $result=pg_Exec($p_conn,"select id,$pitanja from member  
                 where $uvjet and id = $member_id");  
         $numrows=pg_numrows($result);  
         if ($numrows) {  
                 $row=pg_fetch_array($result,0);  
                 $pit=split(",",$pitanja);  
                 while(list($key,$val) = each($row)) {  
                         $GLOBALS["member_".$key]=$val;  
                 }  
         }  
 }  
   
 if (isset($a) && !isset($id) && !isset($pid)) {  
         global $conn,$db,$do_stranice;  
         $pid=id_decode($a);  
         $result = pg_Exec ($conn,"select id,do_stranice from $db where member_id=$pid");  
         if ($result && pg_numrows($result) > 0) {  
                 $row=pg_fetch_array($result,0);  
                 $id=$row[id];  
                 $do_stranice=$row[do_stranice];  
                 $do_uri="http://".$SERVER_NAME.":".$SERVER_PORT.$row[do_stranice];  
         }  
 }  
   
 End_of_common;  
119    
120  #------------------------------------------------------------------  #------------------------------------------------------------------
121    
122  my $head_php.=<<'End_of_head;';  my $head_php=suck_file("head.php");
   
         Header("Content-type: image/gif");  
         header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past  
         header ("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); // always modified  
         header ("Cache-Control: no-cache, must-revalidate");    // HTTP/1.1  
         header ("Pragma: no-cache");                            // HTTP/1.0  
         $string=implode($argv," ");  
         $im = imagecreatefromgif("head.gif");  
         $red = ImageColorAllocate($im, 255, 0, 0);  
         $black = ImageColorAllocate($im, 0, 0, 0);  
         $px = (imagesx($im)-7.5*strlen($string))/2;  
         if (! isset($pcnt)) {  
                 $pcnt=floor(substr(basename($HTTP_REFERER),0,2)/$max_page*100);  
         }  
         ImageTTFText($im, 6, 0, 10, 65, $black, dirname($PATH_TRANSLATED)."/head.ttf", "Ispunili ste ".sprintf("%02d",$pcnt)."% ankete");  
         $w=80;  
         ImageRectangle($im,149,60,151+$w,66,$black);  
         ImageFilledRectangle($im,150,61,150+floor($pcnt*$w/100),65,$red);  
         ImageGif($im);  
         ImageDestroy($im);  
   
 End_of_head;  
123    
124  #------------------------------------------------------------------  #------------------------------------------------------------------
125    
126  my $html_kraj=<<'End_of_kraj;';  my $html_kraj=suck_file("thanks.html");
 <html>  
 <head>  
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">  
         <title>wopi.poll</title><link rel="STYLESHEET" type="text/css" href="../stil.css">  
 </head>  
   
 <body background="../beki.gif" bgcolor="White" leftmargin=0 topmargin=0 marginwidth="0" marginheight="0">  
   
 <table width="460" cellspacing="0" cellpadding="0" border="0">  
 <tr>  
     <td colspan="2"><img src="head.php?pcnt=100" width=460 height=72 alt="" border="0"><br><br></td>  
 </tr>  
 <tr>  
     <td><img src="../klir.gif" width=20 height=1 alt="" border="0"><br>  
         </td>  
     <td><img src="../klir.gif" width=332 height=1 alt="" border="0"><br>        </td>  
 </tr>  
     <td><img src="../klir.gif" width=20 height=1 alt="" border="0"><br>  
         </td>  
     <td><img src="../klir.gif" width=332 height=1 alt="" border="0"><br>        </td>  
 </tr>  
 <tr>  
     <td> </td>  
     <td><br>  
 <p><b>  
 Hvala vam na sudjelovanju u anketi!  
 </b></p>  
 <br><br>  
 Zahvaljujemo se na vašem vremenu. Nadamo se da ćete i vi biti  
 među sretnim dobitnicima.  
 <br>  
 <br>  
 Do slijedeće ankete i nagradne igre srdačno vas pozdravljamo.  
 <br>  
 <br>Hvala.  
 <br>  
 <br>  
 <a href="http://www.proof.hr"><tt>proof.</tt></a>  
 </td>  
 </tr>  
 <tr>  
     <td></td>  
     <td bgcolor="#006699"><img src="../klir.gif" width=1 height=1 alt="" border="0"><br></td>  
 </tr>  
 <tr>  
     <td align="right" valign="top"></td>  
     <td> </td>  
     <td align="right"><br>  
 <br>  
 </td>  
 </tr>  
 </table>  
   
 </body>  
 </html>  
 End_of_kraj;  
127    
128  #------------------------------------------------------------------  #------------------------------------------------------------------
129    
# Line 447  close(PAGE); Line 228  close(PAGE);
228  $page_nr++;  $page_nr++;
229  open(PAGE, ">$dir/$next_fn") or die "Couldn't open $next_fn for writing:\n$!";  open(PAGE, ">$dir/$next_fn") or die "Couldn't open $next_fn for writing:\n$!";
230  print PAGE php_header($page_nr,@last_sql_update);  print PAGE php_header($page_nr,@last_sql_update);
231  print PAGE $html_kraj;  print PAGE "$html_header $html_kraj $html_footer";
232  close(PAGE);  close(PAGE);
233    
234  # dump sql structure  # dump sql structure
# Line 457  print SQL "create table poslani ( member Line 238  print SQL "create table poslani ( member
238  print SQL "create table $dir (do_stranice text default null, ",join(",\n",@sql_create),");\n";  print SQL "create table $dir (do_stranice text default null, ",join(",\n",@sql_create),");\n";
239  close(SQL);  close(SQL);
240    
241  # dump common.inc  # dump common.php
242    
243    open(PHP,">$dir/common.php") || die "common.php: $!";
244    $common_php =~ s/##DB##/$dir/g;
245    my $db_name = $prefix.$dir;
246    $common_php =~ s/##DB_NAME##/$db_name/g;
247    $common_php =~ s/##PREFIX##/$prefix/g;
248    $common_php =~ s/##DB_USER##/$db_user/g;
249    $common_php =~ s/##PREFIX##/$prefix/g;
250    my $members_db = $prefix."members";
251    $common_php =~ s/##MEMBERS_DB##/$members_db/g;
252    
253  open(PHP,">$dir/common.inc") || die "common.inc: $!";  print PHP $common_php;
 print PHP '<? $db="'.$dir.'";';  
 print PHP $common_inc;  
 print PHP '?>';  
254  close(PHP);  close(PHP);
255    
256  open(PHP,">$dir/head.php") || die "head.php: $!";  open(PHP,">$dir/head.php") || die "head.php: $!";
257  print PHP '<? $max_page="'.($page_nr+1).'";';  my $max_page = $page_nr - 1;
258    $head_php=~ s/##MAXPAGE##/$max_page/;
259    $head_php=~ s/##TEXT##/Ispunili ste %02d%% ankete/;
260  print PHP $head_php;  print PHP $head_php;
 print PHP '?>';  
261  close(PHP);  close(PHP);
262    
263  ################  ################
# Line 705  sub page { Line 494  sub page {
494                                  $last_fn="index.php" if ($last_fn eq "01.php");                                  $last_fn="index.php" if ($last_fn eq "01.php");
495                                  open(PAGE, ">$dir/$last_fn") or die "Couldn't open $last_fn for writing:\n$!";                                  open(PAGE, ">$dir/$last_fn") or die "Couldn't open $last_fn for writing:\n$!";
496                                  if ($page_nr == 2) {                                  if ($page_nr == 2) {
497                                          print PAGE '<?                                          print PAGE '<?php
498  include("common.inc");  include("common.php");
499  if (isset($do_stranice) && $do_stranice !="") {  if (isset($do_stranice) && $do_stranice !="") {
500          Header("Location: $do_uri?a=$a");          Header("Location: $do_uri?a=$a");
501          exit;          exit;
# Line 738  $sql="insert into '.$dir.' ( http_refere Line 527  $sql="insert into '.$dir.' ( http_refere
527                          @sql_update = ();                          @sql_update = ();
528                    
529                          $last_fn=sprintf("%02d.php",$page_nr);                          $last_fn=sprintf("%02d.php",$page_nr);
530                          $last_page="$html_header $body $html_footer";                          $last_page="$html_header $body $html_next $html_footer";
531                          # delete vars for next page                          # delete vars for next page
532                          $page_nr++;                          $page_nr++;
533                          $body="";                          $body="";
# Line 788  sub pit { Line 577  sub pit {
577                  my ($xp, $text) = @_;                  my ($xp, $text) = @_;
578    
579                  if (defined $text) {                  if (defined $text) {
580                          $body.=$text;                          $body.=x($text);
581                  } else {                  } else {
582                          $body.="</p>";                          $body.="</p>";
583                  }                  }
# Line 805  sub podpit { Line 594  sub podpit {
594                  my ($xp, $text) = @_;                  my ($xp, $text) = @_;
595    
596                  if (defined $text) {                  if (defined $text) {
597                          $body.=$text;                          $body.=x($text);
598                  } else {                  } else {
599                          $body.="</table>";                          $body.="</table>";
600                  }                  }
# Line 824  sub odg { Line 613  sub odg {
613                  my ($xp, $text) = @_;                  my ($xp, $text) = @_;
614    
615                  if (defined $text) {                  if (defined $text) {
616                          $body .= $text;                          $body .= x($text);
617                  } else {                  } else {
618                          $body .= "</p>";                          $body .= "</p>";
619                  }                  }
# Line 845  sub php { Line 634  sub php {
634                          $text=~s/ le / <= /g;                          $text=~s/ le / <= /g;
635                          $text=~s/ gt / > /g;                          $text=~s/ gt / > /g;
636                          $text=~s/ ge / >= /g;                          $text=~s/ ge / >= /g;
637                          $body.=$text;                          $body.=x($text);
638                  } else {                  } else {
639                          $body.="\n?>\n";                          $body.="\n?>\n";
640                  }                  }
# Line 867  sub dropdown { Line 656  sub dropdown {
656                          $text=~s/^\s*//g;                          $text=~s/^\s*//g;
657                          $text=~s/^[\d\.\s]+//g;                          $text=~s/^[\d\.\s]+//g;
658                          $text=~s/\s*$//g;                          $text=~s/\s*$//g;
659                          push @dropdown_data,$text if ($text ne "");                          push @dropdown_data,x($text) if ($text ne "");
660                  } else {                  } else {
661                          my $opt;                          my $opt;
662                          my $id=1;                          my $id=1;
# Line 897  sub textbox { Line 686  sub textbox {
686                  my $size=$attref->{size};                  my $size=$attref->{size};
687                  $size = 25 if (! defined $size || $size == 0);  # default                  $size = 25 if (! defined $size || $size == 0);  # default
688                  my $p=new_pit();                  my $p=new_pit();
689                  $body.="<input type=text name=$p size=$size >\n";                  $body.="<input type=text name=$p size=".x($size)." >\n";
690                  push @sql_create,"$p text";                  push @sql_create,"$p text";
691                  push @sql_update,"$p='\$$p'";                  push @sql_update,"$p='\$$p'";
692          }          }
# Line 935  sub radiobuttons { Line 724  sub radiobuttons {
724                          $text=~s/^\s*//g;                          $text=~s/^\s*//g;
725                          $text=~s/^[\d\.\s]+//g;                          $text=~s/^[\d\.\s]+//g;
726                          $text=~s/\s*$//g;                          $text=~s/\s*$//g;
727                          push @radiobuttons_data,$text if ($text ne "");                          push @radiobuttons_data,x($text) if ($text ne "");
728                  } else {                  } else {
729                          my $opt;                          my $opt;
730                          my $p=new_pit();                          my $p=new_pit();
# Line 980  sub checkboxes { Line 769  sub checkboxes {
769                          $text=~s/^\s*//g;                          $text=~s/^\s*//g;
770                          $text=~s/^[\d\.\s]+//g;                          $text=~s/^[\d\.\s]+//g;
771                          $text=~s/\s*$//g;                          $text=~s/\s*$//g;
772                          push @checkboxes_data,$text if ($text ne "");                          push @checkboxes_data,x($text) if ($text ne "");
773                  } else {                  } else {
774                          my $opt;                          my $opt;
775                          my $base_p=new_pit();                          my $base_p=new_pit();
# Line 999  sub checkboxes { Line 788  sub checkboxes {
788                                  if (defined($opt) && $opt ne "") {                                  if (defined($opt) && $opt ne "") {
789                                          $p=$base_p."_".$id;                                          $p=$base_p."_".$id;
790                                          $id++;                                          $id++;
791                                          $body .= $before if ($before);                                          $body .= x($before) if ($before);
792                                          $body.="<input type=checkbox name=$p>";                                          $body.="<input type=checkbox name=$p>";
793                                          $body .= $middle if ($middle);                                          $body .= x($middle) if ($middle);
794                                          $body .= "$opt" if (! $hide_description);                                          $body .= "$opt" if (! $hide_description);
795                                          $body .= $after if ($after);                                          $body .= x($after) if ($after);
796                                          $body.="\n";                                          $body.="\n";
797    
798                                          push @sql_create,"$p boolean";                                          push @sql_create,"$p boolean";
# Line 1017  sub checkboxes { Line 806  sub checkboxes {
806  }  }
807    
808  #---------------------------------------------------------------  #---------------------------------------------------------------
   
 sub slide {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   my $prev = $page_number ? slidename($page_number) : $index;  
   $page_number++;  
   my $fn = slidename($page_number);  
   my $next = slidename($page_number + 1);  
   
   open(SLIDE, ">$dir/$fn") or die "Couldn't open $fn for writing:\n$!";  
   
   print SLIDE $prolog;  
   
   undef @slidetitle;  
   $body = '';  
   $inlist = 0;  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         #ignore text at slide toplevel  
       }  
       else {  
         $Titles[$page_number] =  $slidetitle[0];  
   
         print SLIDE "<title>$slidetitle[0]</title>\n";  
         print SLIDE $style_link;  
         print SLIDE "</head>\n";  
   
         if ($dostyle) {  
           print SLIDE "<body>\n";  
         }  
         else {  
           print SLIDE "<body background=\"back.gif\">\n";  
         }  
         
         my $navbar = "<table class=\"navbar\" width=\"100%\"><tr>\n";  
         $navbar .= "<td align=\"left\"><a href=\"$prev\">Previous</td>\n";  
         $navbar .= "<td align=\"left\"><a href=\"$index\">Index</td>\n";  
         $navbar .= "<td align=\"right\"><a href=\"$next\">Next</td>\n";  
         $navbar .= "</table>\n";  
   
         print SLIDE "$navbar<hr>\n";  
         if ($dostyle) {  
           print SLIDE "<img class=\"logo\" src=\"logo.gif\">\n";  
           print SLIDE "<h1 class=\"title\">$slidetitle[1]</h1>\n";  
         }  
         else {  
           print SLIDE "<table width=\"100%\"><tr><td>\n";  
           print SLIDE "<img src=\"logo.gif\">\n";  
           print SLIDE "<td align=\"left\">";  
           print SLIDE "<h1>";  
           print SLIDE "<font size=\"7\" color=\"maroon\">$slidetitle[1]";  
           print SLIDE "</font></h1>\n";  
           print SLIDE "<tr><td colspan=\"2\">\n";  
           print SLIDE "<table width=\"80%\"><tr><td>\n";  
           print SLIDE "<font size=\"+2\">\n";  
         }  
         print SLIDE $body;  
   
         if ($inlist) {  
           print SLIDE "\n</$inlist>\n";  
         }  
   
         unless ($dostyle) {  
           print SLIDE "\n</font>\n";  
           print SLIDE "\n</table></table>\n";  
         }  
   
         print SLIDE "\n<hr>\n$navbar";  
         print SLIDE "</body>\n</html>\n";  
         close(SLIDE);  
       }  
     };  
 }  # End slide  
   
 sub title {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   if ($xp->current_element eq 'slide') {  
     start_mode($xp, 'pass');  
   
     $$ncref =  
       sub {  
         $slidetitle[0] = $Text;  
         $slidetitle[1] = $Markedup_Text;  
       };  
   }  
 }  # End title  
   
 sub point {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   if ($inlist and $inlist ne 'ul') {  
     $body .= "\n</$inlist>\n";  
     $inlist = 0;  
   }  
   
   unless ($inlist) {  
     $body .= "\n<ul>\n";  
   }  
   
   $inlist = 0;  
   
   if ($dostyle) {  
     $body .= "\n<li><div class=\"point\">";  
   }  
   else {  
     $body .= "\n<li>";  
   }  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         $text =~ s/\s+/ /g;  
         $body .= $text;  
       }  
       else {  
         if ($dostyle) {  
           $body .= "</div></li>";  
         }  
         $body .= "\n</$inlist>\n"  
           if $inlist;  
         $inlist = 'ul';  
       }  
     };  
   
 }  # End point  
   
 sub item {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   if ($inlist and $inlist ne 'ul') {  
     $body .= "\n</$inlist>\n";  
     $inlist = 0;  
   }  
   
   unless ($inlist) {  
     $body .= "\n<ul>\n";  
   }  
   
   $inlist = 0;  
   
   if ($dostyle) {  
     $body .= "\n<li><div class=\"item\">";  
   }  
   else {  
     $body .= "\n<li><font face=\"monospace\">";  
   }  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         $text =~ s/\s+/ /g;  
         $body .= $text;  
       }  
       else {  
         if ($dostyle) {  
           $body .= "</div></li>";  
         }  
         else {  
           $body .= "</font>";  
         }  
         $body .= "\n</$inlist>\n"  
           if $inlist;  
         $inlist = 'ul';  
       }  
     };  
 }  # End item  
   
 sub def {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   if ($inlist and $inlist ne 'dl') {  
     $body .= "\n</$inlist>\n";  
     $inlist = 0;  
   }  
   
   unless ($inlist) {  
     $body .= "\n<dl>\n";  
   }  
   
   $inlist = 0;  
   
   if ($dostyle) {  
     $body .= "<dt><span class=\"defterm\">";  
     $body .=  $attref->{term} ."</span></dt>\n";  
     $body .= "<dd><div class=\"def\">\n";  
   }  
   else {  
     $body .= "<dt><font face=\"monospace\" color=\"maroon\" style=\"bold\">";  
     $body .= $attref->{term} . "</font></dt>\n";  
     $body .= "<dd>";  
   }  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         $text =~ s/\s+/ /g;  
         $body .= $text;  
       }  
       else {  
         if ($dostyle) {  
           $body .= "</div></dd>\n";  
         }  
         $body .= "\n</$inlist>\n"  
           if $inlist;  
         $inlist = 'dl';  
       }  
     };  
 }  # End def  
   
 sub eg {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   if ($dostyle) {  
     $body .= "<div class=\"eg\"><pre>";  
   }  
   else {  
     $body .= "<table bgcolor=\"tan\" width=\"70%\"><tr><td>\n";  
     $body .= "<font size=\"+1\"><pre>";  
   }  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         $body .= $text;  
       }  
       else {  
         if ($dostyle) {  
           $body .= "</pre></div>\n";  
         }  
         else {  
           $body .= "</pre></font></td></tr></table>\n"  
         }  
       }  
     };  
 }  # End eg  
   
 sub key {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   if ($dostyle) {  
     $body .= "<span class=\"key\">";  
   }  
   else {  
     $body .= "<font face=\"monospace\" color=\"navy\">";  
   }  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         $body .= $text;  
       }  
       else {  
         if ($dostyle) {  
           $body .= "</span>";  
         }  
         else {  
           $body .= "</font>";  
         }  
       }  
     };  
 }  # End key  
   
 sub abstract {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   if ($dostyle) {  
     $body .= "<span class=\"abstract\">";  
   }  
   else {  
     $body .= "<font color=\"green\">";  
   }  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         $body .= $text;  
       }  
       else {  
         if ($dostyle) {  
           $body .= "</span>";  
         }  
         else {  
           $body .= "</font>";  
         }  
       }  
     };  
 }  # End abstract  
   
 sub screen {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   if ($dostyle) {  
     $body .= "<pre class=\"screen\">\n";  
   }  
   else {  
     $body .= "<table bgcolor=\"white\" border=\"1\" width=\"70%\"><tr><td>\n";  
     $body .= "<font size=\"+1\"><pre>";  
   }  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         $body .= $text;  
       }  
       else {  
         if ($dostyle) {  
           $body .= "</pre>\n";  
         }  
         else {  
           $body .= "</pre></td></tr></table>\n";  
         }  
       }  
     };  
 }  # End screen  
   
 sub input {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   if ($dostyle) {  
     $body .= "<span class=\"input\">";  
   }  
   else {  
     $body .= "<b>";  
   }  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         $body .= $text;  
       }  
       else {  
         if ($dostyle) {  
           $body .= "</span>";  
         }  
         else {  
           $body .= "</b>";  
         }  
       }  
     };  
 }  # End input  
   
 sub group {  
 }  # End group  
   
 sub text {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   $body .= "<p>\n";  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         $text =~ s/\s+/ /g;  
         $body .= $text;  
       }  
     };  
 }  # End text  
   
 sub book {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   start_mode($xp, 'object');  
   
   $$ncref =  
     sub {  
       my ($xp) = @_;  
   
       if ($dostyle) {  
         $body .= "<span class=\"booktitle\">";  
         $body .= sgml_escape($Object->{title});  
         $body .= "</span>\n";  
       }  
       else {  
         $body .= "<cite>" . sgml_escape($Object->{title}) . "</cite>\n";  
       }  
     };  
 }  
   
 sub aside {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   if ($dostyle) {  
     $body .= "<span class=\"aside\">[";  
   }  
   else {  
     $body .= "<em>[";  
   }  
     
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined $text) {  
         $body .= $text;  
       }  
       else {  
         if ($dostyle) {  
           $body .= "]</span>\n";  
         }  
         else {  
           $body .= "]</em>";  
         }  
       }  
     };  
 }  
   
 sub url {  
   package main;  
   
   my ($xp, $el, $attref, $ncref) = @_;  
   
   my $url='';  
   
   $$ncref =  
     sub {  
       my ($xp, $text) = @_;  
   
       if (defined($text)) {  
         $url .= $text;  
       }  
       else {  
         $body .= "<a href=\"$url\">$url</a>";  
       }  
     }  
 }  
   
 ## Local Variables: ##  
 ## mode:perl ##  
 ## End: ##  

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.26