public function findallAction() { if ($value_id = $this->getRequest()->getParam("value_id")) { try { $video = new Media_Model_Gallery_Video(); $videos = $video->findAll(array('value_id' => $value_id)); $data = array("collection" => array()); $has_youtube_videos = false; foreach ($videos as $video) { $data["collection"][] = array("id" => $video->getId(), "name" => $video->getName(), "type" => $video->getTypeId(), "search_by" => $video->getType(), "search_keyword" => $video->getParam()); if ($video->getTypeId() == "youtube") { $has_youtube_videos = true; } } $data["page_title"] = $this->getCurrentOptionValue()->getTabbarName(); $data["displayed_per_page"] = Media_Model_Gallery_Video_Abstract::DISPLAYED_PER_PAGE; $data["header_right_button"]["picto_url"] = $this->_getColorizedImage($this->_getImage('pictos/more.png', true), $this->getApplication()->getBlock('subheader')->getColor()); if ($has_youtube_videos) { $data["youtube_key"] = Api_Model_Key::findKeysFor('youtube')->getApiKey(); } } catch (Exception $e) { $data = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($data); } }
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)); } }
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); } }
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); } }