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); } }