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 delAction() { if ($this->getRequest()->isSecure()) { $fileMapper = new FileMapper(); $id = $this->getRequest()->getParam('id'); $fileMapper->deleteById($id); $this->addMessage('deleteSuccess'); $this->redirect(array('action' => 'treatdownloads', 'id' => $this->getRequest()->getParam('downloads'))); } }
public function treatFileAction() { $fileMapper = new FileMapper(); $id = (int) $this->getRequest()->getParam('id'); if ($this->getRequest()->getPost()) { $fileTitle = $this->getRequest()->getPost('fileTitle'); $fileImage = $this->getRequest()->getPost('fileImage'); $fileDesc = $this->getRequest()->getPost('fileDesc'); $model = new \Modules\Downloads\Models\File(); $model->setId($id); $model->setFileImage($fileImage); $model->setFileTitle($fileTitle); $model->setFileDesc($fileDesc); $fileMapper->saveFileTreat($model); $this->addMessage('Success'); } $this->getView()->set('file', $fileMapper->getFileById($id)); }