Archived
1
0
Fork 0

some blog work

This commit is contained in:
Fredric N 2011-02-26 14:16:40 +01:00
parent a60ffcee92
commit 44fb3e694c
6 changed files with 54 additions and 35 deletions

View file

@ -4,7 +4,8 @@ class Blog_ArchiveController extends Fiktiv_Controller_Action
{
public function indexAction()
{
$this->view->postsByMonthYear = $this->dataService->BlogPost->findByMonth();
$blogposts = new ModelBlogPost();
$this->view->postsByMonthYear = $blogposts->findByMonth();
}
public function filterAction()
@ -12,15 +13,16 @@ class Blog_ArchiveController extends Fiktiv_Controller_Action
$params = $this->_getAllParams();
$blogposts = new ModelBlogPost();
if (array_key_exists('date', $params)) {
$this->view->posts = $this->dataService->BlogPost->findByDate($params['date']);
$this->view->posts = $blogposts->findByDate($params['date'], '%Y-%MM');
} else if (array_key_exists('tag', $params)) {
$this->view->posts = $this->dataService->BlogPost->findByTag($params['tag']);
$this->view->posts = $blogposts->findByTag($params['tag']);
}
}
}

View file

@ -10,7 +10,8 @@ class Blog_IndexController extends Fiktiv_Controller_Action
public function latestAction()
{
// Fetch last ten posts
$this->view->posts = $this->dataService->BlogPost->findAll(10);
$posts = new ModelBlogPost();
$this->view->posts = $posts->fetchAll(null, 'pubDate DESC', 10);
}
public function readableAction()
@ -20,7 +21,8 @@ class Blog_IndexController extends Fiktiv_Controller_Action
public function readAction()
{
$this->view->post = $this->dataService->BlogPost->findByPermalink($this->_getParam('id', null));
$posts = new ModelBlogPost();
$this->view->post = $posts->findByPermlink($this->_getParam('id', null));
if (!$this->view->post)
$this->_redirect(array('action' => 'latest'));

View file

@ -1,29 +1,28 @@
<a href="<?=$this->url(array('action' => 'latest', 'id' => ''), 'blog-default') ?>">« <?=$this->translate('u:back') ?></a>
<a href="<?=$this->url(array('controller' => 'archive'), 'blog', true) ?>">« <?=$this->translate('u:back') ?></a>
<?php foreach($this->posts as $post) : ?>
<div class="blogpost">
<h3><a href="<?=$this->url(array('action' => 'read','id' => $post->getPermalink()),'blog-default') ?>"><?=$post->getTitle() ?></a></h3>
<p class="publish"><?=$post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->getFirstName() ?></p>
<h3><a href="<?=$this->url(array('action' => 'read','id' => $post->permlink),'blog-default') ?>"><?=$post->title ?></a></h3>
<p class="publish"><?=$post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->firstName ?></p>
<div class="content">
<?=$post->getContent() ?>
<?=$post->content ?>
</div>
<?php
if ($post->getTags()) {
<?php if ($post->hasTags()): ?>
echo '<div class="tags">';
<div class="tags">
<?php
$count = $post->getTags()->count();
for ($i = 0; $i < $count-1; $i++): ?>
<a href="#"><?=$post->getTags()->getRow($i)->name ?></a>,
<?php
endfor;
?>
<a href="#"><?=$post->getTags()->getRow($i)->name ?></a>
</div>
$tagList = '';
foreach ($post->getTags() as $k => $t) {
$tagList .= '<a href="'.$this->url(array('controller' => 'archive','action' => 'filter', 'tag' => $t), 'blog').'">'.$t.'</a>, ';
}
echo substr($tagList,0,-2);
echo '</div>';
}
?>
<?php endif; ?>
</div>
<?php endforeach; ?>

View file

@ -4,6 +4,6 @@
<ul class="custom">
<?php foreach($this->postsByMonthYear as $month): ?>
<li><a href="<?=$this->url(array('action' => 'filter', 'date' => $month['Date']), 'blog') ?>"><?=$this->translate($month['Month']) ?></a></li>
<li><a href="<?=$this->url(array('action' => 'filter', 'date' => $month['Date']), 'blog') ?>"><?=$this->translate('uw:'.$month['Month']) ?></a></li>
<?php endforeach; ?>
</ul>

View file

@ -2,18 +2,34 @@
<p><?=$this->translate('BLOG_LATEST_INTRO') ?></p>
<?php
$hl = new Fiktiv_Highlighter();
$hl->setHighlighter('geshi');
?>
<?php foreach($this->posts as $post) : ?>
<div class="blogpost">
<h3><a href="<?=$this->url(array('action' => 'read','id' => $post->getPermalink()),'blog-default') ?>"><?=$post->getTitle() ?></a></h3>
<p class="publish"><?=$post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->getFirstName() ?></p>
<h3><a href="<?=$this->url(array('action' => 'read','id' => $post->permlink),'blog-default') ?>"><?=$post->title ?></a></h3>
<p class="publish"><?=$post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->firstName ?></p>
<div class="content">
<?=$post->getContent() ?>
<?= $hl->replaceCodeblock($post->content) ?>
</div>
<?php if ($post->getTags()) : ?>
<div class="tags">
<?=$this->tagList($post->getTags(), array('controller' => 'archive', 'action' => 'filter'), 'blog') ?>
</div>
<?php endif ?>
<?php if ($post->hasTags()): ?>
<div class="tags">
<?php
$count = $post->getTags()->count();
for ($i = 0; $i < $count-1; $i++): ?>
<a href="#"><?=$post->getTags()->getRow($i)->name ?></a>,
<?php
endfor;
?>
<a href="#"><?=$post->getTags()->getRow($i)->name ?></a>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>

View file

@ -5,9 +5,9 @@
<a href="<?=$this->url(array('action' => 'latest', 'id' => ''), 'blog-default') ?>">« <?=$this->translate('u:back') ?></a>
<div class="blogpost">
<h1><?=$this->post->getTitle() ?></h1>
<p class="publish"><?=$this->post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$this->post->getPubDate()->toString('HH:mm').' '.$this->post->getAuthor()->getFirstName() ?></p>
<div class="content"><?=$this->post->getContent() ?></div>
<h1><?=$this->post->title ?></h1>
<p class="publish"><?=$this->post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$this->post->getPubDate()->toString('HH:mm').' '.$this->translate('by').' '.$this->post->getAuthor()->firstName ?></p>
<div class="content"><?=$this->post->content ?></div>
</div>
<?php endif; ?>