git-svn-id: http://xe-core.googlecode.com/svn/trunk@153 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-02-22 03:06:50 +00:00
parent 693103aaa0
commit 17c29c6957
15 changed files with 108 additions and 107 deletions

View file

@ -244,6 +244,7 @@
* 만약 code에 해당하는 문자열이 없다면 code를 그대로 리턴
**/
function getLang($code) {
if(!$code) return;
if($GLOBALS['lang']->{$code}) return $GLOBALS['lang']->{$code};
return $code;
}

View file

@ -19,12 +19,6 @@
**/
function printContent(&$oModule) {
// 모듈이 정상적이지 않으면 system message 출력
if(!is_object($oModule)) {
$oModule = &getView('message');
Context::set('system_message', Context::getLang('msg_invalid_request_module'));
}
// header 출력
$this->_printHeader();

View file

@ -21,7 +21,7 @@
var $module_info = NULL; ///< 모듈의 정보
var $check_standalone = false; ///< 요청된 모듈의 standalone을 체크할 것인지에 설정
var $error = NULL; ///< 진행 도중 에러 발생시 에러 코드를 정의, message 모듈을 호출시 사용
/**
* @brief constructor
@ -52,9 +52,6 @@
* @brief module, mid, document_srl을 이용하여 모듈을 찾고 act를 실행하기 위한 준비를
**/
function init() {
// 일반적인 요청으로 간주 standalone를 체크하도록 설정
$this->check_standalone = true;
// ModuleModel 객체 생성
$oModuleModel = &getModel('module');
@ -76,10 +73,7 @@
}
// 여기까지도 모듈 정보를 찾지 못했다면 깔끔하게 시스템 오류 표시
if(!$this->module) {
$this->module = 'message';
Context::set('system_message', Context::getLang('msg_mid_not_exists'));
}
if(!$this->module) $this->error = 'msg_module_is_not_exists';
// mid값이 있을 경우 mid값을 세팅
if($this->mid) Context::set('mid', $this->mid, true);
@ -90,8 +84,8 @@
* @brief 모듈과 관련된 정보를 이용하여 객체를 구하고 act 실행까지 진행시킴
**/
function procModule() {
// $module이 세팅되어 있지 않다면 return NULL, 이럴 경우가 없어야 함
if(!$this->module) return;
// 에러가 있으면 return
if($this->error) return;
// ModuleModel 객체 생성
$oModuleModel = &getModel('module');
@ -99,33 +93,64 @@
// 해당 모듈의 conf/action.xml 을 분석하여 action 정보를 얻어옴
$xml_info = $oModuleModel->getModuleXmlInfo($this->module);
// module_info가 없고(mid가 없다는 의미) standalone이 false이면 오류 표시
if($this->check_standalone && !$this->mid && !$xml_info->standalone) {
$this->module = 'message';
Context::set('system_message', Context::getLang('msg_invalid_request_module'));
$xml_info = $oModuleModel->getModuleXmlInfo($this->module);
}
// 현재 요청된 act가 있으면 $xml_info에서 type을 찾음, 없다면 기본 action을 이용
if(!$this->act || !$xml_info->action->{$this->act}) $this->act = $xml_info->default_action;
// 설정된 mid가 없을 경우 요청된 act의 standalone 여부 체크
if(!$this->mid && !$xml_info->action->{$this->act}->standalone) return $this->error = 'msg_module_is_not_standalone';
// type, grant 값 구함
$type = $xml_info->action->{$this->act}->type;
$grant = $xml_info->action->{$this->act}->grant;
// 모듈 객체 생성
$oModule = &$this->getModuleInstance($this->module, $type);
if(!is_object($oModule)) return;
$this->oModule = &$this->getModuleInstance($this->module, $type);
if(!is_object($this->oModule)) return $this->error = 'msg_module_is_not_exists';
// 모듈에 act값을 세팅
$oModule->setAct($this->act);
$this->oModule->setAct($this->act);
// 모듈 정보 세팅
$oModule->setModuleInfo($this->module_info, $xml_info);
$this->oModule->setModuleInfo($this->module_info, $xml_info);
$oModule->proc();
// 모듈을 수행하고 결과가 false이면 message 모듈 호출 지정
if(!$this->oModule->proc()) $this->error = $this->oModule->getMessage();
}
return $oModule;
/**
* @ 실행된 모듈의 컨텐츠를 출력
**/
function displayContent() {
// 설정된 모듈이 정상이지 않을 경우 message 모듈 객체 생성
if(!$this->oModule || !is_object($this->oModule)) {
$this->error = 'msg_module_is_not_exists';
}
// 에러가 발생하였을시 처리
if($this->error) {
// message 모듈 객체를 생성해서 컨텐츠 생성
$oModule = &getView('message');
$oModule->setError(-1);
$oModule->setMessage($this->error);
$oModule->dispContent();
// 정상적으로 호출된 객체가 있을 경우 해당 객체의 template를 변경
if($this->oModule) {
$this->oModule->setTemplatePath($oModule->getTemplatePath());
$this->oModule->setTemplateFile($oModule->getTemplateFile());
// 그렇지 않으면 message 객체를 호출된 객체로 지정
} else {
$this->oModule = $oModule;
}
}
// 컨텐츠 출력
$oDisplayHandler = new DisplayHandler();
$oDisplayHandler->printContent($this->oModule);
// DB 및 기타 자원의 종결 처리
Context::close();
}
/**

View file

@ -23,7 +23,7 @@
var $layout_path = './common/tpl/'; ///< 레이아웃 경로
var $layout_file = 'default_layout.html'; ///< 레이아웃 파일
var $stop_proc = false; ///< action 수행중 dispMessage를 호출하면 ModuleObject::proc()를 수행하지 않음
var $stop_proc = false; ///< action 수행중 stop()를 호출하면 ModuleObject::proc()를 수행하지 않음
/**
* @brief 현재 모듈의 이름을 지정
@ -126,21 +126,13 @@
/**
* @brief 메세지 출력
**/
function dispMessage($msg_code) {
function stop($msg_code) {
// proc 수행을 중지 시키기 위한 플래그 세팅
$this->stop_proc = true;
// RequestMethod가 XMLRPC일 경우를 대비
if(Context::getRequestMethod()=='XMLRPC') {
// 에러 처리
$this->setError(-1);
$this->setMessage($msg_code);
} else {
Context::set('system_message', Context::getLang($msg_code));
$oMessageView = &getView('message');
$oMessageView->dispMessage();
$this->setTemplatePath($oMessageView->getTemplatePath());
$this->setTemplateFile($oMessageView->getTemplateFile());
}
}
/**
@ -213,10 +205,10 @@
**/
function proc() {
// stop_proc==true이면 그냥 패스
if($this->stop_proc==true) return;
if($this->stop_proc==true) return false;
// 기본 act조차 없으면 return
if(!method_exists($this, $this->act)) return;
if(!method_exists($this, $this->act)) return false;
// this->act값으로 method 실행
$output = call_user_method($this->act, $this);
@ -224,7 +216,10 @@
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
$this->setError($output->getError());
$this->setMessage($output->getMessage());
return false;
}
return true;
}
}
?>

View file

@ -108,8 +108,6 @@
// 메세지 관련
$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 = '비밀번호를 입력하여 주세요';
@ -119,6 +117,9 @@
$lang->msg_error_occured = '오류가 발생하였습니다';
$lang->msg_not_founded = '대상을 찾을 수 없습니다';
$lang->msg_module_is_not_exists = '요청하신 모듈을 찾을 수 없습니다';
$lang->msg_module_is_not_standalone = '요청하신 모듈은 독립적으로 동작할 수가 없습니다';
$lang->success_registed = '등록되었습니다';
$lang->success_updated = '수정되었습니다';
$lang->success_deleted = '삭제되었습니다';

View file

@ -34,28 +34,13 @@
* @brief ModuleHandler 객체를 생성/ 실행
*
* 모듈 핸들러는 Request Argument를 바탕으로 모듈을 찾아서\n
* 객체를 생성하고 기본 정보를 setting \n
* 객체를 생성하고 기본 정보를 setting 준다.\n
* ModuleHandler는 외에도 설치가 되어 있는지에 대한 체크를\n
* 하여 미설치시 Install 모듈을 실행하도록 한다\n
* 그리고 해당 모듈을 실행후 모듈 객체를 return한다
* 모듈 객체는 DisplayHandler에 의해 content 출력시 사용된다.
* 그리고 해당 모듈을 실행후 컨텐츠를 출력한다\n
**/
$oModuleHandler = new ModuleHandler();
$oModuleHandler->init();
$oModule = &$oModuleHandler->procModule();
/**
* @brief DisplayHandler 객체를 생성하여 모듈의 처리 결과를 출력
*
* ModuleHandler에 의해 주어진 모듈 객체는 Object 클래스의 상속을 받으므로\n
* RequestMethod의 종류(GET/POST/XML) 따라 적절한 헤더 정보를 발송하고\n
* XML 데이터 혹은 HTML 데이터를 출력한다
**/
$oDisplayHandler = new DisplayHandler();
$oDisplayHandler->printContent($oModule);
/**
* @brief Context::close() 통해서 DB및 기타 사용된 자원들의 처리
**/
$oContext->close();
$oModuleHandler->procModule();
$oModuleHandler->displayContent();
?>

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<module standalone="true" default_action="dispAdminIndex" management_action="">
<module default_action="dispAdminIndex">
<actions>
<action name="dispAdminIndex" type="view" grant="root" />
<action name="dispLogin" type="view" grant="guest" />
<action name="dispLogout" type="view" grant="root" />
<action name="procLogin" type="controller" grant="guest" />
<action name="procLogout" type="controller" grant="guest" />
<action name="dispAdminIndex" type="view" standalone="true" />
<action name="dispLogin" type="view" standalone="true" />
<action name="dispLogout" type="view" standalone="true" />
<action name="procLogin" type="controller" standalone="true" />
<action name="procLogout" type="controller" standalone="true" />
</actions>
</module>

View file

@ -375,9 +375,6 @@
// module_srl 값이 없다면 그냥 index 페이지를 보여줌
if(!Context::get('module_srl')) return $this->dispAdminContent();
// template 경로를 변경
$this->setTemplatePath(
// 요청받은 모듈의 정보를 구함
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<module standalone="false" default_action="dispContent" management_action="dispAdminContent">
<module default_action="dispContent">
<grants>
<grant name="list" default="guest">
<title xml:lang="ko">목록</title>
@ -35,18 +35,9 @@
<action name="dispCommentDelete" type="view" />
<action name="dispTrackbackDelete" type="view" />
<action name="dispLogin" type="view" />
<action name="dispLogout" type="view" grant="member" />
<action name="dispLogout" type="view" />
<action name="dispMessage" type="view" />
<action name="dispRss" type="view" />
<action name="dispAdminContent" type="view" grant="root" />
<action name="dispAdminBoardInfo" type="view" grant="root" />
<action name="dispAdminInsertBoard" type="view" grant="root" />
<action name="dispAdminDeleteBoard" type="view" grant="root" />
<action name="dispAdminSkinInfo" type="view" grant="root" />
<action name="dispAdminCategoryInfo" type="view" grant="root" />
<action name="dispAdminGrantInfo" type="view" grant="root" />
<action name="procLogin" type="controller" />
<action name="procLogout" type="controller" grant="member" />
<action name="procInsertDocument" type="controller" />
<action name="procDeleteDocument" type="controller" />
<action name="procVoteDocument" type="controller" />
@ -59,11 +50,20 @@
<action name="procUploadFile" type="controller" />
<action name="procDownloadFile" type="controller" />
<action name="procClearFile" type="controller" />
<action name="procInsertGrant" type="controller" grant="root"/>
<action name="procUpdateSkinInfo" type="controller" grant="root"/>
<action name="procInsertBoard" type="controller" grant="root"/>
<action name="procDeleteBoard" type="controller" grant="root"/>
<action name="procInsertCategory" type="controller" grant="root"/>
<action name="procUpdateCategory" type="controller" grant="root"/>
<action name="dispAdminContent" type="view" standalone="true" />
<action name="dispAdminBoardInfo" type="view" standalone="true" />
<action name="dispAdminInsertBoard" type="view" standalone="true" />
<action name="dispAdminDeleteBoard" type="view" standalone="true" />
<action name="dispAdminSkinInfo" type="view" standalone="true" />
<action name="dispAdminCategoryInfo" type="view" standalone="true" />
<action name="dispAdminGrantInfo" type="view" standalone="true" />
<action name="procLogin" type="controller" standalone="true" />
<action name="procLogout" type="controller" standalone="true" />
<action name="procInsertGrant" type="controller" standalone="true" />
<action name="procUpdateSkinInfo" type="controller" standalone="true" />
<action name="procInsertBoard" type="controller" standalone="true" />
<action name="procDeleteBoard" type="controller" standalone="true" />
<action name="procInsertCategory" type="controller" standalone="true" />
<action name="procUpdateCategory" type="controller" standalone="true" />
</actions>
</module>

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<module standalone="true" default_action="dispIntroduce">
<module default_action="dispIntroduce">
<grants />
<actions>
<action name="dispIntroduce" type="view" grant="guest" />
<action name="dispInstallForm" type="view" grant="guest" />
<action name="procInstall" type="controller" grant="guest" />
<action name="dispIntroduce" type="view" standalone="true" />
<action name="dispInstallForm" type="view" standalone="true" />
<action name="procInstall" type="controller" standalone="true" />
</actions>
</module>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<module standalone="false" version="0.1" default_action="viewIntroduce" management_action="" >
<module default_action="viewIntroduce">
<actions>
<action name="viewIntroduce" type="view" />
<action name="viewDBInfoForm" type="view" />

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<module standalone="true" default_action="dispMessage">
<module default_action="dispMessage">
<grants />
<actions>
<action name="dispMessage" type="view" />
<action name="dispMessage" type="view" standalone="true" />
</actions>
</module>

View file

@ -11,13 +11,15 @@
* @brief 초기화
**/
function init() {
// 템플릿 경로를 지정
$this->setTemplatePath($this->module_path.'tpl');
}
/**
* @brief 메세지 출력
**/
function dispMessage() {
function dispContent() {
Context::set('system_message', $this->getMessage());
$this->setTemplateFile('system_message');
}
}

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<module standalone="false" default_action="dispContent" management_action="">
<module default_action="dispContent">
<actions>
<action name="dispContent" type="view" grant="root" />
<action name="dispContent" type="view" standalone="true" />
</actions>
</module>

View file

@ -26,9 +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
$grants = $xml_obj->module->grants->grant; ///< 권한 정보 (없는 경우도 있음)
$actions = $xml_obj->module->actions->action; ///< action list (필수)
@ -40,9 +38,8 @@
foreach($grant_list as $grant) {
$name = $grant->attrs->name;
$default = $grant->attrs->default;
$default = $grant->attrs->default?$grant->attrs->default:'guest';
$title = $grant->title->body;
if(!$default) $default = 'guest';
$output->grant->{$name}->title = $title;
$output->grant->{$name}->default = $default;
@ -56,11 +53,14 @@
foreach($action_list as $action) {
$name = $action->attrs->name;
$type = $action->attrs->type;
$grant = $action->attrs->grant;
if(!$grant) $grant = 'guest';
$grant = $action->attrs->grant?$action->attrs->grant:'guest';
$standalone = $action->attrs->standalone=='true'?true:false;
$output->action->{$name}->type = $type;
$output->action->{$name}->grant = $grant;
$output->action->{$name}->standalone= $standalone;
}
}