From 5e9d217f353ff18b25ce6856ce4a149d58e34b06 Mon Sep 17 00:00:00 2001 From: zero Date: Tue, 6 Mar 2007 04:01:44 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@283 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- layouts/sample_layout/conf/info.xml | 26 ++++ modules/board/tpl.admin/index.html | 2 +- modules/layout/addon.class.php | 13 ++ modules/layout/addon.controller.php | 74 +++++++++ modules/layout/addon.model.php | 145 ++++++++++++++++++ modules/layout/addon.view.php | 31 ++++ modules/layout/conf/info.xml | 11 ++ modules/layout/conf/module.xml | 6 + modules/layout/queries/deleteAddon.xml | 8 + .../layout/queries/getAddonIsActivated.xml | 11 ++ modules/layout/queries/getAddons.xml | 8 + modules/layout/queries/insertAddon.xml | 9 ++ modules/layout/schemas/addons.xml | 4 + modules/layout/tpl.admin/addon_list.html | 43 ++++++ .../filter/toggle_activate_addon.xml | 9 ++ modules/layout/tpl.admin/js/addon.js | 9 ++ 16 files changed, 408 insertions(+), 1 deletion(-) create mode 100644 layouts/sample_layout/conf/info.xml create mode 100644 modules/layout/addon.class.php create mode 100644 modules/layout/addon.controller.php create mode 100644 modules/layout/addon.model.php create mode 100644 modules/layout/addon.view.php create mode 100644 modules/layout/conf/info.xml create mode 100644 modules/layout/conf/module.xml create mode 100644 modules/layout/queries/deleteAddon.xml create mode 100644 modules/layout/queries/getAddonIsActivated.xml create mode 100644 modules/layout/queries/getAddons.xml create mode 100644 modules/layout/queries/insertAddon.xml create mode 100644 modules/layout/schemas/addons.xml create mode 100644 modules/layout/tpl.admin/addon_list.html create mode 100644 modules/layout/tpl.admin/filter/toggle_activate_addon.xml create mode 100644 modules/layout/tpl.admin/js/addon.js diff --git a/layouts/sample_layout/conf/info.xml b/layouts/sample_layout/conf/info.xml new file mode 100644 index 000000000..752d17635 --- /dev/null +++ b/layouts/sample_layout/conf/info.xml @@ -0,0 +1,26 @@ + + + 견본 레이아웃 + sample layout + + 제로 + zero + + 견본 레이아웃입니다. + 가장 기본적인 기능으로 이루어져 있습니다. + + sample layout + + + + 주메뉴 + main menu + 2 + + + 하단 메뉴 + bottom menu + 1 + + + diff --git a/modules/board/tpl.admin/index.html b/modules/board/tpl.admin/index.html index d73c055e4..65eedcb6b 100644 --- a/modules/board/tpl.admin/index.html +++ b/modules/board/tpl.admin/index.html @@ -4,7 +4,7 @@
- {number_format($total_count)}, + {$lang->total_count} {number_format($total_count)}, {$lang->page_count} : {number_format($page)} / {number_format($total_page)}
diff --git a/modules/layout/addon.class.php b/modules/layout/addon.class.php new file mode 100644 index 000000000..f88b2a2eb --- /dev/null +++ b/modules/layout/addon.class.php @@ -0,0 +1,13 @@ + diff --git a/modules/layout/addon.controller.php b/modules/layout/addon.controller.php new file mode 100644 index 000000000..e650f39eb --- /dev/null +++ b/modules/layout/addon.controller.php @@ -0,0 +1,74 @@ +isActivatedAddon($addon)) $this->doDeactivate($addon); + + // 비활성화 되어 있으면 활성화 시킴 + else $this->doActivate($addon); + } + + // 모듈에서 애드온을 사용하기 위한 캐시 파일 생성 + $buff = ""; + $addon_list = $oAddonModel->getActivatedAddons(); + $addon_count = count($addon_list); + for($i=0;$i<$addon_count;$i++) { + $addon = trim($addon_list[$i]); + if(!$addon) continue; + + $buff .= sprintf(' include("./addons/%s/%s.addon.php"); ', $addon, $addon); + } + + $buff = sprintf('', $buff); + + FileHandler::writeFile($this->cache_file, $buff); + + // 페이지를 애드온 목록으로 이동 + $this->setRedirectUrl("./?module=admin&act=dispAddonList"); + } + + /** + * @brief 애드온 활성화 + * + * addons라는 테이블에 애드온의 이름을 등록하는 것으로 활성화를 시키게 된다 + **/ + function doActivate($addon) { + $oDB = &DB::getInstance(); + $args->addon = $addon; + return $oDB->executeQuery('addon.insertAddon', $args); + } + + /** + * @brief 애드온 비활성화 + * + * addons라는 테이블에 애드온의 이름을 제거하는 것으로 비활성화를 시키게 된다 + **/ + function doDeactivate($addon) { + $oDB = &DB::getInstance(); + $args->addon = $addon; + return $oDB->executeQuery('addon.deleteAddon', $args); + } + + } +?> diff --git a/modules/layout/addon.model.php b/modules/layout/addon.model.php new file mode 100644 index 000000000..fe6ac6ea3 --- /dev/null +++ b/modules/layout/addon.model.php @@ -0,0 +1,145 @@ +getActivatedAddons(); + + // DB 객체 생성 + $oDB = &DB::getInstance(); + + // 다운받은 애드온과 설치된 애드온의 목록을 구함 + $downloaded_list = FileHandler::readDir('./files/addons'); + $installed_list = FileHandler::readDir('./addons'); + $searched_list = array_merge($downloaded_list, $installed_list); + $searched_count = count($searched_list); + if(!$searched_count) return; + + for($i=0;$i<$searched_count;$i++) { + // 애드온의 이름 + $addon_name = $searched_list[$i]; + + // 애드온의 경로 (files/addons가 우선) + $path = $this->getAddonPath($addon_name); + + // 해당 애드온의 정보를 구함 + $info = $this->getAddonInfoXml($addon_name); + unset($obj); + + $info->addon = $addon_name; + $info->path = $path; + + if(in_array($addon_name, $activated_addons)) $info->activated = true; + else $info->activated = false; + + $list[] = $info; + } + return $list; + } + + /** + * @brief 모듈의 conf/info.xml 을 읽어서 정보를 구함 + **/ + function getAddonInfoXml($addon) { + // 요청된 모듈의 경로를 구한다. 없으면 return + $addon_path = $this->getAddonPath($addon); + if(!$addon_path) return; + + // 현재 선택된 모듈의 스킨의 정보 xml 파일을 읽음 + $xml_file = sprintf("%sconf/info.xml", $addon_path); + if(!file_exists($xml_file)) return; + + $oXmlParser = new XmlParser(); + $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); + $xml_obj = $tmp_xml_obj->addon; + + if(!$xml_obj) return; + + $info->title = $xml_obj->title->body; + + // 작성자 정보 + $addon_info->title = $xml_obj->title->body; + $addon_info->version = $xml_obj->attrs->version; + $addon_info->author->name = $xml_obj->author->name->body; + $addon_info->author->email_address = $xml_obj->author->attrs->email_address; + $addon_info->author->homepage = $xml_obj->author->attrs->link; + $addon_info->author->date = $xml_obj->author->attrs->date; + $addon_info->author->description = $xml_obj->author->description->body; + + // history + if(!is_array($xml_obj->history->author)) $history[] = $xml_obj->history->author; + else $history = $xml_obj->history->author; + + foreach($history as $item) { + unset($obj); + $obj->name = $item->name->body; + $obj->email_address = $item->attrs->email_address; + $obj->homepage = $item->attrs->link; + $obj->date = $item->attrs->date; + $obj->description = $item->description->body; + $addon_info->history[] = $obj; + } + + return $addon_info; + } + + /** + * @brief 활성화된 애드온 목록을 구해옴 + **/ + function getActivatedAddons() { + $oDB = &DB::getInstance(); + $args->list_order = 'addon'; + $output = $oDB->executeQuery('addon.getAddons', $args); + if(!$output->data) return array(); + if(!is_array($output->data)) $output->data = array($output->data); + + $activated_count = count($output->data); + for($i=0;$i<$activated_count;$i++) { + $addon = $output->data[$i]; + $addon_list[] = $addon->addon; + } + return $addon_list; + } + + /** + * @brief 애드온이 활성화 되어 있는지 체크 + **/ + function isActivatedAddon($addon) { + $oDB = &DB::getInstance(); + $args->addon = $addon; + $output = $oDB->executeQuery('addon.getAddonIsActivated', $args); + if($output->data->count>0) return true; + return false; + } + + + } +?> diff --git a/modules/layout/addon.view.php b/modules/layout/addon.view.php new file mode 100644 index 000000000..0ca412d9b --- /dev/null +++ b/modules/layout/addon.view.php @@ -0,0 +1,31 @@ +setTemplatePath($this->module_path.'tpl.admin'); + } + + /** + * @brief 애드온 목록을 보여줌 + **/ + function dispAddonList() { + // 애드온 목록을 세팅 + $oAddonModel = &getModel('addon'); + $addon_list = $oAddonModel->getAddonList(); + Context::set('addon_list', $addon_list); + + $this->setTemplateFile('addon_list'); + } + + + } +?> diff --git a/modules/layout/conf/info.xml b/modules/layout/conf/info.xml new file mode 100644 index 000000000..dd61ab1ed --- /dev/null +++ b/modules/layout/conf/info.xml @@ -0,0 +1,11 @@ + + + 애드온 관리 + addon management + + 제로 + zero + 애드온 관리 모듈 + addon management + + diff --git a/modules/layout/conf/module.xml b/modules/layout/conf/module.xml new file mode 100644 index 000000000..000a88e93 --- /dev/null +++ b/modules/layout/conf/module.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/modules/layout/queries/deleteAddon.xml b/modules/layout/queries/deleteAddon.xml new file mode 100644 index 000000000..e80b07b87 --- /dev/null +++ b/modules/layout/queries/deleteAddon.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/modules/layout/queries/getAddonIsActivated.xml b/modules/layout/queries/getAddonIsActivated.xml new file mode 100644 index 000000000..63c925c4f --- /dev/null +++ b/modules/layout/queries/getAddonIsActivated.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/layout/queries/getAddons.xml b/modules/layout/queries/getAddons.xml new file mode 100644 index 000000000..a27f481bb --- /dev/null +++ b/modules/layout/queries/getAddons.xml @@ -0,0 +1,8 @@ + + +
+ + + + + diff --git a/modules/layout/queries/insertAddon.xml b/modules/layout/queries/insertAddon.xml new file mode 100644 index 000000000..066af5694 --- /dev/null +++ b/modules/layout/queries/insertAddon.xml @@ -0,0 +1,9 @@ + + +
+ + + + + + diff --git a/modules/layout/schemas/addons.xml b/modules/layout/schemas/addons.xml new file mode 100644 index 000000000..37230d0cd --- /dev/null +++ b/modules/layout/schemas/addons.xml @@ -0,0 +1,4 @@ +
+ + +
diff --git a/modules/layout/tpl.admin/addon_list.html b/modules/layout/tpl.admin/addon_list.html new file mode 100644 index 000000000..4dcb09863 --- /dev/null +++ b/modules/layout/tpl.admin/addon_list.html @@ -0,0 +1,43 @@ + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
{$lang->addon_name}{$lang->version}{$lang->author}{$lang->date}{$lang->installed_path}{$lang->use}
+ {$val->title}
+ ({$val->addon}) +
{$val->version}{$val->author->name}{$val->author->date}{$val->path} + + {$lang->notuse} + + {$lang->use} + +
+ {nl2br($val->author->description)} +
diff --git a/modules/layout/tpl.admin/filter/toggle_activate_addon.xml b/modules/layout/tpl.admin/filter/toggle_activate_addon.xml new file mode 100644 index 000000000..e18e2f683 --- /dev/null +++ b/modules/layout/tpl.admin/filter/toggle_activate_addon.xml @@ -0,0 +1,9 @@ + +
+ + + + + + +
diff --git a/modules/layout/tpl.admin/js/addon.js b/modules/layout/tpl.admin/js/addon.js new file mode 100644 index 000000000..e1cedd536 --- /dev/null +++ b/modules/layout/tpl.admin/js/addon.js @@ -0,0 +1,9 @@ +/** + * @brief 애드온의 활성/비활성 토글용 함수 + * fo_addon이라는 id를 가지는 form에 인자로 주어진 addon값을 세팅후 실행 + **/ +function doToggleAddon(addon) { + var fo_obj = xGetElementById('fo_addon'); + fo_obj.addon.value = addon; + procFilter(fo_obj, toggle_activate_addon); +}