diff --git a/modules/editor/editor.class.php b/modules/editor/editor.class.php
index 43db2119c..1c4e02d83 100644
--- a/modules/editor/editor.class.php
+++ b/modules/editor/editor.class.php
@@ -14,6 +14,18 @@
// 에디터 모듈에서 사용할 디렉토리 생성
FileHandler::makeDir('./files/cache/editor');
+ // 기본 에디터 컴포넌트를 추가
+ $oEditorController = &getController('editor');
+ $oEditorController->insertComponent('colorpicker_text',true);
+ $oEditorController->insertComponent('colorpicker_bg',true);
+ $oEditorController->insertComponent('emoticon',true);
+ $oEditorController->insertComponent('url_link',true);
+ $oEditorController->insertComponent('image_link',true);
+ $oEditorController->insertComponent('multimedia_link',true);
+ $oEditorController->insertComponent('image_gallery',true);
+ $oEditorController->insertComponent('quotation',true);
+ $oEditorController->insertComponent('table_maker',true);
+
return new Object();
}
diff --git a/modules/editor/editor.controller.php b/modules/editor/editor.controller.php
index b5a6bf091..8507dace5 100644
--- a/modules/editor/editor.controller.php
+++ b/modules/editor/editor.controller.php
@@ -13,6 +13,28 @@
function init() {
}
+ /**
+ * @brief 컴포넌트를 DB에 추가
+ **/
+ function insertComponent($component_name, $enabled = false) {
+ if($enabled) $enabled = 'Y';
+ else $enabled = 'N';
+
+ $oDB = &DB::getInstance();
+
+ $args->component_name = $component_name;
+ $args->enabled = $enabled;
+
+ // 컴포넌트가 있는지 확인
+ $output = $oDB->executeQuery('editor.isComponentInserted', $args);
+ if($output->data->count) return new Object(-1, 'msg_component_is_not_founded');
+
+ // 입력
+ $args->list_order = $oDB->getNextSequence();
+ $output = $oDB->executeQuery('editor.insertComponent', $args);
+ return $output;
+ }
+
/**
* @brief 컴포넌트에서 ajax요청시 해당 컴포넌트의 method를 실행
diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php
index 9067bcc7f..c11638990 100644
--- a/modules/editor/editor.model.php
+++ b/modules/editor/editor.model.php
@@ -24,6 +24,64 @@
return $oComponent;
}
+ /**
+ * @brief component 목록을 return (DB정보 보함)
+ **/
+ function getComponentList($filter_enabled = true) {
+ if($filter_enabled) $args->enabled = "Y";
+
+ // DB에서 가져옴
+ $oDB = &DB::getInstance();
+ $output = $oDB->executeQuery('editor.getComponentList', $args);
+ $db_list = $output->data;
+
+ // 파일목록을 구함
+ $downloaded_list = FileHandler::readDir($this->module_path.'components');
+
+ // DB 목록을 loop돌면서 xml정보까지 구함
+ if(!is_array($db_list)) $db_list = array($db_list);
+ foreach($db_list as $component) {
+ if(!$component->component_name) continue;
+
+ $component_name = $component->component_name;
+
+ unset($xml_info);
+ $xml_info = $this->getComponentXmlInfo($component_name);
+ $xml_info->enabled = $component->enabled;
+
+ if($component->extra_vars) {
+ $extra_vars = unserialize($component->extra_vars);
+ foreach($xml_info->extra_vars as $key => $val) {
+ $xml_info->extra_vars->{$key}->value = $extra_vars->{$key};
+ }
+ }
+
+ $component_list->{$component_name} = $xml_info;
+ }
+
+ // enabled만 체크하도록 하였으면 그냥 return
+ if($filter_enabled) return $component_list;
+
+ // 다운로드된 목록의 xml_info를 마저 구함
+ foreach($downloaded_list as $component_name) {
+ // 설정된 것이라면 패스
+ if($component_list->{$component_name}) continue;
+
+ // DB에 입력
+ $oEditorController = &getController('editor');
+ $oEditorController->insertComponent($component_name, false);
+
+ // component_list에 추가
+ unset($xml_info);
+ $xml_info = $this->getComponentXmlInfo($component_name);
+ $xml_info->enabled = 'N';
+
+ $component_list->{$component_name} = $xml_info;
+ }
+
+ return $component_list;
+ }
+
/**
* @brief component의 xml정보를 읽음
**/
diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php
index ff860dc7d..1b7870ccd 100644
--- a/modules/editor/editor.view.php
+++ b/modules/editor/editor.view.php
@@ -19,14 +19,10 @@
**/
function adminIndex() {
// 컴포넌트의 종류를 구해옴
- $component_list = FileHandler::readDir($this->module_path.'components');
- arsort($component_list);
-
$oEditorModel = &getModel('editor');
- foreach($component_list as $component) {
- $list[$component] = $xml_doc = $oEditorModel->getComponentXmlInfo($component);
- }
- Context::set('component_list', $list);
+ $component_list = $oEditorModel->getComponentList(false);
+
+ Context::set('component_list', $component_list);
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('admin_index');
@@ -42,8 +38,9 @@
// 에디터 컴포넌트를 구함
if(!Context::get('component_list')) {
- $component_list = FileHandler::readDir($this->module_path.'components');
- arsort($component_list);
+ $oEditorModel = &getModel('editor');
+ $component_list = $oEditorModel->getComponentList();
+ debugPrint($component_list);
Context::set('component_list', $component_list);
}
diff --git a/modules/editor/lang/ko.lang.php b/modules/editor/lang/ko.lang.php
index 380da3a9b..1793cc4ab 100644
--- a/modules/editor/lang/ko.lang.php
+++ b/modules/editor/lang/ko.lang.php
@@ -13,4 +13,5 @@
$lang->component_description = "설명";
$lang->msg_component_is_not_founded = '%s 에디터 컴포넌트를 찾을 수 없습니다';
+ $lang->msg_component_is_inserted = '선택하신 컴포넌트는 이미 입력되어 있습니다';
?>
diff --git a/modules/editor/queries/getComponentList.xml b/modules/editor/queries/getComponentList.xml
new file mode 100644
index 000000000..2fc576a90
--- /dev/null
+++ b/modules/editor/queries/getComponentList.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/editor/queries/insertComponent.xml b/modules/editor/queries/insertComponent.xml
new file mode 100644
index 000000000..a43032a9b
--- /dev/null
+++ b/modules/editor/queries/insertComponent.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/editor/queries/isComponentInserted.xml b/modules/editor/queries/isComponentInserted.xml
new file mode 100644
index 000000000..d7d505a0c
--- /dev/null
+++ b/modules/editor/queries/isComponentInserted.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/editor/queries/updateComponent.xml b/modules/editor/queries/updateComponent.xml
new file mode 100644
index 000000000..58e7c7478
--- /dev/null
+++ b/modules/editor/queries/updateComponent.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/editor/tpl/editor.html b/modules/editor/tpl/editor.html
index f9dc3d32f..5321c59c7 100644
--- a/modules/editor/tpl/editor.html
+++ b/modules/editor/tpl/editor.html
@@ -66,9 +66,9 @@
-
-
-

+
+
+