PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/file/file.admin.view.php

http://xe-core.googlecode.com/
PHP | 225 lines | 179 code | 11 blank | 35 comment | 29 complexity | 6cad60b97923e91539e57ae40d1c04cc MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause
  1. <?php
  2. /**
  3. * Admin view of the module class file
  4. * @author NHN (developers@xpressengine.com)
  5. */
  6. class fileAdminView extends file
  7. {
  8. /**
  9. * Initialization
  10. * @return void
  11. */
  12. function init()
  13. {
  14. }
  15. /**
  16. * Display output list (for administrator)
  17. *
  18. * @return Object
  19. */
  20. function dispFileAdminList()
  21. {
  22. // Options to get a list
  23. $args = new stdClass();
  24. $args->page = Context::get('page'); // /< Page
  25. $args->list_count = 30; // /< Number of documents that appear on a single page
  26. $args->page_count = 10; // /< Number of pages that appear in the page navigation
  27. $args->sort_index = 'file_srl'; // /< Sorting values
  28. $args->isvalid = Context::get('isvalid');
  29. $args->module_srl = Context::get('module_srl');
  30. // Get a list
  31. $oFileAdminModel = &getAdminModel('file');
  32. $columnList = array('file_srl', 'upload_target_srl', 'upload_target_type', 'sid', 'module_srl'
  33. , 'source_filename', 'isvalid', 'file_size', 'download_count', 'files.regdate', 'ipaddress', 'member.member_srl', 'member.nick_name');
  34. $output = $oFileAdminModel->getFileList($args, $columnList);
  35. // Get the document for looping a list
  36. if($output->data)
  37. {
  38. $oCommentModel = &getModel('comment');
  39. $oDocumentModel = &getModel('document');
  40. $oModuleModel = &getModel('module');
  41. $file_list = array();
  42. $document_list = array();
  43. $comment_list = array();
  44. $module_list= array();
  45. $doc_srls = array();
  46. $com_srls = array();
  47. $mod_srls= array();
  48. foreach($output->data as $file)
  49. {
  50. $file_srl = $file->file_srl;
  51. $target_srl = $file->upload_target_srl;
  52. $file_update_args = new stdClass();
  53. $file_update_args->file_srl = $file_srl;
  54. // Find and update if upload_target_type doesn't exist
  55. if(!$file->upload_target_type)
  56. {
  57. // Pass if upload_target_type is already found
  58. if($document_list[$target_srl])
  59. {
  60. $file->upload_target_type = 'doc';
  61. }
  62. else if($comment_list[$target_srl])
  63. {
  64. $file->upload_target_type = 'com';
  65. }
  66. else if($module_list[$target_srl])
  67. {
  68. $file->upload_target_type = 'mod';
  69. }
  70. else
  71. {
  72. // document
  73. $document = $oDocumentModel->getDocument($target_srl);
  74. if($document->isExists())
  75. {
  76. $file->upload_target_type = 'doc';
  77. $file_update_args->upload_target_type = $file->upload_target_type;
  78. $document_list[$target_srl] = $document;
  79. }
  80. // comment
  81. if(!$file->upload_target_type)
  82. {
  83. $comment = $oCommentModel->getComment($target_srl);
  84. if($comment->isExists())
  85. {
  86. $file->upload_target_type = 'com';
  87. $file->target_document_srl = $comment->document_srl;
  88. $file_update_args->upload_target_type = $file->upload_target_type;
  89. $comment_list[$target_srl] = $comment;
  90. $doc_srls[] = $comment->document_srl;
  91. }
  92. }
  93. // module (for a page)
  94. if(!$file->upload_target_type)
  95. {
  96. $module = $oModuleModel->getModulesInfo($target_srl);
  97. if($module)
  98. {
  99. $file->upload_target_type = 'mod';
  100. $file_update_args->upload_target_type = $file->upload_target_type;
  101. $module_list[$module->comment_srl] = $module;
  102. }
  103. }
  104. if($file_update_args->upload_target_type)
  105. {
  106. executeQuery('file.updateFileTargetType', $file_update_args);
  107. }
  108. }
  109. // Check if data is already obtained
  110. for($i = 0; $i < $com_srls_count; ++$i)
  111. {
  112. if($comment_list[$com_srls[$i]]) delete($com_srls[$i]);
  113. }
  114. for($i = 0; $i < $doc_srls_count; ++$i)
  115. {
  116. if($document_list[$doc_srls[$i]]) delete($doc_srls[$i]);
  117. }
  118. for($i = 0; $i < $mod_srls_count; ++$i)
  119. {
  120. if($module_list[$mod_srls[$i]]) delete($mod_srls[$i]);
  121. }
  122. }
  123. if($file->upload_target_type)
  124. {
  125. if(!in_array($file->upload_target_srl, ${$file->upload_target_type.'_srls'}))
  126. {
  127. ${$file->upload_target_type.'_srls'}[] = $target_srl;
  128. }
  129. }
  130. $file_list[$file_srl] = $file;
  131. $mod_srls[] = $file->module_srl;
  132. }
  133. // Remove duplication
  134. $doc_srls = array_unique($doc_srls);
  135. $com_srls = array_unique($com_srls);
  136. $mod_srls = array_unique($mod_srls);
  137. // Comment list
  138. $com_srls_count = count($com_srls);
  139. if($com_srls_count)
  140. {
  141. $comment_output = $oCommentModel->getComments($com_srls);
  142. foreach($comment_output as $comment)
  143. {
  144. $comment_list[$comment->comment_srl] = $comment;
  145. $doc_srls[] = $comment->document_srl;
  146. }
  147. }
  148. // Document list
  149. $doc_srls_count = count($doc_srls);
  150. if($doc_srls_count)
  151. {
  152. $document_output = $oDocumentModel->getDocuments($doc_srls);
  153. if(is_array($document_output))
  154. {
  155. foreach($document_output as $document)
  156. {
  157. $document_list[$document->document_srl] = $document;
  158. }
  159. }
  160. }
  161. // Module List
  162. $mod_srls_count = count($mod_srls);
  163. if($mod_srls_count)
  164. {
  165. $columnList = array('module_srl', 'mid', 'browser_title');
  166. $module_output = $oModuleModel->getModulesInfo($mod_srls, $columnList);
  167. if($module_output && is_array($module_output))
  168. {
  169. foreach($module_output as $module)
  170. {
  171. $module_list[$module->module_srl] = $module;
  172. }
  173. }
  174. }
  175. foreach($file_list as $srl => $file)
  176. {
  177. if($file->upload_target_type == 'com')
  178. {
  179. $file_list[$srl]->target_document_srl = $comment_list[$file->upload_target_srl]->document_srl;
  180. }
  181. }
  182. }
  183. Context::set('file_list', $file_list);
  184. Context::set('document_list', $document_list);
  185. Context::set('comment_list', $comment_list);
  186. Context::set('module_list', $module_list);
  187. Context::set('total_count', $output->total_count);
  188. Context::set('total_page', $output->total_page);
  189. Context::set('page', $output->page);
  190. Context::set('page_navigation', $output->page_navigation);
  191. // Set a template
  192. $security = new Security();
  193. $security->encodeHTML('file_list..');
  194. $security->encodeHTML('module_list..');
  195. $this->setTemplatePath($this->module_path.'tpl');
  196. $this->setTemplateFile('file_list');
  197. }
  198. /**
  199. * Set attachment information (for administrator)
  200. *
  201. * @return Object
  202. */
  203. function dispFileAdminConfig()
  204. {
  205. $oFileModel = &getModel('file');
  206. $config = $oFileModel->getFileConfig();
  207. Context::set('config',$config);
  208. // Set a template file
  209. $this->setTemplatePath($this->module_path.'tpl');
  210. $this->setTemplateFile('adminConfig');
  211. }
  212. }
  213. /* End of file file.admin.view.php */
  214. /* Location: ./modules/file/file.admin.view.php */