1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
# |
# |
3 |
|
# Dobrica Pavlinusic <dpavlin@rot13.org> |
4 |
use XML::Parser; |
# |
5 |
|
# Originally made for proof. during April 2001; later released under GPL v2 |
6 |
|
# |
7 |
|
# 2003-04-dd general cleanup in preparation of release |
8 |
|
|
9 |
use strict; |
use strict; |
10 |
|
|
11 |
|
use XML::Parser; |
12 |
|
use common; |
13 |
|
|
14 |
$|=1; |
$|=1; |
15 |
|
|
16 |
my $Usage =<<'End_of_Usage;'; |
my $Usage =<<'End_of_Usage;'; |
17 |
slides [-h] [-d dir] [-mode mode] slide-doc |
I will write usage information here. I promise! |
|
|
|
|
Convert a slideshow document into html, with a separate html document |
|
|
for each slide and an index to all of them. |
|
|
|
|
|
-h Print this message and exit |
|
|
|
|
|
-w warn about unrecognized tags |
|
|
|
|
|
-d Use dir as directory into which to write html pages. Defaults |
|
|
to basename of supplied doc file. |
|
|
|
|
|
-mode Output mode. Choices are html, html-style. Default is |
|
|
html-style. |
|
|
|
|
18 |
End_of_Usage; |
End_of_Usage; |
19 |
|
|
20 |
my @Modes = qw(object pass skip); |
my @Modes = qw(object pass skip); |
21 |
|
|
22 |
my $dir; |
my $poll; |
23 |
my $dowarn = 1; |
my $dowarn = 1; |
|
my $dostyle = 0; |
|
24 |
|
|
25 |
my $pitanje_nr = 0; # curr. pitanje |
my $pitanje_nr = 0; # curr. pitanje |
26 |
my $pitanje_tag = ""; # originalni oblik broja pitanja |
my $pitanje_tag = ""; # originalni oblik broja pitanja |
53 |
# this is usename in database |
# this is usename in database |
54 |
my $db_user="dpavlin"; |
my $db_user="dpavlin"; |
55 |
|
|
56 |
#------------------------------------------------------------------ |
# This option allows users to fill poll without using invitation URL. |
57 |
|
# That also means it's unpossible for them to return to exiting poll |
58 |
my $html_header.=<<'End_of_header;'; |
# because they don't have thair own unique ID. Howver, it enables simple |
59 |
<html> |
# polls to be conducted by just publishing URL to them. |
60 |
<head> |
my $without_invitation=0; |
61 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
62 |
<title>proof.anketa</title><link rel="STYLESHEET" type="text/css" href="../stil.css"> |
# This will remove numbers before answers. That enables you to have |
63 |
</head> |
# answers written like: |
64 |
|
# 1.1 red |
65 |
<body background="../beki.gif" bgcolor="White" leftmargin=0 topmargin=0 marginwidth="0" marginheight="0"> |
# 1.2 black |
66 |
|
# and users will see just "red" and "black" |
67 |
<table width="460" cellspacing="0" cellpadding="0" border="0"> |
my $remove_nrs_in_answers=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; |
|
68 |
|
|
69 |
#------------------------------------------------------------------ |
#------------------------------------------------------------------ |
70 |
|
|
71 |
my $html_separator=<<'End_of_separator;'; |
sub suck_file { |
72 |
<tr> |
my $file = shift @_; |
73 |
<td></td> |
open(H,$file) || die "can't open '$file': $!"; |
74 |
<td bgcolor="#006699"><img src="../klir.gif" width=1 height=1 alt="" border="0"><br></td> |
my $content; |
75 |
</tr> |
while (<H>) { $content .= $_; } ; |
76 |
End_of_separator; |
close(H); |
77 |
|
return $content; |
78 |
#------------------------------------------------------------------ |
} |
79 |
|
|
80 |
my $html_footer=<<'End_of_footer;'; |
my $html_header=suck_file("header.html"); |
81 |
</td> |
my $html_separator=suck_file("separator.html"); |
82 |
</tr> |
my $html_next=suck_file("next.html"); |
83 |
|
my $html_footer=suck_file("footer.html"); |
|
<tr> |
|
|
<td> </td> |
|
|
<td align="right"><br> |
|
|
<input type=submit name="update" value="dalje."> |
|
|
<br><br><br> |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
|
|
|
</body> |
|
|
</html> |
|
|
End_of_footer; |
|
84 |
|
|
85 |
#------------------------------------------------------------------ |
#------------------------------------------------------------------ |
86 |
|
|
87 |
sub php_header { |
sub php_header { |
88 |
my ($page_nr,@sql_update) = @_; |
my ($page_nr,@sql_update) = @_; |
89 |
my $out='<? |
my $out='<?php |
90 |
include("common.inc"); |
include_once("common.php"); |
91 |
if (isset($update)) { |
if (isset($update)) { |
92 |
$member_id=id_decode($a); |
$member_id=id_decode($a); |
93 |
'; |
'; |
94 |
$out.=$php_addon[$page_nr-2] if (defined $php_addon[$page_nr-2]); |
$out.=$php_addon[$page_nr-2] if (defined $php_addon[$page_nr-2]); |
95 |
$out.=' |
$out.=' |
96 |
$sql="update '.$dir.' set '.join(",\n",@sql_update).', |
$sql="update '.$poll.' set '.join(",\n",@sql_update).', |
97 |
do_stranice=\'$PHP_SELF\' |
do_stranice=\'$PHP_SELF\' |
98 |
where id=$id"; |
where id=$id"; |
99 |
# print "<pre>$sql</pre>"; |
# print "<pre>$sql</pre>"; |
100 |
$result=pg_Exec($conn,fix_sql($sql)); |
$result=pg_Exec($conn,fix_sql($sql)); |
101 |
} elseif($do_stranice != $PHP_SELF) { |
} elseif($do_stranice != $PHP_SELF && isset($do_uri) && isset($a)) { |
102 |
Header("Location: $do_uri?a=$a"); |
Header("Location: $do_uri?a=$a"); |
103 |
exit; |
exit; |
104 |
} |
} |
109 |
#------------------------------------------------------------------ |
#------------------------------------------------------------------ |
110 |
|
|
111 |
# first, define some constants |
# first, define some constants |
112 |
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; |
|
113 |
|
|
114 |
#------------------------------------------------------------------ |
#------------------------------------------------------------------ |
115 |
|
|
116 |
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; |
|
117 |
|
|
118 |
#------------------------------------------------------------------ |
#------------------------------------------------------------------ |
119 |
|
|
120 |
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; |
|
121 |
|
|
122 |
#------------------------------------------------------------------ |
#------------------------------------------------------------------ |
123 |
|
|
128 |
print $Usage; |
print $Usage; |
129 |
exit; |
exit; |
130 |
} |
} |
|
elsif ($opt eq '-d') { |
|
|
$dir = shift; |
|
|
} |
|
|
elsif ($opt eq '-w') { |
|
|
$dowarn = 1; |
|
|
} |
|
|
elsif ($opt eq '-mode') { |
|
|
my $marg = shift; |
|
|
if ($marg eq 'html') { |
|
|
$dostyle = 0; |
|
|
} |
|
|
else { |
|
|
die "Unrecognized mode: $marg\n$Usage"; |
|
|
} |
|
|
} |
|
|
else { |
|
|
die "Unrecognized option: $opt\n$Usage"; |
|
|
} |
|
131 |
} # End of option processing |
} # End of option processing |
132 |
|
|
133 |
my $docfile = shift; |
my $xmlfile = shift; |
134 |
|
|
135 |
die "No docfile provided:\n$Usage" unless defined $docfile; |
die "No poll xml file provided!\n$Usage" unless defined $xmlfile; |
136 |
|
|
137 |
die "Can't read $docfile" unless -r $docfile; |
die "Can't read $xmlfile" unless -r $xmlfile; |
138 |
|
|
139 |
if (defined $dir) { |
if (defined $poll) { |
140 |
die "$dir isn't a directory" unless -d $dir; |
die "$poll isn't a directory" unless -d $poll; |
141 |
} |
} |
142 |
else { |
else { |
143 |
$docfile =~ m!([^/.]+)(?:\.[^/.]*)?$!; |
$xmlfile =~ m!([^/.]+)(?:\.[^/.]*)?$!; |
144 |
$dir = $1; |
$poll = $1; |
145 |
if (-e $dir) { |
if (-e $poll) { |
146 |
die "$dir exists but isn't a directory" |
die "$poll exists but isn't a directory" |
147 |
unless -d $dir; |
unless -d $poll; |
148 |
} |
} |
149 |
else { |
else { |
150 |
mkdir $dir, 0755; |
mkdir $poll, 0755; |
151 |
} |
} |
152 |
} |
} |
153 |
|
|
154 |
my $in_slideshow = 0; |
my $in_poll = 0; |
155 |
my $after_head = 0; |
my $after_head = 0; |
156 |
|
|
157 |
my $Mode = 0; |
my $Mode = 0; |
162 |
my $Object; |
my $Object; |
163 |
my @Ostack = (); |
my @Ostack = (); |
164 |
|
|
165 |
my $intext = 0; |
#my $intext = 0; |
166 |
my $closure; |
my $closure; |
167 |
my @closure_stack = (); |
my @closure_stack = (); |
168 |
|
|
169 |
my $style_link = ''; |
#my $style_link = ''; |
170 |
|
|
171 |
my $index = 'index.html'; |
#my $index = 'index.html'; |
172 |
my @slidetitle; |
#my @slidetitle; |
173 |
my $body; |
my $body; |
174 |
my $inlist = 0; |
#my $inlist = 0; |
175 |
|
|
176 |
my @Titles; |
#my @Titles; |
177 |
|
|
178 |
my $header; |
my $header; |
179 |
|
|
|
my $prolog = "<html><head>\n"; |
|
|
$prolog .= "<!-- Generated by $0 on " . gmtime() . " GMT -->\n"; |
|
|
|
|
180 |
my $page_number = 0; |
my $page_number = 0; |
181 |
|
|
182 |
my $p = new XML::Parser(ErrorContext => 3, |
my $p = new XML::Parser(ErrorContext => 3, |
183 |
Handlers => {Start => \&starthndl, |
Handlers => {Start => \&starthndl, |
184 |
End => \&endhndl, |
End => \&endhndl, |
185 |
Char => \&text}); |
Char => \&text}); |
186 |
$p->parsefile($docfile); |
$p->parsefile($xmlfile); |
187 |
|
|
188 |
#---------------------------------------------------------- |
#---------------------------------------------------------- |
189 |
|
|
191 |
|
|
192 |
print "p[$page_nr] "; |
print "p[$page_nr] "; |
193 |
|
|
194 |
open(PAGE, ">$dir/$last_fn") or die "Couldn't open $last_fn for writing:\n$!"; |
open(PAGE, ">$poll/$last_fn") or die "Couldn't open $last_fn for writing:\n$!"; |
195 |
print PAGE php_header($page_nr,@prelast_sql_update); |
print PAGE php_header($page_nr,@prelast_sql_update); |
196 |
my $next_fn=sprintf("%02d.php",$page_nr); |
my $next_fn=sprintf("%02d.php",$page_nr); |
197 |
$last_page=~s/##NEXTPAGE##/$next_fn/; |
$last_page=~s/##NEXTPAGE##/$next_fn/; |
199 |
close(PAGE); |
close(PAGE); |
200 |
|
|
201 |
$page_nr++; |
$page_nr++; |
202 |
open(PAGE, ">$dir/$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$!"; |
203 |
print PAGE php_header($page_nr,@last_sql_update); |
print PAGE php_header($page_nr,@last_sql_update); |
204 |
print PAGE $html_kraj; |
print PAGE "$html_header $html_kraj $html_footer"; |
205 |
close(PAGE); |
close(PAGE); |
206 |
|
|
207 |
# dump sql structure |
# dump sql structure |
208 |
|
|
209 |
open(SQL,">$dir/$dir.sql") || die "$dir.sql: $!"; |
open(SQL,">$poll/$poll.sql") || die "$poll.sql: $!"; |
210 |
|
print SQL "drop database ".$prefix.$poll.";\n"; |
211 |
|
print SQL "create database ".$prefix.$poll.";\n"; |
212 |
|
print SQL "\\connect ".$prefix.$poll.";\n"; |
213 |
print SQL "create table poslani ( member_id int4 not null, unesen timestamp default now() );\n"; |
print SQL "create table poslani ( member_id int4 not null, unesen timestamp default now() );\n"; |
214 |
print SQL "create table $dir (do_stranice text default null, ",join(",\n",@sql_create),");\n"; |
print SQL "create table $poll (do_stranice text default null, ",join(",\n",@sql_create),");\n"; |
215 |
close(SQL); |
close(SQL); |
216 |
|
|
217 |
# dump common.inc |
# dump common.php |
218 |
|
|
219 |
open(PHP,">$dir/common.inc") || die "common.inc: $!"; |
open(PHP,">$poll/common.php") || die "common.php: $!"; |
220 |
print PHP '<? $db="'.$dir.'";'; |
$common_php =~ s/##DB##/$poll/g; |
221 |
print PHP $common_inc; |
my $db_name = $prefix.$poll; |
222 |
print PHP '?>'; |
$common_php =~ s/##DB_NAME##/$db_name/g; |
223 |
|
$common_php =~ s/##PREFIX##/$prefix/g; |
224 |
|
$common_php =~ s/##DB_USER##/$db_user/g; |
225 |
|
$common_php =~ s/##PREFIX##/$prefix/g; |
226 |
|
my $members_db = $prefix."members"; |
227 |
|
$common_php =~ s/##MEMBERS_DB##/$members_db/g; |
228 |
|
$common_php =~ s/##WITHOUT_INVITATION##/$without_invitation/g; |
229 |
|
|
230 |
|
print PHP $common_php; |
231 |
close(PHP); |
close(PHP); |
232 |
|
|
233 |
open(PHP,">$dir/head.php") || die "head.php: $!"; |
open(PHP,">$poll/head.php") || die "head.php: $!"; |
234 |
print PHP '<? $max_page="'.($page_nr+1).'";'; |
my $max_page = $page_nr - 1; |
235 |
|
$head_php=~ s/##MAXPAGE##/$max_page/; |
236 |
|
$head_php=~ s/##TEXT##/Ispunili ste %02d%% ankete/; |
237 |
print PHP $head_php; |
print PHP $head_php; |
|
print PHP '?>'; |
|
238 |
close(PHP); |
close(PHP); |
239 |
|
|
240 |
|
# 01.php -> index.php |
241 |
|
rename "$poll/01.php","$poll/index.php" || die "can't rename '$poll/01.php' to index.php"; |
242 |
|
|
243 |
################ |
################ |
244 |
## End of main |
## End of main |
245 |
################ |
################ |
246 |
|
|
247 |
# return unique name of pitanje |
# return unique name of pitanje |
248 |
sub new_pit { |
sub new_pit { |
249 |
my $out="p".$pitanje_nr.$p_suffix; |
my $out="p".$pitanje_nr; |
250 |
|
$out .= "_".$p_suffix if ($p_suffix); |
251 |
$curr_suffix=$p_suffix; |
$curr_suffix=$p_suffix; |
252 |
$p_suffix++; |
$p_suffix++; |
253 |
return $out; |
return $out; |
258 |
return "p".$pitanje_nr.$curr_suffix; |
return "p".$pitanje_nr.$curr_suffix; |
259 |
} |
} |
260 |
|
|
261 |
|
#---------------------------------------------------------- |
262 |
|
|
263 |
sub starthndl { |
sub starthndl { |
264 |
my ($xp, $el, %atts) = @_; |
my ($xp, $el, %atts) = @_; |
265 |
|
|
266 |
# return unless ($in_slideshow or $el eq 'slideshow'); |
# return unless ($in_poll or $el eq 'slideshow'); |
267 |
|
|
268 |
unless ($in_slideshow) { |
unless ($in_poll) { |
269 |
$in_slideshow = $xp->depth + 1; |
$in_poll = $xp->depth + 1; |
270 |
return; |
return; |
271 |
} |
} |
272 |
|
|
313 |
|
|
314 |
my $new_closure; |
my $new_closure; |
315 |
|
|
316 |
my $subname = "Slideshow::$el"; |
my $subname = "Poll::$el"; |
317 |
|
|
318 |
if (defined &$subname) { |
if (defined &$subname) { |
319 |
no strict 'refs'; |
no strict 'refs'; |
321 |
&$subname($xp, $el, \%atts, \$new_closure); |
&$subname($xp, $el, \%atts, \$new_closure); |
322 |
} |
} |
323 |
else { |
else { |
324 |
$body .= $xp->recognized_string; |
$body .= x($xp->recognized_string); |
325 |
$new_closure = |
$new_closure = |
326 |
sub { |
sub { |
327 |
my ($xp, $text) = @_; |
my ($xp, $text) = @_; |
328 |
|
|
329 |
if (defined $text) { |
if (defined $text) { |
330 |
$body .= $text; |
$body .= x($text); |
331 |
} |
} |
332 |
else { |
else { |
333 |
$body .= "</$el>"; |
$body .= x("</$el>"); |
334 |
} |
} |
335 |
}; |
}; |
336 |
} |
} |
342 |
sub endhndl { |
sub endhndl { |
343 |
my ($xp, $el) = @_; |
my ($xp, $el) = @_; |
344 |
|
|
345 |
return unless $in_slideshow; |
return unless $in_poll; |
346 |
|
|
347 |
my $lev = $xp->depth; |
my $lev = $xp->depth; |
348 |
|
|
349 |
if ($lev == $in_slideshow - 1) { |
if ($lev == $in_poll - 1) { |
350 |
$in_slideshow = 0; |
$in_poll = 0; |
351 |
$xp->finish; |
$xp->finish; |
352 |
return; |
return; |
353 |
} |
} |
397 |
$closure = pop(@closure_stack); |
$closure = pop(@closure_stack); |
398 |
} # End endhndl |
} # End endhndl |
399 |
|
|
400 |
|
#---------------------------------------------------------- |
401 |
|
|
402 |
sub text { |
sub text { |
403 |
my ($xp, $data) = @_; |
my ($xp, $data) = @_; |
404 |
|
|
405 |
return unless $in_slideshow; |
return unless $in_poll; |
406 |
|
|
407 |
if ($Mode ) { |
if ($Mode ) { |
408 |
|
|
452 |
$str; |
$str; |
453 |
} # End sgml_escape |
} # End sgml_escape |
454 |
|
|
|
sub slidename { |
|
|
my ($num) = @_; |
|
|
|
|
|
sprintf("slide%03d.html", $num); |
|
|
} # End slidename |
|
455 |
|
|
456 |
################################################################ |
################################################################ |
457 |
|
|
458 |
package Slideshow; |
package Poll; |
459 |
|
|
460 |
sub page { |
sub page { |
461 |
package main; |
package main; |
470 |
print "p[$page_nr] "; |
print "p[$page_nr] "; |
471 |
|
|
472 |
if (defined $last_fn) { |
if (defined $last_fn) { |
473 |
# 01.php -> index.php |
open(PAGE, ">$poll/$last_fn") or die "Couldn't open $last_fn for writing:\n$!"; |
474 |
$last_fn="index.php" if ($last_fn eq "01.php"); |
print PAGE php_header($page_nr,@prelast_sql_update); |
|
open(PAGE, ">$dir/$last_fn") or die "Couldn't open $last_fn for writing:\n$!"; |
|
|
if ($page_nr == 2) { |
|
|
print PAGE '<? |
|
|
include("common.inc"); |
|
|
if (isset($do_stranice) && $do_stranice !="") { |
|
|
Header("Location: $do_uri?a=$a"); |
|
|
exit; |
|
|
} |
|
|
$member_id=id_decode($a); |
|
|
$sql="insert into '.$dir.' ( http_referer,remote_addr,user_agent, member_id ) values (\'$HTTP_REFERER\',\'$REMOTE_ADDR\',\'$HTTP_USER_AGENT\',$member_id)"; |
|
|
|
|
|
# print "<pre>$sql</pre>"; |
|
|
$result=pg_Exec($conn,fix_sql($sql)); |
|
|
$lastoid=pg_getlastoid($result); |
|
|
$result = pg_Exec($conn,fix_sql("select id from '.$dir.' where oid=$lastoid")); |
|
|
$row=pg_fetch_row($result,0); |
|
|
$id=$row[0]; |
|
|
?>'; |
|
|
|
|
|
} else { |
|
|
print PAGE php_header($page_nr,@prelast_sql_update); |
|
|
} # last_sql_update |
|
|
|
|
|
|
|
475 |
my $next_fn=sprintf("%02d.php",$page_nr); |
my $next_fn=sprintf("%02d.php",$page_nr); |
476 |
$last_page=~s/##NEXTPAGE##/$next_fn/; |
$last_page=~s/##NEXTPAGE##/$next_fn/; |
477 |
print PAGE $last_page; |
print PAGE $last_page; |
483 |
@sql_update = (); |
@sql_update = (); |
484 |
|
|
485 |
$last_fn=sprintf("%02d.php",$page_nr); |
$last_fn=sprintf("%02d.php",$page_nr); |
486 |
$last_page="$html_header $body $html_footer"; |
$last_page="$html_header $body $html_next $html_footer"; |
487 |
# delete vars for next page |
# delete vars for next page |
488 |
$page_nr++; |
$page_nr++; |
489 |
$body=""; |
$body=""; |
501 |
$$ncref = sub { |
$$ncref = sub { |
502 |
my ($xp, $text) = @_; |
my ($xp, $text) = @_; |
503 |
if (defined($text)) { |
if (defined($text)) { |
504 |
$body.=$text; |
$body.=x($text); |
505 |
chomp $text; |
chomp $text; |
506 |
$pitanje_tag .= $text; |
$pitanje_tag .= x($text); |
507 |
} else { |
} else { |
508 |
$pitanje_nr = $pitanje_tag; |
$pitanje_nr = $pitanje_tag; |
509 |
$pitanje_nr =~ s/[^0-9a-zA-Z]//g; |
$pitanje_nr =~ s/[^0-9a-zA-Z]//g; |
533 |
my ($xp, $text) = @_; |
my ($xp, $text) = @_; |
534 |
|
|
535 |
if (defined $text) { |
if (defined $text) { |
536 |
$body.=$text; |
$body.=x($text); |
537 |
} else { |
} else { |
538 |
$body.="</p>"; |
$body.="</p>"; |
539 |
} |
} |
550 |
my ($xp, $text) = @_; |
my ($xp, $text) = @_; |
551 |
|
|
552 |
if (defined $text) { |
if (defined $text) { |
553 |
$body.=$text; |
$body.=x($text); |
554 |
} else { |
} else { |
555 |
$body.="</table>"; |
$body.="</table>"; |
556 |
} |
} |
569 |
my ($xp, $text) = @_; |
my ($xp, $text) = @_; |
570 |
|
|
571 |
if (defined $text) { |
if (defined $text) { |
572 |
$body .= $text; |
$body .= x($text); |
573 |
} else { |
} else { |
574 |
$body .= "</p>"; |
$body .= "</p>"; |
575 |
} |
} |
590 |
$text=~s/ le / <= /g; |
$text=~s/ le / <= /g; |
591 |
$text=~s/ gt / > /g; |
$text=~s/ gt / > /g; |
592 |
$text=~s/ ge / >= /g; |
$text=~s/ ge / >= /g; |
593 |
$body.=$text; |
$body.=x($text); |
594 |
} else { |
} else { |
595 |
$body.="\n?>\n"; |
$body.="\n?>\n"; |
596 |
} |
} |
604 |
|
|
605 |
my @dropdown_data; |
my @dropdown_data; |
606 |
|
|
607 |
|
my $default_value = x($attref->{default_value}) || 'null'; |
608 |
|
my $default_text = x($attref->{default_text}) || '-'; |
609 |
|
|
610 |
$$ncref = sub { |
$$ncref = sub { |
611 |
my ($xp, $text) = @_; |
my ($xp, $text) = @_; |
612 |
|
|
613 |
if (defined $text) { |
if (defined $text) { |
614 |
chomp $text; |
chomp $text; |
615 |
$text=~s/^\s*//g; |
$text=~s/^\s*//g; |
616 |
$text=~s/^[\d\.\s]+//g; |
$text=~s/^[\d\.\s]+//g if ($remove_nrs_in_answers); |
617 |
$text=~s/\s*$//g; |
$text=~s/\s*$//g; |
618 |
push @dropdown_data,$text if ($text ne ""); |
push @dropdown_data,x($text) if ($text ne ""); |
619 |
} else { |
} else { |
620 |
my $opt; |
my $opt; |
621 |
my $id=1; |
my $id=1; |
622 |
my $p=new_pit(); |
my $p=new_pit(); |
623 |
$body.="<select name=$p >\n"; |
$body.="<select name=$p >\n"; |
624 |
$body.="<option value=null>-</option>\n"; |
$body.="<option value=\"$default_value\">$default_text</option>\n"; |
625 |
foreach $opt (@dropdown_data) { |
foreach $opt (@dropdown_data) { |
626 |
if (defined($opt) && $opt ne "") { |
if (defined($opt) && $opt ne "") { |
627 |
$body.="<option value=$id>$opt</option>\n"; |
$body.="<option value=$id>$opt</option>\n"; |
645 |
my $size=$attref->{size}; |
my $size=$attref->{size}; |
646 |
$size = 25 if (! defined $size || $size == 0); # default |
$size = 25 if (! defined $size || $size == 0); # default |
647 |
my $p=new_pit(); |
my $p=new_pit(); |
648 |
$body.="<input type=text name=$p size=$size >\n"; |
$body.="<input type=text name=$p size=".x($size)." >\n"; |
649 |
push @sql_create,"$p text"; |
push @sql_create,"$p text"; |
650 |
push @sql_update,"$p='\$$p'"; |
push @sql_update,"$p='\$$p'"; |
651 |
} |
} |
681 |
if (defined $text) { |
if (defined $text) { |
682 |
chomp $text; |
chomp $text; |
683 |
$text=~s/^\s*//g; |
$text=~s/^\s*//g; |
684 |
$text=~s/^[\d\.\s]+//g; |
$text=~s/^[\d\.\s]+//g if ($remove_nrs_in_answers); |
685 |
$text=~s/\s*$//g; |
$text=~s/\s*$//g; |
686 |
push @radiobuttons_data,$text if ($text ne ""); |
push @radiobuttons_data,x($text) if ($text ne ""); |
687 |
} else { |
} else { |
688 |
my $opt; |
my $opt; |
689 |
my $p=new_pit(); |
my $p=new_pit(); |
726 |
if (defined $text) { |
if (defined $text) { |
727 |
chomp $text; |
chomp $text; |
728 |
$text=~s/^\s*//g; |
$text=~s/^\s*//g; |
729 |
$text=~s/^[\d\.\s]+//g; |
$text=~s/^[\d\.\s]+//g if ($remove_nrs_in_answers); |
730 |
$text=~s/\s*$//g; |
$text=~s/\s*$//g; |
731 |
push @checkboxes_data,$text if ($text ne ""); |
push @checkboxes_data,x($text) if ($text ne ""); |
732 |
} else { |
} else { |
733 |
my $opt; |
my $opt; |
734 |
my $base_p=new_pit(); |
my $base_p=new_pit(); |
747 |
if (defined($opt) && $opt ne "") { |
if (defined($opt) && $opt ne "") { |
748 |
$p=$base_p."_".$id; |
$p=$base_p."_".$id; |
749 |
$id++; |
$id++; |
750 |
$body .= $before if ($before); |
$body .= x($before) if ($before); |
751 |
$body.="<input type=checkbox name=$p>"; |
$body.="<input type=checkbox name=$p>"; |
752 |
$body .= $middle if ($middle); |
$body .= x($middle) if ($middle); |
753 |
$body .= "$opt" if (! $hide_description); |
$body .= "$opt" if (! $hide_description); |
754 |
$body .= $after if ($after); |
$body .= x($after) if ($after); |
755 |
$body.="\n"; |
$body.="\n"; |
756 |
|
|
757 |
push @sql_create,"$p boolean"; |
push @sql_create,"$p boolean"; |
764 |
} |
} |
765 |
} |
} |
766 |
|
|
767 |
#--------------------------------------------------------------- |
print "\n\nTo create database for poll $poll use:\n\n"; |
768 |
|
print "\$ psql template1 < $poll/$poll.sql\n\n"; |
769 |
sub slide { |
print "THIS WILL DISTROY ALL DATA IN EXISTING DATABASE ".$prefix.$poll." !!\n"; |
|
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; |
|
770 |
|
|
771 |
my ($xp, $el, $attref, $ncref) = @_; |
# read configuration data |
772 |
|
# |
773 |
if ($dostyle) { |
# FIX: write actually this :-) |
774 |
$body .= "<span class=\"aside\">["; |
sub config { |
775 |
} |
package main; |
776 |
else { |
my ($xp, $el, $attref, $ncref) = @_; |
|
$body .= "<em>["; |
|
|
} |
|
|
|
|
|
|
|
|
$$ncref = |
|
|
sub { |
|
|
my ($xp, $text) = @_; |
|
777 |
|
|
778 |
if (defined $text) { |
$$ncref = sub { |
779 |
$body .= $text; |
my ($xp, $text) = @_; |
780 |
} |
$db_user=x($attref->{db_user}); |
781 |
else { |
$prefix=x($attref->{prefix}); |
782 |
if ($dostyle) { |
$without_invitation=x($attref->{without_invitation}) && |
783 |
$body .= "]</span>\n"; |
print "Pool is without need for unique ID (and invitation URLs).\n"; |
784 |
} |
$remove_nrs_in_answers=x($attref->{$remove_nrs_in_answers}) && |
785 |
else { |
print "Numbers before answers will be removed.\n"; |
|
$body .= "]</em>"; |
|
786 |
} |
} |
|
} |
|
|
}; |
|
787 |
} |
} |
788 |
|
|
789 |
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: ## |
|