本文整理汇总了PHP中UploadField::setAllowedExtensions方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadField::setAllowedExtensions方法的具体用法?PHP UploadField::setAllowedExtensions怎么用?PHP UploadField::setAllowedExtensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadField
的用法示例。
在下文中一共展示了UploadField::setAllowedExtensions方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCMSFields
function updateCMSFields(FieldList $fields)
{
$linkToManagerForPages = Config::inst()->get("MetaTagCMSControlPages", "url_segment") . '/';
$linkToManagerForFiles = Config::inst()->get("MetaTagCMSControlFiles", "url_segment") . '/';
$fields->addFieldToTab('Root.SearchEngines', new TabSet('Options', new Tab('Help', new LiteralField('HelpExplanation', '
<h3>Search Engine - How to use ...</h3>
<p>
To improve your visibility with search engines, we provide a number of tools here.
Improving your rankings with Search Engines can work as follows:
</p>
<ul>
<li> - decide on a few keywords for each page - basically the words that people would search for on Google (e.g. <i>feed elderly cat</i>))</li>
<li> - ensure that these words are seen in strategic places on this page</li>
<li> - create links to the page from <i>third-party</i> websites</li>
</ul>
<p>
<br />The tools provided here help you to achieve these goals by ensuring:
</p>
<ul>
<li> - easy addition of keywords to key field (navigation label, meta description)</li>
<li> - you can adjust the file image names and descriptions to match the keywords</li>
</ul>
')), new Tab('Menus', new LiteralField('MenuTitleExplanation', '<h3>Menu Title</h3><p>To improve consistency, you can set the menu title to automatically match the page title for any page on the site. </p>'), new CheckboxField('UpdateMenuTitle', 'Automatically update the Menu Title / Navigation Label to match the Page Title?')), new Tab('Meta Title', new TextField('PrependToMetaTitle', 'Prepend (add in front) of Meta Title'), new TextField('AppendToMetaTitle', 'Append (add at the end) of Meta Title')), new Tab('Meta Description', new LiteralField('MetaDescriptionExplanation', '<h3>“Meta Description”: Summary for Search Engines</h3><p>The Meta Description is not visible on the website itself. However, it is picked up by search engines like google. They display it as the short blurb underneath the link to your pages. It will not get you much higher in the rankings, but it will entice people to click on your link.</p>'), new CheckboxField('UpdateMetaDescription', 'Automatically fill every meta description on every Page (using the first ' . Config::inst()->get("MetaTagsContentControllerEXT", "meta_desc_length") . ' words of the Page Content field).')), new Tab('Other Meta Data', new LiteralField('MetaOtherExplanation', '<h3>Other “Meta Data”: More hidden information about the page</h3><p>You can add some other <i>hidden</i> information to your pages - which can be picked up by Search Engines and other automated readers decyphering your website.</p>'), new TextField('MetaDataCountry', 'Country'), new TextField('MetaDataCopyright', 'Content Copyright'), new TextField('MetaDataDesign', 'Design provided by ...'), new TextField('MetaDataCoding', 'Website Coding carried out by ...'), new TextareaField('ExtraMeta', 'Custom Meta Tags (advanced users only)')), new Tab('Pages', new LiteralField('LinkToManagerHeaderForPages', "<p><a href=\"{$linkToManagerForPages}\" target=\"_blank\">Review and Edit</a> pages in a new window ...</p>")), new Tab('Files', new LiteralField('LinkToManagerHeaderForFiles', "<p><a href=\"{$linkToManagerForFiles}\" target=\"_blank\">Review and Edit</a> files in a new window ...</p>"))));
$fields->addFieldToTab("Root.Icons", $uploadField = new UploadField('Favicon', 'Icon'));
$uploadField->setAllowedExtensions(array("png"));
$uploadField->setRightTitle("Upload a 480px wide x 480px high non-transparent PNG file. Ask your developer for help if unsure. Icons can also be loaded onto the server directly into the /themes/mytheme/icons/ folder and as a favicon.ico in the root directory.");
return $fields;
}
示例2: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Main", $uploadField = new UploadField("TestimonialImage", "Testimonial Image"));
$uploadField->setFolderName('Testimonials');
$uploadField->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
return $fields;
}
示例3: getCMSFields
public function getCMSFields()
{
$fields = new FieldList(new TextField("Title", "Title"), new HTMLEditorField("Description", "Description"), $mp3file = new UploadField("MP3File", "MP3 File"), $oggfile = new UploadField("OGGFile", "OGG File"));
$mp3file->setAllowedExtensions(array('mp3'));
$oggfile->setAllowedExtensions(array('ogg'));
$mp3file->setFolderName('Uploads/audio');
$oggfile->setFolderName('Uploads/audio');
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例4: getCMSFields
public function getCMSFields()
{
$f = parent::getCMSFields();
//current summit
$f->removeByName('Content');
$f->addFieldToTab('Root.CurrentSummit', new HtmlEditorField('ThankYouText', 'ThankYouText'));
$f->addFieldToTab('Root.CurrentSummit', new TextField('CurrentSummitFlickrUrl', 'Flickr Url'));
$image = new UploadField('CurrentSummitBackgroundImage', 'Background Image');
$image->setAllowedMaxFileNumber(1);
$image->setFolderName(sprintf('summits/%s/highlights/', $this->SummitID));
$f->addFieldToTab('Root.CurrentSummit', $image);
// statistics
$f->addFieldToTab('Root.Statistics', new TextField('AttendanceQty', 'Attendance Qty'));
$f->addFieldToTab('Root.Statistics', new TextField('CompaniesRepresentedQty', 'Companies Represented Qty'));
$f->addFieldToTab('Root.Statistics', new TextField('CountriesRepresentedQty', 'Countries Represented Qty'));
$f->addFieldToTab('Root.Statistics', new TextField('StatisticsVideoUrl', 'Video Url'));
$file = new UploadField('StatisticsVideo', 'Video');
$file->setAllowedMaxFileNumber(1);
$file->setAllowedExtensions(array('mp4'));
$file->setFolderName(sprintf('summits/%s/highlights/statistics', $this->SummitID));
$f->addFieldToTab('Root.Statistics', $file);
$image = new UploadField('StatisticsVideoPoster', 'Video Poster');
$image->setAllowedMaxFileNumber(1);
$image->setFolderName(sprintf('summits/%s/highlights/statistics', $this->SummitID));
$f->addFieldToTab('Root.Statistics', $image);
// next summit
$f->addFieldToTab('Root.NextSummit', new HtmlEditorField('NextSummitText', 'Next Summit Text'));
$dropdown = DropdownField::create('NextSummitBackgroundImageID', 'Please choose an image for this page', SummitImage::get()->map("ID", "Title", "Please Select"))->setEmptyString('(None)');
$f->addFieldToTab('Root.NextSummit', $dropdown);
$image = new UploadField('NextSummitTinyBackgroundImage', 'Promo Background Image');
$image->setAllowedMaxFileNumber(1);
$image->setFolderName(sprintf('summits/%s/highlights/next_summit/', $this->SummitID));
$f->addFieldToTab('Root.NextSummit', $image);
// release
$f->addFieldToTab('Root.ReleaseAnnounced', new TextField('ReleaseAnnouncedTitle', 'Title'));
$f->addFieldToTab('Root.ReleaseAnnounced', new HtmlEditorField('ReleaseAnnouncedDescription', 'Description'));
$f->addFieldToTab('Root.ReleaseAnnounced', new TextField('ReleaseAnnouncedButtonTitle', 'Button Text'));
$f->addFieldToTab('Root.ReleaseAnnounced', new TextField('ReleaseAnnouncedButtonLink', 'Button Link'));
$release_image = new UploadField('ReleaseAnnouncedImage', 'Image');
$release_image->setAllowedMaxFileNumber(1);
$release_image->setFolderName(sprintf('summits/%s/highlights/release/', $this->SummitID));
$f->addFieldToTab('Root.ReleaseAnnounced', $release_image);
if ($this->ID > 0) {
$config = GridFieldConfig_RecordEditor::create();
$config->addComponent($sort = new GridFieldSortableRows('Order'));
$gridField = new GridField('KeynotesImages', 'KeynotesImages', $this->KeynotesImages(), $config);
$f->addFieldToTab('Root.KeyNotesImages', $gridField);
$config = GridFieldConfig_RecordEditor::create();
$config->addComponent($sort = new GridFieldSortableRows('Order'));
$gridField = new GridField('Pics', 'Pics', $this->Pics(), $config);
$f->addFieldToTab('Root.Pics', $gridField);
}
return $f;
}
示例5: getCMSFields
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new DropdownField('Size', 'Icon size:', singleton('WebAppIcon')->dbObject('Size')->enumValues()));
$fields->addFieldToTab('Root.Main', $uploadField = new UploadField($name = 'Image', $title = 'Upload a App Icon'));
$uploadField->setAllowedMaxFileNumber(1);
$uploadField->setFolderName('appicons');
$uploadField->setAllowedExtensions(array('png'));
$sizeMB = 1;
$size = $sizeMB * 1024 * 1024;
$uploadField->getValidator()->setAllowedMaxFileSize($size);
// hide the settings field
$fields->removeByName('WebAppConfigID');
return $fields;
}
示例6: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Tags', new CheckboxField('TagPersonalTraining', 'Personal Training'));
$fields->addFieldToTab('Root.Tags', new CheckboxField('TagMassage', 'Massage'));
$fields->addFieldToTab('Root.Tags', new CheckboxField('TagCrossFit', 'CrossFit'));
$fields->addFieldToTab('Root.Tags', new CheckboxField('TagSportSpecific', 'Sport Specific'));
$fields->addFieldToTab('Root.Tags', new CheckboxField('TagTeamTraining', 'Team Training'));
$fields->addFieldToTab('Root.Tags', new CheckboxField('TagBoxing', 'Boxing'));
$fields->addFieldToTab('Root.Tags', new CheckboxField('TagCounselling', 'Counselling'));
$fields->addFieldToTab('Root.Tags', new CheckboxField('TagMentoring', 'Mentoring'));
$fields->addFieldToTab("Root.Main", $uploadField = new UploadField("TeamMemberImage", "Team Member Image"));
$uploadField->setFolderName('TeamMembers');
$uploadField->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
return $fields;
}
示例7: getCMSFields
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new DropdownField('Device', 'Startup screen size:', singleton('WebAppStartupScreen')->dbObject('Device')->enumValues()));
$fields->addFieldToTab('Root.Main', $uploadField = new UploadField($name = 'Image', $title = 'Upload a Splash Screen'));
$uploadField->setAllowedMaxFileNumber(1);
$uploadField->setFolderName('splashscreens');
$uploadField->setAllowedExtensions(array('png'));
$sizeMB = 5;
$size = $sizeMB * 1024 * 1024;
$uploadField->getValidator()->setAllowedMaxFileSize($size);
// hide the media field, this gets written inBefore Write. See below
$fields->addFieldToTab('Root.Main', new HiddenField('Media'));
// hide the settings field
$fields->removeByName('WebAppConfigID');
return $fields;
}
示例8: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldsToTab('Root.Main', new HtmlEditorField('OverviewIntro', 'Overview Intro'));
if ($this->ID > 0) {
$fields->addFieldToTab('Root.Networking', new HtmlEditorField('NetworkingContent', 'Content'));
//networking photos
$config = GridFieldConfig_RecordEditor::create();
$config->addComponent(new GridFieldSortableRows('Order'));
$gridField = new GridField('NetworkingPhotos', 'Photos', $this->NetworkingPhotos(), $config);
$fields->addFieldToTab('Root.Networking', $gridField);
$fields->addFieldToTab('Root.Networking', new HtmlEditorField('NetworkingContent', 'Content'));
//menu items
$config = GridFieldConfig_RecordEditor::create();
$config->addComponent(new GridFieldSortableRows('Order'));
$gridField = new GridField('HelpMenuItems', 'Help Menu Items', $this->HelpMenuItems(), $config);
$fields->addFieldToTab('Root.HelpSideBarMenu', $gridField);
}
$fields->addFieldsToTab('Root.Schedule', new TextField('ScheduleTitle', 'Title'));
$fields->addFieldsToTab('Root.Schedule', new HtmlEditorField('ScheduleText', 'Text'));
$fields->addFieldsToTab('Root.Schedule', new TextField('ScheduleUrl', 'Url'));
$fields->addFieldsToTab('Root.Schedule', new TextField('ScheduleBtnText', 'Button Caption'));
// Video Recap
$fields->addFieldsToTab('Root.VideoRecap', new TextField('RecapTitle', 'Title'));
$fields->addFieldsToTab('Root.VideoRecap', new TextField('VideoRecapCaption1', 'Caption Text 1'));
$fields->addFieldsToTab('Root.VideoRecap', new TextField('VideoRecapYouTubeID1', 'YouTubeID 1'));
$fields->addFieldsToTab('Root.VideoRecap', new TextField('VideoRecapCaption2', 'Caption Text 2'));
$fields->addFieldsToTab('Root.VideoRecap', new TextField('VideoRecapYouTubeID2', 'YouTubeID 2'));
// GrowthBox
$fields->addFieldToTab("Root.GrowthBox", new HtmlEditorField('GrowthBoxTextTop', 'Text Top'));
$fields->addFieldToTab("Root.GrowthBox", new HtmlEditorField('GrowthBoxTextBottom', 'Text Bottom'));
$fields->addFieldsToTab("Root.GrowthBox", $upload_0 = new UploadField('GrowthBoxBackground', 'Background Image'));
$fields->addFieldsToTab("Root.GrowthBox", $upload_1 = new UploadField('GrowthBoxChartLegend', 'Chart Legend (SVG)'));
$fields->addFieldsToTab("Root.GrowthBox", $upload_2 = new UploadField('GrowthBoxChartLegendPng', 'Chart Legend (PNG)'));
$fields->addFieldsToTab("Root.GrowthBox", $upload_3 = new UploadField('GrowthBoxChart', 'Chart (SVG)'));
$fields->addFieldsToTab("Root.GrowthBox", $upload_4 = new UploadField('GrowthBoxChartPng', 'Chart (PNG)'));
$upload_0->setFolderName('summits/overview');
$upload_0->setAllowedMaxFileNumber(1);
$upload_0->setAllowedFileCategories('image');
$upload_0->setOverwriteWarning(false);
$upload_0->getUpload()->setReplaceFile(true);
$upload_1->setFolderName('summits/overview');
$upload_1->setAllowedMaxFileNumber(1);
$upload_1->setAllowedExtensions(array('svg'));
$upload_1->setOverwriteWarning(false);
$upload_1->getUpload()->setReplaceFile(true);
$upload_2->setFolderName('summits/overview');
$upload_2->setAllowedMaxFileNumber(1);
$upload_2->setAllowedExtensions(array('png'));
$upload_2->setOverwriteWarning(false);
$upload_2->getUpload()->setReplaceFile(true);
$upload_3->setFolderName('summits/overview');
$upload_3->setAllowedMaxFileNumber(1);
$upload_3->setAllowedExtensions(array('svg'));
$upload_3->setOverwriteWarning(false);
$upload_3->getUpload()->setReplaceFile(true);
$upload_4->setFolderName('summits/overview');
$upload_4->setAllowedMaxFileNumber(1);
$upload_4->setAllowedExtensions(array('png'));
$upload_4->setOverwriteWarning(false);
$upload_4->getUpload()->setReplaceFile(true);
//two main events
$fields->addFieldsToTab('Root.TwoMainEvents', new TextField('TwoMainEventsTitle', 'Title'));
$fields->addFieldsToTab('Root.TwoMainEvents', new TextField('EventOneTitle', 'Event One - Title'));
$fields->addFieldsToTab('Root.TwoMainEvents', new TextField('EventOneSubTitle', 'Event One - SubTitle'));
$fields->addFieldsToTab('Root.TwoMainEvents', new HtmlEditorField('EventOneContent', 'Event One - Content'));
$fields->addFieldsToTab('Root.TwoMainEvents', new TextField('EventTwoTitle', 'Event Two - Title'));
$fields->addFieldsToTab('Root.TwoMainEvents', new TextField('EventTwoSubTitle', 'Event Two - SubTitle'));
$fields->addFieldsToTab('Root.TwoMainEvents', new HtmlEditorField('EventTwoContent', 'Event Two - Content'));
$fields->addFieldsToTab("Root.TwoMainEvents", $upload_5 = new UploadField('EventOneLogo', 'Event Two Logo (SVG)'));
$fields->addFieldsToTab("Root.TwoMainEvents", $upload_6 = new UploadField('EventOneLogoPng', 'Event Two Logo (PNG)'));
$fields->addFieldsToTab("Root.TwoMainEvents", $upload_7 = new UploadField('EventTwoLogo', 'Event Two Logo (SVG)'));
$fields->addFieldsToTab("Root.TwoMainEvents", $upload_8 = new UploadField('EventTwoLogoPng', 'Event Two Logo (PNG)'));
$upload_5->setFolderName('summits/overview/events');
$upload_5->setAllowedMaxFileNumber(1);
$upload_5->setAllowedExtensions(array('svg'));
$upload_5->setOverwriteWarning(false);
$upload_5->getUpload()->setReplaceFile(true);
$upload_6->setFolderName('summits/overview/events');
$upload_6->setAllowedMaxFileNumber(1);
$upload_6->setAllowedExtensions(array('png'));
$upload_6->setOverwriteWarning(false);
$upload_6->getUpload()->setReplaceFile(true);
$upload_7->setFolderName('summits/overview/events');
$upload_7->setAllowedMaxFileNumber(1);
$upload_7->setAllowedExtensions(array('svg'));
$upload_7->setOverwriteWarning(false);
$upload_7->getUpload()->setReplaceFile(true);
$upload_8->setFolderName('summits/overview/events');
$upload_8->setAllowedMaxFileNumber(1);
$upload_8->setAllowedExtensions(array('png'));
$upload_8->setOverwriteWarning(false);
$upload_8->getUpload()->setReplaceFile(true);
//atendees chart
$fields->addFieldsToTab("Root.AtendeesChart", $upload_13 = new UploadField('AtendeesChartRef', 'Atendees Chart Legend (SVG)'));
$fields->addFieldsToTab("Root.AtendeesChart", $upload_19 = new UploadField('AtendeesChartRefPng', 'Atendees Chart Legend (PNG)'));
$fields->addFieldToTab("Root.AtendeesChart", new TextField('Atendees1Label', 'Atendees 1 Label'));
$fields->addFieldsToTab("Root.AtendeesChart", $upload_9 = new UploadField('Atendees1Chart', 'Atendees 1 Chart (SVG)'));
$fields->addFieldsToTab("Root.AtendeesChart", $upload_15 = new UploadField('Atendees1ChartPng', 'Atendees 1 Chart (PNG)'));
$fields->addFieldToTab("Root.AtendeesChart", new TextField('Atendees2Label', 'Atendees 2 Label'));
//.........这里部分代码省略.........
示例9: getCMSFields
public function getCMSFields()
{
$fields = new FieldList();
$fields->push(new CurrencyField("Price", "Price"));
$fields->push(new TextField("ItemID", "Item / Invoice Number"));
$fields->push(new TextField("Name", "Item Name"));
$fields->push($UploadField = new UploadField("Image"));
$fields->push(new TextAreaField("Description", "Description of Item"));
$UploadField->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
if (!$this->ID) {
$fields->push(new HeaderField('note1', 'You must first save this product before adding options.'));
}
$PaypalItemOptions_config = GridFieldConfig::create()->addComponents(new GridFieldSortableRows('SortOrder'), new GridFieldToolbarHeader(), $this->ID ? new GridFieldAddNewButton('toolbar-header-right') : null, new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(10), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm());
$fields->push(new GridField('PaypalItemOptions', 'Paypal Item Options', $this->PaypalItemOptions(), $PaypalItemOptions_config));
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例10: getCMSFields
/**
* Set some CMS fields for managing Products
*
* @see Page::getCMSFields()
* @return FieldList
*/
public function getCMSFields()
{
$shopConfig = ShopConfig::current_shop_config();
$fields = parent::getCMSFields();
//Main Product Image
$fields->addFieldToTab("Root.Main", $uploadField = new UploadField("MainProductImage", "Main Product Image"));
$uploadField->setFolderName('Store');
$uploadField->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
// Use SortableUploadField instead of UploadField!
$imageField = new SortableUploadField('OtherImages', 'Other Product Images');
$imageField->setFolderName('Store');
$imageField->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
$fields->addFieldToTab('Root.Main', $imageField);
//Product fields
$fields->addFieldToTab('Root.Main', new PriceField('Price'), 'Content');
//Replace URL Segment field
if ($this->ParentID == -1) {
$urlsegment = new SiteTreeURLSegmentField("URLSegment", 'URLSegment');
$baseLink = Controller::join_links(Director::absoluteBaseURL(), 'product/');
$url = strlen($baseLink) > 36 ? "..." . substr($baseLink, -32) : $baseLink;
$urlsegment->setURLPrefix($url);
$fields->replaceField('URLSegment', $urlsegment);
}
if ($this->isInDB()) {
//Product attributes
$listField = new GridField('Attributes', 'Attributes', $this->Attributes(), GridFieldConfig_BasicSortable::create());
$fields->addFieldToTab('Root.Attributes', $listField);
//Product variations
$attributes = $this->Attributes();
if ($attributes && $attributes->exists()) {
//Remove the stock level field if there are variations, each variation has a stock field
$fields->removeByName('Stock');
$variationFieldList = array();
foreach ($attributes as $attribute) {
$variationFieldList['AttributeValue_' . $attribute->ID] = $attribute->Title;
}
$variationFieldList = array_merge($variationFieldList, singleton('Variation')->summaryFields());
$config = GridFieldConfig_HasManyRelationEditor::create();
$dataColumns = $config->getComponentByType('GridFieldDataColumns');
$dataColumns->setDisplayFields($variationFieldList);
$listField = new GridField('Variations', 'Variations', $this->Variations(), $config);
$fields->addFieldToTab('Root.Variations', $listField);
}
}
//Ability to edit fields added to CMS here
$this->extend('updateProductCMSFields', $fields);
if ($warning = ShopConfig::base_currency_warning()) {
$fields->addFieldToTab('Root.Main', new LiteralField('BaseCurrencyWarning', '<p class="message warning">' . $warning . '</p>'), 'Title');
}
return $fields;
}