|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @license MIT |
|
7
|
|
|
* @copyright 2013 - 2016 Cross Solution <http://cross-solution.de> |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** */ |
|
11
|
|
|
namespace Jobs\Form\Element; |
|
12
|
|
|
|
|
13
|
|
|
use Jobs\Entity\Status; |
|
14
|
|
|
use Zend\Form\Element\Select; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* ${CARET} |
|
18
|
|
|
* |
|
19
|
|
|
* @author Mathias Gelhausen <[email protected]> |
|
20
|
|
|
* @todo write test |
|
21
|
|
|
*/ |
|
22
|
|
|
class StatusSelect extends Select |
|
23
|
|
|
{ |
|
24
|
|
|
public function init() |
|
25
|
|
|
{ |
|
26
|
|
|
$valueOptions = [ |
|
27
|
|
|
Status::ACTIVE => /*@translate*/ 'Active', |
|
28
|
|
|
Status::INACTIVE => /*@translate*/ 'Inactive', |
|
29
|
|
|
//Status::WAITING_FOR_APPROVAL => /*@translate*/ 'Waiting for approval', |
|
30
|
|
|
Status::CREATED => /*@translate*/ 'Created', |
|
31
|
|
|
Status::PUBLISH => /*@translate*/ 'Published', |
|
32
|
|
|
Status::REJECTED => /*@translate*/ 'Rejected', |
|
33
|
|
|
Status::EXPIRED => /*@translate*/ 'Expired', |
|
34
|
|
|
]; |
|
35
|
|
|
|
|
36
|
|
|
if (true === $this->getOption('include_all_option')) { |
|
37
|
|
|
$valueOptions = array_merge([ |
|
38
|
|
|
'all' => /*@translate*/ 'All', |
|
39
|
|
|
], $valueOptions ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$this->setValueOptions($valueOptions); |
|
43
|
|
|
|
|
44
|
|
|
foreach (['data-searchbox' => -1, 'data-allowclear' => 'false', 'class' => 'form-control'] as $attr => $value) { |
|
45
|
|
|
if (!$this->hasAttribute($attr)) { |
|
46
|
|
|
$this->setAttribute($attr, $value); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
if (null === $this->getName()) { |
|
51
|
|
|
$this->setName('status'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
if (null === $this->getLabel()) { |
|
55
|
|
|
$this->setLabel(/*@translate*/ 'Status'); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
if (null === $this->getOption('description')) { |
|
59
|
|
|
$this->setOption('description', /*@translate*/ 'Select a job status.'); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function setOptions($options) |
|
64
|
|
|
{ |
|
65
|
|
|
parent::setOptions($options); |
|
66
|
|
|
|
|
67
|
|
|
if (null == $this->getLabel()) { |
|
|
|
|
|
|
68
|
|
|
$this->setLabel('Status'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
if (!isset($this->options['description'])) { |
|
72
|
|
|
$this->options['description'] = /*@translate*/ 'Select a job status.'; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
if (null == $this->getName()) { |
|
76
|
|
|
$this->setName('status'); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function getValueOptions() |
|
81
|
|
|
{ |
|
82
|
|
|
$options = parent::getValueOptions(); |
|
83
|
|
|
|
|
84
|
|
|
return true === $this->getOption('include_all_option') |
|
85
|
|
|
? array_merge([ 'all' => /*@translate*/ 'All' ], $options) |
|
86
|
|
|
: $options; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
|
|
90
|
|
|
} |