Provides custom find types for the various calls on the web service, mapping familiar CakePHP methods and parameters to the http request params for issuing to the web service.
Author: Neil Crookes (neil@neilcrookes.com)
Inheritance: extends GdataAppModel
 public function parseNewsArticlesHook($objTemplate, $arrNews, $objModule)
 {
     if (!$arrNews['addYouTube']) {
         return;
     }
     $objConfig = YouTubeSettings::getInstance()->setModule($objModule->getModel());
     YouTubeVideo::getInstance()->setData($objTemplate->getData())->setConfig($objConfig)->addToTemplate($objTemplate);
 }
 protected function compile()
 {
     if (TL_MODE == 'FE') {
         $this->Template = new \FrontendTemplate($this->strTemplate);
         $this->Template->setData($this->arrData);
         $objConfig = YouTubeSettings::getInstance()->setModule($this->objModel);
         YouTubeVideo::getInstance()->setData($this->arrData)->setConfig($objConfig)->addToTemplate($this->Template);
     } else {
         $this->strTemplate = 'be_wildcard';
         $this->Template = new \BackendTemplate($this->strTemplate);
         $this->Template->title = 'YouTube-Video ' . $this->youtube;
     }
 }
Esempio n. 3
0
*/
/*
$pls = $user->getPlaylists();
$pl = $pls[0];

$pl->loadPlaylist();

echo "<h2>Playlist Title: " . $pl->getTitle() . "</h2>";

$videos = $pl->getVideos();

foreach ($videos as $v) {
	echo "<h2>" . "<a href='". $v->link ."'>";
	echo "<img src='". $v->thumbnails[0]->url ."' width='". $v->thumbnails[0]->width ."' height='". $v->thumbnails[0]->height ."' />&nbsp;";
	echo $v->title . "</a></h2>";

	echo '<iframe width="560" height="345" src="'. $v->content .'" frameborder="0" allowfullscreen></iframe>';

	echo "<br />";
	print_r($v);
}
*/
echo "<hr /><hr /><hr /><h1>Single Video Test</h1>";
$v = new YouTubeVideo();
$v->load("57a6t_1Owfc");
echo "<h2>" . "<a href='" . $v->link . "'>";
echo "<img src='" . $v->thumbnails[0]->url . "' width='" . $v->thumbnails[0]->width . "' height='" . $v->thumbnails[0]->height . "' />&nbsp;";
echo $v->title . "</a></h2>";
echo '<iframe width="560" height="345" src="' . $v->content . '" frameborder="0" allowfullscreen></iframe>';
echo "<br />";
print_r($v);
Esempio n. 4
0
 public function LatestYouTubeVideos()
 {
     return YouTubeVideo::get()->filter('ThumbnailID:GreaterThan', 0)->sort(array('SortOrder' => 'ASC', 'Created' => 'ASC'));
 }
 /**
  * Looks up YouTubeVideo objects by VideoID, returns the first result
  *
  * @param $videoID
  * @return bool|DataList
  */
 public static function getExisting($videoID)
 {
     $video = YouTubeVideo::get()->filter('VideoID', $videoID)->first();
     return $video ? $video : false;
 }
 /**
  * Saves a Google_Service_YouTube_PlaylistItem into YouTubeVideo
  * Overwrites an existing object, or creates a new one.
  * Returns the YouTubeVideo DataObject.
  *
  * @param $video
  * @return YouTubeVideo
  */
 protected function processVideo($video)
 {
     $snippet = $video['snippet'];
     $videoFields = array();
     // Map response data to columns in our YouTubeVideo table
     $videoFields['VideoID'] = $snippet['resourceId']['videoId'];
     $videoFields['Description'] = $snippet['description'];
     $videoFields['Published'] = strtotime($snippet['publishedAt']);
     $videoFields['Title'] = $snippet['title'];
     $videoFields['ChannelTitle'] = $snippet['channelTitle'];
     $videoFields['ChannelID'] = $snippet['channelId'];
     $videoFields['PlaylistID'] = $snippet['playlistId'];
     $videoFields['PlaylistPosition'] = $snippet['position'];
     // Get the highest res thumbnail available
     if (isset($snippet['thumbnails']['maxres'])) {
         $videoFields['ThumbnailURL'] = $snippet['thumbnails']['maxres']['url'];
     } elseif (isset($snippet['thumbnails']['standard'])) {
         $videoFields['ThumbnailURL'] = $snippet['thumbnails']['standard']['url'];
     } elseif (isset($snippet['thumbnails']['high'])) {
         $videoFields['ThumbnailURL'] = $snippet['thumbnails']['high']['url'];
     } elseif (isset($snippet['thumbnails']['medium'])) {
         $videoFields['ThumbnailURL'] = $snippet['thumbnails']['medium']['url'];
     } elseif (isset($snippet['thumbnails']['default'])) {
         $videoFields['ThumbnailURL'] = $snippet['thumbnails']['default']['url'];
     }
     // Try retrieve existing YouTubeVideo by Youtube Video ID, create if it doesn't exist
     $videoObject = YouTubeVideo::getExisting($videoFields['VideoID']);
     if (!$videoObject) {
         $videoObject = new YouTubeVideo();
         $newYouTubeVideo = true;
     }
     $videoObject->update($videoFields);
     $videoObject->write();
     if (isset($newYouTubeVideo)) {
         // Allow decoration of YouTubeVideo with onAfterCreate(YouTubeVideo $videoObject) method
         $this->extend('onAfterCreate', $videoObject);
     }
     return $videoObject;
 }