From c690cff0c805c9fcae00981f5cd29dd86038ffba Mon Sep 17 00:00:00 2001 From: zero Date: Wed, 14 Feb 2007 09:52:04 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@25 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/context/Context.class.php | 17 +- classes/db/DB.class.php | 42 +- classes/db/DBMysql.class.php | 4 +- classes/display/DisplayHandler.class.php | 2 +- classes/module/Module.class.php | 134 +-- classes/module/ModuleHandler.class.php | 191 ++- .../Object.class.php} | 47 +- classes/xml/XmlQueryParser.class.php | 2 +- config/config.inc.php | 5 +- config/func.inc.php | 6 +- index.php | 19 +- modules/document/document.controller.php | 1063 ++++++++--------- modules/install/install.controller.php | 208 ++++ .../install/{module.xml => install.info.xml} | 0 modules/install/install.module.php | 265 ---- modules/install/install.view.php | 51 + modules/member/member.model.php | 188 +++ 17 files changed, 1216 insertions(+), 1028 deletions(-) rename classes/{output/Output.class.php => object/Object.class.php} (59%) create mode 100644 modules/install/install.controller.php rename modules/install/{module.xml => install.info.xml} (100%) delete mode 100644 modules/install/install.module.php create mode 100644 modules/install/install.view.php create mode 100644 modules/member/member.model.php diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 541892487..738a43d06 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -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); + } } /** diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php index 9380fbb4f..a35ce492d 100644 --- a/classes/db/DB.class.php +++ b/classes/db/DB.class.php @@ -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(); } /** diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php index e8f68314f..d2ba95c1d 100644 --- a/classes/db/DBMysql.class.php +++ b/classes/db/DBMysql.class.php @@ -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; diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php index bb4825b1b..b6832fc38 100644 --- a/classes/display/DisplayHandler.class.php +++ b/classes/display/DisplayHandler.class.php @@ -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; } diff --git a/classes/module/Module.class.php b/classes/module/Module.class.php index 7f0e4bffd..52d8270ec 100644 --- a/classes/module/Module.class.php +++ b/classes/module/Module.class.php @@ -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; } } ?> diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 34312aa63..ec02a1b88 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -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; } } diff --git a/classes/output/Output.class.php b/classes/object/Object.class.php similarity index 59% rename from classes/output/Output.class.php rename to classes/object/Object.class.php index 56f24d327..8046021eb 100644 --- a/classes/output/Output.class.php +++ b/classes/object/Object.class.php @@ -1,21 +1,14 @@ 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; - } } ?> diff --git a/classes/xml/XmlQueryParser.class.php b/classes/xml/XmlQueryParser.class.php index 65adc40da..b03ef64f5 100644 --- a/classes/xml/XmlQueryParser.class.php +++ b/classes/xml/XmlQueryParser.class.php @@ -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, diff --git a/config/config.inc.php b/config/config.inc.php index ef1df88ce..a7b88269b 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -37,11 +37,10 @@ require_once("./classes/context/Context.class.php"); require_once("./classes/db/DB.class.php"); require_once("./classes/file/FileHandler.class.php"); - require_once("./classes/output/Output.class.php"); + require_once("./classes/object/Object.class.php"); require_once("./classes/module/Module.class.php"); - require_once("./classes/display/DisplayHandler.class.php"); require_once("./classes/module/ModuleHandler.class.php"); - require_once('./modules/module_manager/module_manager.module.php'); + require_once("./classes/display/DisplayHandler.class.php"); //require_once("./classes/addon/AddOnHandler.class.php"); //require_once("./classes/layout/LayoutHandler.class.php"); if(__DEBUG__) define('__RequireClassEndTime__', getMicroTime()); diff --git a/config/func.inc.php b/config/func.inc.php index 6c05cf9ea..5ce1def85 100644 --- a/config/func.inc.php +++ b/config/func.inc.php @@ -17,13 +17,13 @@ } /** - * @brief module_manager::getModuleObject($module_name, $act_type)을 쓰기 쉽게 함수로 선언 + * @brief ModuleHandler::getModuleObject($module_name, $act_type)을 쓰기 쉽게 함수로 선언 * @param module_name 모듈이름 * @param act_type disp, proc, lib(기본), admin * @return module instance **/ - function getModule($module_name, $act_type = 'lib') { - return module_manager::getModuleObject($module_name, $act_type); + function getModule($module_name, $act_type = 'view') { + return ModuleHandler::getModuleInstance($module_name, $act_type); } diff --git a/index.php b/index.php index 2f3e6b5a0..a372b8695 100644 --- a/index.php +++ b/index.php @@ -31,18 +31,29 @@ /** * @brief ModuleHandler 객체를 생성 + * + * 모듈 핸들러는 Request Argument를 바탕으로 모듈을 찾아서\n + * 객체를 생성하고 기본 정보를 setting 해줌\n + * ModuleHandler는 이 외에도 설치가 되어 있는지에 대한 체크를\n + * 하여 미설치시 Install 모듈을 실행하도록 한다\n **/ $oModuleHandler = new ModuleHandler(); /** - * @brief ModuleHandler 객체를 를 실행하여 요청받은 모듈 객체를\n - * 찾고 모듈 정보를 세팅하는 등의 역할을 한후 모듈 객체를\n - * return받음 + * @brief ModuleHandler에서 모듈 객체를 받는다 + * + * ModuleHandler는 찾아진 모듈 객체를 이용하여 주어진 act에 해당하는\n + * method를 찾아서 실행을 모두 시킨후에 모듈 객체를 return 한다.\n + * 이 모듈 객체는 DisplayHandler에 의해 content 출력시 사용된다. **/ - $oModule = $oModuleHandler->proc(); + $oModule = &$oModuleHandler->proc(); /** * @brief DisplayHandler 객체를 생성하여 모듈의 처리 결과를 출력 + * + * ModuleHandler에 의해 주어진 모듈 객체는 Object 클래스의 상속을 받으므로\n + * RequestMethod의 종류(GET/POST/XML)에 따라 적절한 헤더 정보를 발송하고\n + * XML 데이터 혹은 HTML 데이터를 출력한다 **/ $oDisplayHandler = new DisplayHandler(); $oDisplayHandler->printContent($oModule); diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 0e58ab999..ec26f7e63 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -1,702 +1,671 @@ - * @desc : 기본 모듈중의 하나인 document module - * Module class에서 상속을 받아서 사용 - * action 의 경우 disp/proc 2가지만 존재하며 이는 action명세서에 - * 미리 기록을 하여야 함 - **/ - - class document extends Module { - /** - * 모듈의 정보 - **/ - var $cur_version = "20070130_0.01"; - - // 공지사항의 고정된 list_order - var $notice_list_order = -1000000000; - - /** - * 기본 action 지정 - * $act값이 없거나 잘못된 값이 들어올 경우 $default_act 값으로 진행 - **/ - var $default_act = ''; - - /** - * 현재 모듈의 초기화를 위한 작업을 지정해 놓은 method - * css/js파일의 load라든지 lang파일 load등을 미리 선언 + * @class documentController + * @author zero (zero@nzeo.com) + * @brief document 모듈의 controller * - * Init() => 공통 - * dispInit() => disp시에 - * procInit() => proc시에 - * - * $this->module_path는 현재 이 모듈파일의 위치를 나타낸다 - * (ex: $this->module_path = "./modules/install/"; + * document의 생성/수정/삭제와 관련된 action 수행 **/ - // 초기화 - function init() {/*{{{*/ - //Context::loadLang($this->module_path.'lang'); - }/*}}}*/ + class documentController extends Controller { - // disp 초기화 - function dispInit() {/*{{{*/ - }/*}}}*/ - - // proc 초기화 - function procInit() {/*{{{*/ - }/*}}}*/ + var $notice_list_order = -1000000000; ///< 공지사항의 고정된 list_order - /** - * 여기서부터는 action의 구현 - * request parameter의 경우 각 method의 첫번째 인자로 넘어온다 - * - * dispXXXX : 출력을 위한 method, output에 tpl file이 지정되어야 한다 - * procXXXX : 처리를 위한 method, output에는 document, document가 지정되어야 한다 - **/ + /** + * @brief constructor + **/ + function documentController() { + parent::Controller(); + } - /** - * 여기부터는 이 모듈과 관련된 라이브러리 개념의 method들 - **/ + /** + * 여기서부터는 action의 구현 + * request parameter의 경우 각 method의 첫번째 인자로 넘어온다 + * + * dispXXXX : 출력을 위한 method, output에 tpl file이 지정되어야 한다 + * procXXXX : 처리를 위한 method, output에는 document, document가 지정되어야 한다 + **/ - // 문서의 권한 부여 - // 세션값으로 현 접속상태에서만 사용 가능 - // public void addGrant($document_srl) {/*{{{*/ - function addGrant($document_srl) { - $_SESSION['own_document'][$document_srl] = true; - }/*}}}*/ + /** + * 여기부터는 이 모듈과 관련된 라이브러리 개념의 method들 + **/ - // public void isGranted($document_srl) {/*{{{*/ - function isGranted($document_srl) { - return $_SESSION['own_document'][$document_srl]; - }/*}}}*/ + // 문서의 권한 부여 + // 세션값으로 현 접속상태에서만 사용 가능 + // public void addGrant($document_srl) { + function addGrant($document_srl) { + $_SESSION['own_document'][$document_srl] = true; + } - // 문서 - // public object insertDocument($obj)/*{{{*/ - // 문서 입력 - function insertDocument($obj) { - // 입력 - $oDB = &DB::getInstance(); + // public void isGranted($document_srl) { + function isGranted($document_srl) { + return $_SESSION['own_document'][$document_srl]; + } - // 카테고리가 있나 검사하여 없는 카테고리면 0으로 세팅 - if($obj->category_srl) { + // 문서 + // public object insertDocument($obj) + // 문서 입력 + function insertDocument($obj) { + // 입력 + $oDB = &DB::getInstance(); + + // 카테고리가 있나 검사하여 없는 카테고리면 0으로 세팅 + if($obj->category_srl) { $category_list = $this->getCategoryList($obj->module_srl); if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; - } + } - // 태그 처리 - $oTag = getModule('tag'); - $obj->tags = $oTag->insertTag($obj->module_srl, $obj->document_srl, $obj->tags); + // 태그 처리 + $oTag = getModule('tag'); + $obj->tags = $oTag->insertTag($obj->module_srl, $obj->document_srl, $obj->tags); - // 글 입력 - $obj->readed_count = 0; - $obj->update_order = $obj->list_order = $obj->document_srl * -1; - if($obj->password) $obj->password = md5($obj->password); + // 글 입력 + $obj->readed_count = 0; + $obj->update_order = $obj->list_order = $obj->document_srl * -1; + if($obj->password) $obj->password = md5($obj->password); - // 공지사항일 경우 list_order에 무지막지한 값;;을 입력 - if($obj->is_notice=='Y') $obj->list_order = $this->notice_list_order; + // 공지사항일 경우 list_order에 무지막지한 값;;을 입력 + if($obj->is_notice=='Y') $obj->list_order = $this->notice_list_order; - // DB에 입력 - $output = $oDB->executeQuery('document.insertDocument', $obj); + // DB에 입력 + $output = $oDB->executeQuery('document.insertDocument', $obj); - if(!$output->toBool()) return $output; + if(!$output->toBool()) return $output; - // 성공하였을 경우 category_srl이 있으면 카테고리 update - if($obj->category_srl) $this->updateCategoryCount($obj->category_srl); + // 성공하였을 경우 category_srl이 있으면 카테고리 update + if($obj->category_srl) $this->updateCategoryCount($obj->category_srl); - // return - $this->addGrant($obj->document_srl); - $output->add('document_srl',$obj->document_srl); - $output->add('category_srl',$obj->category_srl); - return $output; - }/*}}}*/ + // return + $this->addGrant($obj->document_srl); + $output->add('document_srl',$obj->document_srl); + $output->add('category_srl',$obj->category_srl); + return $output; + } - // public object updateDocument($source_obj, $obj)/*{{{*/ - // 문서 수정 - function updateDocument($source_obj, $obj) { - // 카테고리가 변경되었으면 검사후 없는 카테고리면 0으로 세팅 - if($source_obj->category_srl!=$obj->category_srl) { + // public object updateDocument($source_obj, $obj) + // 문서 수정 + function updateDocument($source_obj, $obj) { + // 카테고리가 변경되었으면 검사후 없는 카테고리면 0으로 세팅 + if($source_obj->category_srl!=$obj->category_srl) { $category_list = $this->getCategoryList($obj->module_srl); if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; - } + } - // 태그 처리 - $oTag = getModule('tag'); - $obj->tags = $oTag->insertTag($obj->module_srl, $obj->document_srl, $obj->tags); + // 태그 처리 + $oTag = getModule('tag'); + $obj->tags = $oTag->insertTag($obj->module_srl, $obj->document_srl, $obj->tags); - // 수정 - $oDB = &DB::getInstance(); - $obj->update_order = $oDB->getNextSequence() * -1; + // 수정 + $oDB = &DB::getInstance(); + $obj->update_order = $oDB->getNextSequence() * -1; - // 공지사항일 경우 list_order에 무지막지한 값을, 그렇지 않으면 document_srl*-1값을 - if($obj->is_notice=='Y') $obj->list_order = $this->notice_list_order; - else $obj->list_order = $obj->document_srl*-1; + // 공지사항일 경우 list_order에 무지막지한 값을, 그렇지 않으면 document_srl*-1값을 + if($obj->is_notice=='Y') $obj->list_order = $this->notice_list_order; + else $obj->list_order = $obj->document_srl*-1; - if($obj->password) $obj->password = md5($obj->password); + if($obj->password) $obj->password = md5($obj->password); - // DB에 입력 - $output = $oDB->executeQuery('document.updateDocument', $obj); + // DB에 입력 + $output = $oDB->executeQuery('document.updateDocument', $obj); - if(!$output->toBool()) return $output; + if(!$output->toBool()) return $output; - // 성공하였을 경우 category_srl이 있으면 카테고리 update - if($source_obj->category_srl!=$obj->category_srl) { + // 성공하였을 경우 category_srl이 있으면 카테고리 update + if($source_obj->category_srl!=$obj->category_srl) { if($source_obj->category_srl) $this->updateCategoryCount($source_obj->category_srl); if($obj->category_srl) $this->updateCategoryCount($obj->category_srl); - } + } - $output->add('document_srl',$obj->document_srl); - return $output; - }/*}}}*/ + $output->add('document_srl',$obj->document_srl); + return $output; + } - // public object deleteDocument($obj)/*{{{*/ - // 문서 삭제 - function deleteDocument($obj) { - // 변수 세팅 - $document_srl = $obj->document_srl; - $category_srl = $obj->category_srl; + // public object deleteDocument($obj) + // 문서 삭제 + function deleteDocument($obj) { + // 변수 세팅 + $document_srl = $obj->document_srl; + $category_srl = $obj->category_srl; - // 기존 문서가 있는지 확인 - $document = $this->getDocument($document_srl); - if($document->document_srl != $document_srl) return false; + // 기존 문서가 있는지 확인 + $document = $this->getDocument($document_srl); + if($document->document_srl != $document_srl) return false; - // 권한이 있는지 확인 - if(!$document->is_granted) return new Output(-1, 'msg_not_permitted'); + // 권한이 있는지 확인 + if(!$document->is_granted) return new Output(-1, 'msg_not_permitted'); - // 글 삭제 - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.deleteDocument', $args); - if(!$output->toBool()) return $output; + // 글 삭제 + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $output = $oDB->executeQuery('document.deleteDocument', $args); + if(!$output->toBool()) return $output; - // 댓글 삭제 - $oComment = getModule('comment'); - $output = $oComment->deleteComments($document_srl); + // 댓글 삭제 + $oComment = getModule('comment'); + $output = $oComment->deleteComments($document_srl); - // 엮인글 삭제 - $oTrackback = getModule('trackback'); - $output = $oTrackback->deleteTrackbacks($document_srl); + // 엮인글 삭제 + $oTrackback = getModule('trackback'); + $output = $oTrackback->deleteTrackbacks($document_srl); - // 태그 삭제 - $oTag = getModule('tag'); - $oTag->deleteTag($document_srl); + // 태그 삭제 + $oTag = getModule('tag'); + $oTag->deleteTag($document_srl); - // 첨부 파일 삭제 - if($document->uploaded_count) $this->deleteFiles($document->module_srl, $document_srl); + // 첨부 파일 삭제 + if($document->uploaded_count) $this->deleteFiles($document->module_srl, $document_srl); - // 카테고리가 있으면 카테고리 정보 변경 - if($document->category_srl) $this->updateCategoryCount($document->category_srl); + // 카테고리가 있으면 카테고리 정보 변경 + if($document->category_srl) $this->updateCategoryCount($document->category_srl); - return $output; - }/*}}}*/ + return $output; + } - // public object deleteModuleDocument($module_srl) /*{{{*/ - function deleteModuleDocument($module_srl) { - $args->module_srl = $module_srl; - $oDB = &DB::getInstance(); - $output = $oDB->executeQuery('document.deleteModuleDocument', $args); - return $output; - }/*}}}*/ + // public object deleteModuleDocument($module_srl) + function deleteModuleDocument($module_srl) { + $args->module_srl = $module_srl; + $oDB = &DB::getInstance(); + $output = $oDB->executeQuery('document.deleteModuleDocument', $args); + return $output; + } - // public object getDocument($document_srl)/*{{{*/ - // 문서 가져오기 - function getDocument($document_srl) { - // DB에서 가져옴 - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.getDocument', $args); - $document = $output->data; + // public object getDocument($document_srl) + // 문서 가져오기 + function getDocument($document_srl) { + // DB에서 가져옴 + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $output = $oDB->executeQuery('document.getDocument', $args); + $document = $output->data; - // 이 문서에 대한 권한이 있는지 확인 - if($this->isGranted($document->document_srl)) { + // 이 문서에 대한 권한이 있는지 확인 + if($this->isGranted($document->document_srl)) { $document->is_granted = true; - } elseif($document->member_srl) { + } elseif($document->member_srl) { $oMember = getModule('member'); $member_srl = $oMember->getMemberSrl(); if($member_srl && $member_srl ==$document->member_srl) $document->is_granted = true; - } - return $document; - }/*}}}*/ + } + return $document; + } - // public object getDocuments($document_srl_list)/*{{{*/ - // 여러개의 문서들을 가져옴 (페이징 아님) - function getDocuments($document_srl_list) { - if(is_array($document_srl_list)) $document_srls = implode(',',$document_srl_list); + // public object getDocuments($document_srl_list) + // 여러개의 문서들을 가져옴 (페이징 아님) + function getDocuments($document_srl_list) { + if(is_array($document_srl_list)) $document_srls = implode(',',$document_srl_list); - // DB에서 가져옴 - $oDB = &DB::getInstance(); - $args->document_srls = $document_srls; - $output = $oDB->executeQuery('document.getDocuments', $args); - $document_list = $output->data; - if(!$document_list) return; + // DB에서 가져옴 + $oDB = &DB::getInstance(); + $args->document_srls = $document_srls; + $output = $oDB->executeQuery('document.getDocuments', $args); + $document_list = $output->data; + if(!$document_list) return; - // 권한 체크 - $oMember = getModule('member'); - $member_srl = $oMember->getMemberSrl(); + // 권한 체크 + $oMember = getModule('member'); + $member_srl = $oMember->getMemberSrl(); - $document_count = count($document_list); - for($i=0;$i<$document_count;$i++) { + $document_count = count($document_list); + for($i=0;$i<$document_count;$i++) { $document = $document_list[$i]; $is_granted = false; if($this->isGranted($document->document_srl)) { - $is_granted = true; + $is_granted = true; } elseif($member_srl && $member_srl == $document->member_srl) { - $is_granted = true; + $is_granted = true; } $document_list[$i]->is_granted = $is_granted; - } - return $document_list; - }/*}}}*/ + } + return $document_list; + } - // public object getDocumentCount($module_srl, $search_obj = NULL)/*{{{*/ - // module_srl에 해당하는 문서의 전체 갯수를 가져옴 - function getDocumentCount($module_srl, $search_obj = NULL) { - $oDB = &DB::getInstance(); + // public object getDocumentCount($module_srl, $search_obj = NULL) + // module_srl에 해당하는 문서의 전체 갯수를 가져옴 + function getDocumentCount($module_srl, $search_obj = NULL) { + $oDB = &DB::getInstance(); - $args->module_srl = $module_srl; - $args->s_title = $search_obj->s_title; - $args->s_content = $search_obj->s_content; - $args->s_user_name = $search_obj->s_user_name; - $args->s_member_srl = $search_obj->s_member_srl; - $args->s_ipaddress = $search_obj->s_ipaddress; - $args->s_regdate = $search_obj->s_regdate; - $output = $oDB->executeQuery('document.getDocumentCount', $args); - $total_count = $output->data->count; - return (int)$total_count; - }/*}}}*/ + $args->module_srl = $module_srl; + $args->s_title = $search_obj->s_title; + $args->s_content = $search_obj->s_content; + $args->s_user_name = $search_obj->s_user_name; + $args->s_member_srl = $search_obj->s_member_srl; + $args->s_ipaddress = $search_obj->s_ipaddress; + $args->s_regdate = $search_obj->s_regdate; + $output = $oDB->executeQuery('document.getDocumentCount', $args); + $total_count = $output->data->count; + return (int)$total_count; + } - // public object getDocumentList($module_srl, $sort_index='list_order', $page=1, $list_order=20, $page_count=10, $search_obj = NULL)/*{{{*/ - // module_srl값을 가지는 문서의 목록을 가져옴 - function getDocumentList($module_srl, $sort_index = 'list_order', $page = 1, $list_count = 20, $page_count = 10, $search_obj = NULL) { - $args->module_srl = $module_srl; - $args->s_title = $search_obj->s_title; - $args->s_content = $search_obj->s_content; - $args->s_user_name = $search_obj->s_user_name; - $args->s_member_srl = $search_obj->s_member_srl; - $args->s_ipaddress = $search_obj->s_ipaddress; - $args->s_regdate = $search_obj->s_regdate; - $args->category_srl = $search_obj->category_srl; + // public object getDocumentList($module_srl, $sort_index='list_order', $page=1, $list_order=20, $page_count=10, $search_obj = NULL) + // module_srl값을 가지는 문서의 목록을 가져옴 + function getDocumentList($module_srl, $sort_index = 'list_order', $page = 1, $list_count = 20, $page_count = 10, $search_obj = NULL) { + $args->module_srl = $module_srl; + $args->s_title = $search_obj->s_title; + $args->s_content = $search_obj->s_content; + $args->s_user_name = $search_obj->s_user_name; + $args->s_member_srl = $search_obj->s_member_srl; + $args->s_ipaddress = $search_obj->s_ipaddress; + $args->s_regdate = $search_obj->s_regdate; + $args->category_srl = $search_obj->category_srl; - $args->sort_index = $sort_index; - $args->page = $page; - $args->list_count = $list_count; - $args->page_count = $page_count; - $oDB = &DB::getInstance(); - $output = $oDB->executeQuery('document.getDocumentList', $args); + $args->sort_index = $sort_index; + $args->page = $page; + $args->list_count = $list_count; + $args->page_count = $page_count; + $oDB = &DB::getInstance(); + $output = $oDB->executeQuery('document.getDocumentList', $args); - if(!count($output->data)) return $output; + if(!count($output->data)) return $output; - // 권한 체크 - $oMember = getModule('member'); - $member_srl = $oMember->getMemberSrl(); + // 권한 체크 + $oMember = getModule('member'); + $member_srl = $oMember->getMemberSrl(); - foreach($output->data as $key => $document) { + foreach($output->data as $key => $document) { $is_granted = false; if($this->isGranted($document->document_srl)) $is_granted = true; elseif($member_srl && $member_srl == $document->member_srl) $is_granted = true; $output->data[$key]->is_granted = $is_granted; - } - return $output; - }/*}}}*/ + } + return $output; + } - // public object getDocumentPage($document_srl, $module_srl, $list_count)/*{{{*/ - // 해당 document의 page 가져오기, module_srl이 없으면 전체에서.. - function getDocumentPage($document_srl, $module_srl=0, $list_count) { - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $args->module_srl = $module_srl; - $output = $oDB->executeQuery('document.getDocumentPage', $args); - $count = $output->data->count; - $page = (int)(($count-1)/$list_count)+1; - return $page; - }/*}}}*/ + // public object getDocumentPage($document_srl, $module_srl, $list_count) + // 해당 document의 page 가져오기, module_srl이 없으면 전체에서.. + function getDocumentPage($document_srl, $module_srl=0, $list_count) { + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $args->module_srl = $module_srl; + $output = $oDB->executeQuery('document.getDocumentPage', $args); + $count = $output->data->count; + $page = (int)(($count-1)/$list_count)+1; + return $page; + } - // public object updateReadedCount($document_srl)/*{{{*/ - // 해당 document의 조회수 증가 - function updateReadedCount($document_srl) { - if($_SESSION['readed_document'][$document_srl]) return false; - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.updateReadedCount', $args); - return $_SESSION['readed_document'][$document_srl] = true; - }/*}}}*/ + // public object updateReadedCount($document_srl) + // 해당 document의 조회수 증가 + function updateReadedCount($document_srl) { + if($_SESSION['readed_document'][$document_srl]) return false; + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $output = $oDB->executeQuery('document.updateReadedCount', $args); + return $_SESSION['readed_document'][$document_srl] = true; + } - // public object updateVotedCount($document_srl)/*{{{*/ - // 해당 document의 추천수 증가 - function updateVotedCount($document_srl) { - if($_SESSION['voted_document'][$document_srl]) return new Output(-1, 'failed_voted'); - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.updateVotedCount', $args); - $_SESSION['voted_document'][$document_srl] = true; - return new Output(0, 'success_voted'); - }/*}}}*/ + // public object updateVotedCount($document_srl) + // 해당 document의 추천수 증가 + function updateVotedCount($document_srl) { + if($_SESSION['voted_document'][$document_srl]) return new Output(-1, 'failed_voted'); + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $output = $oDB->executeQuery('document.updateVotedCount', $args); + $_SESSION['voted_document'][$document_srl] = true; + return new Output(0, 'success_voted'); + } - // public object updateCommentCount($document_srl, $comment_count)/*{{{*/ - // 해당 document의 댓글 수 증가 - function updateCommentCount($document_srl, $comment_count) { - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $args->comment_count = $comment_count; - $output = $oDB->executeQuery('document.updateCommentCount', $args); - return new Output(); - }/*}}}*/ + // public object updateCommentCount($document_srl, $comment_count) + // 해당 document의 댓글 수 증가 + function updateCommentCount($document_srl, $comment_count) { + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $args->comment_count = $comment_count; + $output = $oDB->executeQuery('document.updateCommentCount', $args); + return new Output(); + } - // public object updateTrackbackCount($document_srl, $trackback_count)/*{{{*/ - // 해당 document의 엮인글 수증가 - function updateTrackbackCount($document_srl, $trackback_count) { - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $args->trackback_count = $trackback_count; - $output = $oDB->executeQuery('document.updateTrackbackCount', $args); - return new Output(); - }/*}}}*/ + // public object updateTrackbackCount($document_srl, $trackback_count) + // 해당 document의 엮인글 수증가 + function updateTrackbackCount($document_srl, $trackback_count) { + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $args->trackback_count = $trackback_count; + $output = $oDB->executeQuery('document.updateTrackbackCount', $args); + return new Output(); + } - // 카테고리 관리 - // public object getCategory($category_srl) /*{{{*/ - function getCategory($category_srl) { - $args->category_srl = $category_srl; - $oDB = &DB::getInstance(); - $output = $oDB->executeQuery('document.getCategory', $args); - return $output->data; - }/*}}}*/ + // 카테고리 관리 + // public object getCategory($category_srl) + function getCategory($category_srl) { + $args->category_srl = $category_srl; + $oDB = &DB::getInstance(); + $output = $oDB->executeQuery('document.getCategory', $args); + return $output->data; + } - // public object getCategoryList($module_srl) /*{{{*/ - function getCategoryList($module_srl) { - $args->module_srl = $module_srl; - $args->sort_index = 'list_order'; - $oDB = &DB::getInstance(); - $output = $oDB->executeQuery('document.getCategoryList', $args); - $category_list = $output->data; - if(!$category_list) return NULL; - if(!is_array($category_list)) $category_list = array($category_list); - $category_count = count($category_list); - for($i=0;$i<$category_count;$i++) { + // public object getCategoryList($module_srl) + function getCategoryList($module_srl) { + $args->module_srl = $module_srl; + $args->sort_index = 'list_order'; + $oDB = &DB::getInstance(); + $output = $oDB->executeQuery('document.getCategoryList', $args); + $category_list = $output->data; + if(!$category_list) return NULL; + if(!is_array($category_list)) $category_list = array($category_list); + $category_count = count($category_list); + for($i=0;$i<$category_count;$i++) { $category_srl = $category_list[$i]->category_srl; $list[$category_srl] = $category_list[$i]; - } - return $list; - }/*}}}*/ + } + return $list; + } - // public object insertCategory($module_srl, $title) /*{{{*/ - function insertCategory($module_srl, $title) { - $oDB = &DB::getInstance(); - $args->list_order = $args->category_srl = $oDB->getNextSequence(); - $args->module_srl = $module_srl; - $args->title = $title; - $args->document_count = 0; - return $oDB->executeQuery('document.insertCategory', $args); - }/*}}}*/ + // public object insertCategory($module_srl, $title) + function insertCategory($module_srl, $title) { + $oDB = &DB::getInstance(); + $args->list_order = $args->category_srl = $oDB->getNextSequence(); + $args->module_srl = $module_srl; + $args->title = $title; + $args->document_count = 0; + return $oDB->executeQuery('document.insertCategory', $args); + } - // public object updateCategory($args) /*{{{*/ - function updateCategory($args) { - $oDB = &DB::getInstance(); - return $oDB->executeQuery('document.updateCategory', $args); - }/*}}}*/ + // public object updateCategory($args) + function updateCategory($args) { + $oDB = &DB::getInstance(); + return $oDB->executeQuery('document.updateCategory', $args); + } - // public object updateCategoryCount($category_srl, $document_count = 0) /*{{{*/ - function updateCategoryCount($category_srl, $document_count = 0) { - if(!$document_count) $document_count = $this->getCategoryDocumentCount($category_srl); - $args->category_srl = $category_srl; - $args->document_count = $document_count; - $oDB = &DB::getInstance(); - return $oDB->executeQuery('document.updateCategoryCount', $args); - }/*}}}*/ + // public object updateCategoryCount($category_srl, $document_count = 0) + function updateCategoryCount($category_srl, $document_count = 0) { + if(!$document_count) $document_count = $this->getCategoryDocumentCount($category_srl); + $args->category_srl = $category_srl; + $args->document_count = $document_count; + $oDB = &DB::getInstance(); + return $oDB->executeQuery('document.updateCategoryCount', $args); + } - // public int getCategoryDocumentCount($category_srl) /*{{{*/ - function getCategoryDocumentCount($category_srl) { - $args->category_srl = $category_srl; - $oDB = &DB::getInstance(); - $output = $oDB->executeQuery('document.getCategoryDocumentCount', $args); - return (int)$output->data->count; - }/*}}}*/ + // public int getCategoryDocumentCount($category_srl) + function getCategoryDocumentCount($category_srl) { + $args->category_srl = $category_srl; + $oDB = &DB::getInstance(); + $output = $oDB->executeQuery('document.getCategoryDocumentCount', $args); + return (int)$output->data->count; + } - // public object deleteCategory($category_srl) /*{{{*/ - function deleteCategory($category_srl) { - $args->category_srl = $category_srl; - $oDB = &DB::getInstance(); + // public object deleteCategory($category_srl) + function deleteCategory($category_srl) { + $args->category_srl = $category_srl; + $oDB = &DB::getInstance(); - // 카테고리 정보를 삭제 - $output = $oDB->executeQuery('document.deleteCategory', $args); - if(!$output->toBool()) return $output; + // 카테고리 정보를 삭제 + $output = $oDB->executeQuery('document.deleteCategory', $args); + if(!$output->toBool()) return $output; - // 현 카테고리 값을 가지는 문서들의 category_srl을 0 으로 세팅 - unset($args); - $args->target_category_srl = 0; - $args->source_category_srl = $category_srl; - $output = $oDB->executeQuery('document.updateDocumentCategory', $args); - return $output; - }/*}}}*/ + // 현 카테고리 값을 가지는 문서들의 category_srl을 0 으로 세팅 + unset($args); + $args->target_category_srl = 0; + $args->source_category_srl = $category_srl; + $output = $oDB->executeQuery('document.updateDocumentCategory', $args); + return $output; + } - // public object deleteModuleCategory($module_srl) /*{{{*/ - function deleteModuleCategory($module_srl) { - $args->module_srl = $module_srl; - $oDB = &DB::getInstance(); - $output = $oDB->executeQuery('document.deleteModuleCategory', $args); - return $output; - }/*}}}*/ + // public object deleteModuleCategory($module_srl) + function deleteModuleCategory($module_srl) { + $args->module_srl = $module_srl; + $oDB = &DB::getInstance(); + $output = $oDB->executeQuery('document.deleteModuleCategory', $args); + return $output; + } - // public object moveCategoryUp($category_srl) /*{{{*/ - function moveCategoryUp($category_srl) { - // 선택된 카테고리의 정보를 구한다 - $oDB = &DB::getInstance(); - $args->category_srl = $category_srl; - $output = $oDB->executeQuery('document.getCategory', $args); - $category = $output->data; - $list_order = $category->list_order; - $module_srl = $category->module_srl; + // public object moveCategoryUp($category_srl) + function moveCategoryUp($category_srl) { + // 선택된 카테고리의 정보를 구한다 + $oDB = &DB::getInstance(); + $args->category_srl = $category_srl; + $output = $oDB->executeQuery('document.getCategory', $args); + $category = $output->data; + $list_order = $category->list_order; + $module_srl = $category->module_srl; - // 전체 카테고리 목록을 구한다 - $category_list = $this->getCategoryList($module_srl); - $category_srl_list = array_keys($category_list); - if(count($category_srl_list)<2) return new Output(); + // 전체 카테고리 목록을 구한다 + $category_list = $this->getCategoryList($module_srl); + $category_srl_list = array_keys($category_list); + if(count($category_srl_list)<2) return new Output(); - $prev_category = NULL; - foreach($category_list as $key => $val) { + $prev_category = NULL; + foreach($category_list as $key => $val) { if($key==$category_srl) break; $prev_category = $val; - } + } - // 이전 카테고리가 없으면 그냥 return - if(!$prev_category) return new Output(-1,Context::getLang('msg_category_not_moved')); + // 이전 카테고리가 없으면 그냥 return + if(!$prev_category) return new Output(-1,Context::getLang('msg_category_not_moved')); - // 선택한 카테고리가 가장 위의 카테고리이면 그냥 return - if($category_srl_list[0]==$category_srl) return new Output(-1,Context::getLang('msg_category_not_moved')); + // 선택한 카테고리가 가장 위의 카테고리이면 그냥 return + if($category_srl_list[0]==$category_srl) return new Output(-1,Context::getLang('msg_category_not_moved')); - // 선택한 카테고리의 정보 - $cur_args->category_srl = $category_srl; - $cur_args->list_order = $prev_category->list_order; - $cur_args->title = $category->title; - $this->updateCategory($cur_args); + // 선택한 카테고리의 정보 + $cur_args->category_srl = $category_srl; + $cur_args->list_order = $prev_category->list_order; + $cur_args->title = $category->title; + $this->updateCategory($cur_args); - // 대상 카테고리의 정보 - $prev_args->category_srl = $prev_category->category_srl; - $prev_args->list_order = $list_order; - $prev_args->title = $prev_category->title; - $this->updateCategory($prev_args); + // 대상 카테고리의 정보 + $prev_args->category_srl = $prev_category->category_srl; + $prev_args->list_order = $list_order; + $prev_args->title = $prev_category->title; + $this->updateCategory($prev_args); - return new Output(); - }/*}}}*/ + return new Output(); + } - // public object moveCategoryDown($category_srl) /*{{{*/ - function moveCategoryDown($category_srl) { - // 선택된 카테고리의 정보를 구한다 - $oDB = &DB::getInstance(); - $args->category_srl = $category_srl; - $output = $oDB->executeQuery('document.getCategory', $args); - $category = $output->data; - $list_order = $category->list_order; - $module_srl = $category->module_srl; + // public object moveCategoryDown($category_srl) + function moveCategoryDown($category_srl) { + // 선택된 카테고리의 정보를 구한다 + $oDB = &DB::getInstance(); + $args->category_srl = $category_srl; + $output = $oDB->executeQuery('document.getCategory', $args); + $category = $output->data; + $list_order = $category->list_order; + $module_srl = $category->module_srl; - // 전체 카테고리 목록을 구한다 - $category_list = $this->getCategoryList($module_srl); - $category_srl_list = array_keys($category_list); - if(count($category_srl_list)<2) return new Output(); + // 전체 카테고리 목록을 구한다 + $category_list = $this->getCategoryList($module_srl); + $category_srl_list = array_keys($category_list); + if(count($category_srl_list)<2) return new Output(); - for($i=0;$icategory_srl = $category_srl; - $cur_args->list_order = $next_category->list_order; - $cur_args->title = $category->title; - $this->updateCategory($cur_args); + // 선택한 카테고리의 정보 + $cur_args->category_srl = $category_srl; + $cur_args->list_order = $next_category->list_order; + $cur_args->title = $category->title; + $this->updateCategory($cur_args); - // 대상 카테고리의 정보 - $next_args->category_srl = $next_category->category_srl; - $next_args->list_order = $list_order; - $next_args->title = $next_category->title; - $this->updateCategory($next_args); + // 대상 카테고리의 정보 + $next_args->category_srl = $next_category->category_srl; + $next_args->list_order = $list_order; + $next_args->title = $next_category->title; + $this->updateCategory($next_args); - return new Output(); - }/*}}}*/ + return new Output(); + } - // 파일 관리 - // public int getFilesCount($document_srl) /*{{{*/ - function getFilesCount($document_srl) { - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.getFilesCount', $args); - return (int)$output->data->count; - }/*}}}*/ + // 파일 관리 + // public int getFilesCount($document_srl) + function getFilesCount($document_srl) { + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $output = $oDB->executeQuery('document.getFilesCount', $args); + return (int)$output->data->count; + } - // public object getFile($file_srl) /*{{{*/ - function getFile($file_srl) { - $oDB = &DB::getInstance(); - $args->file_srl = $file_srl; - $output = $oDB->executeQuery('document.getFile', $args); - return $output->data; - }/*}}}*/ + // public object getFile($file_srl) + function getFile($file_srl) { + $oDB = &DB::getInstance(); + $args->file_srl = $file_srl; + $output = $oDB->executeQuery('document.getFile', $args); + return $output->data; + } - // public object getFiles($document_srl) /*{{{*/ - function getFiles($document_srl) { - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $args->sort_index = 'file_srl'; - $output = $oDB->executeQuery('document.getFiles', $args); - $file_list = $output->data; - if($file_list && !is_array($file_list)) $file_list = array($file_list); - for($i=0;$idocument_srl = $document_srl; + $args->sort_index = 'file_srl'; + $output = $oDB->executeQuery('document.getFiles', $args); + $file_list = $output->data; + if($file_list && !is_array($file_list)) $file_list = array($file_list); + for($i=0;$idirect_download; if($direct_download!='Y') continue; $uploaded_filename = Context::getRequestUri().substr($file_list[$i]->uploaded_filename,2); $file_list[$i]->uploaded_filename = $uploaded_filename; - } - return $file_list; - }/*}}}*/ + } + return $file_list; + } - // public object insertFile($module_srl, $document_sr) /*{{{*/ - function insertFile($module_srl, $document_srl) { - $oDB = &DB::getInstance(); + // public object insertFile($module_srl, $document_sr) + function insertFile($module_srl, $document_srl) { + $oDB = &DB::getInstance(); - $file_info = Context::get('file'); + $file_info = Context::get('file'); - // 정상적으로 업로드된 파일이 아니면 오류 출력 - if(!is_uploaded_file($file_info['tmp_name'])) return false; + // 정상적으로 업로드된 파일이 아니면 오류 출력 + if(!is_uploaded_file($file_info['tmp_name'])) return false; - // 이미지인지 기타 파일인지 체크하여 upload path 지정 - if(eregi("\.(jpg|jpeg|gif|png|wmv|mpg|mpeg|avi|swf|flv|mp3|asaf|wav|asx|midi)$", $file_info['name'])) { + // 이미지인지 기타 파일인지 체크하여 upload path 지정 + if(eregi("\.(jpg|jpeg|gif|png|wmv|mpg|mpeg|avi|swf|flv|mp3|asaf|wav|asx|midi)$", $file_info['name'])) { $path = sprintf("./files/attach/images/%s/%s/", $module_srl,$document_srl); $filename = $path.$file_info['name']; $direct_download = 'Y'; - } else { + } else { $path = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl); $filename = $path.md5(crypt(rand(1000000,900000), rand(0,100))); $direct_download = 'N'; - } + } - // 디렉토리 생성 - if(!FileHandler::makeDir($path)) return false; + // 디렉토리 생성 + if(!FileHandler::makeDir($path)) return false; - // 파일 이동 - if(!move_uploaded_file($file_info['tmp_name'], $filename)) return false; + // 파일 이동 + if(!move_uploaded_file($file_info['tmp_name'], $filename)) return false; - // 사용자 정보를 구함 - $oMember = getModule('member'); - $member_srl = $oMember->getMemberSrl(); + // 사용자 정보를 구함 + $oMember = getModule('member'); + $member_srl = $oMember->getMemberSrl(); - // 파일 정보를 정리 - $oDB = &DB::getInstance(); - $args->file_srl = $oDB->getNextSequence(); - $args->document_srl = $document_srl; - $args->module_srl = $module_srl; - $args->direct_download = $direct_download; - $args->source_filename = $file_info['name']; - $args->uploaded_filename = $filename; - $args->file_size = filesize($filename); - $args->comment = NULL; - $args->member_srl = $member_srl; - $args->sid = md5($args->source_filename); + // 파일 정보를 정리 + $oDB = &DB::getInstance(); + $args->file_srl = $oDB->getNextSequence(); + $args->document_srl = $document_srl; + $args->module_srl = $module_srl; + $args->direct_download = $direct_download; + $args->source_filename = $file_info['name']; + $args->uploaded_filename = $filename; + $args->file_size = filesize($filename); + $args->comment = NULL; + $args->member_srl = $member_srl; + $args->sid = md5($args->source_filename); - $output = $oDB->executeQuery('document.insertFile', $args); - if(!$output->toBool()) return $output; - $output->add('file_srl', $args->file_srl); - $output->add('file_size', $args->file_size); - $output->add('source_filename', $args->source_filename); - return $output; - }/*}}}*/ + $output = $oDB->executeQuery('document.insertFile', $args); + if(!$output->toBool()) return $output; + $output->add('file_srl', $args->file_srl); + $output->add('file_size', $args->file_size); + $output->add('source_filename', $args->source_filename); + return $output; + } - // public object deleteFile($file_srl) /*{{{*/ - function deleteFile($file_srl) { - $oDB = &DB::getInstance(); + // public object deleteFile($file_srl) + function deleteFile($file_srl) { + $oDB = &DB::getInstance(); - // 파일 정보를 가져옴 - $args->file_srl = $file_srl; - $output = $oDB->executeQuery('document.getFile', $args); - if(!$output->toBool()) return $output; - $file_info = $output->data; - if(!$file_info) return new Output(-1, 'file_not_founded'); + // 파일 정보를 가져옴 + $args->file_srl = $file_srl; + $output = $oDB->executeQuery('document.getFile', $args); + if(!$output->toBool()) return $output; + $file_info = $output->data; + if(!$file_info) return new Output(-1, 'file_not_founded'); - $source_filename = $output->data->source_filename; - $uploaded_filename = $output->data->uploaded_filename; + $source_filename = $output->data->source_filename; + $uploaded_filename = $output->data->uploaded_filename; - // DB에서 삭제 - $output = $oDB->executeQuery('document.deleteFile', $args); - if(!$output->toBool()) return $output; + // DB에서 삭제 + $output = $oDB->executeQuery('document.deleteFile', $args); + if(!$output->toBool()) return $output; - // 삭제 성공하면 파일 삭제 - unlink($uploaded_filename); + // 삭제 성공하면 파일 삭제 + unlink($uploaded_filename); - return $output; - }/*}}}*/ + return $output; + } - // public object deleteFiles($module_srl, $document_srl) /*{{{*/ - function deleteFiles($module_srl, $document_srl) { - // DB에서 삭제 - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.deleteFiles', $args); - if(!$output->toBool()) return $output; + // public object deleteFiles($module_srl, $document_srl) + function deleteFiles($module_srl, $document_srl) { + // DB에서 삭제 + $oDB = &DB::getInstance(); + $args->document_srl = $document_srl; + $output = $oDB->executeQuery('document.deleteFiles', $args); + if(!$output->toBool()) return $output; - // 실제 파일 삭제 - $path[0] = sprintf("./files/attach/images/%s/%s/", $module_srl, $document_srl); - $path[1] = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl); + // 실제 파일 삭제 + $path[0] = sprintf("./files/attach/images/%s/%s/", $module_srl, $document_srl); + $path[1] = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl); - FileHandler::removeDir($path[0]); - FileHandler::removeDir($path[1]); + FileHandler::removeDir($path[0]); + FileHandler::removeDir($path[1]); - return $output; - }/*}}}*/ + return $output; + } - // public object deleteModuleFiles($module_srl) /*{{{*/ - function deleteModuleFiles($module_srl) { - // DB에서 삭제 - $oDB = &DB::getInstance(); - $args->module_srl = $module_srl; - $output = $oDB->executeQuery('document.deleteModuleFiles', $args); - if(!$output->toBool()) return $output; + // public object deleteModuleFiles($module_srl) + function deleteModuleFiles($module_srl) { + // DB에서 삭제 + $oDB = &DB::getInstance(); + $args->module_srl = $module_srl; + $output = $oDB->executeQuery('document.deleteModuleFiles', $args); + if(!$output->toBool()) return $output; - // 실제 파일 삭제 - $path[0] = sprintf("./files/attach/images/%s/", $module_srl); - $path[1] = sprintf("./files/attach/binaries/%s/", $module_srl); - FileHandler::removeDir($path[0]); - FileHandler::removeDir($path[1]); + // 실제 파일 삭제 + $path[0] = sprintf("./files/attach/images/%s/", $module_srl); + $path[1] = sprintf("./files/attach/binaries/%s/", $module_srl); + FileHandler::removeDir($path[0]); + FileHandler::removeDir($path[1]); - return $output; - }/*}}}*/ + return $output; + } - // 기타 기능 - // public string transContent($content) {/*{{{*/ - // 내용 관리 - // 내용의 플러그인이나 기타 기능에 대한 code를 실제 code로 변경 - function transContent($content) { - // 멀티미디어 코드의 변환 - $content = preg_replace_callback('!]*)editor_multimedia([^\>]*?)>!is', array('Document','_transMultimedia'), $content); + // 기타 기능 + // public string transContent($content) { + // 내용 관리 + // 내용의 플러그인이나 기타 기능에 대한 code를 실제 code로 변경 + function transContent($content) { + // 멀티미디어 코드의 변환 + $content = preg_replace_callback('!]*)editor_multimedia([^\>]*?)>!is', array('Document','_transMultimedia'), $content); - //
코드 변환 - $content = str_replace(array("
","
","
"),"
", $content); + //
코드 변환 + $content = str_replace(array("
","
","
"),"
", $content); - // 코드를 코드로 변환 - $content = preg_replace('!!is','', $content); + // 코드를 코드로 변환 + $content = preg_replace('!!is','', $content); - return $content; - }/*}}}*/ + return $content; + } - // public string _transMultimedia($matches)/*{{{*/ - // 로 되어 있는 코드를 변경 - function _transMultimedia($matches) { - preg_match("/style\=(\"|'){0,1}([^\"\']+)(\"|'){0,1}/i",$matches[0], $buff); - $style = str_replace("\"","'",$buff[0]); - preg_match("/alt\=\"{0,1}([^\"]+)\"{0,1}/i",$matches[0], $buff); - $opt = explode('|@|',$buff[1]); - if(count($opt)<1) return $matches[0]; + // public string _transMultimedia($matches) + // 로 되어 있는 코드를 변경 + function _transMultimedia($matches) { + preg_match("/style\=(\"|'){0,1}([^\"\']+)(\"|'){0,1}/i",$matches[0], $buff); + $style = str_replace("\"","'",$buff[0]); + preg_match("/alt\=\"{0,1}([^\"]+)\"{0,1}/i",$matches[0], $buff); + $opt = explode('|@|',$buff[1]); + if(count($opt)<1) return $matches[0]; - for($i=0;$i{$cmd} = $val; - } + } - return sprintf("", $obj->type, $obj->src, $style); - }/*}}}*/ - } + return sprintf("", $obj->type, $obj->src, $style); + } + } ?> diff --git a/modules/install/install.controller.php b/modules/install/install.controller.php new file mode 100644 index 000000000..7fe452de1 --- /dev/null +++ b/modules/install/install.controller.php @@ -0,0 +1,208 @@ +doError('msg_already_installed'); + } + + // DB와 관련된 변수를 받음 + $db_info = Context::gets('db_type','db_hostname','db_userid','db_password','db_database','db_table_prefix'); + + // DB의 타입과 정보를 등록 + Context::setDBInfo($db_info); + + // DB Instance 생성 + $oDB = &DB::getInstance(); + + // DB접속이 가능한지 체크 + if(!$oDB->isConnected()) { + return $this->doError('msg_dbconnect_failed'); + } + + // 모든 모듈의 테이블 생성 + $output = $this->makeTable(); + if(!$output->toBool()) return $output; + + // 관리자 정보 입력 (member 모듈을 찾아서 method 실행) + $oMember = getModule('member'); + + // 그룹을 입력 + $group_args->title = Context::getLang('default_group_1'); + $group_args->is_default = 'Y'; + $oMember->insertGroup($group_args); + + $group_args->title = Context::getLang('default_group_2'); + $group_args->is_default = 'N'; + $oMember->insertGroup($group_args); + + // 금지 아이디 등록 + $oMember->insertDeniedID('www',''); + $oMember->insertDeniedID('root',''); + $oMember->insertDeniedID('admin',''); + $oMember->insertDeniedID('administrator',''); + $oMember->insertDeniedID('telnet',''); + $oMember->insertDeniedID('ftp',''); + $oMember->insertDeniedID('http',''); + + // 관리자 정보 세팅 + $admin_info = Context::gets('user_id','password','nick_name','user_name', 'email_address'); + + // 관리자 정보 입력 + $oMember->insertAdmin($admin_info); + + // 로그인 처리시킴 + $oMember->doLogin($admin_info->user_id, $admin_info->password); + + // 기본 모듈을 생성 + $oModule = getModule('module_manager'); + $oModule->makeDefaultModule(); + + // config 파일 생성 + if(!$this->makeConfigFile()) return $this->doError('msg_install_failed'); + + // 설치 완료 메세지 출력 + $this->setMessage('msg_install_completed'); + } + + + /** + * @brief files 및 하위 디렉토리 생성 + * DB 정보를 바탕으로 실제 install하기 전에 로컬 환경 설저d + **/ + function makeDefaultDirectory() { + $directory_list = array( + './files', + './files/modules', + './files/plugins', + './files/addons', + './files/layouts', + './files/queries', + './files/schemas', + './files/js_filter_compiled', + './files/template_compiled', + './files/config', + './files/attach', + './files/attach/images', + './files/attach/binaries', + ); + + foreach($directory_list as $dir) { + if(is_dir($dir)) continue; + @mkdir($dir, 0707); + @chmod($dir, 0707); + } + } + + /** + * @brief DB Table 생성 + * + * 모든 module의 schemas 디렉토리를 확인하여 schema xml을 이용, 테이블 생성 + **/ + function makeTable() { + // db instance생성 + $oDB = &DB::getInstance(); + + // 각 모듈의 schemas/*.xml 파일을 모두 찾아서 table 생성 + $module_list_1 = FileHandler::readDir('./modules/', NULL, false, true); + $module_list_2 = FileHandler::readDir('./files/modules/', NULL, false, true); + $module_list = array_merge($module_list_1, $module_list_2); + foreach($module_list as $module_path) { + $schema_dir = sprintf('%s/schemas/', $module_path); + $schema_files = FileHandler::readDir($schema_dir, NULL, false, true); + $file_cnt = count($schema_files); + if(!$file_cnt) continue; + + for($i=0;$i<$file_cnt;$i++) { + $file = trim($schema_files[$i]); + if(!$file || substr($file,-4)!='.xml') continue; + $output = $oDB->createTableByXmlFile($file); + if($oDB->isError()) return $oDB->getError(); + } + } + return new Output(); + } + + /** + * @brief config 파일을 생성 + * 모든 설정이 이상없이 끝난 후에 config파일 생성 + **/ + function makeConfigFile() { + $config_file = Context::getConfigFile(); + if(file_exists($config_file)) return; + + $db_info = Context::getDbInfo(); + if(!$db_info) return; + + $buff = ' $val) { + $buff .= sprintf("\$db_info->%s = \"%s\";\n", $key, $val); + } + $buff .= "?>"; + + FileHandler::writeFile($config_file, $buff); + + if(@file_exists($config_file)) return true; + return false; + } + } +?> diff --git a/modules/install/module.xml b/modules/install/install.info.xml similarity index 100% rename from modules/install/module.xml rename to modules/install/install.info.xml diff --git a/modules/install/install.module.php b/modules/install/install.module.php deleted file mode 100644 index a6861a65a..000000000 --- a/modules/install/install.module.php +++ /dev/null @@ -1,265 +0,0 @@ - - * @desc : 기본 모듈중의 하나인 install module - * Module class에서 상속을 받아서 사용 - * action 의 경우 disp/proc 2가지만 존재하며 이는 action명세서에 - * 미리 기록을 하여야 함 - **/ - - class install extends Module { - - /** - * 모듈의 정보 - **/ - var $cur_version = "20070130_0.01"; - - /** - * 기본 action 지정 - * $act값이 없거나 잘못된 값이 들어올 경우 $default_act 값으로 진행 - **/ - var $default_act = 'dispIntroduce'; - - /** - * 현재 모듈의 초기화를 위한 작업을 지정해 놓은 method - * css/js파일의 load라든지 lang파일 load등을 미리 선언 - * - * Init() => 공통 - * dispInit() => disp시에 - * procInit() => proc시에 - * - * $this->module_path는 현재 이 모듈파일의 위치를 나타낸다 - * (ex: $this->module_path = "./modules/install/"; - **/ - - // 초기화 - function init() {/*{{{*/ - Context::loadLang($this->module_path.'lang'); - - // 설치시 필수항목 검사 - $this->checkInstallEnv(); - - if(Context::get('install_enable')) $this->makeDefaultDirectory(); - }/*}}}*/ - - // disp 초기화 - function dispInit() {/*{{{*/ - // 설치가 가능하면 기본 디렉토리등을 만듬 - if(!Context::get('install_enable')) { - $this->act = 'dispIntroduce'; - } - - return true; - }/*}}}*/ - - // proc 초기화 - function procInit() {/*{{{*/ - // 설치가 불가능한 환경인데 요청이 오면 에러 표시 - if(!Context::get('install_enable')) return $this->doError('msg_already_installed'); - return true; - }/*}}}*/ - - /** - * 여기서부터는 action의 구현 - * request parameter의 경우 각 method의 첫번째 인자로 넘어온다 - * - * dispXXXX : 출력을 위한 method, output에 tpl file이 지정되어야 한다 - * procXXXX : 처리를 위한 method, output에는 error, message가 지정되어야 한다 - * - * 변수의 사용은 Context::get('이름')으로 얻어오면 된다 - **/ - function dispIntroduce() {/*{{{*/ - // disp_license.html 파일 출력 - $this->setTemplateFile('disp_license'); - }/*}}}*/ - - function dispDBInfoForm() {/*{{{*/ - // db_type이 지정되지 않았다면 다시 초기화면 출력 - if(!Context::get('db_type')) return $this->dispIntroduce(); - - // disp_db_info_form.html 파일 출력 - $tpl_filename = sprintf('db_form.%s.html', Context::get('db_type')); - $this->setTemplateFile($tpl_filename); - }/*}}}*/ - - function procInstall() {/*{{{*/ - // 설치가 되어 있는지에 대한 체크 - if(Context::isInstalled()) { - return $this->doError('msg_already_installed'); - } - - // DB와 관련된 변수를 받음 - $db_info = Context::gets('db_type','db_hostname','db_userid','db_password','db_database','db_table_prefix'); - - // DB의 타입과 정보를 등록 - Context::setDBInfo($db_info); - - // DB Instance 생성 - $oDB = &DB::getInstance(); - - // DB접속이 가능한지 체크 - if(!$oDB->isConnected()) { - return $this->doError('msg_dbconnect_failed'); - } - - // 모든 모듈의 테이블 생성 - $output = $this->makeTable(); - if(!$output->toBool()) return $output; - - // 관리자 정보 입력 (member 모듈을 찾아서 method 실행) - $oMember = getModule('member'); - - // 그룹을 입력 - $group_args->title = Context::getLang('default_group_1'); - $group_args->is_default = 'Y'; - $oMember->insertGroup($group_args); - - $group_args->title = Context::getLang('default_group_2'); - $group_args->is_default = 'N'; - $oMember->insertGroup($group_args); - - // 금지 아이디 등록 - $oMember->insertDeniedID('www',''); - $oMember->insertDeniedID('root',''); - $oMember->insertDeniedID('admin',''); - $oMember->insertDeniedID('administrator',''); - $oMember->insertDeniedID('telnet',''); - $oMember->insertDeniedID('ftp',''); - $oMember->insertDeniedID('http',''); - - // 관리자 정보 세팅 - $admin_info = Context::gets('user_id','password','nick_name','user_name', 'email_address'); - - // 관리자 정보 입력 - $oMember->insertAdmin($admin_info); - - // 로그인 처리시킴 - $oMember->doLogin($admin_info->user_id, $admin_info->password); - - // 기본 모듈을 생성 - $oModule = getModule('module_manager'); - $oModule->makeDefaultModule(); - - // config 파일 생성 - if(!$this->makeConfigFile()) return $this->doError('msg_install_failed'); - - // 설치 완료 메세지 출력 - $this->setMessage('msg_install_completed'); - }/*}}}*/ - - /** - * 여기부터는 이 모듈과 관련된 라이브러리 개념의 method들 - **/ - // public void checkInstallEnv()/*{{{*/ - // 기본적으로 필수적인 체크항목들을 검사하여 Context에 바로 넣어버림.. - function checkInstallEnv() { - // 각 필요한 항목 체크 - $checklist = array(); - - // 1. permission 체크 - if(is_writable('./')||is_writable('./files')) $checklist['permission'] = true; - else $checklist['permission'] = false; - - // 2. xml_parser_create함수 유무 체크 - if(function_exists('xml_parser_create')) $checklist['xml'] = true; - else $checklist['xml'] = false; - - // 3. ini_get(session.auto_start)==1 체크 - if(ini_get(session.auto_start)!=1) $checklist['session'] = true; - else $checklist['session'] = false; - - // 4. iconv 체크 - if(function_exists('iconv')) $checklist['iconv'] = true; - else $checklist['iconv'] = false; - - // 5. gd 체크 (imagecreatefromgif함수) - if(function_exists('imagecreatefromgif')) $checklist['gd'] = true; - else $checklist['gd'] = false; - - // 6. mysql_get_client_info() 체크 - if(mysql_get_client_info() < "4.1.00") $checklist['mysql'] = false; - else $checklist['mysql'] = true; - - if(!$checklist['permission'] || !$checklist['xml'] || !$checklist['session']) $install_enable = false; - else $install_enable = true; - - // 체크 결과를 Context에 저장 - Context::set('install_enable', $install_enable); - Context::set('checklist', $checklist); - }/*}}}*/ - - // public void makeDefaultDirectory()/*{{{*/ - // files 및 하위 디렉토리 생성 - function makeDefaultDirectory() { - $directory_list = array( - './files', - './files/modules', - './files/plugins', - './files/addons', - './files/layouts', - './files/queries', - './files/schemas', - './files/js_filter_compiled', - './files/template_compiled', - './files/config', - './files/attach', - './files/attach/images', - './files/attach/binaries', - ); - - foreach($directory_list as $dir) { - if(is_dir($dir)) continue; - @mkdir($dir, 0707); - @chmod($dir, 0707); - } - }/*}}}*/ - - // public void makeTable()/*{{{*/ - // 모든 모듈의 테이블 생성 schema를 찾아서 생성 - function makeTable() { - // db instance생성 - $oDB = &DB::getInstance(); - - // 각 모듈의 schemas/*.xml 파일을 모두 찾아서 table 생성 - $module_list_1 = FileHandler::readDir('./modules/', NULL, false, true); - $module_list_2 = FileHandler::readDir('./files/modules/', NULL, false, true); - $module_list = array_merge($module_list_1, $module_list_2); - foreach($module_list as $module_path) { - $schema_dir = sprintf('%s/schemas/', $module_path); - $schema_files = FileHandler::readDir($schema_dir, NULL, false, true); - $file_cnt = count($schema_files); - if(!$file_cnt) continue; - - for($i=0;$i<$file_cnt;$i++) { - $file = trim($schema_files[$i]); - if(!$file || substr($file,-4)!='.xml') continue; - $output = $oDB->createTableByXmlFile($file); - if($oDB->isError()) return $oDB->getError(); - } - } - return new Output(); - }/*}}}*/ - - // public boolean makeConfigFile() /*{{{*/ - // config 파일을 생성 - function makeConfigFile() { - $config_file = Context::getConfigFile(); - if(file_exists($config_file)) return; - - $db_info = Context::getDbInfo(); - if(!$db_info) return; - - $buff = ' $val) { - $buff .= sprintf("\$db_info->%s = \"%s\";\n", $key, $val); - } - $buff .= "?>"; - - FileHandler::writeFile($config_file, $buff); - - if(@file_exists($config_file)) return true; - return false; - }/*}}}*/ - } -?> diff --git a/modules/install/install.view.php b/modules/install/install.view.php new file mode 100644 index 000000000..311739245 --- /dev/null +++ b/modules/install/install.view.php @@ -0,0 +1,51 @@ +setTemplatePath($this->module_path."skins/default"); + + // 컨트롤러 생성 + $oController = getModule('install','controller'); + + // 설치 불가능하다면 introduce를 출력 + if(!$oController->checkInstallEnv()) $this->act = $this->default_act; + + // 설치 가능한 환경이라면 installController::makeDefaultDirectory() 실행 + else $oController->makeDefaultDirectory(); + } + + /** + * @brief license 및 설치 환경에 대한 메세지 보여줌 + **/ + function viewIntroduce() { + $this->setTemplateFile('disp_license'); + } + + /** + * @brief DB 정보 입력 화면을 보여줌 + **/ + function viewDBInfoForm() { + // db_type이 지정되지 않았다면 다시 초기화면 출력 + if(!Context::get('db_type')) return $this->viewIntroduce(); + + // disp_db_info_form.html 파일 출력 + $tpl_filename = sprintf('db_form.%s', Context::get('db_type')); + $this->setTemplateFile($tpl_filename); + } + + } +?> diff --git a/modules/member/member.model.php b/modules/member/member.model.php new file mode 100644 index 000000000..335265efa --- /dev/null +++ b/modules/member/member.model.php @@ -0,0 +1,188 @@ +isLogged()) return $_SESSION['logged_info']; + } + + /** + * @brief user_id에 해당하는 사용자 정보 return + **/ + function getMemberInfoByUserID($user_id) { + $args->user_id = $user_id; + + $output = $this->executeQuery('member.getMemberInfo', $args); + if(!$output) return $output; + + $member_info = $output->data; + $member_info->group_list = $this->getMemberGroups($member_info->member_srl); + + return $member_info; + } + + /** + * @brief member_srl로 사용자 정보 return + **/ + function getMemberInfoByMemberSrl($member_srl) { + $args->member_srl = $member_srl; + + $output = $this->executeQuery('member.getMemberInfoByMemberSrl', $args); + if(!$output) return $output; + + $member_info = $output->data; + $member_info->group_list = $this->getMemberGroups($member_info->member_srl); + + return $member_info; + } + + /** + * @brief userid에 해당하는 member_srl을 구함 + **/ + function getMemberSrlByUserID($user_id) { + $args->user_id = $user_id; + + $output = $this->executeQuery('member.getMemberSrl', $args); + return $output->data->member_srl; + } + + /** + * @brief userid에 해당하는 member_srl을 구함 + **/ + function getMemberSrlByEmailAddress($email_address) { + $args->email_address = $email_address; + + $output = $this->executeQuery('member.getMemberSrl', $args); + return $output->data->member_srl; + } + + /** + * @brief userid에 해당하는 member_srl을 구함 + **/ + function getMemberSrlByNickName($nick_name) { + $args->nick_name = $nick_name; + + $output = $this->executeQuery('member.getMemberSrl', $args); + return $output->data->member_srl; + } + + /** + * @brief 현재 접속자의 member_srl을 return + **/ + function getLoggedMemberSrl() { + if(!$this->isLogged()) return; + return $_SESSION['member_srl']; + } + + /** + * @brief 현재 접속자의 user_id을 return + **/ + function getLoggedUserID() { + if(!$this->isLogged()) return; + $logged_info = $_SESSION['logged_info']; + return $logged_info->user_id; + } + + /** + * @brief member_srl이 속한 group 목록을 가져옴 + **/ + function getMemberGroups($member_srl) { + $args->member_srl = $member_srl; + $output = $this->executeQuery('member.getMemberGroups', $args); + if(!$output->data) return; + + $group_list = $output->data; + if(!is_array($group_list)) $group_list = array($group_list); + + foreach($group_list as $group) { + $result[$group->group_srl] = $group->title; + } + return $result; + } + + /** + * @brief 기본 그룹을 가져옴 + **/ + function getDefaultGroup() { + $output = $this->executeQuery('member.getDefaultGroup'); + return $output->data; + } + + /** + * @brief group_srl에 해당하는 그룹 정보 가져옴 + **/ + function getGroup($group_srl) { + $args->group_srl = $group_srl; + + $output = $this->executeQuery('member.getGroup', $args); + return $output->data; + } + + /** + * @brief 그룹 목록을 가져옴 + **/ + function getGroups() { + $output = $this->executeQuery('member.getGroups'); + if(!$output->data) return; + + $group_list = $output->data; + if(!is_array($group_list)) $group_list = array($group_list); + + foreach($group_list as $val) { + $result[$val->group_srl] = $val; + } + return $result; + } + + /** + * @brief 금지 아이디 목록 가져오기 + **/ + function getDeniedIDList() { + $args->sort_index = "list_order"; + $args->page = Context::get('page'); + $args->list_count = 40; + $args->page_count = 10; + + $output = $this->executeQuery('member.getDeniedIDList', $args); + return $output; + } + + /** + * @brief 금지 아이디인지 확인 + **/ + function isDeniedID($user_id) { + $args->user_id = $user_id; + + $output = $this->executeQuery('member.chkDeniedID', $args); + if($output->data->count) return true; + return false; + } + + } +?>