public function showImageAction() { $commentMapper = new CommentMapper(); $imageMapper = new ImageMapper(); $galleryMapper = new GalleryMapper(); $id = $this->getRequest()->getParam('id'); $galleryId = $this->getRequest()->getParam('gallery'); if ($this->getRequest()->getPost('saveComment')) { $date = new \Ilch\Date(); $commentModel = new CommentModel(); if ($this->getRequest()->getPost('fkId')) { $commentModel->setKey('gallery/index/showimage/gallery/' . $galleryId . '/id/' . $id . '/id_c/' . $this->getRequest()->getPost('fkId')); $commentModel->setFKId($this->getRequest()->getPost('fkId')); } else { $commentModel->setKey('gallery/index/showimage/gallery/' . $galleryId . '/id/' . $id); } $commentModel->setText($this->getRequest()->getPost('gallery_comment_text')); $commentModel->setDateCreated($date); $commentModel->setUserId($this->getUser()->getId()); $commentMapper->save($commentModel); } $gallery = $galleryMapper->getGalleryById($galleryId); $comments = $commentMapper->getCommentsByKey('gallery/index/showimage/gallery/' . $galleryId . '/id/' . $id); $image = $imageMapper->getImageById($id); $model = new ImageModel(); $model->setImageId($image->getImageId()); $model->setVisits($image->getVisits() + 1); $imageMapper->saveVisits($model); $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('gallery') . ' - ' . $this->getTranslator()->trans('image') . ' - ' . $image->getImageTitle()); $this->getLayout()->set('metaDescription', $this->getTranslator()->trans('gallery') . ' - ' . $image->getImageDesc()); $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuGalleryOverview'), array('action' => 'index'))->add($gallery->getTitle(), array('action' => 'show', 'id' => $galleryId))->add($image->getImageTitle(), array('action' => 'showimage', 'gallery' => $galleryId, 'id' => $id)); $this->getView()->set('image', $imageMapper->getImageById($id)); $this->getView()->set('comments', $comments); }
public function showFileAction() { $commentMapper = new CommentMapper(); $fileMapper = new FileMapper(); $downloadsMapper = new DownloadsMapper(); $id = $this->getRequest()->getParam('id'); $downloadsId = $this->getRequest()->getParam('downloads'); if ($this->getRequest()->getPost('downloads_comment_text')) { $commentModel = new CommentModel(); $commentModel->setKey('downloads/index/showfile/downloads/' . $downloadsId . '/id/' . $id); $commentModel->setText($this->getRequest()->getPost('downloads_comment_text')); $date = new \Ilch\Date(); $commentModel->setDateCreated($date); $commentModel->setUserId($this->getUser()->getId()); $commentMapper->save($commentModel); } $downloads = $downloadsMapper->getDownloadsById($downloadsId); $comments = $commentMapper->getCommentsByKey('downloads/index/showfile/downloads/' . $downloadsId . '/id/' . $id); $file = $fileMapper->getFileById($id); $model = new FileModel(); $model->setFileId($file->getFileId()); $model->setVisits($file->getVisits() + 1); $fileMapper->saveVisits($model); $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('downloads') . ' - ' . $this->getTranslator()->trans('file') . ' - ' . $file->getFileTitle()); $this->getLayout()->set('metaDescription', $this->getTranslator()->trans('downloads') . ' - ' . $file->getFileDesc()); $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuDownloadsOverview'), array('action' => 'index'))->add($downloads->getTitle(), array('action' => 'show', 'id' => $downloadsId))->add($file->getFileTitle(), array('action' => 'showfile', 'downloads' => $downloadsId, 'id' => $id)); $this->getView()->set('file', $fileMapper->getFileById($id)); $this->getView()->set('comments', $comments); }
public function showAction() { $commentMapper = new CommentMapper(); if ($this->getRequest()->getPost('saveComment')) { $date = new \Ilch\Date(); $commentModel = new CommentModel(); if ($this->getRequest()->getPost('fkId')) { $commentModel->setKey('article/index/show/id/' . $this->getRequest()->getParam('id') . '/id_c/' . $this->getRequest()->getPost('fkId')); $commentModel->setFKId($this->getRequest()->getPost('fkId')); } else { $commentModel->setKey('article/index/show/id/' . $this->getRequest()->getParam('id')); } $commentModel->setText($this->getRequest()->getPost('article_comment_text')); $commentModel->setDateCreated($date); $commentModel->setUserId($this->getUser()->getId()); $commentMapper->save($commentModel); } if ($this->getRequest()->isPost() & $this->getRequest()->getParam('preview') == 'true') { $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuArticle'), array('action' => 'index'))->add($this->getTranslator()->trans('preview'), array('action' => 'index')); $title = $this->getRequest()->getPost('title'); $catId = $this->getRequest()->getPost('cats'); $content = $this->getRequest()->getPost('content'); $image = $this->getRequest()->getPost('image'); $articleModel = new ArticleModel(); $articleModel->setTitle($title); $articleModel->setCatId($catId); $articleModel->setContent($content); $articleModel->setArticleImage($image); $articleModel->setVisits(0); $this->getView()->set('article', $articleModel); } else { $articleMapper = new ArticleMapper(); $articleModel = new ArticleModel(); $categoryMapper = new CategoryMapper(); $article = $articleMapper->getArticleByIdLocale($this->getRequest()->getParam('id')); $articlesCats = $categoryMapper->getCategoryById($article->getCatId()); $comments = $commentMapper->getCommentsByKey('article/index/show/id/' . $this->getRequest()->getParam('id')); $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuArticle'), array('action' => 'index'))->add($this->getTranslator()->trans('menuCats'), array('controller' => 'cats', 'action' => 'index'))->add($articlesCats->getName(), array('controller' => 'cats', 'action' => 'show', 'id' => $articlesCats->getId()))->add($article->getTitle(), array('action' => 'show', 'id' => $article->getId())); $articleModel->setId($article->getId()); $articleModel->setVisits($article->getVisits() + 1); $articleMapper->saveVisits($articleModel); $this->getLayout()->set('metaTitle', $article->getTitle()); $this->getLayout()->set('metaDescription', $article->getDescription()); $this->getView()->set('article', $article); $this->getView()->set('comments', $comments); } }
public function eventAction() { $eventMapper = new EventMapper(); $entrantsMapper = new EntrantsMapper(); $entrantsModel = new EntrantsModel(); $commentMapper = new CommentMapper(); $commentModel = new CommentModel(); $event = $eventMapper->getEventById($this->getRequest()->getParam('id')); $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuEvents'), array('controller' => 'index', 'action' => 'index'))->add($event->getTitle(), array('controller' => 'show', 'action' => 'event', 'id' => $event->getId())); if ($this->getRequest()->isPost()) { if ($this->getRequest()->getPost('save')) { $entrantsModel->setEventId(trim($this->getRequest()->getPost('id'))); $entrantsModel->setUserId($this->getUser()->getId()); $entrantsModel->setStatus(trim($this->getRequest()->getPost('save'))); $entrantsMapper->saveUserOnEvent($entrantsModel); $this->addMessage('saveSuccess'); } if ($this->getRequest()->getPost('commentEvent')) { $date = new \Ilch\Date(); $commentModel->setKey('events/show/event/id/' . $this->getRequest()->getParam('id')); $commentModel->setText($this->getRequest()->getPost('commentEvent')); $commentModel->setDateCreated($date); $commentModel->setUserId($this->getUser()->getId()); $commentMapper->save($commentModel); $this->addMessage('saveSuccess'); } if ($this->getRequest()->getPost('deleteUser')) { $entrantsMapper->deleteUserFromEvent($this->getRequest()->getParam('id'), $this->getUser()->getId()); $this->addMessage('deleteSuccess'); } if ($this->getRequest()->getPost('deleteEvent')) { $eventMapper->delete($this->getRequest()->getParam('id')); $this->addMessage('deleteSuccess'); $this->redirect(array('controller' => 'index', 'action' => 'index')); } } if ($this->getUser()) { $this->getView()->set('eventEntrants', $entrantsMapper->getEventEntrants($this->getRequest()->getParam('id'), $this->getUser()->getId())); } $this->getView()->set('event', $eventMapper->getEventById($this->getRequest()->getParam('id'))); $this->getView()->set('eventEntrantsUser', $entrantsMapper->getEventEntrantsById($this->getRequest()->getParam('id'))); $this->getView()->set('eventEntrantsCount', count($entrantsMapper->getEventEntrantsById($this->getRequest()->getParam('id')))); $this->getView()->set('eventComments', $commentMapper->getCommentsByKey('events/show/event/id/' . $this->getRequest()->getParam('id'))); }
public function indexAction() { $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuComments'), array('action' => 'index')); $commentMapper = new CommentMapper(); $this->getView()->set('comments', $commentMapper->getComments()); if ($this->getRequest()->getPost('comment_comment_text')) { $commentModel = new CommentModel(); $commentModel->setKey('article/index/show/id/' . $this->getRequest()->getParam('id_a') . '/id_c/' . $this->getRequest()->getParam('id')); $commentModel->setFKId($this->getRequest()->getParam('id')); $commentModel->setText($this->getRequest()->getPost('comment_comment_text')); $date = new \Ilch\Date(); $commentModel->setDateCreated($date); $commentModel->setUserId($this->getUser()->getId()); $commentMapper->save($commentModel); } $comments = $commentMapper->getComments('comment/index/index/id/' . $this->getRequest()->getParam('id')); $this->getView()->set('comment_reply', $this->getConfig()->get('comment_reply')); $this->getView()->set('comments', $comments); }
/** * @return CommentModel[]|null */ public function getComments() { $commentsArray = $this->db()->select('*')->from('comments')->order(array('id' => 'DESC'))->execute()->fetchRows(); if (empty($commentsArray)) { return NULL; } $comments = array(); foreach ($commentsArray as $commentRow) { $commentModel = new CommentModel(); $commentModel->setId($commentRow['id']); $commentModel->setFKId($commentRow['fk_id']); $commentModel->setKey($commentRow['key']); $commentModel->setText($commentRow['text']); $commentModel->setUserId($commentRow['user_id']); $commentModel->setDateCreated($commentRow['date_created']); $comments[] = $commentModel; } return $comments; }