예제 #1
0
 public function findallAction()
 {
     if ($value_id = $this->getRequest()->getParam("value_id")) {
         try {
             $image = new Media_Model_Gallery_Image();
             $images = $image->findAll(array('value_id' => $value_id));
             $data = array("galleries" => array());
             foreach ($images as $image) {
                 $data["galleries"][] = array("id" => $image->getId(), "name" => $image->getName(), "type" => $image->getTypeId());
             }
             $data["page_title"] = $this->getCurrentOptionValue()->getTabbarName();
             $data["header_right_button"]["picto_url"] = $this->_getColorizedImage($this->_getImage('pictos/more.png', true), $this->getApplication()->getBlock('subheader')->getColor());
         } catch (Exception $e) {
             $data = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
예제 #2
0
 public function loadmoreAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             if (empty($datas['gallery_id'])) {
                 throw new Exception($this->_('An error occurred while loading pictures. Please try later.'));
             }
             $offset = !empty($datas['offset']) ? $datas['offset'] : 0;
             $image = new Media_Model_Gallery_Image();
             $image->find($datas['gallery_id']);
             if (!$image->getId() or $image->getValueId() != $this->getCurrentOptionValue()->getId()) {
                 throw new Exception($this->_('An error occurred while loading pictures. Please try later.'));
             }
             $images = $image->setOffset($offset)->getImages();
             $html = array();
             $image_datas = array();
             //                $offset--;
             foreach ($images as $key => $link) {
                 $key += $offset;
                 $html[] = $this->getLayout()->addPartial('row', 'core_view_default', 'media/gallery/image/l1/view/list/li.phtml')->setCurrentImage($image)->setKey($key)->setLink($link)->toHtml();
                 $image_datas[] = $link->getData();
             }
             $html = array('html' => implode('', $html), 'images' => $image_datas, 'id' => $image->getId());
         } catch (Exception $e) {
             $html = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($html);
     }
 }
예제 #3
0
 public function findAction()
 {
     if ($gallery_id = $this->getRequest()->getParam("gallery_id")) {
         try {
             $offset = $this->getRequest()->getParam('offset', 0);
             $data = array("collection" => array());
             $image = new Media_Model_Gallery_Image();
             $image->find($gallery_id);
             if (!$image->getId() or $image->getValueId() != $this->getCurrentOptionValue()->getId()) {
                 throw new Exception($this->_('An error occurred while loading pictures. Please try later.'));
             }
             $images = $image->setOffset($offset)->getImages();
             foreach ($images as $key => $link) {
                 $key += $offset;
                 $data["collection"][] = array("offset" => $link->getOffset(), "gallery_id" => $key, "is_visible" => false, "url" => $link->getImage(), "title" => $link->getTitle(), "description" => $link->getDescription(), "author" => $link->getAuthor());
             }
             if ($image->getTypeId() != "custom") {
                 $data["show_load_more"] = count($data["images"]) > 0;
             } else {
                 $data["show_load_more"] = $key - $offset + 1 > Media_Model_Gallery_Image_Abstract::DISPLAYED_PER_PAGE - 1 ? true : false;
             }
         } catch (Exception $e) {
             $data = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
예제 #4
0
 public function deleteAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         $html = '';
         try {
             // Test s'il y a un value_id
             if (empty($datas['value_id']) or empty($datas['id'])) {
                 throw new Exception($this->_("An error occurred while deleting you images gallery. Please try again later."));
             }
             // Récupère l'option_value en cours
             $option_value = new Application_Model_Option_Value();
             $option_value->find($datas['value_id']);
             $image = new Media_Model_Gallery_Image();
             $image->find($datas['id']);
             $image->delete();
             $html = array('success' => 1);
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }