34 parent::__construct(
'Video');
37 $this->sWorkingFile = CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri() .
'albums/my/add_objects';
39 $iMaxByAdmin = 1024*1024*(int)
getParam($this->oModule->_oConfig->getMainPrefix() .
'_max_file_size');
40 if ($iMaxByAdmin > 0 && $iMaxByAdmin < $this->iMaxFilesize)
41 $this->iMaxFilesize = $iMaxByAdmin;
43 $this->sAcceptMimeType =
'*';
60 if(isset($aDefaultValues[
'image']))
61 $sVideoUrl = $aDefaultValues[
'image'];
62 else if(!
empty($iFileID)) {
63 $aVideoInfo =
ChWsbService::call(
'videos',
'get_video_array', array($iFileID),
'Search');
64 $sVideoUrl = $aVideoInfo[
'file'];
67 $sVideoUrl .= (
false === strpos($sVideoUrl,
'?') ?
'?' :
'&') .
'_t=' .
time();
69 $sProtoEl =
'<img src="' . $sVideoUrl .
'" />';
71 $aPossibleImage = array();
72 $aPossibleImage[
'preview_image'] = array(
74 'content' => $sProtoEl,
75 'caption' =>
_t(
'_ch_videos_preview'),
78 $aPossibleDuration = array();
79 $aPossibleDuration[
'duration'] = array(
82 'value' => isset($aDefaultValues[
'duration']) ? $aDefaultValues[
'duration'] :
"0"
85 return $this->
_GenSendFileInfoForm($iFileID, $aDefaultValues, $aPossibleImage, $aPossibleDuration);
90 if ($bRet = parent::serviceCancelFileInfo())
91 deleteVideo($iFileID, $this->oModule->_oConfig->aFilesConfig);
99 return isset($a[
'id']) && $a[
'id'] ? $a[
'id'] :
false;
110 $sErrorReturn =
'<script type="text/javascript">parent.' . $this->_sJsPostObject .
'.showErrorMsg("video_embed_failed_message");parent.' . $this->_sJsPostObject .
'.resetEmbed();</script>';
111 $sVideoId = substr(trim($_POST[
'embed']), -11);
112 if(
empty($sVideoId))
return $sErrorReturn;
114 $aSiteInfo =
getSiteInfo(
'https://www.youtube.com/watch?v=' . $sVideoId, array(
116 'duration' => array(),
117 'thumbnailUrl' => array(
'tag' =>
'link',
'content_attr' =>
'href'),
123 $sDesc = $aSiteInfo[
'description'];
124 $sTags = $aSiteInfo[
'keywords'];
125 $sImage = $aSiteInfo[
'thumbnailUrl'];
126 $iDuration = (int)$aSiteInfo[
'duration'];
138 $sJSVideoId = (int)$_POST[
'file_id'];
139 switch($_POST[
'type']) {
141 $iVideoID = (int)
embedVideo($iAuthorId, $_POST[
'video'], $_POST[
'duration'], $this->oModule->_oConfig->aFilesConfig);
143 $this->
addObjectToAlbum($this->oModule->oAlbums, $_POST[
'extra_param_album'], $iVideoID, $bUpdateCounter);
147 $this->
addObjectToAlbum($this->oModule->oAlbums, $_POST[
'extra_param_album'], $iVideoID,
false);
151 $iVideoID = $sJSVideoId;
155 if ($iVideoID && $iAuthorId) {
158 $sDescription = $_POST[
'description'];
160 $aCategories = array();
161 foreach ($_POST[
'Categories']
as $sKey => $sVal) {
163 $aCategories[] = $sVal;
169 return '<script type="text/javascript">parent.' . $this->_sJsPostObject .
'.onSuccessSendingFileInfo("' . $sJSVideoId .
'");</script>';
172 return '<script type="text/javascript">parent.' . $this->_sJsPostObject .
'.showErrorMsg("video_failed_message");</script>';
178 if(
empty($sAuthorCheck)) {
180 if($sEmbedThumbUrl) {
181 $this->oModule->isAllowedAdd(
true);
182 $aDefault = array(
'video' => $sVideoId,
'title' =>
$sTitle,
'description' =>
$sDesc,
'tags' =>
$sTags,
'duration' => $iDuration,
'image' => $sEmbedThumbUrl,
'type' =>
"embed");
187 return $sAuthorCheck;
193 if(
empty($sAuthorCheck)) {
195 if($sRecordThumbUrl) {
196 $this->oModule->isAllowedAdd(
true);
197 $aDefault = array(
'image' => $sRecordThumbUrl,
'type' =>
"record");
202 return $sAuthorCheck;
210 function performUpload ($sFilePath, $sRealFilename =
'',
$aInfo = array(), $isMoveUploadedFile =
true, $aExtraParams = array())
212 $bUpdateAlbumCounter =
false;
214 if ($this->_iOwnerId)
218 $sRealFilename = pathinfo($sFilePath, PATHINFO_BASENAME);
223 return array(
'error' =>
_t(
'_LOGIN_REQUIRED_AE1'));
225 if (!$this->oModule->_oConfig->checkAllowedExtsByFilename($sRealFilename))
226 return array(
'error' =>
_t(
'_sys_txt_wrong_file_extension'));
228 if (!$this->oModule->isAllowedAdd())
229 return array(
'error' =>
_t(
'_Access denied'));
234 include(
$GLOBALS[
'sModulesPath'] .
$GLOBALS[
'sModule'] .
'/inc/header.inc.php');
236 $this->sTempFilename = pathinfo($sRealFilename, PATHINFO_FILENAME);
238 return array(
'error' =>
_t(
'_sys_txt_upload_failed'));
242 $sFile1 =
$GLOBALS[
'dir'][
'root'] .
'flash/modules/video/files/' . $iMID;
243 $sFile2 =
$GLOBALS[
'dir'][
'root'] .
'flash/modules/video/files/' . $iMID .
'.m4v';
245 if($aVideoData[
'CodecName'] ==
'h264') {
246 $sAutoApprove =
'on' ==
getParam(
'videoAutoApprove') ?
'approved' :
'disapproved';
247 rename($sFile1, $sFile2);
249 'Time' => (
int)$aVideoData[
'Duration']*1000,
254 'Status' => $sAutoApprove,
256 $this->oModule->_oDb->updateVideo($iMID, $aData);
257 $bUpdateAlbumCounter =
true;
259 $this->oModule->_oDb->updateVideo($iMID, array(
'Status' =>
'pending'));
265 foreach (array(
'title',
'categories',
'tags',
'desc')
as $sKey)
273 $sAlbum =
empty($_POST[
'extra_param_album']) ?
getParam(
'sys_album_default_name') : $_POST[
'extra_param_album'];
274 $aAlbumParams = isset($_POST[
'extra_param_albumPrivacy']) ? array(
'privacy' => (
int)$_POST[
'extra_param_albumPrivacy']) : array();
279 $this->oModule->isAllowedAdd(
true,
true);
283 return array(
'id' => $iMID);