public function showAction() { $profilMapper = new UserMapper(); $imageMapper = new GalleryImageMapper(); $pagination = new \Ilch\Pagination(); $galleryMapper = new GalleryMapper(); $id = $this->getRequest()->getParam('id'); $gallery = $galleryMapper->getGalleryById($id); $profil = $profilMapper->getUserById($this->getRequest()->getParam('user')); $this->getLayout()->set('metaTitle', $this->getTranslator()->trans('gallery') . ' - ' . $gallery->getTitle()); $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' => $id)); $pagination->setPage($this->getRequest()->getParam('page')); $this->getView()->set('image', $imageMapper->getImageByGalleryId($id, $pagination)); $this->getView()->set('pagination', $pagination); }
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()); }