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; }
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; }
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; }
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; }
public function Field($properties = array()) { FormExtraJquery::include_jquery(); // Use updated version of Chosen Requirements::block(FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.css'); Requirements::block(FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.jquery.js'); Requirements::css(FORM_EXTRAS_PATH . '/javascript/chosen/chosen.min.css'); Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/chosen/chosen.jquery.js'); if ($this->use_order) { Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/chosen_order/chosen.order.jquery.js'); } // Init $opts = array('no_results_text' => $this->no_results_text, 'allow_single_deselect' => $this->allow_single_deselect ? true : false); if (self::config()->rtl) { $this->addExtraClass('chosen-rtl'); } if ($this->allow_max_selected) { $opts['allow_max_selected'] = $this->allow_max_selected; } if ($this->use_order) { $stringValue = $this->value; if (is_array($stringValue)) { $stringValue = implode(',', $stringValue); } $this->setAttribute('data-chosen-order', $stringValue); } $this->setAttribute('data-chosen', json_encode($opts)); Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/ChosenField.js'); return parent::Field($properties); }
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; }
public function Field($properties = array()) { Requirements::javascript(BOLTTOOLS_DIR . '/javascript/addnewlistboxfield.js'); $this->setTemplate('AddNewListboxField'); $this->addExtraClass('has-chzn'); return parent::Field($properties); }
/** * * @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); } }
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; }
/** * 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); }
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; }
/** * 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'); } }
/** * Builds the form field, sets default attributes, and includes JS * * @param array $attributes The attributes to include on the formfield * @return SSViewer */ public function FieldHolder($attributes = array()) { Requirements::javascript(FRAMEWORK_DIR . "/admin/thirdparty/chosen/chosen/chosen.jquery.js"); Requirements::css(FRAMEWORK_DIR . "/admin/thirdparty/chosen/chosen/chosen.css"); $this->addExtraClass('chosen'); if (!$this->getAttribute('data-search-threshold')) { $this->setSearchThreshold(self::$default_search_threshold); } return parent::FieldHolder($attributes); }
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); }
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; }
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; }
/** * 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; }
public function getSettingsFields() { $fields = parent::getSettingsFields(); $groupsMap = array(); foreach (Group::get() as $group) { // Listboxfield values are escaped, use ASCII char instead of » $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; }
public function updateCMSFields(FieldList $fields) { $services = SiteConfig::config()->available_services; if (!$services) { $services = array_keys(self::listAvailableMediaServices()); } if (in_array('twitter', $services)) { $fields->addFieldToTab('Root.Social', new TextField('TwitterUsername', _t('Socialstream.TwitterUsername', 'Twitter Username'))); } if (in_array('twitter_hashtag', $services)) { $fields->addFieldToTab('Root.Social', new TextField('TwitterHashtag', _t('Socialstream.TwitterHashtag', 'Twitter Hashtag'))); } if (in_array('facebook_page', $services)) { $fields->addFieldToTab('Root.Social', new TextField('FacebookPage', _t('Socialstream.FacebookPage', 'Facebook Page'))); } if (in_array('vimeo', $services)) { $fields->addFieldToTab('Root.Social', new TextField('VimeoUsername', _t('Socialstream.VimeoUsername', 'Vimeo Username'))); } if (in_array('youtube', $services)) { $fields->addFieldToTab('Root.Social', new TextField('YoutubeUsername', _t('Socialstream.YoutubeUsername', 'Youtube Username'))); } if (in_array('dailymotion', $services)) { $fields->addFieldToTab('Root.Social', new TextField('DailymotionUsername', _t('Socialstream.DailymotionUsername', 'Dailymotion Username'))); } if (in_array('rss', $services)) { $fields->addFieldToTab('Root.Social', new TextField('RssFeed', _t('Socialstream.RssFeed', 'Rss Feed'))); } if (in_array('flickr', $services)) { $fields->addFieldToTab('Root.Social', new TextField('FlickrUsername', _t('Socialstream.FlickrUsername', 'Flickr Username'))); } if (in_array('github', $services)) { $fields->addFieldToTab('Root.Social', new TextField('GithubUsername', _t('Socialstream.GithubUsername', 'Github Username'))); } $fields->addFieldToTab('Root.Social', $wl = new ListboxField('LifestreamWhitelist', _t('Socialstream.LifestreamWhitelist', 'Lifestream Whitelist'), array_combine($services, $services))); $wl->setMultiple(true); $wl->setDescription('A list of services to display on the Lifestream. If left blank, all configured streams will be used.'); $fields->addFieldToTab('Root.Social', new NumericField('LifestreamItems', _t('Socialstream.LifestreamItems', 'Lifestream Items'))); return $fields; }
/** * 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; }
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); }
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; }
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'); } }
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; }
/** * Display the appropriate tagging field. */ public function updateCMSFields(FieldList $fields) { $fields->removeByName('FusionTags'); // Determine whether consolidated tags are found in the existing relationships. $types = array(); foreach (singleton('FusionService')->getFusionTagTypes() as $type => $field) { $types[$type] = $type; } $types = array_intersect($this->owner->many_many(), $types); if (empty($types)) { // There are no consolidated tags found, therefore instantiate a tagging field. $fields->addFieldToTab('Root.Tagging', ListboxField::create('FusionTags', 'Tags', FusionTag::get()->map()->toArray())->setMultiple(true)); } // Allow extension. $this->owner->extend('updateTaggingExtensionCMSFields', $fields); }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->insertAfter($gameFormContent = new HTMLEditorField('GameLiveContent', 'Game selection form detail'), 'Content'); $gameFormContent->setRows(20); $regOpen = new CheckboxField('OpenGameReg', ''); $fields->insertBefore($cField = new CompositeField(array($label = new LabelField('OpenGameRegLabel', 'Open game selection (all)'), $regOpen)), 'Content'); $cField->addExtraClass('field'); $regOpen->addExtraClass('mts'); $label->addExtraClass('left'); $groupsMap = array(); foreach (Group::get() as $group) { // Listboxfield values are escaped, use ASCII char instead of » $groupsMap[$group->ID] = $group->getBreadcrumbs(' > '); } asort($groupsMap); $fields->insertBefore(ListboxField::create('OpenGameRegForGroups', "Open game selection for group (limited)")->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('Member.ADDGROUP', 'Add group', 'Placeholder text for a dropdown')), 'Content'); return $fields; }
/** * * @param FieldList $fields */ public function updateCMSFields(FieldList $fields) { $helpText = LiteralField::create("ContentReviewHelp", _t("ContentReview.DEFAULTSETTINGSHELP", "These content review settings will apply to all pages that does not have specific Content Review schedule.")); $fields->addFieldToTab("Root.ContentReview", $helpText); $reviewFrequency = DropdownField::create("ReviewPeriodDays", _t("ContentReview.REVIEWFREQUENCY", "Review frequency"), SiteTreeContentReview::get_schedule())->setDescription(_t("ContentReview.REVIEWFREQUENCYDESCRIPTION", "The review date will be set to this far in the future whenever the page is published")); $fields->addFieldToTab("Root.ContentReview", $reviewFrequency); $users = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN")); $usersMap = $users->map("ID", "Title")->toArray(); asort($usersMap); $userField = ListboxField::create("OwnerUsers", _t("ContentReview.PAGEOWNERUSERS", "Users"), $usersMap)->setMultiple(true)->setAttribute("data-placeholder", _t("ContentReview.ADDUSERS", "Add users"))->setDescription(_t("ContentReview.OWNERUSERSDESCRIPTION", "Page owners that are responsible for reviews")); $fields->addFieldToTab("Root.ContentReview", $userField); $groupsMap = array(); foreach (Group::get() as $group) { // Listboxfield values are escaped, use ASCII char instead of » $groupsMap[$group->ID] = $group->getBreadcrumbs(" > "); } asort($groupsMap); $groupField = ListboxField::create("OwnerGroups", _t("ContentReview.PAGEOWNERGROUPS", "Groups"), $groupsMap)->setMultiple(true)->setAttribute("data-placeholder", _t("ContentReview.ADDGROUP", "Add groups"))->setDescription(_t("ContentReview.OWNERGROUPSDESCRIPTION", "Page owners that are responsible for reviews")); $fields->addFieldToTab("Root.ContentReview", $groupField); }
/** * Get the fields that are sent to the CMS. In * your extensions: updateCMSFields($fields) * * @return FieldList */ function getCMSFields() { Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js"); $groupsMap = Group::get()->map('ID', 'Breadcrumbs')->toArray(); asort($groupsMap); $fields = new FieldList(new TabSet("Root", $tabMain = new Tab('Main', $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")), $taglineField = new TextField("Tagline", _t('SiteConfig.SITETAGLINE', "Site Tagline/Slogan")), $themeDropdownField = new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemes())), $tabAccess = new Tab('Access', $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?")), $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap), $editorsOptionsField = new OptionsetField("CanEditType", _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?")), $editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))->setMultiple(true)->setSource($groupsMap), $topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType", _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?")), $topLevelCreatorsGroupsField = ListboxField::create("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators"))->setMultiple(true)->setSource($groupsMap)))); $themeDropdownField->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)')); $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); $editorsOptionsSource = array(); $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS"); $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)"); $editorsOptionsField->setSource($editorsOptionsSource); $topLevelCreatorsOptionsField->setSource($editorsOptionsSource); // Translatable doesn't handle updateCMSFields on DataObjects, // so add it here to save the current Locale, // because onBeforeWrite does not work. if (class_exists('Translatable') && Object::has_extension('SiteConfig', "Translatable")) { $fields->push(new HiddenField("Locale")); } if (!Permission::check('EDIT_SITECONFIG')) { $fields->makeFieldReadonly($viewersOptionsField); $fields->makeFieldReadonly($viewerGroupsField); $fields->makeFieldReadonly($editorsOptionsField); $fields->makeFieldReadonly($editorGroupsField); $fields->makeFieldReadonly($topLevelCreatorsOptionsField); $fields->makeFieldReadonly($topLevelCreatorsGroupsField); $fields->makeFieldReadonly($taglineField); $fields->makeFieldReadonly($titleField); } if (file_exists(BASE_PATH . '/install.php')) { $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader", "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING", "Warning: You should remove install.php from this SilverStripe install for security reasons.") . "</p>"), "Title"); } $tabMain->setTitle(_t('SiteConfig.TABMAIN', "Main")); $tabAccess->setTitle(_t('SiteConfig.TABACCESS', "Access")); $this->extend('updateCMSFields', $fields); return $fields; }
function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', new TextField('Description', 'Story Summary'), 'Content'); $fields->addFieldToTab('Root.Main', new UploadField('CoverImage', 'Cover Image'), 'Content'); $fields->addFieldToTab('Root.Main', new DropdownField('Rating', 'Story Rating', $this->dbObject('Rating')->enumValues()), 'Content'); $fields->addFieldToTab('Root.Main', new DropdownField('StoryStatus', 'Story Status', $this->dbObject('StoryStatus')->enumValues()), 'Content'); $fields->addFieldToTab('Root.Main', new DropdownField('Type', 'Story Type', $this->dbObject('Type')->enumValues()), 'Content'); $fields->addFieldToTab('Root.Main', $dateField = new DateField('Added', 'Added on (for example: 12/20/2010)'), 'Content'); $dateField->setConfig('showcalendar', true); $dateField->setConfig('dateformat', 'MM/dd/YYYY'); $characters = DataObject::get('Character'); if (!empty($characters)) { // create an array('ID'=>'Name') $characterMap = $characters->map("ID", "Name", "Please Select"); // create a Multi-select group based on the array $fields->addFieldToTab('Root.Details', ListboxField::Create('Characters', 'Select a Character')->setMultiple(true)->setSource($characterMap)); } $series = DataObject::get('Series'); if (!empty($series)) { // create an array('ID'=>'Name') $seriesMap = $series->map("ID", "Name", "Please Select"); // create a Multi-select group based on the array $fields->addFieldToTab('Root.Details', ListboxField::Create('Series', 'Select a Series')->setMultiple(true)->setSource($seriesMap)); } $genres = DataObject::get('Genre'); if (!empty($genres)) { // create an array('ID'=>'Name') $genreMap = $genres->map("ID", "Name", "Please Select"); // create a Multi-select group based on the array $fields->addFieldToTab('Root.Details', ListboxField::Create('Genres', 'Select a Genre')->setMultiple(true)->setSource($genreMap)); } $authors = DataObject::get('Author'); if (!empty($authors)) { // create an array('ID'=>'Name') $authorMap = $authors->map("ID", "Name", "Please Select"); // create a Multi-select group based on the array $fields->addFieldToTab('Root.Details', ListboxField::create('Authors', 'Select an Author')->setMultiple(true)->setSource($authorMap)); } return $fields; }
function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', new TextField('Description', 'Article Summary'), 'Content'); $fields->addFieldToTab('Root.Main', new UploadField('CoverImage', 'Cover Image'), 'Content'); $categories = DataObject::get('ArticleCategory'); if (!empty($categories)) { // create an array('ID'=>'Name') $categoriesMap = $categories->map("ID", "Name", "Please Select"); // create a Multi-select group based on the array $fields->addFieldToTab('Root.Details', ListboxField::Create('ArticleCategories', 'Select a Category')->setMultiple(true)->setSource($categoriesMap)); } $authors = DataObject::get('Author'); if (!empty($authors)) { // create an array('ID'=>'Name') $authorsMap = $authors->map("ID", "Name", "Please Select"); // create a Multi-select group based on the array $fields->addFieldToTab('Root.Details', ListboxField::Create('Authors', 'Select an Author')->setMultiple(true)->setSource($authorsMap)); } return $fields; }