/** * Adds group select fields to CMS * * @param FieldSet $fields * @return void */ public function updateCMSFields(FieldSet &$fields) { // Only modify folder objects with parent nodes if (!$this->owner instanceof Folder || !$this->owner->ID) { return; } // Only allow ADMIN and SECURE_FILE_SETTINGS members to edit these options if (!Permission::checkMember(Member::currentUser(), array('ADMIN', 'SECURE_FILE_SETTINGS'))) { return; } // Update Security Tab $secureFilesTab = $fields->findOrMakeTab('Root.' . _t('SecureFiles.SECUREFILETABNAME', 'Security')); $secureFilesTab->push(new HeaderField(_t('SecureFiles.GROUPACCESSTITLE', 'Group Access'))); $secureFilesTab->push(new TreeMultiselectField('GroupPermissions', _t('SecureFiles.GROUPACCESSFIELD', 'Group Access Permissions'))); if ($this->owner->InheritSecured()) { $permissionGroups = $this->owner->InheritedGroupPermissions(); if ($permissionGroups->Count()) { $fieldText = implode(", ", $permissionGroups->map()); } else { $fieldText = _t('SecureFiles.NONE', "(None)"); } $InheritedGroupsField = new ReadonlyField("InheritedGroupPermissionsText", _t('SecureFiles.GROUPINHERITEDPERMS', 'Inherited Group Permissions'), $fieldText); $InheritedGroupsField->addExtraClass('prependUnlock'); $secureFilesTab->push($InheritedGroupsField); } }
public function Field($properties = array()) { $titleArray = $itemIDs = array(); $titleList = $itemIDsList = ""; if ($items = $this->getItems()) { foreach ($items as $item) { $titleArray[] = $item->Title; } foreach ($items as $item) { $itemIDs[] = $item->ID; } if ($titleArray) { $titleList = implode(", ", $titleArray); } if ($itemIDs) { $itemIDsList = implode(",", $itemIDs); } } $field = new ReadonlyField($this->name . '_ReadonlyValue', $this->title); $field->setValue($titleList); $field->setForm($this->form); $valueField = new HiddenField($this->name); $valueField->setValue($itemIDsList); $valueField->setForm($this->form); return $field->Field() . $valueField->Field(); }
/** * Makes a pretty readonly field with some stars in it */ function performReadonlyTransformation() { $stars = '*****'; $field = new ReadonlyField($this->name, $this->title ? $this->title : '', $stars); $field->setForm($this->form); return $field; }
/** * Returns a readonly version of this field */ function performReadonlyTransformation() { $field = new ReadonlyField($this->name, $this->title, $this->value); $field->addExtraClass($this->extraClass()); $field->setForm($this->form); return $field; }
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 Field($properties = array()) { $content = ''; Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(FRAMEWORK_DIR . "/javascript/ToggleField.js"); if ($this->startClosed) { $this->addExtraClass('startClosed'); } $valforInput = $this->value ? Convert::raw2att($this->value) : ""; $rawInput = Convert::html2raw($valforInput); if ($this->charNum) { $reducedVal = substr($rawInput, 0, $this->charNum); } else { $reducedVal = DBField::create_field('Text', $rawInput)->{$this->truncateMethod}(); } // only create togglefield if the truncated content is shorter if (strlen($reducedVal) < strlen($rawInput)) { $content = <<<HTML \t\t\t<div class="readonly typography contentLess" style="display: none"> \t\t\t\t{$reducedVal} \t\t\t\t <a href="#" class="triggerMore">{$this->labelMore}</a> \t\t\t</div> \t\t\t<div class="readonly typography contentMore"> \t\t\t\t{$this->value} \t\t\t\t <a href="#" class="triggerLess">{$this->labelLess}</a> \t\t\t</div>\t \t\t\t<br /> \t\t\t<input type="hidden" name="{$this->name}" value="{$valforInput}" /> HTML; } else { $this->dontEscape = true; $content = parent::Field(); } return $content; }
/** * Gets the form used for viewing a time log */ public function getEditForm($id = null, $fields = null) { $record = $this->currentPage(); if ($this->action == 'view' && $record) { $fields = new FieldList(new HeaderField('LogHeader', _t('KapostBridgeLogViewer.VIEWING_ENTRY', '_Viewing Log Entry: {datetime}', array('datetime' => $record->dbObject('Created')->FormatFromSettings())), 3), new ReadonlyField('UserAgent', _t('KapostBridgeLogViewer.USER_AGENT', '_Requestor User Agent')), new ReadonlyField('Method', _t('KapostBridgeLogViewer.METHOD', '_Method')), ToggleCompositeField::create('RequestData', _t('KapostBridgeLogViewer.KAPOST_REQUEST', '_Kapost Request'), new FieldList(ReadonlyField::create('RequestFormatted', '')->setTemplate('KapostBridgeLogField')->addExtraClass('log-contents cms-panel-layout')))->setHeadingLevel(3), ToggleCompositeField::create('ResponseData', _t('KapostBridgeLogViewer.SILVERSTRIPE_RESPONSE', '_SilverStripe Response'), new FieldList(ReadonlyField::create('ResponseFormatted', '')->setTemplate('KapostBridgeLogField')->addExtraClass('log-contents cms-panel-layout')))->setHeadingLevel(3)); $refObj = $record->ReferenceObject; if (!empty($refObj) && $refObj !== false && $refObj->exists()) { if (method_exists($refObj, 'CMSEditLink')) { $fields->insertBefore(new KapostLogLinkField('CMSEditLink', _t('KapostBridgeLogViewer.REFERENCED_OBJECT', '_Referenced Object'), $refObj->CMSEditLink(), _t('KapostBridgeLogViewer.VIEW_REFERENCED_OBJECT', '_View Referenced Object')), 'RequestData'); } else { if ($refObj instanceof File) { $refObjLink = Controller::join_links(LeftAndMain::config()->url_base, AssetAdmin::config()->url_segment, 'EditForm/field/File/item', $refObj->ID, 'edit'); $fields->insertBefore(new KapostLogLinkField('CMSEditLink', _t('KapostBridgeLogViewer.REFERENCED_OBJECT', '_Referenced Object'), $refObjLink, _t('KapostBridgeLogViewer.VIEW_REFERENCED_OBJECT', '_View Referenced Object')), 'RequestData'); } } } } else { $fields = new FieldList(); } $form = new CMSForm($this, 'EditForm', $fields, new FieldList()); $form->setResponseNegotiator($this->getResponseNegotiator()); $form->addExtraClass('cms-edit-form center'); $form->setAttribute('data-layout-type', 'border'); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); $form->setAttribute('data-pjax-fragment', 'CurrentForm'); $form->setHTMLID('Form_EditForm'); if ($record) { $form->loadDataFrom($record); } return $form; }
public function updateCMSFields(FieldList $fields) { $extFields = self::$db; $fields->removeByName(array_keys($extFields)); if (!$this->owner->WordpressID) { return; } $compositeFields = array(); foreach ($extFields as $name => $type) { $value = $this->owner->getField($name); $compositeFields[$name] = ReadonlyField::create($name . '_Readonly', FormField::name_to_label($name), $value); } if ($compositeFields) { $wordpressCompositeField = ToggleCompositeField::create('WordpressCompositeField', 'Wordpress', $compositeFields)->setHeadingLevel(4); if ($fields->fieldByName('Metadata')) { $fields->insertBefore($wordpressCompositeField, 'Metadata'); } else { if ($fields->fieldByName('Root')) { $fields->addFieldToTab('Root.Main', $wordpressCompositeField); } else { $fields->push($wordpressCompositeField); } } } }
/** * Gets a list of form fields for editing the record. * These records should never be edited, so a readonly list of fields * is forced. * * @return FieldList */ public function getCMSFields() { preg_match("/<body[^>]*>(.*?)<\\/body>/is", $this->Body, $matches); $contents = $matches ? $matches[1] : ""; $f = FieldList::create(ReadonlyField::create('To'), ReadonlyField::create('Subject'), ReadonlyField::create('BCC'), ReadonlyField::create('CC'), HeaderField::create('Email contents', 5), LiteralField::create('BodyContents', "<div class='field'>{$contents}</div>")); return $f; }
public function getCMSFields() { $fields = parent::getCMSFields(); $createdDate = new Date(); $createdDate->setValue($this->Created); $reviewer = $this->Member()->Name; $email = $this->Member()->Email; $star = "★"; $emptyStar = "☆"; $fields->insertBefore(LiteralField::create('reviewer', '<p>Written by <strong>' . $this->getMemberDetails() . '</strong><br />' . $createdDate->Format('l F jS Y h:i:s A') . '</p>'), 'Title'); $fields->insertBefore(CheckboxField::create('Approved'), 'Title'); $starRatings = $this->StarRatings(); foreach ($starRatings as $starRating) { $cat = $starRating->StarRatingCategory; $stars = str_repeat($star, $starRating->Rating); $ratingStars = $stars; $maxRating = $starRating->MaxRating - $starRating->Rating; $emptyStarRepeat = str_repeat($emptyStar, $maxRating); $emptyStars = $emptyStarRepeat; /* 4/5 Stars */ $ratingInfo = $ratingStars . $emptyStars . ' (' . $starRating->Rating . ' of ' . $starRating->MaxRating . ' Stars)'; $fields->insertBefore(ReadonlyField::create('rating_' . $cat, $cat, html_entity_decode($ratingInfo, ENT_COMPAT, 'UTF-8')), 'Title'); } $fields->removeByName('StarRatings'); $fields->removeByName('MemberID'); $fields->removeByName('ProductID'); return $fields; }
public function updateCMSFields(FieldList $fields) { // vars $config = SiteConfig::current_site_config(); $owner = $this->owner; // decode data into array $data = json_decode($owner->OpenGraphData, true); // @todo Add repair method if data is missing / corrupt ~ for fringe cases // tab $tab = new Tab('OpenGraph'); // add disabled/error state if `off` if ($data['og:type'] === 'off') { $tab->addExtraClass('error'); } // add the tab $fields->addFieldToTab('Root.Metadata', $tab, 'FullOutput'); // new identity $tab = 'Root.Metadata.OpenGraph'; // add description // type always visible $fields->addFieldsToTab($tab, array(LabelField::create('OpenGraphHeader', '@todo Information</a>')->addExtraClass('information'), DropdownField::create('OpenGraphType', '<a href="http://ogp.me/#types">og:type</a>', self::$types, $data['og:type']))); if ($data['og:type'] !== 'off') { $fields->addFieldsToTab($tab, array(ReadonlyField::create('OpenGraphURL', 'Canonical URL', $owner->AbsoluteLink()), TextField::create('OpenGraphSiteName', 'Site Name', $data['og:site_name'])->setAttribute('placeholder', $config->Title), TextField::create('OpenGraphTitle', 'Page Title', $data['og:title'])->setAttribute('placeholder', $owner->Title), TextareaField::create('OpenGraphDescription', 'Description', $data['og:description'])->setAttribute('placeholder', $owner->GenerateDescription()), UploadField::create('OpenGraphImage', 'Image<pre>type: png/jpg/gif</pre><pre>size: variable *</pre>', $owner->OpenGraphImage)->setAllowedExtensions(array('png', 'jpg', 'jpeg', 'gif'))->setFolderName(self::$SEOOpenGraphUpload . $owner->Title)->setDescription('* <a href="https://developers.facebook.com/docs/sharing/best-practices#images" target="_blank">Facebook image best practices</a>, or use any preferred Open Graph guide.'))); } }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('ConfiguredScheduleID'); $interval = $fields->dataFieldByName('Interval')->setDescription('Number of seconds between each run. e.g 3600 is 1 hour'); $fields->replaceField('Interval', $interval); $dt = new DateTime(); $fields->replaceField('StartDate', DateField::create('StartDate')->setConfig('dateformat', 'dd/MM/yyyy')->setConfig('showcalendar', true)->setDescription('DD/MM/YYYY e.g. ' . $dt->format('d/m/y'))); $fields->replaceField('EndDate', DateField::create('EndDate')->setConfig('dateformat', 'dd/MM/yyyy')->setConfig('showcalendar', true)->setDescription('DD/MM/YYYY e.g. ' . $dt->format('d/m/y'))); if ($this->ID == null) { foreach ($fields->dataFields() as $field) { //delete all included fields $fields->removeByName($field->Name); } $rangeTypes = ClassInfo::subclassesFor('ScheduleRange'); $fields->addFieldToTab('Root.Main', TextField::create('Title', 'Title')); $fields->addFieldToTab('Root.Main', DropdownField::create('ClassName', 'Range Type', $rangeTypes)); } else { $fields->addFieldToTab('Root.Main', ReadonlyField::create('ClassName', 'Type')); } if ($this->ClassName == __CLASS__) { $fields->removeByName('ApplicableDays'); } return $fields; }
public function __construct($controller, $name, $show_actions = true) { $TempBasketID = Store_BasketController::get_temp_basket_id(); $order_id = DB::Query("SELECT id FROM `order` WHERE (`TempBasketID`='" . $TempBasketID . "')")->value(); /* Basket GridField */ $config = new GridFieldConfig(); $dataColumns = new GridFieldDataColumns(); $dataColumns->setDisplayFields(array('getPhoto' => "Photo", 'Title' => 'Product', 'Price' => 'Item Price', 'Quantity' => 'Quantity', 'productPrice' => 'Total Price', 'getfriendlyTaxCalculation' => 'Tax Inc/Exc', 'TaxClassName' => 'Tax')); $config->addComponent($dataColumns); $config->addComponent(new GridFieldTitleHeader()); $basket = GridField::create("BasketItems", "", DataObject::get("Order_Items", "(OrderID='" . $order_id . "')"), $config); /* Basket Subtotal */ $subtotal = new Order(); $subtotal = $subtotal->calculateSubTotal($order_id); $subtotal = ReadonlyField::create("SubTotal", "Basket Total (" . Product::getDefaultCurrency() . ")", $subtotal); /* Fields */ $fields = FieldList::create($basket, $subtotal, ReadonlyField::create("Tax", "Tax", "Calculated on the Order Summary page.")); /* Actions */ $actions = FieldList::create(CompositeField::create(FormAction::create('continueshopping', 'Continue Shopping'), FormAction::create('placeorder', 'Place Order'))); /* Required Fields */ $required = new RequiredFields(array()); /* * Now we create the actual form with our fields and actions defined * within this class. */ return parent::__construct($controller, $name, $fields, $show_actions ? $actions : FieldList::create(), $required); }
public function SyncButton() { $fields = FieldList::create(ReadonlyField::create('LastSyncDate', 'Last Sync Date')); $actions = FieldList::create(FormAction::create("doSyncFromFeed")->setTitle("Sync Feed to Events")); $form = Form::create($this, 'SyncButton', $fields, $actions); $form->loadDataFrom($this->data()); return $form; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('PlaylistItemID'); $fields->removeByName('SortOrder'); $fields->addFieldsToTab('Root.Main', array(ReadonlyField::create('VideoID'), ReadonlyField::create('ThumbnailURL')), 'Title'); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName("Content"); $fields->addFieldToTab("Root.Main", ReadonlyField::create('UID', 'UID'), 'URLSegment'); $fields->addFieldsToTab("Root.Main", array(TextField::create('Opposition', 'Opposition'), DropdownField::create('Result', 'Game result', singleton('Match')->dbObject('Result')->enumValues())->setEmptyString('(TBD)')), 'Metadata'); return $fields; }
/** * Add fields to the CMS for this gateway. */ public function getCMSFields() { //Fetch the fields from the Courier DataObject $fields = parent::getCMSFields(); //Add new fields $fields->addFieldsToTab("Root.Main", array(HeaderField::create("PayPal Transaction Information"), CompositeField::create(ReadonlyField::create("custom", "Order Number"), ReadonlyField::create("payment_date", "Payment Date"), ReadonlyField::create("payment_status", "Payment Status")->setRightTitle("\n\t\t\t\t\tIf this status is pending, see Pending Reason below. \n\t\t\t\t"), ReadonlyField::create("payment_type", "Payment Type")->setRightTitle("\n\t\t\t\t\tFor a explanation of the different payment types please see 'payment_type' at \n\t\t\t\t\t<a href=\"https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/\">paypal.com</a>\n\t\t\t\t"), ReadonlyField::create("pending_reason", "Pending Reason")->setRightTitle("\n\t\t\t\t\tFor a explanation of pending reasons please see 'pending_reason' at \n\t\t\t\t\t<a href=\"https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/\">paypal.com</a>\n\t\t\t\t"), ReadonlyField::create("reason_code", "Reason Code")->setRightTitle("\n\t\t\t\t\tThis is set if Payment Status is Reversed, Refunded, Canceled_Reversal, or Denied. For an explanation of its\n\t\t\t\t\tmeaning see 'reason_code' at \n\t\t\t\t\t<a href=\"https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/\">paypal.com</a>\n\t\t\t\t"), FieldGroup::create("Transaction Identifiers", ReadonlyField::create("txn_id", "<strong>Transaction ID</strong>"), ReadonlyField::create("parent_txn_id", "<strong>Parent Transaction ID</strong>"))->setRightTitle("\n\t\t\t\t\t<strong>Transaction ID</strong><br />\n\t\t\t\t\tThe identifier for this specific transaction entry.\n\t\t\t\t\t\n\t\t\t\t\t<br /><br />\n\t\t\t\t\t\n\t\t\t\t\t<strong>Parent Transaction ID</strong><br />\n\t\t\t\t\tIf provided, this value is the transaction identifier of the\n\t\t\t\t\tparent transaction. i.e. If this transaction is a refund, the\n\t\t\t\t\tvalue will be the transaction ID of the original purchase.\n\t\t\t\t\t<br />\n\t\t\t\t"), FieldGroup::create("Funds", ReadonlyField::create("mc_gross", "<strong>Gross Payment</strong>"), ReadonlyField::create("mc_fee", "<strong>PayPal Fee</strong>"))->setRightTitle("\n\t\t\t\t\t<strong>Gross Payment</strong><br />\n\t\t\t\t\tFull amount of the customer's payment, before transaction fee is subtracted.\n\t\t\t\t\t\n\t\t\t\t\t<br /><br />\n\t\t\t\t\t\n\t\t\t\t\t<strong>PayPal Fee</strong><br />\n\t\t\t\t\tTransaction fee associated with the payment.\n\t\t\t\t")))); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); if ($this->Code) { $fields->addFieldToTab("Root.Main", ReadonlyField::create("DiscountURL", _t("CheckoutAdmin.AddDiscountURL", "Add discount URL"), $this->AddLink()), "Code"); } return $fields; }
public function getCMSFields() { $existing_customer = $this->config()->existing_customer_class; // Manually inject HTML for totals as Silverstripe refuses to // render Currency.Nice any other way. $subtotal_html = '<div id="SubTotal" class="field readonly">'; $subtotal_html .= '<label class="left" for="Form_ItemEditForm_SubTotal">'; $subtotal_html .= _t("Orders.SubTotal", "Sub Total"); $subtotal_html .= '</label>'; $subtotal_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_SubTotal" class="readonly">'; $subtotal_html .= $this->SubTotal->Nice(); $subtotal_html .= '</span></div></div>'; $discount_html = '<div id="Discount" class="field readonly">'; $discount_html .= '<label class="left" for="Form_ItemEditForm_Discount">'; $discount_html .= _t("Orders.Discount", "Discount"); $discount_html .= '</label>'; $discount_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Discount" class="readonly">'; $discount_html .= $this->dbObject("DiscountAmount")->Nice(); $discount_html .= '</span></div></div>'; $postage_html = '<div id="Postage" class="field readonly">'; $postage_html .= '<label class="left" for="Form_ItemEditForm_Postage">'; $postage_html .= _t("Orders.Postage", "Postage"); $postage_html .= '</label>'; $postage_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Postage" class="readonly">'; $postage_html .= $this->Postage->Nice(); $postage_html .= '</span></div></div>'; $tax_html = '<div id="TaxTotal" class="field readonly">'; $tax_html .= '<label class="left" for="Form_ItemEditForm_TaxTotal">'; $tax_html .= _t("Orders.Tax", "Tax"); $tax_html .= '</label>'; $tax_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_TaxTotal" class="readonly">'; $tax_html .= $this->TaxTotal->Nice(); $tax_html .= '</span></div></div>'; $total_html = '<div id="Total" class="field readonly">'; $total_html .= '<label class="left" for="Form_ItemEditForm_Total">'; $total_html .= _t("Orders.Total", "Total"); $total_html .= '</label>'; $total_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Total" class="readonly">'; $total_html .= $this->Total->Nice(); $total_html .= '</span></div></div>'; $fields = new FieldList($tab_root = new TabSet("Root", $tab_main = new Tab('Main', new OrderItemGridField("Items", "", $this->Items(), $config = GridFieldConfig::create()->addComponents(new GridFieldButtonRow('before'), new GridFieldTitleHeader(), new GridFieldEditableColumns(), new GridFieldDeleteAction(), new GridFieldAddOrderItem())), new HeaderField("PostageDetailsHeader", _t("Orders.PostageDetails", "Postage Details")), TextField::create("PostageType"), TextField::create("PostageCost"), TextField::create("PostageTax"), new HeaderField("DiscountDetailsHeader", _t("Orders.DiscountDetails", "Discount")), TextField::create("Discount"), TextField::create("DiscountAmount"), OrderSidebar::create(ReadonlyField::create("QuoteNumber", "#")->setValue($this->ID), LiteralField::create("SubTotal", $subtotal_html), LiteralField::create("Discount", $discount_html), LiteralField::create("Postage", $postage_html), LiteralField::create("TaxTotal", $tax_html), LiteralField::create("Total", $total_html))->setTitle("Details")), $tab_customer = new Tab('Customer', TextField::create("Company"), TextField::create("FirstName"), TextField::create("Surname"), TextField::create("Address1"), TextField::create("Address2"), TextField::create("City"), TextField::create("PostCode"), TextField::create("Country"), TextField::create("Email"), TextField::create("PhoneNumber")))); if ($this->canEdit()) { // Sidebar $tab_customer->insertBefore(CustomerSidebar::create(new GridField("ExistingCustomers", "", $existing_customer::get(), $config = GridFieldConfig_Base::create()->addComponents($map_extension = new GridFieldMapExistingAction())))->setTitle("Use Existing Customer"), "Company"); if (is_array($this->config()->existing_customer_fields)) { $columns = $config->getComponentByType("GridFieldDataColumns"); if ($columns) { $columns->setDisplayFields($this->config()->existing_customer_fields); } } // Set the record ID $map_extension->setMapFields($this->config()->existing_customer_map); } $tab_main->addExtraClass("order-admin-items"); $tab_customer->addExtraClass("order-admin-customer"); $this->extend("updateCMSFields", $fields); return $fields; }
public function __construct($controller, $name, $fields = null, $actions = null) { $fields = new FieldList(ReadonlyField::create('FirstName')->setTitle(_t('PasswordEditForm.FIRSTNAME', 'PasswordEditForm.FIRSTNAME')), ReadonlyField::create('Surname')->setTitle(_t('PasswordEditForm.SURNAME', 'PasswordEditForm.SURNAME')), ReadonlyField::create('Email')->setTitle(_t('PasswordEditForm.EMAIL', 'PasswordEditForm.EMAIL')), $Password = new BootstrapConfirmedPasswordField('Password', _t('Member.db_Password', 'Member.db_Password'))); $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doEdit')->setTitle(_t('PasswordEditForm.CHANGEPASSWORD', 'PasswordEditForm.CHANGEPASSWORD'))); parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Password")); if (Member::currentUser()) { $this->loadDataFrom(Member::currentUser()); } }
public function getCMSFields() { $fields = parent::getCMSFields(); if ($this->ID && $this->RegionCode) { $readOnlyCode = ReadonlyField::create('RegionCode', 'Region code'); $fields->replaceField('RegionCode', $readOnlyCode); } return $fields; }
public function updateCMSFields(FieldList $fields) { // vars $config = SiteConfig::current_site_config(); $self = $this->owner; $tab = 'Root.SSSEO.TouchIcon'; // $fields->addFieldsToTab($tab, array(ReadonlyField::create('AppleTouchIconPrecomposed', 'apple-touch-icon-precomposed', 'on'), UploadField::create('TouchIconImage', 'Touch Icon Image')->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'))->setFolderName('SSSEO/TouchIcon/')->setDescription('file format: JPG, PNG, GIF<br />pixel dimensions: 400 x 400 (recommended, minimum 192)<br />pixel ratio: 1:1'))); }
/** * standard SS method * @var Array **/ public function updateSettingsFields(FieldList $fields) { $fields->addFieldToTab("Root.Facebook", new HeaderField(_t("MetaTagsSTE.FB_HOW_THIS_PAGE_IS_SHARED", "How is this page shared on Facebook?"))); $fields->addFieldToTab("Root.Facebook", $fieldTitle = new ReadonlyField("fb_title", _t("MetaTagsSTE.FB_TITLE", "Title"), $this->owner->Title)); $fields->addFieldToTab("Root.Facebook", $fieldType = new ReadonlyField("fb_type", _t("MetaTagsSTE.FB_TITLE", "Type"), "website")); $fields->addFieldToTab("Root.Facebook", $fieldSiteName = new ReadonlyField("fb_type", _t("MetaTagsSTE.FB_SITE_NAME", "Site Name"), SiteConfig::current_site_config()->Title)); $fields->addFieldToTab("Root.Facebook", $fieldDescription = new ReadonlyField("fb_description", _t("MetaTagsSTE.FB_DESCRIPTION", "Description (from MetaDescription)"), $this->owner->MetaDescription)); $fields->addFieldToTab("Root.Facebook", $shareOnFacebookImageField = new UploadField("ShareOnFacebookImage", _t("MetaTagsSTE.FB_IMAGE", "Image"))); $shareOnFacebookImageField->setFolderName("OpenGraphShareImages"); $shareOnFacebookImageField->setRightTitle("Use images that are at least 1200 x 630 pixels for the best display on high resolution devices. At the minimum, you should use images that are 600 x 315 pixels to display link page posts with larger images."); $fields->addFieldToTab("Root.Facebook", $shareOnFacebookImageField = new LiteralField("fb_try_it_out", '<h3><a href="https://www.facebook.com/sharer/sharer.php?u=' . urlencode($this->owner->AbsoluteLink()) . '">' . _t("MetaTagsSTE.FB_TRY_IT_OUT", "Share on Facebook Now") . '</a></h3>', $this->owner->ShareOnFacebookImage())); //right titles $fieldTitle->setRightTitle(_t("MetaTagsSTE.FB_TITLE_RIGHT", "Uses the Page Title")); $fieldType->setRightTitle(_t("MetaTagsSTE.FB_TYPE_RIGHT", "Can not be changed")); $fieldSiteName->setRightTitle(_t("MetaTagsSTE.FB_SITE_NAME_RIGHT", "Can be set in the site settings")); $fieldDescription->setRightTitle(_t("MetaTagsSTE.FB_DESCRIPTION", "Description is set in the Metadata section of each page.")); $shareOnFacebookImageField->setRightTitle(_t("MetaTagsSTE.FB_HOW_TO_CHOOSE_IMAGE", "If no image is set then the Facebook user can choose an image from the page - with options retrieved by Facebook.")); }
public function setValue($value) { if ($this->fixed) { return $this; } if ($value) { $this->fixed = true; } return parent::setValue($value); }
public function __construct($controller, $name, $fields = null, $actions = null) { $fields = new FieldList(ReadonlyField::create('Title')->setTitle(_t('Box.TITLE', 'Box.TITLE')), TextareaField::create('Description')->setTitle(_t('Box.DESCRIPTION', 'Box.DESCRIPTION')), CheckboxField::create("Public")->setTitle(_t('Box.PUBLIC', 'Box.PUBLIC')), $Members = CheckboxSetField::create('Members')->setTitle(_t('Box.MEMBERS', 'Box.MEMBERS'))->setSource(Member::get()->map('ID', 'Name')), HiddenField::create('BoxID')); $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doEdit')->setTitle(_t('BoxEditForm.DOEDIT', 'BoxEditForm.DOEDIT'))); parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Description")); if (isset($GLOBALS['BoxID'])) { $Box = Box::get()->byID($GLOBALS['BoxID']); $this->loadDataFrom($Box); } }
public function updateCMSFields(FieldList $fields) { // variables $config = SiteConfig::current_site_config(); $self = $this->owner; // SSSEO Tabset $fields->addFieldToTab('Root', new TabSet('SSSEO')); // remove $fields->removeByName(array('Metadata')); //// Full Output $tab = 'Root.SSSEO.FullOutput'; if ($self->hasExtension('SSSEO_SchemaDotOrg_SiteTree_DataExtension')) { if ($head = $self->Metahead()) { $fields->addFieldsToTab($tab, array(LiteralField::create('HeaderMetahead', '<pre class="bold">$Metahead()</pre>'), LiteralField::create('LiteralMetahead', '<pre><span style="background-color: white;">' . htmlentities($head) . '</span></pre>'))); } } $fields->addFieldsToTab($tab, array(LiteralField::create('HeaderMetadata', '<pre class="bold">$Metadata()</pre>'), LiteralField::create('LiteralMetadata', '<pre>' . nl2br(htmlentities(trim($self->Metadata()), ENT_QUOTES)) . '</pre>'))); //// Metadata $tab = 'Root.SSSEO.Metadata'; // Canonical if ($config->CanonicalEnabled()) { $fields->addFieldsToTab($tab, array(ReadonlyField::create('ReadonlyMetaCanonical', 'link rel="canonical"', $self->AbsoluteLink()))); } // Title if ($config->TitleEnabled()) { $fields->addFieldsToTab($tab, array(TextField::create('MetaTitle', 'meta title')->setAttribute('placeholder', $self->GenerateTitle()))); } // Description $fields->addFieldsToTab($tab, array(TextareaField::create('MetaDescription', 'meta description')->setAttribute('placeholder', $self->GenerateDescriptionFromContent()))); // ExtraMeta if ($config->ExtraMetaEnabled()) { $fields->addFieldsToTab($tab, array(TextareaField::create('ExtraMeta', 'Custom Metadata'))); } //// Open Graph if ($config->OpenGraphEnabled()) { $tab = 'Root.SSSEO.OpenGraph'; $fields->addFieldsToTab($tab, array()); } //// Twitter Cards if ($config->TwitterCardsEnabled()) { $tab = 'Root.SSSEO.TwitterCards'; $fields->addFieldsToTab($tab, array()); } //// Schema.org if ($config->SchemaDotOrgEnabled()) { $tab = 'Root.SSSEO.SchemaDotOrg'; $fields->addFieldsToTab($tab, array()); } //// Authorship // Authors if ($config->AuthorshipEnabled()) { $tab = 'Root.SSSEO.Authors'; $fields->addFieldsToTab($tab, array(GridField::create('Authors', 'Authors', $self->Authors())->setConfig(GridFieldConfig_RelationEditor::create()))); } }
/** * Return field list for iframe insert/update form * * @see HtmlEditorField_Toolbar::getFieldsForOembed() */ protected function getFieldsForIframe($url, $file) { $thumbnailURL = FRAMEWORK_DIR . '/images/default_media.png'; $fields = new FieldList($filePreview = CompositeField::create(CompositeField::create(new LiteralField("ImageFull", "<img id='thumbnailImage' class='thumbnail-preview' " . "src='{$thumbnailURL}?r=" . rand(1, 100000) . "' alt='{$file->Name}' />\n"))->setName("FilePreviewImage")->addExtraClass('cms-file-info-preview'), CompositeField::create(CompositeField::create(new ReadonlyField("FileType", _t('AssetTableField.TYPE', 'File type') . ':', $file->Type), $urlField = ReadonlyField::create('ClickableURL', _t('AssetTableField.URL', 'URL'), sprintf('<a href="%s" target="_blank" class="file">%s</a>', $url, $url))->addExtraClass('text-wrap')))->setName("FilePreviewData")->addExtraClass('cms-file-info-data'))->setName("FilePreview")->addExtraClass('cms-file-info'), new TextField('CaptionText', _t('HtmlEditorField.CAPTIONTEXT', 'Caption text')), DropdownField::create('CSSClass', _t('HtmlEditorField.CSSCLASS', 'Alignment / style'), array('left' => _t('HtmlEditorField.CSSCLASSLEFT', 'On the left, with text wrapping around.'), 'leftAlone' => _t('HtmlEditorField.CSSCLASSLEFTALONE', 'On the left, on its own.'), 'right' => _t('HtmlEditorField.CSSCLASSRIGHT', 'On the right, with text wrapping around.'), 'center' => _t('HtmlEditorField.CSSCLASSCENTER', 'Centered, on its own.')))->addExtraClass('last')); if ($file->Width != null) { $fields->push(FieldGroup::create(_t('HtmlEditorField.IMAGEDIMENSIONS', 'Dimensions'), TextField::create('Width', _t('HtmlEditorField.IMAGEWIDTHPX', 'Width'), $file->Width)->setMaxLength(5), TextField::create('Height', _t('HtmlEditorField.IMAGEHEIGHTPX', 'Height'), $file->Height)->setMaxLength(5))->addExtraClass('dimensions last')); } $urlField->dontEscape = true; $fields->push(new HiddenField('URL', false, $url)); return $fields; }
function __construct($controller, $name = "ShippingEstimateForm") { $countries = SiteConfig::current_site_config()->getCountriesList(); $countryfield = count($countries) ? DropdownField::create("Country", _t('Address.COUNTRY', 'Country'), $countries) : ReadonlyField::create("Country", _t('Address.COUNTRY', 'Country')); $countryfield->setHasEmptyDefault(true); $fields = new FieldList($countryfield, TextField::create('State', _t('Address.STATE', 'State')), TextField::create('City', _t('Address.CITY', 'City')), TextField::create('PostalCode', _t('Address.POSTALCODE', 'Postal Code'))); $actions = new FieldList(FormAction::create("submit", "Estimate")); $validator = new RequiredFields(array('Country')); parent::__construct($controller, $name, $fields, $actions, $validator); $this->extend('updateForm'); }
/** * getCMSFields * Construct the FieldList used in the CMS. To provide a * smarter UI we don't use the scaffolding provided by * parent::getCMSFields. * * @return FieldList */ public function getCMSFields() { Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css'); //Product Item not yet created $select_product_item = Tab::create("Item", HeaderField::create("Add Order Item"), CompositeField::create(DropdownField::create("OriginalProductID", "Select Product", Product::get()->sort("Title ASC")->map())->setEmptyString("(Select a product)"))); //Product Item has been created $edit_product_item = Tab::create("Item", HeaderField::create("Order Item"), CompositeField::create(ReadonlyField::create("Title", "Product")->setRightTitle("You will need to remove this item and add another should you wish to change the product."), ReadonlyField::create("SKU", "SKU"), FieldGroup::create(NumericField::create("Price", "Cost per item"), DropdownField::create("Discounted", "Is this the sale price?", array("0" => "No", "1" => "Yes")), NumericField::create("Quantity", "Quantity ordered"))->setTitle("Pricing (" . Product::getDefaultCurrency() . ") "), ReadonlyField::create("SubTotal", "Subtotal (" . Product::getDefaultCurrency() . ")", StoreCurrency::convertToCurrency($this->Price * $this->Quantity)), ReadonlyField::create("TAX", $this->TaxClassName . " (" . Product::getDefaultCurrency() . ")", $this->calculateItemTax())->setRightTitle($this->TaxCalculation == 1 ? "Subtotal is inclusive of this tax." : "Subtotal is exclusive of this tax."), ReadonlyField::create("Total", "Total (" . Product::getDefaultCurrency() . ")", $this->TaxCalculation == 1 ? StoreCurrency::convertToCurrency($this->Price * $this->Quantity) : StoreCurrency::convertToCurrency($this->Price * $this->Quantity + $this->calculateItemTax())))); //Create the FieldList and push the either of the above Tabs to the Root TabSet based on if Product Item exists yet or not. $fields = FieldList::create($root = TabSet::create('Root', $this->exists() ? $edit_product_item : $select_product_item)); return $fields; }
public function getCountryField() { $countries = SiteConfig::current_site_config()->getCountriesList(); if (count($countries) == 1) { //field name is Country_readonly so it's value doesn't get updated return ReadonlyField::create("Country_readonly", _t('Address.db_Country', 'Country'), array_pop($countries)); } $field = DropdownField::create("Country", _t('Address.db_Country', 'Country'), $countries)->setHasEmptyDefault(true); $this->extend('updateCountryField', $field); return $field; }