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


PHP ListboxField::create方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: getSettingsFields

 public function getSettingsFields()
 {
     $fields = parent::getSettingsFields();
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of &raquo;
         $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
     }
     asort($groupsMap);
     $fields->addFieldToTab("Root.Settings", ListboxField::create("PosterGroups", _t("Discussion.PosterGroups", "Groups that can post"))->setMultiple(true)->setSource($groupsMap)->setValue(null, $this->PosterGroups()), "CanViewType");
     $fields->addFieldToTab("Root.Settings", ListboxField::create("ModeratorGroups", _t("Discussion.ModeratorGroups", "Groups that can moderate"))->setMultiple(true)->setSource($groupsMap)->setValue(null, $this->ModeratorGroups()), "CanViewType");
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-discussions,代码行数:13,代码来源:DiscussionHolder.php

示例11: getCMSFields

 /**
  * getCMSFields
  * @return FieldList
  **/
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->dataFieldByName('Title')->setTitle('Article Title');
     $fields->dataFieldByName('Content')->setTitle('Article Content');
     $config = $this->config();
     // publish date
     $fields->addFieldToTab('Root.Main', DateField::create('PublishDate')->setAttribute('placeholder', $this->dbObject('Created')->Format('M d, Y')), 'Content');
     // tags
     if ($config->enable_tags) {
         $tagSource = function () {
             return NewsTag::get()->map()->toArray();
         };
         $fields->addFieldToTab('Root.Main', ListboxField::create('Tags', 'Tags', $tagSource(), null, null, true)->useAddnew('NewsTag', $tagSource), 'Content');
     }
     // author
     if ($config->author_mode == 'string') {
         $fields->addFieldToTab('Root.Main', TextField::create('Author', 'Author'), 'Content');
     }
     if ($config->author_mode == 'object') {
         $authorSource = function () {
             return NewsAuthor::get()->map('ID', 'Name')->toArray();
         };
         $fields->addFieldToTab('Root.Main', DropdownField::create('NewsAuthorID', 'Author', $authorSource())->useAddNew('NewsAuthor', $authorSource)->setHasEmptyDefault(true), 'Content');
     }
     // featured
     if ($config->enable_featured_articles) {
         $fields->addFieldToTab('Root.Main', CheckboxField::create('Featured', _t('NewsArticle.FEATURED', 'Feature this article')), 'Content');
     }
     // images
     if ($config->enable_images) {
         $fields->addFieldToTab('Root.FilesAndImages', UploadField::create('Image')->setAllowedFileCategories('image')->setAllowedMaxFileNumber(1)->setFolderName($config->get('image_folder')));
     }
     // attachments
     if ($config->enable_attachments) {
         $fields->addFieldToTab('Root.FilesAndImages', UploadField::create('Attachment')->setAllowedFileCategories('doc')->setAllowedMaxFileNumber(1)->setFolderName($config->get('attachment_folder')));
     }
     // summary
     if ($config->enable_summary) {
         $fields->addFieldToTab('Root.Main', HTMLEditorField::create('Summary', 'Article Summary'), 'Content');
     }
     // parent
     $holders = NewsHolder::get();
     if ($holders->count() > 1) {
         $fields->addFieldToTab('Root.Main', DropdownField::create('ParentID', 'News Section', $holders->map()->toArray()), 'Title');
     } else {
         $fields->addFieldToTab('Root.Main', HiddenField::create('ParentID', 'News Section', $holders->first()->ID), 'Title');
     }
     $this->extend('updateArticleCMSFields', $fields);
     return $fields;
 }
开发者ID:nyeholt,项目名称:silverstripe-newsly,代码行数:55,代码来源:NewsArticle.php

示例12: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     $categories = function () {
         //TODO: This should only be the case for public events
         return PublicEventCategory::get()->map()->toArray();
     };
     $categoriesField = ListboxField::create('Categories', 'Categories')->setMultiple(true)->setSource($categories());
     //If the quickaddnew module is installed, use it to allow
     //for easy adding of categories
     if (class_exists('QuickAddNewExtension')) {
         $categoriesField->useAddNew('PublicEventCategory', $categories);
     }
     $fields->addFieldToTab('Root.Main', $categoriesField);
 }
开发者ID:andrewandante,项目名称:silverstripe-calendar,代码行数:14,代码来源:EventCategoryExtention.php

示例13: getCMSFields

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('Order');
        $fields->removeByName('ProcessInfo');
        $fields->removeByName('StopStageID');
        $fields->removeByName('StopButton');
        $fields->removeByName('ContinueButton');
        $fields->removeByName('DecisionPoint');
        $fields->removeByName('CaseFinal');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
			<span class="step-label">
				<span class="flyout">3</span><span class="arrow"></span>
				<span class="title">Stage Settings</span>
			</span>
		</h3>'), 'Title');
        $caseFinalMap = ProcessCase::get()->filter(array('ParentProcessID' => $this->ParentID))->map("ID", "Title")->toArray();
        asort($caseFinalMap);
        $case = ListboxField::create('CaseFinal', 'Final step for these Cases')->setMultiple(true)->setSource($caseFinalMap)->setAttribute('data-placeholder', _t('ProcessAdmin.Cases', 'Cases', 'Placeholder text for a dropdown'));
        $fields->insertAfter($case, 'Title');
        $fields->insertAfter($group = new CompositeField($label = new LabelField('switchLabel', 'Act as Decision Point'), new CheckboxField('DecisionPoint', '')), 'ParentID');
        $group->addExtraClass("field special process-noborder");
        $label->addExtraClass("left");
        $fields->dataFieldByName('Content')->setRows(10);
        if ($this->ID > 0) {
            $fields->addFieldToTab('Root.Main', new LiteralField('SaveRecord', '<p></p>'));
            $fields->addFieldToTab('Root.Main', $processInfo = new CompositeField($grid = new GridField('ProcessInfo', 'Information for this stage', $this->ProcessInfo()->sort(array('TypeID' => 'ASC', 'ProcessCaseID' => 'ASC', 'LinksToAnotherStageID' => 'ASC')), $gridConfig = GridFieldConfig_RelationEditor::create())));
            $gridConfig->addComponent(new GridFieldSortableRows('Order'));
            $processInfo->addExtraClass('process-spacing');
            $grid->addExtraClass('toggle-grid');
        } else {
            $fields->addFieldToTab('Root.Main', new LiteralField('SaveRecord', '<p class="message info">Save this stage to add info</p>'));
        }
        $fields->insertBefore(new LiteralField('StageTitleInfo', '<h3 class="process-info-header">
				<span class="step-label">
					<span class="flyout">4</span><span class="arrow"></span>
					<span class="title">Information</span>
				</span>
			</h3>'), 'SaveRecord');
        $stopStage = ProcessStopStage::get();
        if ($stopStage) {
            $fields->insertBefore($inner = new CompositeField(new LiteralField('Decision', '<h3>Decision Point</h3>'), new LiteralField('ExplainStop', '<label class="right">Choose a stop stage if you would like this stage to act as a decision point</label>'), $stop = new DropdownField('StopStageID', 'Stop Stage', $stopStage->map('ID', 'Title')), $continue = new TextField('ContinueButton', 'Button: Continue (e.g. "Yes")'), new TextField('StopButton', 'Button: Stop (e.g. "No")')), 'ProcessInfo');
            $stop->setEmptyString('No stop after this stage');
            $inner->addExtraClass('message special toggle-decide');
            $continue->addExtraClass('process-noborder');
            $stop->addExtraClass('process-noborder');
        }
        return $fields;
    }
开发者ID:helpfulrobot,项目名称:adrexia-processmap,代码行数:49,代码来源:ProcessStage.php

示例14: getCMSFields

 public function getCMSFields()
 {
     $datefield = DateField::create('Date')->setTitle('Article Date');
     $datefield->setConfig('showcalendar', true);
     $datefield->setConfig('dateformat', 'MM/dd/YYYY');
     $imagefield = UploadField::create('Photo')->setTitle('Featured Photo');
     $imagefield->folderName = 'News';
     $imagefield->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png');
     $imagefield->getValidator()->setAllowedMaxFileSize('2097152');
     // 2 MB in bytes
     $categoriesMap = NewsCategory::get()->filter('NewsHolderID', $this->Parent()->ID)->sort('Title ASC')->map('ID', 'Title')->toArray();
     $fields = parent::getCMSFields();
     $fields->addFieldsToTab('Root.Main', array($datefield, TextField::create('Author')->setTitle('Author Name'), $imagefield, ListboxField::create('NewsCategories')->setTitle('Category')->setMultiple(true)->setSource($categoriesMap)), 'Content');
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:andrewhoule-silverstripe-basicnews,代码行数:15,代码来源:NewsPage.php

示例15: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->ID) {
         $srcTags = function () {
             $tags = array();
             foreach (DMSTag::get() as $t) {
                 $tags[$t->ID] = $t->Category . ($t->isValueDefined() ? ' -> ' . $t->Value : '');
             }
             return $tags;
         };
         $selectTags = ListboxField::create('DocumentTags', _t('DMSDocumentExtension.Tags', 'Tags'), $srcTags(), implode(',', $this->owner->Tags()->column()), null, true)->useAddNew('DMSTag', $srcTags, FieldList::create(TextField::create('Category', _t('DMSDocumentExtension.Category', 'Category *')), TextField::create('Value', _t('DMSDocumentExtension.Value', 'Value')), HiddenField::create('MultiValue', null, 1)));
         $fields->insertAfter($selectTags, 'Description');
         $fields->insertAfter(CheckboxField::create('ShowTagsFrontend', _t('DMSDocumentExtension.ShowTagsFrontend', 'Show document tags in frontend?')), 'DocumentTags');
     }
 }
开发者ID:tubbs,项目名称:silverstripe-dms-simple-tags,代码行数:15,代码来源:DMSDocumentExtension.php


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