Пример #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 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());
 }