public function updateFields($fields) { $types = $this->allowedItems(); $fields->replaceField('ItemType', DropdownField::create('ItemType', 'Items of type', $types)->setEmptyString('--select type--')); if ($this->ItemType) { $list = $this->getFilteredItemList(false); $dummy = $list->first(); if (!$dummy) { $dummy = singleton($this->ItemType); } $dbFields = $dummy->db(); $dbFields = array_combine(array_keys($dbFields), array_keys($dbFields)); $typeFields = array('ID' => 'ID', 'LastEdited' => 'LastEdited', 'Created' => 'Created'); $additional = $dummy->summaryFields(); $hasOnes = $dummy->has_one(); foreach ($hasOnes as $relName => $relType) { $dbFields[$relName . 'ID'] = $relName . 'ID'; } // $hasOnes, $dbFields = array_merge($typeFields, $dbFields); //, $additional); $fields->replaceField('Filter', KeyValueField::create('Filter', 'Filter by', $dbFields)); $fields->replaceField('Include', KeyValueField::create('Include', 'Include where', $dbFields)); $displayAble = array_merge($dbFields, $additional); $fields->replaceField('DataFields', KeyValueField::create('DataFields', 'Fields in table', $displayAble)); $fields->replaceField('FieldFormatting', KeyValueField::create('FieldFormatting', 'Formatting for fields', $displayAble)); $fields->replaceField('SortBy', KeyValueField::create('SortBy', 'Sorting', $dbFields, array('ASC' => 'ASC', 'DESC' => 'DESC'))); } }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.MicroBlog', MultiValueTextField::create('ShowTaggedWith', _t('MicroBlog.SHOW_POSTS_TAGGED', 'Show posts with these tags'))); $fields->addFieldToTab('Root.MicroBlog', MultiValueTextField::create('AddTags', _t('MicroBlog.ADD_TAGS', 'Add the following tags to posts'))); $fields->addFieldToTab('Root.MicroBlog', $cb = CheckboxField::create('SelfTagPosts', _t('MicroBlog.SELF_TAG', 'Tag posts against this page'))); $cb->setDescription('Self-tagging will mean posts added via this page will not appear on other microblog pages, but may still appear in global timelines'); $defaults = Config::inst()->get('TimelineController', 'options'); $options = array_combine(array_keys($defaults), array_keys($defaults)); $values = array('1' => 'Enabled', '0' => 'Disabled'); $custom = $this->CustomOptions->getValues(); if (!$custom || !count($custom)) { $this->CustomOptions = $defaults; } $fields->addFieldToTab('Root.MicroBlog', KeyValueField::create('CustomOptions', _t('MicroBlog.CUSTOM_OPTIONS', 'Options'), $options, $values)); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $available_classes = ClassInfo::subclassesFor("BuildTask"); array_shift($available_classes); ksort($available_classes); $available_jobtypes = array(QueuedJob::IMMEDIATE => "Small", QueuedJob::QUEUED => "Medium", QueuedJob::LARGE => "Large"); $fields->removeByName(array("ExecuteInterval", "ExecuteEvery", "ExecuteFree", "ScheduledJobID")); $fields->addFieldsToTab('Root.Main', array(DropdownField::create("BuildTaskClass", "Build Task", $available_classes), KeyValueField::create("RequestVariables", "Request Variables")->setDescription("Optional"), $dt = new Datetimefield('FirstExecution', _t('ScheduledExecution.FIRST_EXECUTION', 'First Execution')), FieldGroup::create(new NumericField('ExecuteInterval', ''), new DropdownField('ExecuteEvery', '', array('' => '', 'Minute' => _t('ScheduledExecution.ExecuteEveryMinute', 'Minute'), 'Hour' => _t('ScheduledExecution.ExecuteEveryHour', 'Hour'), 'Day' => _t('ScheduledExecution.ExecuteEveryDay', 'Day'), 'Week' => _t('ScheduledExecution.ExecuteEveryWeek', 'Week'), 'Fortnight' => _t('ScheduledExecution.ExecuteEveryFortnight', 'Fortnight'), 'Month' => _t('ScheduledExecution.ExecuteEveryMonth', 'Month'), 'Year' => _t('ScheduledExecution.ExecuteEveryYear', 'Year'))))->setTitle(_t('ScheduledExecution.EXECUTE_EVERY', 'Execute every')), DropdownField::create("JobType", "Job Type", $available_jobtypes))); if ($this->ScheduledJobID) { $jobTime = $this->getNextRunDate(); $fields->addFieldsToTab('Root.Schedule', array(new ReadonlyField('NextRunDate', _t('ScheduledExecution.NEXT_RUN_DATE', 'Next run date'), $jobTime))); } $dt->getDateField()->setConfig('showcalendar', true); $dt->getTimeField()->setConfig('showdropdown', true); return $fields; }
/** * @return FieldSet */ public function getCMSFields() { $fields = parent::getCMSFields(); /* @var FieldSet $fields */ $fields->replaceField('Content', new HtmlEditorField('Content', _t('ListingPage.CONTENT', 'Content (enter $Listing to display the listing)'))); $templates = DataObject::get('ListingTemplate'); if ($templates) { $templates = $templates->map(); } else { $templates = array(); } $fields->addFieldToTab('Root.ListingSettings', new DropdownField('ListingTemplateID', _t('ListingPage.CONTENT_TEMPLATE', 'Listing Template'), $templates)); $fields->addFieldToTab('Root.ListingSettings', new NumericField('PerPage', _t('ListingPage.PER_PAGE', 'Items Per Page'))); $fields->addFieldToTab('Root.ListingSettings', new DropdownField('SortDir', _t('ListingPage.SORT_DIR', 'Sort Direction'), $this->dbObject('SortDir')->enumValues())); $listType = $this->ListType ? $this->ListType : 'Page'; $objFields = $this->getSelectableFields($listType); $fields->addFieldToTab('Root.ListingSettings', new DropdownField('SortBy', _t('ListingPage.SORT_BY', 'Sort By'), $objFields)); // $fields->addFieldToTab('Root.Content.Main', new TextField('CustomSort', _t('ListingPage.CUSTOM_SORT', 'Custom sort field'))); $types = ClassInfo::subclassesFor('DataObject'); array_shift($types); $source = array_combine($types, $types); asort($source); $optionsetField = new DropdownField('ListType', _t('ListingPage.PAGE_TYPE', 'List items of type'), $source, 'Any'); $fields->addFieldToTab('Root.ListingSettings', $optionsetField); $fields->addFieldToTab('Root.ListingSettings', new CheckboxField('StrictType', _t('ListingPage.STRICT_TYPE', 'List JUST this type, not descendents'))); $sourceType = $this->effectiveSourceType(); $parentType = $this->parentType($sourceType); if ($sourceType && $parentType) { $fields->addFieldToTab('Root.ListingSettings', new DropdownField('Depth', _t('ListingPage.DEPTH', 'Depth'), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5))); $fields->addFieldToTab('Root.ListingSettings', new TreeDropdownField('ListingSourceID', _t('ListingPage.LISTING_SOURCE', 'Source of content for listing'), $parentType)); $fields->addFieldToTab('Root.ListingSettings', new CheckboxField('ClearSource', _t('ListingPage.CLEAR_SOURCE', 'Clear listing source value'))); } $contentTypes = array('' => 'In Theme', 'text/html; charset=utf-8' => 'HTML Fragment', 'text/xml; charset=utf-8' => 'XML', 'application/rss+xml; charset=utf-8' => 'RSS (xml)', 'application/rdf+xml; charset=utf-8' => 'RDF (xml)', 'application/atom+xml; charset=utf-8' => 'ATOM (xml)'); $fields->addFieldToTab('Root.ListingSettings', new DropdownField('ContentType', _t('ListingPage.CONTENT_TYPE', 'Content Type'), $contentTypes)); $fields->addFieldToTab('Root.ListingSettings', new TextField('CustomContentType', _t('ListingPage.CUSTOM_CONTENT_TYPE', 'Custom Content Type'))); if ($this->ListType) { $componentsManyMany = singleton($this->ListType)->config()->many_many; if (!is_array($componentsManyMany)) { $componentsManyMany = array(); } $componentNames = array(); foreach ($componentsManyMany as $componentName => $className) { $componentNames[$componentName] = FormField::name_to_label($componentName) . ' (' . $className . ')'; } $fields->addFieldToTab('Root.ListingSettings', DropdownField::create('ComponentFilterName', _t('ListingPage.RELATION_COMPONENT_NAME', 'Filter by Relation'), $componentNames)->setEmptyString('(Select)')->setRightTitle('Will cause this page to list items based on the last URL part. (ie. ' . $this->AbsoluteLink() . '{$componentFieldName})')); $fields->addFieldToTab('Root.ListingSettings', $componentColumnField = DropdownField::create('ComponentFilterColumn', 'Filter by Relation Field')->setEmptyString('(Must select a relation and save)')); $fields->addFieldToTab('Root.ListingSettings', $componentListingField = DropdownField::create('ComponentListingTemplateID', _t('ListingPage.COMPONENT_CONTENT_TEMPLATE', 'Relation Listing Template'))->setEmptyString('(Must select a relation and save)')); if ($this->ComponentFilterName) { $componentClass = isset($componentsManyMany[$this->ComponentFilterName]) ? $componentsManyMany[$this->ComponentFilterName] : ''; if ($componentClass) { $componentFields = array(); foreach ($this->getSelectableFields($componentClass) as $columnName => $type) { $componentFields[$columnName] = $columnName; } $componentColumnField->setSource($componentFields); $componentColumnField->setEmptyString('(Select)'); $componentListingField->setSource($templates); $componentListingField->setHasEmptyDefault(false); if (class_exists('KeyValueField')) { $fields->addFieldToTab('Root.ListingSettings', KeyValueField::create('ComponentFilterWhere', 'Constrain Relation By', $componentFields)->setRightTitle("Filter '{$this->ComponentFilterName}' with these properties.")); } } } } return $fields; }