| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
abstract class Basesympal_blogActions extends sfActions |
|---|
| 12 |
{ |
|---|
| 13 |
|
|---|
| 14 |
* An action that filters posts by year and month |
|---|
| 15 |
*/ |
|---|
| 16 |
public function executeMonth(sfWebRequest $request) |
|---|
| 17 |
{ |
|---|
| 18 |
$month = $request->getParameter('m'); |
|---|
| 19 |
$year = $request->getParameter('y'); |
|---|
| 20 |
|
|---|
| 21 |
$this->menuItem = $this->getBlogMenuItem(); |
|---|
| 22 |
$this->pager = Doctrine::getTable('sfSympalBlogPost')->retrieveBlogMonth($month, $year); |
|---|
| 23 |
$this->content = $this->pager->getResults(); |
|---|
| 24 |
|
|---|
| 25 |
$this->breadcrumbsTitle = date('M Y', strtotime($month.'/01/'.$year)); |
|---|
| 26 |
$this->title = 'Posts for the month of ' . $this->breadcrumbsTitle; |
|---|
| 27 |
|
|---|
| 28 |
$this->setTemplate('list'); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
* An action that filters posts by tags. This requires the sfSympalTagsPlugin |
|---|
| 33 |
*/ |
|---|
| 34 |
public function executeTag(sfWebRequest $request) |
|---|
| 35 |
{ |
|---|
| 36 |
if (!in_array('sfSympalBlogPlugin', $this->getSympalContext()->getSympalConfiguration()->getInstalledPlugins())) |
|---|
| 37 |
{ |
|---|
| 38 |
throw new sfException('sympal_blog/tag action requires sfSympalBlogPlugin to be installed'); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
$tag = $request->getParameter('tag'); |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
$q = Doctrine::getTable('sfSympalTag')->getContentQueryByTag('sfSympalBlogPost', $tag); |
|---|
| 45 |
$q->orderBy('c.date_published DESC'); |
|---|
| 46 |
|
|---|
| 47 |
$this->pager = new sfDoctrinePager('sfSympalContent', sfSympalConfig::get('rows_per_page')); |
|---|
| 48 |
$this->pager->setQuery($q); |
|---|
| 49 |
$this->pager->init(); |
|---|
| 50 |
|
|---|
| 51 |
$this->menuItem = $this->getBlogMenuItem(); |
|---|
| 52 |
$this->content = $this->pager->getResults(); |
|---|
| 53 |
|
|---|
| 54 |
$this->breadcrumbsTitle = $tag; |
|---|
| 55 |
$this->title = sprintf('Posts tagged with "%s"', $tag); |
|---|
| 56 |
|
|---|
| 57 |
$this->setTemplate('list'); |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
* Returns the default blog menu item so that the breadcrumbs can be |
|---|
| 62 |
* properly rendered |
|---|
| 63 |
* |
|---|
| 64 |
* @return sfSympalMenuItem |
|---|
| 65 |
*/ |
|---|
| 66 |
protected function getBlogMenuItem() |
|---|
| 67 |
{ |
|---|
| 68 |
return Doctrine::getTable('sfSympalMenuItem')->findOneBySlug('blog'); |
|---|
| 69 |
} |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|