<?php
/**
* XS2:
*
* This file is developed by Solutecs, LLC for the purpose of the company
* and is provided together with XS2 Framework as and inherent part of the
* system. This file can be used on the terms of License Agreement.
*
* +7 (495) 585-0833 / 13 Rusakovskaya street, Moscow 107140 Russia
*
* @link http://www.solutecs.com
* @copyright ©1998-2007 Solutecs, LLC
* @package XS2-MODCOM
* @subpackage proc-voting
* @version 1.XX
*/
// Если в атрибуте не указан показываемый вопрос, выбирается самый свежий
if ($_THE['PARAMS'][0]) {
$question = xs2GetNode(array("mod"=>"voting",'NodId'=>$_THE['PARAMS'][0]));
}
else {
$questions = xs2GetNodes(array('mod'=>"voting",'NType'=>"question",'sort'=>"CDate desc"));
$question = $questions[0];
}
if ($question) {
$answers = xs2GetChildren(array('ParId'=>$question['NodId'],
'mod'=>'voting',
'NType'=>'answer'));
// Определяем общее число ответивших
$sum = 0;
foreach($answers as $key=>$node) {
$sum += $node['Counter'];
}
foreach($answers as $key=>$node) {
$answers[$key]['CounterPercent'] = ($sum > 0 ? ((100*$node['Counter'])/$sum) : 0);
}
$_HTML->assign('answers', $answers);
$_HTML->assign('question', $question);
$_HTML->assign('sum', $sum);
}
?>
|
|