Example #1
0
 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);
 }
Example #2
0
    public function getFileByDownloadsId($id, $pagination = NULL)
    {
        $sql = 'SELECT SQL_CALC_FOUND_ROWS g.file_id,g.cat,g.id as fileid,g.file_title,g.file_image,g.file_description,g.visits, m.url, m.id, m.url_thumb
                           FROM `[prefix]_downloads_files` AS g
                           LEFT JOIN `[prefix]_media` m ON g.file_image = m.url

                           WHERE g.cat = ' . $id . ' ORDER BY g.id DESC
                           LIMIT ' . implode(',', $pagination->getLimit());
        $fileArray = $this->db()->queryArray($sql);
        $pagination->setRows($this->db()->querycell('SELECT FOUND_ROWS()'));
        $entry = array();
        foreach ($fileArray as $entries) {
            $entryModel = new FileModel();
            $entryModel->setFileUrl($entries['url']);
            $entryModel->setFileThumb($entries['url_thumb']);
            $entryModel->setId($entries['fileid']);
            $entryModel->setFileTitle($entries['file_title']);
            $entryModel->setFileImage($entries['url_thumb']);
            $entryModel->setFileDesc($entries['file_description']);
            $entryModel->setVisits($entries['visits']);
            $entryModel->setCat($entries['cat']);
            $entry[] = $entryModel;
        }
        return $entry;
    }