public function getDashletFields()
 {
     $fields = parent::getDashletFields();
     $all = PostTag::get()->map('Title', 'Title')->toArray();
     $fields->insertAfter(MultiValueTextField::create('FilterTags', 'Tags to filter by', $all), 'Title');
     return $fields;
 }
 public function getDashletFields()
 {
     $fields = parent::getDashletFields();
     $fields->push(CheckboxField::create('ShowAnnouncements', 'Show general announcements'));
     $fields->push(MultiValueTextField::create('RSSFeeds', 'RSS Feeds'));
     return $fields;
 }
 /**
  * Gets the fields used for editing this dashlet on the frontend
  *
  * @return FieldSet 
  */
 public function getDashletFields()
 {
     /**
      *	if you want to use jQuery color picker instead of HTML5
      *	<input type='color' />, uncomment out the lined which add
      *	the extra class, and comment out the lines which are setting
      *	the attribute to type => color
      */
     $extraClasses = MultiValueTextField::create('ExtraClasses');
     $fields = new FieldList(new TextField('Title', _t('Dashlet.TITLE', 'Title')), $extraClasses);
     $this->extend('updateDashletFields', $fields);
     return $fields;
 }
 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;
 }
 /**
  * @param int $id
  * @param FieldList $fields
  * @return Form
  */
 public function getEditForm($id = null, $fields = null)
 {
     $form = parent::getEditForm($id, $fields);
     $filter = $this->jobQueue->getJobListFilter(null, 300);
     $list = DataList::create('QueuedJobDescriptor');
     $list = $list->where($filter)->sort('Created', 'DESC');
     $gridFieldConfig = GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldQueuedJobExecute('execute'))->addComponent(new GridFieldQueuedJobExecute('pause', function ($record) {
         return $record->JobStatus == QueuedJob::STATUS_WAIT || $record->JobStatus == QueuedJob::STATUS_RUN;
     }))->addComponent(new GridFieldQueuedJobExecute('resume', function ($record) {
         return $record->JobStatus == QueuedJob::STATUS_PAUSED || $record->JobStatus == QueuedJob::STATUS_BROKEN;
     }))->removeComponentsByType('GridFieldAddNewButton');
     // Set messages to HTML display format
     $formatting = array('Messages' => function ($val, $obj) {
         return "<div style='max-width: 300px; max-height: 200px; overflow: auto;'>{$obj->Messages}</div>";
     });
     $gridFieldConfig->getComponentByType('GridFieldDataColumns')->setFieldFormatting($formatting);
     // Replace gridfield
     $grid = new GridField('QueuedJobDescriptor', _t('QueuedJobs.JobsFieldTitle', 'Jobs'), $list, $gridFieldConfig);
     $grid->setForm($form);
     $form->Fields()->replaceField('QueuedJobDescriptor', $grid);
     if (Permission::check('ADMIN')) {
         $types = ClassInfo::subclassesFor('AbstractQueuedJob');
         $types = array_combine($types, $types);
         unset($types['AbstractQueuedJob']);
         $jobType = DropdownField::create('JobType', _t('QueuedJobs.CREATE_JOB_TYPE', 'Create job of type'), $types);
         $jobType->setEmptyString('(select job to create)');
         $form->Fields()->push($jobType);
         $jobParams = MultiValueTextField::create('JobParams', _t('QueuedJobs.JOB_TYPE_PARAMS', 'Constructor parameters for job creation'));
         $form->Fields()->push($jobParams);
         $form->Fields()->push($dt = DatetimeField::create('JobStart', _t('QueuedJobs.START_JOB_TIME', 'Start job at')));
         $dt->getDateField()->setConfig('showcalendar', true);
         $actions = $form->Actions();
         $actions->push(FormAction::create('createjob', _t('QueuedJobs.CREATE_NEW_JOB', 'Create new job')));
     }
     $this->extend('updateEditForm', $form);
     return $form;
 }
 public function __construct($name, $title = null, $source = array(), $value = null, $form = null)
 {
     parent::__construct($name, $title === null ? $name : $title, $value, $form);
     $this->source = $source;
 }
 /**
  * Gets the form fields for configuring the report settings.
  *
  * @return FieldList
  */
 public function getSettingsFields()
 {
     $reportable = $this->getReportableFields();
     $converted = array();
     foreach ($reportable as $k => $v) {
         if (preg_match('/^(.*) +AS +"([^"]*)"/i', $k, $matches)) {
             $k = $matches[2];
         }
         $converted[$this->dottedFieldToUnique($k)] = $v;
     }
     $fieldsGroup = new FieldGroup('Fields', MultiValueDropdownField::create('ReportFields')->setTitle(_t('AdvancedReport.REPORT_FIELDS', 'Report Fields'))->setSource($reportable)->addExtraClass('advanced-report-field-names'), MultiValueTextField::create('ReportHeaders')->setTitle(_t('AdvancedReport.REPORT_HEADERS', 'Headers'))->addExtraClass('advanced-report-field-headers'));
     $fieldsGroup->setName('FieldsGroup');
     $fieldsGroup->addExtraClass('advanced-report-fields dropdown');
     $conditionsGroup = new FieldGroup('Conditions', new MultiValueDropdownField('ConditionFields', _t('AdvancedReport.CONDITION_FIELDS', 'Condition Fields'), $reportable), new MultiValueDropdownField('ConditionOps', _t('AdvancedReport.CONDITION_OPERATIONS', 'Operation'), $this->config()->allowed_conditions), new MultiValueTextField('ConditionValues', _t('AdvancedReport.CONDITION_VALUES', 'Value')));
     $conditionsGroup->setName('ConditionsGroup');
     $conditionsGroup->addExtraClass('dropdown');
     // define the group for the sort field
     $sortGroup = new FieldGroup('Sort', new MultiValueDropdownField('SortBy', _t('AdvancedReport.SORTED_BY', 'Sorted By'), $reportable), new MultiValueDropdownField('SortDir', _t('AdvancedReport.SORT_DIRECTION', 'Sort Direction'), array('ASC' => _t('AdvancedReport.ASC', 'Ascending'), 'DESC' => _t('AdvancedReport.DESC', 'Descending'))));
     $sortGroup->setName('SortGroup');
     $sortGroup->addExtraClass('dropdown');
     // build a list of the formatters
     $formatters = ClassInfo::implementorsOf('ReportFieldFormatter');
     $fmtrs = array();
     foreach ($formatters as $formatterClass) {
         $formatter = new $formatterClass();
         $fmtrs[$formatterClass] = $formatter->label();
     }
     // define the group for the custom field formatters
     $fieldFormattingGroup = new FieldGroup(_t('AdvancedReport.FORMAT_FIELDS', 'Custom field formatting'), new MultiValueDropdownField('FieldFormattingField', _t('AdvancedReport.FIELDFORMATTING', 'Field'), $converted), new MultiValueDropdownField('FieldFormattingFormatter', _t('AdvancedReport.FIELDFORMATTINGFORMATTER', 'Formatter'), $fmtrs));
     $fieldFormattingGroup->setName('FieldFormattingGroup');
     $fieldFormattingGroup->addExtraClass('dropdown');
     // assemble the fieldlist
     $fields = new FieldList(new TextField('Title', _t('AdvancedReport.TITLE', 'Title')), new TextareaField('Description', _t('AdvancedReport.DESCRIPTION', 'Description')), $fieldsGroup, $conditionsGroup, new KeyValueField('ReportParams', _t('AdvancedReport.REPORT_PARAMETERS', 'Default report parameters')), $sortGroup, new MultiValueDropdownField('NumericSort', _t('AdvancedReport.SORT_NUMERICALLY', 'Sort these fields numerically'), $reportable), DropdownField::create('PaginateBy')->setTitle(_t('AdvancedReport.PAGINATE_BY', 'Paginate By'))->setSource($reportable)->setHasEmptyDefault(true), TextField::create('PageHeader')->setTitle(_t('AdvancedReport.HEADER_TEXT', 'Header text'))->setDescription(_t('AdvancedReport.USE_NAME_FOR_PAGE_NAME', 'use $name for the page name'))->setValue('$name'), new MultiValueDropdownField('AddInRows', _t('AdvancedReport.ADD_IN_ROWS', 'Add these columns for each row'), $converted), new MultiValueDropdownField('AddCols', _t('AdvancedReport.ADD_IN_ROWS', 'Provide totals for these columns'), $converted), $fieldFormattingGroup, new MultiValueDropdownField('ClearColumns', _t('AdvancedReport.CLEARED_COLS', '"Cleared" columns'), $converted));
     if ($this->config()->allow_grouping) {
         // GroupBy
         $groupingGroup = new FieldGroup('Grouping', new MultiValueDropdownField('GroupBy', _t('AdvancedReport.GROUPBY_FIELDS', 'Group by fields'), $reportable), new MultiValueDropdownField('SumFields', _t('AdvancedReport.SUM_FIELDS', 'SUM fields'), $reportable));
         $groupingGroup->addExtraClass('dropdown');
         $fields->insertAfter($groupingGroup, 'Conditions');
     }
     if ($this->hasMethod('updateReportFields')) {
         Deprecation::notice('3.0', 'The updateReportFields method is deprecated, instead overload getSettingsFields');
         $this->updateReportFields($fields);
     }
     $this->extend('updateSettingsFields', $fields);
     return $fields;
 }
 public function setValue($v)
 {
     if (is_array($v)) {
         // we've been set directly via the post - lets convert things to an appropriate key -> value
         // structure
         if (isset($v['key'])) {
             $newVal = array();
             for ($i = 0, $c = count($v['key']); $i < $c; $i++) {
                 if (strlen($v['key'][$i]) && strlen($v['val'][$i])) {
                     $newVal[$v['key'][$i]] = $v['val'][$i];
                 }
             }
             $v = $newVal;
         }
     }
     if ($v instanceof MultiValueField) {
         $v = $v->getValues();
     }
     if (!is_array($v)) {
         $v = array();
     }
     parent::setValue($v);
 }
Exemplo n.º 9
0
 public function updateExtensibleSearchPageCMSFields(FieldList $fields)
 {
     if ($this->owner->SearchEngine === get_class($this)) {
         $types = SiteTree::page_type_classes();
         $source = array_combine($types, $types);
         // add in any explicitly configured
         asort($source);
         $source = $this->owner->updateSource($source);
         $parsers = $this->owner->getQueryBuilders();
         $options = array();
         foreach ($parsers as $key => $objCls) {
             $obj = new $objCls();
             $options[$key] = $obj->title;
         }
         $fields->addFieldToTab('Root.Main', new DropdownField('QueryType', _t('ExtensibleSearchPage.QUERY_TYPE', 'Query Type'), $options), 'Content');
         ksort($source);
         $source = array_merge($source, ExtensibleSearchPage::config()->additional_search_types);
         $types = MultiValueDropdownField::create('SearchType', _t('ExtensibleSearchPage.SEARCH_ITEM_TYPE', 'Search items of type'), $source);
         $fields->addFieldToTab('Root.Main', $types, 'Content');
         $objFields = $this->owner->getSelectableFields();
         $sortFields = $objFields;
         // Remove content and groups from being sortable (as they are not relevant).
         unset($sortFields['Content']);
         unset($sortFields['Groups']);
         $fields->replaceField('SortBy', new DropdownField('SortBy', _t('ExtensibleSearchPage.SORT_BY', 'Sort By'), $sortFields));
         $fields->addFieldToTab('Root.Main', MultiValueDropdownField::create('SearchOnFields', _t('ExtensibleSearchPage.INCLUDE_FIELDS', 'Search On Fields'), $objFields), 'Content');
         $fields->addFieldToTab('Root.Main', MultiValueTextField::create('ExtraSearchFields', _t('SolrSearch.EXTRA_FIELDS', 'Custom solr fields to search')), 'Content');
         $boostVals = array();
         for ($i = 1; $i <= static::BOOST_MAX; $i++) {
             $boostVals[$i] = $i;
         }
         $fields->addFieldToTab('Root.Main', new KeyValueField('BoostFields', _t('ExtensibleSearchPage.BOOST_FIELDS', 'Boost values'), $objFields, $boostVals), 'Content');
         $fields->addFieldToTab('Root.Main', $f = new KeyValueField('BoostMatchFields', _t('ExtensibleSearchPage.BOOST_MATCH_FIELDS', 'Boost fields with field/value matches'), array(), $boostVals), 'Content');
         $f->setRightTitle('Enter a field name, followed by the value to boost if found in the result set, eg "title:Home" ');
         $fields->addFieldToTab('Root.Main', $kv = new KeyValueField('FilterFields', _t('ExtensibleSearchPage.FILTER_FIELDS', 'Fields to filter by')), 'Content');
         $fields->addFieldToTab('Root.Main', new HeaderField('FacetHeader', _t('ExtensibleSearchPage.FACET_HEADER', 'Facet Settings')), 'Content');
         $fields->addFieldToTab('Root.Main', new MultiValueDropdownField('FacetFields', _t('ExtensibleSearchPage.FACET_FIELDS', 'Fields to create facets for'), $objFields), 'Content');
         $fields->addFieldToTab('Root.Main', new MultiValueTextField('CustomFacetFields', _t('ExtensibleSearchPage.CUSTOM_FACET_FIELDS', 'Additional fields to create facets for')), 'Content');
         $facetMappingFields = $objFields;
         if ($this->owner->CustomFacetFields && ($cff = $this->owner->CustomFacetFields->getValues())) {
             foreach ($cff as $facetField) {
                 $facetMappingFields[$facetField] = $facetField;
             }
         }
         $fields->addFieldToTab('Root.Main', new KeyValueField('FacetMapping', _t('ExtensibleSearchPage.FACET_MAPPING', 'Mapping of facet title to nice title'), $facetMappingFields), 'Content');
         $fields->addFieldToTab('Root.Main', new KeyValueField('FacetQueries', _t('ExtensibleSearchPage.FACET_QUERIES', 'Fields to create query facets for')), 'Content');
         $fields->addFieldToTab('Root.Main', new NumericField('MinFacetCount', _t('ExtensibleSearchPage.MIN_FACET_COUNT', 'Minimum facet count for inclusion in facet results'), 2), 'Content');
     }
     // Make sure previously existing hooks are carried across.
     $this->owner->extend('updateSolrCMSFields', $fields);
 }