public function run() { if ($this->Environment->method == 'GET') { return new colesoControllerExecResult($this->renderForm()); } $errStatus = false; if ($this->Environment->method == 'POST') { if (!colesoToken::checkValid()) { throw new Exception('Invalid token'); } try { $bookshelfData = $this->loadData($this->bookshelfFields); $bookData = $this->loadData($this->bookFields, array('title' => 'book_title')); if (!$bookshelfData['key']) { throw new bookCreationException('You should assign keyword value'); } $this->saveBookshelfPosition($bookshelfData); if ($bookshelfData['separator'] == '') { $this->saveBook($bookData, $bookshelfData['key']); } } catch (bookCreationException $e) { $data = array('errMessage' => $e->getMessage()); $data = array_merge($data, $bookshelfData); $bookData['book_title'] = $bookData['title']; unset($bookData['title']); $data = array_merge($data, $bookData); return new colesoControllerExecResult($this->renderForm($data)); } return new colesoControllerRedirect('./'); } throw new Exception('Invalid HTTP method'); }
function executeSave() { if ($this->useToken) { if (!colesoToken::checkValid()) { throw new Exception('Invalid token'); } } $content = $this->Environment->getPostVar('content'); $this->savePageContent($content); return new colesoControllerRedirect($this->buildRedirectAfterSaveURL()); }