Пример #1
0
 public static function ShowActiveVideo($gallery_list, $width, $height, $videoid, &$videolist_row, &$theme_row, $videosource = '')
 {
     jimport('joomla.version');
     $version = new JVersion();
     $JoomlaVersionRelease = $version->RELEASE;
     $VideoRow = YoutubeGalleryLayoutRenderer::getVideoRowByID($videoid, $gallery_list);
     if ($theme_row->changepagetitle != 3) {
         $mainframe = JFactory::getApplication();
         $sitename = $mainframe->getCfg('sitename');
         if ($VideoRow) {
             $title = $VideoRow['title'];
         } else {
             $title = '';
         }
         //$title=YoutubeGalleryLayoutRenderer::getTitleByVideoID($videoid,$gallery_list);
         $mydoc = JFactory::getDocument();
         if ($theme_row->changepagetitle == 0) {
             $mydoc->setTitle($title . ' - ' . $sitename);
         } elseif ($theme_row->changepagetitle == 1) {
             $mydoc->setTitle($sitename . ' - ' . $title);
         } elseif ($theme_row->changepagetitle == 2) {
             $mydoc->setTitle($title);
         }
     }
     $result = '';
     if ($videoid) {
         $vpoptions = array();
         $vpoptions['width'] = $width;
         $vpoptions['height'] = $height;
         $vpoptions['videoid'] = $videoid;
         $vpoptions['autoplay'] = $theme_row->autoplay;
         $vpoptions['showinfo'] = $theme_row->showinfo;
         $vpoptions['relatedvideos'] = $theme_row->related;
         $vpoptions['repeat'] = $theme_row->repeat;
         $vpoptions['allowplaylist'] = $theme_row->allowplaylist;
         $vpoptions['border'] = $theme_row->border;
         $vpoptions['color1'] = $theme_row->color1;
         $vpoptions['color2'] = $theme_row->color2;
         $vpoptions['controls'] = $theme_row->controls;
         $vpoptions['playertype'] = $theme_row->playertype;
         $vpoptions['youtubeparams'] = $theme_row->youtubeparams;
         $vpoptions['fullscreen'] = $theme_row->fullscreen;
         $list_index = YoutubeGalleryLayoutRenderer::getListIndexByVideoID($videoid, $gallery_list);
         if ($list_index == -1) {
             //Hot Switch
             if ($videosource != '') {
                 $vs = $videosource;
             } else {
                 $vs = '';
             }
             $image_link = '';
             $startsecond = '****youtubegallery-video-startsecond****';
             $endsecond = '****youtubegallery-video-endsecond****';
         } else {
             if ($videosource != '') {
                 $vs = $videosource;
             } else {
                 $vs = $gallery_list[$list_index]['videosource'];
             }
             $image_link = $gallery_list[$list_index]['imageurl'];
             $startsecond = $gallery_list[$list_index]['startsecond'];
             $endsecond = $gallery_list[$list_index]['endsecond'];
         }
         if ($theme_row->prepareheadtags == 2 or $theme_row->prepareheadtags == 3) {
             if ($image_link != '' and strpos($image_link, '#') === false) {
                 $curPageUrl = YoutubeGalleryLayoutRenderer::curPageURL();
                 $document = JFactory::getDocument();
                 $image_link_array = explode(',', $image_link);
                 if (count($image_link_array) >= 3) {
                     $imagelink = $image_link_array[3];
                 } else {
                     $imagelink = $image_link_array[0];
                 }
                 $imagelink = (strpos($imagelink, 'http://') === false and strpos($image_link, 'https://') === false ? $curPageUrl . '/' : '') . $imagelink;
                 if (isset($_SERVER["HTTPS"]) and $_SERVER["HTTPS"] == "on") {
                     $imagelink = str_replace('http://', 'https://', $imagelink);
                 }
                 $document->addCustomTag('<link rel="image_src" href="' . $imagelink . '" /><!-- active -->');
             }
         }
         if ((int) $vpoptions['width'] == 0) {
             $width = 400;
         } else {
             $width = (int) $vpoptions['width'];
         }
         if ((int) $vpoptions['height'] == 0) {
             $height = 200;
         } else {
             $height = (int) $vpoptions['height'];
         }
         switch ($vs) {
             case 'break':
                 require_once 'break.php';
                 $result .= VideoSource_Break::renderBreakPlayer($vpoptions, $width, $height, $videolist_row, $theme_row);
                 break;
             case 'vimeo':
                 require_once 'vimeo.php';
                 $result .= VideoSource_Vimeo::renderVimeoPlayer($vpoptions, $width, $height, $videolist_row, $theme_row);
                 break;
             case 'own3dtvlive':
                 require_once 'own3dtvlive.php';
                 $result .= VideoSource_Own3DTvLive::renderOwn3DTvLivePlayer($vpoptions, $width, $height, $videolist_row, $theme_row);
                 break;
             case 'own3dtvvideo':
                 require_once 'own3dtvvideo.php';
                 $result .= VideoSource_Own3DTvVideo::renderOwn3DTvVideoPlayer($vpoptions, $width, $height, $videolist_row, $theme_row);
                 break;
             case 'youtube':
                 //if($vpoptions['autoplay']==1 and $vpoptions['repeat']==1 )
                 //{
                 $pl = YoutubeGalleryLayoutRenderer::getYoutubeVideoIdsOnly($gallery_list, $videoid);
                 //print_r($pl);
                 //die;
                 $shorten_pl = array();
                 $i = 0;
                 foreach ($pl as $p) {
                     $i++;
                     if ($i > 20) {
                         break;
                     }
                     $shorten_pl[] = $p;
                 }
                 $YoutubeVideoList = implode(',', $shorten_pl);
                 if ($vpoptions['youtubeparams'] == '') {
                     $vpoptions['youtubeparams'] = 'playlist=' . $YoutubeVideoList;
                 } else {
                     $vpoptions['youtubeparams'] .= ';playlist=' . $YoutubeVideoList;
                 }
                 //}
                 require_once 'youtube.php';
                 $temp = VideoSource_Youtube::renderYouTubePlayer($vpoptions, $width, $height, $videolist_row, $theme_row, $startsecond, $endsecond);
                 if ($temp != '') {
                     if ($theme_row->useglass or $theme_row->logocover) {
                         $result .= '<div style="position: relative;width:' . $width . 'px;height:' . $height . 'px;padding:0;">';
                     }
                     $result .= $temp;
                     if ($theme_row->logocover) {
                         if ($theme_row->controls and ($theme_row->playertype == 3 or $theme_row->playertype == 4)) {
                             $bottom_px = '25';
                         } else {
                             $bottom_px = '0';
                         }
                         $result .= '<div style="position: absolute;bottom:' . $bottom_px . 'px;right:0px;margin-top:0px;margin-left:0px;">' . '<img src="' . $theme_row->logocover . '" style="margin:0px;padding:0px;display:block;border: none;" /></div>';
                     }
                     if ($theme_row->useglass) {
                         $result .= '<div style="position: absolute;background-image: url(\'components/com_youtubegallery/images/dot.png\');' . 'top:0px;left:0px;width:' . $width . 'px;height:' . ($height - 25) . 'px;margin-top:0px;margin-left:0px;padding:0px;"></div>';
                     }
                     if ($theme_row->useglass or $theme_row->logocover) {
                         $result .= '</div>';
                     }
                 }
                 break;
             case 'google':
                 require_once 'google.php';
                 $result .= VideoSource_Google::renderGooglePlayer($vpoptions, $width, $height, $videolist_row, $theme_row);
                 break;
             case 'yahoo':
                 require_once 'yahoo.php';
                 $vpoptions['thumbnail'] = YoutubeGalleryLayoutRenderer::getThumbnailByID($videoid, $gallery_list);
                 $result .= VideoSource_Yahoo::renderYahooPlayer($vpoptions, $width, $height, $videolist_row, $theme_row);
                 break;
             case 'collegehumor':
                 require_once 'collegehumor.php';
                 $vpoptions['thumbnail'] = YoutubeGalleryLayoutRenderer::getThumbnailByID($videoid, $gallery_list);
                 $result .= VideoSource_CollegeHumor::renderCollegeHumorPlayer($vpoptions, $width, $height, $videolist_row, $theme_row);
                 break;
             case 'dailymotion':
                 require_once 'dailymotion.php';
                 $vpoptions['thumbnail'] = YoutubeGalleryLayoutRenderer::getThumbnailByID($videoid, $gallery_list);
                 $result .= VideoSource_DailyMotion::renderDailyMotionPlayer($vpoptions, $width, $height, $videolist_row, $theme_row);
                 break;
             case 'presentme':
                 require_once 'presentme.php';
                 $vpoptions['thumbnail'] = YoutubeGalleryLayoutRenderer::getThumbnailByID($videoid, $gallery_list);
                 $result .= VideoSource_PresentMe::renderPresentMePlayer($vpoptions, $width, $height, $videolist_row, $theme_row);
                 break;
             case 'ustream':
                 require_once 'ustream.php';
                 $vpoptions['thumbnail'] = YoutubeGalleryLayoutRenderer::getThumbnailByID($videoid, $gallery_list);
                 $result .= VideoSource_Ustream::renderUstreamPlayer($vpoptions, $width, $height, $videolist_row, $theme_row);
                 break;
             case '.flv':
                 if ($list_index != -1) {
                     //Not Hot Switch
                     $vpoptions['thumbnail'] = $gallery_list[$list_index]['imageurl'];
                     //YoutubeGalleryLayoutRenderer::getThumbnailByID($videoid,$gallery_list);;
                     $videolink = $gallery_list[$list_index]['link'];
                 } else {
                     $videolink = '****youtubegallery-video-link****';
                 }
                 //For Hot Switch
                 require_once 'flv.php';
                 $result .= VideoSource_FLV::renderFLVPlayer($vpoptions, $width, $height, $videolist_row, $theme_row, $videolink);
                 break;
         }
     }
     $imageurl = '';
     $isHot = false;
     if ($videoid == '****youtubegallery-video-id****') {
         $isHot = true;
         $videoid_d = 'hot' . $videolist_row->id;
         $imageurl = '****youtubegallery-video-customimage****';
     } else {
         $videoid_d = $videoid;
         if ($VideoRow) {
             $imageurl = $VideoRow['custom_imageurl'];
         }
     }
     if ($imageurl != '' and $theme_row->rel == '' and strpos($imageurl, '#') === false and strpos($imageurl, '_small') === false) {
         //Specific preview image for your YouTube video
         //The idea of Jarrett Gucci (Modified: play button added)
         $result = ($isHot ? '***code_begin***' : '') . '<div onclick="ygimage' . $videoid_d . '=document.getElementById(\'ygvideoplayer' . $videoid_d . '\');ygimage' . $videoid_d . '.style.display=\'block\';this.style.display=\'none\'"' . ' style="position:relative;width:' . $width . 'px;height:' . $height . 'px;padding:0;">' . '<img src="' . $imageurl . '" style="cursor:pointer;width:' . $width . 'px;height:' . $height . 'px;padding:0;" />' . '<div style="position:absolute;width:100px;height:100px;left:' . floor($width / 2 - 50) . 'px;top:' . floor($height / 2 - 50) . 'px;">' . '<img src="components/com_youtubegallery/images/play.png" style="border:none!important;cursor:pointer;width:100px;height:100px;padding:0;" />' . '</div>' . '</div>' . '<div id="ygvideoplayer' . $videoid_d . '" style="display:none">' . ($isHot ? '***code_end***' : '') . $result . ($isHot ? '***code_begin***' : '') . '</div>' . ($isHot ? '***code_end***' : '');
     }
     if ($videoid != '****youtubegallery-video-id****') {
         $result = str_replace('****youtubegallery-video-id****', $videoid, $result);
     } else {
         $result = str_replace('\'', '*quote*', $result);
     }
     //alteracao projeto portal padrao: retirada do atributo style
     $result = '<div id="YoutubeGallerySecondaryContainer' . $videolist_row->id . '">' . $result . '</div>';
     //fim alteracao projeto portal padrao
     return $result;
 }