diff --git a/modules/editor/components/naver_map/icon.gif b/modules/editor/components/naver_map/icon.gif new file mode 100644 index 000000000..26c0eaef4 Binary files /dev/null and b/modules/editor/components/naver_map/icon.gif differ diff --git a/modules/editor/components/naver_map/info.xml b/modules/editor/components/naver_map/info.xml new file mode 100644 index 000000000..66a584832 --- /dev/null +++ b/modules/editor/components/naver_map/info.xml @@ -0,0 +1,29 @@ + + + 네이버맵 연동 + ネイバーマップ + NAVER 地图 + Naver Map Open Api + + 제로 + Zero + zero + zero + 네이버에서 제공하는 네이버 지도 open api를 이용하여 에디터에 원하는 곳의 지도를 추가하거나 수정할 수 있습니다.\n네이버 지도 open api키를 발급 받아서 등록을 해주셔야 정상적인 사용이 가능합니다. + ネバーから提供されるネイバーマップのOpenAPIを利用してエディターに表示したい地図を追加したり修正したりすることができます。ネイバーマップは、OpenAPIキーを取得してから登録すれば使用することができます。 + naver提供的naver地图,利用open api在编辑器里添加或修改您所需要的地图。\n为了使用naver地图首先要取得open api key,然后登录此key才可正常使用。 + You can add a map to the editor or modify it by using Naver Map open api provided by Naver.\nYou would be able to use it when you register Naver Map api key after you get it from http://www.naver.com. + + + + 네이버지도 api key + APIキー + naver地图 api key + Naver Map api key + http://www.naver.com/ 에서 네이버 지도 API key를 발급 받으신 후 입력해주세요. + http://www.naver.com/ からネイバーマップのAPIキーを取得してから入力してください。 + 在http://www.naver.com/ 取得naver地图 API key后输入。 + Please get Naver Map API key from http://www.naver.com first and then input the key. + + + diff --git a/modules/editor/components/naver_map/lang/en.lang.php b/modules/editor/components/naver_map/lang/en.lang.php new file mode 100644 index 000000000..b8840e7ed --- /dev/null +++ b/modules/editor/components/naver_map/lang/en.lang.php @@ -0,0 +1,22 @@ + + * @brief editor module > language pack of multimedia_link(Naver Map) component + **/ + + $lang->map_width = "Width"; + $lang->map_height = "Height"; + + // Expressions + $lang->about_address = "Ex) Jeongjadong Boondang, Yeoksam"; + $lang->about_address_use = "Please search the address first and then press [Insert] button. Then, the map would be added to the article."; + + // Error Messages + $lang->msg_not_exists_addr = "Address doesn't exists"; + $lang->msg_fail_to_socket_open = "Failed to connect zip code searching server"; + $lang->msg_no_result = "Nothing Found"; + + $lang->msg_no_apikey = "Naver Map api key is necessary to use Naver Map.\nPlease input api key after selecting Module > WISYWIG Editor > Naver Map Open Api"; + +?> diff --git a/modules/editor/components/naver_map/lang/jp.lang.php b/modules/editor/components/naver_map/lang/jp.lang.php new file mode 100644 index 000000000..9346c207b --- /dev/null +++ b/modules/editor/components/naver_map/lang/jp.lang.php @@ -0,0 +1,21 @@ + 翻訳:RisaPapa + * @brief ウィジウィグエディター(editor) > マルチメディアリンク(naver_map)コンポネント言語パッケージ + **/ + + $lang->map_width = "横幅サイズ"; + $lang->map_height = "縦幅サイズ"; + + // 表示メッセージ + $lang->about_address = "例)분당 정자동, 역삼"; + $lang->about_address_use = "検索ウィンドウで住所を検索した後、出力された結果を選択して、「追加」ボタンを押せば、書き込みに地図が追加されます。"; + + // エラーメッセージ + $lang->msg_not_exists_addr = "検索対象がありません。"; + $lang->msg_fail_to_socket_open = "郵便番号を検索するサーバとの接続に失敗しました。"; + $lang->msg_no_result = "検索結果がありません。"; + + $lang->msg_no_apikey = "ネイバーマップを使用するためには、ネイバーマップのOpenAPIキーを取得しなければなりません。\nOpenAPIキーを 管理者 > ウィジウィグエディター > ネイバーマップコンポネント設定を選択した後、入力してください。"; +?> diff --git a/modules/editor/components/naver_map/lang/ko.lang.php b/modules/editor/components/naver_map/lang/ko.lang.php new file mode 100644 index 000000000..da1af2a8e --- /dev/null +++ b/modules/editor/components/naver_map/lang/ko.lang.php @@ -0,0 +1,21 @@ + + * @brief 위지윅에디터(editor) 모듈 > 멀티미디어 링크 (naver_map) 컴포넌트의 언어팩 + **/ + + $lang->map_width = "가로크기"; + $lang->map_height = "세로크기"; + + // 문구 + $lang->about_address = "예) 분당 정자동, 역삼"; + $lang->about_address_use = "검색창에서 원하는 주소를 검색하신후 출력된 결과물을 선택하시고 [추가] 버튼을 눌러주시면 글에 지도가 추가가 됩니다"; + + // 에러 메세지들 + $lang->msg_not_exists_addr = "검색하려는 대상이 없습니다"; + $lang->msg_fail_to_socket_open = "우편번호 검색 대상 서버 접속이 실패하였습니다"; + $lang->msg_no_result = "검색 결과가 없습니다"; + + $lang->msg_no_apikey = "네이버맵 사용을 위해서는 네이버맵 open api key가 있어야 합니다.\nopen api key를 관리자 > 위지윅에디터 > 네이버 지도 연동 컴포넌트 설정을 선택한 후 입력하여 주세요"; +?> diff --git a/modules/editor/components/naver_map/lang/zh-CN.lang.php b/modules/editor/components/naver_map/lang/zh-CN.lang.php new file mode 100644 index 000000000..8535f3252 --- /dev/null +++ b/modules/editor/components/naver_map/lang/zh-CN.lang.php @@ -0,0 +1,21 @@ + + * @brief 网页编辑器(editor) 模块 > naver地图 (naver_map) 组件语言包 + **/ + + $lang->map_width = "宽度"; + $lang->map_height = "高度"; + + // 词句 + $lang->about_address = "例) 王府井 餐厅, 月坛公园"; + $lang->about_address_use = "在搜索窗口搜索要找的地址后,按『添加』按钮即可把相关地图插入到文章当中。"; + + // 错误信息 + $lang->msg_not_exists_addr = "没有找到搜索的对象"; + $lang->msg_fail_to_socket_open = "链接搜索邮编服务器失败。"; + $lang->msg_no_result = "没有搜索结果"; + + $lang->msg_no_apikey = "要想使用naver地图,将需要一个open api key。\n 请选择管理员 > 网页编辑器 > naver地图设置后输入open api key。"; +?> diff --git a/modules/editor/components/naver_map/naver_map.class.php b/modules/editor/components/naver_map/naver_map.class.php new file mode 100644 index 000000000..5c1150839 --- /dev/null +++ b/modules/editor/components/naver_map/naver_map.class.php @@ -0,0 +1,183 @@ +upload_target_srl = $upload_target_srl; + $this->component_path = $component_path; + } + + /** + * @brief popup window요청시 popup window에 출력할 내용을 추가하면 된다 + **/ + function getPopupContent() { + // 템플릿을 미리 컴파일해서 컴파일된 소스를 return + $tpl_path = $this->component_path.'tpl'; + + if(!$this->api_key) $tpl_file = 'error.html'; + else $tpl_file = 'popup.html'; + + Context::set("tpl_path", $tpl_path); + + $oTemplate = &TemplateHandler::getInstance(); + 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->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 + * + * 이미지나 멀티미디어, 설문등 고유 코드가 필요한 에디터 컴포넌트는 고유코드를 내용에 추가하고 나서 + * DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경 + * + * 네이버 지도 open api 는 doctype에 대한 오류 및 기타 등등등등의 문제 때문에 iframe 을 만들고 컴포넌트를 다시 호출해서 html을 출력하게 한다. + * 네이버 지도 open api 가 xhtml1-transitional.dtd 를 지원하게 되면 다시 깔끔하게 고쳐야 함.. + * 2006년 3월 12일 하루 다 날렸다~~~ ㅡ.ㅜ + **/ + function transHTML($xml_obj) { + $x = $xml_obj->attrs->x; + $y = $xml_obj->attrs->y; + $marker = $xml_obj->attrs->marker; + $style = $xml_obj->attrs->style; + + preg_match_all('/(width|height)([^[:digit:]]+)([0-9]+)/i',$style,$matches); + $width = trim($matches[3][0]); + $height = trim($matches[3][1]); + if(!$width) $width = 400; + if(!$height) $height = 400; + + $body_code = sprintf('
', $width, $height, Context::getRequestUri(), $width, $height, $x, $y, $marker, $width, $height); + return $body_code; + } + + function displayMap() { + $id = "navermap".rand(11111111,99999999); + + $width = Context::get('width'); + if(!$width) $width = 640; + + $height = Context::get('height'); + if(!$height) $height = 480; + + $x = Context::get('x'); + if(!$x) $x = 321198; + + $y = Context::get('y'); + if(!$y) $y = 529730; + + $marker = Context::get('marker'); + + $html = ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + '
'. + ''. + ''. + ''; + + print $html; + exit(); + } + } +?> diff --git a/modules/editor/components/naver_map/tpl/error.html b/modules/editor/components/naver_map/tpl/error.html new file mode 100644 index 000000000..1a909bf5d --- /dev/null +++ b/modules/editor/components/naver_map/tpl/error.html @@ -0,0 +1,10 @@ + + +
+
+ {nl2br($lang->msg_no_apikey)} +
+
+ +
+
diff --git a/modules/editor/components/naver_map/tpl/navermap_component.gif b/modules/editor/components/naver_map/tpl/navermap_component.gif new file mode 100644 index 000000000..a9e22712b Binary files /dev/null and b/modules/editor/components/naver_map/tpl/navermap_component.gif differ diff --git a/modules/editor/components/naver_map/tpl/popup.css b/modules/editor/components/naver_map/tpl/popup.css new file mode 100644 index 000000000..6080afd51 --- /dev/null +++ b/modules/editor/components/naver_map/tpl/popup.css @@ -0,0 +1,11 @@ +@charset "utf-8"; +@import url(../../../../../../modules/admin/tpl/css/admin.css); + +.search { border:1px solid #DDDDDD; padding:5px; } +#address { width:100px; } +.about_address { clear:both; color:#DDDDDD; } + +.address_list_box { color:#AAAAAA; margin-top:1em; clear:both;} +.address_list_box a { color:#AAAAAA; } + +#display_map { width:400px; height:400px; border:0px; border:1px solid #DDDDDD; margin-left:10px; } diff --git a/modules/editor/components/naver_map/tpl/popup.html b/modules/editor/components/naver_map/tpl/popup.html new file mode 100644 index 000000000..63b3bd131 --- /dev/null +++ b/modules/editor/components/naver_map/tpl/popup.html @@ -0,0 +1,57 @@ + + + + +
+

{$component_info->title} ver. {$component_info->version}

+
+ +
+ + + + + + + + +
+ + +
{$lang->about_address_use}
+ + + + + + + + + +
{$lang->map_width}px
{$lang->map_height}px
+
+ +
+
+ +
+ {$lang->cmd_insert} + {$lang->cmd_close} + {$lang->about_component} +
diff --git a/modules/editor/components/naver_map/tpl/popup.js b/modules/editor/components/naver_map/tpl/popup.js new file mode 100644 index 000000000..1e301f25e --- /dev/null +++ b/modules/editor/components/naver_map/tpl/popup.js @@ -0,0 +1,108 @@ +/** + * popup으로 열렸을 경우 부모창의 위지윅에디터에 select된 멀티미디어 컴포넌트 코드를 체크하여 + * 있으면 가져와서 원하는 곳에 삽입 + **/ +function getNaverMap() { + // 부모 위지윅 에디터에서 선택된 영역이 있는지 확인 + if(typeof(opener)=="undefined") return; + + var node = opener.editorPrevNode; + if(!node || node.nodeName != "IMG") return; + + var x = node.getAttribute("x"); + var y = node.getAttribute("y"); + var width = xWidth(node); + var height = xHeight(node); + var address = node.getAttribute("address"); + + if(x&&y) { + xGetElementById("map_x").value = x; + xGetElementById("map_y").value = y; + moveMap(x,y,3); + } + if(address) { + xGetElementById("address").value = address; + search_address(address); + } + + xGetElementById("map_width").value = width-4; + xGetElementById("map_height").value = height-4; +} + +function insertNaverMap(obj) { + if(typeof(opener)=="undefined") return; + + var x = xGetElementById("map_x").value; + var y = xGetElementById("map_y").value; + var marker = xGetElementById("marker").value; + var address = xGetElementById("address").value; + + var width = xGetElementById("map_width").value; + var height = xGetElementById("map_height").value; + + var text = ""; + + opener.editorFocus(opener.editorPrevSrl); + + var iframe_obj = opener.editorGetIFrame(opener.editorPrevSrl) + + opener.editorReplaceHTML(iframe_obj, text); + opener.editorFocus(opener.editorPrevSrl); + + window.close(); +} + +xAddEventListener(window, "load", getNaverMap); + +/* 네이버의 map openapi로 주소에 따른 좌표를 요청 */ +function search_address(selected_address) { + if(typeof(selected_address)=="undefined") selected_address = null; + 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', 'procEditorCall', params, complete_search_address, response_tags, selected_address); +} + +function moveMap(x,y,scale) { + if(typeof(scale)=="undefined") scale = 3; + display_map.moveMap(x,y,scale); +} + +function mapClicked(pos) { + xGetElementById("map_x").value = pos.x; + xGetElementById("map_y").value = pos.y; +} + +var naver_address_list = new Array(); +function complete_search_address(ret_obj, response_tags, selected_address) { + var address_list = ret_obj['address_list']; + if(!address_list) return; + + naver_address_list = new Array(); + + var html = ""; + var address_list = address_list.split("\n"); + for(var i=0;i"+item[2]+"
"; + } + + var list_zone = xGetElementById("address_list"); + xInnerHtml(list_zone, html); +} + +/* 마커 표시 */ +var marker_count = 1; +function addMarker(pos) { + if(marker_count>10) return; + xGetElementById("marker").value += '|@|'+pos; + marker_count++; + return true; +}