1
|
|
|
<?php |
2
|
|
|
namespace PlaygroundCore\Controller\Admin; |
3
|
|
|
|
4
|
|
|
use Zend\Mvc\Controller\AbstractActionController; |
5
|
|
|
use Zend\View\Model\ViewModel; |
6
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
7
|
|
|
|
8
|
|
|
class FormgenController extends AbstractActionController |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
protected $formgenService; |
12
|
|
|
protected $websiteService; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* |
16
|
|
|
* @var ServiceManager |
17
|
|
|
*/ |
18
|
|
|
protected $serviceLocator; |
19
|
|
|
|
20
|
|
|
public function __construct(ServiceLocatorInterface $locator) |
21
|
|
|
{ |
22
|
|
|
$this->serviceLocator = $locator; |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function getServiceLocator() |
26
|
|
|
{ |
27
|
|
|
|
28
|
|
|
return $this->serviceLocator; |
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function indexAction() |
32
|
|
|
{ |
33
|
|
|
return array(); |
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function listAction() |
37
|
|
|
{ |
38
|
|
|
$mapper = $this->getFormgenService()->getformgenMapper(); |
39
|
|
|
$forms = $mapper->findAll(); |
40
|
|
|
|
41
|
|
|
return new ViewModel(array( |
42
|
|
|
'forms' => $forms, |
43
|
|
|
)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function generateAction() |
47
|
|
|
{ |
48
|
|
|
if ($this->getRequest()->isPost()) { |
|
|
|
|
49
|
|
|
$data = $this->getRequest()->getPost()->toArray(); |
|
|
|
|
50
|
|
|
$formGenService = $this->getFormgenService(); |
51
|
|
|
$formGenService->insert($data); |
52
|
|
|
return $this->redirect()->toRoute('admin/formgen/list'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$websites = $this->getWebsiteService()->getWebsiteMapper()->findAll(); |
56
|
|
|
return new ViewModel(array( |
57
|
|
|
'websites' => $websites, |
58
|
|
|
)); |
59
|
|
|
} |
60
|
|
|
public function editAction() |
61
|
|
|
{ |
62
|
|
|
if ($this->getRequest()->isPost()) { |
|
|
|
|
63
|
|
|
$data = $this->getRequest()->getPost()->toArray(); |
|
|
|
|
64
|
|
|
$formGenService = $this->getFormgenService(); |
65
|
|
|
$formgen = $this->getFormgenService()->getFormgenMapper()->findById($data['formId']); |
66
|
|
|
$formGenService->update($formgen, $data); |
67
|
|
|
|
68
|
|
|
return $this->redirect()->toRoute('admin/formgen/list'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$formId = $this->getEvent()->getRouteMatch()->getParam('formId'); |
72
|
|
|
$formgen = $formGenService = $this->getFormgenService()->getFormgenMapper()->findById($formId); |
|
|
|
|
73
|
|
|
|
74
|
|
|
|
75
|
|
|
$websites = $this->getWebsiteService()->getWebsiteMapper()->findAll(); |
76
|
|
|
return new ViewModel(array( |
77
|
|
|
'websites' => $websites, |
78
|
|
|
'form' => $formgen, |
79
|
|
|
)); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function activateAction() |
83
|
|
|
{ |
84
|
|
|
$formId = $this->getEvent()->getRouteMatch()->getParam('formId'); |
85
|
|
|
$formgen = $this->getFormgenService()->getFormgenMapper()->findById($formId); |
86
|
|
|
$formgen->setActive(!$formgen->getActive()); |
87
|
|
|
$this->getFormgenService()->getFormgenMapper()->update($formgen); |
88
|
|
|
|
89
|
|
|
return $this->redirect()->toRoute('admin/formgen/list'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function viewAction() |
93
|
|
|
{ |
94
|
|
|
$renderer = $this->serviceLocator->get('Zend\View\Renderer\RendererInterface'); |
95
|
|
|
$headScript = $this->getServiceLocator()->get('viewhelpermanager')->get('HeadScript'); |
96
|
|
|
$headScript->appendFile($renderer->adminAssetPath() . '/js/form/parse.form.js'); |
97
|
|
|
|
98
|
|
|
$formId = $this->params('form'); |
99
|
|
|
|
100
|
|
|
return array('form_id' => $formId); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function createAction() |
104
|
|
|
{ |
105
|
|
|
$renderer = $this->serviceLocator->get('Zend\View\Renderer\RendererInterface'); |
106
|
|
|
$headScript = $this->getServiceLocator()->get('viewhelpermanager')->get('HeadScript'); |
107
|
|
|
$headScript->appendFile($renderer->adminAssetPath() . '/js/form/create.form.js'); |
108
|
|
|
$headScript->appendFile($renderer->adminAssetPath() . '/js/form/line.text.js'); |
109
|
|
|
$headScript->appendFile($renderer->adminAssetPath() . '/js/form/add.form.js'); |
110
|
|
|
$headScript->appendFile($renderer->adminAssetPath() . '/js/form/json.form.js'); |
111
|
|
|
$headScript->appendFile($renderer->adminAssetPath() . '/js/form/edit.form.js'); |
112
|
|
|
|
113
|
|
|
return array(); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
public function inputAction() |
117
|
|
|
{ |
118
|
|
|
$result = $this->getAjax(); |
119
|
|
|
|
120
|
|
|
return $result; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function passwordAction() |
124
|
|
|
{ |
125
|
|
|
$result = $this->getAjax(); |
126
|
|
|
|
127
|
|
|
return $result; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function passwordverifyAction() |
131
|
|
|
{ |
132
|
|
|
$result = $this->getAjax(); |
133
|
|
|
|
134
|
|
|
return $result; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function numberAction() |
138
|
|
|
{ |
139
|
|
|
$result = $this->getAjax(); |
140
|
|
|
|
141
|
|
|
return $result; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function phoneAction() |
145
|
|
|
{ |
146
|
|
|
$result = $this->getAjax(); |
147
|
|
|
|
148
|
|
|
return $result; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function paragraphAction() |
152
|
|
|
{ |
153
|
|
|
$result = $this->getAjax(); |
154
|
|
|
|
155
|
|
|
return $result; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function checkboxAction() |
159
|
|
|
{ |
160
|
|
|
$result = $this->getAjax(); |
161
|
|
|
|
162
|
|
|
return $result; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function radioAction() |
166
|
|
|
{ |
167
|
|
|
$result = $this->getAjax(); |
168
|
|
|
|
169
|
|
|
return $result; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
public function dropdownAction() |
173
|
|
|
{ |
174
|
|
|
$result = $this->getAjax(); |
175
|
|
|
|
176
|
|
|
return $result; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
public function emailAction() |
180
|
|
|
{ |
181
|
|
|
$result = $this->getAjax(); |
182
|
|
|
|
183
|
|
|
return $result; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
public function dateAction() |
187
|
|
|
{ |
188
|
|
|
$result = $this->getAjax(); |
189
|
|
|
|
190
|
|
|
return $result; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
public function uploadAction() |
194
|
|
|
{ |
195
|
|
|
$result = $this->getAjax(); |
196
|
|
|
|
197
|
|
|
return $result; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
public function creditcardAction() |
201
|
|
|
{ |
202
|
|
|
$result = $this->getAjax(); |
203
|
|
|
|
204
|
|
|
return $result; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
public function urlAction() |
208
|
|
|
{ |
209
|
|
|
$result = $this->getAjax(); |
210
|
|
|
|
211
|
|
|
return $result; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
public function hiddenAction() |
215
|
|
|
{ |
216
|
|
|
$result = $this->getAjax(); |
217
|
|
|
|
218
|
|
|
return $result; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
public function getAjax() |
222
|
|
|
{ |
223
|
|
|
$request = $this->getRequest(); |
224
|
|
|
$results = $request->getQuery(); |
225
|
|
|
|
226
|
|
|
$result = new ViewModel(array( |
227
|
|
|
'result' => $results, |
228
|
|
|
)); |
229
|
|
|
|
230
|
|
|
$result->setTerminal(true); |
231
|
|
|
|
232
|
|
|
return $result; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
public function getFormgenService() |
236
|
|
|
{ |
237
|
|
|
if (!$this->formgenService) { |
238
|
|
|
$this->formgenService = $this->getServiceLocator()->get('playgroundcore_formgen_service'); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
return $this->formgenService; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
public function getWebsiteService() |
245
|
|
|
{ |
246
|
|
|
if (!$this->websiteService) { |
247
|
|
|
$this->websiteService = $this->getServiceLocator()->get('playgroundcore_website_service'); |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
return $this->websiteService; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
public function setFormgenService($formgenService) |
254
|
|
|
{ |
255
|
|
|
$this->formgenService = $formgenService; |
256
|
|
|
|
257
|
|
|
return $this; |
258
|
|
|
} |
259
|
|
|
} |
260
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..