mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 11:40:48 +03:00
Модуль для работы с geo-базой, привязка пользователя к гео-базе с выбором страны/региона/города на ajax
This commit is contained in:
parent
644f4bacba
commit
dfe273aade
|
@ -57,6 +57,9 @@ class ActionAjax extends Action {
|
|||
$this->AddEventPreg('/^autocompleter$/i','/^user$/','EventAutocompleterUser');
|
||||
|
||||
$this->AddEventPreg('/^comment$/i','/^delete$/','EventCommentDelete');
|
||||
|
||||
$this->AddEventPreg('/^geo/i','/^get/','/^regions$/','EventGeoGetRegions');
|
||||
$this->AddEventPreg('/^geo/i','/^get/','/^cities/','EventGeoGetCities');
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,6 +68,60 @@ class ActionAjax extends Action {
|
|||
**********************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* Получение списка регионов по стране
|
||||
*/
|
||||
protected function EventGeoGetRegions() {
|
||||
$iCountryId=getRequest('country');
|
||||
$iLimit=200;
|
||||
if (is_numeric(getRequest('limit')) and getRequest('limit')>0) {
|
||||
$iLimit=getRequest('limit');
|
||||
}
|
||||
|
||||
if (!($oCountry=$this->Geo_GetGeoObject('country',$iCountryId))) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('system_error'));
|
||||
return;
|
||||
}
|
||||
|
||||
$aResult=$this->Geo_GetRegions(array('country_id'=>$oCountry->getId()),array('sort'=>'asc'),1,$iLimit);
|
||||
$aRegions=array();
|
||||
foreach($aResult['collection'] as $oObject) {
|
||||
$aRegions[]=array(
|
||||
'id' => $oObject->getId(),
|
||||
'name' => $oObject->getName(),
|
||||
);
|
||||
}
|
||||
|
||||
$this->Viewer_AssignAjax('aRegions',$aRegions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение списка городов по региону
|
||||
*/
|
||||
protected function EventGeoGetCities() {
|
||||
$iRegionId=getRequest('region');
|
||||
$iLimit=500;
|
||||
if (is_numeric(getRequest('limit')) and getRequest('limit')>0) {
|
||||
$iLimit=getRequest('limit');
|
||||
}
|
||||
|
||||
if (!($oRegion=$this->Geo_GetGeoObject('region',$iRegionId))) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('system_error'));
|
||||
return;
|
||||
}
|
||||
|
||||
$aResult=$this->Geo_GetCities(array('region_id'=>$oRegion->getId()),array('sort'=>'asc'),1,$iLimit);
|
||||
$aCities=array();
|
||||
foreach($aResult['collection'] as $oObject) {
|
||||
$aCities[]=array(
|
||||
'id' => $oObject->getId(),
|
||||
'name' => $oObject->getName(),
|
||||
);
|
||||
}
|
||||
|
||||
$this->Viewer_AssignAjax('aCities',$aCities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Голосование за комментарий
|
||||
*
|
||||
|
|
|
@ -379,6 +379,18 @@ class ActionSettings extends Action {
|
|||
/**
|
||||
* Заполняем профиль из полей формы
|
||||
*/
|
||||
/**
|
||||
* Определяем гео-объект
|
||||
*/
|
||||
if (getRequest('geo_city')) {
|
||||
$oGeoObject=$this->Geo_GetGeoObject('city',getRequest('geo_city'));
|
||||
} elseif (getRequest('geo_region')) {
|
||||
$oGeoObject=$this->Geo_GetGeoObject('region',getRequest('geo_region'));
|
||||
} elseif (getRequest('geo_country')) {
|
||||
$oGeoObject=$this->Geo_GetGeoObject('country',getRequest('geo_country'));
|
||||
} else {
|
||||
$oGeoObject=null;
|
||||
}
|
||||
/**
|
||||
* Проверяем имя
|
||||
*/
|
||||
|
@ -417,33 +429,6 @@ class ActionSettings extends Action {
|
|||
} else {
|
||||
$this->oUserCurrent->setProfileBirthday(null);
|
||||
}
|
||||
/**
|
||||
* Проверяем страну
|
||||
*/
|
||||
if (func_check(getRequest('profile_country'),'text',1,30)) {
|
||||
$this->oUserCurrent->setProfileCountry(getRequest('profile_country'));
|
||||
} else {
|
||||
$this->oUserCurrent->setProfileCountry(null);
|
||||
}
|
||||
/**
|
||||
* Проверяем регион
|
||||
* пока отключим регион, т.к. не понятно нужен ли он вообще =)
|
||||
*/
|
||||
/*
|
||||
if (func_check(getRequest('profile_region'),'text',1,30)) {
|
||||
$this->oUserCurrent->setProfileRegion(getRequest('profile_region'));
|
||||
} else {
|
||||
$this->oUserCurrent->setProfileRegion(null);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Проверяем город
|
||||
*/
|
||||
if (func_check(getRequest('profile_city'),'text',1,30)) {
|
||||
$this->oUserCurrent->setProfileCity(getRequest('profile_city'));
|
||||
} else {
|
||||
$this->oUserCurrent->setProfileCity(null);
|
||||
}
|
||||
/**
|
||||
* Проверяем ICQ
|
||||
*/
|
||||
|
@ -507,27 +492,32 @@ class ActionSettings extends Action {
|
|||
if (!$bError) {
|
||||
if ($this->User_Update($this->oUserCurrent)) {
|
||||
/**
|
||||
* Добавляем страну
|
||||
* Создаем связь с гео-объектом
|
||||
*/
|
||||
if ($this->oUserCurrent->getProfileCountry()) {
|
||||
if (!($oCountry=$this->User_GetCountryByName($this->oUserCurrent->getProfileCountry()))) {
|
||||
$oCountry=Engine::GetEntity('User_Country');
|
||||
$oCountry->setName($this->oUserCurrent->getProfileCountry());
|
||||
$this->User_AddCountry($oCountry);
|
||||
if ($oGeoObject) {
|
||||
$this->Geo_CreateTarget($oGeoObject,'user',$this->oUserCurrent->getId());
|
||||
if ($oCountry=$oGeoObject->getCountry()) {
|
||||
$this->oUserCurrent->setProfileCountry($oCountry->getName());
|
||||
} else {
|
||||
$this->oUserCurrent->setProfileCountry(null);
|
||||
}
|
||||
$this->User_SetCountryUser($oCountry->getId(),$this->oUserCurrent->getId());
|
||||
}
|
||||
/**
|
||||
* Добавляем город
|
||||
*/
|
||||
if ($this->oUserCurrent->getProfileCity()) {
|
||||
if (!($oCity=$this->User_GetCityByName($this->oUserCurrent->getProfileCity()))) {
|
||||
$oCity=Engine::GetEntity('User_City');
|
||||
$oCity->setName($this->oUserCurrent->getProfileCity());
|
||||
$this->User_AddCity($oCity);
|
||||
if ($oRegion=$oGeoObject->getRegion()) {
|
||||
$this->oUserCurrent->setProfileRegion($oRegion->getName());
|
||||
} else {
|
||||
$this->oUserCurrent->setProfileRegion(null);
|
||||
}
|
||||
$this->User_SetCityUser($oCity->getId(),$this->oUserCurrent->getId());
|
||||
if ($oCity=$oGeoObject->getCity()) {
|
||||
$this->oUserCurrent->setProfileCity($oCity->getName());
|
||||
} else {
|
||||
$this->oUserCurrent->setProfileCity(null);
|
||||
}
|
||||
} else {
|
||||
$this->Geo_DeleteTargetsByTarget('user',$this->oUserCurrent->getId());
|
||||
$this->oUserCurrent->setProfileCountry(null);
|
||||
$this->oUserCurrent->setProfileRegion(null);
|
||||
$this->oUserCurrent->setProfileCity(null);
|
||||
}
|
||||
$this->User_Update($this->oUserCurrent);
|
||||
|
||||
/**
|
||||
* Обрабатываем дополнительные поля, type = ''
|
||||
|
@ -564,6 +554,27 @@ class ActionSettings extends Action {
|
|||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Загружаем гео-объект привязки
|
||||
*/
|
||||
$oGeoTarget=$this->Geo_GetTargetByTarget('user',$this->oUserCurrent->getId());
|
||||
$this->Viewer_Assign('oGeoTarget',$oGeoTarget);
|
||||
/**
|
||||
* Загружаем в шаблон список стран, регионов, городов
|
||||
*/
|
||||
$aCountries=$this->Geo_GetCountries(array(),array('sort'=>'asc'),1,300);
|
||||
$this->Viewer_Assign('aGeoCountries',$aCountries['collection']);
|
||||
if ($oGeoTarget) {
|
||||
if ($oGeoTarget->getCountryId()) {
|
||||
$aRegions=$this->Geo_GetRegions(array('country_id'=>$oGeoTarget->getCountryId()),array('sort'=>'asc'),1,500);
|
||||
$this->Viewer_Assign('aGeoRegions',$aRegions['collection']);
|
||||
}
|
||||
if ($oGeoTarget->getRegionId()) {
|
||||
$aCities=$this->Geo_GetCities(array('region_id'=>$oGeoTarget->getRegionId()),array('sort'=>'asc'),1,500);
|
||||
$this->Viewer_Assign('aGeoCities',$aCities['collection']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
383
classes/modules/geo/Geo.class.php
Normal file
383
classes/modules/geo/Geo.class.php
Normal file
|
@ -0,0 +1,383 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Модуль Geo - привязка объектов к географии (страна/регион/город)
|
||||
* Терминология:
|
||||
* объект - который привязываем к гео-объекту
|
||||
* гео-объект - географический объект(страна/регион/город)
|
||||
*/
|
||||
class ModuleGeo extends Module {
|
||||
|
||||
protected $oMapper;
|
||||
protected $oUserCurrent;
|
||||
/**
|
||||
* Список доступных типов объектов
|
||||
* На данный момент доступен параметр allow_multi=>1 - указывает на возможность создавать несколько связей для одного объекта
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $aTargetTypes=array(
|
||||
'user'=>array(),
|
||||
);
|
||||
/**
|
||||
* Список доступных типов гео-объектов
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $aGeoTypes=array(
|
||||
'country',
|
||||
'region',
|
||||
'city',
|
||||
);
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*
|
||||
*/
|
||||
public function Init() {
|
||||
$this->oMapper=Engine::GetMapper(__CLASS__);
|
||||
$this->oUserCurrent=$this->User_GetUserCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает список типов объектов для облаты
|
||||
*/
|
||||
public function GetTargetTypes() {
|
||||
return $this->aTargetTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавляет в разрешенные новый тип
|
||||
* @param unknown_type $sTargetType
|
||||
*/
|
||||
public function AddTargetType($sTargetType,$aParams=array()) {
|
||||
if (!array_key_exists($sTargetType,$this->aTargetTypes)) {
|
||||
$this->aTargetTypes[$sTargetType]=$aParams;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет разрешен ли данный тип
|
||||
*
|
||||
* @param $sTargetType
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowTargetType($sTargetType) {
|
||||
return in_array($sTargetType,array_keys($this->aTargetTypes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет разрешен ли данный гео-тип
|
||||
*
|
||||
* @param $sTargetType
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowGeoType($sGeoType) {
|
||||
return in_array($sGeoType,$this->aGeoTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка объекта
|
||||
*
|
||||
* @param string $sTargetType
|
||||
* @param int $iTargetId
|
||||
*/
|
||||
public function CheckTarget($sTargetType,$iTargetId) {
|
||||
if (!$this->IsAllowTargetType($sTargetType)) {
|
||||
return false;
|
||||
}
|
||||
$sMethod = 'CheckTarget'.func_camelize($sTargetType);
|
||||
if (method_exists($this,$sMethod)) {
|
||||
return $this->$sMethod($iTargetId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка на возможность нескольких связей
|
||||
*
|
||||
* @param $sTargetType
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowTargetMulti($sTargetType) {
|
||||
if ($this->IsAllowTargetType($sTargetType)) {
|
||||
if (isset($this->aTargetTypes[$sTargetType]['allow_multi']) and $this->aTargetTypes[$sTargetType]['allow_multi']) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавляет связь объекта с гео-объектом в БД
|
||||
*
|
||||
* @param $oTarget
|
||||
* @return ModuleGeo_EntityTarget | bool
|
||||
*/
|
||||
public function AddTarget($oTarget) {
|
||||
if ($this->oMapper->AddTarget($oTarget)) {
|
||||
return $oTarget;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Создание связи
|
||||
*
|
||||
* @param $oGeoObject
|
||||
* @param $sTargetType
|
||||
* @param $iTargetId
|
||||
* @return bool|ModuleGeo_EntityTarget
|
||||
*/
|
||||
public function CreateTarget($oGeoObject,$sTargetType,$iTargetId) {
|
||||
/**
|
||||
* Проверяем объект на валидность
|
||||
*/
|
||||
if (!$this->CheckTarget($sTargetType,$iTargetId)) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Проверяем есть ли уже у этого объекта другие связи
|
||||
*/
|
||||
$aTargets=$this->GetTargets(array('target_type'=>$sTargetType,'target_id'=>$iTargetId),1,1);
|
||||
if ($aTargets['count']) {
|
||||
if ($this->IsAllowTargetMulti($sTargetType)) {
|
||||
/**
|
||||
* Разрешено несколько связей
|
||||
* Проверяем есть ли уже связь с данным гео-объектом, если есть то возвращаем его
|
||||
*/
|
||||
$aTargetSelf=$this->GetTargets(array('target_type'=>$sTargetType,'target_id'=>$iTargetId,'geo_type'=>$oGeoObject->getType(),'geo_id'=>$oGeoObject->getId()),1,1);
|
||||
if (isset($aTargetSelf['collection'][0])) {
|
||||
return $aTargetSelf['collection'][0];
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Есть другие связи и несколько связей запрещено - удаляем имеющиеся связи
|
||||
*/
|
||||
$this->DeleteTargets(array('target_type'=>$sTargetType,'target_id'=>$iTargetId));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Создаем связь
|
||||
*/
|
||||
$oTarget=Engine::GetEntity('ModuleGeo_EntityTarget');
|
||||
$oTarget->setGeoType($oGeoObject->getType());
|
||||
$oTarget->setGeoId($oGeoObject->getId());
|
||||
$oTarget->setTargetType($sTargetType);
|
||||
$oTarget->setTargetId($iTargetId);
|
||||
if ($oGeoObject->getType()=='city') {
|
||||
$oTarget->setCountryId($oGeoObject->getCountryId());
|
||||
$oTarget->setRegionId($oGeoObject->getRegionId());
|
||||
$oTarget->setCityId($oGeoObject->getId());
|
||||
} elseif ($oGeoObject->getType()=='region') {
|
||||
$oTarget->setCountryId($oGeoObject->getCountryId());
|
||||
$oTarget->setRegionId($oGeoObject->getId());
|
||||
} elseif ($oGeoObject->getType()=='country') {
|
||||
$oTarget->setCountryId($oGeoObject->getId());
|
||||
}
|
||||
return $this->AddTarget($oTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает список связей по фильтру
|
||||
*
|
||||
* @param $aFilter
|
||||
* @param $iCurrPage
|
||||
* @param $iPerPage
|
||||
* @return array
|
||||
*/
|
||||
public function GetTargets($aFilter,$iCurrPage,$iPerPage) {
|
||||
return array('collection'=>$this->oMapper->GetTargets($aFilter,$iCount,$iCurrPage,$iPerPage),'count'=>$iCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает первый объект связи по объекту
|
||||
*
|
||||
* @param $sTargetType
|
||||
* @param $iTargetId
|
||||
* @return null
|
||||
*/
|
||||
public function GetTargetByTarget($sTargetType,$iTargetId) {
|
||||
$aTargets=$this->GetTargets(array('target_type'=>$sTargetType,'target_id'=>$iTargetId),1,1);
|
||||
if (isset($aTargets['collection'][0])) {
|
||||
return $aTargets['collection'][0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Удаляет связи по фильтру
|
||||
*
|
||||
* @param $aFilter
|
||||
* @return mixed
|
||||
*/
|
||||
public function DeleteTargets($aFilter) {
|
||||
return $this->oMapper->DeleteTargets($aFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Удаление всех связей объекта
|
||||
*
|
||||
* @param $sTargetType
|
||||
* @param $iTargetId
|
||||
* @return mixed
|
||||
*/
|
||||
public function DeleteTargetsByTarget($sTargetType,$iTargetId) {
|
||||
return $this->DeleteTargets(array('target_type'=>$sTargetType,'target_id'=>$iTargetId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает список стран по фильтру
|
||||
*
|
||||
* @param $aFilter
|
||||
* @param $aOrder
|
||||
* @param $iCurrPage
|
||||
* @param $iPerPage
|
||||
* @return array
|
||||
*/
|
||||
public function GetCountries($aFilter,$aOrder,$iCurrPage,$iPerPage) {
|
||||
return array('collection'=>$this->oMapper->GetCountries($aFilter,$aOrder,$iCount,$iCurrPage,$iPerPage),'count'=>$iCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает список регионов по фильтру
|
||||
*
|
||||
* @param $aFilter
|
||||
* @param $aOrder
|
||||
* @param $iCurrPage
|
||||
* @param $iPerPage
|
||||
* @return array
|
||||
*/
|
||||
public function GetRegions($aFilter,$aOrder,$iCurrPage,$iPerPage) {
|
||||
return array('collection'=>$this->oMapper->GetRegions($aFilter,$aOrder,$iCount,$iCurrPage,$iPerPage),'count'=>$iCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает список городов по фильтру
|
||||
*
|
||||
* @param $aFilter
|
||||
* @param $aOrder
|
||||
* @param $iCurrPage
|
||||
* @param $iPerPage
|
||||
* @return array
|
||||
*/
|
||||
public function GetCities($aFilter,$aOrder,$iCurrPage,$iPerPage) {
|
||||
return array('collection'=>$this->oMapper->GetCities($aFilter,$aOrder,$iCount,$iCurrPage,$iPerPage),'count'=>$iCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает страну по ID
|
||||
*
|
||||
* @param $iId
|
||||
* @return ModuleGeo_EntityCountry
|
||||
*/
|
||||
public function GetCountryById($iId) {
|
||||
$aRes=$this->GetCountries(array('id'=>$iId),array(),1,1);
|
||||
if (isset($aRes['collection'][0])) {
|
||||
return $aRes['collection'][0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает регион по ID
|
||||
*
|
||||
* @param $iId
|
||||
* @return ModuleGeo_EntityRegion
|
||||
*/
|
||||
public function GetRegionById($iId) {
|
||||
$aRes=$this->GetRegions(array('id'=>$iId),array(),1,1);
|
||||
if (isset($aRes['collection'][0])) {
|
||||
return $aRes['collection'][0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает регион по ID
|
||||
*
|
||||
* @param $iId
|
||||
* @return ModuleGeo_EntityCity
|
||||
*/
|
||||
public function GetCityById($iId) {
|
||||
$aRes=$this->GetCities(array('id'=>$iId),array(),1,1);
|
||||
if (isset($aRes['collection'][0])) {
|
||||
return $aRes['collection'][0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает гео-объект
|
||||
*
|
||||
* @param $sType
|
||||
* @param $iId
|
||||
*/
|
||||
public function GetGeoObject($sType,$iId) {
|
||||
$sType=strtolower($sType);
|
||||
if (!$this->IsAllowGeoType($sType)) {
|
||||
return null;
|
||||
}
|
||||
switch($sType) {
|
||||
case 'country':
|
||||
return $this->GetCountryById($iId);
|
||||
break;
|
||||
case 'region':
|
||||
return $this->GetRegionById($iId);
|
||||
break;
|
||||
case 'city':
|
||||
return $this->GetCityById($iId);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает первый гео-объект для объекта
|
||||
*
|
||||
* @param $sTargetType
|
||||
* @param $iTargetId
|
||||
* @return ModuleGeo_EntityCity|ModuleGeo_EntityCountry|ModuleGeo_EntityRegion|null
|
||||
*/
|
||||
public function GetGeoObjectByTarget($sTargetType,$iTargetId) {
|
||||
$aTargets=$this->GetTargets(array('target_type'=>$sTargetType,'target_id'=>$iTargetId),1,1);
|
||||
if (isset($aTargets['collection'][0])) {
|
||||
$oTarget=$aTargets['collection'][0];
|
||||
return $this->GetGeoObject($oTarget->getGeoType(),$oTarget->getGeoId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Проверка объекта с типом "user"
|
||||
* Название метода формируется автоматически
|
||||
*
|
||||
* @param int $iTargetId
|
||||
*/
|
||||
public function CheckTargetUser($iTargetId) {
|
||||
if ($oUser=$this->User_GetUserById($iTargetId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
21
classes/modules/geo/entity/City.entity.class.php
Normal file
21
classes/modules/geo/entity/City.entity.class.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
class ModuleGeo_EntityCity extends ModuleGeo_EntityGeo {
|
||||
|
||||
}
|
||||
?>
|
21
classes/modules/geo/entity/Country.entity.class.php
Normal file
21
classes/modules/geo/entity/Country.entity.class.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
class ModuleGeo_EntityCountry extends ModuleGeo_EntityGeo {
|
||||
|
||||
}
|
||||
?>
|
117
classes/modules/geo/entity/Geo.entity.class.php
Normal file
117
classes/modules/geo/entity/Geo.entity.class.php
Normal file
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
class ModuleGeo_EntityGeo extends Entity {
|
||||
|
||||
/**
|
||||
* Возвращает имя гео-объекта в зависимости от языка
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
$sName='';
|
||||
$sLangDef=Config::get('lang.default');
|
||||
if ($sLangDef=='russian') {
|
||||
$sName=$this->getNameRu();
|
||||
} elseif ($sLangDef=='english') {
|
||||
$sName=$this->getNameEn();
|
||||
}
|
||||
|
||||
$sLang=Config::get('lang.current');
|
||||
if ($sLang=='russian' and $this->getNameRu()) {
|
||||
$sName=$this->getNameRu();
|
||||
} elseif ($sLang=='english' and $this->getNameEn()) {
|
||||
$sName=$this->getNameEn();
|
||||
}
|
||||
return $sName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает тип гео-объекта
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getType() {
|
||||
if ($this instanceof ModuleGeo_EntityCity) {
|
||||
return 'city';
|
||||
} elseif ($this instanceof ModuleGeo_EntityRegion) {
|
||||
return 'region';
|
||||
} elseif ($this instanceof ModuleGeo_EntityCountry) {
|
||||
return 'country';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает гео-объект страны
|
||||
*
|
||||
* @return ModuleGeo_EntityGeo|null
|
||||
*/
|
||||
public function getCountry() {
|
||||
if ($this->getType()=='country') {
|
||||
return $this;
|
||||
}
|
||||
if ($oCountry=$this->_getDataOne('country')) {
|
||||
return $oCountry;
|
||||
}
|
||||
if ($this->getCountryId()) {
|
||||
$oCountry=$this->Geo_GetCountryById($this->getCountryId());
|
||||
return $this->_aData['country']=$oCountry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает гео-объект региона
|
||||
*
|
||||
* @return ModuleGeo_EntityGeo|null
|
||||
*/
|
||||
public function getRegion() {
|
||||
if ($this->getType()=='region') {
|
||||
return $this;
|
||||
}
|
||||
if ($oRegion=$this->_getDataOne('region')) {
|
||||
return $oRegion;
|
||||
}
|
||||
if ($this->getRegionId()) {
|
||||
$oRegion=$this->Geo_GetRegionById($this->getRegionId());
|
||||
return $this->_aData['region']=$oRegion;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает гео-объект города
|
||||
*
|
||||
* @return ModuleGeo_EntityGeo|null
|
||||
*/
|
||||
public function getCity() {
|
||||
if ($this->getType()=='city') {
|
||||
return $this;
|
||||
}
|
||||
if ($oCity=$this->_getDataOne('city')) {
|
||||
return $oCity;
|
||||
}
|
||||
if ($this->getCityId()) {
|
||||
$oCity=$this->Geo_GetCityById($this->getCityId());
|
||||
return $this->_aData['city']=$oCity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
21
classes/modules/geo/entity/Region.entity.class.php
Normal file
21
classes/modules/geo/entity/Region.entity.class.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
class ModuleGeo_EntityRegion extends ModuleGeo_EntityGeo {
|
||||
|
||||
}
|
||||
?>
|
21
classes/modules/geo/entity/Target.entity.class.php
Normal file
21
classes/modules/geo/entity/Target.entity.class.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
class ModuleGeo_EntityTarget extends Entity {
|
||||
|
||||
}
|
||||
?>
|
248
classes/modules/geo/mapper/Geo.mapper.class.php
Normal file
248
classes/modules/geo/mapper/Geo.mapper.class.php
Normal file
|
@ -0,0 +1,248 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
class ModuleGeo_MapperGeo extends Mapper {
|
||||
|
||||
public function AddTarget($oTarget) {
|
||||
$sql = "INSERT INTO ".Config::Get('db.table.geo_target')." SET ?a ";
|
||||
if ($this->oDb->query($sql,$oTarget->_getData())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function GetTargets($aFilter,&$iCount,$iCurrPage,$iPerPage) {
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
".Config::Get('db.table.geo_target')."
|
||||
WHERE
|
||||
1 = 1
|
||||
{ AND geo_type = ? }
|
||||
{ AND geo_id = ?d }
|
||||
{ AND target_type = ? }
|
||||
{ AND target_id = ?d }
|
||||
{ AND country_id = ?d }
|
||||
{ AND region_id = ?d }
|
||||
{ AND city_id = ?d }
|
||||
LIMIT ?d, ?d ;
|
||||
";
|
||||
$aResult=array();
|
||||
if ($aRows=$this->oDb->selectPage($iCount,$sql,
|
||||
isset($aFilter['geo_type']) ? $aFilter['geo_type'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['geo_id']) ? $aFilter['geo_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['target_type']) ? $aFilter['target_type'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['target_id']) ? $aFilter['target_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['country_id']) ? $aFilter['country_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['region_id']) ? $aFilter['region_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['city_id']) ? $aFilter['city_id'] : DBSIMPLE_SKIP,
|
||||
|
||||
($iCurrPage-1)*$iPerPage, $iPerPage
|
||||
)) {
|
||||
foreach ($aRows as $aRow) {
|
||||
$aResult[]=Engine::GetEntity('ModuleGeo_EntityTarget',$aRow);
|
||||
}
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
public function DeleteTargets($aFilter) {
|
||||
if (!$aFilter) {
|
||||
return false;
|
||||
}
|
||||
$sql = "DELETE
|
||||
FROM
|
||||
".Config::Get('db.table.geo_target')."
|
||||
WHERE
|
||||
1 = 1
|
||||
{ AND geo_type = ? }
|
||||
{ AND geo_id = ?d }
|
||||
{ AND target_type = ? }
|
||||
{ AND target_id = ?d }
|
||||
{ AND country_id = ?d }
|
||||
{ AND region_id = ?d }
|
||||
{ AND city_id = ?d }
|
||||
";
|
||||
return $this->oDb->query($sql,
|
||||
isset($aFilter['geo_type']) ? $aFilter['geo_type'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['geo_id']) ? $aFilter['geo_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['target_type']) ? $aFilter['target_type'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['target_id']) ? $aFilter['target_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['country_id']) ? $aFilter['country_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['region_id']) ? $aFilter['region_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['city_id']) ? $aFilter['city_id'] : DBSIMPLE_SKIP
|
||||
);
|
||||
}
|
||||
|
||||
public function GetCountries($aFilter,$aOrder,&$iCount,$iCurrPage,$iPerPage) {
|
||||
$aOrderAllow=array('id','name_ru','name_en','sort');
|
||||
$sOrder='';
|
||||
foreach ($aOrder as $key=>$value) {
|
||||
if (!in_array($key,$aOrderAllow)) {
|
||||
unset($aOrder[$key]);
|
||||
} elseif (in_array($value,array('asc','desc'))) {
|
||||
$sOrder.=" {$key} {$value},";
|
||||
}
|
||||
}
|
||||
$sOrder=trim($sOrder,',');
|
||||
if ($sOrder=='') {
|
||||
$sOrder=' id desc ';
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
".Config::Get('db.table.geo_country')."
|
||||
WHERE
|
||||
1 = 1
|
||||
{ AND id = ?d }
|
||||
{ AND name_ru = ? }
|
||||
{ AND name_ru LIKE ? }
|
||||
{ AND name_en = ? }
|
||||
{ AND name_en LIKE ? }
|
||||
{ AND code = ? }
|
||||
|
||||
ORDER by {$sOrder}
|
||||
LIMIT ?d, ?d ;
|
||||
";
|
||||
$aResult=array();
|
||||
if ($aRows=$this->oDb->selectPage($iCount,$sql,
|
||||
isset($aFilter['id']) ? $aFilter['id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_ru']) ? $aFilter['name_ru'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_ru_like']) ? $aFilter['name_ru_like'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_en']) ? $aFilter['name_en'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_en_like']) ? $aFilter['name_en_like'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['code']) ? $aFilter['code'] : DBSIMPLE_SKIP,
|
||||
($iCurrPage-1)*$iPerPage, $iPerPage
|
||||
)) {
|
||||
foreach ($aRows as $aRow) {
|
||||
$aResult[]=Engine::GetEntity('ModuleGeo_EntityCountry',$aRow);
|
||||
}
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
public function GetRegions($aFilter,$aOrder,&$iCount,$iCurrPage,$iPerPage) {
|
||||
$aOrderAllow=array('id','name_ru','name_en','sort','country_id');
|
||||
$sOrder='';
|
||||
foreach ($aOrder as $key=>$value) {
|
||||
if (!in_array($key,$aOrderAllow)) {
|
||||
unset($aOrder[$key]);
|
||||
} elseif (in_array($value,array('asc','desc'))) {
|
||||
$sOrder.=" {$key} {$value},";
|
||||
}
|
||||
}
|
||||
$sOrder=trim($sOrder,',');
|
||||
if ($sOrder=='') {
|
||||
$sOrder=' id desc ';
|
||||
}
|
||||
|
||||
if (isset($aFilter['country_id']) and !is_array($aFilter['country_id'])) {
|
||||
$aFilter['country_id']=array($aFilter['country_id']);
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
".Config::Get('db.table.geo_region')."
|
||||
WHERE
|
||||
1 = 1
|
||||
{ AND id = ?d }
|
||||
{ AND name_ru = ? }
|
||||
{ AND name_ru LIKE ? }
|
||||
{ AND name_en = ? }
|
||||
{ AND name_en LIKE ? }
|
||||
{ AND country_id IN ( ?a ) }
|
||||
|
||||
ORDER by {$sOrder}
|
||||
LIMIT ?d, ?d ;
|
||||
";
|
||||
$aResult=array();
|
||||
if ($aRows=$this->oDb->selectPage($iCount,$sql,
|
||||
isset($aFilter['id']) ? $aFilter['id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_ru']) ? $aFilter['name_ru'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_ru_like']) ? $aFilter['name_ru_like'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_en']) ? $aFilter['name_en'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_en_like']) ? $aFilter['name_en_like'] : DBSIMPLE_SKIP,
|
||||
(isset($aFilter['country_id']) && count($aFilter['country_id'])) ? $aFilter['country_id'] : DBSIMPLE_SKIP,
|
||||
($iCurrPage-1)*$iPerPage, $iPerPage
|
||||
)) {
|
||||
foreach ($aRows as $aRow) {
|
||||
$aResult[]=Engine::GetEntity('ModuleGeo_EntityRegion',$aRow);
|
||||
}
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
public function GetCities($aFilter,$aOrder,&$iCount,$iCurrPage,$iPerPage) {
|
||||
$aOrderAllow=array('id','name_ru','name_en','sort','country_id','region_id');
|
||||
$sOrder='';
|
||||
foreach ($aOrder as $key=>$value) {
|
||||
if (!in_array($key,$aOrderAllow)) {
|
||||
unset($aOrder[$key]);
|
||||
} elseif (in_array($value,array('asc','desc'))) {
|
||||
$sOrder.=" {$key} {$value},";
|
||||
}
|
||||
}
|
||||
$sOrder=trim($sOrder,',');
|
||||
if ($sOrder=='') {
|
||||
$sOrder=' id desc ';
|
||||
}
|
||||
|
||||
if (isset($aFilter['country_id']) and !is_array($aFilter['country_id'])) {
|
||||
$aFilter['country_id']=array($aFilter['country_id']);
|
||||
}
|
||||
if (isset($aFilter['region_id']) and !is_array($aFilter['region_id'])) {
|
||||
$aFilter['region_id']=array($aFilter['region_id']);
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
".Config::Get('db.table.geo_city')."
|
||||
WHERE
|
||||
1 = 1
|
||||
{ AND id = ?d }
|
||||
{ AND name_ru = ? }
|
||||
{ AND name_ru LIKE ? }
|
||||
{ AND name_en = ? }
|
||||
{ AND name_en LIKE ? }
|
||||
{ AND country_id IN ( ?a ) }
|
||||
{ AND region_id IN ( ?a ) }
|
||||
|
||||
ORDER by {$sOrder}
|
||||
LIMIT ?d, ?d ;
|
||||
";
|
||||
$aResult=array();
|
||||
if ($aRows=$this->oDb->selectPage($iCount,$sql,
|
||||
isset($aFilter['id']) ? $aFilter['id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_ru']) ? $aFilter['name_ru'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_ru_like']) ? $aFilter['name_ru_like'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_en']) ? $aFilter['name_en'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['name_en_like']) ? $aFilter['name_en_like'] : DBSIMPLE_SKIP,
|
||||
(isset($aFilter['country_id']) && count($aFilter['country_id'])) ? $aFilter['country_id'] : DBSIMPLE_SKIP,
|
||||
(isset($aFilter['region_id']) && count($aFilter['region_id'])) ? $aFilter['region_id'] : DBSIMPLE_SKIP,
|
||||
($iCurrPage-1)*$iPerPage, $iPerPage
|
||||
)) {
|
||||
foreach ($aRows as $aRow) {
|
||||
$aResult[]=Engine::GetEntity('ModuleGeo_EntityCity',$aRow);
|
||||
}
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -335,6 +335,10 @@ $config['db']['table']['topic_photo'] = '___db.table.prefix___topic_phot
|
|||
$config['db']['table']['subscribe'] = '___db.table.prefix___subscribe';
|
||||
$config['db']['table']['wall'] = '___db.table.prefix___wall';
|
||||
$config['db']['table']['user_note'] = '___db.table.prefix___user_note';
|
||||
$config['db']['table']['geo_country'] = '___db.table.prefix___geo_country';
|
||||
$config['db']['table']['geo_region'] = '___db.table.prefix___geo_region';
|
||||
$config['db']['table']['geo_city'] = '___db.table.prefix___geo_city';
|
||||
$config['db']['table']['geo_target'] = '___db.table.prefix___geo_target';
|
||||
|
||||
$config['db']['tables']['engine'] = 'InnoDB'; // InnoDB или MyISAM
|
||||
/**
|
||||
|
@ -511,6 +515,7 @@ $config['head']['default']['js'] = array(
|
|||
"___path.root.engine_lib___/internal/template/js/vote.js",
|
||||
"___path.root.engine_lib___/internal/template/js/poll.js",
|
||||
"___path.root.engine_lib___/internal/template/js/subscribe.js",
|
||||
"___path.root.engine_lib___/internal/template/js/geo.js",
|
||||
"___path.root.engine_lib___/internal/template/js/wall.js",
|
||||
"___path.root.engine_lib___/internal/template/js/usernote.js",
|
||||
"___path.root.engine_lib___/internal/template/js/comments.js",
|
||||
|
|
80
engine/lib/internal/template/js/geo.js
Normal file
80
engine/lib/internal/template/js/geo.js
Normal file
|
@ -0,0 +1,80 @@
|
|||
var ls = ls || {};
|
||||
|
||||
/**
|
||||
* Гео-объекты
|
||||
*/
|
||||
ls.geo = (function ($) {
|
||||
|
||||
/**
|
||||
* Инициализация селектов выбора гео-объекта
|
||||
*/
|
||||
this.initSelect = function() {
|
||||
$.each($('.js-geo-select'),function(k,v){
|
||||
$(v).find('.js-geo-country').bind('change',function(e){
|
||||
this.loadRegions($(e.target));
|
||||
}.bind(this));
|
||||
$(v).find('.js-geo-region').bind('change',function(e){
|
||||
this.loadCities($(e.target));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
this.loadRegions = function($country) {
|
||||
$region=$country.parents('.js-geo-select').find('.js-geo-region');
|
||||
$city=$country.parents('.js-geo-select').find('.js-geo-city');
|
||||
$region.empty();
|
||||
$region.append('<option value="">'+ls.lang.get('geo_select_region')+'</option>');
|
||||
$city.empty();
|
||||
$city.hide();
|
||||
|
||||
if (!$country.val()) {
|
||||
$region.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
var url = aRouter['ajax']+'geo/get/regions/';
|
||||
var params = {country: $country.val()};
|
||||
'*loadRegionsBefore*'; '*/loadRegionsBefore*';
|
||||
ls.ajax(url, params, function(result) {
|
||||
if (result.bStateError) {
|
||||
ls.msg.error(null, result.sMsg);
|
||||
} else {
|
||||
$.each(result.aRegions,function(k,v){
|
||||
$region.append('<option value="'+v.id+'">'+v.name+'</option>');
|
||||
});
|
||||
$region.show();
|
||||
ls.hook.run('ls_geo_load_regions_after',[$country, result]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.loadCities = function($region) {
|
||||
$city=$region.parents('.js-geo-select').find('.js-geo-city');
|
||||
$city.empty();
|
||||
$city.append('<option value="">'+ls.lang.get('geo_select_city')+'</option>');
|
||||
|
||||
if (!$region.val()) {
|
||||
$city.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
var url = aRouter['ajax']+'geo/get/cities/';
|
||||
var params = {region: $region.val()};
|
||||
'*loadCitiesBefore*'; '*/loadCitiesBefore*';
|
||||
ls.ajax(url, params, function(result) {
|
||||
if (result.bStateError) {
|
||||
ls.msg.error(null, result.sMsg);
|
||||
} else {
|
||||
$.each(result.aCities,function(k,v){
|
||||
$city.append('<option value="'+v.id+'">'+v.name+'</option>');
|
||||
});
|
||||
$city.show();
|
||||
ls.hook.run('ls_geo_load_cities_after',[$region, result]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
return this;
|
||||
}).call(ls.geo || {},jQuery);
|
19563
install/geo_base_for_0.5.2.sql
Normal file
19563
install/geo_base_for_0.5.2.sql
Normal file
File diff suppressed because it is too large
Load diff
|
@ -928,6 +928,12 @@ return array(
|
|||
* Подписка
|
||||
*/
|
||||
'subscribe_change_ok' => 'Change the subscription was successful',
|
||||
/**
|
||||
* География
|
||||
*/
|
||||
'geo_select_country' => 'Select country',
|
||||
'geo_select_region' => 'Select region',
|
||||
'geo_select_city' => 'Select city',
|
||||
/**
|
||||
* System
|
||||
*/
|
||||
|
|
|
@ -928,6 +928,12 @@ return array(
|
|||
* Подписка
|
||||
*/
|
||||
'subscribe_change_ok' => 'Изменение подписки прошло успешно',
|
||||
/**
|
||||
* География
|
||||
*/
|
||||
'geo_select_country' => 'Выберите страну',
|
||||
'geo_select_region' => 'Укажите регион',
|
||||
'geo_select_city' => 'Укажите город',
|
||||
/**
|
||||
* Системные сообщения
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
{include file='header.tpl' menu='settings' noSidebar=true}
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
ls.lang.load({lang_load name="geo_select_city,geo_select_region"});
|
||||
ls.geo.initSelect();
|
||||
});
|
||||
</script>
|
||||
|
||||
<p id="profile_user_field_template" style="display:none;" class="js-user-field-item">
|
||||
<select name="profile_user_field_type[]">
|
||||
{foreach from=$aUserFieldsContact item=oFieldAll}
|
||||
|
@ -64,15 +71,42 @@
|
|||
</select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="profile_country">{$aLang.settings_profile_country}:</label>
|
||||
<input type="text" id="profile_country" name="profile_country" class="input-text input-width-200 autocomplete-country" value="{$oUserCurrent->getProfileCountry()|escape:'html'}" />
|
||||
<p>
|
||||
|
||||
</p>
|
||||
<label for="profile_city">{$aLang.settings_profile_city}:</label>
|
||||
<input type="text" id="profile_city" name="profile_city" class="input-text input-width-200 autocomplete-city" value="{$oUserCurrent->getProfileCity()|escape:'html'}" />
|
||||
</p>
|
||||
<div class="js-geo-select">
|
||||
|
||||
<p>
|
||||
<select class="js-geo-country" name="geo_country">
|
||||
<option value="">{$aLang.geo_select_country}</option>
|
||||
{if $aGeoCountries}
|
||||
{foreach from=$aGeoCountries item=oGeoCountry}
|
||||
<option value="{$oGeoCountry->getId()}" {if $oGeoTarget and $oGeoTarget->getCountryId()==$oGeoCountry->getId()}selected="selected"{/if}>{$oGeoCountry->getName()}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<select class="js-geo-region" name="geo_region" {if !$oGeoTarget or !$oGeoTarget->getCountryId()}style="display:none;"{/if}>
|
||||
<option value="">{$aLang.geo_select_region}</option>
|
||||
{if $aGeoRegions}
|
||||
{foreach from=$aGeoRegions item=oGeoRegion}
|
||||
<option value="{$oGeoRegion->getId()}" {if $oGeoTarget and $oGeoTarget->getRegionId()==$oGeoRegion->getId()}selected="selected"{/if}>{$oGeoRegion->getName()}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<select class="js-geo-city" name="geo_city" {if !$oGeoTarget or !$oGeoTarget->getRegionId()}style="display:none;"{/if}>
|
||||
<option value="">{$aLang.geo_select_city}</option>
|
||||
{if $aGeoCities}
|
||||
{foreach from=$aGeoCities item=oGeoCity}
|
||||
<option value="{$oGeoCity->getId()}" {if $oGeoTarget and $oGeoTarget->getCityId()==$oGeoCity->getId()}selected="selected"{/if}>{$oGeoCity->getName()}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<label for="profile_about">{$aLang.settings_profile_about}:</label>
|
||||
|
|
Loading…
Reference in a new issue