Skip to content

Commit

Permalink
maps module 지도 저장 기초 제작중
Browse files Browse the repository at this point in the history
  • Loading branch information
misol committed Oct 31, 2014
1 parent 8dfe368 commit 255c24f
Show file tree
Hide file tree
Showing 12 changed files with 442 additions and 19 deletions.
14 changes: 11 additions & 3 deletions lang/lang.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<value xml:lang="ko">제목 없는 지도</value>
<value xml:lang="en">Untitled map</value>
</item>
<item name="maps_module_no_description">
<value xml:lang="ko">지도 설명이 없습니다.</value>
<value xml:lang="en">No description of the map.</value>
</item>
<item name="maps_search">
<value xml:lang="ko">주소 검색</value>
<value xml:lang="en">Search address.</value>
Expand Down Expand Up @@ -48,9 +52,13 @@
<value xml:lang="ko"><![CDATA[지도가 입력되어 있습니다.<br />지도를 보시려면 여기를 클릭하세요.]]></value>
<value xml:lang="en"><![CDATA[A map is here.<br />Click here to view the map.]]></value>
</item>
<item name="maps_module_cmd_insert_map">
<value xml:lang="ko">지도 넣기</value>
<value xml:lang="en">Insert map</value>
<item name="maps_saved">
<value xml:lang="ko">지도가 저장되었습니다.</value>
<value xml:lang="en">The map is saved.</value>
</item>
<item name="maps_module_cmd_save_map">
<value xml:lang="ko">지도 저장</value>
<value xml:lang="en">Save map</value>
</item>
<item name="maps_module_msg_no_result">
<value xml:lang="ko">검색 결과가 없습니다.</value>
Expand Down
18 changes: 14 additions & 4 deletions maps.admin.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,30 @@ public function procMapsAdminCofig()
public function procMapsAdminInsert()
{
$action = ''; //insert or update
$logged_info = Context::get('logged_info');
$args = new stdClass();
$args->maps_srl = intval(trim(Context::get('maps_srl'))); // 정수형이 아닐 경우 제거
$args->maps_content = trim(Context::get('maps_content'));
$args->title = trim(Context::get('title'));
$args->content = trim(Context::get('content'));
$args->member_srl = $logged_info->member_srl;
$args->title = htmlspecialchars(trim(Context::get('map_title')));
$args->content = htmlspecialchars(trim(Context::get('map_description')));
$args->ipaddress = $_SERVER['REMOTE_ADDR'];

$maps_contents = new stdClass();
$maps_contents->map_center = trim(Context::get('map_center'));
$maps_contents->map_markers = trim(Context::get('map_markers'));
$maps_contents->map_zoom = intval(Context::get('map_zoom'));
$maps_contents = base64_encode(serialize($maps_contents));

$args->maps_content = $maps_contents;

// 정수형이고, 값이 존재할 경우 실제 존재하는 지도인지 확인(업데이트 날짜가 존재하는지 확인)
if($args->maps_srl > 0)
{
$output = executeQuery('maps.getMapUpdate', $args);
}

// 존재하는 지도일 경우, 업데이트 진행
if($output->update)
if($output->data->update)
{
$output = executeQuery('maps.updateMapsContent', $args);
}
Expand All @@ -93,6 +102,7 @@ public function procMapsAdminInsert()
$output = executeQuery('maps.insertMapsContent', $args);
}

$this->add("maps_srl", $args->maps_srl);
return;
}

Expand Down
10 changes: 6 additions & 4 deletions maps.admin.model.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ public function getMapsAdminLocation()
$query = Context::get('query');
if(!$query) return;


// API 종류 정하기 다음/네이버/구글
$oMapsModel = getModel('maps');
$maps_config = $oMapsModel->getMapsConfig();

$uri = sprintf('http://maps.googleapis.com/maps/api/geocode/xml?address=%s&sensor=false&language=%s',urlencode($address),urlencode($this->langtype));
// 언어 값 설정
$langtype = str_replace($this->xe_langtype, $this->google_langtype, strtolower(Context::getLangType()));

$uri = sprintf('http://maps.googleapis.com/maps/api/geocode/xml?address=%s&sensor=false&language=%s',urlencode($query),urlencode($langtype));
$xml_doc = $oMapsModel->getApiXmlObject($uri);

$item = $xml_doc->geocoderesponse->result;
Expand All @@ -53,7 +55,7 @@ public function getMapsAdminLocation()
}

if($maps_config->maps_api_type == 'naver') {
$uri = sprintf('http://map.naver.com/api/geocode.php?key=%s&encoding=utf-8&coord=latlng&query=%s',$this->soo_map_api,urlencode($address));
$uri = sprintf('http://map.naver.com/api/geocode.php?key=%s&encoding=utf-8&coord=latlng&query=%s',$maps_config->map_api_key,urlencode($query));
$xml_doc = $oMapsModel->getApiXmlObject($uri);

$item = $xml_doc->geocode->item;
Expand All @@ -77,7 +79,7 @@ public function getMapsAdminLocation()
}

if($maps_config->daum_local_api_key) {
$uri = sprintf('http://apis.daum.net/local/geo/addr2coord?apikey=%s&q=%s&output=xml',$this->soo_daum_local_api_key,urlencode($address));
$uri = sprintf('http://apis.daum.net/local/geo/addr2coord?apikey=%s&q=%s&output=xml',$maps_config->daum_local_api_key,urlencode($query));
$xml_doc = $oMapsModel->getApiXmlObject($uri);

$item = $xml_doc->channel->item;
Expand Down
62 changes: 62 additions & 0 deletions maps.admin.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,70 @@ public function dispMapsAdminList()

public function dispMapsAdminWrite()
{
// 한국 지도가 기본값(언어에 따라 다른 위치 표시될 수도 있음(세계지도 표시가능한 경우만)
$maps_lat = 37.57;
$maps_lng = 126.98;

// API 종류 정하기 다음/네이버/구글
$oMapsModel = getModel('maps');
$maps_config = $oMapsModel->getMapsConfig();

Context::get('maps_srl');

// 다음과 네이버는 국내 지도만 사용가능. 구글은 세계지도.
if($maps_config->maps_api_type == 'daum')
{
$map_comp_header_script = '<script src="https://apis.daum.net/maps/maps3.js?apikey='.$maps_config->map_api_key.'"></script>';
$map_comp_header_script .= '<script>'.
sprintf(
'var defaultlat="%s";'.
'var defaultlng="%s";'
,$maps_lat,$maps_lng).
'</script>';
Context::set('maps_langcode', 'ko');
}
elseif($maps_config->maps_api_type == 'naver')
{
$map_comp_header_script = '<script src="http://openapi.map.naver.com/openapi/naverMap.naver?ver=2.0&amp;key='.$maps_config->map_api_key.'"></script>';
$map_comp_header_script .= '<script>'.
sprintf(
'var defaultlat="%s";'.
'var defaultlng="%s";'
,$maps_lat,$maps_lng).
'</script>';
Context::set('maps_langcode', 'ko');
}
else
{
// 언어 값 설정
$langtype = str_replace($this->xe_langtype, $this->google_langtype, strtolower(Context::getLangType()));

// 세계지도 표시 가능한 경우는 외국이 표시될 수 있음
if(Context::getLangType() == 'zh-CN' || Context::getLangType() == 'zh-TW') // Beijing
{
$maps_lat = 39.55;
$maps_lng = 116.23;
}
elseif(Context::getLangType() != 'ko') // United States
{
$maps_lat = 38;
$maps_lng = -97;
}

$map_comp_header_script = '<script src="https://maps-api-ssl.google.com/maps/api/js?sensor=false&amp;language='.$langtype.'"></script>';
$map_comp_header_script .= '<script>'.
sprintf(
'var defaultlat="%s";'.
'var defaultlng="%s";'
,$maps_lat,$maps_lng).
'</script>';
Context::set('maps_langcode',$langtype);
}

Context::set('maps_api_type', $maps_config->maps_api_type);

Context::addHtmlHeader($map_comp_header_script);

// Specify a template
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('maps_write');
Expand Down
10 changes: 10 additions & 0 deletions maps.model.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ public function getMapsConfig()
{
$oModuleModel = getModel('module');
$maps_config = $oModuleModel->getModuleConfig('maps');
if(!is_object($maps_config))
{
$maps_config = new stdClass();
}

//default settings
if(!$maps_config->maps_api_type)
{
$maps_config->maps_api_type = 'google';
}

return $maps_config;
}
Expand Down
4 changes: 2 additions & 2 deletions queries/insertMapsContent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<column name="title" var="title" />
<column name="content" var="content" />
<column name="ipaddress" var="ipaddress" />
<column name="regdate" var="curdate()" />
<column name="update" var="curdate()" />
<column name="regdate" default="curdate()" />
<column name="update" default="curdate()" />
</columns>
</query>
2 changes: 1 addition & 1 deletion queries/updateMapsContent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<column name="title" var="title" />
<column name="content" var="content" />
<column name="ipaddress" var="ipaddress" />
<column name="update" var="curdate()" />
<column name="update" default="curdate()" />
</columns>
<conditions>
<condition operation="equal" column="maps_srl" var="maps_srl" notnull="notnull" />
Expand Down
10 changes: 7 additions & 3 deletions ruleset/mapsInsert.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset version="1.5.0">
<customrules>
<rule name="base64_encoded" type="regex" test="/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/" />
<rule name="maps_srl" type="regex" test="/^[0-9A-Z]+$/" />
<rule name="positions" type="regex" test="/^[0-9\,\.\;]+$/" />
<rule name="one_point" type="regex" test="/^([0-9\.]+)\,([0-9\.]+)$/" />
</customrules>
<fields>
<field name="maps_srl" required="true" rule="alpha_number" />
<field name="maps_content" required="true" rule="base64_encoded" />
<field name="maps_srl" required="true" rule="maps_srl" />
<field name="map_center" required="true" rule="one_point" />
<field name="map_markers" required="true" rule="positions" />
<field name="map_zoom" required="true" rule="number" />
</fields>
</ruleset>
17 changes: 17 additions & 0 deletions tpl/css/maps_write.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@charset "UTF-8";
#controlArea{box-sizing:border-box;width:310px;height:400px;overflow:hidden;float:left;}
#map_canvas {box-sizing:border-box;overflow:hidden;width:310px;height:400px;float:left;}
#text_writing{box-sizing:border-box;overflow:hidden;width:310px;height:400px; }
#searchArea>ul{margin:15px 0px 0px 5px;}
#searchArea>ul>li,li.result_lists{list-style:none}
#result_list_layer{overflow-y:scroll;height:339px;}
#insertAction{text-decoration:none!important;color:#FFFFFF!important;box-sizing:border-box;display:block;height:287px;font-size:29px;text-align:center;background-color:#8e8e93;border:5px solid #6a6a6e;}
#insertAction>span{vertical-align:-124px;}
#insertAction:hover{background-color:#474749;}
.gmnoprint div[title^="Pan"],.gmnoprint div[title~="이동"] {opacity: 0 !important;}
input[type=text] {
width: 150px!important;
}
#view_list{margin:0;}
li.result_lists>a{box-sizing:border-box;display:block;text-decoration:none;width:100%;font-size:15px;height:31px;padding:5px 10px;border-bottom:1px dotted #8e8e93;overflow:hidden;direction:rtl;text-overflow:ellipsis;white-space : nowrap; }
#helpDiv{display:none;position:absolute;top:0;margin:0px auto;padding:0;width:800px;height:455px;z-index:100000;}
Loading

0 comments on commit 255c24f

Please sign in to comment.