# This source code file is part of the "mod_survey" package. # # Copyright (C) 2004 Joel Palmius # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program (probably in a file named "LICENSE.txt" or the like); # if not, write to: # # Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #!/usr/bin/perl package Survey::Slask; use strict; use Survey::Document; use Survey::Argument; use Survey::Display; use Survey::System; use Survey::Submit; use Survey::Admin; use Survey::Language; use Encode; use Encode::Guess qw/latin1 utf8 ascii/; sub VersionString { my ($style) = "style=\"color: #777799; font-weight: bold; text-decoration: none;\""; my ($href) = "href=\"http://www.modsurvey.org/\""; return "Mod_Survey v3.2.7-pre1 (testing)"; } sub IsError { my ($crap, $obj) = @_; my ($errname, $iserror); if ($obj->Error()) { $iserror = 1; ($crap, $errname) = split("::", $obj, 2); ($errname, $crap) = split("=", $errname, 2); if ($errname eq "Submit") { if (defined($obj->{DOCUMENT}->{ "SUBMITERROR_" . $obj->{ERRORCODE} })) { my ($tagno) = $obj->{DOCUMENT}->{ "SUBMITERROR_" . $obj->{ERRORCODE} }; my ($raw) = $obj->{DOCUMENT}->GetTagParam($tagno, "RAW"); my ($realtagno) = $obj->{ERRORTAG}; # Parse dynamics my ($caption) = $obj->{DOCUMENT}->GetTagParam($realtagno, "CAPTION"); my ($rowcaption) = $obj->{MATRIXWORKAROUND}; my ($tagnumber) = $realtagno; my ($name) = $obj->{DOCUMENT}->GetTagParam($realtagno, "NAME"); my ($shortdesc) = $obj->{ERROR}; $raw =~ s/\$caption/$caption/g; $raw =~ s/\$rowcaption/$rowcaption/g; $raw =~ s/\$tagnumber/$tagnumber/g; $raw =~ s/\$name/$name/g; $raw =~ s/\$shortdesc/$shortdesc/g; print $raw; $obj->{ERRORHANDLED} = 1; return $iserror; } } print " " . lprint("SURVEY") . " : " . $errname . " " . lprint("error") . "\n"; print " \n"; print " \n"; Survey::Slask->BodyTag(); print "

" . $errname . " error

\n"; print " " . $obj->Error() . "
\n"; $obj->PrintErrorDescription(); print "

\n"; print " " . lprint("Did the above not help you ? You can find documentation and examples for the mod_survey system at"); print " http://www.modsurvey.org.\n"; print " " . lprint("There you can also find instructions for joining the survey-discussion mail list, "); print " " . lprint("which might provide some support") . "."; print " " . lprint("You can also check the") . " "; print lprint("local documentation") . ".

\n"; } else { $iserror = 0; } return $iserror; } sub isMobileOverride { if($ENV{_SURVEY_DISABLE_MOBILEOVERRIDE} ne "1") { # Detecting of and overriding for handhelds is enabled my($agent) = lc($ENV{HTTP_USER_AGENT}); if($agent =~ /android/) { # Assume android phone => handheld return 1; } if($agent =~ /iphone/) { # Assume iphone => handheld return 1; } } return 0; } sub MobileHeader { if(Survey::Slask->isMobileOverride()) { print " \n"; print " \n"; } } sub PasswordDialog { my ($crap, $doc, $arg) = @_; $doc->{HANDLER}->content_type("text/html"); my ($action) = $arg->ArgByName("action"); my ($admin) = $arg->ArgByName("admin"); my($enc) = $ENV{_SURVEY_ENCODING}; print "\n"; print "\n"; print "\n"; print " \n"; Survey::Slask->MobileHeader(); print " \n"; print " " . lprint("Password needed") . "\n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " " . lprint("Password needed") . "
\n"; print "
\n"; my ($uri) = $doc->GetOption("URI"); print " \n"; print "
\n"; print "\n"; print "\n"; print "Info

\n"; print lprint("The author of the survey has protected this module with a password."); print lprint("You will have to give the correct password to proceed."); print "

"; print "" . lprint("Password") . ":
\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print " \n"; print "\n"; 1; } sub LangHack { my($self) = shift; my($string) = shift; my($enc) = $ENV{"_SURVEY_ENCODING"} || "utf8"; my($inputformat) = guess_encoding($string, qw/latin1 utf8 ascii/); ref($inputformat) or return $string; my($utf8) = $inputformat->decode($string); $string = encode($enc,$utf8); if($ENV{"_SURVEY_LANGHACK"}) { # Å -> Å $string =~ s/\xc3\x85/\Å/g; $string =~ s/\xc5/\Å/g; # Ä -> Ä $string =~ s/\xc3\x84/\Ä/g; $string =~ s/\xc4/\Ä/g; # Ö -> Ö $string =~ s/\xc3\x96/\Ö/g; $string =~ s/\xd6/\Ö/g; # å -> å $string =~ s/\xc3\xa5/\å/g; $string =~ s/\xe5/\å/g; # ä -> ä $string =~ s/\xc3\xa4/\ä/g; $string =~ s/\xe4/\ä/g; # ö -> ö $string =~ s/\xc3\xb6/\ö/g; $string =~ s/\xf6/\ö/g; } return $string; } sub explicitEncoding { my($self) = shift; my($enc) = shift; my($string) = shift; my($inputformat) = guess_encoding($string, qw/utf8 latin1 ascii/); ref($inputformat) or return $string; my($utf8) = $inputformat->decode($string); $string = encode($enc,$utf8); return $string; } sub BodyTag { my ($self) = shift; print " \n"; 1; } sub HtmlHead { my ($self) = shift; my($enc) = $ENV{"_SURVEY_ENCODING"} || "UTF-8"; #print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n"; print " \n"; Survey::Slask->MobileHeader(); print " \n"; 1; } sub HtmlFoot { my ($self) = shift; if(!Survey::Slask->isMobileOverride()) { print "
\n"; print "

\n"; print "
\n"; print " " . &VersionString() . " \© Joel Palmius in 2010

\n"; print "

\n"; } print " \n"; print "\n"; 1; } 1;