Updating blog administration
This commit is contained in:
parent
b2c54ec874
commit
3b4d093389
6 changed files with 52 additions and 14 deletions
|
|
@ -4,18 +4,23 @@ class Admin_BlogController extends Fiktiv_Controller_Action
|
|||
{
|
||||
public function indexAction()
|
||||
{
|
||||
// Load models
|
||||
$posts = new ModelBlogPost();
|
||||
|
||||
// Get form
|
||||
$form = $this->view->form = $this->_getCreateForm();
|
||||
|
||||
if ($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
|
||||
$this->_savePost($form);
|
||||
// Populate form
|
||||
if ($this->_getParam('id', null)) {
|
||||
$post = $posts->find($this->_getParam('id'))->current();
|
||||
$form->populate($post->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
private function _savePost($form)
|
||||
{
|
||||
$post = new BlogPost($form->getValues());
|
||||
//$this->dataService->BlogPost->save($post);
|
||||
Zend_Debug::dump($post);
|
||||
// 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()
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class Admin_IndexController extends Fiktiv_Controller_Action
|
|||
|
||||
public function indexAction()
|
||||
{
|
||||
|
||||
$posts = new ModelBlogPost();
|
||||
$this->view->posts = $posts->fetchAll();
|
||||
}
|
||||
}
|
||||
|
|
@ -5,19 +5,28 @@
|
|||
<?=$this->headTitle() . "\n" /* Newline for pretty source :) */ ?>
|
||||
<?=$this->headMeta() . "\n" /* Newline for pretty source :) */ ?>
|
||||
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl()?>/css/reset.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl()?>/css/default.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl()?>/fancybox/jquery.fancybox-1.3.1.css" media="screen" />
|
||||
<script type="text/javascript" src="<?=$this->baseUrl()?>/js/nicEdit/nicEdit.js"></script>
|
||||
<?=$this->headScript() ?>
|
||||
<script type="text/javascript" src="<?=$this->baseUrl()?>/fancybox/jquery.fancybox-1.3.1.pack.js"></script>
|
||||
|
||||
<?=$this->fancybox()->headScript() ?>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper" class="small">
|
||||
|
||||
<ul style="margin-bottom: 40px;">
|
||||
<li><a href="<?=$this->url(array('controller' => 'index'), 'admin', true) ?>">Dashboard</a></li>
|
||||
<li><a href="<?=$this->url(array('controller' => 'blog'), 'admin', true) ?>">Skapa ny blogpost</a></li>
|
||||
</ul>
|
||||
<div id="header">
|
||||
<a href="<?=$this->baseUrl() ?>/"><span id="logo"></span></a>
|
||||
</div>
|
||||
|
||||
<div id="nav">
|
||||
<ul>
|
||||
<li><a href="<?=$this->url(array('controller' => 'index'), 'default', true) ?>">« Back to the site</a></li>
|
||||
<li><a href="<?=$this->url(array('controller' => 'index'), 'admin', true) ?>">Dashboard</a></li>
|
||||
<li><a href="<?=$this->url(array('controller' => 'blog'), 'admin', true) ?>">Skapa ny blogpost</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<?=$this->layout()->content ?>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,13 @@
|
|||
<h1>Blog funkis</h1>
|
||||
|
||||
<?php $this->headScript()->captureStart() ?>
|
||||
|
||||
bkLib.onDomLoaded(function() {
|
||||
$j = jQuery.noConflict();
|
||||
|
||||
area1 = new nicEditor({iconsPath : '<?=$this->baseUrl() ?>/img/nicEditorIcons.gif', fullPanel : true}).panelInstance('content',{hasPanel : true});
|
||||
});
|
||||
|
||||
<?php $this->headScript()->captureEnd() ?>
|
||||
|
||||
<?=$this->form ?>
|
||||
|
|
@ -2,3 +2,9 @@
|
|||
|
||||
|
||||
|
||||
<h1>Posts</h1>
|
||||
<ul class="custom">
|
||||
<?php foreach ($this->posts as $post): ?>
|
||||
<li><a href="<?=$this->url(array('controller' => 'blog', 'id' => $post->id), 'admin', true) ?>"><?=$post->title ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
|
|
|||
Reference in a new issue