/** * Create mail body element (text) * * @return object Zend_Form_Element_Text */ protected function _parent() { $element = new Zend_Form_Element_Select('parentId'); $element->setLabel('Parent Category')->setAttribs(array('class' => 'span4'))->setRequired(false); $element->addMultiOption('', ''); $categories = new Categories_Model_Category_Table(); $select = $categories->select()->order('path'); foreach ($categories->fetchAll($select) as $row) { $element->addMultiOption($row->id, str_repeat("…", $row->level) . " " . $row->title); } return $element; }
/** * View post * * @throws Zend_Controller_Action_Exception */ public function indexAction() { if (!($postId = $this->_getParam('id'))) { $this->_forwardNotFound(); return; } $posts = new Forum_Model_Post_Table(); if (!($post = $posts->getById($postId))) { $this->_forwardNotFound(); return; } $users = new Users_Model_User_Table(); $this->view->author = $users->getById($post->userId); $categories = new Categories_Model_Category_Table(); $this->view->category = $categories->getById($post->categoryId); /** update count view */ $post->incViews(); $this->view->post = $post; }
/** * View post * * @throws Zend_Controller_Action_Exception */ public function indexAction() { if (!($alias = $this->_getParam('alias'))) { $this->_forwardNotFound(); return; } $posts = new Blog_Model_Post_Table(); if (!($row = $posts->getByAlias($alias))) { $this->_forwardNotFound(); return; } $users = new Users_Model_User_Table(); $this->view->user = $users->getById($row->userId); $categories = new Categories_Model_Category_Table(); $this->view->category = $categories->getById($row->categoryId); /** update count view */ $row->incViews(); $this->view->row = $row; $this->view->page = $this->_getParam('page'); }
/** * Get Zend_Db_Table_Select * * @param object|integer $category * @param integer $author * @param string $date * @return Zend_Db_Table_Select */ public function getSelect($category = null, $author = null, $date = 'NOW') { $users = new Users_Model_User_Table(); $categories = new Categories_Model_Category_Table(); $select = $this->select()->setIntegrityCheck(false); $select->from(array('p' => $this->_name), array('*'))->joinLeft(array('u' => $users->info('name')), 'p.userId = u.id', array('login'))->joinLeft(array('c' => $categories->info('name')), 'c.id = p.categoryId', array('categoryTitle' => 'title', 'categoryAlias' => 'alias'))->group('p.id')->where('p.status=?', Blog_Model_Post::STATUS_PUBLISHED)->order('published DESC'); if ($date) { if ('NOW' == $date) { $date = date('Y-m-d H:i:s'); } $select->where('published <=?', $date); } if ($category) { if (!$category instanceof Zend_Db_Table_Row_Abstract) { $manager = new Blog_Model_Category_Manager(); $category = $manager->getById($category); } //$separator = Categories_Model_Category::PATH_SEPARATOR; $select->where('c.path LIKE ?', '%' . $category->alias . '%'); } return $select; }
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(); }
public function tearDown() { $table = new Blog_Model_Post_Table(); $table->delete('1'); $table = new Categories_Model_Category_Table(); $table->delete(' id = 43'); $table = new Users_Model_User_Table(); $table->delete(' id = ' . $this->_fixture['user']['id']); }