/** * Action - view * view user post * * Access to the action is possible in the following paths: * router pattern - user/:username/view/:url/* * - /user/user1/view/prosto-fleshka * * @return void */ public function viewAction() { // Определим какую закладку нужно открыть $viewTab = isset($this->_params["view"]) ? $this->_params["view"] : "post"; $url = trim($this->_request->getUserParam('url')); // if no URL was specified, return to the user home page if (strlen($url) == 0) { $urlCustom = $this->getCustomUrl(array('username' => $this->user->username, 'action' => 'index'), 'user'); $this->_redirector->gotoUrl($urlCustom, array('prependBase' => FALSE)); } // try and load the post $post = new Default_Model_DbTable_BlogPost($this->db); $post->loadLivePost($this->user->getId(), $url); // if the post wasn't loaded redirect to postNotFound if (!$post->isSaved()) { $this->_forward('postnotfound'); return; } // Получим дерево комментариев $treeComments = $post->getTreeComments(); // Получим количество комментариев $countComments = $post->getCommentsCount(); // Инициализируем форму добавления комментария $formAddComment = new Default_Form_AddComment($this->user->username, $post->getId()); // build options for the archive breadcrumbs link $archiveOptions = array('username' => $this->user->username, 'year' => date('Y', $post->ts_created), 'month' => date('m', $post->ts_created)); // определим дату $date = new Zend_Date($post->ts_created, 'U'); $dtFormat = $date->get('YYYY MMMM'); $this->_breadcrumbs->addStep($dtFormat, $this->getCustomUrl($archiveOptions, 'archive')); $this->_breadcrumbs->addStep($post->profile->title); // make the post available to the template $this->view->post = $post; $this->view->treeComments = $treeComments; $this->view->countComments = $countComments; $this->view->formAddComment = $formAddComment; $this->view->viewTab = $viewTab; }