Exemplo n.º 1
0
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription, $thumbnailcssstyle, $getinfomethod)
 {
     //onBehalfOfContentOwner
     //blank	array
     $blankArray = array('videosource' => 'youtube', 'videoid' => $videoid, 'imageurl' => '', 'title' => '', 'description' => '', 'publisheddate' => '', 'duration' => 0, 'rating_average' => 0, 'rating_max' => 0, 'rating_min' => 0, 'rating_numRaters' => 0, 'statistics_favoriteCount' => 0, 'statistics_viewCount' => 0, 'keywords' => '', 'likes' => 0, 'dislikes' => '', 'commentcount' => '', 'channel_username' => '', 'channel_title' => '', 'channel_subscribers' => 0, 'channel_subscribed' => 0, 'channel_location' => '', 'channel_commentcount' => 0, 'channel_viewcount' => 0, 'channel_videocount' => 0, 'channel_description' => '');
     $api_key = YouTubeGalleryMisc::getSettingValue('youtube_api_key');
     if ($api_key != '') {
         $answer = VideoSource_YouTube::getYouTubeVideoData_API_v3($videoid, $blankArray, $getinfomethod, $api_key);
     } else {
         $answer = VideoSource_YouTube::getYouTubeVideoData_API_v2($videoid, $blankArray, $getinfomethod);
     }
     if ($answer != '') {
         $blankArray['title'] = '***Video not found*** (' . YouTubeGalleryMisc::html2txt($answer) . ')';
         $blankArray['description'] = YouTubeGalleryMisc::html2txt($answer);
         return $blankArray;
     }
     if ($customtitle != '') {
         $blankArray['title'] = $customtitle;
     }
     if ($customdescription != '') {
         $blankArray['description'] = $customdescription;
     }
     if ($customimage != '' and strpos($customimage, '#') === false) {
         $blankArray['imageurl'] = $customimage;
     } else {
         if ($blankArray['imageurl'] == '') {
             $blankArray['imageurl'] = VideoSource_YouTube::getYouTubeImageURL($videoid, $thumbnailcssstyle);
         }
     }
     return $blankArray;
 }
 public static function getValue($fld, $params, &$videolist_row, &$theme_row, $gallery_list, $width, $height, $videoid, $AllowPagination, $total_number_of_rows, $custom_itemid = 0)
 {
     $fields_theme = array('bgcolor', 'cssstyle', 'navbarstyle', 'thumbnailstyle', 'linestyle', 'listnamestyle', 'activevideotitlestyle', 'color1', 'color2', 'descr_style', 'rel', 'hrefaddon');
     if (in_array($fld, $fields_theme)) {
         $theme_row_array = get_object_vars($theme_row);
         return $theme_row_array[$fld];
     }
     switch ($fld) {
         case 'mediafolder':
             if ($theme_row->mediafolder == '') {
                 return '';
             } else {
                 return 'images/' . $theme_row->mediafolder;
             }
             break;
         case 'videolist':
             if ($params != '') {
                 $pair = explode(',', $params);
                 switch ($pair[0]) {
                     case 'title':
                         return $videolist_row->listname;
                         break;
                     case 'description':
                         return YouTubeGalleryMisc::html2txt($videolist_row->description);
                         break;
                     case 'author':
                         return $videolist_row->author;
                         break;
                     case 'playlist':
                         $pl = YoutubeGalleryLayoutRenderer::getPlaylistIdsOnly($gallery_list);
                         $vlu = implode(',', $pl);
                         break;
                     case 'watchgroup':
                         return $videolist_row->watchusergroup;
                         break;
                     case 'authorurl':
                         return $videolist_row->authorurl;
                         break;
                     case 'image':
                         return $videolist_row->image;
                         break;
                     case 'note':
                         return $videolist_row->note;
                         break;
                 }
             }
             return $videolist_row->listname;
             break;
         case 'cols':
             return $theme_row->cols;
             break;
         case 'listname':
             return $videolist_row->listname;
             break;
         case 'videotitle':
             $title = str_replace('"', '"', YoutubeGalleryLayoutRenderer::getTitleByVideoID($videoid, $gallery_list));
             $title = YouTubeGalleryMisc::html2txt($title);
             if ($theme_row->openinnewwindow == 4 or $theme_row->openinnewwindow == 5) {
                 $title = '<div id="YoutubeGalleryVideoTitle' . $videolist_row->id . '">' . $title . '</div>';
             }
             if ($params != '') {
                 $pair = explode(',', $params);
                 $words = (int) $pair[0];
                 if (isset($pair[1])) {
                     $chars = (int) $pair[1];
                 } else {
                     $chars = 0;
                 }
                 $title = YoutubeGalleryLayoutRenderer::PrepareDescription($title, $words, $chars);
             }
             return $title;
             break;
         case 'videodescription':
             $description = str_replace('"', '&quot;', YoutubeGalleryLayoutRenderer::getDescriptionByVideoID($videoid, $gallery_list));
             $description = YouTubeGalleryMisc::html2txt($description);
             if ($params != '') {
                 $pair = explode(',', $params);
                 $words = (int) $pair[0];
                 if (isset($pair[1])) {
                     $chars = (int) $pair[1];
                 } else {
                     $chars = 0;
                 }
                 $description = YoutubeGalleryLayoutRenderer::PrepareDescription($description, $words, $chars);
             }
             if ($theme_row->openinnewwindow == 4 or $theme_row->openinnewwindow == 5) {
                 $description = '<div id="YoutubeGalleryVideoDescription' . $videolist_row->id . '">' . $description . '</div>';
             }
             return $description;
             break;
         case 'videoplayer':
             $pair = explode(',', $params);
             if ($params != '') {
                 $playerwidth = (int) $pair[0];
             } else {
                 $playerwidth = $width;
             }
             if (isset($pair[1])) {
                 $playerheight = (int) $pair[1];
             } else {
                 $playerheight = $height;
             }
             if ($theme_row->openinnewwindow == 4 or $theme_row->openinnewwindow == 5) {
                 //Update Player - without page reloading
                 YoutubeGalleryLayoutRenderer::addHotReloadScript($gallery_list, $playerwidth, $playerheight, $videolist_row, $theme_row);
             }
             return YoutubeGalleryLayoutRenderer::ShowActiveVideo($gallery_list, $playerwidth, $playerheight, $videoid, $videolist_row, $theme_row);
             break;
         case 'navigationbar':
             //classictable
             $pair = explode(',', $params);
             if ((int) $pair[0] > 0) {
                 $number_of_columns = (int) $pair[0];
             } else {
                 $number_of_columns = (int) $theme_row->cols;
             }
             if ($number_of_columns < 1) {
                 $number_of_columns = 3;
             }
             if ($number_of_columns > 10) {
                 $number_of_columns = 10;
             }
             if (isset($pair[1])) {
                 $navbarwidth = (int) $pair[1];
             } else {
                 $navbarwidth = $width;
             }
             return YoutubeGalleryLayoutRenderer::ClassicNavTable($gallery_list, $navbarwidth, $number_of_columns, $videolist_row, $theme_row, $AllowPagination, $videoid, $custom_itemid);
             break;
         case 'thumbnails':
             //simple list
             return YoutubeGalleryLayoutRenderer::NavigationList($gallery_list, $videolist_row, $theme_row, $AllowPagination, $videoid, $custom_itemid);
             break;
         case 'count':
             if ($params == 'all') {
                 return $videolist_row->TotalVideos;
             } else {
                 return count($gallery_list);
             }
             break;
         case 'pagination':
             return YoutubeGalleryLayoutRenderer::Pagination($theme_row, $gallery_list, $width, $total_number_of_rows);
             break;
         case 'width':
             return $width;
             break;
         case 'height':
             return $height;
             break;
         case 'instanceid':
             return $videolist_row->id;
             break;
         case 'videoid':
             return $videoid;
             break;
         case 'link':
             return $link = YouTubeGalleryMisc::full_url($_SERVER);
             //$_SERVER['HTTP_REFERER'];
             break;
         case 'social':
             return YoutubeGalleryLayoutRenderer::SocialButtons('window.location.href', 'yg', $params, $videolist_row->id, $videoid);
             break;
         case 'video':
             $pair = explode(':', $params);
             if ($pair[0] != "") {
                 $options = '';
                 if (isset($pair[1])) {
                     $options = $pair[1];
                 }
                 $tableFields = array('title', 'description', 'imageurl', 'videoid', 'videosource', 'publisheddate', 'duration', 'rating_average', 'rating_max', 'rating_min', 'rating_numRaters', 'keywords', 'commentcount', 'likes', 'dislikes', 'playlist');
                 $listitem = YoutubeGalleryLayoutRenderer::getVideoRowByID($videoid, $gallery_list, true);
                 //YoutubeGalleryLayoutRenderer::object_to_array($videolist_row);
                 return YoutubeGalleryLayoutRenderer::getTumbnailData($pair[0], "", "", $listitem, $tableFields, $options, $theme_row, $gallery_list, $videolist_row);
             }
             break;
     }
     //switch($fld)
 }
 public static function getListToReplace($par, &$options, &$text)
 {
     $temp_text = preg_replace("/<textarea\\b[^>]*>(.*?)<\\/textarea>/i", "", $text);
     $fList = array();
     $l = strlen($par) + 2;
     $offset = 0;
     do {
         if ($offset >= strlen($temp_text)) {
             break;
         }
         $ps = strpos($text, '{' . $par . '=', $offset);
         if ($ps === false) {
             break;
         }
         if ($ps + $l >= strlen($temp_text)) {
             break;
         }
         $pe = strpos($text, '}', $ps + $l);
         if ($pe === false) {
             break;
         }
         $notestr = substr($temp_text, $ps, $pe - $ps + 1);
         $fList[] = $notestr;
         $opt_string = substr($temp_text, $ps + $l, $pe - $ps - $l);
         $options[] = YouTubeGalleryMisc::html2txt($opt_string);
         $offset = $ps + $l;
     } while (!($pe === false));
     return $fList;
 }