Source of file VideoFile.php
Size: 3,262 Bytes - Last Modified: 2021-12-23T10:11:59+00:00
/var/www/docs.ssmods.com/process/src/code/Video/VideoFile.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 | <?php class VideoFile extends DataObject { private static $db = array( 'Title' => 'Varchar(50)', 'Content' => 'Varchar(100)', ); private static $has_one = array( 'PosterImage' => 'Image', 'MP4Video' => 'File', 'OggVideo' => 'File', 'WebMVideo' => 'File' ); private static $summary_fields = array( 'ID' => 'ID', 'Title' => 'Title', 'Content' => 'Description', ); public function getCMSFields() { $fields = parent::getCMSFields(); $fields->dataFieldByName('Title')->setTitle('Video Title'); $fields->insertBefore( TextField::create('Content', 'Video Description'), 'PosterImage' ); // poster $PosterField = UploadField::create('PosterImage', 'Poster Image') ->setFolderName('Uploads/Video/Images') ->setConfig('allowedMaxFileNumber', 1) ->setDescription('Preview image for the video.') ; $PosterField->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png'); $PosterField->getValidator()->setAllowedMaxFileSize(VIDEO_IMAGE_FILE_SIZE_LIMIT); // 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); return $fields; } public function getGridThumbnail() { if($this->Photo()->exists()) { return $this->Photo()->SetWidth(100); } return '(no image)'; } } |