| @@ 16-59 (lines=44) @@ | ||
| 13 | */ |
|
| 14 | protected $adminGameService; |
|
| 15 | ||
| 16 | public function createPostVoteAction() |
|
| 17 | { |
|
| 18 | $service = $this->getAdminGameService(); |
|
| 19 | $viewModel = new ViewModel(); |
|
| 20 | $viewModel->setTemplate('playground-game/post-vote/postvote'); |
|
| 21 | ||
| 22 | $gameForm = new ViewModel(); |
|
| 23 | $gameForm->setTemplate('playground-game/game/game-form'); |
|
| 24 | ||
| 25 | $postVote = new PostVote(); |
|
| 26 | ||
| 27 | $form = $this->getServiceLocator()->get('playgroundgame_postvote_form'); |
|
| 28 | $form->bind($postVote); |
|
| 29 | $form->get('submit')->setAttribute('label', 'Add'); |
|
| 30 | $form->setAttribute( |
|
| 31 | 'action', |
|
| 32 | $this->url()->fromRoute( |
|
| 33 | 'admin/playgroundgame/create-postvote', |
|
| 34 | array('gameId' => 0) |
|
| 35 | ) |
|
| 36 | ); |
|
| 37 | $form->setAttribute('method', 'post'); |
|
| 38 | ||
| 39 | $request = $this->getRequest(); |
|
| 40 | if ($request->isPost()) { |
|
| 41 | $data = array_replace_recursive( |
|
| 42 | $this->getRequest()->getPost()->toArray(), |
|
| 43 | $this->getRequest()->getFiles()->toArray() |
|
| 44 | ); |
|
| 45 | if (empty($data['prizes'])) { |
|
| 46 | $data['prizes'] = array(); |
|
| 47 | } |
|
| 48 | $game = $service->create($data, $postVote, 'playgroundgame_postvote_form'); |
|
| 49 | if ($game) { |
|
| 50 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The game was created'); |
|
| 51 | ||
| 52 | return $this->redirect()->toRoute('admin/playgroundgame/list'); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | $gameForm->setVariables(array('form' => $form, 'game' => $postVote)); |
|
| 56 | $viewModel->addChild($gameForm, 'game_form'); |
|
| 57 | ||
| 58 | return $viewModel->setVariables(array('form' => $form, 'title' => 'Create Post & Vote')); |
|
| 59 | } |
|
| 60 | ||
| 61 | public function editPostVoteAction() |
|
| 62 | { |
|
| @@ 154-191 (lines=38) @@ | ||
| 151 | return $this->redirect()->toRoute('admin/playgroundgame/quiz-question-list', array('quizId'=>$quizId)); |
|
| 152 | } |
|
| 153 | ||
| 154 | public function createQuizAction() |
|
| 155 | { |
|
| 156 | $service = $this->getAdminGameService(); |
|
| 157 | $viewModel = new ViewModel(); |
|
| 158 | $viewModel->setTemplate('playground-game/quiz/quiz'); |
|
| 159 | ||
| 160 | $gameForm = new ViewModel(); |
|
| 161 | $gameForm->setTemplate('playground-game/game/game-form'); |
|
| 162 | ||
| 163 | $quiz = new Quiz(); |
|
| 164 | ||
| 165 | $form = $this->getServiceLocator()->get('playgroundgame_quiz_form'); |
|
| 166 | $form->bind($quiz); |
|
| 167 | $form->get('submit')->setAttribute('label', 'Add'); |
|
| 168 | $form->setAttribute('action', $this->url()->fromRoute('admin/playgroundgame/create-quiz', array('gameId' => 0))); |
|
| 169 | $form->setAttribute('method', 'post'); |
|
| 170 | ||
| 171 | $request = $this->getRequest(); |
|
| 172 | if ($request->isPost()) { |
|
| 173 | $data = array_replace_recursive( |
|
| 174 | $this->getRequest()->getPost()->toArray(), |
|
| 175 | $this->getRequest()->getFiles()->toArray() |
|
| 176 | ); |
|
| 177 | if (empty($data['prizes'])) { |
|
| 178 | $data['prizes'] = array(); |
|
| 179 | } |
|
| 180 | $game = $service->create($data, $quiz, 'playgroundgame_quiz_form'); |
|
| 181 | if ($game) { |
|
| 182 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The game was created'); |
|
| 183 | ||
| 184 | return $this->redirect()->toRoute('admin/playgroundgame/list'); |
|
| 185 | } |
|
| 186 | } |
|
| 187 | $gameForm->setVariables(array('form' => $form, 'game' => $quiz)); |
|
| 188 | $viewModel->addChild($gameForm, 'game_form'); |
|
| 189 | ||
| 190 | return $viewModel->setVariables(array('form' => $form, 'title' => 'Create quiz')); |
|
| 191 | } |
|
| 192 | ||
| 193 | public function editQuizAction() |
|
| 194 | { |
|