1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PlaygroundGame\Controller\Frontend; |
4
|
|
|
|
5
|
|
|
use Zend\Form\Form; |
6
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
7
|
|
|
|
8
|
|
|
class PostVoteController extends GameController |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var gameService |
12
|
|
|
*/ |
13
|
|
|
protected $gameService; |
14
|
|
|
|
15
|
|
|
public function __construct(ServiceLocatorInterface $locator) |
16
|
|
|
{ |
17
|
|
|
parent::__construct($locator); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* --DONE-- 1. try to change the Game Id (on le redirige vers la home du jeu) |
22
|
|
|
* --DONE-- 2. try to modify questions (the form is recreated and verified in the controller) |
23
|
|
|
* --DONE-- 3. don't answer to questions (form is checked controller side) |
24
|
|
|
* 4. try to game the chrono |
25
|
|
|
* 5. try to play again |
26
|
|
|
* 6. try to change answers |
27
|
|
|
* --DONE-- 7. essaie de répondre sans être inscrit (on le redirige vers la home du jeu) |
28
|
|
|
*/ |
29
|
|
|
public function playAction() |
30
|
|
|
{ |
31
|
|
|
$entry = $this->getGameService()->play($this->game, $this->user); |
32
|
|
|
|
33
|
|
|
if (!$entry) { |
34
|
|
|
$lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
35
|
|
|
if ($lastEntry === null) { |
36
|
|
|
return $this->redirect()->toUrl( |
37
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
38
|
|
|
'postvote', |
39
|
|
|
array('id' => $this->game->getIdentifier()) |
40
|
|
|
) |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$lastEntryId = $lastEntry->getId(); |
45
|
|
|
$lastPost = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntryId)); |
46
|
|
|
$postId = $lastPost->getId(); |
47
|
|
|
if ($lastPost->getStatus() == 2) { |
48
|
|
|
// the user has already taken part to this game and the participation limit has been reached |
49
|
|
|
$this->flashMessenger()->addMessage( |
|
|
|
|
50
|
|
|
$this->getServiceLocator()->get('MvcTranslator')->translate('You have already a Post') |
51
|
|
|
); |
52
|
|
|
|
53
|
|
|
return $this->redirect()->toUrl( |
54
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
55
|
|
|
'postvote/post', |
56
|
|
|
array( |
57
|
|
|
'id' => $this->game->getIdentifier(), |
58
|
|
|
'post' => $postId, |
59
|
|
|
) |
60
|
|
|
) |
61
|
|
|
); |
62
|
|
View Code Duplication |
} else { |
|
|
|
|
63
|
|
|
$this->flashMessenger()->addMessage( |
|
|
|
|
64
|
|
|
$this->getServiceLocator()->get('MvcTranslator')->translate('Your Post is waiting for validation') |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
return $this->redirect()->toUrl( |
68
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
69
|
|
|
'postvote/post', |
70
|
|
|
array( |
71
|
|
|
'id' => $this->game->getIdentifier(), |
72
|
|
|
'post' => $postId, |
73
|
|
|
|
74
|
|
|
) |
75
|
|
|
) |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
if (! $this->game->getForm()) { |
81
|
|
|
return $this->redirect()->toUrl( |
82
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
83
|
|
|
'postvote', |
84
|
|
|
array('id' => $this->game->getIdentifier()) |
85
|
|
|
) |
86
|
|
|
); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
$form = $this->getGameService()->createFormFromJson($this->game->getForm()->getForm(), 'postvoteForm'); |
90
|
|
|
|
91
|
|
|
// Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
92
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0)); |
93
|
|
|
if ($post) { |
94
|
|
|
foreach ($post->getPostElements() as $element) { |
95
|
|
|
try { |
96
|
|
|
$form->get($element->getName())->setValue($element->getValue()); |
97
|
|
|
|
98
|
|
|
$elementType = $form->get($element->getName())->getAttribute('type'); |
99
|
|
|
if ($elementType == 'file' && $element->getValue() != '') { |
100
|
|
|
$filter = $form->getInputFilter(); |
101
|
|
|
$elementInput = $filter->get($element->getName()); |
102
|
|
|
$elementInput->setRequired(false); |
103
|
|
|
$form->get($element->getName())->setAttribute('required', false); |
104
|
|
|
} |
105
|
|
|
} catch (\Zend\Form\Exception\InvalidElementException $e) { |
|
|
|
|
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
$viewModel = $this->buildView($this->game); |
111
|
|
|
|
112
|
|
|
if ($this->getRequest()->isPost()) { |
|
|
|
|
113
|
|
|
// POST Request: Process form |
114
|
|
|
$data = array_merge_recursive( |
115
|
|
|
$this->getRequest()->getPost()->toArray(), |
|
|
|
|
116
|
|
|
$this->getRequest()->getFiles()->toArray() |
|
|
|
|
117
|
|
|
); |
118
|
|
|
|
119
|
|
|
$form->setData($data); |
120
|
|
|
|
121
|
|
|
if ($form->isValid()) { |
122
|
|
|
$data = $form->getData(); |
123
|
|
|
$post = $this->getGameService()->createPost($data, $this->game, $this->user, $form); |
124
|
|
|
|
125
|
|
View Code Duplication |
if ($post && !empty($this->game->nextStep('play'))) { |
|
|
|
|
126
|
|
|
// determine the route where the user should go |
127
|
|
|
$redirectUrl = $this->frontendUrl()->fromRoute( |
|
|
|
|
128
|
|
|
'postvote/'.$this->game->nextStep('play'), |
129
|
|
|
array('id' => $this->game->getIdentifier()) |
130
|
|
|
); |
131
|
|
|
|
132
|
|
|
return $this->redirect()->toUrl($redirectUrl); |
133
|
|
|
} |
134
|
|
|
} else { |
135
|
|
|
$messages = $form->getMessages(); |
136
|
|
|
$viewModel = $this->buildView($this->game); |
137
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
138
|
|
|
'success' => false, |
139
|
|
|
'message' => implode(',', $messages['title']), |
140
|
|
|
)); |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
$viewModel->setVariables(array( |
145
|
|
|
'playerData' => $entry->getPlayerData(), |
146
|
|
|
'form' => $form, |
147
|
|
|
'post' => $post, |
148
|
|
|
)); |
149
|
|
|
|
150
|
|
|
return $viewModel; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function previewAction() |
154
|
|
|
{ |
155
|
|
|
$entry = $this->getGameService()->findLastActiveEntry($this->game, $this->user); |
156
|
|
|
|
157
|
|
View Code Duplication |
if (!$entry) { |
|
|
|
|
158
|
|
|
// the user has already taken part of this game and the participation limit has been reached |
159
|
|
|
return $this->redirect()->toUrl( |
160
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
161
|
|
|
'postvote/'.$this->game->nextStep('preview'), |
162
|
|
|
array('id' => $this->game->getIdentifier()) |
163
|
|
|
) |
164
|
|
|
); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
// Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
168
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0)); |
169
|
|
|
|
170
|
|
|
if (! $post) { |
171
|
|
|
return $this->redirect()->toUrl( |
172
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
173
|
|
|
'postvote', |
174
|
|
|
array('id' => $this->game->getIdentifier()) |
175
|
|
|
) |
176
|
|
|
); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
if ($this->getRequest()->isPost()) { |
|
|
|
|
180
|
|
|
$post = $this->getGameService()->confirmPost($this->game, $this->user); |
181
|
|
|
|
182
|
|
|
if ($post) { |
183
|
|
|
if (!($step = $this->game->nextStep('preview'))) { |
184
|
|
|
$step = 'result'; |
185
|
|
|
} |
186
|
|
|
$redirectUrl = $this->frontendUrl()->fromRoute( |
|
|
|
|
187
|
|
|
'postvote/'.$step, |
188
|
|
|
array('id' => $this->game->getIdentifier()) |
189
|
|
|
); |
190
|
|
|
|
191
|
|
|
return $this->redirect()->toUrl($redirectUrl); |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
$viewModel = $this->buildView($this->game); |
196
|
|
|
$viewModel->setVariables(array('post' => $post)); |
|
|
|
|
197
|
|
|
|
198
|
|
|
return $viewModel; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* View the Post page |
203
|
|
|
* @return multitype:|\Zend\Http\Response|\Zend\View\Model\ViewModel |
|
|
|
|
204
|
|
|
*/ |
205
|
|
|
public function postAction() |
206
|
|
|
{ |
207
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
208
|
|
|
$voted = false; |
209
|
|
|
$statusMail = false; |
210
|
|
|
$mailService = $this->getServiceLocator()->get('playgroundgame_message'); |
211
|
|
|
$to = ''; |
212
|
|
|
$skinUrl = $this->getGameService()->getServiceManager()->get('ViewRenderer')->url( |
213
|
|
|
'frontend', |
214
|
|
|
array(), |
215
|
|
|
array('force_canonical' => true) |
216
|
|
|
); |
217
|
|
|
$config = $this->getGameService()->getServiceManager()->get('config'); |
218
|
|
|
if (isset($config['moderation']['email'])) { |
219
|
|
|
$to = $config['moderation']['email']; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
if (! $postId) { |
223
|
|
|
return $this->notFoundAction(); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
// Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
227
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
228
|
|
|
|
229
|
|
View Code Duplication |
if (! $post || $post->getStatus() === 9) { |
|
|
|
|
230
|
|
|
return $this->redirect()->toUrl( |
231
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
232
|
|
|
'postvote', |
233
|
|
|
array('id' => $this->game->getIdentifier()) |
234
|
|
|
) |
235
|
|
|
); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
$formModeration = new Form(); |
239
|
|
|
$formModeration->setAttribute('method', 'post'); |
240
|
|
|
|
241
|
|
|
$formModeration->add(array( |
242
|
|
|
'name' => 'moderation', |
243
|
|
|
'attributes' => array( |
244
|
|
|
'type' => 'hidden', |
245
|
|
|
'value' => '1' |
246
|
|
|
), |
247
|
|
|
)); |
248
|
|
|
|
249
|
|
|
$form = new \PlaygroundGame\Form\Frontend\PostVoteVote( |
250
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
251
|
|
|
'postvote/post/captcha', |
252
|
|
|
array( |
253
|
|
|
'id' => $this->game->getIdentifier(), |
254
|
|
|
'post' => $postId, |
255
|
|
|
) |
256
|
|
|
) |
257
|
|
|
); |
258
|
|
|
|
259
|
|
|
if ($this->user) { |
260
|
|
|
$form->remove('captcha'); |
261
|
|
|
if (count($this->getGameService()->getPostvoteVoteMapper()->findBy(array('user' => $this->user, 'post' =>$post))) > 0) { |
262
|
|
|
$voted = true; |
263
|
|
|
} |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
$alreadyVoted = ''; |
267
|
|
|
$reportId = ''; |
268
|
|
|
|
269
|
|
|
$request = $this->getRequest(); |
270
|
|
|
if ($request->isPost()) { |
271
|
|
|
$data = $request->getPost()->toArray(); |
272
|
|
|
if (isset($data['moderation'])) { |
273
|
|
|
$formModeration->setData($data); |
274
|
|
|
if ($formModeration->isValid()) { |
275
|
|
|
$from = $to; |
276
|
|
|
$subject= 'Moderation Post and Vote'; |
277
|
|
|
$result = $mailService->createHtmlMessage( |
278
|
|
|
$from, |
279
|
|
|
$to, |
280
|
|
|
$subject, |
281
|
|
|
'playground-game/email/moderation', |
282
|
|
|
array('data' => $data, 'skinUrl' => $skinUrl) |
283
|
|
|
); |
284
|
|
|
$mailService->send($result); |
285
|
|
|
if ($result) { |
286
|
|
|
$statusMail = true; |
287
|
|
|
$reportId = $data['reportid']; |
288
|
|
|
} |
289
|
|
|
} |
290
|
|
|
} else { |
291
|
|
|
$form->setData($request->getPost()); |
292
|
|
|
if ($form->isValid()) { |
293
|
|
|
if ($this->getGameService()->addVote( |
294
|
|
|
$this->user, |
295
|
|
|
$this->getRequest()->getServer('REMOTE_ADDR'), |
|
|
|
|
296
|
|
|
$post |
297
|
|
|
)) { |
298
|
|
|
$voted = true; |
299
|
|
|
} else { |
300
|
|
|
$alreadyVoted = 'Vous avez déjà voté!'; |
301
|
|
|
} |
302
|
|
|
} |
303
|
|
|
} |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
$viewModel = $this->buildView($this->game); |
307
|
|
|
$viewModel->setVariables( |
|
|
|
|
308
|
|
|
array( |
309
|
|
|
'post' => $post, |
310
|
|
|
'voted' => $voted, |
311
|
|
|
'form' => $form, |
312
|
|
|
'formModeration' => $formModeration, |
313
|
|
|
'statusMail' => $statusMail, |
314
|
|
|
'alreadyVoted' => $alreadyVoted, |
315
|
|
|
'reportId' => $reportId, |
316
|
|
|
) |
317
|
|
|
); |
318
|
|
|
|
319
|
|
|
return $viewModel; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* |
324
|
|
|
*/ |
325
|
|
|
public function resultAction() |
326
|
|
|
{ |
327
|
|
|
$playLimitReached = false; |
328
|
|
|
if ($this->getRequest()->getQuery()->get('playLimitReached')) { |
|
|
|
|
329
|
|
|
$playLimitReached = true; |
330
|
|
|
} |
331
|
|
|
$lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
332
|
|
|
if ($lastEntry === null) { |
333
|
|
|
return $this->redirect()->toUrl($this->frontendUrl()->fromRoute('postvote', array('id' => $identifier))); |
|
|
|
|
334
|
|
|
} |
335
|
|
|
// Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
336
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntry)); |
337
|
|
|
|
338
|
|
|
if (! $post) { |
339
|
|
|
return $this->redirect()->toUrl( |
340
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
341
|
|
|
'postvote', |
342
|
|
|
array('id' => $this->game->getIdentifier()) |
343
|
|
|
) |
344
|
|
|
); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
// DEPRECATED: we should be able to add a specific view to each action |
348
|
|
|
// based on config in the admin (tab design) |
349
|
|
|
// $view = $this->forward()->dispatch( |
350
|
|
|
// 'playgroundgame_'.$this->game->getClassType(), |
351
|
|
|
// array( |
352
|
|
|
// 'controller' => 'playgroundgame_'.$this->game->getClassType(), |
353
|
|
|
// 'action' => 'share', |
354
|
|
|
// 'id' => $this->game->getIdentifier() |
355
|
|
|
// ) |
356
|
|
|
// ); |
357
|
|
|
|
358
|
|
|
// if ($view && $view instanceof \Zend\View\Model\ViewModel) { |
359
|
|
|
// $view->setVariables(array('post' => $post)); |
360
|
|
|
|
361
|
|
|
// return $view; |
362
|
|
|
// } elseif ($view && $view instanceof \Zend\Http\PhpEnvironment\Response) { |
363
|
|
|
// return $view; |
364
|
|
|
// } else { |
365
|
|
|
$form = $this->getServiceLocator() |
366
|
|
|
->get('playgroundgame_sharemail_form') |
367
|
|
|
->setAttribute('method', 'post'); |
368
|
|
|
|
369
|
|
|
$viewModel = $this->buildView($this->game); |
370
|
|
|
|
371
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
372
|
|
|
'statusMail' => null, |
373
|
|
|
'post' => $post, |
374
|
|
|
'form' => $form, |
375
|
|
|
'playLimitReached' => $playLimitReached, |
376
|
|
|
)); |
377
|
|
|
|
378
|
|
|
return $viewModel; |
379
|
|
|
//} |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* Example of AJAX File Upload with Session Progress and partial validation. |
384
|
|
|
* It's now possible to send a base64 image in this case the call is the form : |
385
|
|
|
* this._ajax( |
386
|
|
|
* { |
387
|
|
|
* url: url.dataset.url, |
388
|
|
|
* method: 'post', |
389
|
|
|
* body: 'photo=' + image |
390
|
|
|
* }, |
391
|
|
|
* |
392
|
|
|
* @return \Zend\Stdlib\ResponseInterface |
393
|
|
|
*/ |
394
|
|
|
public function ajaxuploadAction() |
395
|
|
|
{ |
396
|
|
|
// Call this for the session lock to be released (other ajax calls can then be made) |
397
|
|
|
session_write_close(); |
398
|
|
|
|
399
|
|
View Code Duplication |
if (! $this->game) { |
|
|
|
|
400
|
|
|
$this->getResponse()->setContent(\Zend\Json\Json::encode(array( |
401
|
|
|
'success' => 0 |
402
|
|
|
))); |
403
|
|
|
|
404
|
|
|
return $this->getResponse(); |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
$entry = $this->getGameService()->findLastActiveEntry( |
408
|
|
|
$this->game, |
409
|
|
|
$this->user |
410
|
|
|
); |
411
|
|
|
if (!$entry) { |
412
|
|
|
// the user has already taken part of this game and the participation limit has been reached |
413
|
|
|
$this->getResponse()->setContent(\Zend\Json\Json::encode(array( |
414
|
|
|
'success' => 0 |
415
|
|
|
))); |
416
|
|
|
|
417
|
|
|
return $this->getResponse(); |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
if ($this->getRequest()->isPost()) { |
|
|
|
|
421
|
|
|
$data = $this->getRequest()->getFiles()->toArray(); |
|
|
|
|
422
|
|
|
|
423
|
|
View Code Duplication |
if (empty($data)) { |
|
|
|
|
424
|
|
|
$data = $this->getRequest()->getPost()->toArray(); |
|
|
|
|
425
|
|
|
$key = key($data); |
426
|
|
|
$uploadImage = array('name' => $key.'.png', 'error' => 0, 'base64' => $data[$key]); |
427
|
|
|
$data = array($key => $uploadImage); |
428
|
|
|
} |
429
|
|
|
$uploadFile = $this->getGameService()->uploadFileToPost( |
430
|
|
|
$data, |
431
|
|
|
$this->game, |
432
|
|
|
$this->user |
433
|
|
|
); |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
$this->getResponse()->setContent(\Zend\Json\Json::encode(array( |
437
|
|
|
'success' => true, |
438
|
|
|
'fileUrl' => $uploadFile |
|
|
|
|
439
|
|
|
))); |
440
|
|
|
|
441
|
|
|
return $this->getResponse(); |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
public function ajaxdeleteAction() |
445
|
|
|
{ |
446
|
|
|
$response = $this->getResponse(); |
447
|
|
|
|
448
|
|
|
if (! $this->game) { |
449
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
450
|
|
|
'success' => 0 |
451
|
|
|
))); |
452
|
|
|
|
453
|
|
|
return $response; |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
$entry = $this->getGameService()->findLastActiveEntry($this->game, $this->user); |
457
|
|
|
if (!$entry) { |
458
|
|
|
// the user has already taken part of this game and the participation limit has been reached |
459
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
460
|
|
|
'success' => 0 |
461
|
|
|
))); |
462
|
|
|
|
463
|
|
|
return $response; |
464
|
|
|
} |
465
|
|
|
if ($request->isPost()) { |
466
|
|
|
$data = $request->getPost()->toArray(); |
|
|
|
|
467
|
|
|
$this->getGameService()->deleteFilePosted($data, $this->game, $this->user); |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
471
|
|
|
'success' => true, |
472
|
|
|
))); |
473
|
|
|
|
474
|
|
|
return $response; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
public function ajaxrejectPostAction() |
478
|
|
|
{ |
479
|
|
|
$response = $this->getResponse(); |
480
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
481
|
|
|
|
482
|
|
|
if (! $postId) { |
483
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
484
|
|
|
'success' => 0 |
485
|
|
|
))); |
486
|
|
|
|
487
|
|
|
return $response; |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
491
|
|
|
|
492
|
|
|
if (! $post || $post->getUser()->getId() !== $this->user->getId()) { |
493
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
494
|
|
|
'success' => 0 |
495
|
|
|
))); |
496
|
|
|
|
497
|
|
|
return $response; |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
if ($this->getRequest()->isPost()) { |
|
|
|
|
501
|
|
|
$postvotePostMapper = $this->getGameService()->getPostVotePostMapper(); |
502
|
|
|
// Post is rejected by User |
503
|
|
|
$post->setStatus(8); |
504
|
|
|
$postvotePostMapper->update($post); |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
508
|
|
|
'success' => true, |
509
|
|
|
))); |
510
|
|
|
|
511
|
|
|
return $response; |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
public function listAction() |
515
|
|
|
{ |
516
|
|
|
$filter = $this->getEvent()->getRouteMatch()->getParam('filter'); |
517
|
|
|
$search = $this->params()->fromQuery('name'); |
518
|
|
|
$postId = $this->params()->fromQuery('id'); |
519
|
|
|
$statusMail = false; |
520
|
|
|
$mailService = $this->getServiceLocator()->get('playgroundgame_message'); |
521
|
|
|
$to = ''; |
522
|
|
|
$skinUrl = $this->getGameService()->getServiceManager()->get('ViewRenderer')->url( |
523
|
|
|
'frontend', |
524
|
|
|
array(), |
525
|
|
|
array('force_canonical' => true) |
526
|
|
|
); |
527
|
|
|
$config = $this->getGameService()->getServiceManager()->get('config'); |
528
|
|
|
if (isset($config['moderation']['email'])) { |
529
|
|
|
$to = $config['moderation']['email']; |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
$request = $this->getRequest(); |
533
|
|
|
|
534
|
|
|
// Je recherche les posts validés associés à ce jeu |
535
|
|
|
$posts = $this->getGameService()->findArrayOfValidatedPosts($this->game, $this->user, $filter, $search); |
536
|
|
|
|
537
|
|
|
if (is_array($posts)) { |
538
|
|
|
$paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\ArrayAdapter($posts)); |
539
|
|
|
$paginator->setItemCountPerPage($this->game->getPostDisplayNumber()); |
540
|
|
|
$paginator->setCurrentPageNumber($this->getEvent()->getRouteMatch()->getParam('p')); |
541
|
|
|
} else { |
542
|
|
|
$paginator = $posts; |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
$form = new Form(); |
546
|
|
|
$form->setAttribute('method', 'post'); |
547
|
|
|
|
548
|
|
|
$form->add(array( |
549
|
|
|
'name' => 'moderation', |
550
|
|
|
'attributes' => array( |
551
|
|
|
'type' => 'hidden', |
552
|
|
|
'value' => '1' |
553
|
|
|
), |
554
|
|
|
)); |
555
|
|
|
|
556
|
|
|
$reportId =''; |
557
|
|
|
|
558
|
|
|
if ($request->isPost()) { |
559
|
|
|
$data = $request->getPost()->toArray(); |
560
|
|
|
|
561
|
|
|
if (isset($data['moderation'])) { |
562
|
|
|
$from = $to; |
563
|
|
|
$subject= 'Moderation Post and Vote'; |
564
|
|
|
$result = $mailService->createHtmlMessage( |
565
|
|
|
$from, |
566
|
|
|
$to, |
567
|
|
|
$subject, |
568
|
|
|
'playground-game/email/moderation', |
569
|
|
|
array('data' => $data, 'skinUrl' => $skinUrl) |
570
|
|
|
); |
571
|
|
|
$mailService->send($result); |
572
|
|
|
if ($result) { |
573
|
|
|
$statusMail = true; |
574
|
|
|
$reportId = $data['reportid']; |
575
|
|
|
} |
576
|
|
|
} |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
$viewModel = $this->buildView($this->game); |
580
|
|
|
|
581
|
|
|
if ($postId) { |
582
|
|
|
$postTarget = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
583
|
|
|
if ($postTarget) { |
584
|
|
View Code Duplication |
foreach ($postTarget->getPostElements() as $element) { |
|
|
|
|
585
|
|
|
$fbShareImage = $this->frontendUrl()->fromRoute( |
|
|
|
|
586
|
|
|
'', |
587
|
|
|
array(), |
588
|
|
|
array('force_canonical' => true), |
589
|
|
|
false |
590
|
|
|
) . $element->getValue(); |
591
|
|
|
break; |
592
|
|
|
} |
593
|
|
|
|
594
|
|
|
$secretKey = strtoupper(substr(sha1(uniqid('pg_', true).'####'.time()), 0, 15)); |
595
|
|
|
|
596
|
|
|
// Without bit.ly shortener |
597
|
|
|
$socialLinkUrl = $this->frontendUrl()->fromRoute( |
|
|
|
|
598
|
|
|
'postvote/list', |
599
|
|
|
array( |
600
|
|
|
'id' => $this->game->getIdentifier(), |
601
|
|
|
'filter' => 'date'), |
602
|
|
|
array('force_canonical' => true) |
603
|
|
|
).'?id='.$postTarget->getId().'&key='.$secretKey; |
604
|
|
|
// With core shortener helper |
605
|
|
|
$socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl); |
|
|
|
|
606
|
|
|
|
607
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('og:image', $fbShareImage); |
|
|
|
|
608
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:card', "photo"); |
609
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:site', "@alfie_selfie"); |
610
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:title', $this->game->getTwShareMessage()); |
611
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:description', ""); |
612
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:image', $fbShareImage); |
613
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:url', $socialLinkUrl); |
614
|
|
|
} |
615
|
|
|
} |
616
|
|
|
|
617
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
618
|
|
|
'posts' => $paginator, |
619
|
|
|
'form' => $form, |
620
|
|
|
'statusMail' => $statusMail, |
621
|
|
|
'reportId' => $reportId, |
622
|
|
|
'filter' => $filter, |
623
|
|
|
'search' => $search, |
624
|
|
|
)); |
625
|
|
|
|
626
|
|
|
return $viewModel; |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
/** |
630
|
|
|
* If the user has already voted, we cancel her vote, else we create the vote. |
631
|
|
|
* TODO : we should distinguish between vote and like (so we should add the like field in post) |
632
|
|
|
*/ |
633
|
|
|
public function ajaxVoteAction() |
634
|
|
|
{ |
635
|
|
|
// Call this for the session lock to be released (other ajax calls can then be made) |
636
|
|
|
session_write_close(); |
637
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
638
|
|
|
$commentId = $this->getEvent()->getRouteMatch()->getParam('comment'); |
639
|
|
|
$request = $this->getRequest(); |
640
|
|
|
$response = $this->getResponse(); |
641
|
|
|
|
642
|
|
|
if (! $this->game) { |
643
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
644
|
|
|
'success' => 0 |
645
|
|
|
))); |
646
|
|
|
|
647
|
|
|
return $response; |
648
|
|
|
} |
649
|
|
|
|
650
|
|
|
if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
|
|
|
651
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
652
|
|
|
'success' => 0 |
653
|
|
|
))); |
654
|
|
|
} else { |
655
|
|
|
if ($request->isPost()) { |
656
|
|
|
$post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
657
|
|
|
$comment = ($commentId !== null) ? $this->getGameService()->getPostVoteCommentMapper()->findById($commentId) : null; |
658
|
|
|
if ($this->getGameService()->toggleVote( |
659
|
|
|
$this->user, |
660
|
|
|
$this->getRequest()->getServer('REMOTE_ADDR'), |
|
|
|
|
661
|
|
|
$post, |
662
|
|
|
$comment |
663
|
|
|
)) { |
664
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
665
|
|
|
'success' => 1 |
666
|
|
|
))); |
667
|
|
|
} else { |
668
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
669
|
|
|
'success' => 0 |
670
|
|
|
))); |
671
|
|
|
} |
672
|
|
|
} |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
return $response; |
676
|
|
|
} |
677
|
|
|
|
678
|
|
|
public function commentsAction() |
679
|
|
|
{ |
680
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
681
|
|
|
if ($postId) { |
682
|
|
|
$post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
683
|
|
|
$comments = $post->getComments(); |
684
|
|
|
} else { |
685
|
|
|
$comments = $this->getGameService()->getCommentsForPostvote($this->game); |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
if (is_array($comments)) { |
689
|
|
|
$paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\ArrayAdapter($comments)); |
690
|
|
|
$paginator->setItemCountPerPage(25); |
691
|
|
|
$paginator->setCurrentPageNumber($this->getEvent()->getRouteMatch()->getParam('p')); |
692
|
|
|
} else { |
693
|
|
|
$paginator = $comments; |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
$viewModel = $this->buildView($this->game); |
697
|
|
|
$viewModel->setVariables(array('comments' => $paginator)); |
|
|
|
|
698
|
|
|
|
699
|
|
|
return $viewModel; |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
public function commentAction() |
703
|
|
|
{ |
704
|
|
|
if ($this->getRequest()->isXmlHttpRequest()) { |
|
|
|
|
705
|
|
|
// Call this for the session lock to be released (other ajax calls can then be made) |
706
|
|
|
session_write_close(); |
707
|
|
|
} |
708
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
709
|
|
|
$request = $this->getRequest(); |
710
|
|
|
$response = $this->getResponse(); |
711
|
|
|
$post = $this->getGameService()->getPostvotePostMapper()->findById($postId); |
712
|
|
|
|
713
|
|
|
if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
|
|
|
714
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
715
|
|
|
'success' => 0 |
716
|
|
|
))); |
717
|
|
View Code Duplication |
} else { |
|
|
|
|
718
|
|
|
if ($request->isPost()) { |
719
|
|
|
if ($this->getGameService()->addComment( |
720
|
|
|
$this->user, |
721
|
|
|
$this->getRequest()->getServer('REMOTE_ADDR'), |
|
|
|
|
722
|
|
|
$post, |
723
|
|
|
$this->params()->fromPost('comment'), |
724
|
|
|
$this->params()->fromPost('category') |
725
|
|
|
)) { |
726
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
727
|
|
|
'success' => 1 |
728
|
|
|
))); |
729
|
|
|
} else { |
730
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
731
|
|
|
'success' => 0 |
732
|
|
|
))); |
733
|
|
|
} |
734
|
|
|
} |
735
|
|
|
} |
736
|
|
|
|
737
|
|
|
//ajax call ? |
738
|
|
|
if ($this->getRequest()->isXmlHttpRequest()) { |
|
|
|
|
739
|
|
|
return $response; |
740
|
|
|
} |
741
|
|
|
|
742
|
|
|
$this->flashMessenger()->addMessage( |
|
|
|
|
743
|
|
|
$this->getServiceLocator()->get('MvcTranslator')->translate('Your comment has been recorded') |
744
|
|
|
); |
745
|
|
|
|
746
|
|
|
return $this->redirect()->toUrl($this->getRequest()->getServer('HTTP_REFERER')); |
|
|
|
|
747
|
|
|
} |
748
|
|
|
|
749
|
|
|
public function ajaxRemoveCommentAction() |
750
|
|
|
{ |
751
|
|
|
// Call this for the session lock to be released (other ajax calls can then be made) |
752
|
|
|
session_write_close(); |
753
|
|
|
$commentId = $this->getEvent()->getRouteMatch()->getParam('comment'); |
754
|
|
|
$request = $this->getRequest(); |
755
|
|
|
$response = $this->getResponse(); |
756
|
|
|
|
757
|
|
|
if (! $this->game) { |
758
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
759
|
|
|
'success' => 0 |
760
|
|
|
))); |
761
|
|
|
|
762
|
|
|
return $response; |
763
|
|
|
} |
764
|
|
|
|
765
|
|
View Code Duplication |
if (!$this->zfcUserAuthentication()->hasIdentity()) { |
|
|
|
|
766
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
767
|
|
|
'success' => 0 |
768
|
|
|
))); |
769
|
|
|
} else { |
770
|
|
|
if ($request->isPost()) { |
771
|
|
|
if ($this->getGameService()->removeComment( |
772
|
|
|
$this->user, |
773
|
|
|
$this->getRequest()->getServer('REMOTE_ADDR'), |
|
|
|
|
774
|
|
|
$commentId |
775
|
|
|
)) { |
776
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
777
|
|
|
'success' => 1 |
778
|
|
|
))); |
779
|
|
|
} else { |
780
|
|
|
$response->setContent(\Zend\Json\Json::encode(array( |
781
|
|
|
'success' => 0 |
782
|
|
|
))); |
783
|
|
|
} |
784
|
|
|
} |
785
|
|
|
} |
786
|
|
|
|
787
|
|
|
return $response; |
788
|
|
|
} |
789
|
|
|
|
790
|
|
|
public function captchaAction() |
791
|
|
|
{ |
792
|
|
|
$response = $this->getResponse(); |
793
|
|
|
$response->getHeaders()->addHeaderLine('Content-Type', "image/png"); |
794
|
|
|
|
795
|
|
|
$id = $this->params('id', false); |
796
|
|
|
|
797
|
|
|
if ($id) { |
798
|
|
|
$image = './data/captcha/' . $id; |
799
|
|
|
|
800
|
|
|
if (file_exists($image) !== false) { |
801
|
|
|
$imagegetcontent = file_get_contents($image); |
802
|
|
|
|
803
|
|
|
$response->setStatusCode(200); |
804
|
|
|
$response->setContent($imagegetcontent); |
805
|
|
|
|
806
|
|
|
if (file_exists($image) === true) { |
807
|
|
|
unlink($image); |
808
|
|
|
} |
809
|
|
|
} |
810
|
|
|
} |
811
|
|
|
|
812
|
|
|
return $response; |
813
|
|
|
} |
814
|
|
|
|
815
|
|
|
public function sharePostAction() |
816
|
|
|
{ |
817
|
|
|
$statusMail = false; |
818
|
|
|
$message = ''; |
819
|
|
|
|
820
|
|
|
$postId = $this->getEvent()->getRouteMatch()->getParam('post'); |
821
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
822
|
|
|
|
823
|
|
|
$secretKey = strtoupper(substr(sha1(uniqid('pg_', true).'####'.time()), 0, 15)); |
824
|
|
|
$socialLinkUrl = $this->frontendUrl()->fromRoute( |
|
|
|
|
825
|
|
|
'postvote/post', |
826
|
|
|
array( |
827
|
|
|
'id' => $this->game->getIdentifier(), |
828
|
|
|
'post' => $post->getId(), |
829
|
|
|
), |
830
|
|
|
array('force_canonical' => true) |
831
|
|
|
).'?key='.$secretKey; |
832
|
|
|
// With core shortener helper |
833
|
|
|
$socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl); |
|
|
|
|
834
|
|
|
|
835
|
|
|
$form = $this->getServiceLocator()->get('playgroundgame_sharemail_form'); |
836
|
|
|
$form->setAttribute('method', 'post'); |
837
|
|
|
|
838
|
|
View Code Duplication |
if ($this->getRequest()->isPost()) { |
|
|
|
|
839
|
|
|
$data = $this->getRequest()->getPost()->toArray(); |
|
|
|
|
840
|
|
|
$form->setData($data); |
841
|
|
|
if ($form->isValid()) { |
842
|
|
|
$data['post'] = $post; |
843
|
|
|
$result = $this->getGameService()->sendShareMail($data, $this->game, $this->user, null, 'share-post'); |
844
|
|
|
if ($result) { |
845
|
|
|
$statusMail = true; |
846
|
|
|
$this->getGameService()->addShare($post); |
847
|
|
|
} |
848
|
|
|
} else { |
849
|
|
|
foreach ($form->getMessages() as $el => $errors) { |
850
|
|
|
foreach ($errors as $key => $message) { |
851
|
|
|
$message = $this->getServiceLocator()->get('MvcTranslator')->translate($message); |
852
|
|
|
} |
853
|
|
|
} |
854
|
|
|
} |
855
|
|
|
} |
856
|
|
|
|
857
|
|
|
$viewModel = $this->buildView($this->game); |
858
|
|
|
|
859
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
860
|
|
|
'statusMail' => $statusMail, |
861
|
|
|
'message' => $message, |
862
|
|
|
'form' => $form, |
863
|
|
|
'socialLinkUrl' => $socialLinkUrl, |
864
|
|
|
'post' => $post |
865
|
|
|
)); |
866
|
|
|
|
867
|
|
|
return $viewModel; |
868
|
|
|
} |
869
|
|
|
|
870
|
|
|
public function shareCommentAction() |
871
|
|
|
{ |
872
|
|
|
$statusMail = false; |
873
|
|
|
$message = ''; |
874
|
|
|
|
875
|
|
|
$commentId = $this->getEvent()->getRouteMatch()->getParam('comment'); |
876
|
|
|
$comment = $this->getGameService()->getPostVoteCommentMapper()->findById($commentId); |
877
|
|
|
|
878
|
|
|
$form = $this->getServiceLocator()->get('playgroundgame_sharemail_form'); |
879
|
|
|
$form->setAttribute('method', 'post'); |
880
|
|
|
|
881
|
|
View Code Duplication |
if ($this->getRequest()->isPost()) { |
|
|
|
|
882
|
|
|
$data = $this->getRequest()->getPost()->toArray(); |
|
|
|
|
883
|
|
|
$form->setData($data); |
884
|
|
|
if ($form->isValid()) { |
885
|
|
|
$data['comment'] = $comment; |
886
|
|
|
$subject = $this->getGameService()->getOptions()->getShareCommentSubjectLine(); |
887
|
|
|
$result = $this->getGameService()->sendShareMail($data, $this->game, $this->user, null, 'share-comment', null, array(), $subject); |
888
|
|
|
if ($result) { |
889
|
|
|
$statusMail = true; |
890
|
|
|
} |
891
|
|
|
} else { |
892
|
|
|
foreach ($form->getMessages() as $el => $errors) { |
893
|
|
|
foreach ($errors as $key => $message) { |
894
|
|
|
$message = $this->getServiceLocator()->get('MvcTranslator')->translate($message); |
895
|
|
|
} |
896
|
|
|
} |
897
|
|
|
} |
898
|
|
|
} |
899
|
|
|
|
900
|
|
|
$viewModel = $this->buildView($this->game); |
901
|
|
|
|
902
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
903
|
|
|
'statusMail' => $statusMail, |
904
|
|
|
'message' => $message, |
905
|
|
|
'form' => $form, |
906
|
|
|
'comment' => $comment |
907
|
|
|
)); |
908
|
|
|
|
909
|
|
|
return $viewModel; |
910
|
|
|
} |
911
|
|
|
|
912
|
|
|
public function shareAction() |
913
|
|
|
{ |
914
|
|
|
$statusMail = null; |
915
|
|
|
|
916
|
|
|
// Has the user finished the game ? |
917
|
|
|
$lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
918
|
|
|
|
919
|
|
|
if ($lastEntry === null) { |
920
|
|
|
return $this->redirect()->toUrl( |
921
|
|
|
$this->frontendUrl()->fromRoute( |
|
|
|
|
922
|
|
|
'postvote', |
923
|
|
|
array('id' => $this->game->getIdentifier()) |
924
|
|
|
) |
925
|
|
|
); |
926
|
|
|
} |
927
|
|
|
|
928
|
|
|
$post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntry)); |
929
|
|
|
|
930
|
|
|
$secretKey = strtoupper(substr(sha1(uniqid('pg_', true).'####'.time()), 0, 15)); |
931
|
|
|
$socialLinkUrl = $this->frontendUrl()->fromRoute( |
|
|
|
|
932
|
|
|
'postvote/post', |
933
|
|
|
array( |
934
|
|
|
'id' => $this->game->getIdentifier(), |
935
|
|
|
'post' => $post->getId(), |
936
|
|
|
), |
937
|
|
|
array('force_canonical' => true) |
938
|
|
|
).'?key='.$secretKey; |
939
|
|
|
// With core shortener helper |
940
|
|
|
$socialLinkUrl = $this->shortenUrl()->shortenUrl($socialLinkUrl); |
|
|
|
|
941
|
|
|
|
942
|
|
|
$form = $this->getServiceLocator()->get('playgroundgame_sharemail_form'); |
943
|
|
|
$form->setAttribute('method', 'post'); |
944
|
|
|
|
945
|
|
View Code Duplication |
if ($this->getRequest()->isPost()) { |
|
|
|
|
946
|
|
|
$data = $this->getRequest()->getPost()->toArray(); |
|
|
|
|
947
|
|
|
$form->setData($data); |
948
|
|
|
if ($form->isValid()) { |
949
|
|
|
$result = $this->getGameService()->sendShareMail($data, $this->game, $this->user, $lastEntry); |
950
|
|
|
if ($result) { |
951
|
|
|
$statusMail = true; |
952
|
|
|
} |
953
|
|
|
} |
954
|
|
|
} |
955
|
|
|
|
956
|
|
|
$viewModel = $this->buildView($this->game); |
957
|
|
|
|
958
|
|
View Code Duplication |
foreach ($post->getPostElements() as $element) { |
|
|
|
|
959
|
|
|
$fbShareImage = $this->frontendUrl()->fromRoute( |
|
|
|
|
960
|
|
|
'', |
961
|
|
|
array(), |
962
|
|
|
array('force_canonical' => true), |
963
|
|
|
false |
964
|
|
|
) . $element->getValue(); |
965
|
|
|
break; |
966
|
|
|
} |
967
|
|
|
|
968
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('og:image', $fbShareImage); |
|
|
|
|
969
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:card', "photo"); |
970
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:site', "@playground"); |
971
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:title', $this->game->getTwShareMessage()); |
972
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:description', ""); |
973
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:image', $fbShareImage); |
974
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('twitter:url', $socialLinkUrl); |
975
|
|
|
|
976
|
|
|
$viewModel->setVariables(array( |
|
|
|
|
977
|
|
|
'statusMail' => $statusMail, |
978
|
|
|
'form' => $form, |
979
|
|
|
'socialLinkUrl' => $socialLinkUrl, |
980
|
|
|
'post' => $post |
981
|
|
|
)); |
982
|
|
|
|
983
|
|
|
return $viewModel; |
984
|
|
|
} |
985
|
|
|
|
986
|
|
|
public function getGameService() |
987
|
|
|
{ |
988
|
|
|
if (!$this->gameService) { |
989
|
|
|
$this->gameService = $this->getServiceLocator()->get('playgroundgame_postvote_service'); |
990
|
|
|
} |
991
|
|
|
|
992
|
|
|
return $this->gameService; |
993
|
|
|
} |
994
|
|
|
} |
995
|
|
|
|
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: