mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
Reduce JSON request of POLL
처음 설문조사 화면을 열 때는 JSON 요청을 하지 않고 바로 결과를 표시합니다.
This commit is contained in:
parent
3170040deb
commit
eee619a743
5 changed files with 61 additions and 35 deletions
|
|
@ -47,7 +47,7 @@ class poll_maker extends EditorHandler
|
||||||
{
|
{
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
|
|
||||||
$args->poll_srl = $xml_obj->attrs->poll_srl;
|
$args->poll_srl = intval($xml_obj->attrs->poll_srl);
|
||||||
$skin = $xml_obj->attrs->skin;
|
$skin = $xml_obj->attrs->skin;
|
||||||
if(!$skin) $skin = 'default';
|
if(!$skin) $skin = 'default';
|
||||||
$args->skin = $skin;
|
$args->skin = $skin;
|
||||||
|
|
@ -61,6 +61,11 @@ class poll_maker extends EditorHandler
|
||||||
$tpl_path = sprintf('%sskins/%s', _XE_PATH_ . 'widgets/pollWidget/', $args->skin);
|
$tpl_path = sprintf('%sskins/%s', _XE_PATH_ . 'widgets/pollWidget/', $args->skin);
|
||||||
$tpl_file = 'pollview';
|
$tpl_file = 'pollview';
|
||||||
|
|
||||||
|
// Get the information related to the survey
|
||||||
|
$oPollModel = getModel('poll');
|
||||||
|
$poll_data = $oPollModel->_getPollinfo($args->poll_srl);
|
||||||
|
|
||||||
|
Context::set('poll_data', $poll_data);
|
||||||
Context::set('colorset', $args->colorset);
|
Context::set('colorset', $args->colorset);
|
||||||
Context::set('poll_srl', $args->poll_srl);
|
Context::set('poll_srl', $args->poll_srl);
|
||||||
Context::set('style', $args->style);
|
Context::set('style', $args->style);
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,21 @@ class pollModel extends poll
|
||||||
/**
|
/**
|
||||||
* @brief Initialization
|
* @brief Initialization
|
||||||
*/
|
*/
|
||||||
function init()
|
public function init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief returns poll infomation
|
* @brief returns poll infomation
|
||||||
*/
|
*/
|
||||||
function getPollinfo()
|
public function _getPollinfo($poll_srl)
|
||||||
{
|
{
|
||||||
$args = new stdClass;
|
$args = new stdClass;
|
||||||
$poll_srl = Context::get('poll_srl');
|
$args->poll_srl = intval($poll_srl);
|
||||||
$logged_info = Context::get('logged_info');
|
$logged_info = Context::get('logged_info');
|
||||||
|
|
||||||
if(!$poll_srl || $poll_srl=='') return new Object(-1,"poll_no_poll_srl");
|
if(!$args->poll_srl || $args->poll_srl === 0) return new Object(-1,"poll_no_poll_srl");
|
||||||
|
|
||||||
$args->poll_srl = $poll_srl;
|
|
||||||
// Get the information related to the survey
|
// Get the information related to the survey
|
||||||
$columnList = array('poll_count', 'stop_date','poll_type','member_srl');
|
$columnList = array('poll_count', 'stop_date','poll_type','member_srl');
|
||||||
$output = executeQuery('poll.getPoll', $args, $columnList);
|
$output = executeQuery('poll.getPoll', $args, $columnList);
|
||||||
|
|
@ -33,8 +32,11 @@ class pollModel extends poll
|
||||||
if(!$output->data) return new Object(-1,"poll_no_poll_or_deleted_poll");
|
if(!$output->data) return new Object(-1,"poll_no_poll_or_deleted_poll");
|
||||||
|
|
||||||
$poll = new stdClass;
|
$poll = new stdClass;
|
||||||
|
|
||||||
|
// if a person can vote is_polled=0, else 1
|
||||||
$poll->is_polled = 0;
|
$poll->is_polled = 0;
|
||||||
if($output->data->stop_date < date("Ymd")) $poll->is_polled = 1;
|
if($output->data->stop_date < date("Ymd")) $poll->is_polled = 1;
|
||||||
|
elseif($this->isPolled($poll_srl)) $poll->is_polled = 1;
|
||||||
|
|
||||||
$poll->poll_count = (int)$output->data->poll_count;
|
$poll->poll_count = (int)$output->data->poll_count;
|
||||||
$poll->poll_type = (int)$output->data->poll_type;
|
$poll->poll_type = (int)$output->data->poll_type;
|
||||||
|
|
@ -64,20 +66,31 @@ class pollModel extends poll
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$output = new stdClass;
|
||||||
|
|
||||||
$poll->poll_srl = $poll_srl;
|
$poll->poll_srl = $poll_srl;
|
||||||
$caniadditem = $this->isAbletoAddItem($poll->poll_type) && !!$logged_info->member_srl;
|
$output->caniadditem = $this->isAbletoAddItem($poll->poll_type) && !!$logged_info->member_srl;
|
||||||
|
|
||||||
$oPollModel = getModel('poll');
|
$output->poll = $poll;
|
||||||
if($oPollModel->isPolled($poll_srl)) $poll->is_polled = 1;
|
|
||||||
|
|
||||||
$this->add('poll', $poll);
|
return $output;
|
||||||
$this->add('caniadditem', $caniadditem);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief returns poll infomation
|
||||||
|
*/
|
||||||
|
public function getPollinfo()
|
||||||
|
{
|
||||||
|
$output = $this->_getPollinfo(Context::get('poll_srl'));
|
||||||
|
|
||||||
|
$this->add('poll', $output->poll);
|
||||||
|
$this->add('caniadditem', $output->caniadditem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief returns poll item infomation
|
* @brief returns poll item infomation
|
||||||
*/
|
*/
|
||||||
function getPollitemInfo()
|
public function getPollitemInfo()
|
||||||
{
|
{
|
||||||
$args = new stdClass;
|
$args = new stdClass;
|
||||||
$poll_srl = Context::get('poll_srl');
|
$poll_srl = Context::get('poll_srl');
|
||||||
|
|
@ -160,13 +173,12 @@ class pollModel extends poll
|
||||||
* @brief returns poll status
|
* @brief returns poll status
|
||||||
* @see this function uses isPolled function below
|
* @see this function uses isPolled function below
|
||||||
*/
|
*/
|
||||||
function getPollstatus()
|
public function getPollstatus()
|
||||||
{
|
{
|
||||||
$poll_srl = Context::get('poll_srl');
|
$poll_srl = Context::get('poll_srl');
|
||||||
if(!$poll_srl || $poll_srl=='') return new Object(-1,"poll_no_poll_srl");
|
if(!$poll_srl || $poll_srl=='') return new Object(-1,"poll_no_poll_srl");
|
||||||
|
|
||||||
$oPollModel = getModel('poll');
|
if($this->isPolled($poll_srl)) $is_polled = 1;
|
||||||
if($oPollModel->isPolled($poll_srl)) $is_polled = 1;
|
|
||||||
else $is_polled = 0;
|
else $is_polled = 0;
|
||||||
|
|
||||||
$this->add('is_polled', $is_polled);
|
$this->add('is_polled', $is_polled);
|
||||||
|
|
@ -175,7 +187,7 @@ class pollModel extends poll
|
||||||
/**
|
/**
|
||||||
* @brief The function examines if the user has already been polled
|
* @brief The function examines if the user has already been polled
|
||||||
*/
|
*/
|
||||||
function isPolled($poll_srl)
|
public function isPolled($poll_srl)
|
||||||
{
|
{
|
||||||
$args = new stdClass;
|
$args = new stdClass;
|
||||||
$args->poll_srl = $poll_srl;
|
$args->poll_srl = $poll_srl;
|
||||||
|
|
@ -199,7 +211,7 @@ class pollModel extends poll
|
||||||
* Return the result after checking if the poll has responses
|
* Return the result after checking if the poll has responses
|
||||||
* @deprecated this function uses poll skin, which will be removed
|
* @deprecated this function uses poll skin, which will be removed
|
||||||
*/
|
*/
|
||||||
function getPollHtml($poll_srl, $style = '', $skin = 'default')
|
public function getPollHtml($poll_srl, $style = '', $skin = 'default')
|
||||||
{
|
{
|
||||||
$args = new stdClass;
|
$args = new stdClass;
|
||||||
$args->poll_srl = $poll_srl;
|
$args->poll_srl = $poll_srl;
|
||||||
|
|
@ -258,7 +270,7 @@ class pollModel extends poll
|
||||||
* @brief Return the result's HTML
|
* @brief Return the result's HTML
|
||||||
* @deprecated this function uses poll skin, which will be removed
|
* @deprecated this function uses poll skin, which will be removed
|
||||||
*/
|
*/
|
||||||
function getPollResultHtml($poll_srl, $skin = 'default')
|
public function getPollResultHtml($poll_srl, $skin = 'default')
|
||||||
{
|
{
|
||||||
$args = new stdClass;
|
$args = new stdClass;
|
||||||
$args->poll_srl = $poll_srl;
|
$args->poll_srl = $poll_srl;
|
||||||
|
|
@ -306,7 +318,7 @@ class pollModel extends poll
|
||||||
* @brief Selected poll - return the colorset of the skin
|
* @brief Selected poll - return the colorset of the skin
|
||||||
* @deprecated this function uses poll skin, which will be removed
|
* @deprecated this function uses poll skin, which will be removed
|
||||||
*/
|
*/
|
||||||
function getPollGetColorsetList()
|
public function getPollGetColorsetList()
|
||||||
{
|
{
|
||||||
$skin = Context::get('skin');
|
$skin = Context::get('skin');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,17 @@ class pollWidget extends WidgetHandler
|
||||||
*/
|
*/
|
||||||
function proc($args)
|
function proc($args)
|
||||||
{
|
{
|
||||||
|
$args->poll_srl = intval($args->poll_srl);
|
||||||
|
|
||||||
|
// Get the information related to the survey
|
||||||
|
$oPollModel = getModel('poll');
|
||||||
|
$poll_data = $oPollModel->_getPollinfo($args->poll_srl);
|
||||||
|
|
||||||
// Set a path of the template skin (values of skin, colorset settings)
|
// Set a path of the template skin (values of skin, colorset settings)
|
||||||
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
|
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
|
||||||
$tpl_file = 'pollview';
|
$tpl_file = 'pollview';
|
||||||
|
|
||||||
|
Context::set('poll_data', $poll_data);
|
||||||
Context::set('colorset', $args->colorset);
|
Context::set('colorset', $args->colorset);
|
||||||
Context::set('poll_srl', $args->poll_srl);
|
Context::set('poll_srl', $args->poll_srl);
|
||||||
Context::set('style', $args->style);
|
Context::set('style', $args->style);
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,25 @@
|
||||||
var poll_alert_lang = "{$lang->msg_check_poll_item}";
|
var poll_alert_lang = "{$lang->msg_check_poll_item}";
|
||||||
var poll_checkcount_lang = "{$lang->poll_checkcount}";
|
var poll_checkcount_lang = "{$lang->poll_checkcount}";
|
||||||
var poll_member_lang = "{$lang->poll_item_members}";
|
var poll_member_lang = "{$lang->poll_item_members}";
|
||||||
jQuery.exec_json("poll.getPollinfo", {/**/"poll_srl":{$poll_srl}/**/}, function(data){/**/
|
jQuery(document).ready(function(){
|
||||||
|
var data = {json_encode($poll_data)};
|
||||||
if(data.poll.is_polled==0) loadPoll({$poll_srl},data);
|
if(data.poll.is_polled==0) loadPoll({$poll_srl},data);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loadPollResult({$poll_srl},data);
|
loadPollResult({$poll_srl},data);
|
||||||
jQuery("#poll_{$poll_srl}_result_button").css({/**/
|
jQuery("#poll_{$poll_srl}_result_button").css({
|
||||||
display: "none"
|
display: "none"
|
||||||
/**/});
|
});
|
||||||
|
|
||||||
jQuery("#poll_{$poll_srl}_result_nobutton").css({/**/
|
jQuery("#poll_{$poll_srl}_result_nobutton").css({
|
||||||
display: "table-row"
|
display: "table-row"
|
||||||
/**/});
|
});
|
||||||
|
|
||||||
jQuery("#poll_{$poll_srl}_result_yesbutton").css({/**/
|
jQuery("#poll_{$poll_srl}_result_yesbutton").css({
|
||||||
display: "none"
|
display: "none"
|
||||||
/**/});
|
});
|
||||||
}
|
}
|
||||||
/**/});
|
});
|
||||||
</script>
|
</script>
|
||||||
<div style="{$style}">
|
<div style="{$style}">
|
||||||
<div id="poll_{$poll_srl}" class="pollWidget" style="display:none;">
|
<div id="poll_{$poll_srl}" class="pollWidget" style="display:none;">
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,25 @@
|
||||||
var poll_alert_lang = "{$lang->msg_check_poll_item}";
|
var poll_alert_lang = "{$lang->msg_check_poll_item}";
|
||||||
var poll_checkcount_lang = "{$lang->poll_checkcount}";
|
var poll_checkcount_lang = "{$lang->poll_checkcount}";
|
||||||
var poll_member_lang = "{$lang->poll_item_members}";
|
var poll_member_lang = "{$lang->poll_item_members}";
|
||||||
jQuery.exec_json("poll.getPollinfo", {/**/"poll_srl":{$poll_srl}/**/}, function(data){/**/
|
jQuery(document).ready(function(){
|
||||||
|
var data = {json_encode($poll_data)};
|
||||||
if(data.poll.is_polled==0) loadPoll({$poll_srl},data);
|
if(data.poll.is_polled==0) loadPoll({$poll_srl},data);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loadPollResult({$poll_srl},data);
|
loadPollResult({$poll_srl},data);
|
||||||
jQuery("#poll_{$poll_srl}_result_button").css({/**/
|
jQuery("#poll_{$poll_srl}_result_button").css({
|
||||||
display: "none"
|
display: "none"
|
||||||
/**/});
|
});
|
||||||
|
|
||||||
jQuery("#poll_{$poll_srl}_result_nobutton").css({/**/
|
jQuery("#poll_{$poll_srl}_result_nobutton").css({
|
||||||
display: "table-row"
|
display: "table-row"
|
||||||
/**/});
|
});
|
||||||
|
|
||||||
jQuery("#poll_{$poll_srl}_result_yesbutton").css({/**/
|
jQuery("#poll_{$poll_srl}_result_yesbutton").css({
|
||||||
display: "none"
|
display: "none"
|
||||||
/**/});
|
});
|
||||||
}
|
}
|
||||||
/**/});
|
});
|
||||||
</script>
|
</script>
|
||||||
<div style="{$style}">
|
<div style="{$style}">
|
||||||
<div id="poll_{$poll_srl}" class="pollWidget" style="display:none;">
|
<div id="poll_{$poll_srl}" class="pollWidget" style="display:none;">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue