1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-30 21:45:01 +03:00
ifhub.club/application/classes/modules/geo/entity/Geo.entity.class.php
2014-10-08 15:49:34 +07:00

131 lines
3.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/*
* LiveStreet CMS
* Copyright © 2013 OOO "ЛС-СОФТ"
*
* ------------------------------------------------------
*
* Official site: www.livestreetcms.com
* Contact e-mail: office@livestreetcms.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* ------------------------------------------------------
*
* @link http://www.livestreetcms.com
* @copyright 2013 OOO "ЛС-СОФТ"
* @author Maxim Mzhelskiy <rus.engine@gmail.com>
*
*/
/**
* Объект сущности гео-объекта
*
* @package application.modules.geo
* @since 1.0
*/
class ModuleGeo_EntityGeo extends Entity
{
/**
* Возвращает имя гео-объекта в зависимости от языка
*
* @return string
*/
public function getName()
{
$sName = '';
$sLangDef = Config::get('lang.default');
if ($sLangDef == 'ru') {
$sName = $this->getNameRu();
} elseif ($sLangDef == 'en') {
$sName = $this->getNameEn();
}
$sLang = Config::get('lang.current');
if ($sLang == 'ru' and $this->getNameRu()) {
$sName = $this->getNameRu();
} elseif ($sLang == 'en' 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;
}
}