当前位置: 首页>>代码示例>>PHP>>正文


PHP ListboxField类代码示例

本文整理汇总了PHP中ListboxField的典型用法代码示例。如果您正苦于以下问题:PHP ListboxField类的具体用法?PHP ListboxField怎么用?PHP ListboxField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ListboxField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makeListboxField

 protected function makeListboxField($value)
 {
     $field = new ListboxField(self::FieldName, $this->getFieldLabel(), array_flip(Config::inst()->get('ArtisanHasWidthExtension', 'widths')), $value);
     if ($note = $this->getFieldLabel('Note')) {
         $field->setRightTitle($note);
     }
     return $field;
 }
开发者ID:CrackerjackDigital,项目名称:artisan,代码行数:8,代码来源:ArtisanHasWidthExtension.php

示例2: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('NotificationMembers');
     $fields->removeByName('CreatedByMemberID');
     $fields->addFieldToTab('Root.Main', new TextField('MemberNotificationTitle', 'User notification title'));
     $fields->addFieldToTab('Root.Main', new TextareaField('MemberNotificationMessage', 'User notification message (200) characters only'));
     // members - many_many relation
     $membersMap = Member::get()->sort('FirstName')->map('ID', 'FirstName')->toArray();
     $membersField = new ListboxField('NotificationMembers', 'Select users');
     $membersField->setMultiple(true)->setSource($membersMap);
     $fields->addFieldToTab('Root.Main', $membersField);
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:nadzweb-membernotification,代码行数:14,代码来源:MemberNotification.php

示例3: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     /*
      *   MAIN TAB
      */
     $tab = 'Root.Main';
     //provides listbox field menu for selecting a predefined Icon
     $data = DataObject::get('Icon');
     $field = new ListboxField('MyIconID', 'My Icon');
     $field->setSource($data->map('ID', 'Name')->toArray());
     $field->setEmptyString('Select one');
     $fields->addFieldToTab($tab, $field);
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:stephenjcorwin-silverstripe-icons,代码行数:15,代码来源:Page.php

示例4: getDefaultSearchContext

 public function getDefaultSearchContext()
 {
     $context = parent::getDefaultSearchContext();
     $fields = $context->getFields();
     $fields->push(CheckboxField::create("HasBeenUsed"));
     //add date range filtering
     $fields->push(ToggleCompositeField::create("StartDate", "Start Date", array(DateField::create("q[StartDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[StartDateTo]", "To")->setConfig('showcalendar', true))));
     $fields->push(ToggleCompositeField::create("EndDate", "End Date", array(DateField::create("q[EndDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[EndDateTo]", "To")->setConfig('showcalendar', true))));
     //must be enabled in config, because some sites may have many products = slow load time, or memory maxes out
     //future solution is using an ajaxified field
     if (self::config()->filter_by_product) {
         $fields->push(ListboxField::create("Products", "Products", Product::get()->map()->toArray())->setMultiple(true));
     }
     if (self::config()->filter_by_category) {
         $fields->push(ListboxField::create("Categories", "Categories", ProductCategory::get()->map()->toArray())->setMultiple(true));
     }
     if ($field = $fields->fieldByName("Code")) {
         $field->setDescription("This can be a partial match.");
     }
     //get the array, to maniplulate name, and fullname seperately
     $filters = $context->getFilters();
     $filters['StartDateFrom'] = GreaterThanOrEqualFilter::create('StartDate');
     $filters['StartDateTo'] = LessThanOrEqualFilter::create('StartDate');
     $filters['EndDateFrom'] = GreaterThanOrEqualFilter::create('EndDate');
     $filters['EndDateTo'] = LessThanOrEqualFilter::create('EndDate');
     $context->setFilters($filters);
     return $context;
 }
开发者ID:helpfulrobot,项目名称:silvershop-discounts,代码行数:28,代码来源:Discount.php

示例5: 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;
 }
开发者ID:helpfulrobot,项目名称:micmania1-silverstripe-blog,代码行数:30,代码来源:BlogPost.php

示例6: Field

 public function Field($properties = array())
 {
     Requirements::javascript(BOLTTOOLS_DIR . '/javascript/addnewlistboxfield.js');
     $this->setTemplate('AddNewListboxField');
     $this->addExtraClass('has-chzn');
     return parent::Field($properties);
 }
开发者ID:christopherbolt,项目名称:silverstripe-bolttools,代码行数:7,代码来源:AddNewListboxField.php

示例7: updateCMSFields

 /**
  * 
  * @param FieldList $fields
  * @return void
  */
 public function updateCMSFields(FieldList $fields)
 {
     $controller = Controller::curr();
     if ($controller instanceof SecuredAssetAdmin || $controller instanceof CMSSecuredFileAddController) {
         Requirements::combine_files('securedassetsadmincmsfields.js', array(SECURED_FILES_MODULE_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-sliderAccess.js', SECURED_FILES_MODULE_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-timepicker-addon.min.js', SECURED_FILES_MODULE_DIR . "/javascript/SecuredFilesLeftAndMain.js"));
         Requirements::css(SECURED_FILES_MODULE_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-timepicker-addon.min.css');
         Requirements::css(SECURED_FILES_MODULE_DIR . "/css/SecuredFilesLeftAndMain.css");
         Requirements::javascript(SECURED_FILES_MODULE_DIR . "/javascript/SecuredFilesLeftAndMain.js");
         if ($this->isFile()) {
             $buttonsSecurity = $this->showButtonsSecurity();
             $buttonsEmbargoExpiry = $this->showButtonsEmbargoExpiry();
             // Embargo field
             $embargoTypeField = new OptionSetField("EmbargoType", "", array("None" => _t('AdvancedSecuredFiles.NONENICE', "None"), "Indefinitely" => _t('AdvancedSecuredFiles.INDEFINITELYNICE', "Hide document indefinitely"), "UntilAFixedDate" => _t('AdvancedSecuredFiles.UNTILAFIXEDDATENICE', 'Hide until set date')));
             $embargoUntilDateField = DatetimeField::create('EmbargoedUntilDate', '');
             $embargoUntilDateField->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('datavalueformat', 'dd-MM-yyyy')->setAttribute('readonly', true);
             $embargoUntilDateField->getTimeField()->setAttribute('readonly', true);
             // Expiry field
             $expireTypeField = new OptionSetField("ExpiryType", "", array("None" => _t('AdvancedSecuredFiles.NONENICE', "None"), "AtAFixedDate" => _t('AdvancedSecuredFiles.ATAFIXEDDATENICE', 'Set file to expire on')));
             $expiryDatetime = DatetimeField::create('ExpireAtDate', '');
             $expiryDatetime->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('datavalueformat', 'dd-MM-yyyy')->setAttribute('readonly', true);
             $expiryDatetime->getTimeField()->setAttribute('readonly', true);
             $securitySettingsGroup = FieldGroup::create(FieldGroup::create($embargoTypeField, $embargoUntilDateField)->addExtraClass('embargo option-change-datetime')->setName("EmbargoGroupField"), FieldGroup::create($expireTypeField, $expiryDatetime)->addExtraClass('expiry option-change-datetime')->setName("ExpiryGroupField"));
         } else {
             $buttonsSecurity = $this->showButtonsSecurity();
             $buttonsEmbargoExpiry = '';
             $securitySettingsGroup = FieldGroup::create();
         }
         $canViewTypeField = new OptionSetField("CanViewType", "", array("Inherit" => _t('AdvancedSecuredFiles.INHERIT', "Inherit from parent folder"), "Anyone" => _t('SiteTree.ACCESSANYONE', 'Anyone'), "LoggedInUsers" => _t('SiteTree.ACCESSLOGGEDIN', 'Logged-in users'), "OnlyTheseUsers" => _t('SiteTree.ACCESSONLYTHESE', 'Only these people (choose from list)')));
         $canEditTypeField = new OptionSetField("CanEditType", "", array("Inherit" => _t('AdvancedSecuredFiles.INHERIT', "Inherit from parent folder"), "LoggedInUsers" => _t('SiteTree.ACCESSLOGGEDIN', 'Logged-in users'), "OnlyTheseUsers" => _t('SiteTree.ACCESSONLYTHESE', 'Only these people (choose from list)')));
         $groupsMap = array();
         foreach (Group::get() as $group) {
             // Listboxfield values are escaped, use ASCII char instead of »
             $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
         }
         asort($groupsMap);
         $viewerGroupsField = ListboxField::create("ViewerGroups", _t('AdvancedSecuredFiles.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('AdvancedSecuredFiles.GroupPlaceholder', 'Click to select group'));
         $editorGroupsField = ListBoxField::create("EditorGroups", _t('AdvancedSecuredFiles.EDITORGROUPS', "Editor Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('AdvancedSecuredFiles.GroupPlaceholder', 'Click to select group'));
         $securitySettingsGroup->push(FieldGroup::create($canViewTypeField, $viewerGroupsField)->addExtraClass('whocanview option-change-listbox')->setName("CanViewGroupField"));
         $securitySettingsGroup->push(FieldGroup::create($canEditTypeField, $editorGroupsField)->addExtraClass('whocanedit option-change-listbox')->setName("CanEditGroupField"));
         $securitySettingsGroup->setName("SecuritySettingsGroupField")->addExtraClass('security-settings');
         $showAdvanced = AdvancedAssetsFilesSiteConfig::is_security_enabled() || $this->isFile() && AdvancedAssetsFilesSiteConfig::is_embargoexpiry_enabled();
         if ($showAdvanced) {
             $fields->insertAfter(LiteralField::create('BottomTaskSelection', $this->owner->renderWith('componentField', ArrayData::create(array('ComponentSecurity' => AdvancedAssetsFilesSiteConfig::component_cms_icon('security'), 'ComponentEmbargoExpiry' => AdvancedAssetsFilesSiteConfig::component_cms_icon('embargoexpiry'), 'ButtonsSecurity' => $buttonsSecurity, 'ButtonsEmbargoExpiry' => $buttonsEmbargoExpiry)))), "ParentID");
             $fields->insertAfter($securitySettingsGroup, "BottomTaskSelection");
         }
     }
     if (!is_a($this->owner, "Folder") && is_a($this->owner, "File")) {
         $parentIDField = $fields->dataFieldByName("ParentID");
         if ($controller instanceof SecuredAssetAdmin) {
             $securedRoot = FileSecured::getSecuredRoot();
             $parentIDField->setTreeBaseID($securedRoot->ID);
             $parentIDField->setFilterFunction(create_function('$node', "return \$node->Secured == 1;"));
         } else {
             $parentIDField->setFilterFunction(create_function('$node', "return \$node->Secured == 0;"));
         }
         // SilverStripe core has a bug for search function now, so disable it for now.
         $parentIDField->setShowSearch(false);
     }
 }
开发者ID:helpfulrobot,项目名称:deviateltd-silverstripe-advancedassets,代码行数:64,代码来源:FileSecured.php

示例8: getCMSFields

 public function getCMSFields()
 {
     Requirements::add_i18n_javascript(BLOCKS_DIR . '/javascript/lang');
     // this line is a temporary patch until I can work out why this dependency isn't being
     // loaded in some cases...
     if (!$this->blockManager) {
         $this->blockManager = singleton('BlockManager');
     }
     $fields = parent::getCMSFields();
     // ClassNmae - block type/class field
     $classes = $this->blockManager->getBlockClasses();
     $fields->addFieldToTab('Root.Main', DropdownField::create('ClassName', 'Block Type', $classes)->addExtraClass('block-type'), 'Title');
     // BlockArea - display areas field if on page edit controller
     if (Controller::curr()->class == 'CMSPageEditController') {
         $currentPage = Controller::curr()->currentPage();
         $fields->addFieldToTab('Root.Main', DropdownField::create('ManyMany[BlockArea]', 'BlockArea', $this->blockManager->getAreasForPageType($currentPage->ClassName))->setHasEmptyDefault(true)->setRightTitle($currentPage->areasPreviewButton()), 'ClassName');
     }
     $fields->removeFieldFromTab('Root', 'BlockSets');
     $fields->removeFieldFromTab('Root', 'Pages');
     // legacy fields, will be removed in later release
     $fields->removeByName('Weight');
     $fields->removeByName('Area');
     $fields->removeByName('Published');
     if ($this->blockManager->getUseExtraCSSClasses()) {
         $fields->addFieldToTab('Root.Main', $fields->dataFieldByName('ExtraCSSClasses'), 'Title');
     } else {
         $fields->removeByName('ExtraCSSClasses');
     }
     // Viewer groups
     $fields->removeFieldFromTab('Root', 'ViewerGroups');
     $groupsMap = Group::get()->map('ID', 'Breadcrumbs')->toArray();
     asort($groupsMap);
     $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteTree.ACCESSHEADER', "Who can view this page?"));
     $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group'));
     $viewersOptionsSource = array();
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource)->setValue("Anyone");
     $fields->addFieldsToTab('Root.ViewerGroups', array($viewersOptionsField, $viewerGroupsField));
     // Disabled for now, until we can list ALL pages this block is applied to (inc via sets)
     // As otherwise it could be misleading
     // Show a GridField (list only) with pages which this block is used on
     // $fields->removeFieldFromTab('Root.Pages', 'Pages');
     // $fields->addFieldsToTab('Root.Pages',
     // 		new GridField(
     // 				'Pages',
     // 				'Used on pages',
     // 				$this->Pages(),
     // 				$gconf = GridFieldConfig_Base::create()));
     // enhance gridfield with edit links to pages if GFEditSiteTreeItemButtons is available
     // a GFRecordEditor (default) combined with BetterButtons already gives the possibility to
     // edit versioned records (Pages), but STbutton loads them in their own interface instead
     // of GFdetailform
     // if(class_exists('GridFieldEditSiteTreeItemButton')){
     // 	$gconf->addComponent(new GridFieldEditSiteTreeItemButton());
     // }
     return $fields;
 }
开发者ID:mhssmnn,项目名称:silverstripe-blocks,代码行数:59,代码来源:Block.php

示例9: updateSearchForm

 /**
  *	Update the page filtering, allowing CMS searchable content tagging.
  */
 public function updateSearchForm($form)
 {
     // Update the page filtering, allowing multiple tags.
     Requirements::javascript(FUSION_PATH . '/javascript/fusion.js');
     // Instantiate a field containing the existing tags.
     $form->Fields()->insertBefore(ListboxField::create('q[Tagging]', 'Tags', FusionTag::get()->map('Title', 'Title')->toArray(), ($filtering = $this->owner->getRequest()->getVar('q')) && isset($filtering['Tagging']) ? $filtering['Tagging'] : array(), null, true), 'q[Term]');
     // Allow extension.
     $this->owner->extend('updateCMSMainTaggingExtensionSearchForm', $form);
 }
开发者ID:nglasl,项目名称:silverstripe-fusion,代码行数:12,代码来源:CMSMainTaggingExtension.php

示例10: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     $localesNames = Fluent::locale_names();
     if (!$this->owner instanceof SiteConfig) {
         // If the ActiveLocales has been applied to SiteConfig, restrict locales to allowed ones
         $conf = SiteConfig::current_site_config();
         if ($conf->hasExtension('ActiveLocalesExtension') && $conf->ActiveLocales) {
             $localesNames = $conf->ActiveLocalesNames();
         }
     }
     // Avoid clutter if we only have one locale anyway
     if (count($localesNames) === 1) {
         return;
     }
     $fields->addFieldToTab('Root.Main', $lang = new ListboxField('ActiveLocales', _t('ActiveLocalesExtension.ACTIVELOCALE', 'Active Languages'), $localesNames));
     $lang->setMultiple(true);
     return $fields;
 }
开发者ID:lekoala,项目名称:silverstripe-devtoolkit,代码行数:18,代码来源:ActiveLocalesExtension.php

示例11: updateCMSFields

 /**
  * Adds variations specific fields to the CMS.
  */
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldsToTab('Root.Variations', array(ListboxField::create("VariationAttributeTypes", _t('ProductVariationsExtension.ATTRIBUTES', "Attributes"), ProductAttributeType::get()->map("ID", "Title")->toArray())->setMultiple(true)->setDescription(_t('ProductVariationsExtension.ATTRIBUTES_DESCRIPTION', "These are fields to indicate the way(s) each variation varies. Once selected, they can be edited on each variation.")), GridField::create("Variations", _t('ProductVariationsExtension.VARIATIONS', "Variations"), $this->owner->Variations(), GridFieldConfig_RecordEditor::create())));
     if ($this->owner->Variations()->exists()) {
         $fields->addFieldToTab('Root.Pricing', LabelField::create('variationspriceinstructinos', _t('ProductVariationsExtension.VARIATIONS_INSTRUCTIONS', "Price - Because you have one or more variations, the price can be set in the \"Variations\" tab.")));
         $fields->removeFieldFromTab('Root.Pricing', 'BasePrice');
         $fields->removeFieldFromTab('Root.Pricing', 'CostPrice');
         $fields->removeFieldFromTab('Root.Main', 'InternalItemID');
     }
 }
开发者ID:NobrainerWeb,项目名称:silverstripe-shop,代码行数:13,代码来源:ProductVariationsExtension.php

示例12: updateCMSFields

 public function updateCMSFields($fields)
 {
     $topLevelGroups = Group::get()->filter('ParentID', 0)->map()->toArray();
     $groups = ListboxField::create('LoggedInGroups', 'Groups representing logged in users', $topLevelGroups);
     $groups->setMultiple(true);
     $fields->addFieldToTab('Root.MicroBlogSettings', $groups);
     $allGroups = Group::get()->map()->toArray();
     $groups = ListboxField::create('TargetedGroups', 'Groups users can selectively post to', $allGroups);
     $groups->setMultiple(true);
     $fields->addFieldToTab('Root.MicroBlogSettings', $groups);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-microblog,代码行数:11,代码来源:MicroBlogSystemSettings.php

示例13: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $metricsMap = array();
     foreach (Metric::get() as $metric) {
         $metricsMap[$metric->ID] = $metric->Name;
     }
     $metricsField = \ListboxField::create('Metrics', 'Metrics')->setMultiple(true)->setSource($metricsMap);
     $fields->addFieldToTab('Root.Main', $metricsField);
     return $fields;
 }
开发者ID:silverstripeltd,项目名称:deploynaut-metrics,代码行数:11,代码来源:MetricSet.php

示例14: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('FaqPageID');
     $fields->removeByName('FaqTags');
     $fields->removeByName('SortOrder');
     $fields->addFieldToTab('Root.Main', new TextField('Question', 'Question'));
     $fields->addFieldToTab('Root.Main', new HtmlEditorField('Answer', 'Answer'));
     // faq section - has_one relation
     $map = FaqSection::get()->sort('Title')->map('ID', 'Title');
     $field = new DropdownField('FaqSectionID', 'Faq section', $map);
     $field->setEmptyString('None');
     $fields->addFieldToTab('Root.Main', $field, 'Question');
     // faq tags - has_many relation
     $tagMap = FaqTag::get()->sort('Title')->map('ID', 'Title')->toArray();
     $tagsField = new ListboxField('FaqTags', 'Faq tags');
     $tagsField->setMultiple(true)->setSource($tagMap);
     $fields->addFieldToTab('Root.Main', $tagsField, 'Question');
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:nadzweb-advancedfaq,代码行数:20,代码来源:Faq.php

示例15: getCMSFields

 /**
  *	Display the appropriate CMS media page fields and respective media type attributes.
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Display the media type as read only.
     $fields->addFieldToTab('Root.Main', ReadonlyField::create('Type', 'Type', $this->MediaType()->Title), 'Title');
     // Display a notification that the parent holder contains mixed children.
     $parent = $this->getParent();
     if ($parent && $parent->getMediaHolderChildren()->exists()) {
         Requirements::css(MEDIAWESOME_PATH . '/css/mediawesome.css');
         $fields->addFieldToTab('Root.Main', LiteralField::create('MediaNotification', "<p class='mediawesome notification'><strong>Mixed {$this->MediaType()->Title} Holder</strong></p>"), 'Type');
     }
     // Display the remaining media page fields.
     $fields->addFieldToTab('Root.Main', TextField::create('ExternalLink')->setRightTitle('An <strong>optional</strong> redirect URL to the media source'), 'URLSegment');
     $fields->addFieldToTab('Root.Main', $date = DatetimeField::create('Date'), 'Content');
     $date->getDateField()->setConfig('showcalendar', true);
     // Allow customisation of categories and tags respective to the current page.
     $tags = MediaTag::get()->map()->toArray();
     $fields->findOrMakeTab('Root.CategoriesTags', 'Categories and Tags');
     $fields->addFieldToTab('Root.CategoriesTags', $categoriesList = ListboxField::create('Categories', 'Categories', $tags)->setMultiple(true));
     $fields->addFieldToTab('Root.CategoriesTags', $tagsList = ListboxField::create('Tags', 'Tags', $tags)->setMultiple(true));
     if (!$tags) {
         $categoriesList->setAttribute('disabled', 'true');
         $tagsList->setAttribute('disabled', 'true');
     }
     // Allow customisation of media type attribute content respective to the current page.
     if ($this->MediaAttributes()->exists()) {
         foreach ($this->MediaAttributes() as $attribute) {
             if (strripos($attribute->Title, 'Time') || strripos($attribute->Title, 'Date') || stripos($attribute->Title, 'When')) {
                 // Display an attribute as a date time field where appropriate.
                 $fields->addFieldToTab('Root.Main', $custom = DatetimeField::create("{$attribute->ID}_MediaAttribute", $attribute->Title, $attribute->Content), 'Content');
                 $custom->getDateField()->setConfig('showcalendar', true);
             } else {
                 $fields->addFieldToTab('Root.Main', $custom = TextField::create("{$attribute->ID}_MediaAttribute", $attribute->Title, $attribute->Content), 'Content');
             }
             $custom->setRightTitle('Custom <strong>' . strtolower($this->MediaType()->Title) . '</strong> attribute');
         }
     }
     // Display an abstract field for content summarisation.
     $fields->addfieldToTab('Root.Main', $abstract = TextareaField::create('Abstract'), 'Content');
     $abstract->setRightTitle('A concise summary of the content');
     $abstract->setRows(6);
     // Allow customisation of images and attachments.
     $type = strtolower($this->MediaType()->Title);
     $fields->findOrMakeTab('Root.ImagesAttachments', 'Images and Attachments');
     $fields->addFieldToTab('Root.ImagesAttachments', $images = UploadField::create('Images'));
     $images->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif', 'bmp'));
     $images->setFolderName("media-{$type}/{$this->ID}/images");
     $fields->addFieldToTab('Root.ImagesAttachments', $attachments = UploadField::create('Attachments'));
     $attachments->setFolderName("media-{$type}/{$this->ID}/attachments");
     // Allow extension customisation.
     $this->extend('updateMediaPageCMSFields', $fields);
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-mediawesome,代码行数:56,代码来源:MediaPage.php


注:本文中的ListboxField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。