/** * @param $mod_reference * @param $module_params */ function module_last_youtube_playlist_videos($mod_reference, $module_params) { global $smarty, $prefs; $tikilib = TikiLib::lib('tiki'); $data = array(); if (!empty($module_params['id'])) { $id = $module_params['id']; require_once 'lib/wiki-plugins/wikiplugin_youtube.php'; if (!empty($module_params['orderby'])) { $orderby = $module_params['orderby']; $feedUrl = 'http://gdata.youtube.com/feeds/api/playlists/' . $id . '?orderby=' . $orderby; } else { $feedUrl = 'http://gdata.youtube.com/feeds/api/playlists/' . $id . '?orderby=position'; } $yt = new Zend_Gdata_YouTube(); $yt->setMajorProtocolVersion(2); $yt->setHttpClient($tikilib->get_http_client()); try { $playlistVideoFeed = $yt->getPlaylistVideoFeed($feedUrl); $data[$id]['info']['title'] = $playlistVideoFeed->title->text; // Prepare params for video display $params = array(); $params['width'] = isset($module_params['width']) ? $module_params['width'] : 425; $params['height'] = isset($module_params['height']) ? $module_params['height'] : 350; // Get information from all videos from playlist // Limit to $module_rows first videos if $module_rows is set $count_videos = 1; foreach ($playlistVideoFeed as $videoEntry) { $videoId = $videoEntry->getVideoId(); $data[$id]['videos'][$videoId]['title'] = $videoEntry->getVideoTitle(); $data[$id]['videos'][$videoId]['uploaded'] = $videoEntry->mediaGroup->uploaded->text; $data[$id]['videos'][$videoId]['description'] = $videoEntry->getVideoDescription(); $params['movie'] = $videoId; $pluginstr = wikiplugin_youtube('', $params); $len = strlen($pluginstr); //need to take off the ~np~ and ~/np~ at the beginning and end of the string returned by wikiplugin_youtube $data[$id]['videos'][$videoId]['xhtml'] = substr($pluginstr, 4, $len - 4 - 5); if (isset($module_rows) && $module_rows > 0 && $count_videos >= $module_rows) { break; } $count_videos++; } } catch (Exception $e) { $data[$id]['info']['title'] = tra('No Playlist found'); $data[$id]['videos'][0]['title'] = $e->getMessage(); } } else { $id = 0; $data[$id]['info']['title'] = tra('No Playlist found'); $data[$id]['videos'][0]['title'] = tra('No Playlist ID was provided'); } $smarty->assign('verbose', isset($module_params['verbose']) ? $module_params['verbose'] : 'y'); $smarty->assign('link_url', isset($module_params['link_url']) ? $module_params['link_url'] : ''); $smarty->assign('link_text', isset($module_params['link_text']) ? $module_params['link_text'] : 'More Videos'); $smarty->assign_by_ref('data', $data[$id]); }