public function testAction()
 {
     //$developerKey = 'AI39si6Jo4JaiNjb5ocqdac1z1sJl_IuNjJyGnJ0uEt10GBJNxE0zpski0aP58TmriRIG9tUBS5oYE65SeAhE5iW2mEAtd_eeQ';
     $yt = new \ZendGData\YouTube();
     $query = $yt->newVideoQuery();
     $query->videoQuery = 'cat';
     $query->startIndex = 10;
     $query->maxResults = 20;
     $query->queryUrl . "\n";
     $videoFeed = $yt->getVideoFeed($query);
     foreach ($videoFeed as $videoEntry) {
         echo "---------VIDEO----------\n";
         echo "Title: " . $videoEntry->getVideoTitle() . "\n";
         echo "\nDescription:\n";
         echo $videoEntry->getVideoDescription();
         echo "\n\n\n";
     }
     return $this->getResponse();
 }
 /**
  * @deprecated since version number
  * not maintained
  * @return type
  */
 private function getGoogleVideos()
 {
     $yVideo = [];
     $cache = $this->getApcCache();
     $key = 'google_yVideo';
     if (!$cache->getItem($key)) {
         $client = $this->getGoogleClient();
         //        \Zend\Debug\Debug::dump($client);
         $yt = new \ZendGData\YouTube($client);
         $yt->setMajorProtocolVersion(2);
         $query = $yt->newVideoQuery();
         $query->setOrderBy('relevance');
         $query->setSafeSearch('none');
         $query->setVideoQuery('Zend Framework');
         //        \Zend\Debug\Debug::dump($userFeed);
         $videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
         $yVideos = array();
         foreach ($videoFeed as $videoEntry) {
             $yVideo = array();
             $yVideo['videoTitle'] = $videoEntry->getVideoTitle();
             $yVideo['videoDescription'] = $videoEntry->getVideoDescription();
             $yVideo['watchPage'] = $videoEntry->getVideoWatchPageUrl();
             $yVideo['duration'] = $videoEntry->getVideoDuration();
             $videoThumbnails = $videoEntry->getVideoThumbnails();
             $yVideo['thumbnailUrl'] = $videoThumbnails[0]['url'];
             $yVideos[] = $yVideo;
         }
         $cache->setItem($key, $yVideo);
     } else {
         $yVideo = $cache->getItem($key);
     }
     // Возвращение объединенного массива в представление для визуализации
     return $yVideo;
 }
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_last_youtube_playlist_videos($mod_reference, $module_params)
{
    global $prefs;
    $tikilib = TikiLib::lib('tiki');
    $data = array();
    $smarty = TikiLib::lib('smarty');
    if (!empty($module_params['id'])) {
        $id = $module_params['id'];
        // Catch common error on param values and convert into the right ones
        if ($params['allowFullScreen'] == 'y') {
            $params['allowFullScreen'] = 'true';
        } else {
            if ($params['allowFullScreen'] == 'n') {
                $params['allowFullScreen'] = 'false';
            }
        }
        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 \ZendGData\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;
            $params['allowFullScreen'] = isset($module_params['allowFullScreen']) ? $module_params['allowFullScreen'] : true;
            // 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]);
}