mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 03:52:15 +09:00
#19122530 Module Extend 지원
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7684 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
8595952528
commit
f55fbeef9d
3 changed files with 96 additions and 3 deletions
|
|
@ -71,6 +71,7 @@
|
||||||
**/
|
**/
|
||||||
function init() {
|
function init() {
|
||||||
$oModuleModel = &getModel('module');
|
$oModuleModel = &getModel('module');
|
||||||
|
$oModuleModel->loadModuleExtends();
|
||||||
|
|
||||||
$site_module_info = Context::get('site_module_info');
|
$site_module_info = Context::get('site_module_info');
|
||||||
|
|
||||||
|
|
@ -425,13 +426,23 @@
|
||||||
* @remarks if there exists a module instance created before, returns it.
|
* @remarks if there exists a module instance created before, returns it.
|
||||||
**/
|
**/
|
||||||
function &getModuleInstance($module, $type = 'view', $kind = '') {
|
function &getModuleInstance($module, $type = 'view', $kind = '') {
|
||||||
$class_path = ModuleHandler::getModulePath($module);
|
$parent_module = $module;
|
||||||
if(!is_dir(_XE_PATH_.$class_path)) return NULL;
|
|
||||||
|
|
||||||
if(__DEBUG__==3) $start_time = getMicroTime();
|
if(__DEBUG__==3) $start_time = getMicroTime();
|
||||||
|
|
||||||
if($kind != 'admin') $kind = 'svc';
|
if($kind != 'admin') $kind = 'svc';
|
||||||
|
|
||||||
|
if(is_array($GLOBALS['__MODULE_EXTEND__'])) {
|
||||||
|
$extend_module = $GLOBALS['__MODULE_EXTEND__'][$module.'.'.($kind=='svc'?'':'admin').'.'.$type];
|
||||||
|
if($extend_module && file_exists(FileHandler::getRealPath(ModuleHandler::getModulePath($extend_module)))) {
|
||||||
|
$module = $extend_module;
|
||||||
|
}else{
|
||||||
|
unset($extend_module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$class_path = ModuleHandler::getModulePath($module);
|
||||||
|
if(!is_dir(_XE_PATH_.$class_path)) return NULL;
|
||||||
|
|
||||||
// if there is no instance of the module in global variable, create a new one
|
// if there is no instance of the module in global variable, create a new one
|
||||||
if(!$GLOBALS['_loaded_module'][$module][$type][$kind]) {
|
if(!$GLOBALS['_loaded_module'][$module][$type][$kind]) {
|
||||||
// Get base class name and load the file contains it
|
// Get base class name and load the file contains it
|
||||||
|
|
@ -501,6 +512,9 @@
|
||||||
|
|
||||||
// Load language files for the class
|
// Load language files for the class
|
||||||
Context::loadLang($class_path.'lang');
|
Context::loadLang($class_path.'lang');
|
||||||
|
if($extend_module) {
|
||||||
|
Context::loadLang(ModuleHandler::getModulePath($parent_module).'lang');
|
||||||
|
}
|
||||||
|
|
||||||
// Set variables to the instance
|
// Set variables to the instance
|
||||||
$oModule->setModule($module);
|
$oModule->setModule($module);
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,45 @@
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief module extend 추가
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
function insertModuleExtend($parent_module, $extend_module, $type, $kind=''){
|
||||||
|
if($kind!='admin') $kind = '';
|
||||||
|
if(!in_array($type,array('model','controller','view')) || !in_array($kind,array('svc','admin'))) return;
|
||||||
|
|
||||||
|
$cache_file = './files/config/module_extend.php';
|
||||||
|
FileHandler::removeFile($cache_file);
|
||||||
|
|
||||||
|
$args->parent_module = $parent_module;
|
||||||
|
$args->extend_module = $extend_module;
|
||||||
|
$args->type = $type;
|
||||||
|
$args->kind = $kind;
|
||||||
|
|
||||||
|
$output = executeQuery('module.insertModuleExtend', $args);
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief module extend 삭제
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
function deleteModuleExtend($parent_module, $extend_module, $type, $kind=''){
|
||||||
|
$cache_file = './files/config/module_extend.php';
|
||||||
|
FileHandler::deleteFile($cache_file);
|
||||||
|
|
||||||
|
$args->parent_module = $parent_module;
|
||||||
|
$args->extend_module = $extend_module;
|
||||||
|
$args->type = $type;
|
||||||
|
$args->kind = $kind;
|
||||||
|
|
||||||
|
$output = executeQuery('module.deleteModuleExtend', $args);
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 특정 모듈의 설정 입력
|
* @brief 특정 모듈의 설정 입력
|
||||||
* board, member등 특정 모듈의 global config 관리용
|
* board, member등 특정 모듈의 global config 관리용
|
||||||
|
|
|
||||||
|
|
@ -295,6 +295,46 @@
|
||||||
return $output->data;
|
return $output->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 특정 module extend 가져옴
|
||||||
|
**/
|
||||||
|
function getModuleExtend($parent_module, $type, $kind='') {
|
||||||
|
$module_extend_info = $this->loadModuleExtends();
|
||||||
|
$extend = $module_extend_info[$parent_module.'.'.$kind.'.'.$type];
|
||||||
|
|
||||||
|
return $extend;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 모든 module extend 가져옴
|
||||||
|
**/
|
||||||
|
function loadModuleExtends() {
|
||||||
|
$cache_file = './files/config/module_extend.php';
|
||||||
|
$cache_file = FileHandler::getRealPath($cache_file);
|
||||||
|
|
||||||
|
if(!isset($GLOBALS['__MODULE_EXTEND__'])){
|
||||||
|
if(!file_exists($cache_file)) {
|
||||||
|
|
||||||
|
$arr = array();
|
||||||
|
$output = executeQueryArray('module.getModuleExtend');
|
||||||
|
if($output->data){
|
||||||
|
foreach($output->data as $v){
|
||||||
|
$arr[] = sprintf("'%s.%s.%s' => '%s'", $v->parent_module, $v->type, $v->kind, $v->extend_module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$str = '<?PHP $__module_extend_info__=array(%s); return $__module_extend_info__; ?>';
|
||||||
|
$str = sprintf($str, join(',',$arr));
|
||||||
|
|
||||||
|
FileHandler::writeFile($cache_file, $str);
|
||||||
|
}
|
||||||
|
|
||||||
|
$GLOBALS['__MODULE_EXTEND__'] = include($cache_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $GLOBALS['__MODULE_EXTEND__'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 모듈의 conf/info.xml 을 읽어서 정보를 구함
|
* @brief 모듈의 conf/info.xml 을 읽어서 정보를 구함
|
||||||
**/
|
**/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue