本文整理汇总了PHP中UploadField类的典型用法代码示例。如果您正苦于以下问题:PHP UploadField类的具体用法?PHP UploadField怎么用?PHP UploadField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UploadField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: getCMSFields
public function getCMSFields()
{
$ScrollDirectionOptions = array("up", "down", "left", "right");
$ScrollEasingOptions = array("Elastic", "Linear");
$ScrollFx = array("none", "scroll", "directscroll", "fade", "crossfade", "cover", "cover-fade", "uncover", "uncover-fade");
$GenAlignment = array("Left", "Center", "Right");
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Photos', $uploadField = new UploadField($name = 'Images', $title = 'Upload one or more images (max 10 at a time)'));
$fields->addFieldToTab('Root.Settings.General', new CheckBoxField('GenAutoStart', 'Auto Start Carousel?'));
$fields->addFieldToTab('Root.Settings.General', new CheckBoxField('GenCarouselCircular', 'Make Carousel Circular?'));
$fields->addFieldToTab('Root.Settings.General', new CheckBoxField('GenCarouselInfinite', 'Make Carousel Infinite?'));
$fields->addFieldToTab('Root.Settings.General', new NumericField('GenItemNumberToStart', 'Which item should start carousel (0 for random)'));
$fields->addFieldToTab('Root.Settings.General', new NumericField('GenDurationBeforeStart', 'Delay before carousel scrolls for first time (millisec)'));
$fields->addFieldToTab('Root.Settings.General', new NumericField('GenItemsMin', 'Items Viewable Minimum'));
$fields->addFieldToTab('Root.Settings.General', new NumericField('GenItemsMax', 'Items Viewable Maximum'));
$fields->addFieldToTab('Root.Settings.General', new NumericField('GenItemWidth', 'Set image width (use 0 for no scaling)'));
$fields->addFieldToTab('Root.Settings.General', new NumericField('GenItemHeight', 'Set image Height (use 0 for no scaling)'));
$fields->addFieldToTab('Root.Settings.General', new DropDownField("GenAlignment", "Slide Alignment?", $GenAlignment));
$fields->addFieldToTab('Root.Settings.Scroll', new DropDownField("ScrollDirection", "What direction to move the carousel?", $ScrollDirectionOptions));
$fields->addFieldToTab('Root.Settings.Scroll', new DropDownField("ScrollFx", "Slide Transition type?", $ScrollFx));
$fields->addFieldToTab('Root.Settings.Scroll', new DropDownField("ScrollEasing", "Slide Easing Option", $ScrollEasingOptions));
$fields->addFieldToTab('Root.Settings.Scroll', new NumericField('ScrollNumItems', 'Scroll number of items (0 will scroll none)'));
$fields->addFieldToTab('Root.Settings.Scroll', new NumericField('ScrollDuration', 'Scroll Duration Time (millisec)'));
$fields->addFieldToTab('Root.Settings.Scroll', new CheckBoxField('ScrollPauseOnHover', 'Pause the scrolling when mouse is hovering?'));
$fields->addFieldToTab('Root.Settings.Swipe', new CheckBoxField('SwipeOnMouse', 'scroll via dragging (on non-touch-devices only)'));
$fields->addFieldToTab('Root.Settings.Swipe', new CheckBoxField('SwipeOnTouch', 'scroll via swiping gestures (on touch-devices only)'));
$uploadField->setFolderName('slides');
$uploadField->setAllowedMaxFileNumber(10);
return $fields;
}
示例4: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new HTMLEditorField('VisaInformation', 'Visa Information'));
$fields->addFieldToTab('Root.Main', new HTMLEditorField('TravelSupport', 'Travel Support'));
$fields->addFieldToTab('Root.CityInfo', new HTMLEditorField('CityIntro', 'City Intro'));
$fields->addFieldToTab('Root.CityInfo', new HTMLEditorField('AboutTheCity', 'About The City'));
$fields->addFieldToTab('Root.CityInfo', new HTMLEditorField('Locals', 'In The Words Of The Locals'));
$fields->addFieldToTab('Root.CityInfo', new HTMLEditorField('GettingAround', 'Getting Around'));
$fields->addFieldsToTab('Root.CityInfo', new TextField('HostCityLat', 'City Latitude (Map Center)'));
$fields->addFieldsToTab('Root.CityInfo', new TextField('HostCityLng', 'City Longitude (Map Center)'));
$fields->addFieldToTab('Root.MapLocations', new HTMLEditorField('LocationsTextHeader', 'Intro Text'));
$fields->addFieldToTab('Root.MapLocations', new HTMLEditorField('OtherLocations', 'Other Locations'));
if ($this->ID) {
// Summit Question Categories
$fields->addFieldsToTab('Root.Main', $venue_back = new UploadField('VenueBackgroundImage', 'Venue Background Image'));
$venue_back->setFolderName('summits/locations');
$venue_back->setAllowedMaxFileNumber(1);
$venue_back->setAllowedFileCategories('image');
$fields->addFieldsToTab('Root.Main', new TextField('VenueBackgroundImageHero', 'Venue Background Image Author'));
$fields->addFieldsToTab('Root.Main', new TextField('VenueBackgroundImageHeroSource', 'Venue Background Image Author Url'));
$fields->addFieldsToTab('Root.CityInfo', $about_back = new UploadField('AboutTheCityBackgroundImage', 'About The City Background Image'));
$about_back->setFolderName('summits/location/about');
$about_back->setAllowedMaxFileNumber(1);
$about_back->setAllowedFileCategories('image');
$fields->addFieldsToTab('Root.CityInfo', new TextField('AboutTheCityBackgroundImageHero', 'About The City Background Image Author'));
$fields->addFieldsToTab('Root.CityInfo', new TextField('AboutTheCityBackgroundImageHeroSource', 'About The City Background Image Author Source Url'));
}
$fields->addFieldToTab('Root.Main', new TextField('VenueTitleText', 'Venue Title Text'));
$fields->addFieldToTab('Root.Main', new TextField('AirportsTitle', 'Airports Title'));
$fields->addFieldToTab('Root.Main', new TextField('AirportsSubTitle', 'Airports SubTitle'));
$fields->addFieldToTab('Root.Main', new TextField('CampusGraphic', 'URL of image of campus graphic'));
return $fields;
}
示例5: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$avatar = new UploadField('Avatar', 'Avatar');
$avatar->setFolderName('member/avatar');
$fields->replaceField('Avatar', $avatar);
$fields->removeByName('SortOrder');
}
示例6: getUploadForm
public static function getUploadForm($file, $parentClass, $parentId, $parentField)
{
if ($file instanceof File && class_exists($parentClass) && is_subclass_of($parentClass, "DataObject")) {
$parent = $parentClass::get()->byId($parentId);
$fields = new FieldList($uploadField = new UploadField($parentField, 'Upload', $parent));
$uploadField->setCanAttachExisting(false);
// Block access to Silverstripe assets library
$uploadField->setCanPreviewFolder(false);
// Don't show target filesystem folder on upload field
$uploadField->relationAutoSetting = false;
// Prevents the form thinking the GalleryPage is the underlying object
$uploadField->setFolderName('Address Book');
$uploadField->setAllowedMaxFileNumber(1);
if ($file instanceof Image) {
$uploadField->setAllowedFileCategories('image');
}
$actions = new FieldList(new FormAction('submit', 'Save'));
$from = new Form(Controller::curr(), 'feFileUploadForm', $fields, $actions, null);
$urlParams = array('feclass' => $parentClass, 'fefield' => $parentField, 'feid' => $parentId, 'filesUpload' => true, 'fefileid' => $file->ID, 'fefileclass' => $file->ClassName);
// feclass: parentClass,
// fefield: parentField,
// feid: parentId,
// feisUpload: true,
// value: "{feclass: " + objClass + ",feid: " + objId + "}"
// echo http_build_query($urlParams) . "\n";
$from->setFormAction('home/feFileUploadForm?' . http_build_query($urlParams));
return $from;
}
}
示例7: getCMSFields
/**
* Returns a FieldSet with which to create the CMS editing form.
* You can use the extend() method of FieldSet to create customised forms for your other
* data objects.
*
* @param Controller
* @return FieldSet
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeFieldFromTab('Root.Main', 'Content');
$BackgroundImageField = new UploadField('BackgroundImage');
$BackgroundImageField->setFolderName('homepage');
$fields->addFieldToTab('Root.Header', $BackgroundImageField);
$ForegroundImageField = new UploadField('ForegroundImage');
$ForegroundImageField->setFolderName('homepage');
$fields->addFieldToTab('Root.Header', $ForegroundImageField);
$FocalImageLeftField = new UploadField('FocalImageLeft');
$FocalImageLeftField->setFolderName('homepage');
$fields->addFieldToTab('Root.Header', $FocalImageLeftField);
$FocalImageCentreField = new UploadField('FocalImageCentre');
$FocalImageCentreField->setFolderName('homepage');
$fields->addFieldToTab('Root.Header', $FocalImageCentreField);
$FocalImageRightField = new UploadField('FocalImageRight');
$FocalImageRightField->setFolderName('homepage');
$fields->addFieldToTab('Root.Header', $FocalImageRightField);
$fields->addFieldToTab('Root.Header', new TextField('FirstTagLine', _t('ScoutDistrict.Homepage.FirstTagLine', 'First Line of Header')));
$fields->addFieldToTab('Root.Header', new TextField('SecondTagLine', _t('ScoutDistrict.Homepage.SecondTagLine', 'Second Line of Header')));
$fields->addFieldToTab('Root.Header', new TextField('TagLinkText', _t('ScoutDistrict.Homepage.TagLinkText', 'Text to show on Header Button')));
$fields->addFieldToTab('Root.Header', new TreeDropdownField("TagLink", _t('ScoutDistrict.Homepage.TagLink', 'Where should Header Button link to'), "SiteTree"));
$blogDropdown = new TreeDropdownField("BlogHolder", "Which blog/news page should we use", "SiteTree");
$fields->addFieldToTab('Root.Main', $blogDropdown, 'Metadata');
$calDropdown = new TreeDropdownField("Calendar", "Which calendar page should we use", "SiteTree");
$fields->addFieldToTab('Root.Main', $calDropdown, 'Metadata');
$fields->addFieldToTab('Root.Main', new TreeDropdownField("InfoPanelPage", "Select the page to use in the Info panel", "SiteTree"), 'Metadata');
$infoImageField = new UploadField('InfoPanelImage');
$fields->addFieldToTab('Root.Main', $infoImageField, 'Metadata');
return $fields;
}
示例8: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$type = new DropdownField('EventType', _t('ScoutDistrict.Events.TYPE', 'Type'), array('section-meeting' => _t('ScoutDistrict.Enum.SECTIONMEETING', 'Section Meeting'), 'leaders-meeting' => _t('ScoutDistrict.Enum.LEADERSMEETING', 'Leaders Meeting'), 'activity' => _t('ScoutDistrict.Enum.ACTIVITY', 'Activity'), 'fundraising' => _t('ScoutDistrict.Enum.FUNDRAISING', 'Fundraising'), 'committee' => _t('ScoutDistrict.Enum.COMMITTEE', 'Committee'), 'camp' => _t('ScoutDistrict.Enum.CAMP', 'Camp'), 'group' => _t('ScoutDistrict.Enum.GROUP', 'Group'), 'district' => _t('ScoutDistrict.Enum.DISTRICT', 'District'), 'training' => _t('ScoutDistrict.Enum.TRAINING', 'Training'), 'other' => _t('ScoutDistrict.Enum.OTHER', 'Other')));
$type->setRightTitle(_t('ScoutDistrict.Events.TYPE_HELP', 'What Type of event is this'))->addExtraClass('help');
$location = new TextField('EventLocation', _t('ScoutDistrict.Events.LOCATION', 'Location'));
$location->setRightTitle(_t('ScoutDistrict.Events.LOCATION_HELP', 'Where is the event being held'))->addExtraClass('help');
$latitude = new TextField('EventLatitude', _t('ScoutDistrict.Events.LATITUDE', 'Latitude'));
$latitude->setRightTitle(_t('ScoutDistrict.Events.LATITUDE_HELP', 'Latitude of event Location'))->addExtraClass('help');
$longitude = new TextField('EventLongitude', _t('ScoutDistrict.Events.LONGITUDE', 'Longitude'));
$longitude->setRightTitle(_t('ScoutDistrict.Events.LONGITUDE_HELP', 'Longitude of event Location'))->addExtraClass('help');
$bookingDetails = new TextareaField('EventBookingDetails', _t('ScoutDistrict.Events.BOOKINGDETAILS', 'Booking Details'));
$bookingDetails->setRightTitle(_t('ScoutDistrict.Events.BOOKINGDETAILS_HELP', 'Details of how to book a place for the Event'))->addExtraClass('help');
$bookingURL = new TextField('EventBookingURL', _t('ScoutDistrict.Events.BOOKINGURL', 'Booking URL'));
$bookingURL->setRightTitle(_t('ScoutDistrict.Events.BOOKINGURL_HELP', 'The URL of an external site to book a place'))->addExtraClass('help');
$fields->addFieldsToTab('Root.Scouts', array($type, $location, $latitude, $longitude, $bookingDetails, $bookingURL));
$thumbnail = new UploadField('ThumbnailImage', _t('ScoutDistrict.Events.THUMBNAIL', 'Thumbnail Image'));
$thumbnail->setFolderName('event/thumbnail');
$thumbnail->setRightTitle(_t('ScoutDistrict.Events.THUMBNAIL_HELP', 'A small image for displaying in listing/aggregated content'))->addExtraClass('help');
$image = new UploadField('Image', _t('ScoutDistrict.Events.IMAGE', 'Image'));
$image->setFolderName('event/image');
$image->setRightTitle(_t('ScoutDistrict.Events.IMAGE_HELP', 'A Larger image for displaying in event header'))->addExtraClass('help');
$files = new UploadField('Files', _t('ScoutDistrict.Events.FILE', 'Files'));
$files->setFolderName('event/file');
$files->setRightTitle(_t('ScoutDistrict.Events.FILE_HELP', 'This can be a file containing information about the event or an application form, etc'))->addExtraClass('help');
$fields->addFieldsToTab('Root.Files', array($thumbnail, $image, $files));
return $fields;
}
开发者ID:helpfulrobot,项目名称:phpboyscout-silverstripe-scouts,代码行数:27,代码来源:ScoutCalenderEventExtension.php
示例9: 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;
}
示例10: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeByName("FlexSliderID");
// Main
$field_Picture = new UploadField('Picture', _t("FlexSlider.Picture"));
$field_Picture->setFolderName("FlexSlides");
$field_Picture->setConfig('allowedMaxFileNumber', 1);
$field_Position = new NumericField("Position", _t("FlexSlider.Position"));
$field_Position->RightTitle(_t("FlexSlider.PositionExplain"));
$field_SlideTitle = new TextField("SlideTitle", _t("FlexSlider.Title"));
$field_SlideDescription = new TextField("SlideDescription", _t("FlexSlider.Description"));
$field_HeadlineLinks = new HeaderField("HeadlineLinks", _t("FlexSlider.HeadlineLinks"));
$field_InternalLink = new TreeDropdownField("InternalLinkID", _t('FlexSlider.InternalLink'), 'SiteTree');
$field_removeInternalLink = new CheckboxField("doRemoveInternalLink", _t("FlexSlider.doRemoveInternalLink"));
$field_ExternalLink = new TextField("ExternalLink", _t("FlexSlider.or") . " " . _t("FlexSlider.ExternalLink"));
$field_HeadlineEnabled = new HeaderField("HeadlineEnabled", _t("FlexSlider.HeadlineEnabled"));
$field_isEnabled = new CheckboxField("isEnabled", _t("FlexSlider.isEnabled"));
$FieldsArray = array($field_Position, $field_Picture, $field_SlideTitle, $field_SlideDescription, $field_InternalLink, $field_removeInternalLink, $field_ExternalLink, $field_HeadlineEnabled, $field_isEnabled);
$fields->addFieldToTab('Root.Main', $field_Position);
$fields->addFieldToTab('Root.Main', $field_Picture);
$fields->addFieldToTab('Root.Main', $field_SlideTitle);
$fields->addFieldToTab('Root.Main', $field_SlideDescription);
$fields->addFieldToTab('Root.Main', $field_HeadlineLinks);
$fields->addFieldToTab('Root.Main', $field_InternalLink);
$fields->addFieldToTab('Root.Main', $field_removeInternalLink);
$fields->addFieldToTab('Root.Main', $field_ExternalLink);
$fields->addFieldToTab('Root.Main', $field_HeadlineEnabled);
$fields->addFieldToTab('Root.Main', $field_isEnabled);
return $fields;
}
示例11: updateCMSFields
/**
* @param FieldList $fields
*/
public function updateCMSFields(FieldList $fields)
{
$tabName = Config::inst()->get('Downloadable', 'tab_name');
$tabFields = array();
$upload = new UploadField('DownloadableFiles', '');
$upload->setFolderName(Config::inst()->get('Downloadable', 'source_folder'));
$tabFields[] = $upload;
// For certain types of products, it makes sense to include downloads
// from parent (ProductVariation) or child products (GroupedProduct)
// NOTE: there could be better ways to do this that don't involve checking
// for specific classes. The advantage here is that the fields show up
// even if the product has not yet been saved or doesn't yet have a
// parent or child products.
$p = $this->owner instanceof ProductVariation ? $this->owner->Product() : $this->owner->Parent();
if ($p && $p->exists() && $p->hasExtension('Downloadable')) {
$tabFields[] = new CheckboxField('IncludeParentDownloads', 'Include downloads from parent product in purchase');
} elseif (class_exists('GroupedProduct') && $this->owner instanceof GroupedProduct) {
$tabFields[] = new CheckboxField('IncludeChildDownloads', 'Include downloads from child products in purchase');
}
// this will just add unnecessary queries slowing down the page load
//$tabFields[] = new LiteralField('DownloadCount', '<p>Total Downloads: <strong>' . $this->owner->getDownloads()->count() . '</strong></p>');
// Product variations don't have tabs, so we need to be able
// to handle either case.
if ($fields->first() instanceof TabSet) {
$fields->addFieldsToTab("Root.{$tabName}", $tabFields);
} else {
$fields->push(new HeaderField('DownloadsHeader', $tabName));
foreach ($tabFields as $f) {
$fields->push($f);
}
}
}
示例12: 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;
}
示例13: 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;
}
示例14: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
// Main
$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.Main', $showTitle = new CheckboxField('ShowTitleInHeader', 'Show title in header'), 'Tagline');
/* @var $logoField UploadField */
$logoField = new UploadField('Logo', 'Large logo, to appear in the header.');
$logoField->setAllowedFileCategories('image');
$logoField->setConfig('allowedMaxFileNumber', 1);
$mobileLogoField = new UploadField('LogoMobile', 'Mobile logo, to appear in the header.');
$mobileLogoField->setAllowedFileCategories('image');
$mobileLogoField->setConfig('allowedMaxFileNumber', 1);
$fields->addFieldToTab('Root.Main', $logoField);
$fields->addFieldToTab('Root.Main', $this->getLogoOffSetField());
$fields->addFieldToTab('Root.Main', $mobileLogoField);
$fields->addFieldToTab('Root.Main', $this->getMobileLogoOffSetField());
//Footer
$fields->addFieldToTab('Root.Footer', $footerLogoField = new UploadField('FooterLogo', 'Footer logo, to appear in the bottom right.'));
$footerLogoField->setAllowedFileCategories('image');
$footerLogoField->setConfig('allowedMaxFileNumber', 1);
$fields->addFieldToTab('Root.Footer', $footerLink = new TextField('FooterLogoLink', 'Footer Logo link'));
$footerLink->setRightTitle('Please include the protocol (ie, http:// or https://) unless it is an internal link.');
$fields->addFieldToTab('Root.Footer', new TextField('FooterLogoDescription', 'Footer Logo description'));
$fields->addFieldToTab('Root.Footer', new TreeMultiselectField('FooterLinks', 'Footer Links', 'SiteTree'));
$fields->addFieldToTab('Root.Footer', new TextField('Copyright', 'Copyright'));
}
示例15: 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 (empty($hasOneClass)) {
return null;
}
$hasOneSingleton = singleton($hasOneClass);
if ($hasOneSingleton instanceof File) {
$field = new UploadField($relationName, $title);
if ($hasOneSingleton instanceof Image) {
$field->setAllowedFileCategories('image/supported');
}
return $field;
}
// Build selector / numeric field
$titleField = $hasOneSingleton->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;
}