From 44fb3e694c4247a963f4feec6e390955ff7fcbf9 Mon Sep 17 00:00:00 2001 From: Fredric N Date: Sat, 26 Feb 2011 14:16:40 +0100 Subject: [PATCH] some blog work --- .../blog/controllers/ArchiveController.php | 10 +++--- .../blog/controllers/IndexController.php | 6 ++-- .../blog/views/scripts/archive/filter.phtml | 33 +++++++++---------- .../blog/views/scripts/archive/index.phtml | 2 +- .../blog/views/scripts/index/latest.phtml | 32 +++++++++++++----- .../blog/views/scripts/index/read.phtml | 6 ++-- 6 files changed, 54 insertions(+), 35 deletions(-) diff --git a/application/modules/blog/controllers/ArchiveController.php b/application/modules/blog/controllers/ArchiveController.php index 9391816..ad2aa5f 100644 --- a/application/modules/blog/controllers/ArchiveController.php +++ b/application/modules/blog/controllers/ArchiveController.php @@ -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']); } - } } \ No newline at end of file diff --git a/application/modules/blog/controllers/IndexController.php b/application/modules/blog/controllers/IndexController.php index 4fd063f..016a211 100644 --- a/application/modules/blog/controllers/IndexController.php +++ b/application/modules/blog/controllers/IndexController.php @@ -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')); diff --git a/application/modules/blog/views/scripts/archive/filter.phtml b/application/modules/blog/views/scripts/archive/filter.phtml index 38844f6..540d4f9 100644 --- a/application/modules/blog/views/scripts/archive/filter.phtml +++ b/application/modules/blog/views/scripts/archive/filter.phtml @@ -1,29 +1,28 @@ -« translate('u:back') ?> +« translate('u:back') ?> posts as $post) : ?>
-

getTitle() ?>

-

getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->getFirstName() ?>

+

title ?>

+

getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->firstName ?>

- getContent() ?> + content ?>
- getTags()) { + hasTags()): ?> - echo '
'; +
+ getTags()->count(); + for ($i = 0; $i < $count-1; $i++): ?> + getTags()->getRow($i)->name ?>, + + getTags()->getRow($i)->name ?> +
- $tagList = ''; - foreach ($post->getTags() as $k => $t) { - $tagList .= ''.$t.', '; - } - - echo substr($tagList,0,-2); - - echo '
'; - } - ?> +
\ No newline at end of file diff --git a/application/modules/blog/views/scripts/archive/index.phtml b/application/modules/blog/views/scripts/archive/index.phtml index 6713739..0cde269 100644 --- a/application/modules/blog/views/scripts/archive/index.phtml +++ b/application/modules/blog/views/scripts/archive/index.phtml @@ -4,6 +4,6 @@ \ No newline at end of file diff --git a/application/modules/blog/views/scripts/index/latest.phtml b/application/modules/blog/views/scripts/index/latest.phtml index 10a9c6f..1e99fb1 100644 --- a/application/modules/blog/views/scripts/index/latest.phtml +++ b/application/modules/blog/views/scripts/index/latest.phtml @@ -2,18 +2,34 @@

translate('BLOG_LATEST_INTRO') ?>

+setHighlighter('geshi'); +?> + + posts as $post) : ?>
-

getTitle() ?>

-

getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->getFirstName() ?>

+

title ?>

+

getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->firstName ?>

- getContent() ?> + replaceCodeblock($post->content) ?>
- getTags()) : ?> -
- tagList($post->getTags(), array('controller' => 'archive', 'action' => 'filter'), 'blog') ?> -
- + hasTags()): ?> + +
+ getTags()->count(); + for ($i = 0; $i < $count-1; $i++): ?> + getTags()->getRow($i)->name ?>, + + getTags()->getRow($i)->name ?> +
+ + +
\ No newline at end of file diff --git a/application/modules/blog/views/scripts/index/read.phtml b/application/modules/blog/views/scripts/index/read.phtml index 5b5460c..2b3e5d2 100644 --- a/application/modules/blog/views/scripts/index/read.phtml +++ b/application/modules/blog/views/scripts/index/read.phtml @@ -5,9 +5,9 @@ « translate('u:back') ?>
-

post->getTitle() ?>

-

post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$this->post->getPubDate()->toString('HH:mm').' '.$this->post->getAuthor()->getFirstName() ?>

-
post->getContent() ?>
+

post->title ?>

+

post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$this->post->getPubDate()->toString('HH:mm').' '.$this->translate('by').' '.$this->post->getAuthor()->firstName ?>

+
post->content ?>
\ No newline at end of file