コード例 #1
0
ファイル: IndexController.php プロジェクト: shahmaulik/zfcore
 /**
  * Category
  */
 public function categoryAction()
 {
     if (!($alias = $this->_getParam('alias'))) {
         throw new Zend_Controller_Action_Exception('Page not found');
     }
     $manager = new Forum_Model_Category_Manager();
     if (!($category = $manager->getByAlias($alias))) {
         throw new Zend_Controller_Action_Exception('Category not found');
     }
     $this->view->category = $category;
     $this->view->categories = $category->getAllChildren();
     $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;
 }
コード例 #2
0
 public function tearDown()
 {
     $table = new Users_Model_User_Table();
     $table->delete('1');
     /* delete all */
     $table = new Forum_Model_Post_Table();
     $table->delete('1');
     /* delete all */
     //        $table = new Comments_Model_Comment_Table();
     //        $table->delete('1'); /* delete all */
     $table = new Categories_Model_Category_Table();
     $table->delete('id = 33');
     parent::tearDown();
 }
コード例 #3
0
ファイル: RssController.php プロジェクト: shahmaulik/zfcore
 /**
  * Post forum rss
  *
  * @todo should return comments of topic
  * @throws Zend_Controller_Action_Exception
  */
 public function postAction()
 {
     if (!($postId = $this->_getParam('id'))) {
         throw new Zend_Controller_Action_Exception('Topic not found');
     }
     $posts = new Forum_Model_Post_Table();
     if (!($row = $posts->getByid($postId))) {
         throw new Zend_Controller_Action_Exception('Topic not found');
     }
     $url = $this->_helper->url;
     $serverUrl = $this->_request->getScheme() . '://' . $this->_request->getHttpHost();
     $title = $row->title . " // Comments RSS Feed";
     $link = $url->url(array('id' => $row->id), 'forumpost');
     $feed = new Zend_Feed_Writer_Feed();
     $feed->setTitle($title);
     $feed->setLink($serverUrl . $link);
     $feed->setDescription($row->getTeaser());
     $feed->setFeedLink($serverUrl . $url->url(array('module' => 'forum')), 'atom');
     $feed->addAuthor(array('name' => 'Forum Owner Name', 'email' => null, 'uri' => $serverUrl));
     $feed->setDateModified(time());
     echo $feed->export('atom');
 }
コード例 #4
0
ファイル: PostController.php プロジェクト: shahmaulik/zfcore
 /**
  * Edit post
  *
  * @throws Zend_Controller_Action_Exception
  */
 public function editAction()
 {
     if (!($postId = $this->_getParam('id'))) {
         throw new Zend_Controller_Action_Exception('Topic not found');
     }
     $posts = new Forum_Model_Post_Table();
     if (!($post = $posts->getById($postId))) {
         throw new Zend_Controller_Action_Exception('Topic not found');
     }
     if (!$post->isOwner()) {
         throw new Zend_Controller_Action_Exception('Access is forbidden');
     }
     $form = new Forum_Form_Post_Edit();
     $form->populate($post->toArray());
     if ($this->getRequest()->isPost() && $form->isValid($this->_getAllParams())) {
         $post->setFromArray($form->getValues());
         $post->save();
         $this->_helper->flashMessenger->addMessage('Topic was saved');
         $this->_helper->redirector->gotoRoute(array('id' => $post->id), 'forumpost');
     }
     $this->view->form = $form;
 }