From 87471eb693b86a0bb70714cc54642822c60e45d9 Mon Sep 17 00:00:00 2001 From: zero Date: Wed, 14 Mar 2007 11:34:57 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@438 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/plugin/PluginHandler.class.php | 30 +++++++++++++++++-- classes/template/TemplateHandler.class.php | 2 +- layouts/sample_layout/layout.html | 2 ++ modules/plugin/lang/ko.lang.php | 4 +++ .../newest_document/newest_document.class.php | 2 +- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/classes/plugin/PluginHandler.class.php b/classes/plugin/PluginHandler.class.php index ea9839116..5c406f9bc 100644 --- a/classes/plugin/PluginHandler.class.php +++ b/classes/plugin/PluginHandler.class.php @@ -6,11 +6,35 @@ * @todo 미구현 **/ - class PluginHandler extends Object { + class PluginHandler { + /** + * @brief 플러그인을 찾아서 실행하고 결과를 출력 + *
태그 사용 templateHandler에서 PluginHandler::execute()를 실행하는 코드로 대체하게 된다 + **/ function execute($plugin, $args) { - debugPrint($plugin); - debugPrint($args); + + // 일단 플러그인의 위치를 찾음 + $oPluginModel = &getModel('plugin'); + $path = $oPluginModel->getPluginPath($plugin); + + // 플러그인 클래스 파일을 찾고 없으면 에러 출력 (html output) + $class_file = sprintf('%s%s.class.php', $path, $plugin); + if(!file_exists($class_file)) return sprintf(Context::getLang('msg_plugin_is_not_exists'), $plugin); + + // 플러그인 클래스를 include + require_once($class_file); + + // 객체 생성 + $eval_str = sprintf('$oPlugin = new %s();', $plugin); + @eval($eval_str); + if(!is_object($oPlugin)) return sprintf(Context::getLang('msg_plugin_object_is_null'), $plugin); + + if(!method_exists($oPlugin, 'proc')) return sprintf(Context::getLang('msg_plugin_proc_is_null'), $plugin); + + // 플러그인 실행 + $output = $oPlugin->proc($args); + print $output; } } diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index 1364541c7..43bde19c9 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -300,7 +300,7 @@ if(!$args) $args = null; // 플러그인 실행코드를 삽입 - return sprintf('', $plugin, $args); + return sprintf('', $plugin, $args); } /** diff --git a/layouts/sample_layout/layout.html b/layouts/sample_layout/layout.html index 85f43061c..1a30b6c08 100644 --- a/layouts/sample_layout/layout.html +++ b/layouts/sample_layout/layout.html @@ -44,6 +44,8 @@ +
+
diff --git a/modules/plugin/lang/ko.lang.php b/modules/plugin/lang/ko.lang.php index fe8feaf22..becc8bc8f 100644 --- a/modules/plugin/lang/ko.lang.php +++ b/modules/plugin/lang/ko.lang.php @@ -13,4 +13,8 @@ $lang->plugin_info = '플러그인 정보'; $lang->plugin_code = '코드'; $lang->about_plugin_code = '생성된 코드는 제로보드XE 내의 템플릿 내용에 추가하시면 동작하게 됩니다'; + + $lang->msg_plugin_is_not_exists = '%s 플러그인을 찾을 수 없습니다'; + $lang->msg_plugin_object_is_null = '%s 플러그인의 객체 생성을 할 수가 없습니다'; + $lang->msg_plugin_proc_is_null = '%s 플러그인의 proc() 를 실행할 수가 없습니다'; ?> diff --git a/plugins/newest_document/newest_document.class.php b/plugins/newest_document/newest_document.class.php index 02904385c..3498cf54a 100644 --- a/plugins/newest_document/newest_document.class.php +++ b/plugins/newest_document/newest_document.class.php @@ -7,7 +7,7 @@ * @version 0.1 **/ - function class newest_document extends Plugin { + class newest_document extends PluginHandler { }