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

This commit is contained in:
zero 2007-06-19 09:11:10 +00:00
parent 15801d738a
commit 8390ec57e2
75 changed files with 484 additions and 484 deletions

View file

@ -767,11 +767,11 @@
}
/**
* @brief 내용의 플러그인이나 기타 기능에 대한 code를 실제 code로 변경
* @brief 내용의 위젯이나 기타 기능에 대한 code를 실제 code로 변경
**/
function transContent($content) {
// 플러그인 코드 변경
$content = preg_replace_callback('!<img([^\>]*)plugin=([^\>]*?)\>!is', array($this,'_transPlugin'), $content);
// 위젯 코드 변경
$content = preg_replace_callback('!<img([^\>]*)widget=([^\>]*?)\>!is', array($this,'_transWidget'), $content);
// 에디터 컴포넌트를 찾아서 결과 코드로 변환
$content = preg_replace_callback('!<div([^\>]*)editor_component=([^\>]*)>(.*?)\<\/div\>!is', array($this,'_transEditorComponent'), $content);
@ -812,7 +812,7 @@
$buff = preg_replace('/([^=^"^ ]*)=([^"])([^=^ ]*)/i', '$1="$2$3"', $buff);
$buff = str_replace("&","&amp;",$buff);
// 플러그인에서 생성된 코드 (img, div태그내에 editor_plugin코드 존재)의 parameter를 추출
// 위젯에서 생성된 코드 (img, div태그내에 editor_widget코드 존재)의 parameter를 추출
$oXmlParser = new XmlParser();
$xml_doc = $oXmlParser->parse($buff);
if($xml_doc->div) $xml_doc = $xml_doc->div;
@ -832,9 +832,9 @@
}
/**
* @brief 플러그인 코드를 실제 php코드로 변경
* @brief 위젯 코드를 실제 php코드로 변경
**/
function _transPlugin($matches) {
function _transWidget($matches) {
// IE에서는 태그의 특성중에서 " 를 빼어 버리는 경우가 있기에 정규표현식으로 추가해줌
$buff = $matches[0];
$buff = preg_replace('/([^=^"^ ]*)=([^"])([^=^ ]*)/i', '$1="$2$3"', $buff);
@ -846,13 +846,13 @@
if($xml_doc->img) $vars = $xml_doc->img->attrs;
else $vars = $xml_doc->attrs;
if(!$vars->plugin) return "";
if(!$vars->widget) return "";
// 플러그인의 이름을 구함
$plugin = $vars->plugin;
unset($vars->plugin);
// 위젯의 이름을 구함
$widget = $vars->widget;
unset($vars->widget);
return PluginHandler::execute($plugin, $vars);
return WidgetHandler::execute($widget, $vars);
}
}

View file

@ -7,7 +7,7 @@
* Response Method에 따라서 html or xml 출력방법을 결정한다
* xml : oModule의 variables를 simple xml 출력
* html : oModule의 template/variables로 html을 만들고 contents_html로 처리
* plugin이나 layout의 html과 연동하여 출력
* widget이나 layout의 html과 연동하여 출력
**/
class DisplayHandler extends Handler {
@ -45,13 +45,13 @@
if(__DEBUG__==3) $GLOBALS['__layout_compile_elapsed__'] = getMicroTime()-$start;
// 각 플러그인, 에디터 컴포넌트의 코드 변경
// 각 위젯, 에디터 컴포넌트의 코드 변경
if(__DEBUG__==3) $start = getMicroTime();
$oContext = &Context::getInstance();
$zbxe_final_content= $oContext->transContent($zbxe_final_content);
if(__DEBUG__==3) $GLOBALS['__trans_plugin_editor_elapsed__'] = getMicroTime()-$start;
if(__DEBUG__==3) $GLOBALS['__trans_widget_editor_elapsed__'] = getMicroTime()-$start;
// 최종 결과를 common_layout에 넣어버림
Context::set('zbxe_final_content', $zbxe_final_content);
@ -187,14 +187,14 @@
$buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']);
$buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end-__StartTime__-$GLOBALS['__template_elapsed__']-$GLOBALS['__xmlparse_elapsed__']-$GLOBALS['__db_elapsed_time__']-$GLOBALS['__elapsed_class_load__']);
// 플러그인 실행 시간 작성
$buff .= sprintf("\n\tPlugins elapsed time \t\t: %0.5f sec", $GLOBALS['__plugin_excute_elapsed__']);
// 위젯 실행 시간 작성
$buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
// 레이아웃 실행 시간
$buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
// 플러그인, 에디터 컴포넌트 치환 시간
$buff .= sprintf("\n\tTrans plugin&editor elapsed time: %0.5f sec\n\n", $GLOBALS['__trans_plugin_editor_elapsed__']);
// 위젯, 에디터 컴포넌트 치환 시간
$buff .= sprintf("\n\tTrans widget&editor elapsed time: %0.5f sec\n\n", $GLOBALS['__trans_widget_editor_elapsed__']);
}
// 전체 실행 시간 작성

View file

@ -1,63 +1,63 @@
<?php
/**
* @class PluginHandler
* @class WidgetHandler
* @author zero (zero@nzeo.com)
* @brief 플러그인실행을 담당
* @brief 위젯실행을 담당
**/
class PluginHandler {
class WidgetHandler {
var $plugin_path = '';
var $widget_path = '';
/**
* @brief 플러그인찾아서 실행하고 결과를 출력
* <div plugin='플러그인'...></div> 태그 사용 templateHandler에서 PluginHandler::execute() 실행하는 코드로 대체하게 된다
* @brief 위젯찾아서 실행하고 결과를 출력
* <div widget='위젯'...></div> 태그 사용 templateHandler에서 WidgetHandler::execute() 실행하는 코드로 대체하게 된다
**/
function execute($plugin, $args) {
// 디버그를 위한 플러그인 실행 시간 저장
function execute($widget, $args) {
// 디버그를 위한 위젯 실행 시간 저장
if(__DEBUG__==3) $start = getMicroTime();
// $plugin의 객체를 받음
$oPlugin = PluginHandler::getObject($plugin);
// $widget의 객체를 받음
$oWidget = WidgetHandler::getObject($widget);
// 플러그인 실행
if($oPlugin) {
$output = $oPlugin->proc($args);
// 위젯 실행
if($oWidget) {
$output = $oWidget->proc($args);
}
if(__DEBUG__==3) $GLOBALS['__plugin_excute_elapsed__'] += getMicroTime() - $start;
if(__DEBUG__==3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start;
return $output;
}
/**
* @brief 플러그인 객체를 return
* @brief 위젯 객체를 return
**/
function getObject($plugin) {
if(!$GLOBALS['_xe_loaded_plugins_'][$plugin]) {
// 일단 플러그인의 위치를 찾음
$oPluginModel = &getModel('plugin');
$path = $oPluginModel->getPluginPath($plugin);
function getObject($widget) {
if(!$GLOBALS['_xe_loaded_widgets_'][$widget]) {
// 일단 위젯의 위치를 찾음
$oWidgetModel = &getModel('widget');
$path = $oWidgetModel->getWidgetPath($widget);
// 플러그인 클래스 파일을 찾고 없으면 에러 출력 (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);
// 위젯 클래스 파일을 찾고 없으면 에러 출력 (html output)
$class_file = sprintf('%s%s.class.php', $path, $widget);
if(!file_exists($class_file)) return sprintf(Context::getLang('msg_widget_is_not_exists'), $widget);
// 플러그인 클래스를 include
// 위젯 클래스를 include
require_once($class_file);
// 객체 생성
$eval_str = sprintf('$oPlugin = new %s();', $plugin);
$eval_str = sprintf('$oWidget = new %s();', $widget);
@eval($eval_str);
if(!is_object($oPlugin)) return sprintf(Context::getLang('msg_plugin_object_is_null'), $plugin);
if(!is_object($oWidget)) return sprintf(Context::getLang('msg_widget_object_is_null'), $widget);
if(!method_exists($oPlugin, 'proc')) return sprintf(Context::getLang('msg_plugin_proc_is_null'), $plugin);
if(!method_exists($oWidget, 'proc')) return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget);
$oPlugin->plugin_path = $path;
$oWidget->widget_path = $path;
$GLOBALS['_xe_loaded_plugins_'][$plugin] = $oPlugin;
$GLOBALS['_xe_loaded_widgets_'][$widget] = $oWidget;
}
return $GLOBALS['_xe_loaded_plugins_'][$plugin];
return $GLOBALS['_xe_loaded_widgets_'][$widget];
}
}