public function testHasTabSet() { $untabbedFields = new FieldList(new TextField('Field1')); $this->assertFalse($untabbedFields->hasTabSet()); $tabbedFields = new FieldList(new TabSet('Root', new Tab('Tab1'))); $this->assertTrue($tabbedFields->hasTabSet()); }
/** * Add FocusPoint field for selecting focus */ public function updateCMSFields(FieldList $fields) { $f = new FocusPointField($this->owner); if ($fields->hasTabSet()) { $fields->addFieldToTab('Root.Main', $f); } else { $fields->add($f); } }
public function updateCMSFields(FieldList $fields) { if ($fields->hasTabSet()) { $fields->addFieldsToTab('Root.Address', $this->getAddressFields()); } else { $newFields = $this->getAddressFields(); foreach ($newFields as $field) { $fields->push($field); } } }
public function updateCMSFields(FieldList $fields) { //Add FocusPoint field for selecting focus $f = new FocusPointField($name = "FocusXY", $title = "Focus point", $value = $this->owner->FocusX . ',' . $this->owner->FocusY, $imageID = $this->owner->ID); //$f->setValue(FocusPointField::sourceCoordsToFieldValue($this->owner->FocusX,$this->owner->FocusY)); if ($fields->hasTabSet()) { $fields->addFieldToTab('Root.Main', $f); } else { $fields->add($f); } }
/** * Extracts out the field updating since that could happen at a couple * different extension points. * @param FieldList $fields */ protected function updateFields(FieldList $fields) { // This seemed to cause problems. Moved to config.yml. //Requirements::javascript(SHOP_EXTENDEDPRICING_FOLDER . '/javascript/ExtendedPricingAdmin.js'); $newFields = array(new CheckboxField("PromoActive", "Promotional pricing active?"), new OptionsetField("PromoDisplay", "Display Settings", array("ShowDiscount" => "Show base price crossed out", "HideDiscount" => "Hide base price")), new OptionsetField("PromoType", "Type of discount", array("Percent" => "Percentage of subtotal (eg 25%)", "Amount" => "Fixed amount (eg \$25.00)")), new PercentageField("PromoPercent", "Percent discount"), new NumericField("PromoAmount", "Fixed discount (e.g. 5 = \$5 off)"), new FieldGroup("Valid date range (optional):", array(PromoDatetimeField::create("PromoStartDate", "Start Date / Time"), PromoDatetimeField::create("PromoEndDate", "End Date / Time (you should set the end time to 23:59:59, if you want to include the entire end day)")))); $f = new ToggleCompositeField('PromoFields', 'Promotional Pricing', $newFields); $f->setStartClosed(!$this->getOwner()->PromoActive); if ($fields->hasTabSet()) { $fields->addFieldToTab('Root.Pricing', $f); } else { $fields->push($f); } }
/** * Extracts out the field updating since that could happen at a couple * different extension points. * @param FieldList $fields */ protected function updateFields(FieldList $fields) { // pricing is handled on the variations instead if they are present if ($this->getOwner() instanceof Product && $this->getOwner()->Variations()->exists()) { return; } foreach (self::get_levels() as $code => $fieldName) { $newField = new TextField($fieldName, $this->getOwner()->fieldLabel($fieldName), '', 12); if ($fields->hasTabSet()) { $fields->addFieldToTab('Root.Pricing', $newField, 'CostPrice'); } else { $fields->insertAfter($newField, 'Price'); } } }
public function updateCMSFields(FieldList $fields) { // Present a set of checkboxes for filtering this item by locale $filterField = FieldGroup::create()->setTitle(_t('Fluent.LocaleFilter', 'Locale Filter'))->setDescription(_t('Fluent.LocaleFilterDescription', 'Check a locale to show this item on that locale')); foreach (Fluent::locales() as $locale) { $id = Fluent::db_field_for_locale("LocaleFilter", $locale); $fields->removeByName($id, true); // Remove existing (in case it was auto scaffolded) $title = i18n::get_locale_name($locale); $filterField->push(new CheckboxField($id, $title)); } if ($fields->hasTabSet()) { $fields->findOrMakeTab('Root.Locales', _t('Fluent.TABLOCALES', 'Locales')); $fields->addFieldToTab('Root.Locales', $filterField); } else { $fields->add($filterField); } }
public function updateCMSFields(FieldList $fields) { if (!($apiKey = Config::inst()->get('Aviary', 'ClientID'))) { return; } // load Aviary (js+css) Aviary::loadAviary(); // Image pointer $aviaryImage = LiteralField::create('AviaryImage', '<img class="aviary_image" id="aviary_image_' . $this->owner->ID . '" src="' . $this->owner->URL . '" style="display: none;" />'); // create edit button $editButton = FormAction::create('AviaryEditImage', _t('Aviary.EditImage', 'Edit Image'))->setAttribute('data-apikey', $apiKey)->setAttribute('data-localprocessing', Config::inst()->get('Aviary', 'LocalProcessing')); if ($fields->hasTabSet()) { $fields->insertAfter(CompositeField::create($editButton)->setName('AviaryEditImageWrapper'), 'ImageFull'); $fields->insertAfter($aviaryImage, 'FilePreviewImage'); } else { $fields->add(CompositeField::create($aviaryImage, $editButton)); } }
public function updateCMSFields(FieldList $fields) { if (!$fields->hasTabSet()) { return $fields; } $tab = $fields->fieldByName('Root.Content') ? 'Root.Content.Media' : 'Root.Media'; $fields->removeByName(SiteMedia::$plural_name); if ($this->owner->ShowSiteMedia() && $this->owner->ID) { //@todo implement shared $shared = false; $field = new GridField(SiteMedia::$plural_name, 'SiteMedia', $this->owner->SiteMedias(), GridFieldConfig_RelationEditor::create()); $config = $field->getConfig(); $config->removeComponentsByType('GridFieldDeleteAction'); $config->addComponents(new GridFieldOrderableRows('SortOrder'), new GridFieldDeleteAction($shared)); if (!$shared) { $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); } $config->getComponentByType('GridFieldAddNewButton')->setButtonName('Add Media'); $field->setTitle('Media'); $fields->addFieldToTab($tab, $field); } return $fields; }
/** * Add moderation functions to the current fieldlist * * @param FieldList $fields */ protected function updateModerationFields(FieldList $fields) { Requirements::css(COMMENTS_DIR . '/css/cms.css'); $newComments = $this->owner->AllComments()->filter('Moderated', 0); $newGrid = new CommentsGridField('NewComments', _t('CommentsAdmin.NewComments', 'New'), $newComments, CommentsGridFieldConfig::create()); $approvedComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 0); $approvedGrid = new CommentsGridField('ApprovedComments', _t('CommentsAdmin.Comments', 'Approved'), $approvedComments, CommentsGridFieldConfig::create()); $spamComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 1); $spamGrid = new CommentsGridField('SpamComments', _t('CommentsAdmin.SpamComments', 'Spam'), $spamComments, CommentsGridFieldConfig::create()); $newCount = '(' . count($newComments) . ')'; $approvedCount = '(' . count($approvedComments) . ')'; $spamCount = '(' . count($spamComments) . ')'; if ($fields->hasTabSet()) { $tabs = new TabSet('Comments', new Tab('CommentsNewCommentsTab', _t('CommentAdmin.NewComments', 'New') . ' ' . $newCount, $newGrid), new Tab('CommentsCommentsTab', _t('CommentAdmin.Comments', 'Approved') . ' ' . $approvedCount, $approvedGrid), new Tab('CommentsSpamCommentsTab', _t('CommentAdmin.SpamComments', 'Spam') . ' ' . $spamCount, $spamGrid)); $fields->addFieldToTab('Root', $tabs); } else { $fields->push($newGrid); $fields->push($approvedGrid); $fields->push($spamGrid); } }