本文整理汇总了PHP中PH7\Form::wrongVideoFileTypeMsg方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::wrongVideoFileTypeMsg方法的具体用法?PHP Form::wrongVideoFileTypeMsg怎么用?PHP Form::wrongVideoFileTypeMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PH7\Form
的用法示例。
在下文中一共展示了Form::wrongVideoFileTypeMsg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
/**
* This can cause minor errors (eg if a user sent a file that is not a video).
* So we hide the errors if we are not in development mode.
*/
if (!isDebug()) {
error_reporting(0);
}
/**
* Check if the video album ID is valid. The value must be numeric.
* This test is necessary because when the selection exists but that no option is available (this can when a user wants to add a video but he has no album)
* the return value is of type "string" and the value is "1".
*/
if (!is_numeric($this->httpRequest->post('album_id'))) {
\PFBC\Form::setError('form_video', t('Please add a category before you add a video.'));
return;
// Stop execution of the method.
}
$sAlbumTitle = $this->httpRequest->post('album_title');
$iAlbumId = (int) $this->httpRequest->post('album_id');
/** Default URL Thumbnail **/
$sThumb = '';
if ($this->httpRequest->postExists('embed_code')) {
$sEmbedUrl = $this->httpRequest->post('embed_code');
if (!($sFile = (new V\Api())->getVideo($sEmbedUrl))) {
\PFBC\Form::setError('form_video', t('Oops, the link of the video looks bad? Check that the link is correct.'));
return;
}
if (!($oInfo = (new V\Api())->getInfo($sEmbedUrl))) {
\PFBC\Form::setError('form_video', t('Unable to retrieve information from the video. Are you sure that the URL of the video is correct?'));
return;
}
$sTitle = $this->httpRequest->postExists('title') && $this->str->length($this->str->trim($this->httpRequest->post('title'))) > 2 ? $this->httpRequest->post('title') : ($oInfo->getTitle() ? $oInfo->getTitle() : t('Untitled'));
$sDescription = $this->httpRequest->postExists('description') ? $this->httpRequest->post('description') : ($oInfo->getDescription() ? $oInfo->getDescription() : '');
$sDuration = $oInfo->getDuration() ? $oInfo->getDuration() : '0';
// Time in seconds
if (!$sFile) {
\PFBC\Form::setError('form_video', t('Invalid Api Video Type! Choose from Youtube, Vimeo, Dailymotion and Metacafe.'));
return;
}
} elseif (!empty($_FILES['video']['tmp_name'])) {
$oVideo = new V\Video($_FILES['video'], 2500, 2500);
if (!$oVideo->validate()) {
\PFBC\Form::setError('form_video', Form::wrongVideoFileTypeMsg());
return;
} elseif (!$oVideo->check()) {
\PFBC\Form::setError('form_video', t('File exceeds maximum allowed video filesize of %0%!', F\Various::bytesToSize($oVideo->getMaxSize())));
return;
} else {
// It creates a nice title if no title is specified.
$sTitle = $this->httpRequest->postExists('title') && $this->str->length($this->str->trim($this->httpRequest->post('title'))) > 2 ? $this->httpRequest->post('title') : $this->str->upperFirst(str_replace(array('-', '_'), ' ', str_ireplace(PH7_DOT . $oVideo->getExt(), '', escape($_FILES['video']['name'], true))));
$sDescription = $this->httpRequest->post('description');
$sDuration = $oVideo->getDuration();
$sPath = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'video/file/' . $this->session->get('member_username') . PH7_DS . $iAlbumId . PH7_DS;
$sFileName = Various::genRnd($oVideo->getFileName(), 20);
$sThumb = $sFileName . '.jpg';
$sThumb1 = $sFileName . '-1.jpg';
$sThumb2 = $sFileName . '-2.jpg';
$sThumb3 = $sFileName . '-3.jpg';
$sThumb4 = $sFileName . '-4.jpg';
$sFile = $sFileName;
$oVideo->thumbnail($sPath . $sThumb, 1, 320, 240);
$oVideo->thumbnail($sPath . $sThumb1, 4, 320, 240);
$oVideo->thumbnail($sPath . $sThumb2, 6, 320, 240);
$oVideo->thumbnail($sPath . $sThumb3, 8, 320, 240);
$oVideo->thumbnail($sPath . $sThumb4, 10, 320, 240);
$oVideo->rename($sPath . $sFile . '.webm');
$oVideo->rename($sPath . $sFile . '.mp4');
//$oVideo->save($sPath . $sFile); // Original file type
}
} else {
\PFBC\Form::setError('form_video', t('You must choose a type of video!'));
return;
}
$iApproved = DbConfig::getSetting('videoManualApproval') == 0 ? '1' : '0';
(new VideoModel())->addVideo($this->session->get('member_id'), $iAlbumId, $sTitle, $sDescription, $sFile, $sThumb, $sDuration, $this->dateTime->get()->dateTime('Y-m-d H:i:s'), $iApproved);
/* Clean VideoModel Cache */
(new Framework\Cache\Cache())->start(VideoModel::CACHE_GROUP, null, null)->clear();
$sModerationText = t('Your video has been received! But it will be visible once approved by our moderators. Please do not send a new video because this is useless!');
$sText = t('Your video has been added successfully!');
$sMsg = $iApproved == '0' ? $sModerationText : $sText;
Header::redirect(Uri::get('video', 'main', 'album', $this->session->get('member_username') . ',' . $sAlbumTitle . ',' . $iAlbumId), $sMsg);
}