XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
poll.model.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class pollModel extends poll
9 {
13  function init()
14  {
15  }
16 
20  function isPolled($poll_srl)
21  {
22  $args = new stdClass;
23  $args->poll_srl = $poll_srl;
24 
25  if(Context::get('is_logged'))
26  {
27  $logged_info = Context::get('logged_info');
28  $args->member_srl = $logged_info->member_srl;
29  }
30  else
31  {
32  $args->ipaddress = $_SERVER['REMOTE_ADDR'];
33  }
34  $output = executeQuery('poll.getPollLog', $args);
35  if($output->data->count) return true;
36  return false;
37  }
38 
43  function getPollHtml($poll_srl, $style = '', $skin = 'default')
44  {
45  $args = new stdClass;
46  $args->poll_srl = $poll_srl;
47  // Get the information related to the survey
48  $columnList = array('poll_count', 'stop_date');
49  $output = executeQuery('poll.getPoll', $args, $columnList);
50  if(!$output->data) return '';
51 
52  $poll = new stdClass;
53  $poll->style = $style;
54  $poll->poll_count = (int)$output->data->poll_count;
55  $poll->stop_date = $output->data->stop_date;
56 
57  $columnList = array('poll_index_srl', 'title', 'checkcount', 'poll_count');
58  $output = executeQuery('poll.getPollTitle', $args, $columnList);
59  if(!$output->data) return;
60  if(!is_array($output->data)) $output->data = array($output->data);
61 
62  $poll->poll = array();
63  foreach($output->data as $key => $val)
64  {
65  $poll->poll[$val->poll_index_srl] = new stdClass;
66  $poll->poll[$val->poll_index_srl]->title = $val->title;
67  $poll->poll[$val->poll_index_srl]->checkcount = $val->checkcount;
68  $poll->poll[$val->poll_index_srl]->poll_count = $val->poll_count;
69  }
70 
71  $output = executeQuery('poll.getPollItem', $args);
72  foreach($output->data as $key => $val)
73  {
74  $poll->poll[$val->poll_index_srl]->item[] = $val;
75  }
76 
77  $poll->poll_srl = $poll_srl;
78  // Only ongoing poll results
79  if($poll->stop_date >= date("Ymd"))
80  {
81  if($this->isPolled($poll_srl)) $tpl_file = "result";
82  else $tpl_file = "form";
83  }
84  else
85  {
86  $tpl_file = "result";
87  }
88 
89  Context::set('poll',$poll);
90  Context::set('skin',$skin);
91  // The skin for the default configurations, and the colorset configurations
92  $tpl_path = sprintf("%sskins/%s/", $this->module_path, $skin);
93 
94  $oTemplate = &TemplateHandler::getInstance();
95  return $oTemplate->compile($tpl_path, $tpl_file);
96  }
97 
101  function getPollResultHtml($poll_srl, $skin = 'default')
102  {
103  $args = new stdClass;
104  $args->poll_srl = $poll_srl;
105  // Get the information related to the survey
106  $output = executeQuery('poll.getPoll', $args);
107  if(!$output->data) return '';
108 
109  $poll = new stdClass;
110  $poll->style = $style;
111  $poll->poll_count = (int)$output->data->poll_count;
112  $poll->stop_date = $output->data->stop_date;
113 
114  $columnList = array('poll_index_srl', 'title', 'checkcount', 'poll_count');
115  $output = executeQuery('poll.getPollTitle', $args, $columnList);
116  if(!$output->data) return;
117  if(!is_array($output->data)) $output->data = array($output->data);
118 
119  $poll->poll = array();
120  foreach($output->data as $key => $val)
121  {
122  $poll->poll[$val->poll_index_srl] = new stdClass;
123  $poll->poll[$val->poll_index_srl]->title = $val->title;
124  $poll->poll[$val->poll_index_srl]->checkcount = $val->checkcount;
125  $poll->poll[$val->poll_index_srl]->poll_count = $val->poll_count;
126  }
127 
128  $output = executeQuery('poll.getPollItem', $args);
129  foreach($output->data as $key => $val)
130  {
131  $poll->poll[$val->poll_index_srl]->item[] = $val;
132  }
133 
134  $poll->poll_srl = $poll_srl;
135 
136  $tpl_file = "result";
137 
138  Context::set('poll',$poll);
139  // The skin for the default configurations, and the colorset configurations
140  $tpl_path = sprintf("%sskins/%s/", $this->module_path, $skin);
141 
142  $oTemplate = &TemplateHandler::getInstance();
143  return $oTemplate->compile($tpl_path, $tpl_file);
144  }
149  {
150  $skin = Context::get('skin');
151 
152  $oModuleModel = getModel('module');
153  $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $skin);
154 
155  for($i=0;$i<count($skin_info->colorset);$i++)
156  {
157  $colorset = sprintf('%s|@|%s', $skin_info->colorset[$i]->name, $skin_info->colorset[$i]->title);
158  $colorset_list[] = $colorset;
159  }
160 
161  if(count($colorset_list)) $colorsets = implode("\n", $colorset_list);
162  $this->add('colorset_list', $colorsets);
163  }
164 }
165 /* End of file poll.model.php */
166 /* Location: ./modules/poll/poll.model.php */
$oModuleModel
Definition: ko.install.php:236
getPollHtml($poll_srl, $style= '', $skin= 'default')
Return the HTML data of the survey Return the result after checking if the poll has responses...
Definition: poll.model.php:43
$output
Definition: ko.install.php:193
add($key, $val)
The model class for the poll modules.
Definition: poll.model.php:8
getPollGetColorsetList()
Selected poll - return the colorset of the skin.
Definition: poll.model.php:148
set($key, $val, $set_to_get_vars=0)
$args
Definition: ko.install.php:185
init()
Initialization.
Definition: poll.model.php:13
isPolled($poll_srl)
The function examines if the user has already been polled.
Definition: poll.model.php:20
getModel($module_name)
Definition: func.inc.php:145
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:203
The parent class of the poll module.
Definition: poll.class.php:8
getPollResultHtml($poll_srl, $skin= 'default')
Return the result&#39;s HTML.
Definition: poll.model.php:101