Esempio n. 1
0
 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);
 }
Esempio n. 2
0
    public function getImageByGalleryId($id, $pagination = NULL)
    {
        $sql = 'SELECT SQL_CALC_FOUND_ROWS g.image_id,g.cat,g.id as imgid,g.image_title,g.image_description,g.visits, m.url, m.id, m.url_thumb
                           FROM `[prefix]_gallery_imgs` AS g
                           LEFT JOIN `[prefix]_media` m ON g.image_id = m.id

                           WHERE g.cat = ' . $id . ' ORDER BY g.id DESC
                           LIMIT ' . implode(',', $pagination->getLimit());
        $imageArray = $this->db()->queryArray($sql);
        $pagination->setRows($this->db()->querycell('SELECT FOUND_ROWS()'));
        $entry = array();
        foreach ($imageArray as $entries) {
            $entryModel = new ImageModel();
            $entryModel->setImageUrl($entries['url']);
            $entryModel->setImageThumb($entries['url_thumb']);
            $entryModel->setId($entries['imgid']);
            $entryModel->setImageTitle($entries['image_title']);
            $entryModel->setImageDesc($entries['image_description']);
            $entryModel->setVisits($entries['visits']);
            $entryModel->setCat($entries['cat']);
            $entry[] = $entryModel;
        }
        return $entry;
    }