Example #1
0
 protected function _category()
 {
     $category = new Zend_Form_Element_Select('categoryId');
     $category->setLabel('categoryId');
     $category->setRequired(true);
     $cats = new Forum_Model_Category_Manager();
     foreach ($cats->getAll() as $cat) {
         $category->addMultiOption($cat->id, $cat->title);
     }
     return $category;
 }
Example #2
0
 /**
  * Category Combobox
  *
  * @return Zend_Form_Element_Select
  */
 protected function _category()
 {
     $categories = new Forum_Model_Category_Manager();
     $options = array();
     foreach ($categories->getAll() as $category) {
         $options[$category->id] = $category->title;
     }
     $element = new Zend_Form_Element_Select('categoryId');
     $element->setLabel('Category')->setRequired(true)->addMultioptions($options)->setAttribs(array('class' => 'span2'));
     return $element;
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * 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');
 }
Example #5
0
 public function testEditWithDataAction()
 {
     $table = new Forum_Model_Post_Table();
     $manager = new Forum_Model_Category_Manager();
     $rootCat = $manager->getRoot();
     $cat = $manager->getDbTable()->createRow($this->_fixture['category']);
     $rootCat->addChild($cat);
     $post = $table->createRow($this->_fixture['post']);
     $post->save();
     $this->_doLogin();
     $this->request->setMethod('POST')->setPost(array('title' => 'tttttttt', 'body' => 'tttttttt', 'categoryId' => 33, 'status' => 'active'));
     $this->dispatch('/forum/post/edit/id/45');
     $this->assertModule('forum');
     $this->assertController('post');
     $this->assertAction('edit');
     $this->assertRedirect();
     $post->delete();
     $cat->delete();
 }