Ejemplo n.º 1
0
 function getYoutubeGallery($galleryparams, $count, $byId)
 {
     $result = '';
     $opt = explode(',', $galleryparams);
     if (count($opt) < 2) {
         return '<p>YoutubeGallery Theme Not Set</p>';
     }
     $db = JFactory::getDBO();
     if ($byId) {
         $listid = (int) $opt[0];
         $themeid = (int) $opt[1];
         $query_list = 'SELECT * FROM #__youtubegallery_videolists WHERE id=' . $listid . ' LIMIT 1';
         $query_theme = 'SELECT * FROM #__youtubegallery_themes WHERE id=' . $themeid . ' LIMIT 1';
     } else {
         $listname = trim($opt[0]);
         $themename = trim($opt[1]);
         $query_list = 'SELECT * FROM #__youtubegallery_videolists WHERE listname="' . $listname . '" LIMIT 1';
         $query_theme = 'SELECT * FROM #__youtubegallery_themes WHERE themename="' . $themename . '" LIMIT 1';
     }
     //Video List data
     $db->setQuery($query_list);
     if (!$db->query()) {
         die($db->stderr());
     }
     $videolist_rows = $db->loadObjectList();
     if (count($videolist_rows) == 0) {
         return '<p>Video list not found</p>';
     }
     $videolist_row = $videolist_rows[0];
     //Theme data
     $db->setQuery($query_theme);
     if (!$db->query()) {
         die($db->stderr());
     }
     $theme_rows = $db->loadObjectList();
     if (count($theme_rows) == 0) {
         return '<p>Theme not found</p>';
     }
     $theme_row = $theme_rows[0];
     $custom_itemid = 0;
     if (isset($opt[2])) {
         $custom_itemid = (int) $opt[2];
     }
     $misc = new YouTubeGalleryMisc();
     $misc->videolist_row = $videolist_row;
     $misc->theme_row = $theme_row;
     $total_number_of_rows = 0;
     $misc->update_playlist();
     $videoid = JRequest::getVar('videoid');
     if (!isset($videoid)) {
         $video = JRequest::getVar('video');
         if (isset($video)) {
             $videoid = YouTubeGalleryMisc::getVideoIDbyAlias($video);
         }
     }
     if ($theme_row->playvideo == 1 and $videoid != '') {
         $theme_row->autoplay = 1;
     }
     $videoid_new = $videoid;
     $videolist = $misc->getVideoList_FromCache_From_Table($videoid_new, $total_number_of_rows);
     if ($videoid == '') {
         if ($theme_row->playvideo == 1 and $videoid_new != '') {
             $videoid = $videoid_new;
         }
     }
     $renderer = new YouTubeGalleryRenderer();
     $result .= $renderer->render($videolist, $videolist_row, $theme_row, $total_number_of_rows, $videoid, $custom_itemid);
     return $result;
 }
 }
 if (!$misc->getThemeTableRow($themeid)) {
     echo '<p>Theme not found</p>';
     $videolist_and_theme_found = false;
 }
 if ($videolist_and_theme_found) {
     $firstvideo = '';
     $youtubegallerycode = '';
     $total_number_of_rows = 0;
     $misc->update_playlist();
     $videoid = JRequest::getCmd('videoid', '');
     if (!isset($videoid) or $videoid == '') {
         $video = JRequest::getVar('video', '');
         $video = preg_replace('/[^a-zA-Z0-9-_]+/', '', $video);
         if ($video != '') {
             $videoid = YouTubeGalleryMisc::getVideoIDbyAlias($video);
         }
     }
     if ($misc->theme_row->playvideo == 1 and $videoid != '') {
         $misc->theme_row->autoplay = 1;
     }
     $videoid_new = $videoid;
     $videolist = $misc->getVideoList_FromCache_From_Table($videoid_new, $total_number_of_rows);
     if ($videoid == '') {
         if ($misc->theme_row->playvideo == 1 and $videoid_new != '') {
             $videoid = $videoid_new;
         }
     }
     $custom_itemid = (int) $params->get('customitemid');
     $renderer = new YouTubeGalleryRenderer();
     $gallerymodule = $renderer->render($videolist, $misc->videolist_row, $misc->theme_row, $total_number_of_rows, $videoid, $custom_itemid);