Development

/plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/lib/Basesympal_blogActions.class.php

You must first sign up to be able to contribute.

root/plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/lib/Basesympal_blogActions.class.php

Revision 27774, 2.1 kB (checked in by weaverryan, 3 years ago)

[1.4][sfSympalBlogPlugin][1.0] Changing function call to be compatible with changes to sfSympalTagsPlugin due to r27773

Line 
1 <?php
2
3 /**
4  * Base actions for the sfSympalBlogPlugin sympal_blog module.
5  *
6  * @package     sfSympalBlogPlugin
7  * @subpackage  sympal_blog
8  * @author      Your name here
9  * @version     SVN: $Id: BaseActions.class.php 12534 2008-11-01 13:38:27Z Kris.Wallsmith $
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     // setup the page
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
Note: See TracBrowser for help on using the browser.