<commit_before><?php

// $Header: /cvsroot/tikiwiki/tiki/tiki-poll_results.php,v 1.5 2003-08-07 04:33:57 rossta Exp $

// Copyright (c) 2002-2003, <NAME>, <NAME>, <NAME>, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.

// Initialization
require_once ('tiki-setup.php');

include_once ('lib/polls/polllib.php');

if (!isset($polllib)) {
	$polllib = new PollLib($dbTiki);
}

if ($feature_polls != 'y') {
	$smarty->assign('msg', tra("This feature is disabled"));

	$smarty->display("styles/$style_base/error.tpl");
	die;
}

if (!isset($_REQUEST["pollId"])) {
	$smarty->assign('msg', tra("No poll indicated"));

	$smarty->display("styles/$style_base/error.tpl");
	die;
}

$poll_info = $tikilib->get_poll($_REQUEST["pollId"]);
$polls = $polllib->list_active_polls(0, -1, 'publishDate_desc', '');
$options = $polllib->list_poll_options($_REQUEST["pollId"], 0, -1, 'title_desc', '');

for ($i = 0; $i < count($options["data"]); $i++) {
	if ($poll_info["votes"] == 0) {
		$percent = 0;
	} else {
		$percent = number_format($options["data"][$i]["votes"] * 100 / $poll_info["votes"], 2);

		$options["data"][$i]["percent"] = $percent;
	}

	$width = $percent * 200 / 100;
	$options["data"][$i]["width"] = $percent;
}

// Poll comments
if ($feature_poll_comments == 'y') {
	$comments_per_page = $poll_comments_per_page;

	$comments_default_ordering = $poll_comments_default_ordering;
	$comments_vars = array('pollId');
	$comments_prefix_var = 'poll';
	$comments_object_var = 'pollId';
	include_once ("comments.php");
}

$smarty->assign_by_ref('poll_info', $poll_info);
$smarty->assign_by_ref('polls', $polls["data"]);
$smarty->assign_by_ref('options', $options["data"]);

// Display the template
$smarty->assign('mid', 'tiki-poll_results.tpl');
$smarty->display("styles/$style_base/tiki.tpl");

?><commit_msg>Sort options in same order as poll fucntion.<commit_after><?php

// $Header: /cvsroot/tikiwiki/tiki/tiki-poll_results.php,v 1.6 2003-10-01 21:38:08 traivor Exp $

// Copyright (c) 2002-2003, <NAME>, <NAME>, <NAME>, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.

// Initialization
require_once ('tiki-setup.php');

include_once ('lib/polls/polllib.php');

if (!isset($polllib)) {
	$polllib = new PollLib($dbTiki);
}

if ($feature_polls != 'y') {
	$smarty->assign('msg', tra("This feature is disabled"));

	$smarty->display("styles/$style_base/error.tpl");
	die;
}

if (!isset($_REQUEST["pollId"])) {
	$smarty->assign('msg', tra("No poll indicated"));

	$smarty->display("styles/$style_base/error.tpl");
	die;
}

$poll_info = $tikilib->get_poll($_REQUEST["pollId"]);
$polls = $polllib->list_active_polls(0, -1, 'publishDate_desc', '');
$options = $polllib->list_poll_options($_REQUEST["pollId"], 0, -1, 'optionId_asc', '');

for ($i = 0; $i < count($options["data"]); $i++) {
	if ($poll_info["votes"] == 0) {
		$percent = 0;
	} else {
		$percent = number_format($options["data"][$i]["votes"] * 100 / $poll_info["votes"], 2);

		$options["data"][$i]["percent"] = $percent;
	}

	$width = $percent * 200 / 100;
	$options["data"][$i]["width"] = $percent;
}

// Poll comments
if ($feature_poll_comments == 'y') {
	$comments_per_page = $poll_comments_per_page;

	$comments_default_ordering = $poll_comments_default_ordering;
	$comments_vars = array('pollId');
	$comments_prefix_var = 'poll';
	$comments_object_var = 'pollId';
	include_once ("comments.php");
}

$smarty->assign_by_ref('poll_info', $poll_info);
$smarty->assign_by_ref('polls', $polls["data"]);
$smarty->assign_by_ref('options', $options["data"]);

// Display the template
$smarty->assign('mid', 'tiki-poll_results.tpl');
$smarty->display("styles/$style_base/tiki.tpl");

?>

{'fraction_non_alphanumeric': 0.21078305519897303, 'fraction_numerical': 0.021052631578947368, 'mean_word_length': 5.648464163822526, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3586977', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1456, 'n_words': 275}