From d94dc0d9a82faaf20e105e3d8770102c20a3498d Mon Sep 17 00:00:00 2001 From: zero Date: Fri, 30 Mar 2007 10:32:58 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@836 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/module/ModuleHandler.class.php | 2 +- classes/module/ModuleObject.class.php | 2 +- modules/board/board.controller.php | 55 ----------------------- modules/board/board.view.php | 8 ++-- modules/editor/editor.model.php | 39 ++++++++++++++++ modules/editor/editor.view.php | 35 --------------- modules/editor/tpl/editor.html | 2 +- modules/editor/tpl/js/uploader.js | 5 +-- modules/file/conf/module.xml | 3 +- modules/file/file.class.php | 6 ++- modules/file/file.controller.php | 61 ++++++++++++++++++++++++++ modules/page/page.view.php | 4 +- 12 files changed, 116 insertions(+), 106 deletions(-) diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index b428f451b..ec321c589 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -105,7 +105,7 @@ // 미설치시에는 act값을 강제로 변경 if($this->module=="install") { - if(!$xml_info->action->{$this->act}) $this->act = $xml_info->default_index_act; + if(!$this->act || !$xml_info->action->{$this->act}) $this->act = $xml_info->default_index_act; } // 현재 요청된 act가 있으면 $xml_info에서 type을 찾음, 없다면 기본 action을 이용 diff --git a/classes/module/ModuleObject.class.php b/classes/module/ModuleObject.class.php index 1b07eeaa8..747a65b88 100644 --- a/classes/module/ModuleObject.class.php +++ b/classes/module/ModuleObject.class.php @@ -266,7 +266,7 @@ $xml_info = $oModuleModel->getModuleActionXml($forward->module); $oModule->setAct($forward->act); $oModule->init(); - $oModule->setModuleInfo(null, $xml_info); + $oModule->setModuleInfo($this->module_info, $xml_info); $output = call_user_method($forward->act, $oModule); $this->setTemplatePath($oModule->getTemplatePath()); diff --git a/modules/board/board.controller.php b/modules/board/board.controller.php index c2b940e71..3a1d04782 100644 --- a/modules/board/board.controller.php +++ b/modules/board/board.controller.php @@ -221,61 +221,6 @@ } } - /** - * @brief 첨부파일 삭제 - * 에디터에서 개별 파일 삭제시 사용 - **/ - function procBoardDeleteFile() { - // 기본적으로 필요한 변수인 upload_target_srl, module_srl을 설정 - $upload_target_srl = Context::get('upload_target_srl'); - $module_srl = $this->module_srl; - $file_srl = Context::get('file_srl'); - - // file class의 controller 객체 생성 - $oFileController = &getController('file'); - if($file_srl) $output = $oFileController->deleteFile($file_srl, $this->grant->manager); - - // 첨부파일의 목록을 java script로 출력 - $oFileController->printUploadedFileList($upload_target_srl); - } - - /** - * @brief 첨부파일 업로드 - * - * editor에서는 upload_target_srl을 넘겨주고 게시판에서는 document_srl을 upload_target_srl로 설정해 놓은 상태이다. - **/ - function procBoardUploadFile() { - // 업로드 권한이 없거나 정보가 없을시 종료 - if(!Context::isUploaded() || !$this->grant->fileupload) exit(); - - // 기본적으로 필요한 변수 설정 - $upload_target_srl = Context::get('upload_target_srl'); - $module_srl = $this->module_srl; - - // file class의 controller 객체 생성 - $oFileController = &getController('file'); - $output = $oFileController->insertFile($module_srl, $upload_target_srl); - - // 첨부파일의 목록을 java script로 출력 - $oFileController->printUploadedFileList($upload_target_srl); - } - - /** - * @brief 첨부파일 다운로드 - * 직접 요청을 받음\n - * file_srl : 파일의 sequence\n - * sid : db에 저장된 비교 값, 틀리면 다운로드 하지 낳음\n - **/ - function procBoardDownloadFile() { - // 다운로드에 필요한 변수 체크 - $file_srl = Context::get('file_srl'); - $sid = Context::get('sid'); - - // document module 객체 생성후 해당 파일의 정보를 체크 - $oFileModel = &getModel('file'); - $oFileModel->procDownload($file_srl, $sid); - } - /** * @brief 권한 추가 **/ diff --git a/modules/board/board.view.php b/modules/board/board.view.php index f7e0f1191..06c144be4 100644 --- a/modules/board/board.view.php +++ b/modules/board/board.view.php @@ -192,8 +192,8 @@ Context::set('document', $document); // 에디터 모듈의 getEditor를 호출하여 세팅 - $oEditorView = &getView('editor'); - $editor = $oEditorView->getEditor($document_srl, $this->grant->fileupload, true); + $oEditorModel = &getModel('editor'); + $editor = $oEditorModel->getEditor($document_srl, $this->grant->fileupload, true); Context::set('editor', $editor); $this->setTemplateFile('write_form'); @@ -425,8 +425,8 @@ } // 에디터 모듈의 getEditor를 호출하여 세팅 - $oEditorView = &getView('editor'); - $comment_editor = $oEditorView->getEditor($comment_srl, $this->grant->fileupload); + $oEditorModel = &getModel('editor'); + $comment_editor = $oEditorModel->getEditor($comment_srl, $this->grant->fileupload); Context::set('comment_editor', $comment_editor); } diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 6eea07ee9..79841e916 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -7,6 +7,45 @@ class editorModel extends editor { + /** + * @brief 에디터를 return + **/ + function getEditor($upload_target_srl, $allow_fileupload = false, $enable_autosave = false) { + // 저장된 임시본이 있는지 검사 + if($enable_autosave) { + $saved_doc = $this->getSavedDoc($upload_target_srl); + Context::set('saved_doc', $saved_doc); + } + Context::set('enable_autosave', $enable_autosave); + + // 업로드를 위한 변수 설정 + Context::set('upload_target_srl', $upload_target_srl); + Context::set('allow_fileupload', $allow_fileupload); + + // 에디터 컴포넌트를 구함 + if(!Context::get('component_list')) { + $component_list = $this->getComponentList(); + Context::set('component_list', $component_list); + } + + // 템플릿을 미리 컴파일해서 컴파일된 소스를 return + $tpl_path = $this->module_path.'tpl'; + $tpl_file = 'editor.html'; + + // editor_path를 지정 + Context::set('editor_path', $tpl_path); + + // 만약 allow_fileupload == true 이면 upload_target_srl에 upload가능하다고 설정 + if($allow_fileupload) { + $oFileController = &getController('file'); + $oFileController->setUploadEnable($upload_target_srl); + } + require_once("./classes/template/TemplateHandler.class.php"); + $oTemplate = new TemplateHandler(); + return $oTemplate->compile($tpl_path, $tpl_file); + } + + /** * @brief 자동저장되어 있는 정보를 가져옴 **/ diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php index b9783f67f..3fc32a5e8 100644 --- a/modules/editor/editor.view.php +++ b/modules/editor/editor.view.php @@ -91,40 +91,5 @@ $this->setLayoutFile("popup_layout"); } - /** - * @brief 에디터를 return - **/ - function getEditor($upload_target_srl, $allow_fileupload = false, $enable_autosave = false) { - $oEditorModel = &getModel('editor'); - - // 저장된 임시본이 있는지 검사 - if($enable_autosave) { - $saved_doc = $oEditorModel->getSavedDoc($upload_target_srl); - Context::set('saved_doc', $saved_doc); - } - Context::set('enable_autosave', $enable_autosave); - - // 업로드를 위한 변수 설정 - Context::set('upload_target_srl', $upload_target_srl); - Context::set('allow_fileupload', $allow_fileupload); - - // 에디터 컴포넌트를 구함 - if(!Context::get('component_list')) { - $component_list = $oEditorModel->getComponentList(); - Context::set('component_list', $component_list); - } - - // 템플릿을 미리 컴파일해서 컴파일된 소스를 return - $tpl_path = $this->module_path.'tpl'; - $tpl_file = 'editor.html'; - - // editor_path를 지정 - Context::set('editor_path', $tpl_path); - - require_once("./classes/template/TemplateHandler.class.php"); - $oTemplate = new TemplateHandler(); - return $oTemplate->compile($tpl_path, $tpl_file); - } - } ?> diff --git a/modules/editor/tpl/editor.html b/modules/editor/tpl/editor.html index c9a498000..23f812108 100644 --- a/modules/editor/tpl/editor.html +++ b/modules/editor/tpl/editor.html @@ -102,7 +102,7 @@
- +
preview
diff --git a/modules/editor/tpl/js/uploader.js b/modules/editor/tpl/js/uploader.js index 28326a334..558b43662 100755 --- a/modules/editor/tpl/js/uploader.js +++ b/modules/editor/tpl/js/uploader.js @@ -60,9 +60,6 @@ function editor_upload_form_set(upload_target_srl) { if(fo_obj["document_srl"]) document_srl = fo_obj.document_srl.value; var url = "./?act=procFileDelete&upload_target_srl="+upload_target_srl; - if(module) url+="&module="+module; - if(mid) url+="&mid="+mid; - if(document_srl) url+="&document_srl="+document_srl; // iframe에 url을 보내버림 var iframe_obj = xGetElementById('tmp_upload_iframe'); @@ -159,7 +156,7 @@ function editor_remove_file(upload_target_srl) { while(fo_obj.nodeName != 'FORM') { fo_obj = fo_obj.parentNode; } var mid = fo_obj.mid.value; var upload_target_srl = fo_obj.upload_target_srl.value; - var url = "./?mid="+mid+"&act=procFileDelete&upload_target_srl="+upload_target_srl+"&file_srl="+file_srl; + var url = "./?act=procFileDelete&upload_target_srl="+upload_target_srl+"&file_srl="+file_srl; // iframe에 url을 보내버림 var iframe_obj = xGetElementById('tmp_upload_iframe'); diff --git a/modules/file/conf/module.xml b/modules/file/conf/module.xml index a3a195beb..bedb14258 100644 --- a/modules/file/conf/module.xml +++ b/modules/file/conf/module.xml @@ -4,8 +4,9 @@ - + + diff --git a/modules/file/file.class.php b/modules/file/file.class.php index 935760dbb..569ce386f 100644 --- a/modules/file/file.class.php +++ b/modules/file/file.class.php @@ -14,8 +14,10 @@ // action forward에 등록 (관리자 모드에서 사용하기 위함) $oModuleController = &getController('module'); $oModuleController->insertActionForward('file', 'view', 'dispFileAdminList'); - $oModuleController->insertActionForward('file', 'controller', 'dispFileDownload'); - $oModuleController->insertActionForward('file', 'controller', 'dispFileAdminDeleteChecked'); + $oModuleController->insertActionForward('file', 'controller', 'procFileUpload'); + $oModuleController->insertActionForward('file', 'controller', 'procFileDelete'); + $oModuleController->insertActionForward('file', 'controller', 'procFileDownload'); + $oModuleController->insertActionForward('file', 'controller', 'procFileAdminDeleteChecked'); // file 모듈에서 사용할 디렉토리 생성 FileHandler::makeDir('./files/attach/images'); diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php index 3fdfb8d4c..dfb3c6bd9 100644 --- a/modules/file/file.controller.php +++ b/modules/file/file.controller.php @@ -13,6 +13,67 @@ function init() { } + /** + * @brief 에디터에서 첨부파일 업로드 + **/ + function procFileUpload() { + // 기본적으로 필요한 변수 설정 + $upload_target_srl = Context::get('upload_target_srl'); + $module_srl = $this->module_srl; + debugPrint($module_srl); + + // 업로드 권한이 없거나 정보가 없을시 종료 + if(!$_SESSION['upload_enable'][$upload_target_srl]) exit(); + + $output = $this->insertFile($module_srl, $upload_target_srl); + debugPrint($output); + + // 첨부파일의 목록을 java script로 출력 + $this->printUploadedFileList($upload_target_srl); + } + + + /** + * @brief 에디터에서 첨부 파일 삭제 + **/ + function procFileDelete() { + // 기본적으로 필요한 변수인 upload_target_srl, module_srl을 설정 + $upload_target_srl = Context::get('upload_target_srl'); + $file_srl = Context::get('file_srl'); + if(!$file_srl) exit(); + + // 업로드 권한이 없거나 정보가 없을시 종료 + if(!$_SESSION['upload_enable'][$upload_target_srl]) exit(); + + $output = $this->deleteFile($file_srl, $this->grant->manager); + + // 첨부파일의 목록을 java script로 출력 + $this->printUploadedFileList($upload_target_srl); + } + + /** + * @brief 첨부파일 다운로드 + * 직접 요청을 받음 + * file_srl : 파일의 sequence + * sid : db에 저장된 비교 값, 틀리면 다운로드 하지 낳음 + **/ + function procFileDownload() { + // 다운로드에 필요한 변수 체크 + $file_srl = Context::get('file_srl'); + $sid = Context::get('sid'); + + // document module 객체 생성후 해당 파일의 정보를 체크 + $oFileModel = &getModel('file'); + $oFileModel->procDownload($file_srl, $sid); + } + + /** + * @brief 업로드 가능하다고 세팅 + **/ + function setUploadEnable($upload_target_srl) { + $_SESSION['upload_enable'][$upload_target_srl] = true; + } + /** * @brief 첨부파일 추가 **/ diff --git a/modules/page/page.view.php b/modules/page/page.view.php index 19ac683d1..53377c1ef 100644 --- a/modules/page/page.view.php +++ b/modules/page/page.view.php @@ -169,8 +169,8 @@ Context::set('plugin_list', $plugin_list); // 에디터 모듈의 getEditor를 호출하여 세팅 - $oEditorView = &getView('editor'); - $editor = $oEditorView->getEditor($module_srl, true); + $oEditorModel = &getModel('editor'); + $editor = $oEditorModel->getEditor($module_srl, true); Context::set('editor', $editor); // 템플릿 파일 지정