public function viewAction() { $topicTbl = new VC_DbTable_Store_Topic(); $topicId = $this->_getParam("tpid"); $articleId = $this->_getParam("id"); if (!$topicId && !$articleId) { throw new Zend_Exception("Invalid request, please try again"); } $articleTbl = new VC_DbTable_Store_Article(); $article = array(); if (!$articleId) { $articleInfo = $articleTbl->findByMaxIdOfTopicAndUserId($topicId, $this->userId); if ($articleInfo) { $articleId = $articleInfo->max_id; } } if ($articleId) { $article = $articleTbl->findByIdAndUserId($articleId, $this->userId); if (!$topicId) { $topicId = $article->topic_id; } //Get all relative article $relativeTbl = new VC_DbTable_Store_RelativeArticle(); $relativeArticles = $relativeTbl->findRelativeArticleId($articleId); $listRelativeArticle = array(); if ($relativeArticles) { //Get article $listRelativeArticle = $articleTbl->find(explode(",", $relativeArticles->article_ids))->toArray(); } //LeftColumn paginater $perPage = 20; $curPage = (int) $this->_getParam('page'); $start = 0; if ($curPage > 0) { $start = ($curPage - 1) * $perPage; } $listArticleOfTopic = $articleTbl->findByTopicId($topicId, $start, $perPage); $totalArticleOfTopic = $articleTbl->getTotalArticleByTopic($topicId); if ($totalArticleOfTopic >= $perPage) { $paginator = Zend_Paginator::factory((int) $totalArticleOfTopic); $paginator->setItemCountPerPage($perPage); $paginator->setCurrentPageNumber($curPage); $this->view->paginator = $paginator; } $this->view->listArticleOfTopic = $listArticleOfTopic; $this->view->article = $article; $this->view->relativeArticles = $relativeArticles; $this->view->listRelativeArticle = $listRelativeArticle; } $this->view->topicInfo = $topicTbl->findById($topicId); $this->view->params = $this->_getAllParams(); }