本文整理汇总了PHP中UploadField::create方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadField::create方法的具体用法?PHP UploadField::create怎么用?PHP UploadField::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadField
的用法示例。
在下文中一共展示了UploadField::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCMSFields
public function getCMSFields()
{
if ($this->ID == 0) {
$categorydropdown = TextField::create('CategoryDisclaimer')->setTitle('Category')->setDisabled(true)->setValue('You can assign a category once you have saved the record for the first time.');
} else {
$categories = ListCategory::get()->filter("ListPageID", "{$this->ListPageID}")->sort("Category ASC");
$map = $categories ? $categories->map('ID', 'Category', 'Please Select') : array();
if ($map) {
$categorydropdown = new DropdownField('ListCategoryID', 'Category', $map);
$categorydropdown->setEmptyString("-- Please Select --");
} else {
$categorydropdown = new DropdownField('ListCategoryID', 'Category', $map);
$categorydropdown->setEmptyString("There are no categories created yet");
}
}
$ImageField = UploadField::create('Photo')->setDescription('(Allowed filetypes: jpg, jpeg, png, gif)');
$ImageField->folderName = 'ListPage';
$ImageField->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png');
$DocumentField = UploadField::create('Resource')->setTitle('Resource/Document')->setDescription('(Allowed filetypes: pdf, doc, docx, txt, ppt, or pptx)');
$DocumentField->folderName = "ListPage";
$DocumentField->getValidator()->allowedExtensions = array('pdf', 'doc', 'docx', 'txt', 'ppt', 'pptx');
$LinkField = TextField::create('Link')->setTitle('Link URL');
$fields = FieldList::create(TabSet::create('Root'));
$fields->addFieldsToTab('Root.Main', array($categorydropdown, TextField::create('Title'), OptionSetField::create('LinkType')->setTitle('')->setSource($this->dbObject('LinkType')->enumValues()), TextField::create('Link')->setTitle('Link URL')->displayIf('LinkType')->isEqualTo('Link')->andIf('LinkType')->isNotEqualTo('Resource')->end(), DisplayLogicWrapper::create($DocumentField)->displayIf('LinkType')->isEqualTo('Resource')->andIf('LinkType')->isNotEqualTo('Link')->end(), $ImageField, HTMLEditorField::create('Content')));
return $fields;
}
示例2: __construct
public function __construct($controller, $name)
{
$product = new Product();
$title = new TextField('Title', _t('Product.PAGETITLE', 'Product Title'));
$urlSegment = new TextField('URLSegment', 'URL Segment');
$menuTitle = new TextField('MenuTitle', 'Navigation Title');
$sku = TextField::create('InternalItemID', _t('Product.CODE', 'Product Code/SKU'), '', 30);
$categories = DropdownField::create('ParentID', _t("Product.CATEGORY", "Category"), $product->categoryoptions())->setDescription(_t("Product.CATEGORYDESCRIPTION", "This is the parent page or default category."));
$otherCategories = ListBoxField::create('ProductCategories', _t("Product.ADDITIONALCATEGORIES", "Additional Categories"), ProductCategory::get()->filter("ID:not", $product->getAncestors()->map('ID', 'ID'))->map('ID', 'NestedTitle')->toArray())->setMultiple(true);
$model = TextField::create('Model', _t('Product.MODEL', 'Model'), '', 30);
$featured = CheckboxField::create('Featured', _t('Product.FEATURED', 'Featured Product'));
$allow_purchase = CheckboxField::create('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased'), 1, 'Content');
$price = TextField::create('BasePrice', _t('Product.PRICE', 'Price'))->setDescription(_t('Product.PRICEDESC', "Base price to sell this product at."))->setMaxLength(12);
$image = UploadField::create('Image', _t('Product.IMAGE', 'Product Image'));
$content = new HtmlEditorField('Content', 'Content');
$fields = new FieldList();
$fields->add($title);
//$fields->add($urlSegment);
//$fields->add($menuTitle);
//$fields->add($sku);
$fields->add($categories);
//$fields->add($otherCategories);
$fields->add($model);
$fields->add($featured);
$fields->add($allow_purchase);
$fields->add($price);
$fields->add($image);
$fields->add($content);
//$fields = $product->getFrontEndFields();
$actions = new FieldList(new FormAction('submit', _t("ChefProductForm.ADDPRODUCT", 'Add product')));
$requiredFields = new RequiredFields(array('Title', 'Model', 'Price'));
parent::__construct($controller, $name, $fields, $actions, $requiredFields);
}
示例3: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
if ($this->owner->Site()->hasFeature('PageThumbnails')) {
$fields->addFieldToTab('Root.Main', $thumb = UploadField::create('PageThumbnail', 'Page Thumbnail'));
$thumb->getValidator()->allowedExtensions = array('jpg', 'gif', 'png');
}
}
示例4: getCMSFields
/**
* CMS Fields
* @return array
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldsToTab("Root.Main", array(UploadField::create('Image')->setFolderName('Person'), TextField::create('Name'), TextField::create('Title'), TextField::create('Email'), TextField::create('Phone'), TextField::create('Mobile'), HTMLEditorField::create('Description')));
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例5: getEditForm
/**
* @return Form
* @todo what template is used here? AssetAdmin_UploadContent.ss doesn't seem to be used anymore
*/
public function getEditForm($id = null, $fields = null)
{
Requirements::javascript(FRAMEWORK_DIR . '/javascript/AssetUploadField.js');
Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
$folder = $this->currentPage();
$uploadField = UploadField::create('AssetUploadField', '');
$uploadField->setConfig('previewMaxWidth', 40);
$uploadField->setConfig('previewMaxHeight', 30);
$uploadField->setConfig('changeDetection', false);
$uploadField->addExtraClass('ss-assetuploadfield');
$uploadField->removeExtraClass('ss-uploadfield');
$uploadField->setTemplate('AssetUploadField');
if ($folder->exists() && $folder->getFilename()) {
// The Upload class expects a folder relative *within* assets/
$path = preg_replace('/^' . ASSETS_DIR . '\\//', '', $folder->getFilename());
$uploadField->setFolderName($path);
} else {
$uploadField->setFolderName('/');
// root of the assets
}
$exts = $uploadField->getValidator()->getAllowedExtensions();
asort($exts);
$uploadField->Extensions = implode(', ', $exts);
$form = CMSForm::create($this, 'EditForm', new FieldList($uploadField, new HiddenField('ID')), new FieldList())->setHTMLID('Form_EditForm');
$form->setResponseNegotiator($this->getResponseNegotiator());
$form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
// Don't use AssetAdmin_EditForm, as it assumes a different panel structure
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
$form->Fields()->push(new LiteralField('BackLink', sprintf('<a href="%s" class="backlink ss-ui-button cms-panel-link" data-icon="back">%s</a>', Controller::join_links(singleton('AssetAdmin')->Link('show'), $folder ? $folder->ID : 0), _t('AssetAdmin.BackToFolder', 'Back to folder'))));
$form->loadDataFrom($folder);
return $form;
}
示例6: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
// Add config sets
$fields->addFieldToTab('Root.Catalogue', UploadField::create('DefaultProductImage', _t("Catalogue.DefaultProductImage", 'Default product image')));
// Add config sets
$fields->addFieldToTab('Root.Catalogue', GridField::create('TaxRates', _t("Catalogue.TaxRates", "Tax Rates"), TaxRate::get(), GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldAddNewButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(5), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm())));
}
示例7: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->insertBefore($shoptab = new Tab('Shop', 'Shop'), 'Access');
$fields->addFieldsToTab("Root.Shop", new TabSet("ShopTabs", $maintab = new Tab("Main", TreeDropdownField::create('TermsPageID', _t("ShopConfig.TERMSPAGE", 'Terms and Conditions Page'), 'SiteTree'), TreeDropdownField::create("CustomerGroupID", _t("ShopConfig.CUSTOMERGROUP", "Group to add new customers to"), "Group"), UploadField::create('DefaultProductImage', _t('ShopConfig.DEFAULTIMAGE', 'Default Product Image'))), $countriestab = new Tab("Countries", CheckboxSetField::create('AllowedCountries', 'Allowed Ordering and Shipping Countries', self::config()->iso_3166_country_codes))));
$fields->removeByName("CreateTopLevelGroups");
$countriestab->setTitle("Allowed Countries");
}
示例8: getCMSFields
public function getCMSFields()
{
Requirements::css(BLOGGER_DIR . '/css/cms.css');
$self =& $this;
$this->beforeUpdateCMSFields(function ($fields) use($self) {
$fields->addFieldsToTab('Root.Main', array(HeaderField::create('Post Options', 3), $publishDate = DatetimeField::create("PublishDate", _t("BlogPost.PublishDate", "Publish Date")), ListboxField::create("Categories", _t("BlogPost.Categories", "Categories"), $self->Parent()->Categories()->map()->toArray())->setMultiple(true), ListboxField::create("Tags", _t("BlogPost.Tags", "Tags"), $self->Parent()->Tags()->map()->toArray())->setMultiple(true)));
$publishDate->getDateField()->setConfig("showcalendar", true);
// Add featured image
$fields->insertBefore($uploadField = UploadField::create("FeaturedImage", _t("BlogPost.FeaturedImage", "Featured Image")), "Content");
$uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
});
$fields = parent::getCMSFields();
// We're going to make an SEO tab and move all the usual crap there
$menuTitle = $fields->dataFieldByName('MenuTitle');
$urlSegment = $fields->dataFieldByName('URLSegment');
$fields->addFieldsToTab('Root.SEO', array($menuTitle, $urlSegment));
$metaField = $fields->fieldByName('Root.Main.Metadata');
if ($metaField) {
$metaFields = $metaField->getChildren();
if ($metaFields->count() > 0) {
$tab = $fields->findOrMakeTab('Root.SEO');
$tab->push(HeaderField::create('Meta', 3));
foreach ($metaFields as $field) {
$tab->push($field);
}
}
$fields->removeByName('Metadata');
}
return $fields;
}
示例9: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeFieldsFromTab('Root.Main', array('Content'));
$fields->addFieldsToTab('Root.Main', array(TextField::create('PolicySummary', 'Policy Summary'), HtmlEditorField::create('PolicyDetail', 'Policy Detail'), UploadField::create('PolicyImages', 'Policy Images', $this->PolicyImages())->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'))->setAllowedMaxFileNumber(6)->setFolderName('AboutPage'), TextField::create('RecipeSummary', 'Recipe Summary'), HtmlEditorField::create('RecipeDetail', 'Recipe Detail'), UploadField::create('RecipeImages', 'Recipe Images', $this->RecipeImages())->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'))->setAllowedMaxFileNumber(6)->setFolderName('AboutPage'), TextField::create('ReputationSummary', 'Reputation Summary'), HtmlEditorField::create('ReputationDetail', 'Reputation Detail'), UploadField::create('ReputationImages', 'Reputation Images', $this->ReputationImages())->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'))->setAllowedMaxFileNumber(6)->setFolderName('AboutPage')), 'Title');
return $fields;
}
示例10: getCMSFields
public function getCMSFields()
{
$fields = FieldList::create(TextField::create('Title'), TextField::create('Teaser'), TextAreaField::create('Description'), $uploader = UploadField::create('Icon'));
$uploader->setFolderName('feature-icons');
$uploader->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpeg', 'jpg', 'svg'));
return $fields;
}
示例11: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldsToTab("Root.Main", array(TextareaField::create('Content', 'Content'), UploadField::create('PreviewImage', 'Image')), 'Type');
$fields->addFieldsToTab("Root.Main", array(TextField::create('ReadMore', 'Read more')));
return $fields;
}
示例12: getCMSFields
public function getCMSFields()
{
$fields = FieldList::create(TextField::create('Author'), TextareaField::create('Teaser'), TextareaField::create('Description'), DateField::create('Date', 'Date of article')->setConfig('showcalendar', true)->setConfig('dateformat', 'd MMMM yyyy'), $photo = UploadField::create('Photo'), $brochure = UploadField::create('Brochure', 'Travel brochure, optional (PDF only)'));
$photo->setFolderName('article-photos')->getValidator()->setAllowedExtensions(array('gif', 'png', 'jpg', 'jpeg'));
$brochure->setFolderName('article-brochures')->getValidator()->setAllowedExtensions(array('pdf'));
return $fields;
}
示例13: getCMSFields
public function getCMSFields()
{
$fields = FieldList::create(TextField::create('Name'), TextField::create('Job'), TextAreaField::create('Description'), $uploader = UploadField::create('Photo'));
$uploader->setFolderName('profile-pictures');
$uploader->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpeg', 'jpg'));
return $fields;
}
示例14: getCMSFields
public function getCMSFields()
{
$fields = FieldList::create(TextField::create('Title'), TextField::create('Copyright'), TextareaField::create('Caption'), $imageField = UploadField::create('Attachment'));
$imageField->setAllowedFileCategories('image');
$imageField->setAllowedMaxFileNumber(1);
return $fields;
}
示例15: updateCMSFields
/**
* CMS Fields
* @return FieldList
*/
public function updateCMSFields(FieldList $fields)
{
if (!Permission::check("VIEW_SECTIONS")) {
return $fields;
}
$SectionGrid = GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->addComponent(new GridFieldAddNewMultiClass())->addComponent(new GridFieldOrderableRows());
$SectionGrid->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('AdminTitle', 'MenuTitle'))->setResultsFormat('$AdminTitle - $Type');
$AvailableTypes = $this->AvailableSectionTypes();
foreach ($AvailableTypes as $key => $value) {
if ($value['selectable_option'] && !$value['limit_reached']) {
$AvailableTypes[$key] = $value['type'];
}
}
$SectionGrid->getComponentByType('GridFieldAddNewMultiClass')->setClasses($AvailableTypes);
// Limit total sections
$LimitSectionTotal = Config::inst()->get($this->owner->ClassName, 'LimitSectionTotal');
if (isset($LimitSectionTotal) && $this->owner->Sections()->Count() >= $LimitSectionTotal) {
// remove the buttons if we don't want to allow more records to be added/created
$SectionGrid->removeComponentsByType('GridFieldAddNewButton');
$SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
$SectionGrid->removeComponentsByType('GridFieldAddNewMultiClass');
}
if (!Permission::check("LINK_SECTIONS")) {
$SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
}
if (!Permission::check("REORDER_SECTIONS")) {
$SectionGrid->removeComponentsByType('GridFieldOrderableRows');
}
if (!Permission::check("UNLINK_SECTIONS")) {
$SectionGrid->removeComponentsByType('GridFieldDeleteAction');
}
$fields->addFieldToTab('Root.Section', GridField::create('Sections', 'Current Section(s)', $this->owner->Sections(), $SectionGrid));
$fields->addFieldToTab('Root.Preview', UploadField::create('PreviewImage', 'Preview image')->setFolderName('Preview'));
return $fields;
}