/**
  * 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('SilvercartProductImageAdmin.Description');
     $descriptionField = new SilvercartAlertInfoField('SilvercartProductImagesDescription', str_replace(PHP_EOL, '<br/>', $desc));
     $uploadField = new UploadField('SilvercartProductImages', _t('SilvercartProductImageAdmin.UploadProductImages', 'Upload product images'));
     $uploadField->setFolderName(SilvercartProductImageImporter::get_relative_upload_folder());
     $fields->push($uploadField);
     $fields->push($descriptionField);
     if (!SilvercartProductImageImporter::is_installed()) {
         $cronTitle = _t('SilvercartProductImageAdmin.CronNotInstalledTitle') . ':';
         $cron = _t('SilvercartProductImageAdmin.CronNotInstalledDescription');
         $cronjobInfoField = new SilvercartAlertDangerField('SilvercartProductImagesCronjobInfo', str_replace(PHP_EOL, '<br/>', $cron), $cronTitle);
         $fields->insertAfter('SilvercartProductImages', $cronjobInfoField);
     } elseif (SilvercartProductImageImporter::is_running()) {
         $cronTitle = _t('SilvercartProductImageAdmin.CronIsRunningTitle') . ':';
         $cron = _t('SilvercartProductImageAdmin.CronIsRunningDescription');
         $cronjobInfoField = new SilvercartAlertSuccessField('SilvercartProductImagesCronjobInfo', str_replace(PHP_EOL, '<br/>', $cron), $cronTitle);
         $fields->insertAfter('SilvercartProductImages', $cronjobInfoField);
     }
     $uploadedFiles = $this->getUploadedFiles();
     if (count($uploadedFiles) > 0) {
         $uploadedFilesInfo = '<br/>' . implode('<br/>', $uploadedFiles);
         $fileInfoField = new SilvercartAlertWarningField('SilvercartProductImagesFileInfo', $uploadedFilesInfo, _t('SilvercartProductImageAdmin.FileInfoTitle'));
         $fields->insertAfter('SilvercartProductImages', $fileInfoField);
     }
     $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;
 }
 public function getCMSFields($params = null)
 {
     //fields that shouldn't be changed once coupon is used
     $fields = new FieldList(array($tabset = new TabSet("Root", $maintab = new Tab("Main", TextField::create("Title"), CheckboxField::create("Active", "Active")->setDescription("Enable/disable all use of this discount."), HeaderField::create("ActionTitle", "Action", 3), $typefield = SelectionGroup::create("Type", array(new SelectionGroup_Item("Percent", $percentgroup = FieldGroup::create($percentfield = NumericField::create("Percent", "Percentage", "0.00")->setDescription("e.g. 0.05 = 5%, 0.5 = 50%, and 5 = 500%"), $maxamountfield = CurrencyField::create("MaxAmount", _t("MaxAmount", "Maximum Amount"))->setDescription("The total allowable discount. 0 means unlimited.")), "Discount by percentage"), new SelectionGroup_Item("Amount", $amountfield = CurrencyField::create("Amount", "Amount", "\$0.00"), "Discount by fixed amount")))->setTitle("Type"), OptionSetField::create("For", "Applies to", array("Order" => "Entire Order", "Cart" => "Cart Subtotal", "Shipping" => "Shipping Subtotal", "Items" => "Each Individual Item")), new Tab("Main", HeaderField::create("ConstraintsTitle", "Constraints", 3), LabelField::create("ConstraintsDescription", "Configure the requirements an order must meet for this discount to be valid:")), new TabSet("Constraints")))));
     if (!$this->isInDB()) {
         $fields->addFieldToTab("Root.Main", LiteralField::create("SaveNote", "<p class=\"message good\">More constraints will show up after you save for the first time.</p>"), "Constraints");
     }
     if ($count = $this->getUseCount()) {
         $fields->addFieldsToTab("Root.Usage", array(HeaderField::create("UseCount", sprintf("This discount has been used {$count} time%s.", $count > 1 ? "s" : "")), GridField::create("Orders", "Orders", $this->getAppliedOrders(), GridFieldConfig_RecordViewer::create()->removeComponentsByType("GridFieldViewButton"))));
     }
     if ($params && isset($params['forcetype'])) {
         $valuefield = $params['forcetype'] == "Percent" ? $percentfield : $amountfield;
         $fields->insertAfter($valuefield, "Type");
         $fields->makeFieldReadonly("Type");
     } else {
         if ($this->Type && (double) $this->{$this->Type}) {
             $valuefield = $this->Type == "Percent" ? $percentfield : $amountfield;
             $fields->makeFieldReadonly("Type");
             $fields->insertAfter($valuefield, "ActionTitle");
             $fields->replaceField($this->Type, $valuefield->performReadonlyTransformation());
             if ($this->Type == "Percent") {
                 $fields->insertAfter($maxamountfield, "Percent");
             }
         }
     }
     $this->extend("updateCMSFields", $fields, $params);
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->Form() && $this->owner->Form() instanceof UserDefinedPaymentForm) {
         $fields->insertAfter(new CheckboxField('SendCreated', _t('UserDefinedPaymentForm.SendCreated', 'Send email for transactions that are saved as Created')), "SendPlain");
         $fields->insertAfter(new CheckboxField('SendAuthorized', _t('UserDefinedPaymentForm.SendAuthorized', 'Send email for transactions that are saved as Authorized')), "SendCreated");
         $fields->insertAfter(new CheckboxField('SendCaptured', _t('UserDefinedPaymentForm.SendCaptured', 'Send email for transactions that are saved as Captured')), "SendAuthorized");
         $fields->insertAfter(new CheckboxField('SendRefunded', _t('UserDefinedPaymentForm.SendRefunded', 'Send email for transactions that are saved as Refunded')), "SendCaptured");
         $fields->insertAfter(new CheckboxField('SendVoid', _t('UserDefinedPaymentForm.SendVoid', 'Send email for transactions that are saved as Void')), "SendRefunded");
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     $group = Group::get()->filter(array('code' => BlogEntry::config()->defaultGroup))->first();
     $contentAuthors = $group->Members()->map('ID', 'Title');
     $fields->insertAfter(HTMLEditorField::create("Summary")->setRows(4), "Content");
     $fields->insertAfter(UploadField::create("FeatureImage"), "Summary");
     $fields->insertAfter(DropdownField::create('AuthorMemberID', 'Author (Member)', $contentAuthors)->setEmptyString('(Select one)'), 'Date');
     $fields->removeByName('Author');
     $fields->insertAfter(TextField::create('Author', "Guest Author"), "AuthorMemberID");
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->removeByName('LastSignificantChange');
     $fields->removeByName('ChangeDescription');
     if ($this->owner->LastSignificantChange !== NULL) {
         $dateTime = new DateTime($this->owner->LastSignificantChange);
         //Put these fields on the top of the First Tab's form
         $fields->first()->Tabs()->first()->getChildren()->unshift(LabelField::create("infoLastSignificantChange", "<strong>Last Significant change was at: " . "{$dateTime->Format('d/m/Y H:i')}</strong>"));
         $fields->insertAfter(CheckboxField::create("isSignificantChange", "CLEAR Last Significant change: {$dateTime->Format('d/m/Y H:i')}")->setDescription('Check and save this Record again to clear the Last Significant change date.')->setValue(FALSE), 'infoLastSignificantChange');
         $fields->insertAfter(TextField::create('ChangeDescription', 'Description of Changes')->setDescription('This is an automatically generated list of changes to important fields.'), 'isSignificantChange');
     }
 }
 /**
  * Add URL field and a read-only External ID field to CMS form.
  *
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $descriptionFieldName = $this->getModelFieldName(self::DescriptionFieldName);
     $fields->insertBefore(new TextField($this->linkFieldName(), 'Feed URL'), $descriptionFieldName);
     $fields->insertAfter(new DropdownField(self::FeedTypeFieldName, 'Type', static::feed_types()), $descriptionFieldName);
     $fields->insertAfter($field = new TextField(self::XPathFieldName, 'XPath'), $descriptionFieldName);
     $field->setAttribute('placeholder', $this->defaultXPath());
     $fields->insertAfter(new CheckboxField(self::ValidateFeedFieldName, 'Validate feed', true), $descriptionFieldName);
     if ($idFieldName = $this->externalIDFieldName()) {
         if ($externalID = $this->owner->{$idFieldName}) {
             $fields->push(new LiteralField($externalID, 'Feed ID', "<p>{$externalID}</p>"));
         }
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->ID) {
         $srcTags = function () {
             $tags = array();
             foreach (DMSTag::get() as $t) {
                 $tags[$t->ID] = $t->Category . ($t->isValueDefined() ? ' -> ' . $t->Value : '');
             }
             return $tags;
         };
         $selectTags = ListboxField::create('DocumentTags', _t('DMSDocumentExtension.Tags', 'Tags'), $srcTags(), implode(',', $this->owner->Tags()->column()), null, true)->useAddNew('DMSTag', $srcTags, FieldList::create(TextField::create('Category', _t('DMSDocumentExtension.Category', 'Category *')), TextField::create('Value', _t('DMSDocumentExtension.Value', 'Value')), HiddenField::create('MultiValue', null, 1)));
         $fields->insertAfter($selectTags, 'Description');
         $fields->insertAfter(CheckboxField::create('ShowTagsFrontend', _t('DMSDocumentExtension.ShowTagsFrontend', 'Show document tags in frontend?')), 'DocumentTags');
     }
 }
Example #8
0
 public function updateCMSFields(FieldList $fields)
 {
     $logo = $fields->dataFieldByName('Logo');
     $fields->removeByName('ParentID');
     $fields->removeByName('Sort');
     $fields->insertAfter($logo, 'Title');
 }
 public function updateFieldsForFile(FieldList $fields, $url, $file)
 {
     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_' . $file->ID . '" src="/' . $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->fieldByName('FilePreview.FilePreviewImage.AviaryEditImageWrapper') && ($previewRoot = $fields->fieldByName('FilePreview.FilePreviewImage.ImageFull'))) {
         $fields->insertAfter(CompositeField::create($editButton)->setName('AviaryEditImageWrapper'), $previewRoot->getName());
         $fields->insertAfter($aviaryImage, 'FilePreviewImage');
     }
 }
 /**
  * Adds the field editor to the page.
  *
  * @return FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     $fieldEditor = $this->getFieldEditorGrid();
     $fields->insertAfter(new Tab('FormFields', _t('UserFormFieldEditorExtension.FORMFIELDS', 'Form Fields')), 'Main');
     $fields->addFieldToTab('Root.FormFields', $fieldEditor);
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->removeByName(array('Lat', 'Lng'));
     // Adds Lat/Lng fields for viewing in the CMS
     $compositeField = CompositeField::create();
     $compositeField->push($overrideField = CheckboxField::create('LatLngOverride', 'Override Latitude and Longitude?'));
     $overrideField->setDescription('Check this box and save to be able to edit the latitude and longitude manually.');
     if ($this->owner->Lng && $this->owner->Lat) {
         $googleMapURL = 'http://maps.google.com/?q=' . $this->owner->Lat . ',' . $this->owner->Lng;
         $googleMapDiv = '<div class="field"><label class="left" for="Form_EditForm_MapURL_Readonly">Google Map</label><div class="middleColumn"><a href="' . $googleMapURL . '" target="_blank">' . $googleMapURL . '</a></div></div>';
         $compositeField->push(LiteralField::create('MapURL_Readonly', $googleMapDiv));
     }
     if ($this->owner->LatLngOverride) {
         $compositeField->push(TextField::create('Lat', 'Lat'));
         $compositeField->push(TextField::create('Lng', 'Lng'));
     } else {
         $compositeField->push(ReadonlyField::create('Lat_Readonly', 'Lat', $this->owner->Lat));
         $compositeField->push(ReadonlyField::create('Lng_Readonly', 'Lng', $this->owner->Lng));
     }
     if ($this->owner->hasExtension('Addressable')) {
         // If using addressable, put the fields with it
         $fields->addFieldToTab('Root.Address', ToggleCompositeField::create('Coordinates', 'Coordinates', $compositeField));
     } else {
         if ($this->owner instanceof SiteTree) {
             // If SIteTree but not using Addressable, put after 'Metadata' toggle composite field
             $fields->insertAfter($compositeField, 'ExtraMeta');
         } else {
             $fields->addFieldToTab('Root.Main', ToggleCompositeField::create('Coordinates', 'Coordinates', $compositeField));
         }
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     $service = ServiceDefinition::get();
     if ($service->Count() > 0) {
         $fields->insertAfter($serviceOptions = new DropdownField('ServiceID', 'Service', $service->map('ID', 'Title')), 'Title');
         $serviceOptions->setEmptyString(' ');
     } else {
         $fields->removeByName('ServiceID');
     }
     $type = TypeDefinition::get();
     if ($type->Count() > 0) {
         $fields->insertAfter($typeOptions = new DropdownField('TypeID', 'Type', $type->map('ID', 'Title')), 'Title');
         $typeOptions->setEmptyString(' ');
     } else {
         $fields->removeByName('TypeID');
     }
 }
 /**
  * Add fields for this discount to CMS form.
  *
  * @param FieldList $fields
  */
 public function updateProductCMSFields(FieldList $fields)
 {
     array_map(function ($fieldName) use(&$fields) {
         if ($fieldName) {
             $fields->insertAfter(new NumericField($fieldName, $this->fieldLabel($fieldName)), 'Price');
         }
     }, array_keys(static::field_specs()));
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner instanceof SiteTree) {
         $tabName = "Root.Main";
         $fieldName = "FeaturedProduct";
         if (!$this->owner->Variations()->exists()) {
             $fields->addFieldToTab($tabName, new NumericField('Stock', 'Stock'), $fieldName);
             $fields->addFieldToTab($tabName, new CheckboxField('UnlimitedStock', 'Unlimited Stock? (over-rides Stock field above)'), $fieldName);
         } else {
             $fields->addFieldToTab($tabName, new LiteralField('note', '<p>Because you have one or more variations, the stock is a calculation of all stock levels</p><h4>Total Variations in Stock: ' . $this->getVariationsStock() . '</h4>'), $fieldName);
         }
     } else {
         // it's a variation and hopefully has fields
         $fields->insertAfter(new NumericField('Stock', 'Stock'), "Price");
         $fields->insertAfter(new CheckboxField('UnlimitedStock', 'Unlimited Stock? (over-rides Stock field above)'), "Stock");
     }
 }
 public function __construct($controller, $name)
 {
     $fields = new FieldList(TextField::create("Name"), EmailField::create("Email")->setAttribute('type', 'email'), TextareaField::create("Company", "Message")->setAttribute('autocomplete', 'no'), TextareaField::create("EmailMessage", "Company")->addExtraClass("honeypot")->setAttribute('autocomplete', 'no'));
     if (!class_exists('FormSpamProtectionExtension')) {
         $fields->insertAfter(HiddenField::create("TimeLog", '', time()), 'EmailMessage');
     }
     $actions = new FieldList(FormAction::create("doSubmit")->setTitle("Submit")->addExtraClass('button')->setUseButtonTag(true));
     parent::__construct($controller, $name, $fields, $actions);
 }
 public function getCMSFields()
 {
     $fields = new FieldList(TextField::create("Title"), TextField::create("Unit"), DropdownField::create("ValueType", "Value Type", $this->dbObject('ValueType')->enumValues()));
     $groups = FeatureGroup::get();
     if ($groups->exists()) {
         $fields->insertAfter(DropdownField::create("GroupID", "Group", $groups->map()->toArray())->setHasEmptyDefault(true), "Unit");
     }
     return $fields;
 }
 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));
     }
 }
Example #18
0
 public function updateCMSFields(FieldList $fields)
 {
     $details = $fields->dataFieldByName('Details');
     $event = $fields->dataFieldByName('EventPageID');
     $cID = Calendar::get_one('Calendar')->ID;
     $fields->push($calendar = HiddenField::create('CalendarID', 'Calendar'));
     $calendar->setValue($cID);
     $fields->insertAfter($event, 'TimeFrameType');
     $fields->insertAfter($region = DropdownField::create('RegionID', 'Region', Region::get()->map('ID', 'Title')), 'EventPageID');
     $region->setEmptyString(' ');
     $fields->removeByName('RelatedPage');
     $fields->addFieldToTab('Root.Details', TextareaField::create('Intro', 'Intro'));
     $fields->insertAfter($details, 'Intro');
     $fields->addFieldToTab('Root.Brand', ColorPaletteField::create("Colour", "Colour", $this->owner->getPalette()));
     $fields->insertAfter($splash = UploadField::create('SplashImage', 'Splash Image'), 'Colour');
     $fields->insertAfter($small = UploadField::create('SmallImage', 'Small Image'), 'SplashImage');
     $splash->setFolderName('Uploads/Splash-Images');
     $small->setFolderName('Uploads/Small-Images');
 }
    public function updateCMSFields(FieldList $fields)
    {
        Requirements::javascript('marketplace/code/ui/admin/js/openstack.release.supported.api.version.admin.ui.js');
        $fields->removeByName('ApiVersionID');
        $versions = OpenStackApiVersion::get()->map('ID', 'Version');
        $ddl = new DropdownField('ApiVersionID', 'API Version', $versions);
        $ddl->addExtraClass('ddl-api-version-id');
        $ddl->setEmptyString('--Select An API Version --');
        $fields->insertAfter($ddl, 'OpenStackComponentID');
        $versions = array();
        foreach (OpenStackComponent::get()->filter('SupportsVersioning', true) as $component) {
            foreach ($component->getVersions() as $version) {
                if (!array_key_exists(intval($component->getIdentifier()), $versions)) {
                    $versions[intval($component->getIdentifier())] = array();
                }
                array_push($versions[intval($component->getIdentifier())], array('value' => intval($version->getIdentifier()), 'text' => $version->getVersion()));
            }
        }
        $json_data = json_encode($versions);
        $script = <<<JS
\t\t<script>
\t\tvar versions = {$json_data};
\t\t</script>
JS;
        $fields->add(new LiteralField('js_data', $script));
        $fields->removeByName('OpenStackComponentID');
        //kludge; get parent id from url....
        $url = preg_split('/\\//', $_REQUEST['url']);
        $release_id = (int) $url[8];
        //components
        $components = OpenStackComponent::get()->filter('SupportsVersioning', true)->innerJoin('OpenStackRelease_OpenStackComponents', "OpenStackRelease_OpenStackComponents.OpenStackComponentID = OpenStackComponent.ID AND OpenStackReleaseID = {$release_id} ");
        $components_source = array();
        foreach ($components as $comp) {
            $components_source[$comp->ID] = sprintf('%s (%s)', $comp->Name, $comp->CodeName);
        }
        $ddl = new DropdownField('OpenStackComponentID', 'OpenStack Component', $components_source);
        $ddl->setEmptyString('--Select A OS Component--');
        $ddl->addExtraClass('ddl-os-component-id');
        $fields->insertBefore($ddl, 'ApiVersionID');
        $fields->insertAfter(new TextField("ReleaseVersion", "Release Version"), 'ReleaseID');
        $fields->insertAfter(new LiteralField('ReleaseVersionTitle', '<p>You could get this data from <a href="http://docs.openstack.org/releases" target="_blank">http://docs.openstack.org/releases</a></p>'), 'ReleaseVersion');
        return $fields;
    }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->insertBefore(TextField::create("PersonalTitle", "Title (Dr., Hon. etc.)"), "FirstName");
     $fields->insertAfter(TextField::create("Credentials"), "Surname");
     $fields->insertAfter(TextField::create("JobTitle", "Job Title"), "Credientials");
     $fields->insertAfter(TextField::create("Role"), "JobTitle");
     $fields->insertAfter(TextField::create("Twitter", "Twitter User Name")->setDescription("Do NOT include the '@'"), "Email");
     $fields->insertAfter(TextField::create("Facebook", "Facebook Page or Profile"), "Twitter");
     $fields->insertAfter(TextField::create("GooglePlus", "Google+ Profile"), "Facebook");
     $fields->insertAfter(UploadField::create("Headshot"), "GooglePlus");
     $fields->insertAfter(HTMLEditorField::create("Bio"), "Headshot");
 }
Example #21
0
 /**
  * This is responsible for adding the child pages tab and gridfield.
  *
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $excluded = $this->owner->getExcludedSiteTreeClassNames();
     if (!empty($excluded)) {
         $pages = SiteTree::get()->filter(array('ParentID' => $this->owner->ID, 'ClassName' => $excluded));
         $gridField = new GridField("ChildPages", $this->getLumberjackTitle(), $pages, $this->getLumberjackGridFieldConfig());
         $tab = new Tab('ChildPages', $this->getLumberjackTitle(), $gridField);
         $fields->insertAfter($tab, 'Main');
     }
 }
 /**
  * Updates the form fields for address'es to use a dropdown for the state and an additional field for the other state
  * @param {FieldList} $fields Fields to modify
  */
 public function updateFormFields(FieldList $fields)
 {
     $stateField = $fields->dataFieldByName('State');
     if ($stateField) {
         $newStateField = new GroupedDropdownField('State', $stateField->Title, array(_t('FedExStateProvinceExtension.UNITED_STATES', '_United States') => array('AL' => _t('FedExStateProvinceExtension.US_AL', '_Alabama'), 'LA' => _t('FedExStateProvinceExtension.US_LA', '_Louisiana'), 'OK' => _t('FedExStateProvinceExtension.US_OK', '_Oklahoma'), 'AK' => _t('FedExStateProvinceExtension.US_AK', '_Alaska'), 'ME' => _t('FedExStateProvinceExtension.US_ME', '_Maine'), 'OR' => _t('FedExStateProvinceExtension.US_OR', '_Oregon'), 'AZ' => _t('FedExStateProvinceExtension.US_AZ', '_Arizona'), 'MD' => _t('FedExStateProvinceExtension.US_MD', '_Maryland'), 'PA' => _t('FedExStateProvinceExtension.US_PA', '_Pennsylvania'), 'AR' => _t('FedExStateProvinceExtension.US_AR', '_Arkansas'), 'MA' => _t('FedExStateProvinceExtension.US_MA', '_Massachusetts'), 'RI' => _t('FedExStateProvinceExtension.US_RI', '_Rhode Island'), 'CA' => _t('FedExStateProvinceExtension.US_CA', '_California'), 'MI' => _t('FedExStateProvinceExtension.US_MI', '_Michigan'), 'SC' => _t('FedExStateProvinceExtension.US_SC', '_South Carolina'), 'CO' => _t('FedExStateProvinceExtension.US_CO', '_Colorado'), 'MN' => _t('FedExStateProvinceExtension.US_MN', '_Minnesota'), 'SD' => _t('FedExStateProvinceExtension.US_SD', '_South Dakota'), 'CT' => _t('FedExStateProvinceExtension.US_CT', '_Connecticut'), 'MS' => _t('FedExStateProvinceExtension.US_MS', '_Mississippi'), 'TN' => _t('FedExStateProvinceExtension.US_TN', '_Tennessee'), 'DE' => _t('FedExStateProvinceExtension.US_DE', '_Delaware'), 'MO' => _t('FedExStateProvinceExtension.US_MO', '_Missouri'), 'TX' => _t('FedExStateProvinceExtension.US_TX', '_Texas'), 'DC' => _t('FedExStateProvinceExtension.US_DC', '_District of Columbia'), 'MT' => _t('FedExStateProvinceExtension.US_MT', '_Montana'), 'UT' => _t('FedExStateProvinceExtension.US_UT', '_Utah'), 'FL' => _t('FedExStateProvinceExtension.US_FL', '_Florida'), 'NE' => _t('FedExStateProvinceExtension.US_NE', '_Nebraska'), 'VT' => _t('FedExStateProvinceExtension.US_VT', '_Vermont'), 'GA' => _t('FedExStateProvinceExtension.US_GA', '_Georgia'), 'NV' => _t('FedExStateProvinceExtension.US_NV', '_Nevada'), 'VA' => _t('FedExStateProvinceExtension.US_VA', '_Virginia'), 'HI' => _t('FedExStateProvinceExtension.US_HI', '_Hawaii'), 'NH' => _t('FedExStateProvinceExtension.US_NH', '_New Hampshire'), 'WA' => _t('FedExStateProvinceExtension.US_WA', '_Washington State'), 'ID' => _t('FedExStateProvinceExtension.US_ID', '_Idaho'), 'NJ' => _t('FedExStateProvinceExtension.US_NJ', '_New Jersey'), 'WV' => _t('FedExStateProvinceExtension.US_WV', '_West Virginia'), 'IL' => _t('FedExStateProvinceExtension.US_IL', '_Illinois'), 'NM' => _t('FedExStateProvinceExtension.US_NM', '_New Mexico'), 'WI' => _t('FedExStateProvinceExtension.US_WI', '_Wisconsin'), 'IN' => _t('FedExStateProvinceExtension.US_IN', '_Indiana'), 'NY' => _t('FedExStateProvinceExtension.US_NY', '_New York'), 'WY' => _t('FedExStateProvinceExtension.US_WY', '_Wyoming'), 'IA' => _t('FedExStateProvinceExtension.US_IA', '_Iowa'), 'NC' => _t('FedExStateProvinceExtension.US_NC', '_North Carolina'), 'PR' => _t('FedExStateProvinceExtension.US_PR', '_Puerto Rico'), 'KS' => _t('FedExStateProvinceExtension.US_KS', '_Kansas'), 'ND' => _t('FedExStateProvinceExtension.US_ND', '_North Dakota'), 'KY' => _t('FedExStateProvinceExtension.US_KY', '_Kentucky'), 'OH' => _t('FedExStateProvinceExtension.US_OH', '_Ohio')), _t('FedExStateProvinceExtension.CANADA', '_Canada') => array('AB' => _t('FedExStateProvinceExtension.CA_AB', '_Alberta'), 'BC' => _t('FedExStateProvinceExtension.CA_BC', '_British Columbia'), 'MB' => _t('FedExStateProvinceExtension.CA_MB', '_Manitoba'), 'NB' => _t('FedExStateProvinceExtension.CA_NB', '_New Brunswick'), 'NL' => _t('FedExStateProvinceExtension.CA_NL', '_Newfoundland'), 'NT' => _t('FedExStateProvinceExtension.CA_NT', '_Northwest Territories and Labrador'), 'NS' => _t('FedExStateProvinceExtension.CA_NS', '_Nova Scotia'), 'NU' => _t('FedExStateProvinceExtension.CA_NU', '_Nunavut'), 'ON' => _t('FedExStateProvinceExtension.CA_ON', '_Ontario'), 'PE' => _t('FedExStateProvinceExtension.CA_PE', '_Prince Edward Island'), 'QC' => _t('FedExStateProvinceExtension.CA_QC', '_Quebec'), 'SK' => _t('FedExStateProvinceExtension.CA_SK', '_Saskatchewan'), 'YT' => _t('FedExStateProvinceExtension.CA_YT', '_Yukon')), '' => _t('FedExStateProvinceExtension.OTHER', '_Other')));
         $newStateField->setDescription = $stateField->getDescription();
         $newStateField->setForm($stateField->getForm());
         $fields->replaceField('State', $newStateField);
         $fields->insertAfter($otherState = new TextField('OtherState', _t('FedExStateProvinceExtension.OTHER_STATE', '_Other State'), null, 200), 'State');
         $otherState->setDescription(_t('FedExStateProvinceExtension.OTHER_DESC', '_If you chose other as your state please place it here'));
         $otherState->setForm($stateField->getForm());
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->stat('box_limit')) {
         $fields->insertAfter(new Tab('PromoBoxes'), 'Main');
         //content boxes
         $boxes = PromoBox::get();
         $aBoxes = $this->PromoBoxes()->toArray();
         $dropBoxes = $boxes->map();
         for ($i = 0; $i < $this->stat('box_limit'); $i++) {
             $value = !empty($aBoxes[$i]) ? $aBoxes[$i]->ID : null;
             $fields->addFieldToTab('Root.PromoBoxes', new DropdownField("PromoBoxes[{$i}]", 'Promo Box ' . ($i + 1), $dropBoxes, $value, null, 'No Box'));
         }
     }
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->insertAfter(TextField::create("Website"), "Email");
     $fields->insertAfter(TextField::create("Twitter", "Twitter User Name")->setDescription("Do NOT include the '@'"), "Website");
     $fields->insertAfter(TextField::create("Facebook", "Facebook Page or Profile"), "Twitter");
     $fields->insertAfter(TextField::create("GooglePlus", "Google+ Profile"), "Facebook");
     $fields->insertAfter(UploadField::create("Headshot"), "Facebook");
     $fields->insertAfter(HTMLEditorField::create("Bio"), "Headshot");
 }
 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;
 }
 /**
  * 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)
 {
     //change Page Name label to Primary Heading - H1 - Only if the title hasn't already been changed
     /** @var TextField $titleField */
     $titleField = $fields->dataFieldByName('Title');
     if ($titleField->Title() == 'Page name') {
         $fields->renameField('Title', 'Primary Heading');
     }
     //Add secondary heading - H2
     $fields->insertAfter(TextField::create('SubTitle', 'Secondary Heading'), 'Title');
     $traits = $this->traitsUsedRecursive($this->owner->ClassName);
     if ($this->owner->config()->get('has_on_after_update_cms_fields')) {
         $traits[] = 'HasOnAfterUpdateCMSFieldsExtensionPoint';
     }
     if (!in_array('HasOnAfterUpdateCMSFieldsExtensionPoint', $traits)) {
         $this->afterUpdateCMSFields($fields);
     }
 }
 function updateCMSFields(FieldList $fields)
 {
     $fields->insertAfter($tabset = new TabSet('ColoredImages'), 'Image');
     $tabset->push($uploadtab = new Tab('UploadImages'));
     $tabset->push($attributetab = new Tab('AssignAttribute'));
     $uploadtab->push($uf = new UploadField('Images', 'Images'));
     $uf->setDescription('Note: The product must be saved before attributes can be assigned to new uploaded images.');
     $attributetab->push($gf = GridField::create("ImageAttributes", "Images", $this->owner->Images(), GridFieldConfig_RelationEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldEditButton")->removeComponentsByType("GridFieldDataColumns")->removeComponentsByType("GridFieldDeleteAction")->addComponent($cols = new GridFieldEditableColumns())->addComponent(new GridFieldOrderableRows('Sort'))));
     $displayfields = array('Title' => array('title' => 'Title', 'field' => new ReadonlyField("Name")));
     //add drop-down color selection
     $colors = $this->owner->getColors();
     if ($colors->exists()) {
         $displayfields['ColorID'] = function ($record, $col, $grid) use($colors) {
             return DropdownField::create($col, "Color", $colors->map('ID', 'Value')->toArray())->setHasEmptyDefault(true);
         };
     }
     $cols->setDisplayFields($displayfields);
 }
    public function updateCMSFields(FieldList $fields)
    {
        //change Page Name label to Primary Heading - H1 - Only if the title hasn't already been changed
        /** @var TextField $titleField */
        $titleField = $fields->dataFieldByName('Title');
        if ($titleField->Title() == 'Page Name') {
            $fields->renameField('Title', 'Primary Heading');
        }
        //Add secondary heading - H2
        $fields->insertAfter(TextField::create('SubTitle', 'Secondary Heading'), 'Title');
        //Move meta fields to their own tab
        /** @var ToggleCompositeField $metaDataChildren */
        $metaDataChildren = $fields->fieldByName('Root.Main.Metadata');
        $children = array_merge([$metaTitle = TextField::create('MetaTitle')], $metaDataChildren->getChildren()->toArray());
        $fields->removeFieldFromTab('Root.Main', 'Metadata');
        $fields->addFieldToTab('Root', Tab::create('Metadata'), 'Content');
        //Add META Title tag to METADATA
        $fields->addFieldsToTab('Root.Metadata', $children);
        $metaTitle->setDescription('Displayed as the tab/window name; Also displayed in search engine result listings as the page title.<br />
									Falls back to the Primary Heading field if not provided.');
    }
 /**
  * Form used for defining the conversion form
  * @return {Form} Form to be used for configuring the conversion
  */
 public function ConvertObjectForm()
 {
     //Verify the record exists before proceeding
     if (empty($this->record) || $this->record === false || !$this->record->exists()) {
         return $this->httpError(404, _t('KapostAdmin.KAPOST_CONTENT_NOT_FOUND', '_Incoming Kapost Content could not be found'));
     }
     //Reset the reading stage
     Versioned::reset();
     $fields = new FieldList($wrapper = CompositeField::create(CompositeField::create($convertModeField = new OptionsetField('ConvertMode', '', array('ReplacePage' => _t('KapostAdmin.REPLACES_AN_EXISTING_PAGE', '_This replaces an existing page'), 'NewPage' => _t('KapostAdmin.IS_NEW_PAGE', '_This is a new page')), 'NewPage'))->addExtraClass('kapostConvertLeftSide noborder')->setName('kapostConvertLeftSide'), CompositeField::create($replacePageField = TreeDropdownField::create('ReplacePageID', _t('KapostAdmin.REPLACE_PAGE', '_Replace this page'), 'SiteTree')->addExtraClass('replace-page-id'), TreeDropdownField::create('ParentPageID', _t('KapostAdmin.USE_AS_PARENT', '_Use this page as the parent for the new page, leave empty for a top level page'), 'SiteTree')->addExtraClass('parent-page-id'))->addExtraClass('kapostConvertRightSide')->setName('kapostConvertRightSide'))->addExtraClass('kapostConvertTypeWrap')->setName('kapostConvertTypeWrap'));
     $actions = new FieldList(FormAction::create('doConvertObject', _t('KapostAdmin.CONTINUE_CONVERT', '_Continue'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'kapost-convert'));
     $validator = new RequiredFields('ConvertMode');
     $form = new Form($this, 'ConvertObjectForm', $fields, $actions, $validator);
     $form->addExtraClass('KapostAdmin center')->setAttribute('data-layout-type', 'border')->setTemplate('KapostAdmin_ConvertForm');
     //Handle pages to see if the page exists
     $convertToClass = $this->getDestinationClass();
     if ($convertToClass !== false && ($convertToClass == 'SiteTree' || is_subclass_of($convertToClass, 'SiteTree'))) {
         $obj = SiteTree::get()->filter('KapostRefID', Convert::raw2sql($this->record->KapostRefID))->first();
         if (!empty($obj) && $obj !== false && $obj->ID > 0) {
             $convertModeField->setValue('ReplacePage');
             $replacePageField->setValue($obj->ID);
             $recordTitle = $this->record->Title;
             if (!empty($recordTitle) && $recordTitle != $obj->Title) {
                 $urlFieldLabel = _t('KapostAdmin.TITLE_CHANGE_DETECT', '_The title differs from the page being replaced, it was "{wastitle}" and will be changed to "{newtitle}". Do you want to update the URL Segment?', array('wastitle' => $obj->Title, 'newtitle' => $recordTitle));
                 $fields->insertAfter(CheckboxField::create('UpdateURLSegment', $urlFieldLabel)->addExtraClass('urlsegmentcheck')->setAttribute('data-replace-id', $obj->ID)->setForm($form)->setDescription(_t('KapostAdmin.NEW_URL_SEGMENT', '_The new URL Segment will be or will be close to "{newsegment}"', array('newsegment' => $obj->generateURLSegment($recordTitle)))), 'kapostConvertTypeWrap');
             }
         }
     }
     Requirements::css(KAPOST_DIR . '/css/KapostAdmin.css');
     Requirements::add_i18n_javascript(KAPOST_DIR . '/javascript/lang/');
     Requirements::javascript(KAPOST_DIR . '/javascript/KapostAdmin_convertPopup.js');
     //Allow extensions to adjust the form
     $this->extend('updateConvertObjectForm', $form, $this->record);
     //If we have more than 1 field enable the line below the convert type
     $csrfToken = $form->getSecurityToken();
     if (!$csrfToken instanceof NullSecurityToken && $form->Fields()->count() > 2 || $csrfToken instanceof NullSecurityToken && $form->Fields()->count() > 1) {
         $wrapper->addExtraClass('has-more-fields');
     }
     return $form;
 }