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

This commit is contained in:
zero 2007-03-21 08:18:40 +00:00
parent 3958be025e
commit a457add255
12 changed files with 186 additions and 139 deletions

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -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 = "검색 결과가 없습니다";
?>

View file

@ -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('<?xml version="1.0" encoding="euc-kr" ?>', '', $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('<div id="%s" style="width:%spx;height:%spx;">%s', $id, $width, $height,"\n");
$footer_code =
sprintf(
'<script type="text/javascript"> '.
'var mapObj = new NMap(xGetElementById("%s")); '.
'mapObj.addControl(new NSaveBtn()); '.
'mapObj.setCenterAndZoom(new NPoint(%d,%d),3); '.
'mapObj.enableWheelZoom(); '.
'</script>',
$id, $x, $y
);
$caption = $xml_obj->body;
$src = str_replace(array('&','"'), array('&amp;','&qout;'), $src);
return sprintf("<div><script type=\"text/javascript\">displayMultimedia(\"%s\", \"%s\",\"%s\",%s);</script>", $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;
}
}
?>

View file

@ -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;

View file

@ -6,8 +6,11 @@
<div class="editor_window">
<div class="editor_title">{$lang->navermap}</div>
<div class="header">{$lang->navermap_address}</div>
<div class="body"><input type="text" class="navermap_address" id="address" value="{$manual_url}" /><input type="button" value="{$lang->cmd_search}" class="editor_button" onclick="search_address();return false;"/></div>
<div class="header">{$lang->search_address}</div>
<div class="body"><input type="text" class="navermap_address" id="address" value="죽전" /><input type="button" value="{$lang->cmd_search}" class="editor_button" onclick="search_address();return false;"/></div>
<div class="header">{$lang->address_list}</div>
<div class="body"><select id="address_list"></select></div>
<div class="header">{$lang->navermap_width}</div>
<div class="body"><input type="text" class="navermap_size" id="navermap_width" value="640" />px</div>
@ -16,7 +19,7 @@
<div class="body"><input type="text" class="navermap_size" id="navermap_height" value="480" />px</div>
<div class="editor_button_area">
<input type="button" value="{$lang->cmd_insert}" class="editor_button" onclick="insertMultimedia()" />
<input type="button" value="{$lang->cmd_insert}" class="editor_button" onclick="insertNaverMap()" />
<input type="button" value="{$lang->cmd_close}" class="editor_button" onclick="window.close();" />
</div>
</div>

View file

@ -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 = "<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>";
var text = "<div editor_component=\"naver_map\" class=\"editor_component_output\" x=\""+x+"\" y=\""+y+"\" width=\""+width+"\" height=\""+height+"\" style=\"width:"+width+"px;height:"+height+"px;\"></div>";
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;i<length;i++) listup_obj.remove(0);
var address_list = address_list.split("\n");
for(var i=0;i<address_list.length;i++) {
var item = address_list[i].split(",");
naver_address_list[naver_address_list.length] = item;
var opt = new Option(item[2], naver_address_list.length-1, false, true);
listup_obj.options[listup_obj.length] = opt;
}
}

View file

@ -1,48 +0,0 @@
<?php
/**
* @class editor
* @author zero (zero@nzeo.com)
* @brief editor 모듈의 high class
**/
class editor extends ModuleObject {
/**
* @brief 설치시 추가 작업이 필요할시 구현
**/
function moduleInstall() {
return new Object();
}
/**
* @brief 설치가 이상이 없는지 체크하는 method
**/
function moduleIsInstalled() {
return new Object();
}
/**
* @brief 업데이트 실행
**/
function moduleUpdate() {
return new Object();
}
/**
* @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));
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;
}
}
?>

View file

@ -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;
}
}
?>