Exemplo n.º 1
0
 public function editpostAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         $html = '';
         try {
             // Test s'il y a un value_id
             if (empty($datas['value_id'])) {
                 throw new Exception($this->_("An error occurred while saving your videos 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']);
             $isNew = true;
             $video = new Media_Model_Gallery_Video();
             if (!empty($datas['id'])) {
                 $video->find($datas['id']);
                 $isNew = false;
             } else {
                 $datas['value_id'] = $option_value->getId();
                 //                    $datas['type_id'] = 'youtube';
             }
             if ($video->getId() and $video->getValueId() != $option_value->getId()) {
                 throw new Exception($this->_("An error occurred while saving your videos gallery. Please try again later."));
             }
             $video->setData($datas)->save();
             $html = array('success' => 1, 'is_new' => (int) $isNew, 'id' => (int) $video->getId(), 'success_message' => $this->_('Videos gallery has been saved successfully'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0);
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }
Exemplo n.º 2
0
 public function loadmoreAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             if (empty($datas['video_id'])) {
                 throw new Exception($this->_('An error occurred while loading videos. Please try later.'));
             }
             $offset = !empty($datas['offset']) ? $datas['offset'] : 1;
             $video = new Media_Model_Gallery_Video();
             $video->find($datas['video_id']);
             if (!$video->getId() or $video->getValueId() != $this->getCurrentOptionValue()->getId()) {
                 throw new Exception($this->_('An error occurred while loading videos. Please try later.'));
             }
             $videos = $video->setOffset($offset)->getVideos();
             $html = array();
             foreach ($videos as $key => $link) {
                 $key += $offset;
                 $html[] = $this->getLayout()->addPartial('row', 'core_view_default', 'media/gallery/video/l1/view/list/li.phtml')->setCurrentOption($this->getCurrentOptionValue())->setCurrentVideo($video)->setKey($key)->setLink($link)->toHtml();
             }
             $html = array('html' => implode('', $html));
         } catch (Exception $e) {
             $html = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($html);
     }
 }
Exemplo n.º 3
0
 public function findAction()
 {
     if ($gallery_id = $this->getRequest()->getParam("gallery_id") and $offset = $this->getRequest()->getParam('offset', 1)) {
         try {
             $data = array("collection" => array());
             $video = new Media_Model_Gallery_Video();
             $video->find($gallery_id);
             if (!$video->getId() or $video->getValueId() != $this->getCurrentOptionValue()->getId()) {
                 throw new Exception($this->_('An error occurred while loading pictures. Please try later.'));
             }
             $videos = $video->setOffset($offset)->getVideos();
             $icon_url = $this->_getColorizedImage($this->getCurrentOptionValue()->getIconId(), $this->getApplication()->getBlock('background')->getColor());
             foreach ($videos as $key => $link) {
                 $key += $offset;
                 $data["collection"][] = array("offset" => $key, "video_id" => $link->getVideoId(), "is_visible" => false, "url" => $link->getLink(), "cover_url" => $link->getImage(), "title" => $link->getTitle(), "description" => $link->getDescription(), "icon_url" => $icon_url);
             }
         } catch (Exception $e) {
             $data = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }