/** * Category */ public function listAction() { if (!($categoryAlias = $this->_getParam('alias'))) { throw new Zend_Controller_Action_Exception('Page not found'); } $manager = new Forum_Model_Category_Manager(); if (!($category = $manager->getByAlias($categoryAlias))) { throw new Zend_Controller_Action_Exception('Category not found'); } $posts = new Forum_Model_Post_Table(); $this->view->posts = $posts->getLastPosts(); $select = $posts->getPostsSelect($category->id); $paginator = Zend_Paginator::factory($select); $paginator->setItemCountPerPage(20); $paginator->setCurrentPageNumber($this->_getParam('page')); $this->view->paginator = $paginator; }
/** * Category forum rss * * @throws Zend_Controller_Action_Exception */ public function categoryAction() { $limit = 10; if (!($alias = $this->_getParam('alias'))) { throw new Zend_Controller_Action_Exception('Forum not found'); } $category = new Forum_Model_Category_Manager(); if (!($row = $category->getByAlias($alias))) { throw new Zend_Controller_Action_Exception('Forum not found'); } $url = $this->_helper->url; $serverUrl = $this->_request->getScheme() . '://' . $this->_request->getHttpHost(); $title = $row->title . " // Topics RSS Feed"; $link = $url->url(array('alias' => $row->alias), 'forumcategory'); $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($title); $feed->setLink($serverUrl . $link); $feed->setFeedLink($serverUrl . $url->url(array('module' => 'forum')), 'atom'); $feed->addAuthor(array('name' => 'Forum Owner Name', 'email' => null, 'uri' => $serverUrl)); $posts = new Forum_Model_Post_Table(); $select = $posts->getPostsSelect($row->id); $select->limit($limit); $feed->setDateModified(time()); foreach ($posts->fetchAll($select) as $i => $row) { if (0 == $i) { $feed->setDateModified(strtotime($row->updated)); } $postUrl = $url->url(array('id' => $row->id), 'forumpost'); $entry = $feed->createEntry(); $entry->setTitle($row->title); $entry->setLink($serverUrl . $postUrl); $entry->addAuthor($row->author, null, null); $entry->setDateModified(strtotime($row->updated)); $entry->setDateCreated(strtotime($row->created)); $entry->setDescription($row->getTeaser()); $feed->addEntry($entry); } echo $feed->export('atom'); }