mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
삭제
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2327 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
commit
8326004cb2
2773 changed files with 91485 additions and 0 deletions
326
classes/module/ModuleHandler.class.php
Normal file
326
classes/module/ModuleHandler.class.php
Normal file
|
|
@ -0,0 +1,326 @@
|
|||
<?php
|
||||
/**
|
||||
* @class ModuleHandler
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief 모듈 핸들링을 위한 Handler
|
||||
*
|
||||
* 모듈을 실행시키기 위한 클래스.
|
||||
* constructor에 아무 인자 없이 객체를 생성하면 현재 요청받은
|
||||
* 상태를 바탕으로 적절한 모듈을 찾게 되고,
|
||||
* 별도의 인자 값을 줄 경우 그에 맞는 모듈을 찾아서 실행한다.
|
||||
* 만약 찾아진 모듈의 요청된 act 가 없으면 action_foward를 참조하여 다른 모듈의 act를 실행한다.
|
||||
**/
|
||||
|
||||
class ModuleHandler extends Handler {
|
||||
|
||||
var $oModule = NULL; ///< 모듈 객체
|
||||
|
||||
var $module = NULL; ///< 모듈
|
||||
var $act = NULL; ///< action
|
||||
var $mid = NULL; ///< 모듈의 객체명
|
||||
var $document_srl = NULL; ///< 문서 번호
|
||||
|
||||
var $module_info = NULL; ///< 모듈의 정보
|
||||
|
||||
var $error = NULL; ///< 진행 도중 에러 발생시 에러 코드를 정의, message 모듈을 호출시 사용
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
*
|
||||
* ModuleHandler에서 사용할 변수를 미리 세팅
|
||||
* 인자를 넘겨주지 않으면 현 페이지 요청받은 Request Arguments를 이용하여
|
||||
* 변수를 세팅한다.
|
||||
**/
|
||||
function ModuleHandler($module = '', $act = '', $mid = '', $document_srl = '') {
|
||||
// 설치가 안되어 있다면 install module을 지정
|
||||
if(!Context::isInstalled()) {
|
||||
$this->module = 'install';
|
||||
$this->act = Context::get('act');
|
||||
return;
|
||||
}
|
||||
|
||||
// Request Argument중 모듈을 찾을 수 있는 변수를 구함
|
||||
if(!$module) $this->module = Context::get('module');
|
||||
else $this->module = $module;
|
||||
|
||||
if(!$act) $this->act = Context::get('act');
|
||||
else $this->act = $act;
|
||||
|
||||
if(!$mid) $this->mid = Context::get('mid');
|
||||
else $this->mid = $mid;
|
||||
|
||||
if(!$document_srl) $this->document_srl = (int)Context::get('document_srl');
|
||||
else $this->document_srl = (int)$document_srl;
|
||||
|
||||
// 기본 변수들의 검사 (XSS방지를 위한 기초적 검사)
|
||||
if($this->module && !eregi("^([a-z0-9\_\-]+)$",$this->module)) die(Context::getLang("msg_invalid_request"));
|
||||
if($this->mid && !eregi("^([a-z0-9\_\-]+)$",$this->mid)) die(Context::getLang("msg_invalid_request"));
|
||||
if($this->act && !eregi("^([a-z0-9\_\-]+)$",$this->act)) die(Context::getLang("msg_invalid_request"));
|
||||
|
||||
// 애드온 실행 (모듈 실행 전)
|
||||
$called_position = 'before_module_init';
|
||||
@include("./files/cache/activated_addons.cache.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief module, mid, document_srl을 이용하여 모듈을 찾고 act를 실행하기 위한 준비를 함
|
||||
**/
|
||||
function init() {
|
||||
// ModuleModel 객체 생성
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
// document_srl이 있으면 document_srl로 모듈과 모듈 정보를 구함
|
||||
if($this->document_srl && !$this->mid) $module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl);
|
||||
if($this->module && $module_info->module != $this->module) unset($module_info);
|
||||
|
||||
// 아직 모듈을 못 찾았고 $mid값이 있으면 $mid로 모듈을 구함
|
||||
if(!$module_info && $this->mid) $module_info = $oModuleModel->getModuleInfoByMid($this->mid);
|
||||
if($this->module && $module_info->module != $this->module) unset($module_info);
|
||||
|
||||
// 역시 모듈을 못 찾았고 $module이 없다면 기본 모듈을 찾아봄
|
||||
if(!$module_info && !$this->module) $module_info = $oModuleModel->getModuleInfoByMid();
|
||||
|
||||
// 모듈 정보가 찾아졌을 경우 모듈 정보에서 기본 변수들을 구함, 모듈 정보에서 module 이름을 구해움
|
||||
if($module_info) {
|
||||
$this->module = $module_info->module;
|
||||
$this->mid = $module_info->mid;
|
||||
$this->module_info = $module_info;
|
||||
Context::setBrowserTitle($module_info->browser_title);
|
||||
}
|
||||
|
||||
// 여기까지도 모듈 정보를 찾지 못했다면 깔끔하게 시스템 오류 표시
|
||||
if(!$this->module) $this->error = 'msg_module_is_not_exists';
|
||||
|
||||
// mid값이 있을 경우 mid값을 세팅
|
||||
if($this->mid) Context::set('mid', $this->mid, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모듈과 관련된 정보를 이용하여 객체를 구하고 act 실행까지 진행시킴
|
||||
**/
|
||||
function procModule() {
|
||||
// 에러가 있으면 return
|
||||
if($this->error) return;
|
||||
|
||||
// ModuleModel 객체 생성
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
// 해당 모듈의 conf/action.xml 을 분석하여 action 정보를 얻어옴
|
||||
$xml_info = $oModuleModel->getModuleActionXml($this->module);
|
||||
|
||||
// 미설치시에는 act값을 강제로 변경
|
||||
if($this->module=="install") {
|
||||
if(!$this->act || !$xml_info->action->{$this->act}) $this->act = $xml_info->default_index_act;
|
||||
}
|
||||
|
||||
// 현재 요청된 act가 있으면 $xml_info에서 type을 찾음, 없다면 기본 action을 이용
|
||||
if(!$this->act) $this->act = $xml_info->default_index_act;
|
||||
|
||||
// act값이 지정이 안되어 있으면 오류 표시
|
||||
if(!$this->act) {
|
||||
$this->error = 'msg_module_is_not_exists';
|
||||
return;
|
||||
}
|
||||
|
||||
// 설정된 mid가 없을 경우 요청된 act의 standalone 여부 체크
|
||||
/*
|
||||
if(!$this->mid && !$xml_info->action->{$this->act}->standalone) {
|
||||
$this->error = 'msg_module_is_not_standalone';
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
// type, grant 값 구함
|
||||
$type = $xml_info->action->{$this->act}->type;
|
||||
$grant = $xml_info->action->{$this->act}->grant;
|
||||
$kind = strpos(strtolower($this->act),'admin')!==false?'admin':'';
|
||||
if(!$kind && $this->module == 'admin') $kind = 'admin';
|
||||
|
||||
// 모듈 객체 생성
|
||||
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
|
||||
if(!is_object($oModule)) {
|
||||
$this->error = 'msg_module_is_not_exists';
|
||||
return;
|
||||
}
|
||||
|
||||
// 모듈에 act값을 세팅
|
||||
$oModule->setAct($this->act);
|
||||
|
||||
// 모듈 정보 세팅
|
||||
$oModule->setModuleInfo($this->module_info, $xml_info);
|
||||
|
||||
// 모듈을 수행하고 결과가 false이면 message 모듈 호출 지정
|
||||
if(!$oModule->proc()) $this->error = $oModule->getMessage();
|
||||
|
||||
return $oModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ 실행된 모듈의 컨텐츠를 출력
|
||||
**/
|
||||
function displayContent($oModule = NULL) {
|
||||
// 설정된 모듈이 정상이지 않을 경우 message 모듈 객체 생성
|
||||
if(!$oModule || !is_object($oModule)) {
|
||||
$this->error = 'msg_module_is_not_exists';
|
||||
}
|
||||
|
||||
// 에러가 발생하였을시 처리
|
||||
if($this->error) {
|
||||
// message 모듈 객체를 생성해서 컨텐츠 생성
|
||||
$oMessageView = &getView('message');
|
||||
$oMessageView->setError(-1);
|
||||
$oMessageView->setMessage($this->error);
|
||||
$oMessageView->dispMessage();
|
||||
|
||||
// 정상적으로 호출된 객체가 있을 경우 해당 객체의 template를 변경
|
||||
if($oModule) {
|
||||
$oModule->setTemplatePath($oMessageView->getTemplatePath());
|
||||
$oModule->setTemplateFile($oMessageView->getTemplateFile());
|
||||
|
||||
// 그렇지 않으면 message 객체를 호출된 객체로 지정
|
||||
} else {
|
||||
$oModule = $oMessageView;
|
||||
}
|
||||
}
|
||||
|
||||
// 해당 모듈에 layout_srl이 있는지 확인
|
||||
if($oModule->module_info->layout_srl && !$oModule->getLayoutFile()) {
|
||||
// layout_srl이 있으면 해당 레이아웃 정보를 가져와 layout_path/ layout_file 위치 변경
|
||||
$oLayoutModel = &getModel('layout');
|
||||
$layout_info = $oLayoutModel->getLayout($oModule->module_info->layout_srl);
|
||||
|
||||
if($layout_info) {
|
||||
|
||||
// 레이아웃 정보중 extra_vars의 이름과 값을 $layout_info에 입력
|
||||
if($layout_info->extra_var_count) {
|
||||
foreach($layout_info->extra_var as $var_id => $val) {
|
||||
$layout_info->{$var_id} = $val->value;
|
||||
}
|
||||
}
|
||||
|
||||
// 레이아웃 정보중 menu를 Context::set
|
||||
if($layout_info->menu_count) {
|
||||
foreach($layout_info->menu as $menu_id => $menu) {
|
||||
if(file_exists($menu->php_file)) @include($menu->php_file);
|
||||
Context::set($menu_id, $menu);
|
||||
}
|
||||
}
|
||||
|
||||
// 레이아웃 정보를 Context::set
|
||||
Context::set('layout_info', $layout_info);
|
||||
|
||||
$oModule->setLayoutPath($layout_info->path);
|
||||
$oModule->setLayoutFile('layout');
|
||||
|
||||
// 레이아웃이 수정되었을 경우 수정본을 지정
|
||||
$edited_layout = sprintf('./files/cache/layout/%d.html', $layout_info->layout_srl);
|
||||
if(file_exists($edited_layout)) $oModule->setEditedLayoutFile($edited_layout);
|
||||
}
|
||||
}
|
||||
|
||||
// 컨텐츠 출력
|
||||
$oDisplayHandler = new DisplayHandler();
|
||||
$oDisplayHandler->printContent($oModule);
|
||||
|
||||
// DB 및 기타 자원의 종결 처리
|
||||
Context::close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief module의 위치를 찾아서 return
|
||||
**/
|
||||
function getModulePath($module) {
|
||||
$class_path = sprintf('./modules/%s/', $module);
|
||||
if(is_dir($class_path)) return $class_path;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모듈 객체를 생성함
|
||||
**/
|
||||
function &getModuleInstance($module, $type = 'view', $kind = '') {
|
||||
$class_path = ModuleHandler::getModulePath($module);
|
||||
if(!$class_path) return NULL;
|
||||
|
||||
if(__DEBUG__==3) $start_time = getMicroTime();
|
||||
|
||||
if($kind != 'admin') $kind = 'svc';
|
||||
|
||||
// global 변수에 미리 생성해 둔 객체가 없으면 새로 생성
|
||||
if(!$GLOBALS['_loaded_module'][$module][$type][$kind]) {
|
||||
|
||||
/**
|
||||
* 모듈의 위치를 파악
|
||||
**/
|
||||
|
||||
// 상위 클래스명 구함
|
||||
if(!class_exists($module)) {
|
||||
$high_class_file = sprintf('%s%s.class.php', $class_path, $module);
|
||||
if(!file_exists($high_class_file)) return NULL;
|
||||
require_once($high_class_file);
|
||||
}
|
||||
|
||||
// 객체의 이름을 구함
|
||||
switch($type) {
|
||||
case 'controller' :
|
||||
if($kind == 'admin') {
|
||||
$instance_name = sprintf("%sAdmin%s",$module,"Controller");
|
||||
$class_file = sprintf('%s%s.admin.%s.php', $class_path, $module, $type);
|
||||
} else {
|
||||
$instance_name = sprintf("%s%s",$module,"Controller");
|
||||
$class_file = sprintf('%s%s.%s.php', $class_path, $module, $type);
|
||||
}
|
||||
break;
|
||||
case 'model' :
|
||||
if($kind == 'admin') {
|
||||
$instance_name = sprintf("%sAdmin%s",$module,"Model");
|
||||
$class_file = sprintf('%s%s.admin.%s.php', $class_path, $module, $type);
|
||||
} else {
|
||||
$instance_name = sprintf("%s%s",$module,"Model");
|
||||
$class_file = sprintf('%s%s.%s.php', $class_path, $module, $type);
|
||||
}
|
||||
break;
|
||||
case 'class' :
|
||||
$instance_name = $module;
|
||||
$class_file = sprintf('%s%s.class.php', $class_path, $module);
|
||||
break;
|
||||
default :
|
||||
$type = 'view';
|
||||
if($kind == 'admin') {
|
||||
$instance_name = sprintf("%sAdmin%s",$module,"View");
|
||||
$class_file = sprintf('%s%s.admin.view.php', $class_path, $module, $type);
|
||||
} else {
|
||||
$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;
|
||||
|
||||
// 해당 위치에 속한 lang 파일을 읽음
|
||||
Context::loadLang($class_path.'lang');
|
||||
|
||||
// 생성된 객체에 자신이 호출된 위치를 세팅해줌
|
||||
$oModule->setModule($module);
|
||||
$oModule->setModulePath($class_path);
|
||||
|
||||
// GLOBALS 변수에 생성된 객체 저장
|
||||
$GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
|
||||
}
|
||||
|
||||
if(__DEBUG__==3) $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
|
||||
|
||||
// 객체 리턴
|
||||
return $GLOBALS['_loaded_module'][$module][$type][$kind];
|
||||
}
|
||||
}
|
||||
?>
|
||||
342
classes/module/ModuleObject.class.php
Normal file
342
classes/module/ModuleObject.class.php
Normal file
|
|
@ -0,0 +1,342 @@
|
|||
<?php
|
||||
/**
|
||||
* @class ModuleObject
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief module의 상위 클래스
|
||||
**/
|
||||
|
||||
class ModuleObject extends Object {
|
||||
|
||||
var $mid = NULL; ///< module로 생성한 instance(관리상)의 값
|
||||
var $module = NULL; ///< mid로 찾아서 생성한 모듈 class 이름
|
||||
var $module_srl = NULL; ///< 모듈 객체의 고유값인 module_srl
|
||||
var $module_info = NULL; ///< 모듈의 설정 정보
|
||||
var $xml_info = NULL; ///< 모듈 자체 정보
|
||||
|
||||
var $module_path = NULL; ///< 모듈 class file의 실행 위치
|
||||
|
||||
var $act = NULL; ///< act 값
|
||||
|
||||
var $template_path = NULL; ///< template 경로
|
||||
var $template_file = NULL; ///< template 파일
|
||||
|
||||
var $layout_path = ''; ///< 레이아웃 경로
|
||||
var $layout_file = ''; ///< 레이아웃 파일
|
||||
var $edited_layout_file = ''; ///< 관리자 모드에서 수정된 레이아웃 파일
|
||||
|
||||
var $stop_proc = false; ///< action 수행중 stop()를 호출하면 ModuleObject::proc()를 수행하지 않음
|
||||
|
||||
/**
|
||||
* @brief 현재 모듈의 이름을 지정
|
||||
**/
|
||||
function setModule($module) {
|
||||
$this->module = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 현재 모듈의 path를 지정
|
||||
**/
|
||||
function setModulePath($path) {
|
||||
if(substr($path,-1)!='/') $path.='/';
|
||||
$this->module_path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief redirect_url을 정함
|
||||
*
|
||||
* redirect_url의 경우 ajax로 request를 받았을 경우에 사용하면 됨...
|
||||
**/
|
||||
function setRedirectUrl($url='./') {
|
||||
$this->add('redirect_url', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 현재 페이지를 refresh시킴
|
||||
*
|
||||
* 공통 tpl중 refresh.html을 실행할 뿐..
|
||||
**/
|
||||
function setRefreshPage() {
|
||||
$this->setTemplatePath('./common/tpl');
|
||||
$this->setTemplateFile('refresh');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief act값 지정
|
||||
**/
|
||||
function setAct($act) {
|
||||
$this->act = $act;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모듈의 정보 세팅
|
||||
**/
|
||||
function setModuleInfo($module_info, $xml_info) {
|
||||
// 기본 변수 설정
|
||||
$this->mid = $module_info->mid;
|
||||
$this->module_srl = $module_info->module_srl;
|
||||
$this->module_info = $module_info;
|
||||
$this->xml_info = $xml_info;
|
||||
$this->skin_vars = $module_info->skin_vars;
|
||||
|
||||
// 웹서비스에서 꼭 필요한 인증 정보와 권한 설정 체크
|
||||
$is_logged = Context::get('is_logged');
|
||||
$logged_info = Context::get('logged_info');
|
||||
$user_id = $logged_info->user_id;
|
||||
$user_group = $logged_info->group_list;
|
||||
|
||||
// 로그인되어 있다면 admin 체크
|
||||
if($is_logged && ($logged_info->is_admin == 'Y' || (is_array($this->module_info->admin_id)&&in_array($user_id, $this->module_info->admin_id) )) ) {
|
||||
$grant->is_admin = true;
|
||||
} else {
|
||||
$grant->is_admin = false;
|
||||
}
|
||||
|
||||
// act값에 admin이 들어 있는데 관리자가 아닌 경우 오류 표시
|
||||
if(substr_count($this->act, 'Admin')) {
|
||||
if(!$is_logged) {
|
||||
$this->setAct("dispMemberLoginForm");
|
||||
} elseif(!$grant->is_admin) {
|
||||
return $this->stop('msg_not_permitted_act');
|
||||
}
|
||||
}
|
||||
|
||||
if($module_info->grants) {
|
||||
foreach($module_info->grants as $key => $val) {
|
||||
if(!$xml_info->grant->{$key}) {
|
||||
$xml_info->grant->{$key}->title = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 권한 설정
|
||||
if($xml_info->grant) {
|
||||
|
||||
// 이 모듈에 action.xml에서 선언된 권한 목록을 루프
|
||||
foreach($xml_info->grant as $grant_name => $grant_item) {
|
||||
|
||||
// 제목과 기타 설정 없을 경우의 기본 권한(guest, member, root)에 대한 변수 설정
|
||||
$title = $grant_item->title;
|
||||
$default = $grant_item->default;
|
||||
|
||||
// 관리자이면 모든 권한에 대해 true 설정
|
||||
if($grant->is_admin) {
|
||||
$grant->{$grant_name} = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 일단 현재 권한에 대해 false 지정
|
||||
$grant->{$grant_name} = false;
|
||||
|
||||
// 모듈의 개별 설정에서 이 권한에 대한 그룹 지정이 있으면 체크
|
||||
if(count($this->module_info->grants[$grant_name])) {
|
||||
$group_srls = $this->module_info->grants[$grant_name];
|
||||
if(!is_array($group_srls)) $group_srls = array($group_srls);
|
||||
|
||||
if(count($user_group)) {
|
||||
foreach($user_group as $group_srl => $group_title) {
|
||||
if(in_array($group_srl, $group_srls)) {
|
||||
$grant->{$grant_name} = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 별도의 지정이 없으면 default값으로 권한 체크
|
||||
} else {
|
||||
switch($default) {
|
||||
case 'member' :
|
||||
if($is_logged) $grant->{$grant_name} = true;
|
||||
break;
|
||||
case 'root' :
|
||||
if($grant->is_admin) $grant->{$grant_name} = true;
|
||||
break;
|
||||
default :
|
||||
$grant->{$grant_name} = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 권한변수 설정
|
||||
$this->grant = $grant;
|
||||
Context::set('grant', $grant);
|
||||
|
||||
if(method_exists($this, 'init')) $this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 메세지 출력
|
||||
**/
|
||||
function stop($msg_code) {
|
||||
// proc 수행을 중지 시키기 위한 플래그 세팅
|
||||
$this->stop_proc = true;
|
||||
|
||||
// 에러 처리
|
||||
$this->setError(-1);
|
||||
$this->setMessage($msg_code);
|
||||
|
||||
// message 모듈의 에러 표시
|
||||
$oMessageView = &getView('message');
|
||||
$oMessageView->setError(-1);
|
||||
$oMessageView->setMessage($msg_code);
|
||||
$oMessageView->dispMessage();
|
||||
|
||||
$this->setTemplatePath($oMessageView->getTemplatePath());
|
||||
$this->setTemplateFile($oMessageView->getTemplateFile());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief template 파일 지정
|
||||
**/
|
||||
function setTemplateFile($filename) {
|
||||
if(substr($filename,-5)!='.html') $filename .= '.html';
|
||||
$this->template_file = $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief template 파일 return
|
||||
**/
|
||||
function getTemplateFile() {
|
||||
return $this->template_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief template 경로 지정
|
||||
**/
|
||||
function setTemplatePath($path) {
|
||||
if(substr($path,0,2)!='./') $path = './'.$path;
|
||||
if(substr($path,-1)!='/') $path .= '/';
|
||||
$this->template_path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief template 경로 return
|
||||
**/
|
||||
function getTemplatePath() {
|
||||
return $this->template_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief edited layout 파일 지정
|
||||
**/
|
||||
function setEditedLayoutFile($filename) {
|
||||
if(substr($filename,-5)!='.html') $filename .= '.html';
|
||||
$this->edited_layout_file = $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief layout 파일 return
|
||||
**/
|
||||
function getEditedLayoutFile() {
|
||||
return $this->edited_layout_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief layout 파일 지정
|
||||
**/
|
||||
function setLayoutFile($filename) {
|
||||
if(substr($filename,-5)!='.html') $filename .= '.html';
|
||||
$this->layout_file = $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief layout 파일 return
|
||||
**/
|
||||
function getLayoutFile() {
|
||||
return $this->layout_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief layout 경로 지정
|
||||
**/
|
||||
function setLayoutPath($path) {
|
||||
if(substr($path,-1)!='/') $path .= '/';
|
||||
if(substr($path,0,2)!='./') $path = './'.$path;
|
||||
$this->layout_path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief layout 경로 return
|
||||
**/
|
||||
function getLayoutPath() {
|
||||
return $this->layout_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모듈의 action에 해당하는 method를 실행
|
||||
*
|
||||
* $act값에 의해서 $action_list에 선언된 것들을 실행한다
|
||||
**/
|
||||
function proc() {
|
||||
// stop_proc==true이면 그냥 패스
|
||||
if($this->stop_proc==true) return false;
|
||||
|
||||
// addon 실행(called_position 를 before_module_proc로 하여 호출)
|
||||
$called_position = 'before_module_proc';
|
||||
@include("./files/cache/activated_addons.cache.php");
|
||||
|
||||
// 지금까지 이상이 없었다면 action 실행
|
||||
if(!$this->stop_proc) {
|
||||
// 현재 모듈에 act값이 있으면 해당 act를 실행
|
||||
if(method_exists($this, $this->act)) {
|
||||
//$output = call_user_method($this->act, $this);
|
||||
//$output = call_user_func(array($this, $this->act));
|
||||
$output = $this->{$this->act}();
|
||||
|
||||
// act가 없으면 action_forward에서 해당하는 act가 있는지 찾아서 대신 실행
|
||||
} else if(Context::isInstalled()) {
|
||||
|
||||
$oModuleModel = &getModel('module');
|
||||
$forward = $oModuleModel->getActionForward($this->act);
|
||||
if($forward->module && $forward->type && $forward->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();
|
||||
$oModule->setModuleInfo($this->module_info, $xml_info);
|
||||
|
||||
//$output = call_user_method($forward->act, $oModule);
|
||||
//$output = call_user_func(array($oModule, $forward->act));
|
||||
$output = $oModule->{$forward->act}();
|
||||
|
||||
$this->setTemplatePath($oModule->getTemplatePath());
|
||||
$this->setTemplateFile($oModule->getTemplateFile());
|
||||
|
||||
} else {
|
||||
if($this->xml_info->default_index_act) {
|
||||
//$output = call_user_method($this->xml_info->default_index_act, $this);
|
||||
//$output = call_user_func(array($this, $this->xml_info->default_index_act));
|
||||
if(method_exists($this, $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로 하여 호출)
|
||||
$called_position = 'after_module_proc';
|
||||
@include("./files/cache/activated_addons.cache.php");
|
||||
|
||||
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
|
||||
$this->setError($output->getError());
|
||||
$this->setMessage($output->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue