Advertisement
Sdelkadrom

Untitled

Feb 1st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. public static function getLocationString(Apartment $model, $sep = ', ', $withAddress = false)
  2. {
  3. $locationArray = array();
  4.  
  5. if (issetModule('location')) {
  6. if ($model->locCountry) {
  7. $locationArray[] = $model->locCountry->getStrByLang('name');
  8. }
  9. if ($model->locRegion) {
  10. if ($model->locCountry)
  11. $locationArray[] = $model->locRegion->getStrByLang('name');
  12. }
  13. if ($model->locCity) {
  14. $cityName = $model->locCity->getStrByLang('name');
  15. $regionName = ($model->locRegion) ? $model->locRegion->getStrByLang('name') : '';
  16.  
  17. if (($model->locCountry || $model->locRegion) && ($cityName != $regionName)) {
  18. $locationArray[] = $cityName;
  19. }
  20. }
  21. } else {
  22. if (isset($model->city) && isset($model->city->name)) {
  23. $locationArray[] = $model->city->name;
  24. }
  25. }
  26.  
  27. if ($withAddress && $model->canShowInView('address')) {
  28. $locationArray[] = $model->getStrByLang("address");
  29. }
  30.  
  31. return implode($sep, $locationArray);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement