mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-27 14:22:54 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@25 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
507b09a62e
commit
c690cff0c8
17 changed files with 1216 additions and 1028 deletions
|
|
@ -61,13 +61,6 @@
|
|||
$this->context = &$GLOBALS['__Context__'];
|
||||
$this->context->lang = &$GLOBALS['lang'];
|
||||
|
||||
// 인증관련 데이터를 Context에 설정
|
||||
$oMember = getModule('member');
|
||||
if($oMember->isLogged()) {
|
||||
$this->_set('is_logged', true);
|
||||
$this->_set('logged_info', $_SESSION['logged_info']);
|
||||
}
|
||||
|
||||
// 기본적인 DB정보 세팅
|
||||
$this->_loadDBInfo();
|
||||
|
||||
|
|
@ -82,6 +75,16 @@
|
|||
$this->_setXmlRpcArgument();
|
||||
$this->_setRequestArgument();
|
||||
$this->_setUploadedArgument();
|
||||
|
||||
// 인증관련 데이터를 Context에 설정
|
||||
$oMember = getModule('member','model');
|
||||
if($oMember->isLogged()) {
|
||||
$this->_set('is_logged', true);
|
||||
$this->_set('logged_info', $_SESSION['logged_info']);
|
||||
} else {
|
||||
$this->_set('is_logged', false);
|
||||
$this->_set('logged_info', NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@
|
|||
**/
|
||||
function &getInstance($db_type = NULL) {
|
||||
if(!$db_type) $db_type = Context::getDBType();
|
||||
if(!$db_type) return new Output(-1, 'msg_db_not_setted');
|
||||
if(!$db_type) return new Object(-1, 'msg_db_not_setted');
|
||||
|
||||
if(!$GLOBALS['__DB__']) {
|
||||
$class_name = sprintf("DB%s%s", strtoupper(substr($db_type,0,1)), strtolower(substr($db_type,1)));
|
||||
$class_file = sprintf("./classes/db/%s.class.php", $class_name);
|
||||
if(!file_exists($class_file)) new Output(-1, 'msg_db_not_setted');
|
||||
if(!file_exists($class_file)) new Object(-1, 'msg_db_not_setted');
|
||||
|
||||
require_once($class_file);
|
||||
$eval_str = sprintf('$GLOBALS[\'__DB__\'] = new %s();', $class_name);
|
||||
|
|
@ -103,10 +103,10 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 에러결과를 Output 객체로 return
|
||||
* @brief 에러결과를 Object 객체로 return
|
||||
**/
|
||||
function getError() {
|
||||
return new Output($this->errno, $this->errstr);
|
||||
return new Object($this->errno, $this->errstr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,15 +116,15 @@
|
|||
* query_id에 해당하는 xml문(or 캐싱파일)을 찾아서 컴파일 후 실행
|
||||
**/
|
||||
function executeQuery($query_id, $args = NULL) {
|
||||
if(!$query_id) return new Output(-1, 'msg_invalid_queryid');
|
||||
if(!$query_id) return new Object(-1, 'msg_invalid_queryid');
|
||||
|
||||
list($module, $id) = explode('.',$query_id);
|
||||
if(!$module||!$id) return new Output(-1, 'msg_invalid_queryid');
|
||||
if(!$module||!$id) return new Object(-1, 'msg_invalid_queryid');
|
||||
|
||||
$xml_file = sprintf('./modules/%s/queries/%s.xml', $module, $id);
|
||||
if(!file_exists($xml_file)) {
|
||||
$xml_file = sprintf('./files/modules/%s/queries/%s.xml', $module, $id);
|
||||
if(!file_exists($xml_file)) return new Output(-1, 'msg_invalid_queryid');
|
||||
if(!file_exists($xml_file)) return new Object(-1, 'msg_invalid_queryid');
|
||||
}
|
||||
|
||||
// 일단 cache 파일을 찾아본다
|
||||
|
|
@ -147,14 +147,14 @@
|
|||
function _executeQuery($cache_file, $source_args, $query_id) {
|
||||
global $lang;
|
||||
|
||||
if(!file_exists($cache_file)) return new Output(-1, 'msg_invalid_queryid');
|
||||
if(!file_exists($cache_file)) return new Object(-1, 'msg_invalid_queryid');
|
||||
|
||||
if(__DEBUG__) $query_start = getMicroTime();
|
||||
|
||||
if($source_args) $args = clone($source_args);
|
||||
$output = include($cache_file);
|
||||
|
||||
if( (is_a($output, 'Output')||is_subclass_of($output,'Output'))&&!$output->toBool()) return $output;
|
||||
if( (is_a($output, 'Object')||is_subclass_of($output,'Object'))&&!$output->toBool()) return $output;
|
||||
|
||||
// action값에 따라서 쿼리 생성으로 돌입
|
||||
switch($action) {
|
||||
|
|
@ -179,9 +179,9 @@
|
|||
$GLOBALS['__db_queries__'] .= sprintf("\t%02d. %s (%0.4f sec)\n\t %s\n", ++$GLOBALS['__dbcnt'], $query_id, $elapsed_time, $this->query);
|
||||
}
|
||||
|
||||
if($this->errno!=0) return new Output($this->errno, $this->errstr);
|
||||
if(is_a($output, 'Output') || is_subclass_of($output, 'Output')) return $output;
|
||||
return new Output();
|
||||
if($this->errno!=0) return new Object($this->errno, $this->errstr);
|
||||
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) return $output;
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -191,33 +191,33 @@
|
|||
global $lang;
|
||||
|
||||
$length = strlen($val);
|
||||
if($minlength && $length < $minlength) return new Output(-1, sprintf($lang->filter->outofrange, $lang->{$key}?$lang->{$key}:$key));
|
||||
if($maxlength && $length > $maxlength) return new Output(-1, sprintf($lang->filter->outofrange, $lang->{$key}?$lang->{$key}:$key));
|
||||
if($minlength && $length < $minlength) return new Object(-1, sprintf($lang->filter->outofrange, $lang->{$key}?$lang->{$key}:$key));
|
||||
if($maxlength && $length > $maxlength) return new Object(-1, sprintf($lang->filter->outofrange, $lang->{$key}?$lang->{$key}:$key));
|
||||
|
||||
switch($filter_type) {
|
||||
case 'email' :
|
||||
case 'email_adderss' :
|
||||
if(!eregi('^[_0-9a-z-]+(\.[_0-9a-z-]+)*@[0-9a-z-]+(\.[0-9a-z-]+)*$', $val)) return new Output(-1, sprintf($lang->filter->invalid_email, $lang->{$key}?$lang->{$key}:$key));
|
||||
if(!eregi('^[_0-9a-z-]+(\.[_0-9a-z-]+)*@[0-9a-z-]+(\.[0-9a-z-]+)*$', $val)) return new Object(-1, sprintf($lang->filter->invalid_email, $lang->{$key}?$lang->{$key}:$key));
|
||||
break;
|
||||
case 'homepage' :
|
||||
if(!eregi('^(http|https)+(:\/\/)+[0-9a-z_-]+\.[^ ]+$', $val)) return new Output(-1, sprintf($lang->filter->invalid_homepage, $lang->{$key}?$lang->{$key}:$key));
|
||||
if(!eregi('^(http|https)+(:\/\/)+[0-9a-z_-]+\.[^ ]+$', $val)) return new Object(-1, sprintf($lang->filter->invalid_homepage, $lang->{$key}?$lang->{$key}:$key));
|
||||
break;
|
||||
case 'userid' :
|
||||
case 'user_id' :
|
||||
if(!eregi('^[a-zA-Z]+([_0-9a-zA-Z]+)*$', $val)) return new Output(-1, sprintf($lang->filter->invalid_userid, $lang->{$key}?$lang->{$key}:$key));
|
||||
if(!eregi('^[a-zA-Z]+([_0-9a-zA-Z]+)*$', $val)) return new Object(-1, sprintf($lang->filter->invalid_userid, $lang->{$key}?$lang->{$key}:$key));
|
||||
break;
|
||||
case 'number' :
|
||||
if(!eregi('^[0-9]+$', $val)) return new Output(-1, sprintf($lang->filter->invalid_number, $lang->{$key}?$lang->{$key}:$key));
|
||||
if(!eregi('^[0-9]+$', $val)) return new Object(-1, sprintf($lang->filter->invalid_number, $lang->{$key}?$lang->{$key}:$key));
|
||||
break;
|
||||
case 'alpha' :
|
||||
if(!eregi('^[a-z]+$', $val)) return new Output(-1, sprintf($lang->filter->invalid_alpha, $lang->{$key}?$lang->{$key}:$key));
|
||||
if(!eregi('^[a-z]+$', $val)) return new Object(-1, sprintf($lang->filter->invalid_alpha, $lang->{$key}?$lang->{$key}:$key));
|
||||
break;
|
||||
case 'alpha_number' :
|
||||
if(!eregi('^[0-9a-z]+$', $val)) return new Output(-1, sprintf($lang->filter->invalid_alpha_number, $lang->{$key}?$lang->{$key}:$key));
|
||||
if(!eregi('^[0-9a-z]+$', $val)) return new Object(-1, sprintf($lang->filter->invalid_alpha_number, $lang->{$key}?$lang->{$key}:$key));
|
||||
break;
|
||||
}
|
||||
|
||||
return new Output();
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@
|
|||
if($this->errno!=0) return;
|
||||
$data = $this->_fetch($result);
|
||||
|
||||
$buff = new Output();
|
||||
$buff = new Object();
|
||||
$buff->data = $data;
|
||||
return $buff;
|
||||
}
|
||||
|
|
@ -394,7 +394,7 @@
|
|||
$data[$virtual_no--] = $tmp;
|
||||
}
|
||||
|
||||
$buff = new Output();
|
||||
$buff = new Object();
|
||||
$buff->total_count = $total_count;
|
||||
$buff->total_page = $total_page;
|
||||
$buff->page = $page;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
require_once("./classes/template/TemplateHandler.class.php");
|
||||
|
||||
$oTemplate = new TemplateHandler();
|
||||
$output = $oTemplate->compile($oModule->layout_path, $oModule->layout_tpl);
|
||||
$output = $oTemplate->compile($oModule->layout_path, $oModule->layout_file);
|
||||
} else {
|
||||
$output = $content;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,55 +2,52 @@
|
|||
/**
|
||||
* @class Module
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief modules 의 abstract class
|
||||
* @brief module의 abstract class
|
||||
**/
|
||||
|
||||
class Module extends Output {
|
||||
|
||||
var $module_path = NULL; ///< 현재 모듈의 실행 위치
|
||||
|
||||
var $skin = 'default'; ///< skin 설정 (없을 경우도 있음)
|
||||
class Module extends Object {
|
||||
|
||||
var $mid = NULL; ///< module로 생성한 instance(관리상)의 값
|
||||
var $module = NULL; ///< mid로 찾아서 생성한 모듈 class 이름
|
||||
var $module_srl = NULL; ///< 모듈 객체의 고유값인 module_srl
|
||||
var $module_info = NULL; ///< 현재 모듈 생성시 주어진 설정 정보들
|
||||
var $module_info = NULL; ///< 모듈의 정보
|
||||
|
||||
var $module_path = NULL; ///< 모듈 class file의 실행 위치
|
||||
|
||||
var $act = NULL; ///< act 값
|
||||
var $act_type = 'disp'; ///< act_type (disp, proc, lib, admin 4가지 존재, act에서 type을 찾음)
|
||||
|
||||
var $layout_path = "./common/tpl/"; ///< 레이아웃 파일의 path
|
||||
var $layout_tpl = "default_layout"; ///< 레이아웃 파일
|
||||
var $template_path = NULL; ///< template 경로
|
||||
var $template_file = NULL; ///< template 파일
|
||||
|
||||
var $layout_path = './common/tpl/'; ///< 레이아웃 경로
|
||||
var $layout_file = 'default_layout.html'; ///< 레이아웃 파일
|
||||
|
||||
/**
|
||||
* @brief 현재 모듈의 path를 지정
|
||||
**/
|
||||
function setModulePath($path) {
|
||||
if(substr($path,-1)!='/') $path.='/';
|
||||
$this->module_path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모듈의 정보 세팅
|
||||
**/
|
||||
function moduleInit($module_info) {
|
||||
// 브라우저 타이틀 지정
|
||||
Context::setBrowserTitle($module_info->browser_title?$module_info->browser_title:$module_info->mid);
|
||||
|
||||
function setModuleInfo($module_info) {
|
||||
// 기본 변수 설정
|
||||
$this->module_info = $module_info;
|
||||
context::set('module_info', &$this->module_info);
|
||||
|
||||
$this->mid = $module_info->mid;
|
||||
$this->module = $module_info->module;
|
||||
$this->module_srl = $module_info->module_srl;
|
||||
$this->module_info = $module_info;
|
||||
|
||||
// skin 설정 (기본으로는 default)
|
||||
if($this->module_info->skin) $this->skin = $this->module_info->skin;
|
||||
else $this->skin = 'default';
|
||||
|
||||
// 템플릿 위치 설정
|
||||
if(!$this->template_path) {
|
||||
$template_path = $this->module_path.'skins/'.$this->skin;
|
||||
$this->setTemplatePath($template_path);
|
||||
}
|
||||
|
||||
$oMember = getModule('member');
|
||||
$user_id = $oMember->getUserID();
|
||||
$logged_info = $oMember->getLoggedInfo();
|
||||
// 웹서비스에서 꼭 필요한 인증 정보와 권한 설정 체크
|
||||
$is_logged = Context::get('is_logged');
|
||||
$logged_info = Context::get('logged_info');
|
||||
$user_id = $logged_info->user_id;
|
||||
$user_group = $logged_info->group_list;
|
||||
$user_group_count = count($user_group);
|
||||
|
||||
// 로그인되어 있다면 admin 체크
|
||||
if($oMember->isLogged() && ($logged_info->is_admin == 'Y' || in_array($user_id, $this->module_info->admin_id) )) {
|
||||
if($is_logged && ($logged_info->is_admin == 'Y' || in_array($user_id, $this->module_info->admin_id) )) {
|
||||
$grant->is_admin = true;
|
||||
} else {
|
||||
$grant->is_admin = false;
|
||||
|
|
@ -58,7 +55,6 @@
|
|||
|
||||
// 권한 설정
|
||||
if($this->grant_list) {
|
||||
|
||||
foreach($this->grant_list as $grant_name) {
|
||||
$grant->{$grant_name} = false;
|
||||
|
||||
|
|
@ -67,7 +63,7 @@
|
|||
continue;
|
||||
}
|
||||
|
||||
if($user_group_count) {
|
||||
if(count($user_group)) {
|
||||
foreach($user_group as $group_srl) {
|
||||
if(in_array($group_srl, $this->module_info->grant[$grant_name])) {
|
||||
$grant->{$grant_name} = true;
|
||||
|
|
@ -87,49 +83,34 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 현재 모듈에 $act에 해당하는 method가 있는지 체크
|
||||
* @brief template 파일 지정
|
||||
**/
|
||||
function isExistsAct($act) {
|
||||
return method_exists($this, $act);
|
||||
function setTemplateFile($filename) {
|
||||
if(substr($filename,-5)!='.html') $filename .= '.html';
|
||||
$this->template_file = $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 현재 acT_type의 return (disp/proc)
|
||||
* @brief template 파일 return
|
||||
**/
|
||||
function getActType() {
|
||||
return $this->act_type;
|
||||
function getTemplateFile() {
|
||||
return $this->template_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 현재 모듈의 path를 지정
|
||||
* @brief template 경로 지정
|
||||
**/
|
||||
function setModulePath($path) {
|
||||
if(substr($path,-1)!='/') $path.='/';
|
||||
$this->module_path = $path;
|
||||
function setTemplatePath($path) {
|
||||
if(substr($path,-1)!='/') $path .= '/';
|
||||
if(substr($path,0,2)!='./') $path = './'.$path;
|
||||
$this->template_path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에러 유발. 에러시 message module을 바로 호출하고 현재 모듈은 exit
|
||||
* @brief template 경로 return
|
||||
**/
|
||||
function doError($msg_code) {
|
||||
$this->setError(-1);
|
||||
if(!Context::getLang($msg_code)) $this->setMessage($msg_code);
|
||||
else $this->setMessage(Context::getLang($msg_code));
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 레이아웃 경로를 지정
|
||||
**/
|
||||
function setLayoutPath($path) {
|
||||
$this->layout_path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 레이아웃 tpl 파일을 지정
|
||||
**/
|
||||
function setLayoutTpl($tpl) {
|
||||
$this->layout_tpl = $tpl;
|
||||
function getTemplatePath() {
|
||||
return $this->template_path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -143,38 +124,19 @@
|
|||
if($act) $this->act = $act;
|
||||
else $this->act = Context::get('act');
|
||||
|
||||
// act의 종류가 disp/proc인지에 대한 확인
|
||||
if($this->act&&strtolower(substr($this->act,0,4)) != 'disp') $this->act_type = 'proc';
|
||||
|
||||
// act값이 없거나 존재하지 않는 method를 호출시에 default_act를 지정
|
||||
if(!$this->act || !$this->isExistsAct($this->act)) $this->act = $this->default_act;
|
||||
|
||||
// module의 *init 호출 (기본 init과 proc/disp init 2가지 있음)
|
||||
if($this->act_type == 'proc') {
|
||||
$output = $this->procInit();
|
||||
if((is_a($output, 'Output') || is_subclass_of($output, 'Output')) && !$output->toBool() ) {
|
||||
$this->setError($output->getError());
|
||||
$this->setMessage($output->getMessage());
|
||||
return;
|
||||
} elseif(!$output) {
|
||||
$this->setError(-1);
|
||||
$this->setMessage('fail');
|
||||
return;
|
||||
}
|
||||
} else $this->dispInit();
|
||||
if(!$this->act || !method_exists($this, $this->act)) $this->act = $this->default_act;
|
||||
|
||||
// 기본 act조차 없으면 return
|
||||
if(!$this->isExistsAct($this->act)) return false;
|
||||
if(!method_exists($this, $this->act)) return false;
|
||||
|
||||
// act값으로 method 실행
|
||||
$output = call_user_method($this->act, $this);
|
||||
|
||||
if(is_a($output, 'Output') || is_subclass_of($output, 'Output')) {
|
||||
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
|
||||
$this->setError($output->getError());
|
||||
$this->setMessage($output->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -3,80 +3,175 @@
|
|||
* @class ModuleHandler
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief mid의 값으로 모듈을 찾아 객체 생성 & 모듈 정보 세팅
|
||||
*
|
||||
* ModuleHandler는 RequestArgument중 $mid 값을 이용하여\n
|
||||
* 모듈을 찾아서 객체를 생성한다.\n
|
||||
* 단 act 값을 이용하여 actType(view, controller)을 판단하여\n
|
||||
* 객체를 생성해야 한다.\n
|
||||
* 그리고 $mid값을 이용 해당 모듈의 config를 읽어와 생성된\n
|
||||
* 모듈 객체에 전달하고 실행까지 진행을 한다.
|
||||
**/
|
||||
|
||||
class ModuleHandler {
|
||||
|
||||
var $mid = NULL; ///< module로 생성한 instance(관리상)의 값
|
||||
var $module_info = NULL; ///< 해당 모듈의 정보
|
||||
|
||||
var $module = NULL; ///< mid로 찾아서 생성한 모듈 class 이름
|
||||
var $oModule = NULL; ///< mid로 찾아서 생성한 모듈의 객체
|
||||
var $oModule = NULL; ///< 모듈 객체
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
*
|
||||
* Request Argument에서 $mid, $act값으로 객체를 찾는다.\n
|
||||
* 단 유연한 처리를 위해 $document_srl 을 이용하기도 한다.
|
||||
**/
|
||||
function ModuleHandler() {
|
||||
function ModuleHandler($module = NULL, $act_type = NULL) {
|
||||
|
||||
// 설치가 안되어 있다면 설치를 위한 준비
|
||||
if(!Context::isInstalled()) return $this->_prepareInstall();
|
||||
// 설치가 안되어 있다면 설치를 위한 준비를 한다
|
||||
if(!Context::isInstalled()) {
|
||||
// install 모듈로 강제 지정
|
||||
$module = 'install';
|
||||
$mid = NULL;
|
||||
|
||||
// 설치가 되어 있다면 요청받은 mid에 해당하는 모듈 instance 생성
|
||||
// Request Argument의 mid값으로 모듈 객체 생성
|
||||
// mid가 없이 document_srl만 있다면 document_srl로 mid를 찾음
|
||||
$mid = Context::get('mid');
|
||||
$document_srl = Context::get('document_srl');
|
||||
} elseif(!$module) {
|
||||
$mid = Context::get('mid');
|
||||
$document_srl = Context::get('document_srl');
|
||||
|
||||
// document_srl만 있다면 mid를 구해옴
|
||||
if(!$mid && $document_srl) {
|
||||
$module_info = module_manager::getModuleInfoByDocument($document_srl);
|
||||
if($module_info) $mid = $module_info->mid;
|
||||
// document_srl만 있다면 mid를 구해옴
|
||||
if(!$mid && $document_srl) $module_info = $this->getModuleInfoByDocumentSrl($document_srl);
|
||||
|
||||
// mid 값에 대한 모듈 정보를 추출
|
||||
if(!$module_info) $module_info = $this->getModuleInfoByMid($mid);
|
||||
|
||||
// 모듈 정보에서 module 이름을 구해움
|
||||
$module = $module_info->module;
|
||||
}
|
||||
|
||||
// mid 값에 대한 모듈 정보를 추출
|
||||
if(!$module_info) $module_info = module_manager::getModuleInfo($mid);
|
||||
// 만약 모듈이 없다면 잘못된 모듈 호출에 대한 오류를 message 모듈을 통해 호출
|
||||
if(!$module) {
|
||||
$module = 'message';
|
||||
$act_type = 'view';
|
||||
Context::set('message', Context::getLang('msg_mid_not_exists'));
|
||||
}
|
||||
|
||||
// 모듈 정보에서 module 이름을 구해움
|
||||
$module = $module_info->module;
|
||||
// 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';
|
||||
}
|
||||
}
|
||||
|
||||
$this->mid = $module_info->mid;
|
||||
$this->module_info = $module_info;
|
||||
// module_info가 없으면 기본적인 값들로 작성
|
||||
if(!$module_info) {
|
||||
$module_info->module = $module;
|
||||
$module_info->module_srl = 0;
|
||||
}
|
||||
|
||||
Context::set('module', $module);
|
||||
Context::set('mid', $this->mid, true);
|
||||
Context::set('module_srl', $this->module_info->module_srl, true);
|
||||
|
||||
// 만약 모듈이 없다면 오류 출력
|
||||
if(!$module) return $this->_moduleIsNotExists();
|
||||
|
||||
$this->oModule = getModule($module);
|
||||
$this->module = $module;
|
||||
// 모듈 객체 생성
|
||||
$this->oModule = &$this->getModuleInstance($module, $act_type, $module_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 설치를 하기 위해서 mid, module등을 강제 지정
|
||||
* @brief document_srl로 모듈의 정보르 구함
|
||||
**/
|
||||
function _prepareInstall() {
|
||||
// module로 install 모듈을 지정
|
||||
$this->module = 'install';
|
||||
Context::set('mid', NULL);
|
||||
Context::set('module', $this->module);
|
||||
function getModuleInfoByDocumentSrl($document_srl) {
|
||||
// DB 객체 생성후 데이터를 DB에서 가져옴
|
||||
$oDB = &DB::getInstance();
|
||||
$args->document_srl = $document_srl;
|
||||
$output = $oDB->executeQuery('module_manager.getModuleInfoByDocument', $args);
|
||||
|
||||
// module_manager 호출
|
||||
$this->oModule = getModule($this->module);
|
||||
// extra_vars의 정리
|
||||
$module_info = module_manager::extractExtraVar($output->data);
|
||||
return $module_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 아무런 설정이 되어 있지 않다면 오류 표시
|
||||
* @brief mid로 모듈의 정보를 구함
|
||||
**/
|
||||
function _moduleIsNotExists() {
|
||||
$this->module = 'message';
|
||||
Context::set('mid', NULL);
|
||||
Context::set('module', $this->module);
|
||||
function getModuleInfo($mid='') {
|
||||
// DB 객체 생성후 데이터를 DB에서 가져옴
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$this->oModule = getModule($this->module);
|
||||
// $mid값이 인자로 주어질 경우 $mid로 모듈의 정보를 구함
|
||||
if($mid) {
|
||||
$args->mid = $mid;
|
||||
$output = $oDB->executeQuery('module_manager.getMidInfo', $args);
|
||||
}
|
||||
|
||||
Context::set('error', -1);
|
||||
Context::set('message', Context::getLang('msg_mid_not_exists'));
|
||||
// 모듈의 정보가 없다면($mid가 잘못이거나 없었을 경우) 기본 모듈을 가져옴
|
||||
if(!$output->data) {
|
||||
$output = $oDB->executeQuery('module_manager.getDefaultMidInfo');
|
||||
}
|
||||
|
||||
// extra_vars의 정리
|
||||
$module_info = module_manager::extractExtraVar($output->data);
|
||||
return $module_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모듈 객체를 생성함
|
||||
**/
|
||||
function getModuleInstance($module, $type = 'view', $module_info = NULL) {
|
||||
// 요청받은 모듈이 있는지 확인
|
||||
$module = strtolower($module);
|
||||
if(!$module) return;
|
||||
|
||||
// global 변수에 미리 생성해 둔 객체가 없으면 새로 생성
|
||||
if(!$GLOBALS['_loaded_module'][$module][$type]) {
|
||||
|
||||
/**
|
||||
* 모듈의 위치를 파악
|
||||
* 기본적으로는 ./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) {
|
||||
case 'controller' :
|
||||
$instance_name = sprintf("%s%s",$module,"Controller");
|
||||
$class_file = sprintf('%s%s.%s.php', $class_path, $module, $type);
|
||||
break;
|
||||
case 'model' :
|
||||
$instance_name = sprintf("%s%s",$module,"Model");
|
||||
$class_file = sprintf('%s%s.%s.php', $class_path, $module, $type);
|
||||
break;
|
||||
default :
|
||||
$type = 'view';
|
||||
$instance_name = sprintf("%s%s",$module,"View");
|
||||
$class_file = sprintf('%s%s.view.php', $class_path, $module, $type);
|
||||
break;
|
||||
}
|
||||
|
||||
// 클래스 파일의 이름을 구함
|
||||
if(!file_exists($class_file)) return NULL;
|
||||
|
||||
// eval로 객체 생성
|
||||
require_once($class_file);
|
||||
$eval_str = sprintf('$oModule = new %s();', $instance_name);
|
||||
@eval($eval_str);
|
||||
if(!is_object($oModule)) return NULL;
|
||||
|
||||
// 생성된 객체에 자신이 호출된 위치를 세팅해줌
|
||||
$oModule->setModulePath($class_path);
|
||||
|
||||
// 모듈 정보 세팅
|
||||
$oModule->setModuleInfo($module_info);
|
||||
|
||||
// 해당 위치에 속한 lang 파일을 읽음
|
||||
Context::loadLang($class_path.'lang');
|
||||
|
||||
// GLOBALS 변수에 생성된 객체 저장
|
||||
$GLOBALS['_loaded_module'][$module][$type] = $oModule;
|
||||
|
||||
}
|
||||
|
||||
// 객체 리턴
|
||||
return $GLOBALS['_loaded_module'][$module][$type];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -85,8 +180,10 @@
|
|||
* 모듈을 실행후에 그 모듈 객체를 return하여 DisplayHandler로 넘겨줌
|
||||
**/
|
||||
function proc() {
|
||||
$this->oModule->moduleInit($this->module_info);
|
||||
if(!is_object($this->oModule)) return;
|
||||
|
||||
$this->oModule->proc();
|
||||
|
||||
return $this->oModule;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* @class Output
|
||||
* @class Object
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief 결과 데이터를 담당하는 class
|
||||
* @brief 모듈간의 데이터를 주고 받기 위한 클래스
|
||||
*
|
||||
* 모듈이나 DB등의 모든 행위의 결과를 담당.\n
|
||||
* 에러 코드를 보관하고 기타 추가 정보가 있을 시에 add/get을 통해\n
|
||||
* parameter를 넘길때도 사용....\n
|
||||
*
|
||||
* @todo 설명이 영.. 안 좋음.. 수정 요망!
|
||||
* @todo result 객체로 사용하면 되는데 왠지 구조적으로 덜 다듬어졌음. 차후 다듬어야 함
|
||||
* Model, Controller, View로 이루어지는 모듈은\n
|
||||
* Object class를 상속받는다.
|
||||
**/
|
||||
|
||||
class Output {
|
||||
|
||||
var $template_path = NULL; ///< template path 지정
|
||||
var $template_file = NULL; ///< template 파일 지정
|
||||
class Object {
|
||||
|
||||
var $error = 0; ///< 에러 코드 (0이면 에러 아님)
|
||||
var $message = 'success'; ///< 에러 메세지 (success이면 에러 아님)
|
||||
|
|
@ -25,7 +18,7 @@
|
|||
/**
|
||||
* @brief constructor
|
||||
**/
|
||||
function Output($error = 0, $message = 'success') {
|
||||
function Object($error = 0, $message = 'success') {
|
||||
$this->error = $error;
|
||||
$this->message = $message;
|
||||
}
|
||||
|
|
@ -95,33 +88,5 @@
|
|||
return $this->toBool();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief tpl 경로을 지정
|
||||
**/
|
||||
function setTemplatePath($path) {
|
||||
if(!substr($path,-1)!='/') $path .= '/';
|
||||
$this->template_path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief tpl 경로를 return
|
||||
**/
|
||||
function getTemplatePath() {
|
||||
return $this->template_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief tpl 파일을 지정
|
||||
**/
|
||||
function setTemplateFile($filename) {
|
||||
$this->template_file = $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief tpl 파일을 지정
|
||||
**/
|
||||
function getTemplateFile() {
|
||||
return $this->template_file;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -155,7 +155,7 @@
|
|||
function _getNotNullCode($name, $var='column') {
|
||||
return
|
||||
sprintf(
|
||||
'if(!$%s->%s) return new Output(-1, sprintf($lang->filter->isnull, $lang->%s?$lang->%s:\'%s\'));'."\n",
|
||||
'if(!$%s->%s) return new Object(-1, sprintf($lang->filter->isnull, $lang->%s?$lang->%s:\'%s\'));'."\n",
|
||||
$var,
|
||||
$name,
|
||||
$name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue