1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Nip\Form\AbstractForm; |
4
|
|
|
|
5
|
|
|
abstract class Nip_Form_Button_Abstract |
6
|
|
|
{ |
7
|
|
|
use \Nip\Form\Traits\HasClassTrait; |
8
|
|
|
use \Nip\Form\Traits\HasAttributesTrait; |
9
|
|
|
|
10
|
|
|
protected $_form; |
11
|
|
|
protected $_attribs; |
12
|
|
|
protected $_uniqueID; |
13
|
|
|
|
14
|
|
|
protected $_type = 'abstract'; |
15
|
|
|
|
16
|
|
|
public function __construct($form) |
17
|
|
|
{ |
18
|
|
|
$this->setForm($form); |
19
|
|
|
$this->init(); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function init() |
23
|
|
|
{ |
24
|
|
|
$this->addClass('btn', 'btn-primary'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function setId($id) |
28
|
|
|
{ |
29
|
|
|
$this->setAttrib('id', $id); |
30
|
|
|
|
31
|
|
|
return $this; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function getId() |
35
|
|
|
{ |
36
|
|
|
return $this->getAttrib('id'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function setName($name) |
40
|
|
|
{ |
41
|
|
|
$this->setAttrib('name', $name); |
42
|
|
|
|
43
|
|
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return string |
48
|
|
|
*/ |
49
|
|
|
public function getName() |
50
|
|
|
{ |
51
|
|
|
return $this->getAttrib('name'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string $label |
56
|
|
|
* @return $this |
57
|
|
|
*/ |
58
|
|
|
public function setLabel($label) |
59
|
|
|
{ |
60
|
|
|
$this->setAttrib('label', $label); |
61
|
|
|
|
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
|
|
public function getLabel() |
69
|
|
|
{ |
70
|
|
|
return $this->getAttrib('label'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param $value |
75
|
|
|
* @return $this |
76
|
|
|
*/ |
77
|
|
|
public function setValue($value) |
78
|
|
|
{ |
79
|
|
|
$this->setAttrib('value', $value); |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $requester |
86
|
|
|
* @return string |
87
|
|
|
*/ |
88
|
|
|
public function getValue($requester = 'abstract') |
|
|
|
|
89
|
|
|
{ |
90
|
|
|
return $this->getAttrib('value'); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param $key |
95
|
|
|
* @return bool |
96
|
|
|
*/ |
97
|
|
|
public function delAttrib($key) |
98
|
|
|
{ |
99
|
|
|
$key = (string) $key; |
100
|
|
|
unset($this->_attribs[$key]); |
101
|
|
|
|
102
|
|
|
return true; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function render() |
106
|
|
|
{ |
107
|
|
|
return $this->getRenderer()->render($this); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getRenderer() |
111
|
|
|
{ |
112
|
|
|
return $this->getForm()->getRenderer()->getButtonRenderer($this); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return AbstractForm |
117
|
|
|
*/ |
118
|
|
|
public function getForm() |
119
|
|
|
{ |
120
|
|
|
return $this->_form; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param AbstractForm $form |
125
|
|
|
* @return $this |
126
|
|
|
*/ |
127
|
|
|
public function setForm(AbstractForm $form) |
128
|
|
|
{ |
129
|
|
|
$this->_form = $form; |
130
|
|
|
|
131
|
|
|
return $this; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return string |
136
|
|
|
*/ |
137
|
|
|
public function getType() |
138
|
|
|
{ |
139
|
|
|
return $this->_type; |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.