Ejemplo n.º 1
0
 /**
  * getvideoselectAction
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function getvideoselectAction()
 {
     $this->core->logger->debug('core->controllers->VideoController->getvideoselectAction()');
     try {
         $arrVideos = array();
         $objRequest = $this->getRequest();
         $intChannelId = $objRequest->getParam('channelId');
         $strChannelUserId = $objRequest->getParam('channelUserId');
         $strElementId = $objRequest->getParam('elementId');
         $strValue = $objRequest->getParam('value');
         $strSearchQuery = $objRequest->getParam('searchString');
         switch ($intChannelId) {
             /*
              * Vimeo Controller
              */
             case $this->core->sysConfig->video_channels->vimeo->id:
                 /**
                  * Requires simplevimeo base class
                  */
                 require_once GLOBAL_ROOT_PATH . 'library/vimeo/vimeo.class.php';
                 $arrChannelUser = $this->core->sysConfig->video_channels->vimeo->users->user->toArray();
                 $intVideoTypeId = 1;
                 $arrVideos = array();
                 /**
                  * Get the vimeo video list
                  */
                 if ($strChannelUserId !== '' && $strChannelUserId !== 'publicAccess' && $strSearchQuery == '') {
                     if (is_array($arrChannelUser)) {
                         foreach ($arrChannelUser as $chUser) {
                             if ($chUser['id'] == $strChannelUserId) {
                                 $objResponse = VimeoVideosRequest::getList($strChannelUserId);
                             }
                         }
                     }
                     $arrVideos = $objResponse->getVideos();
                 } else {
                     if ($strChannelUserId !== '' && isset($strSearchQuery)) {
                         if ($strChannelUserId == 'publicAccess') {
                             $objResponse = VimeoVideosRequest::search($strSearchQuery);
                         } else {
                             $objResponse = VimeoVideosRequest::search($strSearchQuery, $strChannelUserId);
                         }
                         $arrVideos = $objResponse->getVideos();
                     }
                 }
                 // Set channel Users
                 $this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array(0 => $arrChannelUser) : $this->core->sysConfig->video_channels->vimeo->users->user->toArray();
                 break;
                 /**
                  * Youtube Controller
                  */
             /**
              * Youtube Controller
              */
             case $this->core->sysConfig->video_channels->youtube->id:
                 $arrChannelUser = $this->core->sysConfig->video_channels->youtube->users->user->toArray();
                 $intVideoTypeId = 2;
                 $objResponse = new Zend_Gdata_YouTube();
                 $objResponse->setMajorProtocolVersion(2);
                 if ($strChannelUserId !== '' && $strSearchQuery == '' && $strChannelUserId !== 'publicAccess') {
                     $arrVideos = $objResponse->getuserUploads($strChannelUserId);
                 } else {
                     if (isset($strChannelUserId) && isset($strSearchQuery)) {
                         if ($strChannelUserId !== 'publicAccess') {
                             $arrVideos = $objResponse->getVideoFeed('http://gdata.youtube.com/feeds/api/users/' . $strChannelUserId . '/uploads?q=' . urlencode($strSearchQuery));
                         } else {
                             $objQuery = $objResponse->newVideoQuery();
                             $objQuery->setOrderBy('viewCount');
                             $objQuery->setSafeSearch('none');
                             $objQuery->setVideoQuery($strSearchQuery);
                             $arrVideos = $objResponse->getVideoFeed($objQuery->getQueryUrl(2));
                         }
                     }
                 }
                 // Set Channel Users
                 $this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array(0 => $arrChannelUser) : $this->core->sysConfig->video_channels->youtube->users->user->toArray();
                 break;
         }
         $this->view->videoTypeId = $intVideoTypeId;
         $this->view->elements = $arrVideos;
         $this->view->channelUserId = $strChannelUserId;
         $this->view->value = $strValue;
         $this->view->elementId = $strElementId;
         $this->view->SearchQuery = $strSearchQuery;
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
         exit;
     }
 }