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
**/

View file

@ -25,6 +25,12 @@ a.bold {
border:3px dotted #2661db;
}
.zbxe_plugin_output {
background:url(../tpl/images/multimedia_icon.gif) no-repeat center;
background-color:#FFFFFF;
border:3px dotted #039311;
}
h1 {
font-size:20pt;
font-weight:bold;

View file

@ -16,10 +16,10 @@
<div class="item_area" id="col_row_area" style="display:none" >
<div class="header">{$lang->table_cols_count} :</div>
<div class="body"><input type="text" class="table_input" id="cols_count" value="3" /></div>
<div class="body"><input type="text" class="table_input" id="cols_count" value="2" /></div>
<div class="header">{$lang->table_rows_count} :</div>
<div class="body"><input type="text" class="table_input" id="rows_count" value="3" /></div>
<div class="body"><input type="text" class="table_input" id="rows_count" value="1" /></div>
</div>
<div class="item_area">

View file

@ -33,7 +33,8 @@
}
}
$plugin_code = sprintf('<div plugin="%s" %s></div>', $plugin, implode(' ',$attribute));
$blank_img_path = "./common/tpl/images/blank.gif";
$plugin_code = sprintf('<img src="%s" class="zbxe_plugin_output" plugin="%s" %s style="width:100px;height:100px;"/>', $blank_img_path, $plugin, implode(' ',$attribute));
// 코드 출력
$this->add('plugin_code', $plugin_code);

View file

@ -0,0 +1,7 @@
<filter name="generate_code_in_page" module="plugin" act="procGenerateCode">
<response callback_func="completeGenerateCodeInPage">
<tag name="error" />
<tag name="message" />
<tag name="plugin_code" />
</response>
</filter>

View file

@ -5,3 +5,19 @@ function completeGenerateCode(ret_obj) {
var zone = xGetElementById("plugin_code");
zone.value = plugin_code;
}
/* 생성된 코드를 에디터에 출력 */
function completeGenerateCodeInPage(ret_obj,response_tags,params,fo_obj) {
var plugin_code = ret_obj["plugin_code"];
var module_srl = fo_obj.module_srl.value;
if(!opener || !plugin_code || !module_srl) {
window.close();
return;
}
opener.editorFocus(module_srl);
var iframe_obj = opener.editorGetIFrame(module_srl);
opener.editorReplaceHTML(iframe_obj, plugin_code);
opener.editorFocus(module_srl);
}

View file

@ -1,9 +1,10 @@
<!--%import("filter/generate_code.xml")-->
<!--%import("filter/generate_code_in_page.xml")-->
<!--%import("js/admin.js")-->
<!--%import("css/plugin.css")-->
<form action="./" method="get" onsubmit="return procFilter(this, generate_code);">
<form action="./" method="get" onsubmit="return procFilter(this, generate_code_in_page);">
<input type="hidden" name="selected_plugin" value="{$selected_plugin}" />
<input type="hidden" name="module_srl" value="{$module_srl}" />
<div class="plugin_detail_info_window">