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