Exemplo n.º 1
0
 /**
  * View blog category
  */
 public function categoryAction()
 {
     if (!($alias = $this->_getParam('alias'))) {
         throw new Zend_Controller_Action_Exception('Page not found');
     }
     $category = new Blog_Model_Category_Manager();
     if (!($row = $category->getByAlias($alias))) {
         throw new Zend_Controller_Action_Exception('Blog not found');
     }
     $post = new Blog_Model_Post_Table();
     $source = $post->getSelect($row);
     $paginator = Zend_Paginator::factory($source);
     $paginator->getView()->route = 'blogcategory';
     $paginator->setItemCountPerPage($this->_itemsPerPage);
     $paginator->setCurrentPageNumber($this->_getParam('page'));
     $this->view->paginator = $paginator;
     $this->view->category = $row;
     $this->render('index');
 }
Exemplo n.º 2
0
 /**
  * Category blog rss
  *
  * @throws Zend_Controller_Action_Exception
  */
 public function categoryAction()
 {
     $limit = 10;
     if (!($alias = $this->_getParam('alias'))) {
         throw new Zend_Controller_Action_Exception('Page not found');
     }
     $category = new Blog_Model_Category_Manager();
     if (!($row = $category->getByAlias($alias))) {
         throw new Zend_Controller_Action_Exception('Blog not found');
     }
     $url = $this->_helper->url;
     $serverUrl = $this->_request->getScheme() . '://' . $this->_request->getHttpHost();
     $title = $row->title . " Blog Rss Feed";
     $link = $url->url(array('alias' => $row->alias), 'blogcategory');
     $feed = new Zend_Feed_Writer_Feed();
     $feed->setTitle($title);
     $feed->setLink($serverUrl . $link);
     $feed->setFeedLink('http://www.example.com/atom', 'atom');
     $feed->addAuthor(array('name' => 'Blog Owner Name', 'email' => null, 'uri' => $serverUrl));
     $posts = new Blog_Model_Post_Table();
     $select = $posts->getSelect($row);
     $feed->setDateModified(time());
     foreach ($posts->fetchAll($select->limit($limit)) as $i => $row) {
         if (0 == $i) {
             $feed->setDateModified(strtotime($row->updated));
         }
         $postUrl = $url->url(array('alias' => $row->alias), 'blogpost');
         $entry = $feed->createEntry();
         $entry->setTitle($row->title);
         $entry->setLink($serverUrl . $postUrl);
         $entry->addAuthor($row->login, null, null);
         $entry->setDateModified(strtotime($row->updated));
         $entry->setDateCreated(strtotime($row->published));
         $entry->setDescription($row->teaser);
         $feed->addEntry($entry);
     }
     echo $feed->export('atom');
 }