Exemplo n.º 1
0
 /**
  * getselectedvideoAction
  * @author Dominik Mößlang <*****@*****.**>
  * @version 1.0
  */
 public function getselectedvideoAction()
 {
     $this->core->logger->debug('core->controllers->VideoController->getselectedvideoAction()');
     $strVideoTypeName = '';
     $intVideoTypeId = '';
     $objSelectedVideo = '';
     try {
         $objRequest = $this->getRequest();
         $intChannelId = $objRequest->getParam('channelId');
         $strElementId = $objRequest->getParam('elementId');
         $strValue = $objRequest->getParam('value');
         $strChannelUserId = $objRequest->getParam('channelUserId');
         $arrSelectedVideo = array();
         switch ($intChannelId) {
             /**
              * Vimeo Controller
              */
             case $this->core->sysConfig->video_channels->vimeo->id:
                 require_once GLOBAL_ROOT_PATH . 'library/vimeo/vimeo.class.php';
                 $intVideoTypeId = 1;
                 $strVideoTypeName = "Vimeo";
                 /**
                  * Get the selected Video
                  */
                 if (isset($strValue)) {
                     $objResponse = VimeoVideosRequest::getInfo($strValue);
                     $objSelectedVideo = $objResponse->getVideo();
                 }
                 break;
                 /**
                  * Youtube Controller
                  */
             /**
              * Youtube Controller
              */
             case $this->core->sysConfig->video_channels->youtube->id:
                 $intVideoTypeId = 2;
                 $strVideoTypeName = "YouTube";
                 $objResponse = new Zend_Gdata_YouTube();
                 $objResponse->setMajorProtocolVersion(2);
                 /**
                  * Get the selected Video
                  */
                 if (isset($strValue)) {
                     $objSelectedVideo = $objResponse->getVideoEntry($strValue);
                 }
                 break;
         }
         $this->view->strVideoTypeName = $strVideoTypeName;
         $this->view->intVideoTypeId = $intVideoTypeId;
         $this->view->objSelectedVideo = $objSelectedVideo;
         $this->view->strValue = $strValue;
         $this->view->strElementId = $strElementId;
         $this->view->strChannelUserId = $strChannelUserId;
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
         exit;
     }
 }
Exemplo n.º 2
0
 /**
  * Proxy for video uploads
  * 
  * Will call the given video upload handler method (default: executeVideopostCall_FSOCK)
  * for the raw connection and send stuff
  * 
  * @access   public
  * @param    string          Local filename to be transfered
  * @param    string          Ticket
  * @return   string          VimeoVideosCheckUploadStatusResponse
  */
 public function executeVideopostCall($sFilename, $sTicket = false)
 {
     // Check that the upload query handler method exists and can be called
     if (!method_exists(__CLASS__, self::VIDEOPOST_ENGINE_FSOCK)) {
         throw new VimeoUploadException('Upload error: Videopost engine handler method not found', 1);
     }
     // If permission requirement is not met refuse to even call the API, safes bandwith for both ends
     if (!self::checkPermission(VimeoBase::PERMISSION_WRITE)) {
         throw new VimeoUploadException('Upload error: Missing "write" permission for current user', 2);
     }
     // Check that the file exists
     if (!file_exists($sFilename)) {
         throw new VimeoUploadException('Upload error: Local file does not exists', 3);
     }
     // Check that the file is readable
     if (!is_readable($sFilename)) {
         throw new VimeoUploadException('Upload error: Local file is not readable', 4);
     }
     // Check that the file size is not larger then the allowed size you can upload
     $oResponse = VimeoPeopleRequest::getUploadStatus();
     if (filesize($sFilename) > $oResponse->getRemainingBytes()) {
         throw new VimeoUploadException('Upload error: Videosize exceeds remaining bytes', 5);
     }
     // Try to get a upload ticket
     if (!$sTicket) {
         $oResponse = VimeoVideosRequest::getUploadTicket();
         $sTicket = $oResponse->getTicket();
     }
     // Build up the needed API arguments
     // Set API key
     $aArgs['api_key'] = self::$sApiKey;
     // Set request format
     $aArgs['format'] = 'php';
     // Set token
     if (self::$sToken) {
         $aArgs['auth_token'] = self::$sToken;
     }
     // Set ticket
     $aArgs['ticket_id'] = $sTicket;
     // Generate signature
     $aArgs['api_sig'] = self::buildSignature($aArgs);
     // Set file
     $aArgs['file'] = "@{$sFilename}";
     // Do the upload
     $sResponse = call_user_func(array(__CLASS__, self::VIDEOPOST_ENGINE_FSOCK), $aArgs);
     // Call vimeo.videos.checkUploadStatus to prevent abandoned status
     return VimeoVideosRequest::checkUploadStatus($sTicket);
 }
Exemplo n.º 3
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();
                 $intIdVideoType = 1;
                 if (array_key_exists('id', $arrChannelUser)) {
                     // Now lets do the user search query. We will get an response object containing everything we need
                     $objResponse = VimeoVideosRequest::getList($this->core->sysConfig->video_channels->vimeo->users->user->id);
                     // We want the result videos as an array of objects
                     $arrVideos = $objResponse->getVideos();
                 } else {
                     if ($strChannelUserId !== '') {
                         if (is_array($arrChannelUser)) {
                             foreach ($arrChannelUser as $chUser) {
                                 if ($chUser['id'] == $strChannelUserId) {
                                     // Now lets do the user search query. We will get an response object containing everything we need
                                     $objResponse = VimeoVideosRequest::getList($strChannelUserId);
                                     // We want the result videos as an array of objects
                                     $arrVideos = $objResponse->getVideos();
                                 }
                             }
                         }
                     }
                 }
                 // Set Channel Users
                 $this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array() : $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();
                 $intIdVideoType = 2;
                 $objResponse = new Zend_Gdata_YouTube();
                 $objResponse->setMajorProtocolVersion(2);
                 if (array_key_exists('id', $arrChannelUser) && $strSearchQuery === '') {
                     $arrVideos = $objResponse->getuserUploads($this->core->sysConfig->video_channels->youtube->users->user->id);
                 } else {
                     if ($strChannelUserId !== '') {
                         $arrVideos = $objResponse->getuserUploads($strChannelUserId);
                     } else {
                         if ($strSearchQuery !== '') {
                             $query = $objResponse->newVideoQuery();
                             $query->setOrderBy('viewCount');
                             $query->setSafeSearch('none');
                             $query->setVideoQuery($strSearchQuery);
                             $arrVideos = $objResponse->getVideoFeed($query->getQueryUrl(2));
                         }
                     }
                 }
                 // Set Channel Users
                 $this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array() : $this->core->sysConfig->video_channels->youtube->users->user->toArray();
                 break;
         }
         $this->view->idVideoType = $intIdVideoType;
         $this->view->elements = $arrVideos;
         $this->view->channelUserId = $strChannelUserId;
         $this->view->value = $strValue;
         $this->view->elementId = $strElementId;
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
         exit;
     }
 }