function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.CheckboxSet", new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     $fields->addFieldsToTab('Root.Tree', array(TreeDropdownField::create('HasOnePage', 'HasOnePage', 'SiteTree'), TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'), TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true)));
     //		$fields->addFieldToTab("Root.Tests.ComplexTableField",
     //			new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     //		$fields->addFieldToTab("Root.Tests.CheckboxSet", new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('SiteConfigID');
     if ($targetField = $fields->dataFieldByName('Target')) {
         $targetField->setRightTitle('ID or CSS class to find the dom element');
     }
     $fields->removeByName('Pages');
     $fields->addFieldToTab('Root.Main', TreeMultiselectField::create('Pages', 'Select Pages (leave empty for all the pages)')->setSourceObject('SiteTree'));
     return $fields;
 }
Example #3
0
 /**
  * Build the CMS fields for editing 
  * @return FieldList
  **/
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Pages');
     // required information
     $fields->addFieldToTab('Root.Main', HiddenField::create('ModuleID', 'ModuleID', $this->ID));
     $fields->addFieldToTab('Root.Main', LiteralField::create('html', '<h3 style="margin-bottom: 5px;">' . $this->Type() . '</h3>'));
     $fields->addFieldToTab('Root.Main', LiteralField::create('html', '<p><em>' . $this->getDescription() . '</em></p><br />'));
     $fields->addFieldToTab('Root.Main', TextField::create('Title', 'Title'));
     $fields->addFieldToTab('Root.Main', DropdownField::create('Position', 'Position', ModuleManager::get_positions_dropdown())->setEmptyString('Please select'));
     $fields->addFieldToTab("Root.Main", TreeMultiselectField::create("Pages", "Shown on pages", "SiteTree"));
     $fields->addFieldToTab('Root.Main', HTMLEditorField::create('Content', 'Content'));
     return $fields;
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $allFields = array();
     $checkboxFields = array(new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     $fields->addFieldsToTab("Root.CheckboxSet", $checkboxFields);
     $allFields += $checkboxFields;
     $treeFields = array(TreeDropdownField::create('HasOnePageID', 'HasOnePage', 'SiteTree'), TreeDropdownField::create('HasOnePageWithSearchID', 'HasOnePageWithSearch', 'SiteTree')->setShowSearch(true), TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'), TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true));
     $fields->addFieldsToTab('Root.Tree', $treeFields);
     $allFields += $treeFields;
     foreach ($allFields as $field) {
         $field->setDescription('This is <strong>bold</strong> help text')->addExtraClass('cms-help');
         // ->addExtraClass('cms-help cms-help-tooltip');
     }
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldFromTab('Root', 'PageParents');
     $fields->addFieldToTab('Root.Main', HeaderField::create('SettingsHeading', _t('BlockSet.Settings', 'Settings')), 'Title');
     $fields->addFieldToTab('Root.Main', MultiValueCheckboxField::create('PageTypes', _t('BlockSet.OnlyApplyToThesePageTypes', 'Only apply to these Page Types:'), $this->pageTypeOptions())->setDescription(_t('BlockSet.OnlyApplyToThesePageTypesDescription', 'Selected Page Types will inherit this Block Set automatically. Leave all unchecked to apply to all page types.')));
     $fields->addFieldToTab('Root.Main', TreeMultiselectField::create('PageParents', _t('BlockSet.OnlyApplyToChildrenOfThesePages', 'Only apply to children of these Pages:'), 'SiteTree'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('IncludePageParent', _t('BlockSet.ApplyBlockSetToSelectedPageParentsAsWellAsChildren', 'Apply block set to selected page parents as well as children')));
     if (!$this->ID) {
         $fields->addFieldToTab('Root.Main', LiteralField::create('NotSaved', "<p class='message warning'>" . _t('BlockSet.YouCanAddBlocksToThisSetOnceYouHaveSavedIt', 'You can add Blocks to this set once you have saved it for the first time') . '</p>'));
         return $fields;
     }
     $fields->removeFieldFromTab('Root', 'Blocks');
     $gridConfig = GridFieldConfig_BlockManager::create(true, true, true, true, true)->addExisting()->addComponent(new GridFieldOrderableRows());
     $gridSource = $this->Blocks()->Sort('Sort');
     $fields->addFieldToTab('Root.Main', HeaderField::create('BlocksHeading', _t('Block.PLURALNAME', 'Blocks')));
     $fields->addFieldToTab('Root.Main', GridField::create('Blocks', _t('Block.PLURALNAME', 'Blocks'), $gridSource, $gridConfig));
     return $fields;
 }
 /**
  *	Display the search engine specific configuration, and the search page specific analytics and suggestions.
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     Requirements::css(EXTENSIBLE_SEARCH_PATH . '/css/extensible-search.css');
     // Determine the search engine extensions that are available.
     $engines = array();
     foreach (self::config()->search_engine_extensions as $extension => $display) {
         // The search engine extensions may define an optional display title.
         if (is_numeric($extension)) {
             $extension = $display;
         }
         // Determine whether the search engine extensions have been applied correctly.
         if (ClassInfo::exists($extension) && ClassInfo::exists("{$extension}_Controller") && $this->hasExtension($extension) && ModelAsController::controller_for($this)->hasExtension("{$extension}_Controller")) {
             $engines[$extension] = $display;
         }
     }
     // Determine whether the full-text search engine is available.
     $configuration = Config::inst();
     $classes = $configuration->get('FulltextSearchable', 'searchable_classes');
     if (is_array($classes) && count($classes) > 0) {
         $engines['Full-Text'] = 'Full-Text';
     }
     // Display the search engine selection.
     $fields->addFieldToTab('Root.Main', DropdownField::create('SearchEngine', 'Search Engine', $engines)->setHasEmptyDefault(true)->setRightTitle('This needs to be saved before further customisation is available'), 'Title');
     // Determine whether a search engine has been selected.
     if ($this->SearchEngine && isset($engines[$this->SearchEngine])) {
         // Display a search engine specific notice.
         $fields->addFieldToTab('Root.Main', LiteralField::create('SearchEngineNotice', "<p class='extensible-search notice'><strong>{$engines[$this->SearchEngine]} Search Page</strong></p>"), 'Title');
         // Determine whether the search engine supports hierarchy filtering.
         $hierarchy = self::$supports_hierarchy;
         if ($this->SearchEngine !== 'Full-Text') {
             foreach ($this->extension_instances as $instance) {
                 if (get_class($instance) === $this->SearchEngine) {
                     $instance->setOwner($this);
                     if (isset($instance::$supports_hierarchy)) {
                         $hierarchy = $instance::$supports_hierarchy;
                     }
                     $instance->clearOwner();
                     break;
                 }
             }
         }
         // The search engine may only support limited hierarchy filtering for multiple sites.
         if ($hierarchy || ClassInfo::exists('Multisites')) {
             // Display the search trees selection.
             $fields->addFieldToTab('Root.Main', $tree = TreeMultiselectField::create('SearchTrees', 'Search Trees', 'SiteTree'), 'Content');
             // Determine whether the search engine only supports limited hierarchy filtering.
             if (!$hierarchy) {
                 // Update the search trees to reflect this.
                 $tree->setDisableFunction(function ($page) {
                     return $page->ParentID != 0;
                 });
                 $tree->setRightTitle('This <strong>search engine</strong> only supports limited hierarchy');
             }
         }
         // Display the sorting selection.
         $fields->addFieldToTab('Root.Main', DropdownField::create('SortBy', 'Sort By', $this->getSelectableFields()), 'Content');
         $fields->addFieldToTab('Root.Main', DropdownField::create('SortDirection', 'Sort Direction', array('DESC' => 'Descending', 'ASC' => 'Ascending')), 'Content');
         // Display the start with listing selection.
         $fields->addFieldToTab('Root.Main', CheckboxField::create('StartWithListing', 'Start With Listing?')->addExtraClass('start-with-listing'), 'Content');
         // Display the results per page selection.
         $fields->addFieldToTab('Root.Main', NumericField::create('ResultsPerPage'), 'Content');
     } else {
         // The search engine has not been selected.
         $fields->addFieldToTab('Root.Main', LiteralField::create('SearchEngineNotification', "<p class='extensible-search notification'><strong>Select a Search Engine</strong></p>"), 'Title');
     }
     // Determine whether analytics have been enabled.
     if ($configuration->get('ExtensibleSearch', 'enable_analytics')) {
         // Determine the search page specific analytics.
         $history = $this->History();
         $query = new SQLSelect("Term, COUNT(*) AS Frequency, ((COUNT(*) * 100.00) / {$history->count()}) AS FrequencyPercentage, AVG(Time) AS AverageTimeTaken, (Results > 0) AS Results", 'ExtensibleSearch', "ExtensibleSearchPageID = {$this->ID}", array('Frequency' => 'DESC', 'Term' => 'ASC'), 'Term');
         // These will require display formatting.
         $analytics = ArrayList::create();
         foreach ($query->execute() as $result) {
             $result = ArrayData::create($result);
             $result->FrequencyPercentage = sprintf('%.2f %%', $result->FrequencyPercentage);
             $result->AverageTimeTaken = sprintf('%.5f', $result->AverageTimeTaken);
             $result->Results = $result->Results ? 'true' : 'false';
             $analytics->push($result);
         }
         // Instantiate the analytic summary.
         $fields->addFieldToTab('Root.SearchAnalytics', $summary = GridField::create('Summary', 'Summary', $analytics)->setModelClass('ExtensibleSearch'));
         $summaryConfiguration = $summary->getConfig();
         // Update the display columns.
         $summaryDisplay = array('Term' => 'Search Term', 'Frequency' => 'Frequency', 'FrequencyPercentage' => 'Frequency %', 'AverageTimeTaken' => 'Average Time Taken (s)', 'Results' => 'Has Results?');
         $summaryConfiguration->getComponentByType('GridFieldDataColumns')->setDisplayFields($summaryDisplay);
         // Instantiate an export button.
         $summaryConfiguration->addComponent($summaryExport = new GridFieldExportButton());
         $summaryExport->setExportColumns($summaryDisplay);
         // Update the custom summary fields to be sortable.
         $summaryConfiguration->getComponentByType('GridFieldSortableHeader')->setFieldSorting(array('FrequencyPercentage' => 'Frequency'));
         $summaryConfiguration->removeComponentsByType('GridFieldFilterHeader');
         // Instantiate the analytic history.
         $fields->addFieldToTab('Root.SearchAnalytics', $history = GridField::create('History', 'History', $history)->setModelClass('ExtensibleSearch'));
         $historyConfiguration = $history->getConfig();
         // Instantiate an export button.
         $historyConfiguration->addComponent(new GridFieldExportButton());
         // Update the custom summary fields to be sortable.
         $historyConfiguration->getComponentByType('GridFieldSortableHeader')->setFieldSorting(array('TimeSummary' => 'Created', 'TimeTakenSummary' => 'Time', 'SearchEngineSummary' => 'SearchEngine'));
         $historyConfiguration->removeComponentsByType('GridFieldFilterHeader');
     }
     // Determine whether suggestions have been enabled.
     if ($configuration->get('ExtensibleSearchSuggestion', 'enable_suggestions')) {
         // Appropriately restrict the approval functionality.
         $user = Member::currentUserID();
         if (Permission::checkMember($user, 'EXTENSIBLE_SEARCH_SUGGESTIONS')) {
             Requirements::javascript(EXTENSIBLE_SEARCH_PATH . '/javascript/extensible-search-approval.js');
         }
         // Determine the search page specific suggestions.
         $fields->addFieldToTab('Root.SearchSuggestions', GridField::create('Suggestions', 'Suggestions', $this->Suggestions(), $suggestionsConfiguration = GridFieldConfig_RecordEditor::create())->setModelClass('ExtensibleSearchSuggestion'));
         // Update the custom summary fields to be sortable.
         $suggestionsConfiguration->getComponentByType('GridFieldSortableHeader')->setFieldSorting(array('FrequencySummary' => 'Frequency', 'FrequencyPercentage' => 'Frequency', 'ApprovedField' => 'Approved'));
         $suggestionsConfiguration->removeComponentsByType('GridFieldFilterHeader');
     }
     // Allow extension customisation.
     $this->extend('updateExtensibleSearchPageCMSFields', $fields);
     return $fields;
 }
 public function getFormFields($buyable)
 {
     return \CompositeField::create(\LiteralField::create('Recommended_FindBy-OtherCategory-Message', '<p class="message field desc selectionGroup-desc">' . _t('Product.Recommended_FindBy-OtherCategory-Message', 'Recommended products will be pulled from the selected categories') . '</p>'), \TreeMultiselectField::create('Recommended_Categories', _t('Product.Categories', 'Categories'), 'ProductCategory', 'ID', 'MenuTitle'));
 }