public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Remove MCListSegment GridField Tab And Manually Manage
     $fields->removeByName("MCListSegments");
     // Manually Manage Creation of MCListSegments Based on Selected MCLists
     if (empty($this->owner->ID)) {
         $lists = new DataList("MCList");
         if ($lists->count() > 1) {
             $fields->addFieldToTab('Root.Main', new LiteralField('_AffectedMCListsTitle', '<h2>Affected MailChimp Lists</h2>'));
             $map = $lists->map("ID", "Name");
             $listIDs = new CheckboxSetField('_AffectedMCListIDs', 'Which MailChimp List(s) Does This Event Relate To', $map);
             $listIDs->setDefaultItems(array_keys($map->toArray()));
         } else {
             if ($lists->count() == 1) {
                 $listIDs = new HiddenField('_AffectedMCListIDs', 'Which MailChimp List(s) Does This Event Relate To', $lists->first()->ID);
             } else {
                 $listIDs = new HiddenField('_AffectedMCListIDs', 'Which MailChimp List(s) Does This Event Relate To', 0);
             }
         }
         $fields->addFieldToTab('Root.Main', $listIDs);
     }
     // Configure Attendees Gridfield
     $gf = $fields->fieldByName('Root.Attendees.Attendees');
     if (is_object($gf) && $gf->exists()) {
         $gf->setList($this->getMyManyManyComponents('Attendees'));
         $config = $gf->getConfig();
         $config->removeComponentsByType('GridfieldAddNewButton');
     }
     return $fields;
 }
Exemplo n.º 2
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldFromTab('Root', 'Pages');
     $fields->removeFieldsFromTab('Root.Main', array('SortOrder', 'showBlockbyClass', 'shownInClass', 'MemberVisibility'));
     $fields->addFieldToTab('Root.Main', LiteralField::create('Status', 'Published: ' . $this->Published()), 'Title');
     $memberGroups = Group::get();
     $sourcemap = $memberGroups->map('Code', 'Title');
     $source = array('anonymous' => 'Anonymous visitors');
     foreach ($sourcemap as $mapping => $key) {
         $source[$mapping] = $key;
     }
     $memberVisibility = new CheckboxSetField($name = "MemberVisibility", $title = "Show block for specific groups", $source);
     $memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
     $availabelClasses = $this->availableClasses();
     $inClass = new CheckboxSetField($name = "shownInClass", $title = "Show block for specific content types", $availabelClasses);
     $filterSelector = OptionsetField::create('showBlockbyClass', 'Choose filter set', array('0' => 'by page', '1' => 'by page/data type'))->setDescription('<p><br /><strong>by page</strong>: block will be displayed in the selected page(s)<br /><strong>by page/data type</strong>: block will be displayed on the pages created with the particular page/data type. e.g. is <strong>"InternalPage"</strong> is picked, the block will be displayed, and will ONLY be displayed on all <strong>Internal Pages</strong></p>');
     $availablePages = Page::get()->exclude('ClassName', array('ErrorPage', 'RedirectorPage', 'VirtualPage'));
     $pageSelector = new CheckboxSetField($name = "Pages", $title = "Show on Page(s)", $availablePages->map('ID', 'Title'));
     if ($this->canConfigPageAndType(Member::currentUser())) {
         $fields->addFieldsToTab('Root.VisibilitySettings', array($filterSelector, $pageSelector, $inClass));
     }
     if ($this->canConfigMemberVisibility(Member::currentUser())) {
         $fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility);
     }
     if (!$fields->fieldByName('Options')) {
         $fields->insertBefore($right = RightSidebar::create('Options'), 'Root');
     }
     $fields->addFieldsToTab('Options', array(CheckboxField::create('addMarginTop', 'add "margin-top" class to block wrapper'), CheckboxField::create('addMarginBottom', 'add "margin-bottom" class to block wrapper')));
     return $fields;
 }
 public function updateCMSFlexiTabs(TabSet $fields, TabSet $settings_tab, $flexi)
 {
     parent::updateCMSFlexiTabs($fields, $settings_tab, $flexi);
     $mailchimp_tab = new Tab('MailChimp', 'MailChimp');
     $fields->insertBefore($mailchimp_tab, 'Settings');
     $client = new FlexiFormMailChimpClient($flexi->FlexiFormSetting('MailChimpApiKey')->getValue());
     foreach ($this->stat('handler_settings') as $component => $class) {
         $field_name = $this->getSettingFieldName($component);
         $field = $this->augmentMailChimpField($settings_tab->fieldByName($field_name), $component, $client);
         // Move Settings to designated MailChimp Tab
         $settings_tab->removeByName($field_name);
         $mailchimp_tab->push($field);
     }
     // integrate list groups
     if ($list_id = $flexi->FlexiFormSetting('MailChimpListID')->getValue()) {
         $field = new CheckboxSetField('FlexiFormMailChimpGroups', 'List Groups');
         if ($list_groups = $this->getInterestGroups($list_id, $client)) {
             $field->setSource($list_groups->map('id', 'name'));
             $field->setValue($flexi->FlexiFormFields()->filter('ClassName', 'FlexiMailChimpInterestGroupField')->column('InterestGroupID'));
             $field->description = 'Checked groups are added to your form Fields. Groups are refreshed every 10 minutes.';
         } else {
             $field = $field->performReadonlyTransformation();
             $field->setValue('This list has no Interest Groups');
         }
         $mailchimp_tab->push($field);
     }
     $mailchimp_tab->push(new LiteralField('MailChimpRefresh', '<br /><hr />NOTE: list and group selections are cached from mailchimp for up to 10 minutes. changing the API Key or list will cause a refresh.'));
 }
 public function testSavingIntoTextField()
 {
     $field = new CheckboxSetField('Content', 'Content', array('Test' => 'Test', 'Another' => 'Another', 'Something' => 'Something'));
     $article = new CheckboxSetFieldTest_Article();
     $field->setValue(array('Test' => 'Test', 'Another' => 'Another'));
     $field->saveInto($article);
     $article->write();
     $dbValue = DB::query(sprintf('SELECT "Content" FROM "CheckboxSetFieldTest_Article" WHERE "ID" = %s', $article->ID))->value();
     $this->assertEquals('Test,Another', $dbValue);
 }
Exemplo n.º 5
0
 public function testLoadDataFromObject()
 {
     $article = $this->objFromFixture('CheckboxSetFieldTest_Article', 'articlewithouttags');
     $articleWithTags = $this->objFromFixture('CheckboxSetFieldTest_Article', 'articlewithtags');
     $tag1 = $this->objFromFixture('CheckboxSetFieldTest_Tag', 'tag1');
     $tag2 = $this->objFromFixture('CheckboxSetFieldTest_Tag', 'tag2');
     $field = new CheckboxSetField("Tags", "Test field", DataObject::get("CheckboxSetFieldTest_Tag")->map());
     $form = new Form(new Controller(), 'Form', new FieldList($field), new FieldList());
     $form->loadDataFrom($articleWithTags);
     $this->assertEquals(array($tag1->ID => $tag1->ID, $tag2->ID => $tag2->ID), $field->Value(), 'CheckboxSetField loads data from a manymany relationship in an object through Form->loadDataFrom()');
 }
 /**
  * Method that turns this object into a field type, to be loaded into a form
  *
  * @return FormField
  */
 public function Field()
 {
     if ($this->Title && $this->DisplayAs) {
         $name = "customise_{$this->ID}_" . Convert::raw2url($this->Title);
         $title = $this->Required ? $this->Title . ' *' : $this->Title;
         $options = $this->Options()->map('Title', 'ItemSummary');
         $defaults = $this->DefaultOptions();
         $default = $defaults->exists() ? $defaults->first()->Title : null;
         switch ($this->DisplayAs) {
             case 'Dropdown':
                 $field = DropdownField::create($name, $title, $options, $default)->setEmptyString(_t('Commerce.PleaseSelect', 'Please Select'))->setAttribute("class", "dropdown btn");
                 break;
             case 'Radio':
                 $field = OptionSetField::create($name, $title, $options, $default);
                 break;
             case 'Checkboxes':
                 $field = CheckboxSetField::create($name, $title, $options, $defaults->column('ID'));
                 break;
             case 'TextEntry':
                 $field = TextField::create($name, $title);
                 if ($this->MaxLength) {
                     $field->setMaxLength($this->MaxLength);
                 }
                 break;
         }
         $this->extend('updateField', $field);
         return $field;
     } else {
         return false;
     }
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('UniqueHash');
     // create a list of all child pages
     if ($this->ProtectedMiniSiteID) {
         $pagesArray = array();
         $this->getPagesArray($this->ProtectedMiniSiteID, $pagesArray, 0);
         $fields->addFieldToTab('Root.Main', $pagesField = new CheckboxSetField('AccessPageIDs', 'Allowed Pages', $pagesArray));
         $pagesField->addExtraClass('vertical');
     } else {
         $fields->removeByName('AccessPageIDs');
         $fields->addFieldToTab('Root.Main', new LiteralField('note', '<div class="field"><label class="left">Access Pages</label><div class="middleColumn">You must save once before you can select allowed pages</div></div>'));
     }
     return $fields;
 }
 public function getAttributesHTML($attrs = null)
 {
     $options = $this->getOptions();
     //make sure other value is set in attrs
     $attrs = parent::getAttributesHTML($attrs);
     return $attrs;
 }
Exemplo n.º 9
0
 public function updateCMSFields(FieldList $fields)
 {
     $fields->insertBefore($shoptab = new Tab('Shop', 'Shop'), 'Access');
     $fields->addFieldsToTab("Root.Shop", new TabSet("ShopTabs", $maintab = new Tab("Main", TreeDropdownField::create('TermsPageID', _t("ShopConfig.TERMSPAGE", 'Terms and Conditions Page'), 'SiteTree'), TreeDropdownField::create("CustomerGroupID", _t("ShopConfig.CUSTOMERGROUP", "Group to add new customers to"), "Group"), UploadField::create('DefaultProductImage', _t('ShopConfig.DEFAULTIMAGE', 'Default Product Image'))), $countriestab = new Tab("Countries", CheckboxSetField::create('AllowedCountries', 'Allowed Ordering and Shipping Countries', self::config()->iso_3166_country_codes))));
     $fields->removeByName("CreateTopLevelGroups");
     $countriestab->setTitle("Allowed Countries");
 }
 /**
  * Sets the template to be rendered with
  */
 function FieldHolder()
 {
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(NEWSLETTER_DIR . '/thirdparty/jquery-tablednd/jquery.tablednd_0_5.js');
     Requirements::javascript(NEWSLETTER_DIR . '/javascript/CheckboxSetWithExtraField.js');
     return parent::FieldHolder();
 }
 function TypoForm()
 {
     $array = array('green', 'yellow', 'blue', 'pink', 'orange');
     $form = new Form($this, 'TestForm', $fields = FieldList::create(HeaderField::create('HeaderField1', 'HeaderField Level 1', 1), LiteralField::create('LiteralField', '<p>All fields up to EmailField are required and should be marked as such</p>'), TextField::create('TextField1', 'Text Field Example 1'), TextField::create('TextField2', 'Text Field Example 2'), TextField::create('TextField3', 'Text Field Example 3'), TextField::create('TextField4', ''), HeaderField::create('HeaderField2b', 'Field with right title', 2), $textAreaField = new TextareaField('TextareaField', 'Textarea Field'), EmailField::create('EmailField', 'Email address'), HeaderField::create('HeaderField2c', 'HeaderField Level 2', 2), DropdownField::create('DropdownField', 'Dropdown Field', array(0 => '-- please select --', 1 => 'test AAAA', 2 => 'test BBBB')), OptionsetField::create('OptionSF', 'Optionset Field', $array), CheckboxSetField::create('CheckboxSF', 'Checkbox Set Field', $array), CountryDropdownField::create('CountryDropdownField', 'Countries'), CurrencyField::create('CurrencyField', 'Bling bling', '$123.45'), HeaderField::create('HeaderField3', 'Other Fields', 3), NumericField::create('NumericField', 'Numeric Field '), DateField::create('DateField', 'Date Field'), DateField::create('DateTimeField', 'Date and Time Field'), CheckboxField::create('CheckboxField', 'Checkbox Field')), $actions = FieldList::create(FormAction::create('submit', 'Submit Button')), $requiredFields = RequiredFields::create('TextField1', 'TextField2', 'TextField3', 'ErrorField1', 'ErrorField2', 'EmailField', 'TextField3', 'RightTitleField', 'CheckboxField', 'CheckboxSetField'));
     $textAreaField->setColumns(45);
     $form->setMessage('warning message', 'warning');
     return $form;
 }
 /**
  * jQuery validate requires that the value of the option does not contain
  * the actual value of the input.
  *
  * @return ArrayList
  */
 public function getOptions()
 {
     $options = parent::getOptions();
     foreach ($options as $option) {
         $option->Name = "{$this->name}[]";
     }
     return $options;
 }
 public function __construct($modelClass, $newsAdmin = null, $fields = null, $filters = null)
 {
     $fields = new FieldList(TextField::create('Title'), TextField::create('URLSegment'), DropdownField::create('ParentID', 'Parent page')->setSource(NewsIndex::get()->map('ID', 'Title')->toArray())->setEmptyString('Select'), HeaderField::create('DatesHeader', 'Dates')->setHeadingLevel(3), DateField::create('StartDate')->setTitle(null)->setAttribute('placeholder', 'Start Date'), DateField::create('EndDate')->setTitle(null)->setAttribute('placeholder', 'End Date'), CheckboxSetField::create('Types')->setSource(NewsSearchContext::GetNewsTypes($newsAdmin))->setValue(isset($_REQUEST['q']) && isset($_REQUEST['q']['Types']) ? $_REQUEST['q']['Types'] : null), TextField::create('Tags'), TextField::create('Summary'), TextField::create('Content'), TextField::create('Author'), CheckboxSetField::create('Categories')->setSource(NewsCategory::get()->map('ID', 'Title')->toArray())->setValue(isset($_REQUEST['q']) && isset($_REQUEST['q']['Categories']) ? $_REQUEST['q']['Categories'] : null));
     $filters = array('Title' => new PartialMatchFilter('Title'), 'URLSegment' => new PartialMatchFilter('URLSegment'), 'ParentID' => new ExactMatchFilter('ParentID'), 'Tags' => new PartialMatchFilter('Tags'), 'Summary' => new PartialMatchFilter('Summary'), 'Content' => new PartialMatchFilter('Content'), 'Author' => new PartialMatchFilter('Author'), 'StartDate' => new GreaterThanOrEqualFilter('DateTime'), 'EndDate' => new LessThanOrEqualFilter('DateTime'));
     if ($newsAdmin) {
         $this->newsAdmin = $newsAdmin;
     }
     parent::__construct($modelClass, $fields, $filters);
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $cmsUsers = Member::mapInCMSGroups();
     $fields->addFieldsToTab('Root.Main', array(new HeaderField('AssignUsers', $this->fieldLabel('AssignUsers')), new CheckboxField('AssignInitiator', $this->fieldLabel('AssignInitiator')), $users = CheckboxSetField::create('Users', $this->fieldLabel('Users'), $cmsUsers), new TreeMultiselectField('Groups', $this->fieldLabel('Groups'), 'Group')));
     // limit to the users which actually can access the CMS
     $users->setSource(Member::mapInCMSGroups());
     return $fields;
 }
Exemplo n.º 15
0
 /**
  * Caution: Only call on instances, not through a singleton.
  *
  * @return FieldSet
  */
 public function getCMSFields()
 {
     $fields = new FieldSet(new TabSet("Root", new Tab(_t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $memberList = new MemberTableField($this, "Members", $this, null, false)), $permissionsTab = new Tab(_t('SecurityAdmin.PERMISSIONS', 'Permissions'), new PermissionCheckboxSetField('Permissions', false, 'Permission', 'GroupID', $this)), new Tab(_t('Security.IPADDRESSES', 'IP Addresses'), new LiteralField("", _t('SecurityAdmin.IPADDRESSESHELP', "<p>You can restrict this group to a particular \n\t\t\t\t\t\tIP address range (one range per line). <br />Ranges can be in any of the following forms: <br />\n\t\t\t\t\t\t203.96.152.12<br />\n\t\t\t\t\t\t203.96.152/24<br />\n\t\t\t\t\t\t203.96/16<br />\n\t\t\t\t\t\t203/8<br /><br />If you enter one or more IP address ranges in this box, then members will only get\n\t\t\t\t\t\tthe rights of being in this group if they log on from one of the valid IP addresses.  It won't prevent\n\t\t\t\t\t\tpeople from logging in.  This is because the same user might have to log in to access parts of the\n\t\t\t\t\t\tsystem without IP address restrictions.")), new TextareaField("IPRestrictions", "IP Ranges", 10))));
     // Only add a dropdown for HTML editor configurations if more than one is available.
     // Otherwise Member->getHtmlEditorConfigForCMS() will default to the 'cms' configuration.
     $editorConfigMap = HtmlEditorConfig::get_available_configs_map();
     if (count($editorConfigMap) > 1) {
         $fields->addFieldToTab('Root.Permissions', new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', $editorConfigMap), 'Permissions');
     }
     if (!Permission::check('EDIT_PERMISSIONS')) {
         $fields->removeFieldFromTab('Root', 'Permissions');
         $fields->removeFieldFromTab('Root', 'IP Addresses');
     }
     // Only show the "Roles" tab if permissions are granted to edit them,
     // and at least one role exists
     if (Permission::check('APPLY_ROLES') && DataObject::get('PermissionRole')) {
         $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.ROLES', 'Roles'));
         $fields->addFieldToTab('Root.Roles', new LiteralField("", "<p>" . _t('SecurityAdmin.ROLESDESCRIPTION', "This section allows you to add roles to this group. Roles are logical groupings of permissions, which can be editied in the Roles tab") . "</p>"));
         // Add roles (and disable all checkboxes for inherited roles)
         $allRoles = Permission::check('ADMIN') ? DataObject::get('PermissionRole') : DataObject::get('PermissionRole', 'OnlyAdminCanApply = 0');
         $groupRoles = $this->Roles();
         $inheritedRoles = new DataObjectSet();
         $ancestors = $this->getAncestors();
         foreach ($ancestors as $ancestor) {
             $ancestorRoles = $ancestor->Roles();
             if ($ancestorRoles) {
                 $inheritedRoles->merge($ancestorRoles);
             }
         }
         $fields->findOrMakeTab('Root.Roles', 'Root.' . _t('SecurityAdmin.ROLES', 'Roles'));
         $fields->addFieldToTab('Root.Roles', $rolesField = new CheckboxSetField('Roles', 'Roles', $allRoles));
         $rolesField->setDefaultItems($inheritedRoles->column('ID'));
         $rolesField->setDisabledItems($inheritedRoles->column('ID'));
     }
     $memberList->setController($this);
     $memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));
     $memberList->setParentClass('Group');
     $memberList->setPopupCaption(_t('SecurityAdmin.VIEWUSER', 'View User'));
     $memberList->setRelationAutoSetting(false);
     $fields->push($idField = new HiddenField("ID"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Exemplo n.º 16
0
 public function __construct($controller, $name, $fields = null, $actions = null)
 {
     $fields = new FieldList(ReadonlyField::create('Title')->setTitle(_t('Box.TITLE', 'Box.TITLE')), TextareaField::create('Description')->setTitle(_t('Box.DESCRIPTION', 'Box.DESCRIPTION')), CheckboxField::create("Public")->setTitle(_t('Box.PUBLIC', 'Box.PUBLIC')), $Members = CheckboxSetField::create('Members')->setTitle(_t('Box.MEMBERS', 'Box.MEMBERS'))->setSource(Member::get()->map('ID', 'Name')), HiddenField::create('BoxID'));
     $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doEdit')->setTitle(_t('BoxEditForm.DOEDIT', 'BoxEditForm.DOEDIT')));
     parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Description"));
     if (isset($GLOBALS['BoxID'])) {
         $Box = Box::get()->byID($GLOBALS['BoxID']);
         $this->loadDataFrom($Box);
     }
 }
 /**
  *
  * @return Array
  */
 function getSource()
 {
     $source = parent::getSource();
     //debug::log("original source count ".implode($this->classNamesForItems)." ".$this->siteTreeParentID.": ".count($source));
     if ($this->siteTreeParentID) {
         $arrayItems = array();
         $source = $this->getAllChildrenForSiteTreeParent($this->siteTreeParentID);
     }
     return $source;
 }
 /**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     if (Config::inst()->get('FacetedCategory', 'show_disabled_facets_tab')) {
         $spec = FacetHelper::inst()->expandFacetSpec($this->getFacetSpec());
         $facets = array();
         foreach ($spec as $f => $v) {
             $facets[$f] = $v['Label'];
         }
         $fields->addFieldToTab('Root.Facets', CheckboxSetField::create('DisabledFacets', "Don't show the following facets for this category:", $facets));
     }
 }
Exemplo n.º 19
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Attachments', $photo = UploadField::create('Photo'));
     $fields->addFieldToTab('Root.Attachments', $brochure = UploadField::create('Brochure', 'Travel brochure, optional (PDF only)'));
     $photo->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg'));
     $photo->setFolderName('travel-photos');
     $brochure->getValidator()->setAllowedExtensions(array('pdf'));
     $brochure->setFolderName('travel-brochures');
     $fields->addFieldToTab('Root.Categories', CheckboxSetField::create('Categories', 'Selected categories', $this->Parent()->Categories()->map('ID', 'Title')));
     $fields->addFieldToTab('Root.Main', DropdownField::create('RegionID', 'Region', Region::get()->map('ID', 'Title'))->setEmptyString('-- None --'), 'Content');
     return $fields;
 }
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Orders');
     $fields->replaceField('Statuses', CheckboxSetField::create('Statuses', 'Statuses', Order::get_order_status_options()));
     $fields->replaceField('Active', DropdownField::create('Active', 'Active', array(0 => 'No', 1 => 'Yes')));
     $instructions = '';
     foreach ($this->getSubstitutions() as $k => $v) {
         $instructions .= '<li><strong>{{{' . $k . '}}}</strong>: ' . $v . '</li>';
     }
     $fields->addFieldToTab('Root.Main', LiteralField::create('contentinstructions', "<p>The following will be replaced anywhere they appear in the content of the email:</p>" . "<ul>{$instructions}</ul>"), 'HtmlContent');
     return $fields;
 }
Exemplo n.º 21
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // TODO: Change the autogenerated stub
     $fields->addFieldsToTab('Root.Main', DateField::create('Date', 'article date'), 'Content');
     $fields->addFieldsToTab('Root.Main', TextareaField::create('Teaser', 'Teaser text'), 'Content');
     $fields->addFieldsToTab('Root.Main', TextField::create('Author', 'Who made this post possible'), 'Content');
     $fields->addFieldToTab('Root.Attachments', $photo = UploadField::create('Photo'));
     $fields->addFieldToTab('Root.Attachments', $brochure = UploadField::create('Brochure', 'Travel brochure, optional (PDF only)'));
     $photo->setFolderName('travel-photos');
     $brochure->setFolderName('travel-brochures')->getValidator()->setAllowedExtensions(array('pdf'));
     $fields->addFieldsToTab('Root.Categories', CheckboxSetField::create('Categories', 'Categories this article belongs to', $this->Parent()->Categories()->map('ID', 'Title')));
     return $fields;
 }
Exemplo n.º 22
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldsToTab('Root.Main', DateField::create('Date', 'Date of article')->setConfig('showcalendar', true), 'Content');
     $fields->addFieldsToTab('Root.Main', TextareaField::create('Teaser'), 'Content');
     $fields->addFieldsToTab('Root.Main', TextField::create('Author', 'Author of article'), 'Content');
     $fields->addFieldsToTab('Root.Attachments', $photo = UploadField::create('Photo'));
     $fields->addFieldsToTab('Root.Attachments', $brochure = UploadField::create('Brochure', 'Travel brochure, optional (PDF only)'));
     $photo->setFolderName('travel-photos');
     $brochure->setFolderName('travel-brochures')->getValidator()->setAllowedExtensions(array('pdf'));
     $fields->addFieldsToTab('Root.Categories', CheckboxSetField::create('Categories', 'Selected categories', $this->Parent()->Categories()->map('ID', 'Title')));
     $fields->addFieldsToTab('Root.Main', DropdownField::create('RegionID', 'Region', Region::get()->map('ID', 'Title'))->setEmptyString('-- None --'), 'Content');
     return $fields;
 }
Exemplo n.º 23
0
 function getSearchFields()
 {
     if ($this->fields && $this->fields->count()) {
         return $this->fields;
     }
     $fields = new FieldList(TextField::create('Name'), TextField::create('Email'), TextField::create('Company'), CheckboxSetField::create('Status')->setSource(CustomerStatus::get()->map()->toArray()), CheckboxSetField::create('Tags')->setSource(CustomerTag::get()->map()->toArray()));
     $locales = PostmarkHelper::MemberLocales();
     if ($locales && count($locales)) {
         $locale = DropdownField::create('Locale')->setSource($locales)->setEmptyString('Select language');
         $fields->insertBefore($locale, 'Name');
     }
     $this->extend('updateCustomerSearchFields', $fields);
     $this->fields = $fields;
     return $this->fields;
 }
 /**
  * Load a value into this CheckboxSetField
  */
 public function setValue($value, $obj = null)
 {
     // If we're not passed a value directly, we can look for it in a relation method on the object passed as a
     // second arg
     if (!$value && $obj && $obj instanceof DataObject && $obj->hasMethod($this->name)) {
         $funcName = $this->name;
         $join = $obj->{$funcName}();
         if ($join) {
             $join = $join->sort($this->getSortField());
             $value = $join->getIDList();
         } else {
             $value = array();
         }
     }
     parent::setValue($value, $obj);
     return $this;
 }
Exemplo n.º 25
0
 public function __construct($controller, $name, $poll)
 {
     if (!$poll) {
         user_error("The poll doesn't exist.", E_USER_ERROR);
     }
     $this->poll = $poll;
     $data = $poll->Answers()->map('ID', 'Title');
     if ($poll->Multiple) {
         $choiceField = CheckboxSetField::create('PollChoices', $poll->Question, $data);
     } else {
         $choiceField = OptionsetField::create('PollChoices', '', $data);
     }
     $fields = FieldList::create($choiceField);
     $actions = FieldList::create(FormAction::create('submitPoll', 'Verstuur'));
     $validator = RequiredFields::create(array('PollChoices'));
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
Exemplo n.º 26
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Members');
     $fields->removeByName('AccountID');
     $fields->dataFieldByName('establish_time')->setConfig('showcalendar', true);
     $fields->dataFieldByName('register_time')->setConfig('showcalendar', true);
     $fields->replaceField('company_name', new ReadonlyField('company_name', '企业名称'));
     $fields->replaceField('company_class', CheckboxSetField::create('company_class', '企业类别', array('高新技术企业 - 国家' => '高新技术企业 - 国家', '高新技术企业 - 市' => '高新技术企业 - 市', '省级创新型示范企业' => '省级创新型示范企业', '省级创新型试点企业' => '省级创新型试点企业', '省级科技型中小企业' => '省级科技型中小企业', '省级专利示范企业' => '省级专利示范企业', '省级农业科技型企业' => '省级农业科技型企业', '市级专利示范企业' => '市级专利示范企业', '市级创新型企业' => '市级创新型企业', '县级科技型企业' => '县级科技型企业', '其他' => '其他')));
     $fields->replaceField('research_class', CheckboxSetField::create('research_class', '研发中心类别', array('省级企业研究院' => '省级企业研究院', '省级高新技术企业研发中心' => '省级高新技术企业研发中心', '省级农业企业科技研发中心' => '省级农业企业科技研发中心', '省级区域科技创新服务中心' => '省级区域科技创新服务中心', '省级大院名校共建创新载体' => '省级大院名校共建创新载体', '市级工程技术研究开发中心' => '市级工程技术研究开发中心', '企业所属研发机构' => '企业所属研发机构', '其他' => '其他')));
     $fields->replaceField('research_construction', CheckboxSetField::create('research_construction', '研发中心建设', array('国家级' => '国家级', '省级' => '省级', '市级' => '市级', '县级' => '县级')));
     $fields->replaceField('tech_upgrade', CheckboxSetField::create('tech_upgrade', '科技型企业升级', array('国家级' => '国家级', '省级' => '省级', '市级' => '市级', '县级' => '县级')));
     $fields->addFieldToTab('Root.Main', LiteralField::create('企业规模和占地情况', '<h3>企业规模和占地情况</h3>'), 'floor_space');
     $fields->addFieldToTab('Root.Main', LiteralField::create('科研活动情况', '<h3>科研活动情况</h3>'), 'tech_member');
     $fields->addFieldToTab('Root.Main', LiteralField::create('科技创新项目意向', '<h3>科技创新项目意向</h3>'), 'patent_invent');
     return $fields;
 }
 function __construct($name, $title = null, $source = null, $value = "", $form = null, $emptyString = null)
 {
     if (!$source) {
         $source = array();
     }
     if (is_string($source)) {
         // it should be the name of a list, lets get all its contents
         $dynamicList = DataObject::get_one('DynamicList', '"Title" = \'' . Convert::raw2sql($source) . '\'');
         $source = array();
         if ($dynamicList) {
             $items = $dynamicList->Items();
             foreach ($items as $item) {
                 $source[$item->Title] = $item->Title;
             }
         }
     }
     parent::__construct($name, $title, $source, $value, $form, $emptyString);
 }
Exemplo n.º 28
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', DateField::create('Date', 'Date of article')->setConfig('showcalendar', true)->setConfig('dateformat', 'd MMMM yyyy'), 'Content');
     $fields->addFieldToTab('Root.Main', TextareaField::create('Teaser'), 'Content');
     $fields->addFieldToTab('Root.Main', TextField::create('Author', 'Author of article')->setDescription('If multiple authors, separated with commas')->setMaxLength(50), 'Content');
     $fields->addFieldToTab('Root.Attachment', $photo = UploadField::create('Photo'));
     $fields->addFieldToTab('Root.Attachment', $brochure = UploadField::create('Brochure', 'Travel  brochure, optional (PDF only)'));
     $photo->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg'));
     $photo->setFolderName('travel-photos');
     $brochure->getValidator()->setAllowedExtensions(array('pdf'));
     $brochure->setFolderName('travel-brochures');
     //1st param on the checksetfield is Categories the name of the many many relationship
     //2nd param is the label of the checkbox
     //3rd param is the source of the checkbox
     //map tell the checkbox to save the ID to the relationship but present the title field as the label of the checkbox
     //99% of the time the ID is the first argument
     $fields->addFieldToTab('Root.Categories', CheckboxSetField::create('Categories', 'Select categories', $this->Parent()->Categories()->map('ID', 'Title')));
     return $fields;
 }
Exemplo n.º 29
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if (!Config::inst()->get('NewsPost', 'pages_admin')) {
         $arrTypes = NewsPost::GetNewsTypes();
         if (count($arrTypes) > 1) {
             $arrDropDownSource = array();
             foreach ($arrTypes as $strType) {
                 $arrDropDownSource[$strType] = $strType;
             }
             $fields->addFieldToTab('Root.Main', DropdownField::create('ClassName')->setSource($arrDropDownSource)->setTitle('Type'), 'Content');
         }
     }
     $fields->addFieldsToTab('Root.Main', array(DropdownField::create('ParentID')->setSource(NewsIndex::get()->map()->toArray())->setTitle('Parent Page'), DatetimeField::create('DateTime'), TextField::create('Tags'), TextField::create('Author'), HtmlEditorField::create('Summary')->setRows(5)), 'Content');
     if ($this->ID) {
         $fields->addFieldToTab('Root.Main', CheckboxSetField::create('Categories')->setSource(NewsCategory::get()->map('ID', 'Title')->toArray()), 'Content');
         $fields->addFieldToTab('Root.RelatedArticles', GridField::create('RelatedArticles', 'Related Articles')->setList($this->RelatedArticles())->setConfig($relatedArticlesConfig = new GridFieldConfig_RelationEditor()));
     }
     $this->extend('updateNewsPostCMSFields', $fields);
     return $fields;
 }
 public function SS_ConstantContactForm()
 {
     Requirements::css(CONSTANT_CONTACT_BASE . '/css/cc_ccs.css');
     Requirements::javascript(CONSTANT_CONTACT_BASE . '/js/cc_js.js');
     $config = $this->owner;
     $listIDs = $config->CcListID->getValues();
     if (is_array($listIDs)) {
         if (count($listIDs) == 1) {
             $listfield = HiddenField::create('list')->setValue(reset($listIDs));
         } else {
             $lists = $this->owner->CcListCache;
             if (!$lists) {
                 $lists = singleton('SS_ConstantContactController')->getLists(true, $listIDs);
                 if ($lists) {
                     $this->owner->CcListCache = serialize($lists);
                     $this->owner->write();
                 }
             } else {
                 $lists = unserialize($lists);
             }
             $listfield = CheckboxSetField::create('list', 'List Options', $lists)->addExtraClass('form-control ' . $config->CcInputFieldClasses);
         }
     } else {
         return false;
     }
     $fields = new FieldList(array(TextField::create('email')->setTitle('')->addExtraClass('form-control ' . $config->CcInputFieldClasses)->setAttribute('placeholder', 'Email'), TextField::create('first_name')->setTitle('')->addExtraClass('form-control ' . $config->CcInputFieldClasses)->setAttribute('placeholder', 'First Name'), TextField::create('last_name')->setTitle('')->addExtraClass('form-control ' . $config->CcInputFieldClasses)->setAttribute('placeholder', 'Last Name'), $listfield, LiteralField::create('SignUpButton', '<input type="button" class="' . $config->CcSubmitButtonClasses . '" id="subscribe_to_cc_list" value="' . ($config->CcSubmitButtonText ? $config->CcSubmitButtonText : "Sign Up") . '" />')));
     if ($config->CcDisplayZip) {
         //if postcode field is needed.
         $fields->push(TextField::create('postcode')->setTitle('')->addExtraClass('form-control ' . $config->CcInputFieldClasses)->setAttribute('placeholder', 'Postcode'));
     }
     // Create actions
     $actions = new FieldList(FormAction::create('signup')->addExtraClass('small button'));
     $form = new Form($this, 'SS_ConstantContactSignup', $fields, $actions);
     $form->addExtraClass('custom constant-contect-signup');
     // Load the form with previously sent data
     $form->loadDataFrom(Controller::curr()->getRequest()->postVars());
     return $form;
 }