/**
  * Returns the edit form for this admin.
  * 
  * @param type $id
  * @param type $fields
  * 
  * @return Form
  */
 public function getEditForm($id = null, $fields = null)
 {
     $fields = new FieldList();
     $desc = _t('SilvercartNewsletterRecipientsAdmin.Description', 'Please choose your export context and press the export button to download a CSV list of email recipients.');
     $descriptionField = new SilvercartAlertInfoField('SilvercartProductImagesDescription', str_replace(PHP_EOL, '<br/>', $desc));
     $exportContextField = new DropdownField('ExportContext', _t('SilvercartNewsletterRecipientsAdmin.ExportContext', 'Export context'));
     $exportContextField->setSource(array('0' => _t('SilvercartNewsletterRecipientsAdmin.ExportAll', 'Export all customers'), '1' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipients', 'Export all newsletter recipients'), '2' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipientsWithAccount', 'Export all newsletter recipients with customer account'), '3' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipientsWithoutAccount', 'Export all newsletter recipients without customer account'), '4' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNonNewsletterRecipients', 'Export all non-newsletter recipients')));
     $doExportButton = new InlineFormAction('do_newsletter_recipients_export', _t('SilvercartNewsletterRecipientsAdmin.DoExport', 'Export as CSV'));
     $doExportButton->includeDefaultJS(false);
     $doExportButton->setAttribute('data-icon', 'download-csv');
     $fields->push($descriptionField);
     $fields->push($exportContextField);
     $fields->push($doExportButton);
     $actions = new FieldList();
     $form = new Form($this, "EditForm", $fields, $actions);
     $form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
     $form->loadDataFrom($this->request->getVars());
     $this->extend('updateEditForm', $form);
     return $form;
 }
 /**
  * Builds and returns the CMS fields.
  *
  * @return FieldList the CMS tabs and fields
  *
  * @author Sebastian Diel <*****@*****.**>
  * @since 22.02.2013
  */
 public function getCMSFieldsForSilvercart(FieldList $fields)
 {
     //$tab = $fields->findOrMakeTab('Root.Silvercart', 'SilverCart Shop');
     //$tab->setTitle('SilverCart Shop');
     // Build general toggle group
     $generalConfigurationField = ToggleCompositeField::create('GeneralConfiguration', $this->owner->fieldLabel('GeneralConfiguration'), array(SilvercartLanguageHelper::prepareLanguageDropdownField($this->owner, 'SiteTree', 'DefaultLocale'), new CheckboxField('useDefaultLanguageAsFallback', $this->owner->fieldLabel('useDefaultLanguageAsFallback')), new TextField('DefaultCurrency', $this->owner->fieldLabel('DefaultCurrency')), new DropdownField('DefaultPriceType', $this->owner->fieldLabel('DefaultPriceType'))))->setHeadingLevel(4)->setStartClosed(false);
     // Build email toggle group
     $emailConfigurationField = ToggleCompositeField::create('EmailConfiguration', $this->owner->fieldLabel('EmailConfiguration'), array(new TextField('EmailSender', $this->owner->fieldLabel('EmailSender')), new TextField('GlobalEmailRecipient', $this->owner->fieldLabel('GlobalEmailRecipient')), new TextField('DefaultMailRecipient', $this->owner->fieldLabel('DefaultMailRecipient')), new TextField('DefaultMailOrderNotificationRecipient', $this->owner->fieldLabel('DefaultMailOrderNotificationRecipient')), new TextField('DefaultContactMessageRecipient', $this->owner->fieldLabel('DefaultContactMessageRecipient'))))->setHeadingLevel(4);
     // Build customer toggle group
     $customerConfigurationField = ToggleCompositeField::create('CustomerConfiguration', $this->owner->fieldLabel('CustomerConfiguration'), array(new CheckboxField('enableBusinessCustomers', $this->owner->fieldLabel('enableBusinessCustomers')), new CheckboxField('enablePackstation', $this->owner->fieldLabel('enablePackstation')), new CheckboxField('demandBirthdayDateOnRegistration', $this->owner->fieldLabel('demandBirthdayDateOnRegistration'))))->setHeadingLevel(4);
     // Build product toggle group
     $productConfigurationField = ToggleCompositeField::create('ProductConfiguration', $this->owner->fieldLabel('ProductConfiguration'), array(new CheckboxField('enableStockManagement', $this->owner->fieldLabel('enableStockManagement')), new CheckboxField('isStockManagementOverbookable', $this->owner->fieldLabel('isStockManagementOverbookable')), new TextField('productsPerPage', $this->owner->fieldLabel('productsPerPage')), new TextField('productGroupsPerPage', $this->owner->fieldLabel('productGroupsPerPage')), new TextField('displayedPaginationPages', $this->owner->fieldLabel('displayedPaginationPages')), new UploadField('SilvercartNoImage', $this->owner->fieldLabel('SilvercartNoImage')), new CheckboxField('useStrictSearchRelevance', $this->owner->fieldLabel('useStrictSearchRelevance')), new DropdownField('StandardProductConditionID', $this->owner->fieldLabel('StandardProductConditionID'))))->setHeadingLevel(4);
     // Build checkout toggle group
     $checkoutConfigurationField = ToggleCompositeField::create('CheckoutConfiguration', $this->owner->fieldLabel('CheckoutConfiguration'), array(new CheckboxField('enableSSL', $this->owner->fieldLabel('enableSSL')), new CheckboxField('redirectToCartAfterAddToCart', $this->owner->fieldLabel('redirectToCartAfterAddToCart')), new CheckboxField('redirectToCheckoutWhenInCart', $this->owner->fieldLabel('redirectToCheckoutWhenInCart')), new CheckboxField('useProductDescriptionFieldForCart', $this->owner->fieldLabel('useProductDescriptionFieldForCart')), new DropdownField('productDescriptionFieldForCart', $this->owner->fieldLabel('productDescriptionFieldForCart')), new TextField('addToCartMaxQuantity', $this->owner->fieldLabel('addToCartMaxQuantity')), new CheckboxField('useMinimumOrderValue', $this->owner->fieldLabel('useMinimumOrderValue')), new SilvercartMoneyField('minimumOrderValue', $this->owner->fieldLabel('minimumOrderValue')), new CheckboxField('useFreeOfShippingCostsFrom', $this->owner->fieldLabel('useFreeOfShippingCostsFrom')), new SilvercartMoneyField('freeOfShippingCostsFrom', $this->owner->fieldLabel('freeOfShippingCostsFrom')), new CheckboxField('SkipShippingStepIfUnique', $this->owner->fieldLabel('SkipShippingStepIfUnique')), new CheckboxField('SkipPaymentStepIfUnique', $this->owner->fieldLabel('SkipPaymentStepIfUnique')), new CheckboxField('DisplayWeightsInKilogram', $this->owner->fieldLabel('DisplayWeightsInKilogram')), new CheckboxField('ShowTaxAndDutyHint', $this->owner->fieldLabel('ShowTaxAndDutyHint')), new CheckboxField('InvoiceAddressIsAlwaysShippingAddress', $this->owner->fieldLabel('InvoiceAddressIsAlwaysShippingAddress'))))->setHeadingLevel(4);
     // Build shop data toggle group
     $shopDataConfigurationField = ToggleCompositeField::create('ShopDataConfiguration', $this->owner->fieldLabel('ShopDataConfiguration'), array(new TextField('ShopName', $this->owner->fieldLabel('ShopName')), new TextField('ShopStreet', $this->owner->fieldLabel('ShopStreet')), new TextField('ShopStreetNumber', $this->owner->fieldLabel('ShopStreetNumber')), new TextField('ShopPostcode', $this->owner->fieldLabel('ShopPostcode')), new TextField('ShopCity', $this->owner->fieldLabel('ShopCity')), new DropdownField('ShopCountryID', $this->owner->fieldLabel('ShopCountry'), SilvercartCountry::getPrioritiveDropdownMap())))->setHeadingLevel(4);
     // Build security toggle group
     $securityConfigurationField = ToggleCompositeField::create('SecurityConfiguration', $this->owner->fieldLabel('SecurityConfiguration'), array(new TextareaField('userAgentBlacklist', $this->owner->fieldLabel('userAgentBlacklist'))))->setHeadingLevel(4);
     // Build example data toggle group
     $addExampleDataButton = new InlineFormAction('add_example_data', $this->owner->fieldLabel('addExampleData'));
     $addExampleConfigButton = new InlineFormAction('add_example_config', $this->owner->fieldLabel('addExampleConfig'));
     $exampleDataField = ToggleCompositeField::create('ExampleData', $this->owner->fieldLabel('addExampleData'), array($addExampleDataButton, $addExampleConfigButton))->setHeadingLevel(4);
     $addExampleDataButton->setRightTitle($this->owner->fieldLabel('addExampleDataDesc'));
     $addExampleDataButton->includeDefaultJS(false);
     $addExampleDataButton->setAttribute('data-icon', 'addpage');
     $addExampleConfigButton->setRightTitle($this->owner->fieldLabel('addExampleConfigDesc'));
     $addExampleConfigButton->includeDefaultJS(false);
     $addExampleConfigButton->setAttribute('data-icon', 'addpage');
     // Add groups to Root.Main
     $fields->addFieldToTab('Root.Main', $generalConfigurationField);
     $fields->addFieldToTab('Root.Main', $emailConfigurationField);
     $fields->addFieldToTab('Root.Main', $customerConfigurationField);
     $fields->addFieldToTab('Root.Main', $productConfigurationField);
     $fields->addFieldToTab('Root.Main', $checkoutConfigurationField);
     $fields->addFieldToTab('Root.Main', $shopDataConfigurationField);
     $fields->addFieldToTab('Root.Main', $securityConfigurationField);
     $fields->addFieldToTab('Root.Main', $exampleDataField);
     // Modify field data
     $fields->dataFieldByName('DefaultLocale')->setTitle($this->owner->fieldLabel('DefaultLocale'));
     $fields->dataFieldByName('EmailSender')->setRightTitle($this->owner->fieldLabel('EmailSenderRightTitle'));
     $fields->dataFieldByName('GlobalEmailRecipient')->setRightTitle($this->owner->fieldLabel('GlobalEmailRecipientRightTitle'));
     $fields->dataFieldByName('DefaultMailRecipient')->setRightTitle($this->owner->fieldLabel('DefaultMailRecipientRightTitle'));
     $fields->dataFieldByName('DefaultMailOrderNotificationRecipient')->setRightTitle($this->owner->fieldLabel('DefaultMailOrderNotificationRecipientRightTitle'));
     $fields->dataFieldByName('DefaultContactMessageRecipient')->setRightTitle($this->owner->fieldLabel('DefaultContactMessageRecipientRightTitle'));
     $fields->dataFieldByName('userAgentBlacklist')->setRightTitle($this->owner->fieldLabel('userAgentBlacklistRightTitle'));
     // Add i18n to DefaultPriceType source
     $i18nForDefaultPriceTypeField = array();
     foreach ($this->owner->dbObject('DefaultPriceType')->enumValues() as $value => $label) {
         $i18nForDefaultPriceTypeField[$value] = _t('SilvercartCustomer.' . strtoupper($label), $label);
     }
     $fields->dataFieldByName('DefaultPriceType')->setSource($i18nForDefaultPriceTypeField);
     // Add i18n to productDescriptionFieldForCart source
     $i18nForProductDescriptionField = array();
     foreach ($this->owner->dbObject('productDescriptionFieldForCart')->enumValues() as $productDescriptionField) {
         $i18nForProductDescriptionField[$productDescriptionField] = singleton('SilvercartProduct')->fieldLabel($productDescriptionField);
     }
     $fields->dataFieldByName('productDescriptionFieldForCart')->setSource($i18nForProductDescriptionField);
     $fields->dataFieldByName('StandardProductConditionID')->setEmptyString($this->owner->fieldLabel('StandardProductConditionEmptyString'));
     $this->getCMSFieldsForColorScheme($fields);
     return $fields;
 }