11 define(
'CH_WMAP_ZOOM_DEFAULT_ENTRY', 10);
12 define(
'CH_WMAP_ZOOM_DEFAULT_EDIT', 5);
13 define(
'CH_WMAP_PRIVACY_DEFAULT', 3);
21 'group.png' => array(
'w' => 24,
'h' => 24,
'url' =>
''),
22 'default' => array(
'w' => 24,
'h' => 24,
'url' =>
''),
29 $this->_aParts = $this->_oDb->getParts();
36 $this->_oTemplate->pageStart();
42 $this->_oTemplate->addJs($this->_sProto .
'://www.google.com/jsapi?key=' .
getParam(
'ch_wmap_key'));
43 $this->_oTemplate->addJs(
'ChWmap.js');
44 $this->_oTemplate->addCss(
'main.css');
45 $this->_oTemplate->pageCode(
_t(
'_ch_wmap_block_title_block_map'),
false,
false);
50 if (!isset($this->_aParts[$sPart])) {
51 $this->_oTemplate->displayPageNotFound();
56 $iEntryId = (int)$iEntryId;
57 $aLocation = $this->_iProfileId ? $this->_oDb->getDirectLocation($iEntryId, $this->_aParts[$sPart]) :
false;
60 $this->_oTemplate->displayAccessDenied();
65 if (
'profiles' == $sPart) {
66 $aLocation[
'title'] =
getNickName($aLocation[
'id']);
69 $this->_oTemplate->pageStart();
75 $this->_oTemplate->addJs($this->_sProto .
'://www.google.com/jsapi?key=' .
getParam(
'ch_wmap_key'));
76 $this->_oTemplate->addJs(
'ChWmap.js');
77 $this->_oTemplate->addCss(
'main.css');
78 $this->_oTemplate->pageCode(sprintf(
_t(
'_ch_wmap_edit'), $aLocation[
'title'],
79 _t($this->_aParts[$sPart][
'title_singular'])),
false,
false);
89 $sMapClassInstanceName,
93 $iRet = $this->
_saveData($iEntryId, $sPart, $iZoom, $sMapType, $fLat, $fLng, $sMapClassInstanceName, $sAddress,
101 $this->_oTemplate->displayAccessDenied();
126 if (!isset($this->_aParts[$sPart])) {
130 $iEntryId = (int)
$iId;
131 $r = $this->_oDb->getDirectLocation($iEntryId, $this->_aParts[$sPart]);
132 if (!$r ||
empty($r[
'lat'])) {
136 if (
'profiles' == $sPart) {
141 $sIcon = $this->_aParts[$r[
'part']][
'icon_site'];
142 $sIcon =
$GLOBALS[
'oFunctions']->sysImage(
false === strpos($sIcon,
143 '.') ? $sIcon : $this->_oTemplate->getIconUrl($sIcon));
146 'title' => $r[
'title'],
147 'link' => CH_WSB_URL_ROOT . $oPermalinks->permalink($this->_aParts[$r[
'part']][
'permalink'] . $r[
'uri'])
149 $sHtml = $this->_oTemplate->parseHtmlByName(
'popup_location',
$aVars);
151 $aIconJSON = $this->
_getIconArray($sMapClassInstanceName ==
'glChWmapEdit' ?
'' : $this->_aParts[$r[
'part']][
'icon']);
158 'icon' => $aIconJSON,
161 echo json_encode($aRet);
170 $sMapClassInstanceName,
174 $fLatMin = (float)$fLatMin;
175 $fLatMax = (float)$fLatMax;
176 $fLngMin = (float)$fLngMin;
177 $fLngMax = (float)$fLngMax;
178 $iZoom = (int)$iZoom;
180 echo $this->
_getLocationsData($fLatMin, $fLatMax, $fLngMin, $fLngMax, $sCustomParts, $sCustom);
183 function _getLocationsData($fLatMin, $fLatMax, $fLngMin, $fLngMax, $sCustomParts =
'', $sCustom =
'')
190 $a = $this->_oDb->getLocationsByBounds(
'', (
float)$fLatMin, (
float)$fLatMax, (
float)$fLngMin,
195 if (!$this->_oDb->getDirectLocation($r[
'id'], $this->_aParts[$r[
'part']],
true))
198 if (
'profiles' == $r[
'part']) {
202 $sKey = $r[
'lat'] .
'x' . $r[
'lng'];
204 $sIcon = $this->_aParts[$r[
'part']][
'icon_site'];
205 $sIcon =
$GLOBALS[
'oFunctions']->sysImage(
false === strpos($sIcon,
206 '.') ? $sIcon : $this->_oTemplate->getIconUrl($sIcon));
210 'title' => $r[
'title'],
211 'link' => CH_WSB_URL_ROOT . $oPermalinks->permalink($this->_aParts[$r[
'part']][
'permalink'] . $r[
'uri'])
214 $aa[$sKey][] = array(
217 'title' => $r[
'title'],
218 'icon' => $this->_aParts[$r[
'part']][
'icon'],
219 'html' => $this->_oTemplate->parseHtmlByName(
'popup_location',
$aVars),
224 foreach ($aa
as $k => $a) {
229 $sHtml .= $r[
'html'];
230 $aTitles[] = $r[
'title'];
233 $aVars = array(
'content' => $sHtml);
237 'titles' => $aTitles,
238 'data' => $this->_oTemplate->parseHtmlByName(
'popup_locations',
$aVars),
239 'icon' => $this->_getIconArray((count($a) > 1 ?
'group.png' : $sIcon)),
243 return json_encode($aRet);
251 $this->_oTemplate->displayAccessDenied();
256 $iLimit = (int)$iLimit;
257 $iDelay = (int)$iDelay;
259 $a = $this->_oDb->getUndefinedLocations($iLimit);
267 'msg' =>
'Entries update is in progress, please wait...',
269 echo $this->_oTemplate->parseHtmlByName(
'updating',
$aVars);
271 $this->_oTemplate->displayMsg(
'Entries locations update has been completed');
278 $this->_oTemplate->displayAccessDenied();
283 if (!isset($this->_aParts[$sPart])) {
284 $this->_oTemplate->displayPageNotFound();
289 $this->_oTemplate->pageStart();
294 if (isset($_POST[
'save']) && isset($_POST[
'cat']) && (
int)$_POST[
'cat']) {
296 $mixedResult =
$oSettings->saveChanges($_POST);
299 foreach ($_POST
as $k => $v) {
305 'cat' =>
'World Map Home: ' . ucfirst($sPart),
306 'title' =>
_t(
'_ch_wmap_admin_settings_part_home',
_t($this->_aParts[$sPart][
'title'])),
307 'extra' =>
'return $this->_saveLocationForm ("PartHome", $this->serviceHomepagePartBlock ("' . $sPart .
'"));',
310 'cat' =>
'World Map Entry: ' . ucfirst($sPart),
311 'title' =>
_t(
'_ch_wmap_admin_settings_part_entry',
_t($this->_aParts[$sPart][
'title'])),
315 'cat' =>
'World Map Edit Location: ' . ucfirst($sPart),
316 'title' =>
_t(
'_ch_wmap_admin_settings_edit_location',
_t($this->_aParts[$sPart][
'title'])),
321 foreach ($aCats
as $a) {
322 $iId = $this->_oDb->getSettingsCategory($a[
'cat']);
327 if ($mixedResult !==
true && !
empty($mixedResult) && $_POST[
'cat'] ==
$iId) {
333 $aVars = array(
'content' => eval($a[
'extra']));
334 $sExtra = $this->_oTemplate->parseHtmlByName(
'extra_wrapper',
$aVars);
337 echo $this->_oTemplate->adminBlock($this->_oTemplate->parseHtmlByName(
'default_padding',
$aVars),
341 $this->_oTemplate->addJsAdmin($this->_sProto .
'://www.google.com/jsapi?key=' .
getParam(
'ch_wmap_key'));
342 $this->_oTemplate->addJsAdmin(
'modules/cheetah/world_map/js/|ChWmap.js');
343 $this->_oTemplate->addCssAdmin(
'main.css');
344 $this->_oTemplate->addCssAdmin(
'forms_adv.css');
345 $this->_oTemplate->pageCodeAdmin(
_t(
'_ch_wmap_administration') .
' ' .
_t($this->_aParts[$sPart][
'title']));
351 $this->_oTemplate->displayAccessDenied();
356 $this->_oTemplate->pageStart();
358 $aPartsForVars = array();
359 foreach ($this->_aParts
as $k => $r) {
360 $aPartsForVars[] = array(
362 'title' =>
_t($r[
'title']),
363 'icon' =>
$GLOBALS[
'oFunctions']->sysImage(
false === strpos($r[
'icon_site'],
364 '.') ? $r[
'icon_site'] : $this->_oTemplate->getIconUrl($r[
'icon_site'])),
365 'link_base' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration_parts/',
370 'module_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri(),
371 'ch_repeat:parts' => $aPartsForVars,
374 echo $this->_oTemplate->adminBlock(
$sContent,
_t(
'_ch_wmap_admin_links'),
false,
false, 11);
379 if (isset($_POST[
'save']) && isset($_POST[
'cat']) && (
int)$_POST[
'cat']) {
381 $mixedResult =
$oSettings->saveChanges($_POST);
384 foreach ($_POST
as $k => $v) {
390 'cat' =>
'World Map General',
391 'title' =>
_t(
'_ch_wmap_admin_settings_general'),
395 'cat' =>
'World Map Homepage',
396 'title' =>
_t(
'_ch_wmap_admin_settings_homepage'),
397 'extra' =>
'return $this->_saveLocationForm ("Home", $this->serviceHomepageBlock ());',
400 'cat' =>
'World Map Separate',
401 'title' =>
_t(
'_ch_wmap_admin_settings_separate'),
402 'extra' =>
'return $this->_saveLocationForm ("Page", $this->serviceSeparatePageBlock ());',
406 foreach ($aCats
as $a) {
407 $iId = $this->_oDb->getSettingsCategory($a[
'cat']);
412 if ($mixedResult !==
true && !
empty($mixedResult) && $_POST[
'cat'] ==
$iId) {
418 $aVars = array(
'content' => eval($a[
'extra']));
419 $sExtra = $this->_oTemplate->parseHtmlByName(
'extra_wrapper',
$aVars);
422 echo $this->_oTemplate->adminBlock($this->_oTemplate->parseHtmlByName(
'default_padding',
$aVars),
426 $this->_oTemplate->addJsAdmin($this->_sProto .
'://www.google.com/jsapi?key=' .
getParam(
'ch_wmap_key'));
427 $this->_oTemplate->addJsAdmin(CH_WSB_URL_MODULES . $this->_aModule[
'path'] .
'js/ChWmap.js');
428 $this->_oTemplate->addCssAdmin(
'main.css');
429 $this->_oTemplate->addCssAdmin(
'forms_adv.css');
430 $this->_oTemplate->pageCodeAdmin(
_t(
'_ch_wmap_administration'));
445 if (
false === $iViewer) {
449 if (
'profiles' == $sPart) {
455 $oPrivacy =
new ChWsbPrivacy($this->_aParts[$sPart][
'join_table'], $this->_aParts[$sPart][
'join_field_id'],
456 $this->_aParts[$sPart][
'join_field_author']);
457 if (!$oPrivacy->check(
'view', $iEntryId, $iViewer)) {
462 $aLocation = $this->_oDb->getDirectLocation($iEntryId, $this->_aParts[$sPart]);
463 if (!$aLocation || (!$aLocation[
'lat'] && $aLocation[
'lng'])) {
467 if (
false === $aLocation[
'zoom'] || -1 == $aLocation[
'zoom']) {
468 $aLocation[
'zoom'] =
getParam(
"ch_wmap_edit_{$sPart}_zoom");
471 if (!$aLocation[
'type']) {
472 $aLocation[
'type'] =
getParam(
"ch_wmap_edit_{$sPart}_map_type");
505 $a = array(
'fLat',
'fLng',
'iZoom',
'sMapType',
'sCountry',
'sState',
'sCity',
'sAddress');
506 foreach ($a
as $sVar) {
507 if (
'' === $$sVar ||
false === $$sVar) {
512 return $this->
_saveData($iEntryId, $sPart, $iZoom, $sMapType, $fLat, $fLng,
'', $sAddress,
$sCountry);
524 if (!isset($this->_aParts[$sPart])) {
528 $iEntryId = (int)$iEntryId;
529 $aLocation = $this->_oDb->getDirectLocation($iEntryId, $this->_aParts[$sPart]);
530 if (
'profiles' == $sPart) {
531 $aLocation[
'title'] =
getNickName($aLocation[
'id']);
543 if ($aLocation && !
empty($aLocation[
'lat'])) {
544 $fLat = $aLocation[
'lat'];
545 $fLng = $aLocation[
'lng'];
546 $iZoom = $aLocation[
'zoom'];
547 $sMapType = $aLocation[
'type'];
550 if (
false === $fLat ||
false === $fLng) {
551 $aLocationCountry = $this->
_geocode($aLocation[
'country'], $aLocation[
'country']);
552 $fLat = isset($aLocationCountry[0]) ? $aLocationCountry[0] : 0;
553 $fLng = isset($aLocationCountry[1]) ? $aLocationCountry[1] : 0;
557 if (
false === $iZoom || -1 == $iZoom) {
558 $iZoom =
getParam(
"ch_wmap_edit_{$sPart}_zoom");
562 $sMapType =
getParam(
"ch_wmap_edit_{$sPart}_map_type");
566 'msg_incorrect_google_key' => trim(
_t(
'_ch_wmap_msg_incorrect_google_key')),
567 'loading' =>
_t(
'_loading ...'),
568 'map_control' =>
getParam(
"ch_wmap_edit_{$sPart}_control_type"),
569 'map_is_type_control' =>
getParam(
"ch_wmap_edit_{$sPart}_is_type_control") ==
'on' ? 1 : 0,
570 'map_is_scale_control' =>
getParam(
"ch_wmap_edit_{$sPart}_is_scale_control") ==
'on' ? 1 : 0,
571 'map_is_overview_control' =>
getParam(
"ch_wmap_edit_{$sPart}_is_overview_control") ==
'on' ? 1 : 0,
572 'map_is_dragable' =>
getParam(
"ch_wmap_edit_{$sPart}_is_map_dragable") ==
'on' ? 1 : 0,
573 'map_type' => $sMapType,
576 'map_zoom' => $iZoom,
580 'subclass' =>
'ch_wmap_edit',
581 'data_url' => CH_WSB_URL_MODULES .
"?r=wmap/get_data_location/$iEntryId/{parts}/{instance}/{ts}",
582 'save_data_url' => CH_WSB_URL_MODULES .
"?r=wmap/save_data/$iEntryId/{parts}/{zoom}/{map_type}/{lat}/{lng}/{instance}/{address}/{country}/{ts}",
583 'save_location_url' =>
'',
587 $sMap = $this->_oTemplate->parseHtmlByName(
'map',
$aVars);
590 $sBackLink = CH_WSB_URL_ROOT . $oPermalinks->permalink($this->_aParts[$aLocation[
'part']][
'permalink'] . $aLocation[
'uri']);
592 'info' => sprintf(
_t(
'_ch_wmap_edit'),
"<a href=\"{$sBackLink}\">{$aLocation['title']}</a>",
593 _t($this->_aParts[$sPart][
'title_singular'])),
597 return array($this->_oTemplate->parseHtmlByName(
'map_edit',
$aVars));
607 $this->_oTemplate->addJs($this->_sProto .
'://www.google.com/jsapi?key=' .
getParam(
'ch_wmap_key'));
608 $this->_oTemplate->addJs(
'ChWmap.js');
609 $this->_oTemplate->addCss(
'main.css');
622 if (!isset($this->_aParts[$sPart])) {
625 $this->_oTemplate->addJs($this->_sProto .
'://www.google.com/jsapi?key=' .
getParam(
'ch_wmap_key'));
626 $this->_oTemplate->addJs(
'ChWmap.js');
627 $this->_oTemplate->addCss(
'main.css');
630 'ch_wmap_home_' . $sPart,
'PartHome',
'part_home/' . $sPart,
false);
644 $sSubclass =
'ch_wmap_separate',
645 $sParamPrefix =
'ch_wmap_separate',
647 $sSaveLocationSuffix =
'separate_page',
648 $isPartsSelector =
true
650 if (
false === $fLat) {
651 $fLat =
getParam($sParamPrefix .
'_lat');
653 if (
false === $fLng) {
654 $fLng =
getParam($sParamPrefix .
'_lng');
656 if (
false === $iZoom) {
657 $iZoom =
getParam($sParamPrefix .
'_zoom');
661 'msg_incorrect_google_key' => trim(
_t(
'_ch_wmap_msg_incorrect_google_key')),
662 'loading' =>
_t(
'_loading ...'),
663 'map_control' =>
getParam($sParamPrefix .
'_control_type'),
664 'map_is_type_control' =>
getParam($sParamPrefix .
'_is_type_control') ==
'on' ? 1 : 0,
665 'map_is_scale_control' =>
getParam($sParamPrefix .
'_is_scale_control') ==
'on' ? 1 : 0,
666 'map_is_overview_control' =>
getParam($sParamPrefix .
'_is_overview_control') ==
'on' ? 1 : 0,
667 'map_is_dragable' =>
getParam($sParamPrefix .
'_is_map_dragable') ==
'on' ? 1 : 0,
668 'map_type' =>
getParam($sParamPrefix .
'_map_type'),
671 'map_zoom' => $iZoom,
672 'parts' => $sPartsCustom,
673 'custom' => $sCustom,
674 'suffix' => $sSuffix,
675 'subclass' => $sSubclass,
676 'data_url' => CH_WSB_URL_MODULES .
"?r=wmap/get_data/{zoom}/{lat_min}/{lat_max}/{lng_min}/{lng_max}/{instance}/{parts}/{custom}",
677 'save_data_url' =>
'',
678 'save_location_url' => $this->
isAdmin() ? CH_WSB_URL_MODULES .
"?r=wmap/save_location_{$sSaveLocationSuffix}/{zoom}/{map_type}/{lat}/{lng}" :
'',
679 'shadow_url' => $this->_oTemplate->getIconUrl(
'flag_icon_shadow.png'),
683 $sMap = $this->_oTemplate->parseHtmlByName(
'map',
$aVars);
685 if (!$isPartsSelector) {
690 'suffix' =>
$aVars[
'suffix'],
691 'subclass' =>
$aVars[
'subclass'],
692 'ch_repeat:parts' => array(),
695 foreach ($this->_aParts AS $k => $r) {
696 $aVarsParts[
'ch_repeat:parts'][] = array(
698 'title' =>
_t($r[
'title']),
699 'icon' =>
$GLOBALS[
'oFunctions']->sysImage(
false === strpos($r[
'icon_site'],
700 '.') ? $r[
'icon_site'] : $this->_oTemplate->getIconUrl($r[
'icon_site'])),
701 'suffix' =>
$aVars[
'suffix'],
702 'checked' => isset($aPartsSelected[$k]) ?
'checked' :
'',
705 $sMapParts = $this->_oTemplate->parseHtmlByName(
'map_parts', $aVarsParts);
707 return array($sMapParts . $sMap);
719 if (!isset($this->_aParts[$sPart])) {
723 $sParamPrefix =
'ch_wmap_entry_' . $sPart;
724 $iEntryId = (int)$iEntryId;
725 $r = $this->_oDb->getDirectLocation($iEntryId, $this->_aParts[$sPart]);
728 if ($r && !
empty($r[
'lat'])) {
731 'msg_incorrect_google_key' =>
_t(
'_ch_wmap_msg_incorrect_google_key'),
732 'loading' =>
_t(
'_loading ...'),
733 'map_control' =>
getParam($sParamPrefix .
'_control_type'),
734 'map_is_type_control' =>
getParam($sParamPrefix .
'_is_type_control') ==
'on' ? 1 : 0,
735 'map_is_scale_control' =>
getParam($sParamPrefix .
'_is_scale_control') ==
'on' ? 1 : 0,
736 'map_is_overview_control' =>
getParam($sParamPrefix .
'_is_overview_control') ==
'on' ? 1 : 0,
737 'map_is_dragable' =>
getParam($sParamPrefix .
'_is_map_dragable') ==
'on' ? 1 : 0,
738 'map_lat' => $r[
'lat'],
739 'map_lng' => $r[
'lng'],
741 'map_type' => $r[
'type'] ? $r[
'type'] : (
getParam($sParamPrefix .
'_map_type') ?
getParam($sParamPrefix .
'_map_type') :
'normal'),
744 'suffix' =>
'Location',
745 'subclass' =>
'ch_wmap_location_box',
746 'data_url' => CH_WSB_URL_MODULES .
"' + '?r=wmap/get_data_location/" . $iEntryId .
"/" . $sPart .
"/{instance}",
747 'save_data_url' =>
'',
748 'save_location_url' =>
'',
753 $this->_oTemplate->addJs($this->_sProto .
'://www.google.com/jsapi?key=' .
getParam(
'ch_wmap_key'));
754 $this->_oTemplate->addJs(
'ChWmap.js');
755 $this->_oTemplate->addCss(
'main.css');
758 'map' => $this->_oTemplate->parseHtmlByName(
'map',
$aVars),
760 $sBoxContent = $this->_oTemplate->parseHtmlByName(
'entry_location', $aVars2);
764 if ($r[
'author_id'] == $this->_iProfileId || $this->
isAdmin()) {
766 'icon' => $this->_oTemplate->getIconUrl(
'more.png'),
767 'url' => $this->_oConfig->getBaseUri() .
"edit/$iEntryId/$sPart",
768 'title' =>
_t(
'_ch_wmap_box_footer_edit'),
770 $sBoxFooter = $this->_oTemplate->parseHtmlByName(
'box_footer',
$aVars);
785 if (!isset($this->_aParts[$sPart])) {
789 $aPart = $this->_aParts[$sPart];
791 return $this->_oDb->deleteLocation((
int)$iEntryId, $sPart);
801 if (!isset($this->_aParts[$sPart])) {
805 $aPart = $this->_aParts[$sPart];
807 $a = $this->_oDb->getDirectLocation($iEntryId, $aPart);
812 if ($a[
'lat'] && $a[
'lng'] && $a[
'type']) {
816 $this->_oDb->updateLocationPrivacy((
int)$a[
'id'],
827 if (!$this->_oDb->enablePart($sPart, (
int)$isEnable)) {
831 if ($isClearPartLocations) {
832 $this->_oDb->clearLocations($sPart,
false);
840 if (!$this->_oDb->updatePart($sPart, $a))
851 'title_singular' =>
'',
856 'join_field_id' =>
'id',
857 'join_field_country' =>
'',
858 'join_field_city' =>
'',
859 'join_field_state' =>
'',
860 'join_field_zip' =>
'',
861 'join_field_address' =>
'',
862 'join_field_latitude' =>
'',
863 'join_field_longitude' =>
'',
864 'join_field_title' =>
'',
865 'join_field_uri' =>
'',
866 'join_field_author' =>
'',
867 'join_field_privacy' =>
'',
872 $aOptions = array_merge($aDefaults, $a);
874 if (!$this->_oDb->addPart($aOptions)) {
883 $this->_oDb->clearLocations($sPart,
false);
885 return $this->_oDb->removePart($sPart);
894 array(
'location' => $aLocation));
901 $oAlert =
new ChWsbAlerts(
'ch_wmap',
'location_manually_updated', $iEntryId, $this->_iProfileId,
902 array(
'location' => $aLocation,
'part' => $sPart));
910 if (!$this->_iProfileId) {
916 if ($aLocation && $aLocation[
'author_id'] == $this->_iProfileId) {
934 $sAddress = rawurlencode($sAddress);
936 $sUrl =
ch_proto() .
"://maps.googleapis.com/maps/api/geocode/json";
939 'address' => $sAddress,
943 $oData = json_decode(
$s);
944 if (
null == $oData) {
948 if (
'OK' != $oData->status) {
952 foreach ($oData->results
as $oResult) {
953 $sShortNameCountry =
'';
954 foreach ($oResult->address_components
as $oAddressComponent) {
955 if (in_array(
'country', $oAddressComponent->types)) {
956 $sShortNameCountry = $oAddressComponent->short_name;
960 if (!$sCountryCode || ($sShortNameCountry && $sCountryCode == $sShortNameCountry)) {
961 $oLocation = $oResult->geometry->location;
963 return array($oLocation->lat, $oLocation->lng, $sShortNameCountry);
972 $iDelay = (int)$iDelay;
974 $iId = (int)$r[
'id'];
977 if (isset($r[
'latitude']) && isset($r[
'longitude'])) {
978 $r[
'latitude'] = floatval($r[
'latitude']);
979 $r[
'longitude'] = floatval($r[
'longitude']);
980 if (is_float($r[
'latitude']) && is_float($r[
'longitude'])) {
984 $a = $this->
_geocode($r[
'latitude'] .
', ' . $r[
'longitude']);
988 if (isset($r[
'state']) && trim($r[
'state'])) {
989 $sState =
' ' . $r[
'state'];
992 if (isset($r[
'address']) && trim($r[
'address'])) {
996 $a = $this->
_geocode($r[
'address'] .
' ' . $r[
'city'] .
' ' . $r[
'state'] . $r[
'country'],
1000 if (!$a && isset($r[
'zip']) && trim($r[
'zip'])) {
1004 $a = $this->
_geocode($r[
'zip'] .
' ' . $r[
'country'], $r[
'country']);
1011 $a = $this->
_geocode($r[
'city'] .
' ' . $r[
'state'] . $r[
'country'], $r[
'country']);
1020 $this->_oDb->insertLocation(
$iId, $r[
'part'],
$sTitle, $r[
'uri'], $a[0], $a[1], -1,
'',
1026 $this->_oDb->insertLocation(
$iId, $r[
'part'],
$sTitle, $r[
'uri'], 0, 0, -1,
'',
'',
'',
'', $mixedPrivacy,
1032 'lat' => (isset($a[0]) ? $a[0] :
false),
1033 'lng' => (isset($a[1]) ? $a[1] :
false),
1034 'country' => $sCountryCode
1043 echo
'Access denied';
1048 if ($iZoom = (
int)$iZoom) {
1049 setParam($sPrefix .
'_zoom', $iZoom);
1052 switch ($sMapType) {
1056 setParam($sPrefix .
'_map_type', $sMapType);
1059 if ($fLat = (
float)$fLat) {
1060 setParam($sPrefix .
'_lat', $fLat);
1063 if ($fLng = (
float)$fLng) {
1064 setParam($sPrefix .
'_lng', $fLng);
1072 if (is_array($sMap)) {
1076 if (!preg_match(
'/^[A-Za-z0-9]+$/', $sSuffix)) {
1080 $aCustomForm = array(
1082 'form_attrs' => array(
1083 'name' =>
"ch_wmap_save_location_{$sSuffix}",
1084 'onsubmit' =>
"return glChWmap{$sSuffix}.saveLocation();",
1092 'content' =>
"<div class=\"ch_wmap_form_map\">$sMap</div>",
1094 'caption' =>
_t(
'_ch_wmap_admin_map'),
1099 'name' =>
'submit_form',
1100 'value' =>
_t(
'_ch_wmap_admin_save_location'),
1107 return $f->getCode();
1120 $sMapClassInstanceName =
'',
1124 if (!isset($this->_aParts[$sPart])) {
1128 $iEntryId = (int)$iEntryId;
1129 $aLocation = $this->_iProfileId ? $this->_oDb->getDirectLocation($iEntryId, $this->_aParts[$sPart]) :
false;
1135 if (!$aLocation && (
'null' == $fLat ||
'null' == $fLng)) {
1139 $fLat =
'null' != $fLat ? (float)$fLat : $aLocation[
'lat'];
1140 $fLng =
'null' != $fLng ? (float)$fLng : $aLocation[
'lng'];
1141 $iZoom =
'null' != $iZoom ? (int)$iZoom : ($aLocation ? $aLocation[
'zoom'] : -1);
1142 $sMapType = $sMapType &&
'null' != $sMapType ? $sMapType : ($aLocation ? $aLocation[
'type'] :
'');
1150 switch ($sMapType) {
1156 $sMapType =
'normal';
1163 if (!$this->_oDb->insertLocation($iEntryId, $sPart, $aLocation[
'title'], $aLocation[
'uri'], $fLat, $fLng,
1164 $iZoom, $sMapType, $sAddress, $aLocation[
'city'],
$sCountry, $mixedPrivacy)
1173 'map_type' => $sMapType,
1174 'address' => $sAddress,
1183 $aPartsRet = array();
1184 $aPartsTmp = explode(
',', $sParts);
1185 foreach ($aPartsTmp
as $sPart) {
1186 if (isset($this->_aParts[$sPart])) {
1187 $aPartsRet[$sPart] = $sPart;
1191 foreach ($this->_aParts
as $sPart => $r) {
1192 $aPartsRet[$sPart] = $sPart;
1201 if ($isCountryFlag) {
1202 $this->aIconsSizes[
'country_flag'][
'url'] = $sBaseFilename;
1204 return $this->aIconsSizes[
'country_flag'];
1207 if (!$sBaseFilename) {
1208 return $this->aIconsSizes[
'default'];
1211 if (
empty($this->aIconsSizes[$sBaseFilename])) {
1212 $this->aIconsSizes[$sBaseFilename] = $this->aIconsSizes[
'default'];
1215 if (
empty($this->aIconsSizes[$sBaseFilename][
'url'])) {
1216 $this->aIconsSizes[$sBaseFilename][
'url'] = $this->_oTemplate->getIconUrl($sBaseFilename);
1219 return $this->aIconsSizes[$sBaseFilename];