예제 #1
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]_users_gallery_imgs` AS g
             LEFT JOIN `[prefix]_users_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);
     if (empty($imageArray)) {
         return null;
     }
     $pagination->setRows($this->db()->querycell('SELECT FOUND_ROWS()'));
     $entry = array();
     foreach ($imageArray as $entries) {
         $entryModel = new GalleryImageModel();
         $entryModel->setImageUrl($entries['url']);
         $entryModel->setImageThumb($entries['url_thumb']);
         $entryModel->setId($entries['imgid']);
         $entryModel->setImageId($entries['id']);
         $entryModel->setImageTitle($entries['image_title']);
         $entryModel->setImageDesc($entries['image_description']);
         $entryModel->setVisits($entries['visits']);
         $entryModel->setCat($entries['cat']);
         $entry[] = $entryModel;
     }
     return $entry;
 }
예제 #2
0
 public function showImageAction()
 {
     $profilMapper = new UserMapper();
     $commentMapper = new CommentMapper();
     $imageMapper = new GalleryImageMapper();
     $galleryMapper = new GalleryMapper();
     $id = $this->getRequest()->getParam('id');
     $galleryId = $this->getRequest()->getParam('gallery');
     $userId = $this->getRequest()->getParam('user');
     $gallery = $galleryMapper->getGalleryById($galleryId);
     $comments = $commentMapper->getCommentsByKey('user/gallery/showimage/user/' . $userId . '/gallery/' . $galleryId . '/id/' . $id);
     $image = $imageMapper->getImageById($id);
     $profil = $profilMapper->getUserById($this->getRequest()->getParam('user'));
     $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('gallery') . ' - ' . $gallery->getTitle() . ' - ' . $image->getImageTitle());
     $this->getLayout()->set('metaDescription', $this->getTranslator()->trans('gallery') . ' - ' . $gallery->getDesc());
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuUserList'), array('controller' => 'index'))->add($profil->getName(), array('controller' => 'profil', 'action' => 'index', 'user' => $this->getRequest()->getParam('user')))->add($this->getTranslator()->trans('menuGallery'), array('controller' => 'gallery', 'action' => 'index', 'user' => $this->getRequest()->getParam('user')))->add($gallery->getTitle(), array('action' => 'show', 'user' => $this->getRequest()->getParam('user'), 'id' => $galleryId))->add($image->getImageTitle(), array('action' => 'showimage', 'user' => $this->getRequest()->getParam('user'), 'gallery' => $galleryId, 'id' => $id));
     if ($this->getRequest()->getPost('saveComment')) {
         $date = new \Ilch\Date();
         $commentModel = new CommentModel();
         if ($this->getRequest()->getPost('fkId')) {
             $commentModel->setKey('user/gallery/showimage/user/' . $userId . '/gallery/' . $galleryId . '/id/' . $id . '/id_c/' . $this->getRequest()->getPost('fkId'));
             $commentModel->setFKId($this->getRequest()->getPost('fkId'));
         } else {
             $commentModel->setKey('user/gallery/showimage/user/' . $userId . '/gallery/' . $galleryId . '/id/' . $id);
         }
         $commentModel->setText($this->getRequest()->getPost('gallery_comment_text'));
         $commentModel->setDateCreated($date);
         $commentModel->setUserId($this->getUser()->getId());
         $commentMapper->save($commentModel);
     }
     $model = new GalleryImageModel();
     $model->setImageId($image->getImageId());
     $model->setVisits($image->getVisits() + 1);
     $imageMapper->saveVisits($model);
     $this->getView()->set('image', $imageMapper->getImageById($id));
     $this->getView()->set('comments', $comments);
 }
예제 #3
0
파일: Panel.php 프로젝트: sCar-w4y/Ilch-2.0
 public function treatGalleryAction()
 {
     $imageMapper = new GalleryImageMapper();
     $pagination = new \Ilch\Pagination();
     $galleryMapper = new GalleryMapper();
     $id = $this->getRequest()->getParam('id');
     $gallery = $galleryMapper->getGalleryById($id);
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuPanel'), array('controller' => 'panel', 'action' => 'index'))->add($this->getTranslator()->trans('menuGallery'), array('controller' => 'panel', 'action' => 'gallery'))->add($gallery->getTitle(), array('controller' => 'panel', 'action' => 'treatgallery', 'id' => $id));
     if ($this->getRequest()->getPost('action') == 'delete') {
         foreach ($this->getRequest()->getPost('check_gallery') as $imageId) {
             $imageMapper->deleteById($imageId);
         }
         $this->addMessage('deleteSuccess');
         $this->redirect(array('action' => 'treatgallery', 'id' => $id));
     }
     if ($this->getRequest()->getPost()) {
         foreach ($this->getRequest()->getPost('check_image') as $imageId) {
             $catId = $this->getRequest()->getParam('id');
             $model = new GalleryImageModel();
             $model->setUserId($this->getUser()->getId());
             $model->setImageId($imageId);
             $model->setCat($catId);
             $imageMapper->save($model);
         }
     }
     $pagination->setPage($this->getRequest()->getParam('page'));
     $this->getView()->set('image', $imageMapper->getImageByGalleryId($id, $pagination));
     $this->getView()->set('pagination', $pagination);
     $this->getView()->set('galleryTitle', $gallery->getTitle());
 }