From a457add255df1fcb81ffcb00a36bd7403a0b2f65 Mon Sep 17 00:00:00 2001 From: zero Date: Wed, 21 Mar 2007 08:18:40 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@585 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/context/Context.class.php | 47 ++++++++-- common/css/default.css | 2 +- common/tpl/common_footer.html | 1 + .../components/multimedia_link/tpl/popup.js | 2 +- modules/editor/components/naver_map/icon.gif | Bin 0 -> 1343 bytes .../components/naver_map/lang/ko.lang.php | 9 +- .../components/naver_map/naver_map.class.php | 83 ++++++++++++++---- .../editor/components/naver_map/tpl/popup.css | 6 ++ .../components/naver_map/tpl/popup.html | 9 +- .../editor/components/naver_map/tpl/popup.js | 66 +++++++------- modules/editor/editor.controller.ph | 48 ---------- modules/editor/editor.controller.php | 52 +++++------ 12 files changed, 186 insertions(+), 139 deletions(-) create mode 100644 modules/editor/components/naver_map/icon.gif delete mode 100644 modules/editor/editor.controller.ph diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index a37fc42e4..4a1085938 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -19,11 +19,12 @@ var $db_info = NULL; ///< @brief DB 정보 - var $js_files = array(); ///< @brief display시에 사용하게 된 js files의 목록 + var $js_files = array(); ///< @brief display시에 사용하게 되는 js files의 목록 - var $css_files = array(); ///< @brief display시에 사용하게 된 css files의 목록 + var $css_files = array(); ///< @brief display시에 사용하게 되는 css files의 목록 - var $html_header = NULL; ///< @brief display시에 사용하게 된 ..내의 스크립트. 거의 사용할 일은 없음 + var $html_header = NULL; ///< @brief display시에 사용하게 되는 ..내의 스크립트. 거의 사용할 일은 없음 + var $html_footer = NULL; ///< @brief display시에 사용하게 되는 바로 앞에 추가될 코드 /** * @brief 언어 정보 @@ -627,16 +628,16 @@ /** * @brief HtmlHeader 추가 **/ - function addHtmlHeader($file) { + function addHtmlHeader($header) { $oContext = &Context::getInstance(); - return $oContext->_addHtmlHeader($file); + return $oContext->_addHtmlHeader($header); } /** * @brief HtmlHeader 추가 **/ - function _addHtmlHeader($file) { - $this->HtmlHeader .= ($this->HtmlHeader?"\n":"").$file; + function _addHtmlHeader($header) { + $this->html_header .= ($this->html_header?"\n":"").$header; } /** @@ -651,7 +652,37 @@ * @brief HtmlHeader return **/ function _getHtmlHeader() { - return $this->HtmlHeader; + return $this->html_header; + } + + /** + * @brief HtmlFooter 추가 + **/ + function addHtmlFooter($footer) { + $oContext = &Context::getInstance(); + return $oContext->_addHtmlFooter($footer); + } + + /** + * @brief HtmlFooter 추가 + **/ + function _addHtmlFooter ($footer) { + $this->html_footer .= ($this->Htmlfooter?"\n":"").$footer; + } + + /** + * @brief HtmlFooter return + **/ + function getHtmlFooter() { + $oContext = &Context::getInstance(); + return $oContext->_getHtmlFooter(); + } + + /** + * @brief HtmlFooter return + **/ + function _getHtmlFooter() { + return $this->html_footer; } /** diff --git a/common/css/default.css b/common/css/default.css index 604906623..a7f193ddc 100644 --- a/common/css/default.css +++ b/common/css/default.css @@ -30,7 +30,7 @@ a.bold { .folder_closer { display: none; } .folder_area { display: none; } -.editor_multimedia { +.editor_component_output { background:url(../tpl/images/multimedia_icon.gif) no-repeat center; background-color:#FFFFFF; border:3px dotted #2661db; diff --git a/common/tpl/common_footer.html b/common/tpl/common_footer.html index d254cb43e..fd74b580a 100644 --- a/common/tpl/common_footer.html +++ b/common/tpl/common_footer.html @@ -1,3 +1,4 @@ +{Context::getHtmlFooter()}
{$lang->msg_call_server}
diff --git a/modules/editor/components/multimedia_link/tpl/popup.js b/modules/editor/components/multimedia_link/tpl/popup.js index 473d31fef..9a45d7d9f 100644 --- a/modules/editor/components/multimedia_link/tpl/popup.js +++ b/modules/editor/components/multimedia_link/tpl/popup.js @@ -46,7 +46,7 @@ function insertMultimedia(obj) { return; } - var text = "
"+caption+"
"; + var text = "
"+caption+"
"; opener.editorFocus(opener.editorPrevSrl); diff --git a/modules/editor/components/naver_map/icon.gif b/modules/editor/components/naver_map/icon.gif new file mode 100644 index 0000000000000000000000000000000000000000..cc0ee89c7257370d7a940c5cc317c924622f86bc GIT binary patch literal 1343 zcmZ?wbhEHb3}Fypc;3sv$-$wgt?1_@iv)-H3ceb!os>~&5#>z(p9xD{-0Up6tTc$0V87XMXqovXHmRBa2b z*&bH2J-lIO%#F#`4ZC8RcEz>qNow1hyl16`hnZTs>8M^4Q*8H<#_YxqRR4)pxJA9J;sh z@V!k(?{7W!VB3j@J5D{?efrU!>({TJezf<@<9)Yo-8%pD(6dLgpFN%M=)r-@&yQVs zaqQ}glQ&+Tz4iLS?bjEdJb7~G&853Y_y7NY zhEYJ95K#Ol>RgnXSdyBeP@Y+mp%9Xhs^ISF8^ECWlZBCs;Xi{8$X-xpVc_`3Ajv6n zVg>(fCl+C?m=hZo9&Q)lZ1c=G$|Y+hXq70VC z_l7BvL2B)%W?RVm2}->1kW_X%HRa$UH$^7)XcnatI|Urut(X@ZL{u631e#jf{o%1< z33OuN(3_L!GF8)YgFc_(u1^d)e$K&<{4^CxPEL}F+Sli>;UMo-K3=IAE1K9CS?wD1 z6dVq>ySK4v9+==dLFLd*QI4jPi3bkpDj#TC?eosj@rXp5B@2T_zyoLA1*U3q8VbvL z*;rIg=?OJEFfSJ8m}256&^(ckCH|O#f#J=~m&_#uJPt4%|M~9Tc&$`sYB9-db{1w}Y!NiqXh`vinBzJ@pr_&?Ba=}@TRWfC14RLO`+^Avm{k-k z9!xL2H}m-n4HE(85WZT5W+t{hY10LZXDnUWEA_K+376Z7%EN-Qr=5E0)+wRXA(f?) P^lCNhhGSCM4h+@+IS}mY literal 0 HcmV?d00001 diff --git a/modules/editor/components/naver_map/lang/ko.lang.php b/modules/editor/components/naver_map/lang/ko.lang.php index 7d6981a4b..9faa9d2d2 100644 --- a/modules/editor/components/naver_map/lang/ko.lang.php +++ b/modules/editor/components/naver_map/lang/ko.lang.php @@ -6,8 +6,13 @@ **/ $lang->navermap = "네이비 지도"; - $lang->navermap_address = "주소"; + $lang->search_address = "주소 검색"; + $lang->address_list = "주소 선택"; $lang->navermap_width = "가로크기"; $lang->navermap_height = "세로크기"; - $lang->navermap_auto_start = "자동시작"; + + // 에러 메세지들 + $lang->msg_not_exists_addr = "검색하려는 대상이 없습니다"; + $lang->msg_fail_to_socket_open = "우편번호 검색 대상 서버 접속이 실패하였습니다"; + $lang->msg_no_result = "검색 결과가 없습니다"; ?> diff --git a/modules/editor/components/naver_map/naver_map.class.php b/modules/editor/components/naver_map/naver_map.class.php index 51e1be1f9..dd43eacc5 100644 --- a/modules/editor/components/naver_map/naver_map.class.php +++ b/modules/editor/components/naver_map/naver_map.class.php @@ -11,6 +11,9 @@ var $upload_target_srl = 0; var $component_path = ''; + // 네이버맵 openapi 키 값 + var $open_api_key = 'fb697bbfd01b42ab26db22162e166842'; + /** * @brief upload_target_srl과 컴포넌트의 경로를 받음 **/ @@ -34,6 +37,54 @@ return $oTemplate->compile($tpl_path, $tpl_file); } + /** + * @brief naver map open api에서 주소를 찾는 함수 + **/ + function search_address() { + $address = Context::get('address'); + if(!$address) return new Object(-1,'msg_not_exists_addr'); + + Context::loadLang($this->component_path."lang"); + + // 지정된 서버에 요청을 시도한다 + $query_string = iconv("UTF-8","EUC-KR",sprintf('/api/geocode.php?key=%s&query=%s', $this->open_api_key, $address)); + + $fp = fsockopen('maps.naver.com', 80, $errno, $errstr); + if(!$fp) return new Object(-1, 'msg_fail_to_socket_open'); + + fputs($fp, "GET {$query_string} HTTP/1.0\r\n"); + fputs($fp, "Host: maps.naver.com\r\n\r\n"); + + $buff = ''; + while(!feof($fp)) { + $str = fgets($fp, 1024); + if(trim($str)=='') $start = true; + if($start) $buff .= trim($str); + } + + fclose($fp); + + $buff = trim(iconv("EUC-KR", "UTF-8", $buff)); + $buff = str_replace('', '', $buff); + + $oXmlParser = new XmlParser(); + $xml_doc = $oXmlParser->parse($buff); + + $addrs = $xml_doc->geocode->item; + if(!is_array($addrs)) $addrs = array($addrs); + $addrs_count = count($addrs); + + $address_list = array(); + for($i=0;$i<$addrs_count;$i++) { + $item = $addrs[$i]; + + $address_list[] = sprintf("%s,%s,%s", $item->point->x->body, $item->point->y->body, $item->address->body); + + } + + $this->add("address_list", implode("\n", $address_list)); + } + /** * @brief 에디터 컴포넌트가 별도의 고유 코드를 이용한다면 그 코드를 html로 변경하여 주는 method * @@ -41,25 +92,27 @@ * DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경 **/ function transHTML($xml_obj) { - /* - $src = $xml_obj->attrs->src; - + $x = $xml_obj->attrs->x; + $y = $xml_obj->attrs->y; $width = $xml_obj->attrs->width; - if(!$width) $width = 640; - $height = $xml_obj->attrs->height; - if(!$height) $height = 480; + $id = "navermap".rand(11111111,99999999); - $auto_start = $xml_obj->attrs->auto_start; - if($auto_start!="true") $auto_start = "false"; - else $auto_start = "true"; + $body_code = sprintf('
%s', $id, $width, $height,"\n"); + $footer_code = + sprintf( + '', + $id, $x, $y + ); - $caption = $xml_obj->body; - - $src = str_replace(array('&','"'), array('&','&qout;'), $src); - - return sprintf("
", $src, $width, $height, $auto_start); - */ + Context::addJsFile("http://maps.naver.com/js/naverMap.naver?key=".$this->open_api_key); + Context::addHtmlFooter($footer_code); + return $body_code; } } ?> diff --git a/modules/editor/components/naver_map/tpl/popup.css b/modules/editor/components/naver_map/tpl/popup.css index d83305350..8199262f5 100644 --- a/modules/editor/components/naver_map/tpl/popup.css +++ b/modules/editor/components/naver_map/tpl/popup.css @@ -47,6 +47,12 @@ font-size:9pt; } +.navermap_size { + width:40px; + border:1px solid #AAAAAA; + height:12px; + font-size:9pt; +} .editor_button_area { border-top:1px solid #AAAAAA; diff --git a/modules/editor/components/naver_map/tpl/popup.html b/modules/editor/components/naver_map/tpl/popup.html index b07cbc244..77c6a80ea 100644 --- a/modules/editor/components/naver_map/tpl/popup.html +++ b/modules/editor/components/naver_map/tpl/popup.html @@ -6,8 +6,11 @@
{$lang->navermap}
-
{$lang->navermap_address}
-
+
{$lang->search_address}
+
+ +
{$lang->address_list}
+
{$lang->navermap_width}
px
@@ -16,7 +19,7 @@
px
- +
diff --git a/modules/editor/components/naver_map/tpl/popup.js b/modules/editor/components/naver_map/tpl/popup.js index c1c186688..f4340a232 100644 --- a/modules/editor/components/naver_map/tpl/popup.js +++ b/modules/editor/components/naver_map/tpl/popup.js @@ -10,45 +10,29 @@ function getNaverMap() { var node = opener.editorPrevNode; if(!node || node.nodeName != "DIV") return; - var url = node.getAttribute("src"); - var caption = xInnerHtml(node); - var width = node.getAttribute("width"); - if(width!=xWidth(node)) width = xWidth(node); - var height = node.getAttribute("height"); - if(height!=xHeight(node)) height = xHeight(node); - var auto_start = node.getAttribute("auto_start"); - - xGetElementById("multimedia_url").value = url; - xGetElementById("multimedia_caption").value = caption; - xGetElementById("multimedia_width").value = width; - xGetElementById("multimedia_height").value = height; - if(auto_start=="true") xGetElementById("multimedia_auto_start").checked = true; - } function insertNaverMap(obj) { if(typeof(opener)=="undefined") return; - return; - var url = xGetElementById("multimedia_url").value; + var listup_obj = xGetElementById("address_list"); + var idx = listup_obj.options[listup_obj.selectedIndex].value; + if(!idx) { + window.close(); + return; + } + + var item = naver_address_list[idx]; + var x = item[0]; + var y = item[1]; - var caption = xGetElementById("multimedia_caption").value; - - var width = xGetElementById("multimedia_width").value; + var width = xGetElementById("navermap_width").value; if(!width) width = 640; - var height = xGetElementById("multimedia_height").value; + var height = xGetElementById("navermap_height").value; if(!height) height= 480; - var auto_start = "false"; - if(xGetElementById("multimedia_auto_start").checked) auto_start = "true"; - - if(!url) { - window.close(); - return; - } - - var text = "
"+caption+"
"; + var text = "
"; opener.editorFocus(opener.editorPrevSrl); @@ -64,17 +48,33 @@ xAddEventListener(window, "load", getNaverMap); /* 네이버의 map openapi로 주소에 따른 좌표를 요청 */ function search_address() { - var address = xGetElementById("adress"); + var address = xGetElementById("address").value; if(!address) return; - var params = new Array(); + params['component'] = "naver_map"; params['address'] = address; + params['method'] = "search_address"; var response_tags = new Array('error','message','address_list'); - exec_xml('editor', 'procCall', params, complete_search_address); + exec_xml('editor', 'procCall', params, complete_search_address, response_tags); } +var naver_address_list = new Array(); function complete_search_address(ret_obj) { var address_list = ret_obj['address_list']; - alert(address_list); + if(!address_list) return; + + naver_address_list = new Array(); + + var listup_obj = xGetElementById("address_list"); + var length = listup_obj.options.length; + for(var i=0;imodule_path, $component); - $class_file = sprintf('%s%s.class.php', $class_path, $component); - if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); - - require_once($class_file); - $eval_str = sprintf('$oComponent = new %s("%s","%s");', $component, $upload_target_srl, $class_path); - @eval($eval_str); - if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); - - return $oComponent; - } - } -?> diff --git a/modules/editor/editor.controller.php b/modules/editor/editor.controller.php index a2a493ae0..1755bd0a1 100644 --- a/modules/editor/editor.controller.php +++ b/modules/editor/editor.controller.php @@ -2,47 +2,43 @@ /** * @class editor * @author zero (zero@nzeo.com) - * @brief editor 모듈의 high class + * @brief editor 모듈의 controller class **/ - class editor extends ModuleObject { + class editorController extends editor { /** - * @brief 설치시 추가 작업이 필요할시 구현 + * @brief 초기화 **/ - function moduleInstall() { - return new Object(); + function init() { } - /** - * @brief 설치가 이상이 없는지 체크하는 method - **/ - function moduleIsInstalled() { - return new Object(); - } /** - * @brief 업데이트 실행 + * @brief 컴포넌트에서 ajax요청시 해당 컴포넌트의 method를 실행 **/ - function moduleUpdate() { - return new Object(); - } + function procCall() { + $component = Context::get('component'); + $method = Context::get('method'); + if(!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); - /** - * @brief component의 객체 생성 - **/ - function getComponentObject($component, $upload_target_srl) { - // 해당 컴포넌트의 객체를 생성해서 실행 - $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); - $class_file = sprintf('%s%s.class.php', $class_path, $component); - if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); + $oComponent = &$this->getComponentObject($component); + if(!$oComponent->toBool()) return $oComponent; + + if(!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); + + $output = call_user_method($method, $oComponent); + if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output; + + $this->setError($oComponent->getError()); + $this->setMessage($oComponent->getMessage()); + + $vars = $oComponent->getVariables(); + if(count($vars)) { + foreach($vars as $key=>$val) $this->add($key, $val); + } - require_once($class_file); - $eval_str = sprintf('$oComponent = new %s("%s","%s");', $component, $upload_target_srl, $class_path); - @eval($eval_str); - if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); - return $oComponent; } } ?>