XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
poll.admin.view.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class pollAdminView extends poll
9 {
13  function init()
14  {
15  }
16 
20  function dispPollAdminList()
21  {
22  // Arrange the search options
23  $search_target = trim(Context::get('search_target'));
24  $search_keyword = trim(Context::get('search_keyword'));
25 
26  $args = new stdClass();
27  if($search_target && $search_keyword)
28  {
29  switch($search_target)
30  {
31  case 'title' :
32  if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
33  $args->s_title= $search_keyword;
34  break;
35  case 'regdate' :
36  $args->s_regdate = $search_keyword;
37  break;
38  case 'ipaddress' :
39  $args->s_ipaddress= $search_keyword;
40  break;
41  }
42  }
43  // Options to get a list of pages
44  $args->page = Context::get('page');
45  $args->list_count = 50; // The number of posts to show on one page
46  $args->page_count = 10; // The number of pages to display in the page navigation
47 
48  $args->sort_index = 'P.list_order'; // Sorting value
49 
50  // Get the list
51  $oPollAdminModel = getAdminModel('poll');
52  $output = $oPollAdminModel->getPollListWithMember($args);
53 
54  // check poll type. document or comment
55  if(is_array($output->data))
56  {
57  $uploadTargetSrlList = array();
58  foreach($output->data as $value)
59  {
60  $uploadTargetSrlList[] = $value->upload_target_srl;
61  }
62 
63  $oDocumentModel = getModel('document');
64  $targetDocumentOutput = $oDocumentModel->getDocuments($uploadTargetSrlList);
65  if(!is_array($targetDocumentOutput)) $targetDocumentOutput = array();
66 
67  $oCommentModel = getModel('comment');
68  $columnList = array('comment_srl', 'document_srl');
69  $targetCommentOutput = $oCommentModel->getComments($uploadTargetSrlList, $columnList);
70  if(!is_array($targetCommentOutput)) $targetCommentOutput = array();
71 
72  foreach($output->data as $value)
73  {
74  if(array_key_exists($value->upload_target_srl, $targetDocumentOutput))
75  $value->document_srl = $value->upload_target_srl;
76 
77  if(array_key_exists($value->upload_target_srl, $targetCommentOutput))
78  {
79  $value->comment_srl = $value->upload_target_srl;
80  $value->document_srl = $targetCommentOutput[$value->comment_srl]->document_srl;
81  }
82  }
83  }
84 
85  // Configure the template variables
86  Context::set('total_count', $output->total_count);
87  Context::set('total_page', $output->total_page);
88  Context::set('page', $output->page);
89  Context::set('poll_list', $output->data);
90  Context::set('page_navigation', $output->page_navigation);
91  Context::set('module_list', $module_list);
92 
93  $security = new Security();
94  $security->encodeHTML('poll_list..title', 'poll_list..nick_name');
95  $security->encodeHTML('search_target', 'search_keyword');
96 
97  // Set a template
98  $this->setTemplatePath($this->module_path.'tpl');
99  $this->setTemplateFile('poll_list');
100  }
101 
106  {
107  $oModuleModel = getModel('module');
108  // Get the configuration information
109  $config = $oModuleModel->getModuleConfig('poll');
110  Context::set('config', $config);
111  // Get the skin information
112  $skin_list = $oModuleModel->getSkins($this->module_path);
113  Context::set('skin_list', $skin_list);
114 
115  if(!$skin_list[$config->skin]) $config->skin = "default";
116  // Set the skin colorset once the configurations is completed
117  Context::set('colorset_list', $skin_list[$config->skin]->colorset);
118 
119  $security = new Security();
120  $security->encodeHTML('config..');
121  $security->encodeHTML('skin_list..title');
122  $security->encodeHTML('colorset_list..name','colorset_list..title');
123 
124  // Set a template
125  $this->setTemplatePath($this->module_path.'tpl');
126  $this->setTemplateFile('config');
127  }
128 
133  {
134  // Popup layout
135  $this->setLayoutFile("popup_layout");
136  // Draw results
137  $args = new stdClass();
138  $args->poll_srl = Context::get('poll_srl');
139  $args->poll_index_srl = Context::get('poll_index_srl');
140 
141  $output = executeQuery('poll.getPoll', $args);
142  if(!$output->data) return $this->stop('msg_poll_not_exists');
143 
144  $poll = new stdClass();
145  $poll->stop_date = $output->data->stop_date;
146  $poll->poll_count = $output->data->poll_count;
147 
148  $output = executeQuery('poll.getPollTitle', $args);
149  if(!$output->data)
150  {
151  return $this->stop('msg_poll_not_exists');
152  }
153 
154  $tmp = &$poll->poll[$args->poll_index_srl];
155  $tmp->title = $output->data->title;
156  $tmp->checkcount = $output->data->checkcount;
157  $tmp->poll_count = $output->data->poll_count;
158 
159  $output = executeQuery('poll.getPollItem', $args);
160  foreach($output->data as $val)
161  {
162  $tmp->item[] = $val;
163  }
164 
165  $poll->poll_srl = $poll_srl;
166 
167  Context::set('poll',$poll);
168  // Configure the skin and the colorset for the default configuration
169  $oModuleModel = getModel('module');
170  $poll_config = $oModuleModel->getModuleConfig('poll');
171  Context::set('poll_config', $poll_config);
172 
173  $this->setTemplatePath($this->module_path.'tpl');
174  $this->setTemplateFile('result');
175  }
176 }
177 /* End of file poll.admin.view.php */
178 /* Location: ./modules/poll/poll.admin.view.php */
setTemplateFile($filename)
$oModuleModel
Definition: ko.install.php:236
$output
Definition: ko.install.php:193
setLayoutFile($filename)
set($key, $val, $set_to_get_vars=0)
init()
Initialization.
The admin view class of the poll module.
dispPollAdminResult()
Poll Results.
dispPollAdminList()
Administrator&#39;s Page.
$args
Definition: ko.install.php:185
getAdminModel($module_name)
Definition: func.inc.php:156
$oDocumentModel
Definition: ko.install.php:259
getModel($module_name)
Definition: func.inc.php:145
dispPollAdminConfig()
Confgure the poll skin and colorset.
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