public function getSettingsFields() { $dataTypes = $this->getAvailableTypes(); $reportable = $this->getReportableFields(); $converted = array(); foreach ($reportable as $k => $v) { $converted[$this->dottedFieldToUnique($k)] = $v; } $dataTypes = array_merge(array('' => ''), $dataTypes); $types = new MultiValueDropdownField('DataTypes', _t('AdvancedReport.DATA_TYPES', 'Data types'), $dataTypes); $fieldsGroup = new FieldGroup('Fields', $reportFieldsSelect = new MultiValueDropdownField('ReportFields', _t('AdvancedReport.REPORT_FIELDS', 'Report Fields'), $reportable)); $fieldsGroup->push(new MultiValueTextField('ReportHeaders', _t('AdvancedReport.HEADERS', 'Header labels'))); $fieldsGroup->addExtraClass('reportMultiField'); $reportFieldsSelect->addExtraClass('reportFieldsSelection'); $fieldsGroup->setName('FieldsGroup'); $fieldsGroup->addExtraClass('advanced-report-fields dropdown'); $conditions = new FieldGroup('Conditions', new MultiValueDropdownField('ConditionFields', _t('AdvancedReport.CONDITION_FIELDS', 'Condition Fields'), $reportable), new MultiValueDropdownField('ConditionOps', _t('AdvancedReport.CONDITION_OPERATIONS', 'Op'), $this->config()->allowed_conditions), new MultiValueTextField('ConditionValues', _t('AdvancedReport.CONDITION_VALUES', 'Value'))); $conditions->setName('ConditionsGroup'); $conditions->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')), $types, $fieldsGroup, $conditions, 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, 'ConditionsGroup'); } 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 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); }