/
Common.php
184 lines (157 loc) · 3.89 KB
/
Common.php
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
/**
*
* @author Pavel Stepanets <pahhan.ne@gmail.com>
*/
class Domstor_List_Common extends HtmlTable
{
protected $in_region;
protected $object;
protected $action;
protected $pagination;
protected $object_href;
protected $id_placeholder;
protected $filter;
protected $_show_filter = false;
protected $empty_list_message = 'Список пуст';
protected $city_id;
/**
*
* @var SP_Helper_Pager
*/
protected $pager;
public function cityId($val = null)
{
if (is_null($val)) {
return $this->city_id;
}
$this->city_id = $val;
return $this;
}
public function getObjectHref()
{
return $this->object_href;
}
public function getIdPlaceholder($param)
{
return $this->id_placeholder;
}
public function inRegion($val)
{
$this->in_region = (bool) $val;
}
public function isInRegion()
{
return $this->in_region;
}
public function getServerName()
{
return $this->server_name;
}
public function setPagination($value)
{
$this->pagination = $value;
}
public function getPagination()
{
return $this->pagination;
}
public function setPager(SP_Helper_Pager $pager)
{
$this->pager = $pager;
}
/**
*
* @return SP_Helper_Pager
*/
public function getPager()
{
return $this->pager;
}
public function setFilter($value)
{
$this->filter = $value;
}
/**
*
* @return Domstor_Filter_Form
*/
public function getFilter()
{
return $this->filter;
}
public function showFilter($val)
{
$this->_show_filter = (bool) $val;
return $this;
}
public function getEmptyListMessage()
{
return $this->empty_list_message;
}
public function display()
{
echo $this->getHtml();
}
public function getHtml()
{
$out = '';
if ($this->_show_filter) {
$out.= (string) $this->getFilter();
}
if (count($this->data)) {
$out.= parent::getHtml();
$out.= $this->pager->render();
} else {
$out.= $this->empty_list_message;
}
return $out;
}
public function render()
{
return parent::getHtml();
}
public function __construct($attr)
{
parent::__construct($attr);
$this->css_class = 'domstor_table';
if ($this->in_region) {
$this->addCssClass('region');
}
$code_field = new Domstor_List_Field_Code(array(
'name' => 'code',
'title' => 'Код',
'css_class' => 'domstor_code',
'position' => 0,
'object_href' => $this->object_href,
'id_placeholder' => $this->id_placeholder,
'sort_name' => 'sort-code',
));
$type_field = new HtmlTableField(array(
'name' => 'type',
'title' => 'Тип',
'css_class' => 'domstor_type',
'position' => 100,
'sort_name' => 'sort-type',
));
$contact_field = new Domstor_List_Field_Contact(array(
'name' => 'contact_phone',
'title' => 'Контактный телефон',
'css_class' => 'domstor_contact',
'position' => 'last',
'position' => 300,
));
$note_web_field = new Domstor_List_Field_Comment(array(
'name' => 'note_web',
'title' => 'Комментарий',
'css_class' => 'domstor_note_web',
'position' => 'last',
'position' => 400,
));
$this->addField($code_field)
->addField($type_field)
->addField($contact_field)
->addField($note_web_field)
;
}
}