XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
file.admin.view.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
7 class fileAdminView extends file
8 {
13  function init()
14  {
15  }
16 
22  function dispFileAdminList()
23  {
24  // Options to get a list
25  $args = new stdClass();
26  $args->page = Context::get('page'); // /< Page
27  $args->list_count = 30; // /< Number of documents that appear on a single page
28  $args->page_count = 10; // /< Number of pages that appear in the page navigation
29 
30  $args->sort_index = 'file_srl'; // /< Sorting values
31  $args->isvalid = Context::get('isvalid');
32  $args->module_srl = Context::get('module_srl');
33  // Get a list
34  $oFileAdminModel = getAdminModel('file');
35  $columnList = array('file_srl', 'upload_target_srl', 'upload_target_type', 'sid', 'module_srl'
36  , 'source_filename', 'isvalid', 'file_size', 'download_count', 'files.regdate', 'ipaddress', 'member.member_srl', 'member.nick_name', 'uploaded_filename');
37  $output = $oFileAdminModel->getFileList($args, $columnList);
38  // Get the document for looping a list
39  if($output->data)
40  {
41  $oCommentModel = getModel('comment');
42  $oDocumentModel = getModel('document');
43  $oModuleModel = getModel('module');
44 
45  $file_list = array();
46  $document_list = array();
47  $comment_list = array();
48  $module_list= array();
49 
50  $doc_srls = array();
51  $com_srls = array();
52  $mod_srls= array();
53 
54  foreach($output->data as $file)
55  {
56  $file_srl = $file->file_srl;
57  $target_srl = $file->upload_target_srl;
58  $file_update_args = new stdClass();
59  $file_update_args->file_srl = $file_srl;
60  // Find and update if upload_target_type doesn't exist
61  if(!$file->upload_target_type)
62  {
63  // Pass if upload_target_type is already found
64  if($document_list[$target_srl])
65  {
66  $file->upload_target_type = 'doc';
67  }
68  else if($comment_list[$target_srl])
69  {
70  $file->upload_target_type = 'com';
71  }
72  else if($module_list[$target_srl])
73  {
74  $file->upload_target_type = 'mod';
75  }
76  else
77  {
78  // document
79  $document = $oDocumentModel->getDocument($target_srl);
80  if($document->isExists())
81  {
82  $file->upload_target_type = 'doc';
83  $file_update_args->upload_target_type = $file->upload_target_type;
84  $document_list[$target_srl] = $document;
85  }
86  // comment
87  if(!$file->upload_target_type)
88  {
89  $comment = $oCommentModel->getComment($target_srl);
90  if($comment->isExists())
91  {
92  $file->upload_target_type = 'com';
93  $file->target_document_srl = $comment->document_srl;
94  $file_update_args->upload_target_type = $file->upload_target_type;
95  $comment_list[$target_srl] = $comment;
96  $doc_srls[] = $comment->document_srl;
97  }
98  }
99  // module (for a page)
100  if(!$file->upload_target_type)
101  {
102  $module = $oModuleModel->getModulesInfo($target_srl);
103  if($module)
104  {
105  $file->upload_target_type = 'mod';
106  $file_update_args->upload_target_type = $file->upload_target_type;
107  $module_list[$module->comment_srl] = $module;
108  }
109  }
110  if($file_update_args->upload_target_type)
111  {
112  executeQuery('file.updateFileTargetType', $file_update_args);
113  }
114  }
115  // Check if data is already obtained
116  for($i = 0; $i < $com_srls_count; ++$i)
117  {
118  if($comment_list[$com_srls[$i]]) delete($com_srls[$i]);
119  }
120  for($i = 0; $i < $doc_srls_count; ++$i)
121  {
122  if($document_list[$doc_srls[$i]]) delete($doc_srls[$i]);
123  }
124  for($i = 0; $i < $mod_srls_count; ++$i)
125  {
126  if($module_list[$mod_srls[$i]]) delete($mod_srls[$i]);
127  }
128  }
129 
130  if($file->upload_target_type)
131  {
132  if(!in_array($file->upload_target_srl, ${$file->upload_target_type.'_srls'}))
133  {
134  ${$file->upload_target_type.'_srls'}[] = $target_srl;
135  }
136  }
137 
138  $file_list[$file_srl] = $file;
139  $mod_srls[] = $file->module_srl;
140  }
141  // Remove duplication
142  $doc_srls = array_unique($doc_srls);
143  $com_srls = array_unique($com_srls);
144  $mod_srls = array_unique($mod_srls);
145  // Comment list
146  $com_srls_count = count($com_srls);
147  if($com_srls_count)
148  {
149  $comment_output = $oCommentModel->getComments($com_srls);
150  foreach($comment_output as $comment)
151  {
152  $comment_list[$comment->comment_srl] = $comment;
153  $doc_srls[] = $comment->document_srl;
154  }
155  }
156  // Document list
157  $doc_srls_count = count($doc_srls);
158  if($doc_srls_count)
159  {
160  $document_output = $oDocumentModel->getDocuments($doc_srls);
161  if(is_array($document_output))
162  {
163  foreach($document_output as $document)
164  {
165  $document_list[$document->document_srl] = $document;
166  }
167  }
168  }
169  // Module List
170  $mod_srls_count = count($mod_srls);
171  if($mod_srls_count)
172  {
173  $columnList = array('module_srl', 'mid', 'browser_title');
174  $module_output = $oModuleModel->getModulesInfo($mod_srls, $columnList);
175  if($module_output && is_array($module_output))
176  {
177  foreach($module_output as $module)
178  {
179  $module_list[$module->module_srl] = $module;
180  }
181  }
182  }
183 
184  foreach($file_list as $srl => $file)
185  {
186  if($file->upload_target_type == 'com')
187  {
188  $file_list[$srl]->target_document_srl = $comment_list[$file->upload_target_srl]->document_srl;
189  }
190  }
191  }
192 
193  Context::set('file_list', $file_list);
194  Context::set('document_list', $document_list);
195  Context::set('comment_list', $comment_list);
196  Context::set('module_list', $module_list);
197  Context::set('total_count', $output->total_count);
198  Context::set('total_page', $output->total_page);
199  Context::set('page', $output->page);
200  Context::set('page_navigation', $output->page_navigation);
201  // Set a template
202  $security = new Security();
203  $security->encodeHTML('file_list..');
204  $security->encodeHTML('module_list..');
205  $security->encodeHTML('search_target', 'search_keyword');
206 
207  $this->setTemplatePath($this->module_path.'tpl');
208  $this->setTemplateFile('file_list');
209  }
210 
217  {
218  $oFileModel = getModel('file');
219  $config = $oFileModel->getFileConfig();
220  Context::set('config',$config);
221  $iniPostMaxSize = FileHandler::returnbytes(ini_get('post_max_size'));
222  $iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize'));
223  $iniMinSize = min($iniPostMaxSize, $iniUploadMaxSize);
224  Context::set('upload_max_filesize', FileHandler::filesize($iniMinSize));
225  // Set a template file
226  $this->setTemplatePath($this->module_path.'tpl');
227  $this->setTemplateFile('adminConfig');
228  }
229 }
230 /* End of file file.admin.view.php */
231 /* Location: ./modules/file/file.admin.view.php */
setTemplateFile($filename)
$oModuleModel
Definition: ko.install.php:236
$output
Definition: ko.install.php:193
set($key, $val, $set_to_get_vars=0)
$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
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:203
$module
Class name of Xe Module that is identified by mid.