upload_target_srl = $upload_target_srl; $this->component_path = $component_path; Context::loadLang($component_path.'lang'); } /** * @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"); // 지정된 서버에 요청을 시도한다 $address = urlencode(iconv("UTF-8","EUC-KR",$address)); $query_string = 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); //If a Naver OpenApi Error message exists. if($xml_doc->error->error_code->body || $xml_doc->error->message->body) return new Object(-1, 'NAVER OpenAPI Error'."\n".'Code : '.$xml_doc->error->error_code->body."\n".'Message : '.$xml_doc->error->message->body); if($xml_doc->geocode->total->body == 0) return new Object(-1,'msg_no_result'); $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; $zoom = $xml_obj->attrs->zoom; if(!is_numeric($zoom)) $zoom = 3; $marker = urlencode($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, $zoom, $marker, $width, $height); return $body_code; } function displayMap() { $id = "navermap".rand(11111111,99999999); $width = Context::get('width'); if(!$width) $width = 640; settype($width,"float"); $height = Context::get('height'); if(!$height) $height = 480; settype($height,"float"); $x = Context::get('x'); if(!$x) $x = 321198; settype($x,"int"); $y = Context::get('y'); if(!$y) $y = 529730; settype($y,"int"); $zoom = Context::get('zoom'); if($zoom == '') $zoom = 3; settype($zoom,"int"); $marker = Context::get('marker'); $html = ''. ''. ''. '