Archived
1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fiktivkod/application/modules/admin/controllers/BlogController.php
2011-02-26 14:15:01 +01:00

31 lines
No EOL
859 B
PHP

<?php
class Admin_BlogController extends Fiktiv_Controller_Action
{
public function indexAction()
{
// Load models
$posts = new ModelBlogPost();
// Get form
$form = $this->view->form = $this->_getCreateForm();
// Populate form
if ($this->_getParam('id', null)) {
$post = $posts->find($this->_getParam('id'))->current();
$form->populate($post->toArray());
}
// Save post
if ($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
$posts->createPost($form->getValues(), $this->_getParam('id', null));
#$this->_redirect('index');
}
}
protected function _getCreateForm()
{
require_once APPLICATION_PATH . '/forms/Admin_BlogCreate.php';
return new Admin_BlogCreate();
}
}