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

This commit is contained in:
zero 2007-03-19 06:26:49 +00:00
parent cc0b017bcc
commit 5d59f2b8f9
13 changed files with 197 additions and 153 deletions

View file

@ -13,6 +13,18 @@
**/
function execute($plugin, $args) {
// $plugin의 객체를 받음
$oPlugin = PluginHandler::getObject($plugin);
// 플러그인 실행
$output = $oPlugin->proc($args);
print $output;
}
/**
* @brief 플러그인 객체를 return
**/
function getObject($plugin) {
// 일단 플러그인의 위치를 찾음
$oPluginModel = &getModel('plugin');
$path = $oPluginModel->getPluginPath($plugin);
@ -30,10 +42,6 @@
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;
}
}

View file

@ -32,25 +32,33 @@ function toggleDisplay(obj, opt) {
}
// 멀티미디어 출력용 (IE에서 플래쉬/동영상 주변에 점선 생김 방지용)
function displayMultimedia(type, src, style) {
function displayMultimedia(src, width, height, auto_start) {
var ext = src.split(".");
var type = ext[ext.length-1];
if(auto_start) auto_start = 1;
else auto_start = 0;
var clsid = "";
var codebase = "";
var html = "";
switch(type) {
case "flv" :
html = "<embed src=\"./common/tpl/images/flvplayer.swf?autoStart="+auto_start+"&file="+src+"\" width=\""+width+"\" height=\""+height+"\" type=\"application/x-shockwave-flash\"></embed>";
break;
case "swf" :
clsid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.c-ab#version=6,0,29,0";
html = ""+
"<object classid=\""+clsid+"\" codebase=\""+codebase+"\" "+style+">"+
"<object classid=\""+clsid+"\" codebase=\""+codebase+"\" width=\""+width+"\" hegiht=\""+height+"\" >"+
"<param name=\"movie\" value=\""+src+"\" />"+
"<param name=\"quality\" value=\"high\" />"+
"<embed src=\""+src+"\" autostart=\"0\" "+style+"></embed>"+
"<embed src=\""+src+"\" autostart=\""+auto_start+"\" "+style+"></embed>"+
"<\/object>";
break;
default :
html = ""+
"<embed src=\""+src+"\" autostart=\"0\" "+style+"></embed>";
"<embed src=\""+src+"\" autostart=\""+auto_start+"\" width=\""+width+"\" hegiht=\""+height+"\"></embed>";
break;
}

View file

@ -18,7 +18,7 @@
/**
* @brief debug mode = true 일때 files/_debug_message.php 디버그 내용이 쌓임
**/
define('__DEBUG__', true);
define('__DEBUG__', false);
if(__DEBUG__) {
// php5이상이면 error handling을 handleError() 로 set

View file

@ -44,12 +44,12 @@
$document->title = $document->content = Context::getLang('msg_is_secret');
}
// 내용 변경
$document->content = $this->transContent($document->content);
// 확장 정보(코멘트나 기타 등등) 플래그가 false이면 기본 문서 정보만 return
if(!$get_extra_info) return $document;
// 내용 변경
$document->content = $this->transContent($document->content);
// document controller 객체 생성
$oDocumentController = &getController('document');
@ -318,8 +318,8 @@
* @brief 내용의 플러그인이나 기타 기능에 대한 code를 실제 code로 변경
**/
function transContent($content) {
// 멀티미디어 코드의 변환
$content = preg_replace_callback('!<img([^\>]*)editor_multimedia([^\>]*?)>!is', array($this,'_transMultimedia'), $content);
// 에디터 컴포넌트를 찾아서 결과 코드로 변환
$content = preg_replace_callback('!<(div|img) editor_component="([a-zA-Z\_^\"]+)"([^\>]*?)>!is', array($this,'_transMultimedia'), $content);
// <br> 코드 변환
$content = str_replace(array("<BR>","<br>","<Br>"),"<br />", $content);
@ -335,19 +335,24 @@
* <img ... class="multimedia" ..> 되어 있는 코드를 변경
**/
function _transMultimedia($matches) {
preg_match("/style\=(\"|'){0,1}([^\"\']+)(\"|'){0,1}/i",$matches[0], $buff);
$style = str_replace("\"","'",$buff[0]);
preg_match("/alt\=\"{0,1}([^\"]+)\"{0,1}/i",$matches[0], $buff);
$opt = explode('|@|',$buff[1]);
if(count($opt)<1) return $matches[0];
// 플러그인에서 생성된 코드 (img, div태그내에 plugin코드 존재)의 parameter를 추출
$oXmlParser = new XmlParser();
$xml_doc = $oXmlParser->parse($matches[0]);
for($i=0;$i<count($opt);$i++) {
$pos = strpos($opt[$i],"=");
$cmd = substr($opt[$i],0,$pos);
$val = substr($opt[$i],$pos+1);
$obj->{$cmd} = $val;
}
return sprintf("<script type=\"text/javascript\">displayMultimedia(\"%s\", \"%s\", \"%s\");</script>", $obj->type, $obj->src, $style);
// plugin attribute가 없으면 return
$editor_component = $xml_doc->attrs->editor_component;
if(!$editor_component) return $matches[0];
// editor class 객체 생성하여 component 객체 받음
$oEditor = &getClass('editor');
if(!is_object($oEditor)) return $matches[0];
// component::transHTML() 을 이용하여 변환된 코드를 받음
$oComponent = &$oEditor->getComponentObject($editor_component, 0);
if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $matches[0];
return $oComponent->transHTML($xml_doc);
//return sprintf("<script type=\"text/javascript\">displayMultimedia(\"%s\", \"%s\", \"%s\");</script>", $obj->type, $obj->src, $style);
}
}
?>

View file

@ -53,5 +53,32 @@
return $oTemplate->compile($tpl_path, $tpl_file);
}
/**
* @brief 에디터 컴포넌트가 별도의 고유 코드를 이용한다면 코드를 html로 변경하여 주는 method
*
* 이미지나 멀티미디어, 설문등 고유 코드가 필요한 에디터 컴포넌트는 고유코드를 내용에 추가하고 나서
* DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경
**/
function transHTML($xml_obj) {
$src = $xml_obj->attrs->src;
$alt = $xml_obj->attrs->alt;
$width = $xml_obj->attrs->width;
$height = $xml_obj->attrs->height;
$align = $xml_obj->attrs->align;
$border = $xml_obj->attrs->border;
$src = str_replace(array('&','"'), array('&amp;','&qout;'), $src);
if(!$alt) $alt = $src;
$output = array();
$output = array("src=\"".$src."\"");
if($alt) $output[] = "alt=\"".$alt."\"";
if($width) $output[] = "width=\"".$width."\"";
if($height) $output[] = "height=\"".$height."\"";
if($align) $output[] = "align=\"".$align."\"";
if($border) $output[] = "border=\"".$border."\"";
return "<img ".implode(" ", $output)." />";
}
}
?>

View file

@ -1,56 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>add Image</title>
<link rel='stylesheet' href='../css/editor.css' type='text/css' />
<script type='text/javascript' src='../../common/js/x.js'></script>
<script type='text/javascript' src='../../common/js/common.js'></script>
<script type='text/javascript' src='../js/editor.js'></script>
<script type='text/javascript'>
function insertImage() {
if(typeof(opener)=='undefined') return;
var fo_obj = xGetElementById("fo");
var url = fo_obj.url.value;
var align = fo_obj.align.options[fo_obj.align.selectedIndex].value;
if(url) {
opener.editorInsertImage(url, align);
opener.editorFocus(opener.editorPrevSrl);
}
self.close();
}
xAddEventListener(window, 'load', setFixedPopupSize);
</script>
</head>
<body class="editor_pop_body">
<form action='./' method='post' id="fo" onSubmit="return false" style="display:inline">
<div id='zone_AddUrl' class="editor_window">
<table width="380" border="0" cellspacing="1" cellpadding="0">
<col width="50" />
<col width="*" />
<tr>
<td class="editor_field">url</td>
<td><input type='text' name='url' class="editor_input" value='<?=$_GET['file_url']?>'/></td>
</tr>
<tr>
<td class="editor_field">type</td>
<td>
<select name='align'>
<option value=''>normal</option>
<option value='left'>left</option>
<option value='right'>right</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" height="40">
<input type='button' class="editor_submit" value='Insert' onClick='insertImage()' />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

View file

@ -7,10 +7,13 @@
$lang->image_url = "이미지 경로";
$lang->image_alt = "설명 입력";
$lang->image_scale = "이미지크기";
$lang->image_align = "정렬 방법 ";
$lang->image_align_normal = "한 문단을 차지";
$lang->image_align_left = "글의 왼쪽으로";
$lang->image_align_middle = "가운데";
$lang->image_align_right = "글의 우측으로";
$lang->image_border = "경계선 두께";
$lang->cmd_get_scale = "크기 구하기";
?>

View file

@ -5,7 +5,15 @@
<form action="./" method="get" onSubmit="return false" id="fo">
<div class="editor_window">
<div class="header">{$lang->image_url}</div>
<div class="body"><input type="text" class="image_url" id="image_url" value="" /></div>
<div class="body"><input type="text" class="image_url" id="image_url" value="" onblur="getImageScale();" /></div>
<div class="header">{$lang->image_scale}</div>
<div class="body">
<input type="text" class="editor_input" id="width" value="0" />px
<input type="text" class="editor_input" id="height" value="0" />px
<input type="button" value="{$lang->cmd_get_scale}" class="editor_button" onclick="getImageScale();return false;" />
</div>
<div class="header">{$lang->image_alt}</div>
<div class="body"><input type="text" class="image_url" id="image_alt" value="" /></div>

View file

@ -1,3 +1,14 @@
function getImageScale() {
var url = xGetElementById("image_url").value;
if(!url) return;
var img = new Image();
img.src = url;
xGetElementById("width").value = img.width;
xGetElementById("height").value = img.height;
}
function insertImage(obj) {
if(typeof(opener)=="undefined") return;
@ -10,14 +21,19 @@ function insertImage(obj) {
else if(xGetElementById("align_right").checked==true) align = "right";
var border = parseInt(xGetElementById("image_border").value,10);
var width = xGetElementById("width").value;
var height = xGetElementById("height").value;
if(!url) {
window.close();
return;
}
var text = "<img src=\""+url+"\" border=\""+border+"\" plugin=\"image_link\" ";
var text = "<img editor_component=\"image_link\" src=\""+url+"\" border=\""+border+"\" ";
if(alt) text+= " alt=\""+alt+"\"";
if(align) text+= " align=\""+align+"\" ";
if(width) text+= " width=\""+width+"\" ";
if(height) text+= " height=\""+height+"\" ";
text+= " />";
opener.editorFocus(opener.editorPrevSrl);

View file

@ -53,5 +53,30 @@
return $oTemplate->compile($tpl_path, $tpl_file);
}
/**
* @brief 에디터 컴포넌트가 별도의 고유 코드를 이용한다면 코드를 html로 변경하여 주는 method
*
* 이미지나 멀티미디어, 설문등 고유 코드가 필요한 에디터 컴포넌트는 고유코드를 내용에 추가하고 나서
* DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경
**/
function transHTML($xml_obj) {
$src = $xml_obj->attrs->src;
$width = $xml_obj->attrs->width;
if(!$width) $width = 640;
$height = $xml_obj->attrs->height;
if(!$height) $height = 480;
$auto_start = $xml_obj->attrs->auto_start;
if(!$auto_start) $auto_start = "false";
else $auto_start = "true";
$caption = $xml_obj->body;
$src = str_replace(array('&','"'), array('&amp;','&qout;'), $src);
return sprintf("<script type=\"text/javascript\">displayMultimedia(\"%s\", \"%s\",\"%s\",%s);</script>", $src, $width, $height, $auto_start);
}
}
?>

View file

@ -19,7 +19,7 @@ function insertMultimedia(obj) {
return;
}
var text = "<div class=\"editor_multimedia\" plugin=\"multimedia_link\" src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" style=\"width:"+width+"px;height:"+height+"px;\" auto_start=\""+auto_start+"\">"+caption+"</div>";
var text = "<div editor_component=\"multimedia_link\" class=\"editor_multimedia\" src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" style=\"width:"+width+"px;height:"+height+"px;\" auto_start=\""+auto_start+"\">"+caption+"</div>";
opener.editorFocus(opener.editorPrevSrl);

View file

@ -19,11 +19,11 @@
* 기본으로는 ./plugins에 있지만 웹관리기능으로 다운로드시 ./files/plugins에 존재함
**/
function getPluginPath($plugin_name) {
$class_path = sprintf('./files/plugins/%s/', $plugin_name);
if(is_dir($class_path)) return $class_path;
$path = sprintf('./files/plugins/%s/', $plugin_name);
if(is_dir($path)) return $path;
$class_path = sprintf('./plugins/%s/', $plugin_name);
if(is_dir($class_path)) return $class_path;
$path = sprintf('./plugins/%s/', $plugin_name);
if(is_dir($path)) return $path;
return "";
}