Ejemplo n.º 1
0
 public function constructUrl()
 {
     $client_id = Api_Model_Key::findKeysFor('instagram')->getClientId();
     $token = Api_Model_Key::findKeysFor('instagram')->getToken();
     $this->_endpointUrls = array('userSearch' => str_replace('%client_id%', $client_id, str_replace('%token%', $token, $this->_endpointUrls['userSearch'])), 'mediaSearch' => str_replace('%client_id%', $client_id, str_replace('%token%', $token, $this->_endpointUrls['mediaSearch'])));
     return $this;
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 /**
  * Récupère les vidéos youtube
  *
  * @param string $search
  * @return array
  */
 public function getList($search)
 {
     if (!$this->_videos) {
         $this->_videos = array();
         try {
             $video_id = $search;
             if (Zend_Uri::check($search)) {
                 $params = Zend_Uri::factory($search)->getQueryAsArray();
                 if (!empty($params['v'])) {
                     $video_id = $params['v'];
                 }
             }
             $api_key = Api_Model_Key::findKeysFor('youtube')->getApiKey();
             $url = "https://www.googleapis.com/youtube/v3/videos?id={$video_id}&key={$api_key}&part=snippet,contentDetails,status";
             $datas = @file_get_contents($url);
             if ($datas && !empty($datas['pageInfo']['totalResults'])) {
                 $datas = Zend_Json::decode($datas);
                 $feed = array();
                 foreach ($datas['items'] as $item) {
                     $feed[] = new Core_Model_Default(array('title' => !empty($item['snippet']['title']) ? $item['snippet']['title'] : null, 'content' => !empty($item['snippet']['description']) ? $item['snippet']['description'] : null, 'link' => "http://www.youtube.com/watch?v={$video_id}"));
                 }
             } else {
                 $this->_setYoutubeUrl($search);
                 $feed = Zend_Feed_Reader::import($this->getLink());
             }
         } catch (Exception $e) {
             $feed = array();
         }
         foreach ($feed as $entry) {
             $params = Zend_Uri::factory($entry->getLink())->getQueryAsArray();
             if (empty($params['v'])) {
                 continue;
             }
             $video = new Core_Model_Default(array('id' => $params['v'], 'title' => $entry->getTitle(), 'description' => $entry->getContent(), 'link' => "http://www.youtube.com/embed/{$params['v']}", 'image' => "http://img.youtube.com/vi/{$params['v']}/0.jpg"));
             $this->_videos[] = $video;
         }
     }
     return $this->_videos;
 }
Ejemplo n.º 4
0
 public function getFacebookKey()
 {
     return Api_Model_Key::findKeysFor('facebook')->getSecretKey();
 }
Ejemplo n.º 5
0
 /**
  * Construit le lien
  *
  * @param string $search
  * @return \Cms_Model_Application_Page_Block_Youtube
  */
 protected function _setYoutubeUrl($search, $type)
 {
     $api_key = Api_Model_Key::findKeysFor('youtube')->getApiKey();
     $flux = $this->_flux[$type];
     $search = str_replace(' ', '+', $search);
     $url = str_replace('%s1', $search, $flux);
     $url = str_replace('%s2', $api_key, $url);
     $url = str_replace('%d1', '1', $url);
     $url = str_replace('%d2', '24', $url);
     $this->setLink($url);
     return $this;
 }
Ejemplo n.º 6
0
 public function getFacebookKey()
 {
     $facebook_key = $this->getData("facebook_key");
     if (!$facebook_key) {
         $facebook_key = Api_Model_Key::findKeysFor('facebook')->getSecretKey();
     }
     return $facebook_key;
 }