| @@ 77-138 (lines=62) @@ | ||
| 74 | ); |
|
| 75 | } |
|
| 76 | ||
| 77 | public function editInstantWinAction() |
|
| 78 | { |
|
| 79 | $this->checkGame(); |
|
| 80 | ||
| 81 | $viewModel = new ViewModel(); |
|
| 82 | $viewModel->setTemplate('playground-game/instant-win/instantwin'); |
|
| 83 | ||
| 84 | $gameForm = new ViewModel(); |
|
| 85 | $gameForm->setTemplate('playground-game/game/game-form'); |
|
| 86 | ||
| 87 | $form = $this->getServiceLocator()->get('playgroundgame_instantwin_form'); |
|
| 88 | $form->setAttribute( |
|
| 89 | 'action', |
|
| 90 | $this->url()->fromRoute( |
|
| 91 | 'admin/playgroundgame/edit-instantwin', |
|
| 92 | array('gameId' => $this->game->getId()) |
|
| 93 | ) |
|
| 94 | ); |
|
| 95 | $form->setAttribute('method', 'post'); |
|
| 96 | ||
| 97 | if ($this->game->getFbAppId()) { |
|
| 98 | $appIds = $form->get('fbAppId')->getOption('value_options'); |
|
| 99 | $appIds[$this->game->getFbAppId()] = $this->game->getFbAppId(); |
|
| 100 | $form->get('fbAppId')->setAttribute('options', $appIds); |
|
| 101 | } |
|
| 102 | ||
| 103 | $gameOptions = $this->getAdminGameService()->getOptions(); |
|
| 104 | $gameStylesheet = $gameOptions->getMediaPath() . '/' . 'stylesheet_'. $this->game->getId(). '.css'; |
|
| 105 | if (is_file($gameStylesheet)) { |
|
| 106 | $values = $form->get('stylesheet')->getValueOptions(); |
|
| 107 | $values[$gameStylesheet] = 'Style personnalisé de ce jeu'; |
|
| 108 | ||
| 109 | $form->get('stylesheet')->setAttribute('options', $values); |
|
| 110 | } |
|
| 111 | ||
| 112 | $form->bind($this->game); |
|
| 113 | ||
| 114 | if ($this->getRequest()->isPost()) { |
|
| 115 | $data = array_replace_recursive( |
|
| 116 | $this->getRequest()->getPost()->toArray(), |
|
| 117 | $this->getRequest()->getFiles()->toArray() |
|
| 118 | ); |
|
| 119 | if (empty($data['prizes'])) { |
|
| 120 | $data['prizes'] = array(); |
|
| 121 | } |
|
| 122 | $result = $service->edit($data, $this->game, 'playgroundgame_instantwin_form'); |
|
| 123 | ||
| 124 | if ($result) { |
|
| 125 | return $this->redirect()->toRoute('admin/playgroundgame/list'); |
|
| 126 | } |
|
| 127 | } |
|
| 128 | ||
| 129 | $gameForm->setVariables(array('form' => $form, 'game' => $this->game)); |
|
| 130 | $viewModel->addChild($gameForm, 'game_form'); |
|
| 131 | ||
| 132 | return $viewModel->setVariables( |
|
| 133 | array( |
|
| 134 | 'form' => $form, |
|
| 135 | 'title' => 'Edit instant win', |
|
| 136 | ) |
|
| 137 | ); |
|
| 138 | } |
|
| 139 | ||
| 140 | public function listOccurrenceAction() |
|
| 141 | { |
|
| @@ 71-127 (lines=57) @@ | ||
| 68 | return $viewModel->setVariables(array('form' => $form, 'title' => 'Create Post & Vote')); |
|
| 69 | } |
|
| 70 | ||
| 71 | public function editPostVoteAction() |
|
| 72 | { |
|
| 73 | $this->checkGame(); |
|
| 74 | ||
| 75 | $viewModel = new ViewModel(); |
|
| 76 | $viewModel->setTemplate('playground-game/post-vote/postvote'); |
|
| 77 | ||
| 78 | $gameForm = new ViewModel(); |
|
| 79 | $gameForm->setTemplate('playground-game/game/game-form'); |
|
| 80 | ||
| 81 | $form = $this->getServiceLocator()->get('playgroundgame_postvote_form'); |
|
| 82 | $form->setAttribute( |
|
| 83 | 'action', |
|
| 84 | $this->url()->fromRoute( |
|
| 85 | 'admin/playgroundgame/edit-postvote', |
|
| 86 | array('gameId' => $this->game->getId()) |
|
| 87 | ) |
|
| 88 | ); |
|
| 89 | $form->setAttribute('method', 'post'); |
|
| 90 | ||
| 91 | if ($this->game->getFbAppId()) { |
|
| 92 | $appIds = $form->get('fbAppId')->getOption('value_options'); |
|
| 93 | $appIds[$this->game->getFbAppId()] = $this->game->getFbAppId(); |
|
| 94 | $form->get('fbAppId')->setAttribute('options', $appIds); |
|
| 95 | } |
|
| 96 | ||
| 97 | $gameOptions = $this->getAdminGameService()->getOptions(); |
|
| 98 | $gameStylesheet = $gameOptions->getMediaPath() . '/' . 'stylesheet_'. $game->getId(). '.css'; |
|
| 99 | if (is_file($gameStylesheet)) { |
|
| 100 | $values = $form->get('stylesheet')->getValueOptions(); |
|
| 101 | $values[$gameStylesheet] = 'Style personnalisé de ce jeu'; |
|
| 102 | ||
| 103 | $form->get('stylesheet')->setAttribute('options', $values); |
|
| 104 | } |
|
| 105 | ||
| 106 | $form->bind($this->game); |
|
| 107 | ||
| 108 | if ($this->getRequest()->isPost()) { |
|
| 109 | $data = array_replace_recursive( |
|
| 110 | $this->getRequest()->getPost()->toArray(), |
|
| 111 | $this->getRequest()->getFiles()->toArray() |
|
| 112 | ); |
|
| 113 | if (empty($data['prizes'])) { |
|
| 114 | $data['prizes'] = array(); |
|
| 115 | } |
|
| 116 | $result = $service->edit($data, $this->game, 'playgroundgame_postvote_form'); |
|
| 117 | ||
| 118 | if ($result) { |
|
| 119 | return $this->redirect()->toRoute('admin/playgroundgame/list'); |
|
| 120 | } |
|
| 121 | } |
|
| 122 | ||
| 123 | $gameForm->setVariables(array('form' => $form, 'game' => $this->game)); |
|
| 124 | $viewModel->addChild($gameForm, 'game_form'); |
|
| 125 | ||
| 126 | return $viewModel->setVariables(array('form' => $form, 'title' => 'Edit Post & Vote')); |
|
| 127 | } |
|
| 128 | ||
| 129 | public function modListAction() |
|
| 130 | { |
|
| @@ 193-243 (lines=51) @@ | ||
| 190 | return $viewModel->setVariables(array('form' => $form, 'title' => 'Create quiz')); |
|
| 191 | } |
|
| 192 | ||
| 193 | public function editQuizAction() |
|
| 194 | { |
|
| 195 | $this->checkGame(); |
|
| 196 | ||
| 197 | $viewModel = new ViewModel(); |
|
| 198 | $viewModel->setTemplate('playground-game/quiz/quiz'); |
|
| 199 | ||
| 200 | $gameForm = new ViewModel(); |
|
| 201 | $gameForm->setTemplate('playground-game/game/game-form'); |
|
| 202 | ||
| 203 | $form = $this->getServiceLocator()->get('playgroundgame_quiz_form'); |
|
| 204 | $form->setAttribute('action', $this->url()->fromRoute('admin/playgroundgame/edit-quiz', array('gameId' => $this->game->getId()))); |
|
| 205 | $form->setAttribute('method', 'post'); |
|
| 206 | ||
| 207 | if ($this->game->getFbAppId()) { |
|
| 208 | $appIds = $form->get('fbAppId')->getOption('value_options'); |
|
| 209 | $appIds[$this->game->getFbAppId()] = $this->game->getFbAppId(); |
|
| 210 | $form->get('fbAppId')->setAttribute('options', $appIds); |
|
| 211 | } |
|
| 212 | ||
| 213 | $gameOptions = $this->getAdminGameService()->getOptions(); |
|
| 214 | $gameStylesheet = $gameOptions->getMediaPath() . '/' . 'stylesheet_'. $game->getId(). '.css'; |
|
| 215 | if (is_file($gameStylesheet)) { |
|
| 216 | $values = $form->get('stylesheet')->getValueOptions(); |
|
| 217 | $values[$gameStylesheet] = 'Style personnalisé de ce jeu'; |
|
| 218 | ||
| 219 | $form->get('stylesheet')->setAttribute('options', $values); |
|
| 220 | } |
|
| 221 | ||
| 222 | $form->bind($this->game); |
|
| 223 | ||
| 224 | if ($this->getRequest()->isPost()) { |
|
| 225 | $data = array_replace_recursive( |
|
| 226 | $this->getRequest()->getPost()->toArray(), |
|
| 227 | $this->getRequest()->getFiles()->toArray() |
|
| 228 | ); |
|
| 229 | if (empty($data['prizes'])) { |
|
| 230 | $data['prizes'] = array(); |
|
| 231 | } |
|
| 232 | $result = $service->edit($data, $this->game, 'playgroundgame_quiz_form'); |
|
| 233 | ||
| 234 | if ($result) { |
|
| 235 | return $this->redirect()->toRoute('admin/playgroundgame/list'); |
|
| 236 | } |
|
| 237 | } |
|
| 238 | ||
| 239 | $gameForm->setVariables(array('form' => $form, 'game' => $this->game)); |
|
| 240 | $viewModel->addChild($gameForm, 'game_form'); |
|
| 241 | ||
| 242 | return $viewModel->setVariables(array('form' => $form, 'title' => 'Edit quiz')); |
|
| 243 | } |
|
| 244 | ||
| 245 | public function getAdminGameService() |
|
| 246 | { |
|