/** * Display widget dashboard * * @param \Zend\EventManager\EventInterface $event Event * * @return void */ public function dashboard(Event $event) { $commentModel = new Comment(); $unactiveCommentList = $commentModel->getList(null, false); $activeCommentList = $commentModel->getList(null, true); $widgets = $event->getParam('widgets'); $widgets['blog']['id'] = 'blog'; $widgets['blog']['title'] = 'Blog information'; $widgets['blog']['content'] = $this->addPath(__DIR__ . '/views')->render('dashboard.phtml', array('unactiveComments' => count($unactiveCommentList), 'activeComments' => count($activeCommentList))); $event->setParam('widgets', $widgets); }
/** * List all comment by document id * * @return array */ public function documentCommentAction() { $documentId = $this->params()->fromRoute('id'); $document = DocumentModel::fromId($documentId); if (empty($document)) { return $this->redirect()->toRoute('module/blog'); } $model = new Model\Comment(); $commentList = $model->getList($documentId, null); if ($this->getRequest()->isPost()) { $comments = $this->getRequest()->getPost()->get('comment'); foreach ($comments as $commentId => $data) { if (!empty($data['delete'])) { $model->delete(array('id' => $commentId)); continue; } foreach ($data as $k => $v) { if (!in_array($k, $this->whiteList)) { unset($data[$k]); } } $data['show_email'] = empty($data['show_email']) ? 0 : 1; $data['is_active'] = empty($data['is_active']) ? 0 : 1; $model->update($data, array('id' => $commentId)); } return $this->redirect()->toRoute('module/blog/document-comment', array('id' => $documentId)); } return array('comment_list' => $commentList, 'document' => $document); }
/** * Invoke form * * @return string */ public function __invoke() { $commentTable = new Blog\Model\Comment(); $document = $this->getServiceLocator()->get('Zend\\View\\Renderer\\PhpRenderer')->plugin('CurrentDocument'); $comments = $commentTable->getList($document()->getId()); return $this->addPath(__DIR__ . '/../views')->render('plugin/comment-list.phtml', array('comments' => $comments)); }
/** * Test * * @return void */ public function testGetList() { $this->assertInternalType('array', $this->object->getList(1)); }