mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@31 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
595b1d5e56
commit
3be841b48a
6 changed files with 68 additions and 71 deletions
|
|
@ -118,20 +118,13 @@
|
|||
*
|
||||
* $act값에 의해서 $action_list에 선언된 것들을 실행한다
|
||||
**/
|
||||
function proc($act = null) {
|
||||
|
||||
// 별도로 요청한 act가 없으면 주어진 act를 이용
|
||||
if($act) $this->act = $act;
|
||||
else $this->act = Context::get('act');
|
||||
|
||||
// act값이 없거나 존재하지 않는 method를 호출시에 default_act를 지정
|
||||
if(!$this->act || !method_exists($this, $this->act)) $this->act = $this->default_act;
|
||||
function proc($act) {
|
||||
|
||||
// 기본 act조차 없으면 return
|
||||
if(!method_exists($this, $this->act)) return false;
|
||||
if(!method_exists($this, $act)) return false;
|
||||
|
||||
// act값으로 method 실행
|
||||
$output = call_user_method($this->act, $this);
|
||||
$output = call_user_method($act, $this);
|
||||
|
||||
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
|
||||
$this->setError($output->getError());
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
* Request Argument에서 $mid, $act값으로 객체를 찾는다.\n
|
||||
* 단 유연한 처리를 위해 $document_srl 을 이용하기도 한다.
|
||||
**/
|
||||
function ModuleHandler($module = NULL, $act_type = NULL) {
|
||||
function ModuleHandler($module = NULL, $act = NULL) {
|
||||
|
||||
// 설치가 안되어 있다면 설치를 위한 준비를 한다
|
||||
if(!Context::isInstalled()) {
|
||||
|
|
@ -49,28 +49,28 @@
|
|||
// 만약 모듈이 없다면 잘못된 모듈 호출에 대한 오류를 message 모듈을 통해 호출
|
||||
if(!$module) {
|
||||
$module = 'message';
|
||||
$act_type = 'view';
|
||||
Context::set('message', Context::getLang('msg_mid_not_exists'));
|
||||
}
|
||||
|
||||
// actType을 정함 (없으면 view를 기본 actType으로 정의)
|
||||
if(!$act_type) {
|
||||
$act = Context::get('act');
|
||||
if(!$act) $act_type = 'view';
|
||||
else {
|
||||
$act_type = substr($act, 0, 4);
|
||||
if(!$act_type or !in_array(strtolower($act_type), array('view','model','controller'))) $act_type = 'view';
|
||||
}
|
||||
}
|
||||
|
||||
// module_info가 없으면 기본적인 값들로 작성
|
||||
if(!$module_info) {
|
||||
$module_info->module = $module;
|
||||
$module_info->module_srl = 0;
|
||||
}
|
||||
// 해당 모듈의 conf/action.xml 을 분석하여 act 값을 체크
|
||||
if(!$act) $act = Context::get('act');
|
||||
$type = $this->getActionType($module, $act);
|
||||
|
||||
// 모듈 객체 생성
|
||||
$this->oModule = &$this->getModuleInstance($module, $act_type, $module_info);
|
||||
$oModule = &$this->getModuleInstance($module, $type, $module_info);
|
||||
|
||||
if(!is_object($oModule)) return;
|
||||
|
||||
$oModule->proc($act);
|
||||
|
||||
$this->oModule = $oModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief constructor에서 생성한 oModule를 return
|
||||
**/
|
||||
function getModule() {
|
||||
return $this->oModule;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,13 +110,50 @@
|
|||
return $module_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief module의 위치를 찾아서 return
|
||||
**/
|
||||
function getModulePath($module) {
|
||||
$class_path = sprintf('./files/modules/%s/', $module);
|
||||
if(is_dir($class_path)) return $class_path;
|
||||
|
||||
$class_path = sprintf('./modules/%s/', $module);
|
||||
if(is_dir($class_path)) return $class_path;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief module의 conf/action.xml 을 통해 act값에 해당하는 action type을 return
|
||||
**/
|
||||
function getActionType($module, &$act) {
|
||||
$class_path = $this->getModulePath($module);
|
||||
if(!$class_path) return;
|
||||
|
||||
$action_xml_file = sprintf("%sconf/action.xml", $class_path);
|
||||
if(!file_exists($action_xml_file)) return;
|
||||
|
||||
$oXml = XmlParser::loadXmlFile($action_xml_file);
|
||||
|
||||
if(!count($oXml->module->action)) return;
|
||||
|
||||
foreach($oXml->module->action as $action) {
|
||||
if($action->attrs->default) $default_act = $action;
|
||||
if($action->attrs->name == $act) return $action->attrs->type;
|
||||
}
|
||||
|
||||
if($default_act) {
|
||||
$act = $default_act->attrs->name;
|
||||
return $default_act->attrs->type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모듈 객체를 생성함
|
||||
**/
|
||||
function getModuleInstance($module, $type = 'view', $module_info = NULL) {
|
||||
// 요청받은 모듈이 있는지 확인
|
||||
$module = strtolower($module);
|
||||
if(!$module) return;
|
||||
$class_path = ModuleHandler::getModulePath($module);
|
||||
if(!$class_path) return NULL;
|
||||
|
||||
// global 변수에 미리 생성해 둔 객체가 없으면 새로 생성
|
||||
if(!$GLOBALS['_loaded_module'][$module][$type]) {
|
||||
|
|
@ -126,9 +163,6 @@
|
|||
* 기본적으로는 ./modules/* 에 있지만 웹업데이트나 웹설치시 ./files/modules/* 에 있음
|
||||
* ./files/modules/* 의 클래스 파일을 우선으로 처리해야 함
|
||||
**/
|
||||
$class_path = sprintf('./files/modules/%s/', $module);
|
||||
if(!is_dir($class_path)) $class_path = sprintf('./modules/%s/', $module);
|
||||
if(!is_dir($class_path)) return NULL;
|
||||
|
||||
// 객체의 이름을 구함
|
||||
switch($type) {
|
||||
|
|
@ -167,24 +201,10 @@
|
|||
|
||||
// GLOBALS 변수에 생성된 객체 저장
|
||||
$GLOBALS['_loaded_module'][$module][$type] = $oModule;
|
||||
|
||||
}
|
||||
|
||||
// 객체 리턴
|
||||
return $GLOBALS['_loaded_module'][$module][$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief mid로 생성한 모듈 객체에 모듈 정보를 세팅하고 실행
|
||||
*
|
||||
* 모듈을 실행후에 그 모듈 객체를 return하여 DisplayHandler로 넘겨줌
|
||||
**/
|
||||
function proc() {
|
||||
if(!is_object($this->oModule)) return;
|
||||
|
||||
$this->oModule->proc();
|
||||
|
||||
return $this->oModule;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
14
index.php
14
index.php
|
|
@ -30,23 +30,17 @@
|
|||
$oContext->init();
|
||||
|
||||
/**
|
||||
* @brief ModuleHandler 객체를 생성
|
||||
* @brief ModuleHandler 객체를 생성/ 실행
|
||||
*
|
||||
* 모듈 핸들러는 Request Argument를 바탕으로 모듈을 찾아서\n
|
||||
* 객체를 생성하고 기본 정보를 setting 해줌\n
|
||||
* ModuleHandler는 이 외에도 설치가 되어 있는지에 대한 체크를\n
|
||||
* 하여 미설치시 Install 모듈을 실행하도록 한다\n
|
||||
**/
|
||||
$oModuleHandler = new ModuleHandler();
|
||||
|
||||
/**
|
||||
* @brief ModuleHandler에서 모듈 객체를 받는다
|
||||
*
|
||||
* ModuleHandler는 찾아진 모듈 객체를 이용하여 주어진 act에 해당하는\n
|
||||
* method를 찾아서 실행을 모두 시킨후에 모듈 객체를 return 한다.\n
|
||||
* 그리고 해당 모듈을 실행후 모듈 객체를 return한다
|
||||
* 이 모듈 객체는 DisplayHandler에 의해 content 출력시 사용된다.
|
||||
**/
|
||||
$oModule = &$oModuleHandler->proc();
|
||||
$oModuleHandler = new ModuleHandler();
|
||||
$oModule = &$oModuleHandler->getModule();
|
||||
|
||||
/**
|
||||
* @brief DisplayHandler 객체를 생성하여 모듈의 처리 결과를 출력
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
/**
|
||||
* @brief 초기화
|
||||
*
|
||||
* 설치가능한지에 대한 체크
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
|
@ -62,9 +60,7 @@
|
|||
**/
|
||||
function doInstall() {
|
||||
// 설치가 되어 있는지에 대한 체크
|
||||
if(Context::isInstalled()) {
|
||||
return $this->doError('msg_already_installed');
|
||||
}
|
||||
if(Context::isInstalled()) return new Object(-1, 'msg_already_installed');
|
||||
|
||||
// DB와 관련된 변수를 받음
|
||||
$db_info = Context::gets('db_type','db_hostname','db_userid','db_password','db_database','db_table_prefix');
|
||||
|
|
@ -76,9 +72,7 @@
|
|||
$oDB = &DB::getInstance();
|
||||
|
||||
// DB접속이 가능한지 체크
|
||||
if(!$oDB->isConnected()) {
|
||||
return $this->doError('msg_dbconnect_failed');
|
||||
}
|
||||
if(!$oDB->isConnected()) return new Object(-1, 'msg_dbconnect_failed');
|
||||
|
||||
// 모든 모듈의 테이블 생성
|
||||
$output = $this->makeTable();
|
||||
|
|
@ -119,7 +113,7 @@
|
|||
$oModule->makeDefaultModule();
|
||||
|
||||
// config 파일 생성
|
||||
if(!$this->makeConfigFile()) return $this->doError('msg_install_failed');
|
||||
if(!$this->makeConfigFile()) return new Object(-1, 'msg_install_failed');
|
||||
|
||||
// 설치 완료 메세지 출력
|
||||
$this->setMessage('msg_install_completed');
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@
|
|||
|
||||
class installView extends Module {
|
||||
|
||||
var $default_act = 'viewIntroduce'; ///< 별도의 act가 없으면 기본으로 사용될 act
|
||||
|
||||
var $install_enable = false; ///< 설치 가능한지에 대한 flag
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue