public function getCMSFields() { $fields = parent::getCMSFields(); // if($this->JobID){ // $fields->addFieldToTab("Root.Main", new LiteralField("JobID", // "<p class=\"message good\">Transcoding job ID: {$this->JobID}, Status: {$this->JobStatus}</p>")); // } // if transcoding started or error if (Session::get('VideoNotification')) { $num = 0; foreach (Session::get('VideoNotification') as $type => $message) { $num += 1; $fields->addFieldToTab("Root.Main", new LiteralField("VideoNotification_" . $num, "<p class=\"message {$type}\">{$message}</p>")); } Session::clear('VideoNotification'); } $UploadSizeMB = 350 * 1024 * 1024; // 350 MB in bytes // Switch between two views; // - Uploadfield for source file (any type) to be transcoded OR // - Uploadfields for manually transcoded files $mode = new DropdownField('DefaultView', _t('Transcodable.Mode', 'Mode'), array('source' => _t('Transcodable.SourceForTranscoding', 'Upload source file for transcoding'), 'transcoded' => _t('Transcodable.EncodedFormats', 'Upload HTML5 encoded formats'))); // $mode->setRightTitle(_t('Transcodable.ModeExplain', // 'Upload a source file to be transcoded to all (missing) HTML5 formats. If your source file is already in one of the HTML5 formats, choose "HTML encoded formats" and upload it into the correct upload field (MP4, WEBM or OGG) to have that used as original for transcoding. Only missing formats will be transcoded.')); $sourcehead = LiteralField::create('SourceHead', '<h2>' . _t('Transcodable.VideoFiles', 'Video files') . '</h2>' . '<p style="font-size: 120%; max-width: 640px; line-height: 130%;">' . _t('Transcodable.VideoFilesExplain', 'Upload a source file to be transcoded to all (missing) HTML5 formats and a poster image. If your source file is already in one of the HTML5 formats, choose "HTML encoded formats" and upload it into the correct upload field (MP4, WEBM or OGG) to have that used as original for transcoding. Only missing formats/files will be transcoded.') . '</p>'); $appextensions = Config::inst()->get('File', 'app_categories'); $movextensions = $appextensions['mov']; array_push($movextensions, 'mp4'); // add mp4 to video (seen as audio) $sourcefield = ChunkedUploadField::create("Source")->setTitle(_t('Transcodable.SourceVideo', "Source video"))->setFolderName('videos')->setAllowedExtensions($movextensions); $sourcefield->getValidator()->setAllowedMaxFileSize($UploadSizeMB); $sourcefieldHolder = DisplayLogicWrapper::create($sourcefield)->displayIf('DefaultView')->isEqualTo("source")->end(); $posterfield = UploadField::create("Poster")->setTitle("'Poster' image")->setFolderName('videos')->setAllowedExtensions(array("jpg", "jpeg", "gif", "png")); // $posterfieldHolder = DisplayLogicWrapper::create($posterfield) // ->displayIf('DefaultView')->isEqualTo("source")->end(); $mp4field = ChunkedUploadField::create("MP4")->setTitle(_t('Transcodable.MP4video', "MP4 video"))->setFolderName('videos')->setAllowedExtensions(array("mp4")); $mp4field->getValidator()->setAllowedMaxFileSize($UploadSizeMB); $mp4fieldHolder = DisplayLogicWrapper::create($mp4field)->displayIf('DefaultView')->isEqualTo("transcoded")->end(); // $mp4field->displayIf("DefaultView")->isEqualTo("transcoded")->end(); $webmfield = ChunkedUploadField::create("WEBM")->setTitle(_t('Transcodable.WEBMvideo', "WEBM video"))->setFolderName('videos')->setAllowedExtensions(array("webm")); $webmfield->getValidator()->setAllowedMaxFileSize($UploadSizeMB); $webmfieldHolder = DisplayLogicWrapper::create($webmfield)->displayIf('DefaultView')->isEqualTo("transcoded")->end(); // $webmfield->displayIf("DefaultView")->isEqualTo("transcoded")->end(); $ogvfield = ChunkedUploadField::create("OGV")->setTitle(_t('Transcodable.OGVvideo', "OGG theora video"))->setFolderName('videos')->setAllowedExtensions(array("ogg", "ogv")); $ogvfield->getValidator()->setAllowedMaxFileSize($UploadSizeMB); $ogvfieldHolder = DisplayLogicWrapper::create($ogvfield)->displayIf('DefaultView')->isEqualTo("transcoded")->end(); // $ogvfield->displayIf("DefaultView")->isEqualTo("transcoded")->end(); $fields->addFieldsToTab('Root.Main', array($mode, $sourcehead, $sourcefieldHolder, $posterfield, $mp4fieldHolder, $webmfieldHolder, $ogvfieldHolder)); if ($this->ID) { $fields->addFieldsToTab('Root.Main', new HeaderField('scode', $this->ShowShortCode()), 'Name'); } return $fields; }
/** * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->dataFieldByName('Title')->setTitle('Video Title'); $fields->dataFieldByName('Content')->setTitle('Video Description'); $fields->insertBefore(TextField::create('Time', 'Video Duration')->setDescription('ex. mm:ss'), 'Content'); // poster $PosterField = UploadField::create('Image', 'Poster Image')->setFolderName('Uploads/Video/Images')->setConfig('allowedMaxFileNumber', 1)->setDescription('Placeholder image until video is played.'); $PosterField->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png'); $PosterField->getValidator()->setAllowedMaxFileSize(VIDEO_IMAGE_FILE_SIZE_LIMIT); $fields->insertBefore($PosterField, 'Content'); // mp4 upload if (class_exists('ChunkedUploadField')) { $MP4Field = ChunkedUploadField::create('MP4Video'); } else { $MP4Field = new UploadField('MP4Video'); } $MP4Field->setTitle('MP4 Video')->setFolderName('Uploads/Video/MP4Video')->setConfig('allowedMaxFileNumber', 1)->setDescription('Required. Format compatible with most browsers.'); $MP4Field->getValidator()->setAllowedExtensions(array('mp4', 'm4v')); $MP4Field->getValidator()->setAllowedMaxFileSize(VIDEO_FILE_SIZE_LIMIT); // ogg upload if (class_exists('ChunkedUploadField')) { $OggField = ChunkedUploadField::create('OggVideo'); } else { $OggField = UploadField::create('OggVideo'); } $OggField->setTitle('Ogg Video')->setFolderName('Uploads/Video/OggVideo')->setConfig('allowedMaxFileNumber', 1)->setDescription('Optional. Format compatible with FireFox.'); $OggField->getValidator()->setAllowedExtensions(array('ogv', 'ogg')); $OggField->getValidator()->setAllowedMaxFileSize(VIDEO_FILE_SIZE_LIMIT); // webm upload if (class_exists('ChunkedUploadField')) { $WebMField = ChunkedUploadField::create('WebMVideo'); } else { $WebMField = UploadField::create('WebMVideo'); } $WebMField->setTitle('WebM Video')->setFolderName('Uploads/Video/WebMVideo')->setConfig('allowedMaxFileNumber', 1)->setDescription('Optional. Format compatible with Chrome.'); $WebMField->getValidator()->setAllowedExtensions(array('webm')); $WebMField->getValidator()->setAllowedMaxFileSize(VIDEO_FILE_SIZE_LIMIT); $fields->addFieldsToTab('Root.Video', array($MP4Field, $WebMField, $OggField)); $this->extend('updateCMSFields', $fields); return $fields; }