git-svn-id: http://xe-core.googlecode.com/svn/trunk@652 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-03-26 06:14:02 +00:00
parent 19f925f0e0
commit d703b6d15a
6 changed files with 103 additions and 25 deletions

View file

@ -6,8 +6,9 @@
<description xml:lang="ko">네이버에서 제공하는 네이버 지도 open api를 이용하여 에디터에 원하는 곳의 지도를 추가하거나 수정할 수 있습니다.\n네이버 지도 open api키를 발급 받아서 등록을 해주셔야 정상적인 사용이 가능합니다.</description>
</author>
<extra_vars>
<var name="api_key" type="text">
<var name="api_key">
<title xml:lang="ko">네이버지도 api key</title>
<description xml:lang="ko">http://www.naver.com/ 에서 네이버 지도 API key를 발급 받으신 후 입력해주세요.</description>
</var>
</extra_vars>
</component>

View file

@ -11,6 +11,9 @@
* @brief 설치시 추가 작업이 필요할시 구현
**/
function moduleInstall() {
// 에디터 모듈에서 사용할 디렉토리 생성
FileHandler::makeDir('./files/cache/editor');
return new Object();
}
@ -27,22 +30,5 @@
function moduleUpdate() {
return new Object();
}
/**
* @brief component의 객체 생성
**/
function getComponentObject($component, $upload_target_srl = 0) {
// 해당 컴포넌트의 객체를 생성해서 실행
$class_path = sprintf('%scomponents/%s/', $this->module_path, $component);
$class_file = sprintf('%s%s.class.php', $class_path, $component);
if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
require_once($class_file);
$eval_str = sprintf('$oComponent = new %s("%s","%s");', $component, $upload_target_srl, $class_path);
@eval($eval_str);
if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
return $oComponent;
}
}
?>

View file

@ -22,7 +22,8 @@
$method = Context::get('method');
if(!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
$oComponent = &$this->getComponentObject($component);
$oEditorModel = &getModel('editor');
$oComponent = &$oEditorModel->getComponentObject($component);
if(!$oComponent->toBool()) return $oComponent;
if(!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));

View file

@ -0,0 +1,87 @@
<?php
/**
* @class editorModel
* @author zero (zero@nzeo.com)
* @brief editor 모듈의 model 클래스
**/
class editorModel extends editor {
/**
* @brief component의 객체 생성
**/
function getComponentObject($component, $upload_target_srl = 0) {
// 해당 컴포넌트의 객체를 생성해서 실행
$class_path = sprintf('%scomponents/%s/', $this->module_path, $component);
$class_file = sprintf('%s%s.class.php', $class_path, $component);
if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
require_once($class_file);
$eval_str = sprintf('$oComponent = new %s("%s","%s");', $component, $upload_target_srl, $class_path);
@eval($eval_str);
if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
return $oComponent;
}
/**
* @brief component의 xml정보를 읽음
**/
function getComponentXmlInfo($component) {
// 요청된 컴포넌트의 xml파일 위치를 구함
$component_path = sprintf('%scomponents/%s/', $this->module_path, $component);
$xml_file = sprintf('%sinfo.xml', $component_path);
$cache_file = sprintf('./files/cache/editor/%s.php', $component);
// 캐시된 xml파일이 있으면 include 후 정보 return
if(file_exists($cache_file) && filectime($cache_file) > filectime($xml_file)) {
@include $cache_file;
return $xml_info;
}
// 캐시된 파일이 없으면 파싱후 캐싱 후 return
$oParser = new XmlParser();
$xml_doc = $oParser->loadXmlFile($xml_file);
// 정보 정리
$xml_info->component_name = $component;
$xml_info->author->name = $xml_doc->component->author->name->body;
$xml_info->author->email_address = $xml_doc->component->author->attrs->email_address;
$xml_info->author->link = $xml_doc->component->author->attrs->link;
$xml_info->author->date = $xml_doc->component->author->attrs->date;
$xml_info->description = str_replace('\n', "\n", $xml_doc->component->author->description->body);
$buff = '<?php if(!__ZB5__) exit(); ';
$buff .= sprintf('$xml_info->component_name = "%s";', $component);
$buff .= sprintf('$xml_info->author->name = "%s";', $xml_info->author->name);
$buff .= sprintf('$xml_info->author->email_address = "%s";', $xml_info->author->email_address);
$buff .= sprintf('$xml_info->author->link = "%s";', $xml_info->author->link);
$buff .= sprintf('$xml_info->author->date = "%s";', $xml_info->author->date);
$buff .= sprintf('$xml_info->description = "%s";', $xml_info->description);
// 추가 변수 정리 (에디터 컴포넌트에서는 text형만 가능)
$extra_vars = $xml_doc->component->extra_vars->var;
if($extra_vars) {
if(!is_array($extra_vars)) $extra_vars = array($extra_vars);
foreach($extra_vars as $key => $val) {
unset($obj);
$key = $val->attrs->name;
$title = $val->title->body;
$description = $val->description->body;
$xml_info->extra_vars->{$key}->title = $title;
$xml_info->extra_vars->{$key}->description = $description;
$buff .= sprintf('$xml_info->extra_vars->%s->%s = "%s";', $key, 'title', $title);
$buff .= sprintf('$xml_info->extra_vars->%s->%s = "%s";', $key, 'description', $description);
}
}
$buff .= ' ?>';
FileHandler::writeFile($cache_file, $buff, "w");
return $xml_doc->component;
}
}
?>

View file

@ -21,6 +21,11 @@
// 컴포넌트의 종류를 구해옴
$component_list = FileHandler::readDir($this->module_path.'components');
arsort($component_list);
$oEditorModel = &getModel('editor');
foreach($component_list as $component) {
$xml_doc = $oEditorModel->getComponentXmlInfo($component);
}
Context::set('component_list', $component_list);
}
@ -60,7 +65,8 @@
$component = Context::get('component');
// component 객체를 받음
$oComponent = &$this->getComponentObject($component, $upload_target_srl);
$oEditorModel = &getModel('editor');
$oComponent = &$oEditorModel->getComponentObject($component, $upload_target_srl);
if(!$oComponent->toBool()) {
Context::set('message', sprintf(Context::getLang('msg_component_is_not_founded'), $component));
$this->setTemplatePath($this->module_path.'tpl');