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

This commit is contained in:
zero 2007-03-27 04:52:30 +00:00
parent 4891ba3a61
commit d38cdb1018
9 changed files with 64 additions and 46 deletions

View file

@ -705,6 +705,9 @@
* @brief 내용의 플러그인이나 기타 기능에 대한 code를 실제 code로 변경
**/
function transContent($content) {
// 플러그인 변경
$content = preg_replace_callback('!<img([^\>]*)plugin=([^\>]*?)\>!is', array($this,'_transPlugin'), $content);
// 에디터 컴포넌트를 찾아서 결과 코드로 변환
$content = preg_replace_callback('!<div([^\>]*)editor_component=([^\>]*)>(.*?)\<\/div\>!is', array($this,'_transEditorComponent'), $content);
$content = preg_replace_callback('!<img([^\>]*)editor_component=([^\>]*?)\>!is', array($this,'_transEditorComponent'), $content);
@ -747,5 +750,29 @@
return $oComponent->transHTML($xml_doc);
}
/**
* @brief 플러그인 코드를 실제 php코드로 변경
**/
function _transPlugin($matches) {
$oXmlParser = new XmlParser();
$xml_doc = $oXmlParser->parse($matches[0]);
$vars = $xml_doc->attrs;
if(!$vars->plugin) return "";
// 플러그인의 이름을 구함
$plugin = $vars->plugin;
unset($vars->plugin);
// className, style attribute를 구해 놓음
$className = $vars->class;
$style = $vars->style;
unset($vars->class);
unset($vars->style);
unset($vars->src);
return PluginHandler::execute($plugin, $vars);
}
}
?>

View file

@ -19,7 +19,7 @@
// 플러그인 실행
$output = $oPlugin->proc($args);
print $output;
return $output;
}
/**

View file

@ -93,9 +93,6 @@
// import xml filter/ css/ js/ 언어파일 <!--%filename-->
$buff = preg_replace_callback('!<\!--%import\(\"([^\"]*?)\"\)-->!is', array($this, '_compileImportCode'), $buff);
// plugin 코드 변경
$buff = preg_replace_callback('!<div plugin=([^<]*?)<\/div>!is', array($this, '_compilePluginCode'), $buff);
// 파일에 쓰기 전에 직접 호출되는 것을 방지
$buff = sprintf('%s%s%s','<?php if(!__ZBXE__) exit();?>',"\n",$buff);
@ -284,43 +281,6 @@
return $output;
}
/**
* @brief 플러그인 코드를 실제 php코드로 변경
**/
function _compilePluginCode($matches) {
$oXmlParser = new XmlParser();
$xml_doc = $oXmlParser->parse($matches[0]);
$vars = $xml_doc->div->attrs;
if(!$vars->plugin) return "";
// 플러그인의 이름을 구함
$plugin = $vars->plugin;
unset($vars->plugin);
// className, style attribute를 구해 놓음
$className = $vars->class;
$style = $vars->style;
unset($vars->class);
unset($vars->style);
// 플러그인의 변수들을 세팅
$vars_count = get_object_vars($vars);
if($vars_count) {
foreach($vars as $key => $val) {
$key = str_replace('"','\"', $key);
$val = str_replace('"','\"', $val);
$args_list[] = sprintf('"%s"=>"%s"', $key, $val);
}
$args = sprintf('array(%s)', implode(',',$args_list));
}
if(!$args) $args = null;
// 플러그인 실행코드를 삽입
return sprintf('<div %s %s><?php print PluginHandler::execute("%s", %s); ?></div>', $className?'class="'.$className.'" ':'', $style?'style="'.$style.'" ':'',$plugin, $args);
}
/**
* @brief $tpl_file로 compiled_tpl_file이름을 return
**/