Project.class.php
4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
namespace SH\Entities;
class Project extends \Cpeople\Classes\Block\Object
{
use \Sh\Traits\FunctionName;
use \Cpeople\Traits\MapConnection;
static $thumbParams = array('width' => 911, 'height' => 566, 'type' => 'put_out');
static $thumbParamsSmall = array('width' => 607, 'height' => 381, 'type' => 'put_out');
function getText()
{
return $this->{'~PREVIEW_TEXT'};
}
function getSquare()
{
return $this->getPropValue('SQUARE');
}
function getFloorCount()
{
return $this->getPropValue('FLOOR_COUNT');
}
function getBedroomCount()
{
return $this->getPropValue('BEDROOM_COUNT');
}
function getPreviewGallery($isSmall = false)
{
$result = array();
$thumbParams = $isSmall ? self::$thumbParamsSmall : self::$thumbParams;
if($this->hasPreviewImage()) {
$result[] = $this->getPreivewImageUrl();
// $result[] = $this->getPreviewImageThumb($thumbParams);
}
if($images = $this->getImages('IMAGES_PROJECT')) {
foreach($images as $image) {
$result[] = $image->getUrl($thumbParams);
// $result[] = $image->getThumbUrl($thumbParams);
}
}
return $result;
}
function getPreviewImage($isSmall = false)
{
if($this->hasPreviewImage()) {
// if($isSmall) {
// return $this->getPreviewImageThumb(self::$thumbParamsSmall);
// } else {
return $this->getPreivewImageUrl();
// }
// $thumbParams = $isSmall ? self::$thumbParamsSmall : self::$thumbParams;
// return $this->getPreviewImageThumb($thumbParams);
}
return false;
}
function getIcon()
{
$sectionXmlId = $this->getPropXMLValue('PROJECT_SECTION');
return '/img/svg/'. ($sectionXmlId == 'house'
? 'house'
: ($sectionXmlId == 'bathhouse' ? 'bath_house' : 'other')) .'.svg';
}
static function getTypeBreadcrumbData()
{
return array(
'house' => array('Дома из клееного бруса', '/projects/doma-iz-kleenogo-brusa/'),
'bathhouse' => array('Бани из клееного бруса', '/projects/bani-iz-kleenogo-brusa/'),
'misc' => array('Малые архитектурные формы и другие постройки', '/projects/raznye-proekty/')
);
}
static function getTypeBreadcrumbNameByCode($code)
{
return false;
$data = self::getTypeBreadcrumbData();
foreach($data as $row) {
if(strpos($row[1], $code) !== false) {
return $row[0];
}
}
}
function getTypeBreadcrumb()
{
$sectionXmlId = $this->getPropXMLValue('PROJECT_SECTION');
$data = self::getTypeBreadcrumbData();
return $data[$sectionXmlId];
}
function getRegion()
{
return $this->getPropValue('REGION');
}
function hasDetail()
{
return (bool) $this->DETAIL_TEXT;
}
function getZoom()
{
return 9;
// $val = $this->hasProp('MAP_ZOOM') ? (int) $this->getPropValue('MAP_ZOOM') : false;
// return $val ? $val : 15;
}
function getImgAlt($photoNumber = false) {
if(empty($this->imgAltBegin)) {
$this->imgAltBegin = 'Проект деревянного дома из клееного бруса ' . strip_tags($this->{'NAME'});
if($val = $this->getSquare()) {
$this->imgAltBegin .= ', площадь ' . $val . ' м2';
}
if($val = $this->getFloorCount()) {
$this->imgAltBegin .= ', ' . num_to_string($val, 'этаж', 'этажа', 'этажей');
}
if($val = $this->getBedroomCount()) {
$this->imgAltBegin .= ', ' . num_to_string($val, 'спальня', 'спальни', 'спален');
}
}
$result = $this->imgAltBegin;
if($photoNumber) $result .= ', фото ' . $photoNumber;
return $result;
}
}