mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
#18947806 : refactor modulehandler, module object for finding module to have single path
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7514 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
d7f1e5bfda
commit
6cfb2be953
2 changed files with 98 additions and 76 deletions
|
|
@ -204,12 +204,84 @@
|
||||||
$kind = strpos(strtolower($this->act),'admin')!==false?'admin':'';
|
$kind = strpos(strtolower($this->act),'admin')!==false?'admin':'';
|
||||||
if(!$kind && $this->module == 'admin') $kind = 'admin';
|
if(!$kind && $this->module == 'admin') $kind = 'admin';
|
||||||
|
|
||||||
// create a module instance
|
// if(type == view, and case for using mobilephone)
|
||||||
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
|
if($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled())
|
||||||
if(!is_object($oModule)) {
|
{
|
||||||
$this->error = 'msg_module_is_not_exists';
|
$orig_type = "view";
|
||||||
return;
|
$type = "mobile";
|
||||||
}
|
// create a module instance
|
||||||
|
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
|
||||||
|
if(!is_object($oModule) || !method_exists($oModule, $this->act)) {
|
||||||
|
$type = $orig_type;
|
||||||
|
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// create a module instance
|
||||||
|
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_object($oModule)) {
|
||||||
|
$this->error = 'msg_module_is_not_exists';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there is no such action in the module object
|
||||||
|
if(!isset($xml_info->action->{$this->act}) || !method_exists($oModule, $this->act))
|
||||||
|
{
|
||||||
|
if(!Context::isInstalled())
|
||||||
|
{
|
||||||
|
$this->error = 'msg_invalid_request';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$forward = null;
|
||||||
|
// 1. Look for the module with action name
|
||||||
|
if(preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches)) {
|
||||||
|
$module = strtolower($matches[2].$matches[3]);
|
||||||
|
$xml_info = $oModuleModel->getModuleActionXml($module);
|
||||||
|
if($xml_info->action->{$this->act}) {
|
||||||
|
$forward->module = $module;
|
||||||
|
$forward->type = $xml_info->action->{$this->act}->type;
|
||||||
|
$forward->act = $this->act;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$forward)
|
||||||
|
{
|
||||||
|
$forward = $oModuleModel->getActionForward($this->act);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($forward->module && $forward->type && $forward->act && $forward->act == $this->act) {
|
||||||
|
|
||||||
|
$kind = strpos(strtolower($forward->act),'admin')!==false?'admin':'';
|
||||||
|
$type = $forward->type;
|
||||||
|
$tpl_path = $oModule->getTemplatePath();
|
||||||
|
$orig_module = $oModule;
|
||||||
|
$oModule = &$this->getModuleInstance($forward->module, $type, $kind);
|
||||||
|
$xml_info = $oModuleModel->getModuleActionXml($forward->module);
|
||||||
|
if($this->module == "admin" && $type == "view")
|
||||||
|
{
|
||||||
|
$oMemberModel = &getModel('member');
|
||||||
|
$logged_info = $oMemberModel->getLoggedInfo();
|
||||||
|
if($logged_info->is_admin=='Y') {
|
||||||
|
$orig_module->loadSideBar();
|
||||||
|
$oModule->setLayoutPath("./modules/admin/tpl");
|
||||||
|
$oModule->setLayoutFile("layout.html");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($xml_info->default_index_act && method_exists($oModule, $xml_info->default_index_act))
|
||||||
|
{
|
||||||
|
$this->act = $xml_info->default_index_act;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error = 'msg_invalid_request';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$oModule->setAct($this->act);
|
$oModule->setAct($this->act);
|
||||||
|
|
||||||
|
|
@ -264,11 +336,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if layout_srl exists for the module
|
// Check if layout_srl exists for the module
|
||||||
if($oModule->module_info->layout_srl && !$oModule->getLayoutFile()) {
|
if(Mobile::isFromMobilePhone())
|
||||||
|
{
|
||||||
|
$layout_srl = $oModule->module_info->mlayout_srl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$layout_srl = $oModule->module_info->layout_srl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($layout_srl && !$oModule->getLayoutFile()) {
|
||||||
|
|
||||||
// If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
|
// If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
|
||||||
$oLayoutModel = &getModel('layout');
|
$oLayoutModel = &getModel('layout');
|
||||||
$layout_info = $oLayoutModel->getLayout($oModule->module_info->layout_srl);
|
$layout_info = $oLayoutModel->getLayout($layout_srl);
|
||||||
if($layout_info) {
|
if($layout_info) {
|
||||||
|
|
||||||
// Input extra_vars into $layout_info
|
// Input extra_vars into $layout_info
|
||||||
|
|
@ -369,10 +450,10 @@
|
||||||
$instance_name = sprintf("%s%s",$module,"WAP");
|
$instance_name = sprintf("%s%s",$module,"WAP");
|
||||||
$class_file = sprintf('%s%s%s.wap.php', _XE_PATH_, $class_path, $module);
|
$class_file = sprintf('%s%s%s.wap.php', _XE_PATH_, $class_path, $module);
|
||||||
break;
|
break;
|
||||||
case 'smartphone' :
|
case 'mobile' :
|
||||||
$instance_name = sprintf("%s%s",$module,"SPhone");
|
$instance_name = sprintf("%s%s",$module,"Mobile");
|
||||||
$class_file = sprintf('%s%s%s.smartphone.php', _XE_PATH_, $class_path, $module);
|
$class_file = sprintf("%s%s%s.mobile.php", _XE_PATH_, $class_path, $module);
|
||||||
break;
|
break;
|
||||||
case 'class' :
|
case 'class' :
|
||||||
$instance_name = $module;
|
$instance_name = $module;
|
||||||
$class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
|
$class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
|
||||||
|
|
|
||||||
|
|
@ -261,70 +261,11 @@
|
||||||
|
|
||||||
// 실행
|
// 실행
|
||||||
$output = $this->{$this->act}();
|
$output = $this->{$this->act}();
|
||||||
|
}
|
||||||
// act이 없으면 action_forward에서 해당하는 act가 있는지 찾아서 대신 실행
|
else {
|
||||||
} else if(Context::isInstalled()) {
|
return false;
|
||||||
$oModuleModel = &getModel('module');
|
}
|
||||||
|
|
||||||
$forward = null;
|
|
||||||
|
|
||||||
// 현재 요청된 action의 대상 모듈을 찾음
|
|
||||||
// 1. action이름으로 검색 (DB검색 없이 하기 위함)
|
|
||||||
if(preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches)) {
|
|
||||||
$module = strtolower($matches[2].$matches[3]);
|
|
||||||
$xml_info = $oModuleModel->getModuleActionXml($module);
|
|
||||||
if($xml_info->action->{$this->act}) {
|
|
||||||
$forward->module = $module;
|
|
||||||
$forward->type = $xml_info->action->{$this->act}->type;
|
|
||||||
$forward->act = $this->act;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 1번에서 찾지 못하면 action forward를 검색
|
|
||||||
if(!$forward) $forward = $oModuleModel->getActionForward($this->act);
|
|
||||||
|
|
||||||
// 찾아진 forward 모듈이 있으면 실행
|
|
||||||
if($forward->module && $forward->type && $forward->act && $forward->act == $this->act) {
|
|
||||||
|
|
||||||
$kind = strpos(strtolower($forward->act),'admin')!==false?'admin':'';
|
|
||||||
|
|
||||||
$oModule = &getModule($forward->module, $forward->type, $kind);
|
|
||||||
$xml_info = $oModuleModel->getModuleActionXml($forward->module);
|
|
||||||
|
|
||||||
$oModule->setAct($forward->act);
|
|
||||||
$oModule->init();
|
|
||||||
if($oModule->stop_proc) return $this->stop($oModule->getMessage());
|
|
||||||
|
|
||||||
$oModule->setModuleInfo($this->module_info, $xml_info);
|
|
||||||
|
|
||||||
if(isset($xml_info->action->{$forward->act}) && method_exists($oModule, $forward->act)) {
|
|
||||||
$output = $oModule->{$forward->act}();
|
|
||||||
} else {
|
|
||||||
return $this->stop("msg_module_is_not_exists");
|
|
||||||
}
|
|
||||||
|
|
||||||
// forward 모듈의 실행 결과 검사
|
|
||||||
if($oModule->stop_proc) return $this->stop($oModule->getMessage());
|
|
||||||
|
|
||||||
$this->setTemplatePath($oModule->getTemplatePath());
|
|
||||||
$this->setTemplateFile($oModule->getTemplateFile());
|
|
||||||
if($oModule->getLayoutFile()) $this->setLayoutFile($oModule->getLayoutFile());
|
|
||||||
|
|
||||||
$this->adds($oModule->getVariables());
|
|
||||||
$this->setMessage($oModule->getMessage());
|
|
||||||
$this->setError($oModule->getError());
|
|
||||||
|
|
||||||
// forward 모듈을 찾지 못했다면 원 모듈의 default index action을 실행
|
|
||||||
} else if($this->xml_info->default_index_act && method_exists($this, $this->xml_info->default_index_act)) {
|
|
||||||
Context::set('act',$this->act = $this->xml_info->default_index_act);
|
|
||||||
$output = $this->{$this->xml_info->default_index_act}();
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// addon 실행(called_position 를 after_module_proc로 하여 호출)
|
// addon 실행(called_position 를 after_module_proc로 하여 호출)
|
||||||
$called_position = 'after_module_proc';
|
$called_position = 'after_module_proc';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue