1 | <?php |
||
16 | class RangeField extends FormField |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * @var array|int |
||
21 | */ |
||
22 | protected $start = [0]; |
||
23 | |||
24 | /** |
||
25 | * @var int |
||
26 | */ |
||
27 | protected $min = 0; |
||
28 | |||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | protected $max = 100; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $range = []; |
||
38 | |||
39 | /** |
||
40 | * @var bool |
||
41 | */ |
||
42 | protected $snap = false; |
||
43 | |||
44 | /** |
||
45 | * @var array |
||
46 | */ |
||
47 | protected $data = []; |
||
48 | |||
49 | /** |
||
50 | * @var int |
||
51 | */ |
||
52 | protected $density = 4; |
||
53 | |||
54 | /** |
||
55 | * @var bool |
||
56 | */ |
||
57 | protected $showPips = true; |
||
58 | |||
59 | /** |
||
60 | * @var int|bool |
||
61 | */ |
||
62 | protected $step; |
||
63 | |||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $unit = ''; |
||
69 | |||
70 | |||
71 | /** |
||
72 | * @var int |
||
73 | */ |
||
74 | protected $decimalPlaces = 2; |
||
75 | |||
76 | /** |
||
77 | * RangeField constructor. |
||
78 | * @param string $name The internal field name, passed to forms. |
||
79 | * @param null|string $title The human-readable field label. |
||
80 | * @param int|array $start Starting point(s) on the line |
||
81 | * @param mixed $value The value of the field. |
||
82 | * @param int|array $min Lowest value of the range |
||
83 | * @param int $max Highest value of the range |
||
84 | * @param array $range Associative array with keys which determine the percentage point on the range |
||
85 | * And values being the labels on the field |
||
86 | */ |
||
87 | public function __construct($name, $title = null, $start = 0, $min = 0, $max = 100, $range = [], $value = null) |
||
102 | |||
103 | /** |
||
104 | * @param array $properties |
||
105 | * @return \SilverStripe\ORM\FieldType\DBHTMLText |
||
106 | */ |
||
107 | public function field($properties = array()) |
||
124 | |||
125 | /** |
||
126 | * @param string unit |
||
127 | * @param int $decimalPlaces |
||
128 | */ |
||
129 | public function setFormat($unit, $decimalPlaces) |
||
134 | |||
135 | |||
136 | protected function setupData() |
||
169 | |||
170 | /** |
||
171 | * @return array|int |
||
172 | */ |
||
173 | public function getStart() |
||
177 | |||
178 | /** |
||
179 | * @param array|int $start |
||
180 | */ |
||
181 | public function setStart($start) |
||
185 | |||
186 | /** |
||
187 | * @return array |
||
188 | */ |
||
189 | public function getMin() |
||
193 | |||
194 | /** |
||
195 | * @param int $min |
||
196 | */ |
||
197 | public function setMin($min) |
||
201 | |||
202 | /** |
||
203 | * @return int |
||
204 | */ |
||
205 | public function getMax() |
||
209 | |||
210 | /** |
||
211 | * @param int $max |
||
212 | */ |
||
213 | public function setMax($max) |
||
217 | |||
218 | /** |
||
219 | * @return array |
||
220 | */ |
||
221 | public function getRange() |
||
225 | |||
226 | /** |
||
227 | * @param array $range |
||
228 | */ |
||
229 | public function setRange($range) |
||
233 | |||
234 | /** |
||
235 | * @return bool |
||
236 | */ |
||
237 | public function isSnap() |
||
241 | |||
242 | /** |
||
243 | * @param bool $snap |
||
244 | */ |
||
245 | public function setSnap($snap) |
||
249 | |||
250 | /** |
||
251 | * @return array |
||
252 | */ |
||
253 | public function getData() |
||
257 | |||
258 | /** |
||
259 | * @param array $data |
||
260 | */ |
||
261 | public function setData($data) |
||
265 | |||
266 | /** |
||
267 | * @return int |
||
268 | */ |
||
269 | public function getDensity() |
||
273 | |||
274 | /** |
||
275 | * @param int $density |
||
276 | */ |
||
277 | public function setDensity($density) |
||
281 | |||
282 | /** |
||
283 | * @return bool |
||
284 | */ |
||
285 | public function isShowPips() |
||
289 | |||
290 | /** |
||
291 | * @param bool $showPips |
||
292 | */ |
||
293 | public function setShowPips($showPips) |
||
297 | |||
298 | /** |
||
299 | * @return bool|int |
||
300 | */ |
||
301 | public function getStep() |
||
305 | |||
306 | /** |
||
307 | * @param bool|int $step |
||
308 | */ |
||
309 | public function setStep($step) |
||
313 | |||
314 | /** |
||
315 | * @return string |
||
316 | */ |
||
317 | public function getUnit() |
||
321 | |||
322 | /** |
||
323 | * @param string $unit |
||
324 | */ |
||
325 | public function setUnit($unit) |
||
329 | |||
330 | /** |
||
331 | * @return int |
||
332 | */ |
||
333 | public function getDecimalPlaces() |
||
337 | |||
338 | /** |
||
339 | * @param int $decimalPlaces |
||
340 | */ |
||
341 | public function setDecimalPlaces($decimalPlaces) |
||
345 | } |
||
346 |