本文整理汇总了PHP中UploadField::getValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadField::getValidator方法的具体用法?PHP UploadField::getValidator怎么用?PHP UploadField::getValidator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadField
的用法示例。
在下文中一共展示了UploadField::getValidator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCMSFields
public function getCMSFields()
{
$fields = new FieldList();
$fields->push(new TabSet('Root', new Tab('Main', _t('SiteTree.TABMAIN', 'Main'), new TextField('Title', _t('UniadsObject.db_Title', 'Title')))));
if ($this->ID) {
$previewLink = Director::absoluteBaseURL() . 'admin/' . UniadsAdmin::config()->url_segment . '/UniadsObject/preview/' . $this->ID;
$fields->addFieldToTab('Root.Main', new ReadonlyField('Impressions', _t('UniadsObject.db_Impressions', 'Impressions')), 'Title');
$fields->addFieldToTab('Root.Main', new ReadonlyField('Clicks', _t('UniadsObject.db_Clicks', 'Clicks')), 'Title');
$fields->addFieldsToTab('Root.Main', array(DropdownField::create('CampaignID', _t('UniadsObject.has_one_Campaign', 'Campaign'), DataList::create('UniadsCampaign')->map())->setEmptyString(_t('UniadsObject.Campaign_none', 'none')), DropdownField::create('ZoneID', _t('UniadsObject.has_one_Zone', 'Zone'), DataList::create('UniadsZone')->map())->setEmptyString(_t('UniadsObject.Zone_select', 'select one')), new NumericField('Weight', _t('UniadsObject.db_Weight', 'Weight (controls how often it will be shown relative to others)')), new TextField('TargetURL', _t('UniadsObject.db_TargetURL', 'Target URL')), new Treedropdownfield('InternalPageID', _t('UniadsObject.has_one_InternalPage', 'Internal Page Link'), 'Page'), new CheckboxField('NewWindow', _t('UniadsObject.db_NewWindow', 'Open in a new Window')), $file = new UploadField('File', _t('UniadsObject.has_one_File', 'Advertisement File')), $AdContent = new TextareaField('AdContent', _t('UniadsObject.db_AdContent', 'Advertisement Content')), $Starts = new DateField('Starts', _t('UniadsObject.db_Starts', 'Starts')), $Expires = new DateField('Expires', _t('UniadsObject.db_Expires', 'Expires')), new NumericField('ImpressionLimit', _t('UniadsObject.db_ImpressionLimit', 'Impression Limit')), new CheckboxField('Active', _t('UniadsObject.db_Active', 'Active')), new LiteralField('Preview', '<a href="' . $previewLink . '" target="_blank">' . _t('UniadsObject.Preview', 'Preview this advertisement') . "</a>")));
$app_categories = File::config()->app_categories;
$file->setFolderName($this->config()->files_dir);
$file->getValidator()->setAllowedMaxFileSize(array('*' => $this->config()->max_file_size));
$file->getValidator()->setAllowedExtensions(array_merge($app_categories['image'], $app_categories['flash']));
$AdContent->setRows(10);
$AdContent->setColumns(20);
$Starts->setConfig('showcalendar', true);
$Starts->setConfig('dateformat', i18n::get_date_format());
$Starts->setConfig('datavalueformat', 'yyyy-MM-dd');
$Expires->setConfig('showcalendar', true);
$Expires->setConfig('dateformat', i18n::get_date_format());
$Expires->setConfig('datavalueformat', 'yyyy-MM-dd');
$Expires->setConfig('min', date('Y-m-d', strtotime($this->Starts ? $this->Starts : '+1 days')));
}
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例2: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$ImageField = new UploadField('Image', 'Image');
$ImageField->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png');
$ImageField->setFolderName('Uploads/SlideImages');
$ImageField->setConfig('allowedMaxFileNumber', 1);
$ImageField->getValidator()->setAllowedMaxFileSize(FLEXSLIDER_IMAGE_FILE_SIZE_LIMIT);
$fields->removeByName(array('ShowSlide'));
$fields->addFieldsToTab('Root.Main', array(TextField::create('Name'), TextareaField::create('Description'), TreeDropdownField::create('PageLinkID', 'Choose a page to link to:', 'SiteTree'), $ImageField, CheckboxField::create('ShowSlide')->setTitle('Show Slide')->setDescription('Include this slide in the slider. Uncheck to hide')));
$fields->removeByName(array('SortOrder', 'PageID'));
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例3: scaffoldFormField
public function scaffoldFormField($title = null, $params = null)
{
if (empty($this->object)) {
return null;
}
$relationName = substr($this->name, 0, -2);
$hasOneClass = $this->object->hasOneComponent($relationName);
if ($hasOneClass && singleton($hasOneClass) instanceof Image) {
$field = new UploadField($relationName, $title);
$field->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
} elseif ($hasOneClass && singleton($hasOneClass) instanceof File) {
$field = new UploadField($relationName, $title);
} else {
$titleField = singleton($hasOneClass)->hasField('Title') ? "Title" : "Name";
$list = DataList::create($hasOneClass);
// Don't scaffold a dropdown for large tables, as making the list concrete
// might exceed the available PHP memory in creating too many DataObject instances
if ($list->count() < 100) {
$field = new DropdownField($this->name, $title, $list->map('ID', $titleField));
$field->setEmptyString(' ');
} else {
$field = new NumericField($this->name, $title);
}
}
return $field;
}
示例4: getCMSFields
public function getCMSFields()
{
$fields = new FieldList(new TabSet('Root'));
// Details
$thumbnailField = new UploadField('CoverImage', _t('ImageGalleryAlbum.COVERIMAGE', 'Cover Image'));
$thumbnailField->getValidator()->setAllowedExtensions(File::config()->app_categories['image']);
$fields->addFieldsToTab('Root.Main', array(new TextField('AlbumName', _t('ImageGalleryAlbum.ALBUMTITLE', 'Album Title'), null, 255), new TextareaField('Description', _t('ImageGalleryAlbum.DESCRIPTION', 'Description')), $thumbnailField));
// Image listing
$galleryConfig = GridFieldConfig_RecordEditor::create();
// Enable bulk image loading if necessary module is installed
// @see composer.json/suggests
if (class_exists('GridFieldBulkManager')) {
$galleryConfig->addComponent(new GridFieldBulkManager());
}
if (class_exists('GridFieldBulkImageUpload')) {
$galleryConfig->addComponents($imageConfig = new GridFieldBulkImageUpload('ImageID'));
$imageConfig->setConfig('fieldsClassBlacklist', array('ImageField', 'UploadField', 'FileField'));
if ($uploadFolder = $this->Folder()) {
// Set upload folder - Clean up 'assets' from target path
$path = preg_replace('/(^' . ASSETS_DIR . '\\/?)|(\\/$)/i', '', $uploadFolder->RelativePath);
$imageConfig->setConfig('folderName', $path);
}
}
// Enable image sorting if necessary module is installed
// @see composer.json/suggests
if (class_exists('GridFieldSortableRows')) {
$galleryConfig->addComponent(new GridFieldSortableRows('SortOrder'));
}
$galleryField = new GridField('GalleryItems', 'Gallery Items', $this->GalleryItems(), $galleryConfig);
$fields->addFieldToTab('Root.Images', $galleryField);
return $fields;
}
示例5: getCMSFields
/**
* Get CMS fields
*
* @return FieldList
*/
function getCMSFields()
{
$fields = new FieldList();
$fields->push(new TextField('Title', _t('Block.TITLE', 'Title')));
$imageField = new UploadField('Image', _t('Block.IMAGE', 'Image'));
$imageField->getValidator()->setAllowedExtensions(array('jpg', 'gif', 'png'));
$fields->push($imageField);
$fields->push(new TextField('FeedURL', _t('FeedBlock.FEEDURL', 'FeedURL')));
$fields->push(new NumericField('Results', _t('FeedBlock.RESULTS', 'Results')));
$fields->push(new NumericField('SummaryMaxLength', _t('FeedBlock.SUMMARYMAXLENGTH', 'SummaryMaxLength')));
$fields->push(new NumericField('CacheTime', _t('FeedBlock.CACHETIME', 'CacheTime')));
$fields->push(new CheckboxField('Striptags', _t('FeedBlock.STRIPTAGS', 'Striptags')));
// Add modifier field (select function to run feed item through before displaying it)
if ($this->modifier_functions) {
if (isset($this->modifier_functions)) {
$options = array('' => 'None');
foreach ($this->modifier_functions as $f) {
$options[$f] = $f;
}
$fields->push(new DropdownField('Modifier', _t('FeedBlock.MODIFIER', 'Feed item filter'), $options));
}
}
$fields->push(new TextField('LinkExternal', _t('FeedBlock.LINKEXTERNAL', 'External link URL')));
if (class_exists('OptionalTreeDropdownField')) {
$treeField = new OptionalTreeDropdownField('LinkInternalID', _t('Block.LINKINTERNAL', 'Internal link'), 'SiteTree');
$treeField->setEmptyString('No page');
} else {
$treeField = new TreeDropdownField('LinkInternalID', _t('Block.LINKINTERNAL', 'Internal link'), 'SiteTree');
}
$fields->push($treeField);
return $fields;
}
示例6: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
// mp4 upload
$MP4Field = new UploadField('MP4Video', 'MP4 Video');
$MP4Field->getValidator()->setAllowedExtensions(array('mp4', 'm4v'));
$MP4Field->setFolderName('Uploads/video');
$MP4Field->setConfig('allowedMaxFileNumber', 1);
// ogg upload
$OggField = new UploadField('OggVideo', 'Ogg Video');
$OggField->getValidator()->setAllowedExtensions(array('ogv', 'ogg'));
$OggField->setFolderName('Uploads/video');
$OggField->setConfig('allowedMaxFileNumber', 1);
// mp4 upload
$WebMField = new UploadField('WebMVideo', 'WebM Video');
$WebMField->getValidator()->setAllowedExtensions(array('webm'));
$WebMField->setFolderName('Uploads/video');
$WebMField->setConfig('allowedMaxFileNumber', 1);
// poster
$PosterField = new UploadField('Poster', 'Poster Image');
$PosterField->allowedExtensions = array('jpg', 'gif', 'png');
$PosterField->setFolderName('Uploads/videoposters');
$PosterField->setConfig('allowedMaxFileNumber', 1);
$fields->addFieldsToTab('Root.Video', array($MP4Field, $OggField, $WebMField, $PosterField));
return $fields;
}
示例7: updateSiteCMSFields
public function updateSiteCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.Main', $gaCode = new TextField('GACode', 'Google Analytics account'));
$gaCode->setRightTitle('Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)');
$fields->addFieldToTab('Root.SocialMedia', $facebookURL = new TextField('FacebookURL', 'Facebook UID or username'));
$facebookURL->setRightTitle('Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)');
$fields->addFieldToTab('Root.SocialMedia', $twitterUsername = new TextField('TwitterUsername', 'Twitter username'));
$twitterUsername->setRightTitle('Twitter username (eg, http://twitter.com/<strong>username</strong>)');
$fields->addFieldToTab('Root.SocialMedia', $addThisID = new TextField('AddThisProfileID', 'AddThis Profile ID'));
$addThisID->setRightTitle('Profile ID to be used all across the site (in the format <strong>ra-XXXXXXXXXXXXXXXX</strong>)');
$fields->addFieldToTab('Root.Logos/Icons', $favIconField = new UploadField('FavIcon', 'Favicon, in .ico format, dimensions of 16x16, 32x32, or 48x48'));
$favIconField->getValidator()->setAllowedExtensions(array('ico'));
$favIconField->setConfig('allowedMaxFileNumber', 1);
$fields->addFieldToTab('Root.Logos/Icons', $atIcon144 = new UploadField('AppleTouchIcon144', 'Apple Touch Web Clip and Windows 8 Tile Icon (dimensions of 144x144, PNG format)'));
$atIcon144->getValidator()->setAllowedExtensions(array('png'));
$atIcon144->setConfig('allowedMaxFileNumber', 1);
$fields->addFieldToTab('Root.Logos/Icons', $atIcon114 = new UploadField('AppleTouchIcon114', 'Apple Touch Web Clip Icon (dimensions of 114x114, PNG format)'));
$atIcon114->getValidator()->setAllowedExtensions(array('png'));
$atIcon114->setConfig('allowedMaxFileNumber', 1);
$fields->addFieldToTab('Root.Logos/Icons', $atIcon72 = new UploadField('AppleTouchIcon72', 'Apple Touch Web Clip Icon (dimensions of 72x72, PNG format)'));
$atIcon72->getValidator()->setAllowedExtensions(array('png'));
$atIcon72->setConfig('allowedMaxFileNumber', 1);
$fields->addFieldToTab('Root.Logos/Icons', $atIcon57 = new UploadField('AppleTouchIcon57', 'Apple Touch Web Clip Icon (dimensions of 57x57, PNG format)'));
$atIcon57->getValidator()->setAllowedExtensions(array('png'));
$atIcon57->setConfig('allowedMaxFileNumber', 1);
}
示例8: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$imageField = new UploadField('PrimaryImage', 'Image');
$imageField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$fields->addFieldToTab('Root.Main', $imageField, 'Content');
return $fields;
}
示例9: getCMSFields
/**
* @return FieldList
*/
public function getCMSFields()
{
$f = parent::getCMSFields();
$f->addFieldToTab('Root.Main', new TextField('Link', 'Slide Link'));
$f->addFieldToTab('Root.Main', $upload_field = new UploadField('Slide', 'Slide File'));
$upload_field->setAllowedMaxFileNumber(1);
$upload_field->getValidator()->setAllowedMaxFileSize(array('*' => 5 * 1024 * 1024));
$upload_field->setFolderName(sprintf('summits/%s/presentations/%s/slides/', $_REQUEST['SummitID'], $_REQUEST['SummitEventID']));
return $f;
}
示例10: getCMSFields
/**
* @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;
}
示例11: getCMSFields
public function getCMSFields()
{
$f = parent::getCMSFields();
$f->removeByName('Picture');
$map_field = new UploadField('Picture', 'Map');
$map_field->setAllowedMaxFileNumber(1);
$map_field->setFolderName(sprintf('summits/%s/locations/%s/maps/', $_REQUEST['SummitID'], $_REQUEST['LocationID']));
$map_field->getValidator()->setAllowedMaxFileSize(array('*' => 500 * 1024));
$f->add($map_field);
return $f;
}
示例12: getCMSFields
public function getCMSFields()
{
$fields = new FieldList(new TabSet('Root'));
// Details
$fields->addFieldToTab('Root.Main', new TextareaField('Caption', _t('ImageGalleryItem.CAPTION', 'Caption')));
// Create image
$imageField = new UploadField('Image');
$imageField->getValidator()->setAllowedExtensions(File::config()->app_categories['image']);
$fields->addFieldToTab('Root.Main', $imageField);
return $fields;
}
示例13: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', $summarySize);
$fields->addFieldToTab('Root.Main', $BlogImage = new UploadField('SummaryImage'));
$folderName = 'BlogImages/' . $this->Name . '/';
$BlogImage->setFolderName($folderName);
$BlogImage->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
$fields->addFieldToTab('Root.Main', HtmlEditorField::create('Content'));
return $fields;
}
示例14: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$tab = 'Root.Main';
$tab = 'Root.Examples';
$field = new UploadField('Image');
$field->setAllowedMaxFileNumber(1);
$field->getValidator()->setAllowedMaxFileSize(4 * 1024 * 1024);
$field->setFolderName('Uploads/10-image-setwidth/');
$fields->addFieldToTab($tab, $field);
return $fields;
}
示例15: getCMSFields
public function getCMSFields()
{
$f = new FieldList();
$f->add(new TextField('Name', 'Name'));
$f->add(new HtmlEditorField('Description', 'Description'));
$map_field = new UploadField('Picture', 'Picture');
$map_field->setAllowedMaxFileNumber(1);
$map_field->setFolderName(sprintf('summits/%s/locations/%s/images/', $_REQUEST['SummitID'], $_REQUEST['LocationID']));
$map_field->getValidator()->setAllowedMaxFileSize(array('*' => 500 * 1024));
$f->add($map_field);
$f->add(new HiddenField('LocationID', 'LocationID'));
return $f;
}