Created
October 2, 2012 19:29
-
-
Save Cacodaimon/3822739 to your computer and use it in GitHub Desktop.
Used in: http://cacodaemon.de/index.php?id=16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class BlogController extends Zend_Controller_Action | |
{ | |
public function indexAction() | |
{ | |
try { | |
$model = new Application_Model_Article; | |
$this->view->articles = $model->fetchAll(); | |
} | |
catch (Exception $e) { | |
$this->view->error = $e->getMessage(); | |
} | |
} | |
public function articleAction() | |
{ | |
$model = new Application_Model_Article; | |
$this->view->article = $model->find( | |
$this->getRequest()->getParam('_id') | |
); | |
$this->view->postCommentForm = new Application_Form_Comment(array( | |
'_id' => $model->_id, | |
)); | |
} | |
public function postcommentAction() | |
{ | |
$form = new Application_Form_Comment; | |
if (!$form->isValid($data = $this->getRequest()->getParams())) { | |
$form->populate($data); | |
$this->_redirect('/blog/', array('exit', true)); | |
} | |
$article = new Application_Model_Article; | |
$article->find($data['_id']); | |
$article->addComment(new Application_Model_Comment(array( | |
'text' => $data['text'], | |
'autor' => $data['autor'], | |
'date' => new MongoDate(time()), | |
))); | |
$this->_redirect('/blog/article/_id/' . $data['_id']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment