include("../Php/pag_session.php");
loadSession();
if (!SHOW_ERRORS) error_reporting(0);
error_reporting(0);
include("../Php/pag_lib.php");
include("../Php/pag_globals.php");
include("../Php/pag_testxml.php");
include("../Php/dat_Poll.php");
include("../Php/pag_form.php");
setPage(PAGE_POLL);
$path = "../";
loadHTMLHeader(PAGE_POLL, $path);
loadHTMLBodyTopArea(PAGE_POLL, $path);
loadHTMLBodyBlueArea($path);
loadHTMLBodyMainAreaBegin();
//---- The specific page start -------
//------------------------------------
//---- The specific page content -------
$pollId = $_GET["pollId"];
$year = $_GET["year"];
if ($pollId == "") {
$pollId = GetIdLastPoll();
}
$subnavi = 0;
$showYears = false;
$ar_navi;
$ar_navi[0][0] = "Poll van de maand";
$ar_navi[0][1] = "http://www.centrumbredevoort.nl/Poll";
$ar_navi[1][0] = "Alle polls";
$ar_navi[1][1] = "http://www.centrumbredevoort.nl/Poll/index.php?pollId=all";
$ar_crumbs;
$ar_crumbs[0][0] = "Poll";
$ar_crumbs[0][1] = "http://www.centrumbredevoort.nl/Poll";
$xsl = "";
$xml = "";
define($lastYearId, false);
$correctSubmitted = $_SESSION["CorrectSubmitted"];
if ($correctSubmitted) clearFormSessionVariables();
else {
$name = $_SESSION["Name"];
$content = $_SESSION["Content"] ;
$submitted = $_SESSION["Submitted"];
}
if ($_POST["vote"]) {
$ip = getip();
$pollvote = $_POST["Poll"];
$success = processVote($pollId, $pollvote, $ip);
}
if (($pollId == GetIdLastPoll())&&($year=="")) {
$title = GetPollTitle($pollId);
$year = GetPollYear($pollId);
//show last poll
$ar_crumbs[1][0] = "Alle polls (".$year.")";
$ar_crumbs[1][1] = "http://www.centrumbredevoort.nl/Poll/index.php?year=".$year."&pollId=all";
$ar_crumbs[2][0] = $title;
loadBreadCrumbs($ar_crumbs);
loadSubNavigation($ar_navi, 0);
echo "
";
//show poll form
$xml = loadPoll($pollId, $year, $success, $name, $content, $submitted, $correctSubmitted);
if (($submitted == true) && (!$correctSubmitted)) {
echo " |
Vul aub je naam EN je reactie in.
|
";
}
$xsl = 'Reactions.xsl';// FIXME
}
else {
$ar_crumbs[1][0] = "Alle polls";
$ar_crumbs[1][1] = "http://www.centrumbredevoort.nl/Poll/index.php?pollId=all";
if ($pollId == "all") {
if ($year != "") {
$ar_crumbs[1][0] = "Alle polls (".$year.")";
$ar_crumbs[1][1] = "http://www.centrumbredevoort.nl/Poll/index.php?year=".$year."&pollId=all";
define(YEAR, $year);
define($lastYearId, true);
}
loadBreadCrumbs($ar_crumbs);
loadSubNavigation($ar_navi, 1);
$xml = GetAllPollYears();
echo "
";
echo " | ";
loadXML($xml);
echo "|
";
$xml = GetAllPolls(YEAR);
$xsl = 'AllPolls.xsl';
}
else {
$ar_crumbs[1][0] = "Alle polls (".$year.")";
$ar_crumbs[1][1] = "http://www.centrumbredevoort.nl/Poll/index.php?year=".$year."&pollId=all";
$title = GetPollTitle($pollId);
$ar_crumbs[2][0] = $title;
loadBreadCrumbs($ar_crumbs);
loadSubNavigation($ar_navi, 1);
echo " ";
$xml = loadPoll($pollId, $year, $success, $name, $content, $submitted, $correctSubmitted);
if (($submitted == true) && (!$correctSubmitted)) {
echo " |
Vul aub je naam EN je reactie in.
|
";
}
$xsl = 'Reactions.xsl'; //FIXME
}
}
//returns loaded xml file
function loadPoll($pollId, $year, $success, $name, $content, $submitted, $correctSubmitted) {
$ip = getip();
if (IsClosed($pollId) == "TRUE") {
$xml = GetPollResultsDetailed($pollId);
$xsl = "Poll_Results.xsl";
print XMLtoHTML($xml, $xsl);
echo "(Je kunt niet meer stemmen op deze poll)
";
}
else if (HasVoted($ip, $pollId) == "FALSE") {
$xml = GetPollDetailed($pollId);
$xsl = "Poll.xsl";
print XMLtoHTML($xml, $xsl);
}
else {
$xml = GetPollResultsDetailed($pollId);
$xsl = "Poll_Results.xsl";
print XMLtoHTML($xml, $xsl);
echo "";
if ($success == "1") {
echo "Bedankt voor je stem!";
}
else {
echo "Je hebt al op deze poll gestemd.";
}
echo "
";
}
//show reaction form
loadFormPoll($pollId, $name, $content, $correctSubmitted, $submitted);// FIXME
echo "
";
return $xml;
}
function startElement($parser, $name, $attrs) {
//echo $name;
}
function endElement($parser, $name) {
//echo $name;
}
function printYearMenu($parser, $data) {
//make menu with links to year pages
if ($lastYearId == false) {
define(YEAR, $data);
define($lastYearId, true);
}
echo "".$data." | ";
}
function loadXML($x) {
$xml_parser = xml_parser_create();
// use case-folding so we are sure to find the tag in $map_array
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "printYearMenu");
if (!xml_parse($xml_parser, $x)) {
die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
}
if (($xml == "") && ($xsl == "")) echo "";
else if ($xsl == "") echo "";
else {
$html = XMLtoHTML($xml, $xsl);
print textToSmilie($html);
print "
";
print "
";
}
//--------------------------------------
loadHTMLBodyMainAreaEnd();
loadHTMLBodyEnd(PAGE_POLL, "../");
?>