Browse Source

Добавлен Модуль Опросы | Голосование

master
SVarlamov 9 years ago
commit
d85d01f238
  1. 22
      README.md
  2. 7
      ReadMe.txt
  3. 78
      admin/admin_comments.tpl
  4. 299
      admin/admin_fields.tpl
  5. 102
      admin/admin_forms.tpl
  6. BIN
      admin/js/color.png
  7. 1
      admin/js/iColorPicker.js
  8. 938
      class.poll.php
  9. 13
      funcs/func.rewrite.php
  10. 4
      index.php
  11. 4
      lang/index.php
  12. 140
      lang/ru.txt
  13. 118
      module.php
  14. 93
      sql.php
  15. 24
      templates/archive.tpl
  16. 4
      templates/index.php
  17. 1
      templates/js/common.js
  18. 93
      templates/poll_form.tpl
  19. 10
      templates/poll_nav.tpl
  20. 15
      templates/poll_nav_result.tpl
  21. 181
      templates/result.tpl

22
README.md

@ -0,0 +1,22 @@
## poll
# Модуль Опросы/Голосование v1.1a
## Данный модуль предназачен для организации системы опросов на сайте.
* Возможности модуля позволяют создавать неограниченное количество опросных листов, а также неограниченное количество вопросов.
* Добавить в .htaccess <br>
```php
## Poll<br>
RewriteRule ^poll-([0-9]+).html$ index.php?module=poll&action=result&pid=$1<br>
RewriteRule ^pollcomment-([0-9]+).html$ index.php?module=poll&action=form&pop=1&pid=$1<br>
RewriteRule ^poll-archive.html$ index.php?module=poll&action=archive<br>
```
## Перед копированием модуля в папку modules, удалите файл README.md, копируйте только корневую папку poll со всем ее содержимым внутри!
## Changelog:
22.09.2013 - версия 1.1a

7
ReadMe.txt

@ -0,0 +1,7 @@
Äîáàâèòü â .htaccess
## Poll
RewriteRule ^poll-([0-9]+).html$ index.php?module=poll&action=result&pid=$1
RewriteRule ^pollcomment-([0-9]+).html$ index.php?module=poll&action=form&pop=1&pid=$1
RewriteRule ^poll-archive.html$ index.php?module=poll&action=archive

78
admin/admin_comments.tpl

@ -0,0 +1,78 @@
<div class="title"><h5>{#POLL_COMMENTS_TITLE#}</h5></div>
<div class="widget" style="margin-top: 0px;">
<div class="body">
{#POLL_COMMENTS_INFO#}
</div>
</div>
<div class="breadCrumbHolder module">
<div class="breadCrumb module">
<ul>
<li class="firstB"><a href="index.php" title="{#MAIN_PAGE#}">{#MAIN_PAGE#}</a></li>
<li><a href="index.php?do=modules&amp;cp={$sess}">{#MODULES_SUB_TITLE#}</a></li>
<li><a href="index.php?do=modules&action=modedit&mod=poll&moduleaction=1&cp={$sess}">{#POLL_MODULE_NAME#}</a></li>
<li><strong class="code">{#POLL_COMMENTS_TITLE#}</strong></li>
</ul>
</div>
</div>
<div class="widget first">
<div class="head">
<h5 class="iFrames">{#POLL_COMMENTS_TITLE#}</h5>
<div class="num"><a class="basicNum" href="index.php?do=modules&action=modedit&mod=poll&moduleaction=new&cp={$sess}">{#POLL_NEW_LINK#}</a></div>
</div>
<form method="post" action="index.php?do=modules&action=modedit&mod=poll&moduleaction=comments&id={$smarty.request.id|escape}&cp={$sess}&pop=1&sub=save&page={$smarty.request.page|escape}">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<col width="10" />
<col width="150" />
<thead>
<tr>
<td align="center"><div align="center"><span class="icon_sprite ico_delete"></span></div></td>
<td>{#POLL_COMMENT_INFO#}</td>
<td>{#POLL_COMMENT_TITLE#}</td>
</tr>
</thead>
<tbody>
{foreach from=$items item=item}
<tr>
<td>
<input title="{#POLL_MARK_DELETE#}" name="del[{$item->id}]" type="checkbox" id="del[{$item->id}]" class="topDir" value="1">
</td>
<td nowrap="nowrap" valign="top">
{#POLL_COMMENT_AUTHOR#}<br />
<strong>{$item->poll_comment_author|escape}</strong>
<br />
<br />
{#POLL_COMMENT_DATE#}<br />
<strong>{$item->poll_comment_time|date_format:$DATE_FORMAT|pretty_date}</strong>
</td>
<td>
<div class="pr12">
<span class="dgrey">Тема</span>
<input name="comment_title[{$item->id}]" type="text" id="comment_title[{$item->id}]" value="{$item->poll_comment_title|escape}"><br />
<span class="dgrey">Комментарий</span>
<textarea name="comment_text[{$item->id}]" cols="50" rows="5" id="comment_text[{$item->id}]">{$item->poll_comment_text|escape}</textarea>
</div>
</td>
</tr>
{/foreach}
<tr>
<td class="third" colspan="3">
<input class="basicBtn" type="submit" value="{#POLL_BUTTON_SAVE#}" />
</td>
</tr>
</tbody>
</table>
</form>
</div>
{if $page_nav}
<div class="pagination">
<ul class="pages">
{$page_nav}
</ul>
</div>
{/if}

299
admin/admin_fields.tpl

@ -0,0 +1,299 @@
<script language="Javascript" type="text/javascript" src="/modules/poll/admin/js/iColorPicker.js"></script>
<script language="Javascript" type="text/javascript">
$(document).ready(function(){ldelim}
{literal}
(function($) {
$.fn.tableSortable = function(options) {
options = $.extend({}, $.fn.tableSortable.defaults, options);
this.sortable({
items: options.items,
axis: 'y',
cursor: 'move',
tolerance: 'pointer',
handle: options.handle,
helper: 'clone',
placeholder: 'sortable-placeholder',
start: function( event, ui ) {
// задаём placeholder
$(this).find(' .sortable-placeholder').html(ui.item.html()).css('opacity',0.3);
// назначаем колонкам ширину
origTd = $(this).find(' .sortable-placeholder td');
ui.helper.find(' td').each(function(index, element) {
$(element).width(origTd.eq(index).width());
});
},
stop: function( event, ui ) {
// удаляем ширину колонок
ui.item.find(' tr:first td').each(function(index, element) {
$(element).width('');
});
},
update: function( event, ui ) {
// отправляем результаты сортировки
sorted = $(this).sortable('serialize', {
key: options.key+'[]',
attribute: options.attr
});
$.ajax({
url: options.url+'&'+sorted,
success: function () {
$.jGrowl(options.success,{theme: 'accept'});
}
});
}
});
};
$.fn.tableSortable.defaults = {
items: 'tr',
handle: '.ico_navigation',
url: 'index.php?',
key: 'sort',
attr: 'data-id',
success: 'Порядок сохранён'
};
})(jQuery);
{/literal}
$('#published').datetimepicker({ldelim}
changeMonth: true,
changeYear: true,
stepHour: 1,
stepMinute: 1,
onClose: function(dateText, inst) {ldelim}
var endDateTextBox = $('#expire');
if (endDateTextBox.val() != '') {ldelim}
var testStartDate = new Date(dateText);
var testEndDate = new Date(endDateTextBox.val());
if (testStartDate > testEndDate)
endDateTextBox.val(dateText);
{rdelim}
else {ldelim}
endDateTextBox.val(dateText);
{rdelim}
{rdelim}
{rdelim});
$('#expire').datetimepicker({ldelim}
changeMonth: true,
changeYear: true,
stepHour: 1,
stepMinute: 1,
onClose: function(dateText, inst) {ldelim}
var startDateTextBox = $('#published');
if (startDateTextBox.val() != '') {ldelim}
var testStartDate = new Date(startDateTextBox.val());
var testEndDate = new Date(dateText);
if (testStartDate > testEndDate)
startDateTextBox.val(dateText);
{rdelim}
else {ldelim}
startDateTextBox.val(dateText);
{rdelim}
{rdelim},
onSelect: function (selectedDateTime){ldelim}
var end = $(this).datetimepicker('getDate');
$('#published').datetimepicker('option', 'maxDate', new Date(end.getTime()) );
{rdelim}
{rdelim});
// Сортировка
$('#itemsId').tableSortable({ldelim}
url: 'index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&sub=sortable&cp={$sess}',
success: '{#POLL_POSITION_SUCCES#}'
{rdelim});
{rdelim});
</script>
{if $smarty.request.moduleaction == 'new'}
<div class="title"><h5>{#POLL_ADD_POLL#}</h5></div>
<div class="widget" style="margin-top: 0px;">
<div class="body">
{#POLL_NEW_INFO#}
</div>
</div>
{else}
<div class="title"><h5>{#POLL_EDIT#}</h5></div>
<div class="widget" style="margin-top: 0px;">
<div class="body">
{#POLL_EDIT_INFO#}
</div>
</div>
{/if}
<div class="breadCrumbHolder module">
<div class="breadCrumb module">
<ul>
<li class="firstB"><a href="#" title="{#MAIN_PAGE#}">{#MAIN_PAGE#}</a></li>
<li><a href="index.php?do=modules&amp;cp={$sess}">{#MODULES_SUB_TITLE#}</a></li>
<li><a href="index.php?do=modules&action=modedit&mod=poll&moduleaction=1&cp={$sess}">{#POLL_MODULE_NAME#}</a></li>
{if $smarty.request.moduleaction == 'new'}
<li><strong class="code">{#POLL_ADD_POLL#}</strong></li>
{else}
<li>{#POLL_EDIT#}</li>
<li><strong class="code">{$row->poll_title|default:''}</strong></li>
{/if}
</ul>
</div>
</div>
<form method="post" action="{$formaction}" class="mainForm">
<div class="widget first">
<div class="head">
<h5 class="iFrames">{if $smarty.request.id != ''}{#POLL_EDIT#}{else}{#POLL_ADD_POLL#}{/if}</h5>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<col width="200">
<tr>
<td>{#POLL_NAME#}:</td>
<td colspan="3">
<div class="pr12"><input name="poll_name" type="text" id="poll_name" value="{$row->poll_title|default:''}" size="20" /></div>
</td>
</tr>
<tr>
<td>{#POLL_STATUS#}?</td>
<td colspan="3">
<input type="radio" name="poll_status" id="poll_status" {if $row->poll_status==1}checked{/if} value="1"/><label>{#POLL_YES#}</label>
<input type="radio" name="poll_status" id="poll_status" {if $row->poll_status==0}checked{/if} value="0" /><label>{#POLL_NO#}</label>
</td>
</tr>
<tr>
<td>{#POLL_CAN_COMMENT#}</td>
<td colspan="3">
<input type="radio" name="poll_can_comment" id="poll_can_comment" value="1" {if $row->poll_can_comment==1}checked{/if} /><label>{#POLL_YES#}</label>
<input type="radio" name="poll_can_comment" id="poll_can_comment" value="0" {if $row->poll_can_comment==0}checked{/if} /><label>{#POLL_NO#}</label>
</td>
</tr>
<tr>
<td>{#POLL_START_TIME#}</td>
<td>
<input id="published" name="poll_published" type="text" value="{if $row->poll_end}{$row->poll_start|date_format:"%d.%m.%Y %H:%M"}{else}{$published|date_format:"%d.%m.%Y %H:%M"}{/if}" style="width: 150px;" />
</td>
<td>{#POLL_END_TIME#}</td>
<td>
<input id="expire" name="poll_expire" type="text" value="{if $row->poll_end}{$row->poll_end|date_format:"%d.%m.%Y %H:%M"}{else}{$expire|date_format:"%d.%m.%Y %H:%M"}{/if}" style="width: 150px;" />
</td>
</tr>
<tr>
<td valign="top">{#POLL_USER_GROUPS#}<br /><small>{#POLL_GROUP_INFO#}</small></td>
<td colspan="3">
<select class="select" style="width:200px" name="groups[]" size="5" multiple="multiple">
{html_options options=$groups selected=$selected}
</select>
</td>
</tr>
</table>
{if $smarty.request.id != ''}
</div>
<div class="widget first">
<div class="head">
<h5 class="iFrames">{#POLL_QUESTIONS#}</h5>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<col width="10" />
<col width="10" />
<col />
<col width="160" />
<col width="100" />
<thead>
<tr>
<td align="center"><div align="center"><span class="icon_sprite ico_delete"></span></div></td>
<td align="center"></td>
<td>{#POLL_QUESTION_NAME#}</td>
<td>{#POLL_QUESTION_COLOR#} </td>
<td>{#POLL_QUESTION_HITS#}</td>
</tr>
</thead>
<tbody id="itemsId">
{if $items}
{foreach from=$items item=item}
<tr data-id="item_{$item->id}">
<td>
<input title="{#POLL_MARK_DELETE#}" name="del[{$item->id}]" class="topDir" type="checkbox" id="del[{$item->id}]" value="1" />
</td>
<td>
<div align="center"><span class="icon_sprite ico_navigation" style="cursor: move;"></span></div>
</td>
<td >
<div class="pr12"><input name="item_title[{$item->id}]" type="text" id="item_title[{$item->id}]" value="{$item->poll_item_title}" /></div>
</td>
<td>
<input maxlength="7" style="width: 100px;" type="text" name="line_color[{$item->id}]" value="{$item->poll_item_color}" class="iColorPicker" id="line_color{$item->id}" />
</td>
<td>
<input style="width:80px" name="poll_item_hits[{$item->id}]" type="text" id="poll_item_hits[{$item->id}]" value="{$item->poll_item_hits}" />
</td>
</tr>
{/foreach}
{else}
<tr>
<td colspan="5">
<ul class="messages">
<li class="highlight yellow">{#POLL_QUESTION_NO_ITEMS#}</li>
</ul>
</td>
</tr>
{/if}
</tbody>
</table>
{/if}
<div class="rowElem">
<input type="submit" class="basicBtn" value="{#POLL_BUTTON_SAVE#}" />
</div>
</div>
</form>
{if $smarty.request.id != ''}
<div class="widget first">
<div class="head">
<h5 class="iFrames">{#POLL_QUESTIONS_ADD#}</h5>
</div>
<form method="post" action="index.php?do=modules&action=modedit&mod=poll&moduleaction=save_new&cp={$sess}&id={$smarty.request.id|escape}" name="new">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<col />
<col width="160" />
<col width="100" />
<thead>
<tr>
<td>{#POLL_QUESTION_NAME#}</td>
<td>{#POLL_QUESTION_COLOR#} </td>
<td>{#POLL_QUESTION_HITS#}</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="pr12"><input name="item_title" type="text" id="item_title" value="" /></div>
</td>
<td>
<input maxlength="7" style="width: 100px;" type="text" name="line_color" class="iColorPicker" value="" id="color1" />
</td>
<td>
<input style="width:80px" name="poll_item_hits" type="text" id="poll_item_hits" value="" />
</td>
</tr>
<tr>
<td colspan="4"><input type="submit" class="basicBtn" value="{#POLL_BUTTON_ADD#}" /></td>
</tr>
</tbody>
</table>
</form>
</div>
{/if}

102
admin/admin_forms.tpl

@ -0,0 +1,102 @@
<div class="title"><h5>{#POLL_MODULE_NAME#}</h5></div>
<div class="widget" style="margin-top: 0px;">
<div class="body">
{#POLL_MODULE_TITLE#}
</div>
</div>
<div class="breadCrumbHolder module">
<div class="breadCrumb module">
<ul>
<li class="firstB"><a href="index.php" title="{#MAIN_PAGE#}">{#MAIN_PAGE#}</a></li>
<li><a href="index.php?do=modules&amp;cp={$sess}">{#MODULES_SUB_TITLE#}</a></li>
<li><a href="index.php?do=modules&action=modedit&mod=poll&moduleaction=1&cp={$sess}">{#POLL_MODULE_NAME#}</a></li>
<li><strong class="code">{#POLL_MODULE_ALL#}</strong></li>
</ul>
</div>
</div>
<div class="widget first">
<div class="head">
<h5 class="iFrames">{#POLL_MODULE_ALL#}</h5>
<div class="num"><a class="basicNum" href="index.php?do=modules&action=modedit&mod=poll&moduleaction=new&cp={$sess}">{#POLL_NEW_LINK#}</a></div>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<col width="20">
<col>
<col width="120">
<col width="200">
<col width="200">
<col width="150">
{if $items}
<thead>
<tr>
<td align="center" width="1%"><span class="">[!]</span></td>
<td>{#POLL_NAME#}</td>
<td>{#POLL_SYSTEM_TAG#}</td>
<td>{#POLL_START_END#}</td>
<td>{#POLL_HITS_CMMENT#}</td>
<td colspan="3" align="center" width="2%">{#POLL_ACTIONS#}</td>
</tr>
</thead>
{foreach from=$items item=item}
<tr>
<td width="10">
{if $item->poll_status != '1'}
<span class="icon_sprite ico_delete_no"></span>
{else}
<span class="icon_sprite ico_ok"></span>
{/if}
</td>
<td>
<a href="index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&cp={$sess}&id={$item->id}"><strong>{$item->poll_title}</strong></a>
</td>
<td>
<div class="pr12"><input type="text" value="[mod_poll:{$item->id}]" size="12" readonly></div>
</td>
<td align="center">
<span class="date_text dgrey">c {$item->poll_start|date_format:$TIME_FORMAT|pretty_date}</span>
<br />
<span class="date_text dgrey">по {$item->poll_end|date_format:$TIME_FORMAT|pretty_date}</span>
</td>
<td align="center">
{if $item->sum_hits == ''} 0 {else} {$item->sum_hits} {/if} / <a href="index.php?do=modules&action=modedit&mod=poll&moduleaction=comments&cp={$sess}&id={$item->id}">{$item->comments}</a>
</td>
<td width="1%" align="center">
<a title="{#POLL_EDIT_POLL#}" href="index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&cp={$sess}&id={$item->id}"><span class="icon_sprite ico_edit"></span></a>
</td>
<td width="1%" align="center">
<a title="{#POLL_DELETE#}" class="ConfirmDelete toprightpDir" dir="{#POLL_DELETE#}" name="{#POLL_DELETE_CONFIRM#}" href="index.php?do=modules&action=modedit&mod=poll&moduleaction=delete&cp={$sess}&id={$item->id}"><span class="icon_sprite ico_delete"></span></a>
</td>
</tr>
{/foreach}
{else}
<tr>
<td colspan="7">
<ul class="messages">
<li class="highlight yellow">{#POLL_MODULE_NO_ITEMS#}</li>
</ul>
</td>
</tr>
{/if}
</table>
</div>
{if $page_nav}
<div class="pagination">
<ul class="pages">
{$page_nav}
</ul>
</div>
{/if}

BIN
admin/js/color.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

1
admin/js/iColorPicker.js

File diff suppressed because one or more lines are too long

938
class.poll.php

@ -0,0 +1,938 @@
<?php
class Poll
{
/**
* СВОЙСТВА
*/
var $_adminlimit = 5;
var $_limit = 5;
var $_commentwords = 1000;
var $_antispam = 0;
/**
* ВНУТРЕННИЕ МЕТОДЫ
*/
function _pollLinkRewrite($string)
{
return (REWRITE_MODE) ? PollRewrite($string) : $string;
}
/**
* ВНЕШНИЕ МЕТОДЫ
*/
/**
* Методы публичной части
*/
/**
* Отображение опроса (вывод тегами)
*
* @param string $tpl_dir путь к папке с шаблонами модуля
* @param string $lang_file путь к языковому файлу модуля
* @param int $pid идентификатор опроса
*/
function pollShow($tpl_dir, $lang_file, $pid)
{
global $AVE_DB, $AVE_Template;
// if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'poll') return;
$AVE_Template->config_load($lang_file, 'showpoll');
$row = $AVE_DB->Query("
SELECT
poll.*,
SUM(itm.poll_item_hits) AS sumhits
FROM
" . PREFIX . "_module_poll AS poll
LEFT JOIN
" . PREFIX . "_module_poll_items AS itm
ON poll_id = poll.id
WHERE
poll.id = '" . $pid . "' AND
poll.poll_title != '' AND
poll.poll_status = '1' AND
poll.poll_start < '" . time() . "'
GROUP BY poll.id
")->FetchRow();
if (!$row) return;
$poll_groups_id = empty($row->poll_groups_id) ? array() : explode(',', $row->poll_groups_id);
$poll_users_id = empty($row->poll_users_id) ? array() : explode(',', $row->poll_users_id);
$poll_users_ip = empty($row->poll_users_ip) ? array() : explode(',', $row->poll_users_ip);
$current_user_ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'];
if (@in_array($current_user_ip, $poll_users_ip) ||
@in_array($_SESSION['user_id'], $poll_users_id) ||
(isset($_COOKIE['poll_' . $pid]) && $_COOKIE['poll_' . $pid] == '1') )
{
$row->message = $AVE_Template->get_config_vars('POLL_ALREADY_POLL');
}
elseif (!(@in_array(UGROUP, $poll_groups_id)))
{
$row->message = $AVE_Template->get_config_vars('POLL_NO_PERMISSION');
}
elseif ($row->poll_end < time())
{
$row->message = $AVE_Template->get_config_vars('POLL_EXPIRED');
}
$items = array();
$sql = $AVE_DB->Query("
SELECT
*,
" . ($row->sumhits > 0 ? 'ROUND(poll_item_hits*100/' . $row->sumhits . ')' : 0) . " AS sum
FROM " . PREFIX . "_module_poll_items
WHERE poll_id = '" . $pid . "'
ORDER BY poll_item_position ASC
");
while ($row_items = $sql->FetchRow())
{
array_push($items, $row_items);
}
$AVE_Template->assign('formaction', 'index.php?module=poll&amp;action=vote&amp;pid=' . $pid);
$AVE_Template->assign('formaction_result', $this->_pollLinkRewrite('index.php?module=poll&amp;action=result&amp;pid=' . $pid));
$AVE_Template->assign('formaction_archive', $this->_pollLinkRewrite('index.php?module=poll&amp;action=archive'));
$AVE_Template->assign('poll', $row);
$AVE_Template->assign('items', $items);
if (isset($row->message))
{
$AVE_Template->display($tpl_dir . 'poll_nav_result.tpl');
}
else
{
$AVE_Template->display($tpl_dir . 'poll_nav.tpl');
}
}
/**
* Учет результатов опроса
*
* @param int $pid идентификатор опроса
*/
function pollVote($pid)
{
global $AVE_DB;
$row = $AVE_DB->Query("
SELECT *
FROM " . PREFIX . "_module_poll
WHERE id = '" . $pid . "'
")->FetchRow();
$poll_groups_id = empty($row->poll_groups_id) ? array() : explode(',', $row->poll_groups_id);
$poll_users_id = empty($row->poll_users_id) ? array() : explode(',', $row->poll_users_id);
$poll_users_ip = empty($row->poll_users_ip) ? array() : explode(',', $row->poll_users_ip);
$current_user_ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'];
$back = $this->_pollLinkRewrite('index.php?module=poll&amp;action=result&amp;pid=' . $pid);
if (!(@in_array(UGROUP, $poll_groups_id)))
{
header('Location:' . $back);
exit;
}
if (@in_array($current_user_ip, $poll_users_ip) ||
@in_array($_SESSION['user_id'], $poll_users_id) ||
$_COOKIE['poll_' . $pid] == '1')
{
header('Location:' . $back);
exit;
}
setcookie('poll_' . $pid, '1', time() + 3600 * 3600);
$AVE_DB->Query("
UPDATE " . PREFIX . "_module_poll_items
SET poll_item_hits = poll_item_hits + 1
WHERE id = '" . (int)$_POST['p_item'] . "'
");
$AVE_DB->Query("
UPDATE " . PREFIX . "_module_poll
SET
poll_users_ip = CONCAT_WS(',', poll_users_ip, '" . $current_user_ip . "')
" . ((UGROUP != 2) ? ", poll_users_id = CONCAT_WS(',', poll_users_id, '" . $_SESSION['user_id'] . "')" : '') . "
WHERE
id = '" . $pid . "'
");
header('Location:' . $back);
exit;
}
/**
* Подробная информация и статистика опроса, комментарии пользователей
*
* @param string $tpl_dir путь к папке с шаблонами модуля
* @param string $lang_file путь к языковому файлу модуля
* @param int $pid идентификатор опроса
*/
function pollResultShow($tpl_dir, $lang_file, $pid)
{
global $AVE_DB, $AVE_Template;
$AVE_Template->config_load($lang_file, 'showresult');
if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'new')
{
$errors = $this->pollCommentNew($pid);
if (sizeof($errors) == 0)
{
header('Location:' . $this->_pollLinkRewrite('index.php?module=poll&amp;action=result&amp;pid=' . $pid));
exit;
}
$AVE_Template->assign('errors', $errors);
}
$poll = $AVE_DB->Query("
SELECT
poll.*,
SUM(itm.poll_item_hits) AS votes
FROM
" . PREFIX . "_module_poll AS poll
LEFT JOIN
" . PREFIX . "_module_poll_items AS itm
ON poll_id = poll.id
WHERE
poll.id = '" . $pid . "' AND
poll.poll_title != '' AND
poll.poll_status = '1' AND
poll.poll_start < '" . time() . "'
GROUP BY poll.id
")->FetchRow();
if ($poll === false) return;
$items = array();
$sql = $AVE_DB->Query("
SELECT
*,
" . ($poll->votes > 0 ? 'ROUND(poll_item_hits*100/' . $poll->votes . ')' : 0) . " AS sum
FROM " . PREFIX . "_module_poll_items
WHERE poll_id = '" . $pid . "'
ORDER BY poll_item_position ASC
");
while ($row_items = $sql->FetchRow())
{
array_push($items, $row_items);
}
if ($poll->poll_can_comment == 1)
{
//include_once(BASE_DIR . '/lib/markitup/sets/bbcode/markitup.bbcode-parser.php');
$comments = array();
$sql = $AVE_DB->Query("
SELECT
cmnt.*,
IFNULL(firstname, '') AS firstname,
IFNULL(lastname, '" . $AVE_Template->get_config_vars('POLL_GUEST') . "') AS lastname
FROM
" . PREFIX . "_module_poll_comments AS cmnt
LEFT JOIN
" . PREFIX . "_users AS usr
ON usr.Id = cmnt.poll_comment_author_id
WHERE poll_id = '" . $pid . "'
ORDER BY poll_comment_time DESC
");
while ($row_comments = $sql->FetchRow())
{
$row_comments->poll_comment_text = $row_comments->poll_comment_text;
array_push($comments, $row_comments);
}
$poll->count_comments = $sql->NumRows();
}
$poll_users_id = empty($poll->poll_users_id) ? array() : explode(',', $poll->poll_users_id);
$poll_users_ip = empty($poll->poll_users_ip) ? array() : explode(',', $poll->poll_users_ip);
$current_user_ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'];
$is_vote = 1;
if (@in_array($current_user_ip, $poll_users_ip) ||
@in_array($_SESSION['user_id'], $poll_users_id) ||
(isset($_COOKIE['poll_' . $pid]) && $_COOKIE['poll_' . $pid] == '1'))
{
$is_vote = 0;
}
$rights = 0;
$groups = array();
if ($poll->poll_groups_id != '')
{
$sql = $AVE_DB->Query("
SELECT
user_group,
user_group_name
FROM
" . PREFIX . "_user_groups
WHERE
user_group IN(" . $poll->poll_groups_id . ")
");
while ($row_g = $sql->FetchRow())
{
if (UGROUP == $row_g->user_group) $rights = 1;
array_push($groups, $row_g->user_group_name);
}
}
$poll->can_vote = ($is_vote == 1 && $rights == 1) ? 1 : 0;
$poll->groups = implode(', ', $groups);
$poll->can_comment = ($poll->poll_status == 1 && $poll->poll_can_comment == 1 && $rights == 1) ? 1 : 0;
$poll->anti_spam = ($this->_antispam == 1 && function_exists('imagettftext') && function_exists('imagejpeg')) ? 1 : 0;
$poll->comment_max_chars = $this->_commentwords;
$poll->items = $items;
$poll->comments = $comments;
$poll->formaction = 'index.php?module=poll&amp;action=vote&amp;pid=' . $pid;
$poll->link_result = $this->_pollLinkRewrite('index.php?module=poll&amp;action=result&amp;pid=' . $pid);
// $poll->link_archive = $this->_pollLinkRewrite('index.php?module=poll&amp;action=archive');
// $poll->link_comment = $this->_pollLinkRewrite('index.php?module=poll&amp;action=form&amp;pop=1&amp;pid=' . $pid);
$AVE_Template->assign('poll', $poll);
define('MODULE_SITE', $AVE_Template->get_config_vars('POLL_PAGE_TITLE_PREFIX') . $poll->poll_title);
define('MODULE_CONTENT', $AVE_Template->fetch($tpl_dir . 'result.tpl'));
}
/**
* Список завершенных и действующих опросов
*
* @param string $tpl_dir путь к папке с шаблонами модуля
* @param string $lang_file путь к языковому файлу модуля
*/
function pollArchiveShow($tpl_dir, $lang_file)
{
global $AVE_DB, $AVE_Template;
if (empty($_REQUEST['order']))
{
$order = 'poll_title';
}
else
{
switch ($_REQUEST['order'])
{
case 'title':
$order = 'poll_title';
break;
case 'start':
$order = 'poll_start';
break;
case 'end':
$order = 'poll_end';
break;
case 'votes':
$order = 'votes';
break;
default:
$order = 'poll_title';
break;
}
}
if (isset($_REQUEST['by']) && $_REQUEST['by'] == 'desc')
{
$order .= ' DESC';
}
else
{
$order .= ' ASC';
}
$items = array();
$sql = $AVE_DB->Query("
SELECT
poll.id,
poll.poll_title,
poll.poll_start,
poll.poll_end,
SUM(itm.poll_item_hits) AS votes
FROM
" . PREFIX . "_module_poll AS poll
LEFT JOIN
" . PREFIX . "_module_poll_items AS itm
ON poll_id = poll.id
WHERE
poll.poll_title != '' AND
poll.poll_status = '1' AND
poll.poll_start < '" . time() . "'
GROUP BY poll.id
ORDER BY " . $order
);
while ($row = $sql->FetchRow())
{
$row->plink = $this->_pollLinkRewrite('index.php?module=poll&amp;action=result&amp;pid=' . $row->id);
array_push($items, $row);
}
$AVE_Template->assign('items', $items);
$AVE_Template->config_load($lang_file, 'showarchive');
define('MODULE_SITE', $AVE_Template->get_config_vars('POLL_ARCHIVE_TITLE'));
define('MODULE_CONTENT', $AVE_Template->fetch($tpl_dir . 'archive.tpl'));
}
/**
* Метод отображения комментариев
*
* @param string $tpl_dir путь к папке с шаблонами модуля
* @param string $lang_file путь к языковому файлу модуля
* @param ini $pid идентификатор опроса
* @param string $theme
* @param string $errors
* @param string $text
* @param string $title
*/
function pollCommentShow($tpl_dir, $lang_file, $pid, $theme, $errors='', $text='', $title='')
{
global $AVE_DB, $AVE_Template;
$AVE_Template->config_load($lang_file, 'displayform');
$row = $AVE_DB->Query("
SELECT *
FROM " . PREFIX . "_module_poll
WHERE id = '" . $pid . "'
LIMIT 1
")->FetchRow();
$groups = explode(',', $row->poll_groups_id);
if ($row->poll_status == 1 && $row->poll_can_comment == 1 && in_array(UGROUP, $groups))
{
$AVE_Template->assign('cancomment', 1);
}
$AVE_Template->assign('max_chars', $this->_commentwords);
if ($this->_antispam == 1 && function_exists('imagettftext') && function_exists('imagejpeg'))
{
$AVE_Template->assign('anti_spam', 1);
}
if (!empty($errors)) $AVE_Template->assign('errors', $errors);
$AVE_Template->assign('theme_folder', $theme);
$AVE_Template->assign('title', $title);
$AVE_Template->assign('text', $text);
$AVE_Template->display($tpl_dir . 'poll_form.tpl');
}
/**
* Метод создания нового комментария
*
* @param string $tpl_dir путь к папке с шаблонами модуля
* @param string $lang_file путь к языковому файлу модуля
* @param int $pid идентификатор опроса
*/
function pollCommentNew($pid)
{
global $AVE_DB, $AVE_Template;
$errors = array();
if (isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 1)
{
$comment_title = iconv('utf-8', 'cp1251', $_POST['comment_title']);
$comment_text = iconv('utf-8', 'cp1251', $_POST['comment_text']);
}
else
{
$comment_title = $_POST['comment_title'];
$comment_text = $_POST['comment_text'];
}
$text = (mb_strlen($comment_text) > $this->_commentwords)
? mb_substr($comment_text, 0, $this->_commentwords) . '...'
: $comment_text;
if (mb_strlen($text) <= 10) $errors[] = $AVE_Template->get_config_vars('POLL_ENTER_TEXT');
if (empty($comment_title)) $errors[] = $AVE_Template->get_config_vars('POLL_ENTER_TITLE');
if ($this->_antispam == 1)
{
if (! (isset($_SESSION['captcha_keystring']) && isset($_POST['securecode'])
&& $_SESSION['captcha_keystring'] == $_POST['securecode']))
{
$errors[] = $AVE_Template->get_config_vars('POLL_ENTER_CODE');
}
unset($_SESSION['captcha_keystring']);
}
if (sizeof($errors) == 0)
{
$poll_groups_id = $AVE_DB->Query("
SELECT poll_groups_id
FROM " . PREFIX . "_module_poll
WHERE id = '" . $pid . "'
AND poll_status = '1'
AND poll_can_comment = '1'
")->GetCell();
if (!empty($poll_groups_id) && in_array(UGROUP, explode(',', $poll_groups_id)))
{
$author_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0;
$author_ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'];
$AVE_DB->Query("
INSERT " . PREFIX . "_module_poll_comments
SET
poll_id = '" . $pid . "',
poll_comment_time = '" . time() . "',
poll_comment_author_id = '" . $author_id . "',
poll_comment_author_ip = '" . $author_ip . "',
poll_comment_title = '" . $comment_title . "',
poll_comment_text = '" . $text . "'
");
return $errors;
}
$errors[] = $AVE_Template->get_config_vars('POLL_ERROR_PERM');
}
return $errors;
}
/**
* Методы административной части
*****************************************************************************************************************************************************/
/**
* Метод вывода списка опросов
*
* @param string $adm_dir путь к папке с шаблонами модуля
* @param string $lang_file путь к языковому файлу модуля
*/
function pollList($adm_dir, $lang_file)
{
global $AVE_DB, $AVE_Template;
$AVE_Template->config_load($lang_file, 'showpolls');
$num = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_module_poll")->GetCell();
$limit = $this->_adminlimit;
$pages = ceil($num / $limit);
$start = get_current_page() * $limit - $limit;
$items = array();
$sql = $AVE_DB->Query("
SELECT *
FROM " . PREFIX . "_module_poll
LIMIT " . $start . "," . $limit
);
while ($row = $sql->FetchRow())
{
$row_hits = $AVE_DB->Query("
SELECT SUM(poll_item_hits)
FROM " . PREFIX . "_module_poll_items
WHERE poll_id = '" . $row->id . "'
GROUP BY poll_id
")->GetCell();
$row->sum_hits = floor($row_hits);
$row->comments = $AVE_DB->Query("
SELECT COUNT(*)
FROM " . PREFIX . "_module_poll_comments
WHERE poll_id = '" . $row->id . "'
")->GetCell();
array_push($items, $row);
}
if ($num > $limit)
{
$page_nav = " <a class=\"pnav\" href=\"index.php?do=modules&action=modedit&mod=poll&moduleaction=1&cp=" . SESSION . "&page={s}\">{t}</a> ";
$page_nav = get_pagination($pages, 'page', $page_nav);
$AVE_Template->assign('page_nav', $page_nav);
}
$AVE_Template->assign('items', $items);
$AVE_Template->assign('content', $AVE_Template->fetch($adm_dir . 'admin_forms.tpl'));
}
/**
* Метод создания нового опроса
*
* @param string $adm_dir путь к папке с шаблонами модуля
* @param string $lang_file путь к языковому файлу модуля
*/
function pollNew($adm_dir, $lang_file)
{
global $AVE_DB, $AVE_Template;
$AVE_Template->config_load($lang_file, 'newpolls');
switch ($_REQUEST['sub'])
{
case '':
$groups = array();
$sql = $AVE_DB->Query("
SELECT
user_group AS id,
user_group_name AS name
FROM " . PREFIX . "_user_groups
");
while ($row = $sql->FetchRow())
{
$groups[$row->id] = $row->name;
}
$AVE_Template->assign('published', time());
$AVE_Template->assign('expire', mktime(date("H"), date("i"), 0, date("m"), date("d"), date("Y") + 10));
$AVE_Template->assign('groups', $groups);
$AVE_Template->assign('selected', array_keys($groups));
$AVE_Template->assign('start', time());
$AVE_Template->assign('end', time());
$AVE_Template->assign('adm_dir', $adm_dir);
$AVE_Template->assign('formaction', 'index.php?do=modules&action=modedit&mod=poll&moduleaction=new&sub=save&cp=' . SESSION);
$AVE_Template->assign('content', $AVE_Template->fetch($adm_dir . 'admin_fields.tpl'));
break;
case 'save':
$_REQUEST['poll_published'] = $this->_mktime($_REQUEST['poll_published']);
$_REQUEST['poll_expire'] = $this->_mktime($_REQUEST['poll_expire']);
$_REQUEST['poll_status'] = (!empty($_REQUEST['poll_status'])) ? (int)$_REQUEST['poll_status'] : '0';
$_REQUEST['poll_can_comment'] = (!empty($_REQUEST['poll_can_comment'])) ? (int)$_REQUEST['poll_can_comment'] : '0';
$AVE_DB->Query("
INSERT
INTO " . PREFIX . "_module_poll
SET
id = '',
poll_title = '" . $_REQUEST['poll_name'] . "',
poll_status = '" . $_REQUEST['poll_status'] . "',
poll_groups_id = '" . @implode(',', $_REQUEST['groups']) . "',
poll_users_id = '0',
poll_users_ip = '0',
poll_can_comment = '" . $_REQUEST['poll_can_comment'] . "',
poll_start = '" . $_REQUEST['poll_published'] . "',
poll_end = '" . $_REQUEST['poll_expire'] . "'
");
$iid = $AVE_DB->InsertId();
reportLog($_SESSION['user_name'] . ' - Добавил новый опрос (' . stripslashes($_REQUEST['poll_name']) . ')');
header('Location:index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&id=' . $iid . '&cp=' . SESSION);
exit;
}
}
/**
* Метод записи вариантов ответа нового опроса
*
* @param int $pid идентификатор опроса
*/
function pollNewItemSave($pid)
{
global $AVE_DB;
if (!empty($_POST['item_title']))
{
$position = (int)$AVE_DB->Query("
SELECT MAX(poll_item_position)
FROM " . PREFIX . "_module_poll_items
WHERE poll_id = '" . $pid . "'
")->GetCell() + 1;
$AVE_DB->Query("
INSERT
INTO " . PREFIX . "_module_poll_items
SET
id = '',
poll_id = '" . $pid . "',
poll_item_title = '" . $_REQUEST['item_title'] . "',
poll_item_hits = '" . $_REQUEST['poll_item_hits'] . "',
poll_item_color = '" . $_REQUEST['line_color'] . "',
poll_item_position = '" . $position . "'
");
}
reportLog($_SESSION['user_name'] . ' - Добавил новый вариант ответа (' . ($_REQUEST['item_title']) . ') для опроса', 2, 2);
header('Location:index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&id=' . $pid . '&cp=' . SESSION);
exit;
}
/**
* Метод редактирования опроса
*
* @param string $adm_dir путь к папке с шаблонами модуля
* @param string $lang_file путь к языковому файлу модуля
* @param int $pid идентификатор опроса
*/
function pollEdit($adm_dir, $lang_file, $pid)
{
global $AVE_DB, $AVE_Template;
$AVE_Template->config_load($lang_file, 'editpolls');
switch ($_REQUEST['sub'])
{
case '':
$items = array();
$sql = $AVE_DB->Query("
SELECT *
FROM " . PREFIX . "_module_poll_items
WHERE poll_id = '" . $pid . "'
ORDER BY poll_item_position ASC
");
while ($row = $sql->FetchRow())
{
array_push($items, $row);
}
$groups = array();
$sql = $AVE_DB->Query("
SELECT
user_group AS id,
user_group_name AS name
FROM " . PREFIX . "_user_groups
");
while ($row = $sql->FetchRow())
{
$groups[$row->id] = $row->name;
}
$row = $AVE_DB->Query("
SELECT *
FROM " . PREFIX . "_module_poll
WHERE id = '" . $pid . "'
")->FetchRow();
$AVE_Template->assign('groups', $groups);
$AVE_Template->assign('selected', explode(',', $row->poll_groups_id));
$AVE_Template->assign('row', $row);
$AVE_Template->assign('items', $items);
$AVE_Template->assign('adm_dir', $adm_dir);
$AVE_Template->assign('start', $row->poll_start);
$AVE_Template->assign('end', $row->poll_end);
$AVE_Template->assign('formaction', 'index.php?do=modules&action=modedit&mod=poll&moduleaction=save&cp=' . SESSION . '&id=' . $pid);
$AVE_Template->assign('content', $AVE_Template->fetch($adm_dir . 'admin_fields.tpl'));
break;
case 'sortable':
foreach ($_REQUEST['sort'] as $position => $items_id)
{
$AVE_DB->Query("
UPDATE " . PREFIX . "_module_poll_items
SET
poll_item_position = '" . (int)$position . "'
WHERE
id = '" . (int)$items_id . "'
");
}
exit;
}
}
/**
* Метод записи изменений в опросе
*
* @param int $pid идентификатор опроса
*/
function pollSave($pid)
{
global $AVE_DB;
$AVE_DB->Query("
UPDATE " . PREFIX . "_module_poll
SET
poll_title = '" . $_REQUEST['poll_name'] . "',
poll_status = '" . $_REQUEST['poll_status'] . "',
poll_can_comment = '" . $_REQUEST['poll_can_comment'] . "',
poll_start = '" . $this->_mktime($_REQUEST['poll_published']) . "',
poll_end = '" . $this->_mktime($_REQUEST['poll_expire']). "',
poll_groups_id = '" . @implode(',', (array)$_REQUEST['groups']) . "'
WHERE
id = '" . $pid . "'
");
if (!empty($_POST['del']))
{
foreach ($_POST['del'] as $id => $field)
{
$AVE_DB->Query("
DELETE
FROM " . PREFIX . "_module_poll_items
WHERE id = '" . $id . "'
");
}
}
foreach ($_POST['item_title'] as $id => $field)
{
if (!empty($field))
{
$AVE_DB->Query("
UPDATE " . PREFIX . "_module_poll_items
SET
poll_item_title = '" . $field . "',
poll_item_hits = '" . $_POST['poll_item_hits'][$id] . "',
poll_item_color = '" . $_POST['line_color'][$id] . "'
WHERE
id = '" . $id . "'
");
}
}
header('Location:index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&id=' . $pid . '&cp=' . SESSION);
exit;
}
/**
* Метод удаления опроса
*
* @param int $pid идентификатор опроса
*/
function pollDelete($pid)
{
global $AVE_DB;
$AVE_DB->Query("
DELETE
FROM " . PREFIX . "_module_poll
WHERE id = '" . $pid . "'
");
$AVE_DB->Query("
DELETE
FROM " . PREFIX . "_module_poll_items
WHERE poll_id = '" . $pid . "'
");
$AVE_DB->Query("
DELETE
FROM " . PREFIX . "_module_poll_comments
WHERE poll_id = '" . $pid . "'
");
reportLog($_SESSION['user_name'] . ' - удалил опрос (' . $pid . ')', 2, 2);
header('Location:index.php?do=modules&action=modedit&mod=poll&moduleaction=1&cp=' . SESSION);
exit;
}
/**
* Метод управления комментариями к опросам
*
* @param string $tpl_dir путь к папке с шаблонами модуля
* @param string $lang_file путь к языковому файлу модуля
* @param int $pid идентификатор опроса
*/
function pollCommentEdit($adm_dir, $lang_file, $pid)
{
global $AVE_DB, $AVE_Template;
$AVE_Template->config_load($lang_file, 'showcomments');
switch ($_REQUEST['sub'])
{
case '':
$items = array();
$sql = $AVE_DB->Query("
SELECT *
FROM " . PREFIX . "_module_poll_comments
WHERE poll_id = '" . $pid . "'
");
while ($row = $sql->FetchRow())
{
$row->poll_comment_author = get_username_by_id($row->poll_comment_author_id);
array_push($items, $row);
}
$AVE_Template->assign('items', $items);
$AVE_Template->assign('adm_dir', $adm_dir);
$AVE_Template->assign('content', $AVE_Template->fetch($adm_dir . 'admin_comments.tpl'));
break;
case 'save':
if (!empty($_POST['del']))
{
foreach ($_POST['del'] as $id => $val)
{
$AVE_DB->Query("
DELETE
FROM " . PREFIX . "_module_poll_comments
WHERE id = '" . $id . "'
");
}
}
foreach ($_POST['comment_text'] as $id => $comment)
{
if (!empty($comment))
{
$AVE_DB->Query("
UPDATE " . PREFIX . "_module_poll_comments
SET
poll_comment_title = '" . $_POST['comment_title'][$id] . "',
poll_comment_text = '" . $comment . "'
WHERE
id = '" . $id . "'
");
}
}
header('Location:index.php?do=modules&action=modedit&mod=poll&moduleaction=comments&id=' . $pid . '&cp=' . SESSION);
exit;
}
}
/**
* Формитрование метки времени по данным полученным из выпадающих списков
* сформированных Smarty {html_select_date} и {html_select_time}
*
* @param string $date имя массива с значениями даты
* @param string $time имя массива с значениями времени
* @return unknown timestamp
*/
function _mktime($data=0)
{
$data = explode(" ", $data);
$stamp[day] = explode(".", $data[0]);
$stamp[time] = explode(":", $data[1]);
if (!empty($stamp))
{
$timestamp = mktime(
$stamp[time][0],
$stamp[time][1],
0,
$stamp[day][1],
$stamp[day][0],
$stamp[day][2]
);
}
return $timestamp;
}
}
?>

13
funcs/func.rewrite.php

@ -0,0 +1,13 @@
<?php
function PollRewrite($print_out)
{
$print_out = preg_replace('/index.php([?])module=poll&amp;action=result&amp;pid=(\d+)/', ABS_PATH . 'poll-\\2.html', $print_out);
$print_out = preg_replace('/index.php([?])module=poll&amp;action=form&amp;pop=1&amp;pid=(\d+)/', ABS_PATH . 'pollcomment-\\2.html', $print_out);
$print_out = preg_replace('/index.php([?])module=poll&amp;action=archive/', ABS_PATH . 'poll-archive.html', $print_out);
$print_out = str_replace(".html&amp;print=1", "-print.html", $print_out);
return $print_out;
}
?>

4
index.php

@ -0,0 +1,4 @@
<?php
header('Location:/');
exit;
?>

4
lang/index.php

@ -0,0 +1,4 @@
<?php
header('Location:/');
exit;
?>

140
lang/ru.txt

@ -0,0 +1,140 @@
[showpoll]
POLL_ALREADY_POLL = "Ваше мнение уже учтено"
POLL_BUTTON_VOTE = "Голосовать"
POLL_EXPIRED = "Ваше мнние не может быть учтено, т.к. период опроса истек"
POLL_NO_PERMISSION = "Ваше мнние не может быть учтено, т.к. Вы не участвуете в опросе"
POLL_PUBLIC_TITLE = "Оставьте ваше мнение"
POLL_PUB_RESULTS = "Результаты"
POLL_VIEW_ARCHIVES = "Архив"
POLL_VOTES = "Мнений:"
[showresult]
POLL_ACTIVE_INFO = "Опрос активен. Вы можете высказать свое мнение."
POLL_ADDED = "Добавил"
POLL_ALL_COMMENTS = "Всего комментариев:"
POLL_ALL_HITS = "Всего мнений:"
POLL_BUTTON_VOTE = "Голосовать"
POLL_DATE_FORMAT1 = "%d.%m.%Y, %H:%M"
POLL_ENDED = "Окончание опроса:"
POLL_GROUPS_PERM = "Участвующие группы:"
POLL_INACTIVE_INFO = "Опрос неактивен. Период действия опроса истек. Вы не можете оставить свой голос."
POLL_INFOS = "Дополнительная информация"
POLL_PUB_ADD_COMMENT = "Добавить комментарий"
POLL_PUB_COMMENTS = "Комментарии к опросу"
POLL_PUB_STATUS = "Статус опроса:"
POLL_QUESTION_LIST = "Варианты ответов"
POLL_RESULT_INFO = "Мнений | График | Процент"
POLL_STARTED = "Начало опроса:"
POLL_PAGE_TITLE_PREFIX = "Результаты опроса / "
POLL_GUEST = "Прохожий"
POLL_BUTTON_ADD_C = "Добавить"
POLL_CHARSET_LEFT = "осталось символов"
POLL_YOUR_NAME = "Имя"
POLL_SECURE_CODE = "Защитный код"
POLL_ERROR_NO_TITLE = "Пожалуйста, укажите заголовок комментария"
POLL_ERROR_NO_TEXT = "Пожалуйста, напишите комментарий длинной не менее 10 символов"
POLL_ERROR_NO_SCODE = "Пожалуйста, укажите защитный код"
[showarchive]
POLL_ARCHIVE_HITS = "Мнений"
POLL_ARCHIVE_TITLE = "Архив опросов"
POLL_DATE_FORMAT2 = "%d.%m.%Y"
POLL_PUB_START = "Начало"
POLL_PUB_END = "Окончание"
POLL_PUB_TITLE = "Тема опроса"
[displayform]
POLL_ADD_COMMENT = "Оставьте свой комментарий"
POLL_BUTTON_ADD_C = "Добавить комментарий"
POLL_BUTTON_RESET = "Очистить поля"
POLL_CHARSET_LEFT = "осталось символов"
POLL_CLOSE_W = "Закрыть окно"
POLL_COMMENT_ERROR = "Извините, но у вас недостаточно прав для добавления комментария."
POLL_COMMENT_M = "Текст комментария"
POLL_COMMENT_T = "Заголовок комментария"
POLL_ENTER_CODE = "Пожалуйста, укажите защитный код"
POLL_ENTER_TEXT = "Пожалуйста, напишите комментарий длинной не менее 10 символов"
POLL_ENTER_TITLE = "Пожалуйста, укажите заголовок комментария"
POLL_SECURE_CODE = "Защитный код"
[showpolls]
POLL_ACTIONS = "Действия"
POLL_ACTIVE = "Опрос активен"
POLL_DATE_FORMAT1 = "%d.%m.%Y, %H:%M"
POLL_DELETE = "Удалить данный опрос"
POLL_DELETE_CONFIRM = "Вы уверены, что хотите удалить данный опрос?"
POLL_EDIT_POLL = "Редактировать данный опрос"
POLL_HITS_CMMENT = "Мнений/Комментариев"
POLL_INACTIVE = "Опрос неактивен"
POLL_MODULE_NAME = "Опросы"
POLL_MODULE_TITLE = "В данном разделе представлены все существующие опросы в системе."
POLL_MODULE_ALL = "Список опросов"
POLL_NAME = "Тема опроса"
POLL_NEW_LINK = "Создать новый опрос"
POLL_START_END = "Время проведения"
POLL_SYSTEM_TAG = "Системный тег"
POLL_MODULE_NO_ITEMS = "В данный момент, нет опросов."
[editpolls]
POLL_ADD_POLL = "Создание нового опроса"
POLL_BUTTON_ADD = "Добавить вариант ответа"
POLL_BUTTON_SAVE = "Сохранить изменения"
POLL_CAN_COMMENT = "Разрешить комментарии?"
POLL_EDIT = "Редактирование опроса"
POLL_EDIT_INFO = "В данном разделе вы можете внести изменения в текущий опрос, продлить или сократить время действия опроса."
POLL_END_TIME = "Дата и время окончания:"
POLL_GROUP_INFO = "Для выбора нескольких групп, удерживайте клавишу CTRL."
POLL_MARK_DELETE = "Отметить для удаления"
POLL_NAME = "Тема опроса"
POLL_NEW_INFO = "В данном разделе вы можете создать новый опрос указав дату начала и окончания опроса. Также вы можете выбрать статус опроса, разрешить или запретить комментарии к даннному опросу и выбрать группы пользователей, которым будет доступно голосование."
POLL_NO = "Нет"
POLL_QUESTION_COLOR = "Цвет (например #F96600)"
POLL_QUESTION_HITS = "Мнений"
POLL_QUESTION_NAME = "Вариант ответа"
POLL_QUESTION_POSI = "Позиция"
POLL_SETTINGS_TITLE = "Создание нового опроса"
POLL_START_TIME = "Дата и время начала:"
POLL_STATUS = "Активный"
POLL_USER_GROUPS = "Группы пользователей, участвующие в опросе:"
POLL_YES = "Да"
POLL_MODULE_NAME = "Опросы"
POLL_QUESTIONS = "Варианты ответа"
POLL_QUESTIONS_ADD = "Добавить вариант"
POLL_QUESTION_NO_ITEMS = "Нет вариантов ответа"
POLL_POSITION_SUCCES = "Порядок сохранён"
[newpolls]
POLL_ADD_POLL = "Создание нового опроса"
POLL_BUTTON_ADD = "Добавить вариант"
POLL_BUTTON_SAVE = "Сохранить изменения"
POLL_CAN_COMMENT = "Разрешить комментарии?"
POLL_EDIT = "Редактирование опроса"
POLL_EDIT_INFO = "В данном разделе вы можете внести изменения в текущий опрос, продлить или сократить время действия опроса."
POLL_END_TIME = "Дата и время окончания:"
POLL_GROUP_INFO = "Для выбора нескольких групп, удерживайте клавишу CTRL."
POLL_MARK_DELETE = "Отметить для удаления"
POLL_NAME = "Название опроса"
POLL_NEW_INFO = "В данном разделе вы можете создать новый опрос указав дату начала и окончания опроса. Также вы можете выбрать статус опроса, разрешить или запретить комментарии к даннному опросу и выбрать группы пользователей, которым будет доступно голосование."
POLL_NO = "Нет"
POLL_QUESTION_COLOR = "Цвет (например #F96600)"
POLL_QUESTION_HITS = "Голосов"
POLL_QUESTION_NAME = "Название вопроса"
POLL_QUESTION_POSI = "Позиция"
POLL_SETTINGS_TITLE = "Создание нового опроса"
POLL_START_TIME = "Дата и время начала:"
POLL_STATUS = "Активный"
POLL_USER_GROUPS = "Группы пользователей, участвующие в опросе:"
POLL_YES = "Да"
POLL_MODULE_NAME = "Опросы"
[showcomments]
POLL_BUTTON_CLOSE = "Закрыть окно"
POLL_BUTTON_SAVE = "Сохранить изменения"
POLL_COMMENTS_INFO = "В данном разделе вы можете удалить или отредактировать комментарии, оставленные пользоателями для данного опроса."
POLL_COMMENTS_TITLE = "Просмотр / Редактирование комментариев"
POLL_COMMENT_AUTHOR = "Автор:"
POLL_COMMENT_DATE = "Дата создания:"
POLL_COMMENT_INFO = "Информация"
POLL_COMMENT_TITLE = "Содержимое комментария"
POLL_MARK_DELETE = "Отметить для удаления"
POLL_MODULE_NAME = "Опросы"

118
module.php

@ -0,0 +1,118 @@
<?php
if(!defined('BASE_DIR')) exit;
if (defined('ACP'))
{
$modul['ModuleName'] = 'Опросы';
$modul['ModuleSysName'] = 'poll';
$modul['ModuleVersion'] = '1.1a';
$modul['ModuleDescription'] = 'Данный модуль предназачен для организации системы опросов на сайте. Возможности модуля позволяют создавать неограниченное количество опросных листов, а также неограниченное количество вопросов.';
$modul['ModuleAutor'] = 'AVE.CMS Team';
$modul['ModuleCopyright'] = '&copy; 2007-2013 AVE.CMS';
$modul['ModuleIsFunction'] = 1;
$modul['ModuleTemplate'] = 1;
$modul['ModuleAdminEdit'] = 1;
$modul['ModuleFunction'] = 'mod_poll';
$modul['ModuleTag'] = '[mod_poll:XXX]';
$modul['ModuleTagLink'] = null;
$modul['ModuleAveTag'] = '#\\\[mod_poll:(\\\d+)]#';
$modul['ModulePHPTag'] = "<?php mod_poll(''$1''); ?>";
}
function mod_poll($poll_id)
{
require_once(BASE_DIR . '/modules/poll/class.poll.php');
require_once(BASE_DIR . '/modules/poll/funcs/func.rewrite.php');
$poll = new Poll;
$tpl_dir = BASE_DIR . '/modules/poll/templates/';
$lang_file = BASE_DIR . '/modules/poll/lang/' . $_SESSION['user_language'] . '.txt';
$poll->pollShow($tpl_dir, $lang_file, stripslashes($poll_id));
}
if (!defined('ACP')
&& isset($_REQUEST['module']) && $_REQUEST['module'] == 'poll'
&& isset($_REQUEST['action']))
{
require_once(BASE_DIR . '/modules/poll/class.poll.php');
require_once(BASE_DIR . '/modules/poll/funcs/func.rewrite.php');
$poll = new Poll;
$tpl_dir = BASE_DIR . '/modules/poll/templates/';
$lang_file = BASE_DIR . '/modules/poll/lang/' . $_SESSION['user_language'] . '.txt';
switch ($_REQUEST['action'])
{
case 'result':
$poll->pollResultShow($tpl_dir, $lang_file, (int)$_REQUEST['pid']);
break;
case 'vote':
$poll->pollVote((int)$_REQUEST['pid']);
break;
case 'archive':
$poll->pollArchiveShow($tpl_dir, $lang_file);
break;
case 'form':
$poll->pollCommentShow($tpl_dir, $lang_file, (int)$_REQUEST['pid'], THEME_FOLDER);
break;
case 'comment':
$poll->pollCommentNew($tpl_dir, $lang_file, (int)$_REQUEST['pid']);
break;
}
}
if (defined('ACP') && !empty($_REQUEST['moduleaction']))
{
require_once(BASE_DIR . '/modules/poll/class.poll.php');
require_once(BASE_DIR . '/modules/poll/funcs/func.rewrite.php');
$poll = new Poll;
$adm_dir = BASE_DIR . '/modules/poll/admin/';
$lang_file = BASE_DIR . '/modules/poll/lang/' . $_SESSION['user_language'] . '.txt';
switch ($_REQUEST['moduleaction'])
{
case '1':
$poll->pollList($adm_dir, $lang_file);
break;
case 'new':
$poll->pollNew($adm_dir, $lang_file);
break;
case 'save_new':
$poll->pollNewItemSave((int)$_REQUEST['id']);
break;
case 'edit':
$poll->pollEdit($adm_dir, $lang_file, (int)$_REQUEST['id']);
break;
case 'save':
$poll->pollSave((int)$_REQUEST['id']);
break;
case 'delete':
$poll->pollDelete((int)$_REQUEST['id']);
break;
case 'comments':
$poll->pollCommentEdit($adm_dir, $lang_file, (int)$_REQUEST['id']);
break;
case 'sort':
$poll->pollSort((array)$_REQUEST['sort']);
exit;
}
}
?>

93
sql.php

@ -0,0 +1,93 @@
<?php
/**
* AVE.cms - Модуль Опросы.
*
* @package AVE.cms
* @subpackage mod_poll
* @since 1.1
* @filesource
*/
/**
* mySQL-запросы для установки, обновления и удаления модуля
*/
$module_sql_install = array();
$module_sql_deinstall = array();
$module_sql_update = array();
// Удаление модуля
$module_sql_deinstall[] = "DROP TABLE IF EXISTS CPPREFIX_module_poll;";
$module_sql_deinstall[] = "DROP TABLE IF EXISTS CPPREFIX_module_poll_comments;";
$module_sql_deinstall[] = "DROP TABLE IF EXISTS CPPREFIX_module_poll_items;";
// Установка модуля
$module_sql_install[] = "CREATE TABLE CPPREFIX_module_poll (
id int(10) unsigned NOT NULL auto_increment,
poll_title varchar(255) NOT NULL default '',
poll_status enum('1','0') NOT NULL default '1',
poll_can_comment enum('0','1') NOT NULL default '0',
poll_groups_id tinytext,
poll_start int(10) unsigned NOT NULL default '0',
poll_end int(10) unsigned NOT NULL default '0',
poll_users_id text NOT NULL default '',
poll_users_ip text NOT NULL default '',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$module_sql_install[] = "CREATE TABLE CPPREFIX_module_poll_comments (
id int(10) unsigned NOT NULL auto_increment,
poll_id int(10) NOT NULL,
poll_comment_author_id int(10) NOT NULL,
poll_comment_author_ip text NOT NULL default '',
poll_comment_time int(10) unsigned NOT NULL default '0',
poll_comment_title varchar(250) NOT NULL default '',
poll_comment_text text NOT NULL default '',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$module_sql_install[] = "CREATE TABLE CPPREFIX_module_poll_items (
id int(10) unsigned NOT NULL auto_increment,
poll_id int(10) NOT NULL,
poll_item_title varchar(250) NOT NULL default '',
poll_item_hits int(10) NOT NULL default '0',
poll_item_color varchar(10) NOT NULL default '',
poll_item_position int(2) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
// Обновление модуля
$module_sql_update[] = "
UPDATE
`CPPREFIX_module`
SET
ModuleAveTag = '" . $modul['ModuleAveTag'] . "',
ModulePHPTag = '" . $modul['ModulePHPTag'] . "',
ModuleVersion = '" . $modul['ModuleVersion'] . "'
WHERE
ModuleSysName = '" . $modul['ModuleSysName'] . "'
LIMIT 1;
";
$module_sql_update[] = "
RENAME TABLE
`CPPREFIX_modul_poll`
TO
`CPPREFIX_module_poll`
";
$module_sql_update[] = "
RENAME TABLE
`CPPREFIX_modul_poll_comments`
TO
`CPPREFIX_module_poll_comments`
";
$module_sql_update[] = "
RENAME TABLE
`CPPREFIX_modul_poll_items`
TO
`CPPREFIX_module_poll_items`
";
?>

24
templates/archive.tpl

@ -0,0 +1,24 @@
<h2>{#POLL_ARCHIVE_TITLE#}</h2><br />
<br />
<table width="100%" border="0" cellpadding="0" cellspacing="1">
<col>
<col width="100">
<col width="100">
<col width="100">
<tr>
<td class="mod_poll_table"><a href="index.php?module=poll&amp;action=archive&amp;order=title{if $smarty.request.order=='title' && $smarty.request.by!='desc'}&amp;by=desc{/if}">{#POLL_PUB_TITLE#}</a></td>
<td class="mod_poll_table" align="center"><a href="index.php?module=poll&amp;action=archive&amp;order=start{if $smarty.request.order=='start' && $smarty.request.by!='desc'}&amp;by=desc{/if}">{#POLL_PUB_START#}</a></td>
<td class="mod_poll_table" align="center"><a href="index.php?module=poll&amp;action=archive&amp;order=end{if $smarty.request.order=='end' && $smarty.request.by!='desc'}&amp;by=desc{/if}">{#POLL_PUB_END#}</a></td>
<td class="mod_poll_table" align="center"><a href="index.php?module=poll&amp;action=archive&amp;order=votes{if $smarty.request.order=='votes' && $smarty.request.by!='desc'}&amp;by=desc{/if}">{#POLL_ARCHIVE_HITS#}</a></td>
</tr>
{foreach from=$items item=item}
<tr class="{cycle name='1' values="mod_poll_first,mod_poll_second"}">
<td><a href="{$item->plink}">{$item->poll_title}</a></td>
<td align="center">{$item->poll_start|date_format:$DATE_FORMAT|pretty_date}</td>
<td align="center">{$item->poll_end|date_format:$DATE_FORMAT|pretty_date}</td>
<td align="center">{$item->votes}</td>
</tr>
{/foreach}
</table><br />
<br />

4
templates/index.php

@ -0,0 +1,4 @@
<?php
header('Location:/');
exit;
?>

1
templates/js/common.js

@ -0,0 +1 @@
(function($){$.fn.extend({limit:function(limit,element){var interval,f;var self=$(this);$(this).focus(function(){interval=window.setInterval(substring,100)});$(this).blur(function(){clearInterval(interval);substring()});substringFunction="function substring(){ var val = $(self).val();var length = val.length;if(length > limit){$(self).val($(self).val().substring(0,limit));}";if(typeof element!='undefined')substringFunction+="if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length);}";substringFunction+="}";eval(substringFunction);substring()}})})(jQuery);

93
templates/poll_form.tpl

@ -0,0 +1,93 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{#POLL_ADD_COMMENT#}</title>
<link href="templates/{$theme_folder}/css/layout.css" rel="stylesheet" type="text/css" media="screen" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="templates/{$theme_folder}/js/common.js" type="text/javascript"></script>
</head>
<body id="body_popup">
<script type="text/javascript" language="JavaScript">
var aveabspath = '{$smarty.const.ABS_PATH}';
$(document).ready(function() {ldelim}
$('#comment_text')
.after('{#POLL_CHARSET_LEFT#} - <span class="charsLeft" id="charsLeft_new"></span>')
.limit({$max_chars},'#charsLeft_new');
$('#gpf').submit(function() {ldelim}
if ($('comment_title').val() == '') {ldelim}
alert("{#POLL_ENTER_TITLE#}");
$('comment_title').focus();
return false;
{rdelim}
if ($('comment_text').val() == '') {ldelim}
alert("{#POLL_ENTER_TEXT#}");
$('comment_text').focus();
return false;
{rdelim}
{if $anti_spam == 1}
if ($('#gbf #securecode').val() == '') {ldelim}
alert("{#POLL_ENTER_CODE#}");
$('#gbf #securecode').focus();
return false;
{rdelim}{/if}
{rdelim});
{rdelim});
</script>
<h5>{#POLL_ADD_COMMENT#}</h5>
<div id="module_content">
{if $cancomment != 1}
<p id="module_intro">{#POLL_COMMENT_ERROR#}</p>
<p>&nbsp;</p>
<p><input onclick="window.close();" type="button" class="button" value="{#POLL_CLOSE_W#}" /></p>
{else}
<form id="pf" method="post" action="index.php?module=poll&action=comment&pid={$smarty.request.pid|escape}">
{if $errors}<ul>
{foreach from=$errors item=error}<li>{$error|escape}</li>
{/foreach}
</ul>{/if}
<fieldset>
<legend><label for="l_Titel">{#POLL_COMMENT_T#}</label></legend>
<input name="comment_title" type="text" id="comment_title" style="width:250px" value="{$title|escape}" />
</fieldset><br />
<fieldset>
<legend><label for="l_Text">{#POLL_COMMENT_M#}</label></legend>
{* <textarea onkeyup="javascript:textCounter(this.form.comment_text,this.form.charleft,{$max_chars});" onkeydown="javascript:textCounter(this.form.comment_text,this.form.charleft,{$max_chars});" style="width:98%; height:165px" name="comment_text" id="comment_text">{$text}</textarea>
<input type="text" size="6" name="charleft" value="{$max_chars}" /> {#POLL_CHARSET_LEFT#}
*}
<textarea id="comment_text" name="comment_text" cols="80" rows="15" style="width:98%; height:165px">{$text}</textarea>
</fieldset>
{if $anti_spam == 1}
<fieldset>
{*
<legend><label for="l_Text">{#POLL_SECURE_CODE#}</label></legend>
<img src="inc/antispam.php?cp_secureimage={$im}" alt="" width="121" height="41" border="0" /><br />
<br />
<small><span id="S_secure_{$im}"></span></small>
<input name="comment_code" type="text" id="comment_code" style="width:100px" maxlength="7" />
*}
<p>
<label>{#POLL_SECURE_CODE#}</label>
<span id="captcha"><img src="{$ABS_PATH}inc/captcha.php" alt="" width="120" height="60" border="0" /></span><br />
<label>{#POLL_ENTER_CODE#}</label><br />
<input name="securecode" type="text" id="securecode" maxlength="10" /><br />
</p>
</fieldset>
{/if}
<p>
<input type="submit" class="button" value="{#POLL_BUTTON_ADD_C#}" />&nbsp;
<input type="reset" class="button" value="{#POLL_BUTTON_RESET#}" />
</p>
</form>
{/if}
</div>
</body>
</html>

10
templates/poll_nav.tpl

@ -0,0 +1,10 @@
<p><strong>{$poll->poll_title}</strong></p>
<form method="post" action="{$formaction}">
<p>
{foreach from=$items item=item}
<input class="absmiddle" type="radio" name="p_item" value="{$item->id}" />&nbsp;{$item->poll_item_title}<br />
{/foreach}
</p>
<input type="submit" style="width:80px" class="button" value="{#POLL_BUTTON_VOTE#}" />&nbsp;
<input type="button" style="width:80px" class="button" value="{#POLL_PUB_RESULTS#}" onclick="location.href='{$formaction_result}';" />
</form>

15
templates/poll_nav_result.tpl

@ -0,0 +1,15 @@
<p><strong>{$poll->poll_title}</strong></p>
<p>
{foreach from=$items item=item}
<div style="padding:2px">{$item->poll_item_title}</div>
<div style="width:98%;height:5px;padding:0">
<div style="display:block;background-color:{$item->poll_item_color};height:5px;width:{$item->sum|default:'0'}%"></div>
</div>
<small style="color:{$item->poll_item_color}">{#POLL_VOTES#} {$item->poll_item_hits} ({$item->sum|default:'0'}%)</small>
{/foreach}
</p>
{if $poll->message != ''}<p><small>{$poll->message}</small></p>{/if}
<form method="post">
<input type="button" class="button" style="width:100px" onclick="location.href='{$formaction_result}';" value="{#POLL_PUB_RESULTS#} ({$poll->sumhits})" />&nbsp;
<input type="button" class="button" style="width:50px" onclick="location.href='{$formaction_archive}';" value="{#POLL_VIEW_ARCHIVES#}" />
</form>

181
templates/result.tpl

@ -0,0 +1,181 @@
{literal}
<style>
#new fieldset {text-align:center; border:#ccc solid 1px;}
#new fieldset input {width:120px;}
#new .p_input label {float:left; width:10%; text-align:right; padding-right:.5em;}
#new .p_input input {width:40%;}
</style>
{/literal}
<script type="text/javascript" src="/modules/poll/templates/js/common.js"></script>
<script language="javascript">
$(document).ready(function() {ldelim}
$('#markItUpPost .markItUpHeader').append('{#POLL_CHARSET_LEFT#} - <span class="charsLeft" id="charsLeft_new"></span>');
$('#post').limit({$poll->comment_max_chars},'#charsLeft_new');
$('#new').submit(function() {ldelim}
if ($('#post_title').val() == '') {ldelim}
alert('{#POLL_ERROR_NO_TITLE#}');
$('#post_title').focus();
return false;
{rdelim}
var pftext = $('#new textarea').val();
if (pftext.length < 10) {ldelim}
alert("{#POLL_ERROR_SMALL_TEXT#}");
$('#new textarea').focus();
return false;
{rdelim}
{if $poll->anti_spam == 1}
if ($('#securecode').val() == '') {ldelim}
alert("{#POLL_ERROR_NO_SCODE#}");
$('#securecode').focus();
return false;
{rdelim}{/if}
{rdelim});
{rdelim});
</script>
<h2 id="page-heading">{$poll->poll_title|escape}</h2>
<div class="tablebox">
<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
<col width="50%">
<col width="5%">
<col width="40%">
<col width="5%">
<thead>
<tr>
<th>{#POLL_QUESTION_LIST#}</th>
<th colspan="3">{#POLL_RESULT_INFO#}</th>
</tr>
</thead>
{foreach from=$poll->items item=item}
<tr class="{cycle name="1" values=",odd"}">
<td>{$item->poll_item_title|escape}</td>
<td><div align="center"> {$item->poll_item_hits} </div></td>
<td >
<div style="width:100%;height:12px;padding:0">
<div style="width:{if $item->sum!=""}{$item->sum}%{else}1%{/if};height:12px;background-color:{$item->poll_item_color}">
<img height="1" width="1" src="{$img_folder}/pixel.gif" alt="" />
</div>
</div>
</td>
<td class="{cycle name="pollerg4" values="mod_poll_first,mod_poll_second"}" width="5%" nowrap="nowrap"><div align="center"> {$item->sum} %</div></td>
</tr>
{/foreach}
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#cccccc">
<col width="170">
<thead>
<tr>
<th colspan="2">{#POLL_INFOS#}</th>
</tr>
</thead>
<tr class="odd">
<td>{#POLL_ALL_HITS#}</td>
<td>{$poll->votes}</td>
</tr>
<tr >
<td>{#POLL_PUB_STATUS#}</td>
<td>{if $poll->poll_end > $smarty.now}{#POLL_ACTIVE_INFO#}{else}{#POLL_INACTIVE_INFO#}{/if}</td>
</tr>
<tr class="odd">
<td>{#POLL_STARTED#}</td>
<td>{$poll->poll_start|date_format:$TIME_FORMAT|pretty_date}</td>
</tr>
<tr >
<td>{#POLL_ENDED#}</td>
<td>{$poll->poll_end|date_format:$TIME_FORMAT|pretty_date}</td>
</tr>
<tr class="odd">
<td>{#POLL_GROUPS_PERM#}</td>
<td>{$poll->groups|escape}</td>
</tr>
</table>
{if $poll->can_vote == 1}
<br />
<div style="padding:5px"><strong>{$poll->poll_title|escape}</strong></div>
<form method="post" action="{$poll->formaction}">
{foreach from=$poll->items item=item}
<div style="margin-left:5px"><input type="radio" name="p_item" value="{$item->id}" /> {$item->poll_item_title|escape}</div>
{/foreach}
<div style="padding:5px"><input type="submit" class="button" value="{#POLL_BUTTON_VOTE#}" /></div>
</form>
{/if}
</div>
{if $poll->poll_can_comment == 1}
<br />
<h6>{#POLL_PUB_COMMENTS#}</h6>
<a href="{$poll->link_result}#new">{#POLL_PUB_ADD_COMMENT#}</a> | {#POLL_ALL_COMMENTS#} {$poll->count_comments}<br />
<br />
{foreach from=$poll->comments item=comment}
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="mod_comment_box" id="{$comment->id}">
<tr>
<td class="mod_comment_header">
<div class="mod_comment_author">
{*#POLL_ADDED#*} <a href="#">{$comment->lastname|escape} {$comment->firstname|escape}</a> {$comment->poll_comment_time|date_format:$TIME_FORMAT|pretty_date}
</div>
</td>
</tr>
<tr>
<td class="mod_comment_text">
<strong>{$comment->poll_comment_title|escape}</strong><br />
{$comment->poll_comment_text}
</td>
</tr>
</table>
{/foreach}
{if $poll->can_comment == 1}
<br />
{*<a name="new"></a>*}
{*<form id="new" method="post" action="index.php?module=poll&action=comment&pid={$poll->id}">*}
<form id="new" method="post">
<input name="sub" type="hidden" value="new" />
<div class="p_input">
<p>
<label>Заголовок</label>
<input type="text" name="comment_title" id="post_title" class="inputfield" size="80" value="{$smarty.post.comment_title|escape|stripslashes}" />
</p>
</div>
<textarea id="post" name="comment_text" cols="80" rows="15">{$smarty.post.comment_text|escape|stripslashes}</textarea>
<fieldset>
{if $poll->anti_spam == 1}
<p>
<span id="captcha"><img src="{$ABS_PATH}inc/captcha.php" alt="" width="120" height="60" border="0" /></span><br />
<label>{#POLL_SECURE_CODE#}</label><br />
<input name="securecode" type="text" id="securecode" maxlength="10" /><br />
</p>
{/if}
<input name="submit" type="submit" class="button" value="{#POLL_BUTTON_ADD_C#}" />
</fieldset>
</form>
<script>
$(document).ready(function(){ldelim}
$('#new').submit(function(){ldelim}
$(this).ajaxSubmit({ldelim}
url: aveabspath+'index.php?module=poll&action=result&pid={$poll->id}&ajax=1',
success: function(){ldelim}
target = $('h6').offset().top;
$("html").animate({ldelim}scrollTop: target{rdelim}, 1100);
{rdelim},
timeout: 3000
{rdelim});
return false;
{rdelim});
{rdelim});
</script>
{/if}
{/if}
Loading…
Cancel
Save