From 5d59f2b8f98fa1d09351e6ae267f92b14c6c3f2b Mon Sep 17 00:00:00 2001 From: zero Date: Mon, 19 Mar 2007 06:26:49 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@537 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/plugin/PluginHandler.class.php | 16 +- common/js/common.js | 144 +++++++++--------- .../tpl/images/flvplayer.swf | Bin config/config.inc.php | 2 +- modules/document/document.model.php | 39 ++--- .../image_link/image_link.class.php | 27 ++++ .../components/image_link/imagelink.html | 56 ------- .../components/image_link/lang/ko.lang.php | 3 + .../components/image_link/tpl/popup.html | 10 +- .../editor/components/image_link/tpl/popup.js | 18 ++- .../multimedia_link/multimedia_link.class.php | 25 +++ .../components/multimedia_link/tpl/popup.js | 2 +- modules/plugin/plugin.model.php | 8 +- 13 files changed, 197 insertions(+), 153 deletions(-) rename {modules/editor => common}/tpl/images/flvplayer.swf (100%) delete mode 100644 modules/editor/components/image_link/imagelink.html diff --git a/classes/plugin/PluginHandler.class.php b/classes/plugin/PluginHandler.class.php index 3c74dced6..976ec463b 100644 --- a/classes/plugin/PluginHandler.class.php +++ b/classes/plugin/PluginHandler.class.php @@ -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; } } diff --git a/common/js/common.js b/common/js/common.js index e3ab373a5..daa37c2d0 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -4,103 +4,111 @@ // string prototype으로 trim 함수 추가 String.prototype.trim = function() { - return this.replace(/(^\s*)|(\s*$)/g, ""); + return this.replace(/(^\s*)|(\s*$)/g, ""); } // 주어진 인자가 하나라도 defined되어 있지 않으면 false return function isDef() { - for(var i=0; i"+ - ""+ - ""+ - ""+ - "<\/object>"; - break; - default : - html = ""+ - ""; - break; - } +function displayMultimedia(src, width, height, auto_start) { + var ext = src.split("."); + var type = ext[ext.length-1]; - document.writeln(html); + if(auto_start) auto_start = 1; + else auto_start = 0; + + var clsid = ""; + var codebase = ""; + var html = ""; + switch(type) { + case "flv" : + html = ""; + 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>"; + break; + default : + html = ""+ + ""; + break; + } + + document.writeln(html); } // 화면내에서 이미지 리사이즈 및 클릭할 수 있도록 function resizeImageContents() { - var objs = xGetElementsByTagName("img"); - for(var i in objs) { - var obj = objs[i]; - var parent = xParent(obj); - if(!obj||!parent) continue; + var objs = xGetElementsByTagName("img"); + for(var i in objs) { + var obj = objs[i]; + var parent = xParent(obj); + if(!obj||!parent) continue; - var parent_width = xWidth(parent); - var obj_width = xWidth(obj); - if(parent_width>=obj_width) continue; + var parent_width = xWidth(parent); + var obj_width = xWidth(obj); + if(parent_width>=obj_width) continue; - obj.style.cursor = "pointer"; - obj.source_width = obj_width; - obj.source_height = xHeight(obj); - xWidth(obj, xWidth(parent)-1); + obj.style.cursor = "pointer"; + obj.source_width = obj_width; + obj.source_height = xHeight(obj); + xWidth(obj, xWidth(parent)-1); - xAddEventListener(obj,"click", resizeImagePopup); - } + xAddEventListener(obj,"click", resizeImagePopup); + } } xAddEventListener(window, "load", resizeImageContents); // 컨텐츠에서 컨텐츠 영역보다 큰 이미지 리사이징후 팝업 클릭시 사용되는 함수 function resizeImagePopup(evt) { - var e = new xEvent(evt); - if(!e.target.src) return; - var obj = e.target; - var scrollbars = "no"; - var resizable = "no"; + var e = new xEvent(evt); + if(!e.target.src) return; + var obj = e.target; + var scrollbars = "no"; + var resizable = "no"; - var width = obj.source_width; - if(width>screen.availWidth) { - width = screen.availWidth-50; - scrollbars = "yes"; - resizable = "yes"; - } - var height = obj.source_height; - if(height>screen.availHeight) { - height = screen.availHeight-50; - scrollbars = "yes"; - resizable = "yes"; - } - var popup = window.open(e.target.src,"_imagePopup","width="+width+",height="+height+",top=1,left=1,resizable="+resizable+",toolbars=no,scrollbars="+resizable); - if(popup) popup.focus(); + var width = obj.source_width; + if(width>screen.availWidth) { + width = screen.availWidth-50; + scrollbars = "yes"; + resizable = "yes"; + } + var height = obj.source_height; + if(height>screen.availHeight) { + height = screen.availHeight-50; + scrollbars = "yes"; + resizable = "yes"; + } + var popup = window.open(e.target.src,"_imagePopup","width="+width+",height="+height+",top=1,left=1,resizable="+resizable+",toolbars=no,scrollbars="+resizable); + if(popup) popup.focus(); } // 에디터에서 사용하는 내용 여닫는 코드 (고정) diff --git a/modules/editor/tpl/images/flvplayer.swf b/common/tpl/images/flvplayer.swf similarity index 100% rename from modules/editor/tpl/images/flvplayer.swf rename to common/tpl/images/flvplayer.swf diff --git a/config/config.inc.php b/config/config.inc.php index d8b39b636..c1fe9b868 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -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 diff --git a/modules/document/document.model.php b/modules/document/document.model.php index 031e71ea3..e472892bd 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -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('!]*)editor_multimedia([^\>]*?)>!is', array($this,'_transMultimedia'), $content); + // 에디터 컴포넌트를 찾아서 결과 코드로 변환 + $content = preg_replace_callback('!<(div|img) editor_component="([a-zA-Z\_^\"]+)"([^\>]*?)>!is', array($this,'_transMultimedia'), $content); //
코드 변환 $content = str_replace(array("
","
","
"),"
", $content); @@ -335,19 +335,24 @@ * 로 되어 있는 코드를 변경 **/ 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{$cmd} = $val; - } - return sprintf("", $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("", $obj->type, $obj->src, $style); } } ?> diff --git a/modules/editor/components/image_link/image_link.class.php b/modules/editor/components/image_link/image_link.class.php index 7d8589f9d..4517c17af 100644 --- a/modules/editor/components/image_link/image_link.class.php +++ b/modules/editor/components/image_link/image_link.class.php @@ -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('&','&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 ""; + } + } ?> diff --git a/modules/editor/components/image_link/imagelink.html b/modules/editor/components/image_link/imagelink.html deleted file mode 100644 index 657cd1eab..000000000 --- a/modules/editor/components/image_link/imagelink.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - add Image - - - - - - - -
-
- - - - - - - - - - - - - - -
url'/>
type - -
- -
-
-
- - - diff --git a/modules/editor/components/image_link/lang/ko.lang.php b/modules/editor/components/image_link/lang/ko.lang.php index d79933a33..fdd7fd725 100644 --- a/modules/editor/components/image_link/lang/ko.lang.php +++ b/modules/editor/components/image_link/lang/ko.lang.php @@ -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 = "크기 구하기"; ?> diff --git a/modules/editor/components/image_link/tpl/popup.html b/modules/editor/components/image_link/tpl/popup.html index 5a767cd04..7b4a69d38 100644 --- a/modules/editor/components/image_link/tpl/popup.html +++ b/modules/editor/components/image_link/tpl/popup.html @@ -5,7 +5,15 @@
{$lang->image_url}
-
+
+ +
{$lang->image_scale}
+
+ px + px + +
+
{$lang->image_alt}
diff --git a/modules/editor/components/image_link/tpl/popup.js b/modules/editor/components/image_link/tpl/popup.js index 868273d78..49161aeb0 100644 --- a/modules/editor/components/image_link/tpl/popup.js +++ b/modules/editor/components/image_link/tpl/popup.js @@ -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 = "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('&','&qout;'), $src); + + return sprintf("", $src, $width, $height, $auto_start); + } } ?> diff --git a/modules/editor/components/multimedia_link/tpl/popup.js b/modules/editor/components/multimedia_link/tpl/popup.js index f15677538..7ff2bd820 100644 --- a/modules/editor/components/multimedia_link/tpl/popup.js +++ b/modules/editor/components/multimedia_link/tpl/popup.js @@ -19,7 +19,7 @@ function insertMultimedia(obj) { return; } - var text = "
"+caption+"
"; + var text = "
"+caption+"
"; opener.editorFocus(opener.editorPrevSrl); diff --git a/modules/plugin/plugin.model.php b/modules/plugin/plugin.model.php index 0b596b7f4..28f7b6d66 100644 --- a/modules/plugin/plugin.model.php +++ b/modules/plugin/plugin.model.php @@ -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 ""; }