From 99c88fee14a6bd8b4e3f627fe95f5a2267ac20a8 Mon Sep 17 00:00:00 2001 From: zero Date: Wed, 21 Feb 2007 08:56:19 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@145 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/module/ModuleHandler.class.php | 13 ++++++-- classes/module/ModuleObject.class.php | 44 +++++++++++++++++++++----- common/lang/ko.lang.php | 1 + modules/admin/conf/module.xml | 2 +- modules/board/conf/module.xml | 2 +- modules/install/conf/module.xml | 2 +- modules/install/install.controller.php | 2 ++ modules/install/install.view.php | 3 ++ modules/member/conf/module.xml | 2 +- modules/message/message.view.php | 2 +- modules/module/conf/module.xml | 2 +- modules/module/module.model.php | 1 + 12 files changed, 60 insertions(+), 16 deletions(-) diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 85b0c6e6b..eee74c1cf 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -68,6 +68,13 @@ // 해당 모듈의 conf/action.xml 을 분석하여 action 정보를 얻어옴 $xml_info = $oModuleModel->getModuleXmlInfo($module); + // module_info가 없고(mid가 없다는 의미) standalone이 false이면 오류 표시 + if(!$module_info&&!$xml_info->standalone) { + $module = 'message'; + Context::set('message', Context::getLang('msg_invalid_request_module')); + $xml_info = $oModuleModel->getModuleXmlInfo($module); + } + // 현재 요청된 act가 있으면 $xml_info에서 type을 찾음, 없다면 기본 action을 이용 if(!$act || !$xml_info->action->{$act}) $act = $xml_info->default_action; @@ -83,14 +90,15 @@ // 모듈 객체 생성 $oModule = &$this->getModuleInstance($module, $type); + // 모듈에 act값을 세팅 + $oModule->setAct($act); // 모듈 정보 세팅 $oModule->setModuleInfo($module_info, $xml_info); if(!is_object($oModule)) return; - $act = Context::get('act'); - $oModule->proc($act); + $oModule->proc(); $this->oModule = $oModule; } @@ -160,6 +168,7 @@ // 생성된 객체에 자신이 호출된 위치를 세팅해줌 $oModule->setModulePath($class_path); + $oModule->init(); // GLOBALS 변수에 생성된 객체 저장 $GLOBALS['_loaded_module'][$module][$type] = $oModule; diff --git a/classes/module/ModuleObject.class.php b/classes/module/ModuleObject.class.php index 18fc4b04a..2e5b812aa 100644 --- a/classes/module/ModuleObject.class.php +++ b/classes/module/ModuleObject.class.php @@ -3,9 +3,6 @@ * @class ModuleObject * @author zero (zero@nzeo.com) * @brief module의 abstract class - * - * @todo 모듈에서 mid가 꼭 필요한지를 체크하는 단계가 필요 (admin은 mid불필요, board는 필요.., 미설정시 필요함으로.. 기본) - * **/ class ModuleObject extends Object { @@ -25,6 +22,8 @@ var $layout_path = './common/tpl/'; ///< 레이아웃 경로 var $layout_file = 'default_layout.html'; ///< 레이아웃 파일 + var $stop_proc = false; ///< action 수행중 dispMessage를 호출하면 ModuleObject::proc()를 수행하지 않음 + /** * @brief 현재 모듈의 path를 지정 **/ @@ -42,6 +41,13 @@ $this->add('redirect_url', $url); } + /** + * @brief act값 지정 + **/ + function setAct($act) { + $this->act = $act; + } + /** * @brief 모듈의 정보 세팅 **/ @@ -110,6 +116,26 @@ $this->init(); } + /** + * @brief 메세지 출력 + **/ + function dispMessage($msg_code) { + // proc 수행을 중지 시키기 위한 플래그 세팅 + $this->stop_proc = true; + + // RequestMethod가 XMLRPC일 경우를 대비 + if(Context::getRequestMethod()=='XMLRPC') { + $this->setError(-1); + $this->setMessage($msg_code); + } else { + Context::set('message', Context::getLang($msg_code)); + $oMessageView = &getView('message'); + $oMessageView->dispMessage(); + $this->setTemplatePath($oMessageView->getTemplatePath()); + $this->setTemplateFile($oMessageView->getTemplateFile()); + } + } + /** * @brief template 파일 지정 **/ @@ -129,8 +155,8 @@ * @brief template 경로 지정 **/ function setTemplatePath($path) { - if(substr($path,-1)!='/') $path .= '/'; if(substr($path,0,2)!='./') $path = './'.$path; + if(substr($path,-1)!='/') $path .= '/'; $this->template_path = $path; } @@ -178,13 +204,15 @@ * * $act값에 의해서 $action_list에 선언된 것들을 실행한다 **/ - function proc($act) { + function proc() { + // stop_proc==true이면 그냥 패스 + if($this->stop_proc==true) return; // 기본 act조차 없으면 return - if(!method_exists($this, $act)) return false; + if(!method_exists($this, $this->act)) return; - // act값으로 method 실행 - $output = call_user_method($act, $this); + // this->act값으로 method 실행 + $output = call_user_method($this->act, $this); if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) { $this->setError($output->getError()); diff --git a/common/lang/ko.lang.php b/common/lang/ko.lang.php index 887716b4e..8e407cee4 100644 --- a/common/lang/ko.lang.php +++ b/common/lang/ko.lang.php @@ -109,6 +109,7 @@ $lang->msg_call_server = '서버에 요청중입니다. 잠시만 기다려주세요.'; $lang->msg_db_not_setted = 'DB설정이 되어 있지 않습니다'; $lang->msg_mid_not_exists = '설정이 되어 있지 않습니다. 관리자 페이지에서 기본 설정을 해주시기 바랍니다.'; + $lang->msg_invalid_request_module = '잘못된 모듈 요청입니다'; $lang->msg_invalid_queryid = 'Query ID값이 잘못 지정되었습니다'; $lang->msg_not_permitted = '권한이 없습니다'; $lang->msg_input_password = '비밀번호를 입력하여 주세요'; diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml index 57e621d00..fd91b1ac5 100644 --- a/modules/admin/conf/module.xml +++ b/modules/admin/conf/module.xml @@ -1,5 +1,5 @@ - + diff --git a/modules/board/conf/module.xml b/modules/board/conf/module.xml index 16d71dad8..2ae890d26 100644 --- a/modules/board/conf/module.xml +++ b/modules/board/conf/module.xml @@ -1,5 +1,5 @@ - + 목록 diff --git a/modules/install/conf/module.xml b/modules/install/conf/module.xml index ce0cd7e5a..4bd769dc1 100644 --- a/modules/install/conf/module.xml +++ b/modules/install/conf/module.xml @@ -1,5 +1,5 @@ - + diff --git a/modules/install/install.controller.php b/modules/install/install.controller.php index 469bd15c7..68c493b0d 100644 --- a/modules/install/install.controller.php +++ b/modules/install/install.controller.php @@ -12,6 +12,8 @@ * @brief 초기화 **/ function init() { + // 설치가 되어 있으면 오류 + if(Context::isInstalled()) return $this->dispMessage('msg_already_installed'); } /** diff --git a/modules/install/install.view.php b/modules/install/install.view.php index e4714b973..7d3ef0892 100644 --- a/modules/install/install.view.php +++ b/modules/install/install.view.php @@ -14,6 +14,9 @@ // template 경로를 지정 $this->setTemplatePath($this->module_path."tpl"); + // 설치가 되어 있으면 오류 + if(Context::isInstalled()) return $this->dispMessage('msg_already_installed'); + // 컨트롤러 생성 $oController = &getController('install'); diff --git a/modules/member/conf/module.xml b/modules/member/conf/module.xml index c911dbeeb..5c14b4f78 100644 --- a/modules/member/conf/module.xml +++ b/modules/member/conf/module.xml @@ -1,5 +1,5 @@ - + diff --git a/modules/message/message.view.php b/modules/message/message.view.php index a11ac6d9f..5561548f4 100644 --- a/modules/message/message.view.php +++ b/modules/message/message.view.php @@ -11,7 +11,7 @@ * @brief 초기화 **/ function init() { - $this->setTemplatePath( + $this->setTemplatePath($this->module_path.'tpl'); } /** diff --git a/modules/module/conf/module.xml b/modules/module/conf/module.xml index 215aaddbb..ddf65f705 100644 --- a/modules/module/conf/module.xml +++ b/modules/module/conf/module.xml @@ -1,5 +1,5 @@ - + diff --git a/modules/module/module.model.php b/modules/module/module.model.php index 6a1e66b33..e70de9e17 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -26,6 +26,7 @@ $xml_obj = XmlParser::loadXmlFile($xml_file); if(!count($xml_obj->module)) return; + $output->standalone = $xml_obj->module->attrs->standalone=='true'?true:false; ///< 모듈 자체적으로 실행이 가능한지에 대한 값 (기본=false) $output->default_action = $xml_obj->module->attrs->default_action; ///< 별도의 action이 지정되지 않으면 호출될 action $output->management_action = $xml_obj->module->attrs->management_action; ///< 관리자용으로 사용될 기본 action