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); } } } }
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; }
/** * 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 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) { $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)); } } }
/** * 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 __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 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; }
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(); if ($this->Code) { $fields->addFieldToTab("Root.Main", ReadonlyField::create("DiscountURL", _t("CheckoutAdmin.AddDiscountURL", "Add discount URL"), $this->AddLink()), "Code"); } 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() { $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 getCMSFields() { $fields = parent::getCMSFields(); if ($this->ID && $this->RegionCode) { $readOnlyCode = ReadonlyField::create('RegionCode', 'Region code'); $fields->replaceField('RegionCode', $readOnlyCode); } 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 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'))); }
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()))); } }
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; }
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; }
/** * 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; }
/** * Display the appropriate CMS media page fields and respective media type attributes. */ public function getCMSFields() { $fields = parent::getCMSFields(); // Display the media type as read only. $fields->addFieldToTab('Root.Main', ReadonlyField::create('Type', 'Type', $this->MediaType()->Title), 'Title'); // Display a notification that the parent holder contains mixed children. $parent = $this->getParent(); if ($parent && $parent->getMediaHolderChildren()->exists()) { Requirements::css(MEDIAWESOME_PATH . '/css/mediawesome.css'); $fields->addFieldToTab('Root.Main', LiteralField::create('MediaNotification', "<p class='mediawesome notification'><strong>Mixed {$this->MediaType()->Title} Holder</strong></p>"), 'Type'); } // Display the remaining media page fields. $fields->addFieldToTab('Root.Main', TextField::create('ExternalLink')->setRightTitle('An <strong>optional</strong> redirect URL to the media source'), 'URLSegment'); $fields->addFieldToTab('Root.Main', $date = DatetimeField::create('Date'), 'Content'); $date->getDateField()->setConfig('showcalendar', true); // Allow customisation of categories and tags respective to the current page. $tags = MediaTag::get()->map()->toArray(); $fields->findOrMakeTab('Root.CategoriesTags', 'Categories and Tags'); $fields->addFieldToTab('Root.CategoriesTags', $categoriesList = ListboxField::create('Categories', 'Categories', $tags)->setMultiple(true)); $fields->addFieldToTab('Root.CategoriesTags', $tagsList = ListboxField::create('Tags', 'Tags', $tags)->setMultiple(true)); if (!$tags) { $categoriesList->setAttribute('disabled', 'true'); $tagsList->setAttribute('disabled', 'true'); } // Allow customisation of media type attribute content respective to the current page. if ($this->MediaAttributes()->exists()) { foreach ($this->MediaAttributes() as $attribute) { if (strripos($attribute->Title, 'Time') || strripos($attribute->Title, 'Date') || stripos($attribute->Title, 'When')) { // Display an attribute as a date time field where appropriate. $fields->addFieldToTab('Root.Main', $custom = DatetimeField::create("{$attribute->ID}_MediaAttribute", $attribute->Title, $attribute->Content), 'Content'); $custom->getDateField()->setConfig('showcalendar', true); } else { $fields->addFieldToTab('Root.Main', $custom = TextField::create("{$attribute->ID}_MediaAttribute", $attribute->Title, $attribute->Content), 'Content'); } $custom->setRightTitle('Custom <strong>' . strtolower($this->MediaType()->Title) . '</strong> attribute'); } } // Display an abstract field for content summarisation. $fields->addfieldToTab('Root.Main', $abstract = TextareaField::create('Abstract'), 'Content'); $abstract->setRightTitle('A concise summary of the content'); $abstract->setRows(6); // Allow customisation of images and attachments. $type = strtolower($this->MediaType()->Title); $fields->findOrMakeTab('Root.ImagesAttachments', 'Images and Attachments'); $fields->addFieldToTab('Root.ImagesAttachments', $images = UploadField::create('Images')); $images->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif', 'bmp')); $images->setFolderName("media-{$type}/{$this->ID}/images"); $fields->addFieldToTab('Root.ImagesAttachments', $attachments = UploadField::create('Attachments')); $attachments->setFolderName("media-{$type}/{$this->ID}/attachments"); // Allow extension customisation. $this->extend('updateMediaPageCMSFields', $fields); return $fields; }
/** * Gets the fields for displaying in the cms * @param {string} $url Vidyard Video URL * @param {VidyardInsertMedia_Embed} $file Vidyard Insert Media Embed Object * @return {FieldList} Field List of fields used in the cms */ protected function getFieldsForVidyard($url, VidyardInsertMedia_Embed $file) { $thumbnailURL = Convert::raw2att($file->Oembed->thumbnail_url); $fileName = Convert::raw2att($file->Name); $fields = new FieldList($filePreview = CompositeField::create(CompositeField::create(new LiteralField("ImageFull", "<img id='thumbnailImage' class='thumbnail-preview' " . "src='{$thumbnailURL}?r=" . rand(1, 100000) . "' alt='{$fileName}' />\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>', Convert::raw2att($url), Convert::raw2att($url)))->addExtraClass('text-wrap')))->setName("FilePreviewData")->addExtraClass('cms-file-info-data'))->setName("FilePreview")->addExtraClass('cms-file-info'), DropdownField::create('CSSClass', _t('HtmlEditorField.CSSCLASS', 'Alignment / style'), array('leftAlone' => _t('HtmlEditorField.CSSCLASSLEFTALONE', 'On the left, on its own.'), 'center' => _t('HtmlEditorField.CSSCLASSCENTER', 'Centered, on its own.'), 'left' => _t('HtmlEditorField.CSSCLASSLEFT', 'On the left, with text wrapping around.'), 'right' => _t('HtmlEditorField.CSSCLASSRIGHT', 'On the right, with text wrapping around.')))->addExtraClass('last'), new CheckboxField('UseLightbox', _t('VidyardInsertMedia.USE_LIGHTBOX', '_Use the Lightbox Display'))); if ($file->Width != null) { $fields->push(FieldGroup::create(_t('HtmlEditorField.IMAGEDIMENSIONS', 'Dimensions'), TextField::create('Width', _t('HtmlEditorField.IMAGEWIDTHPX', 'Width'), $file->InsertWidth)->setMaxLength(5), TextField::create('Height', _t('HtmlEditorField.IMAGEHEIGHTPX', 'Height'), $file->InsertHeight)->setMaxLength(5))->addExtraClass('dimensions last')); } $urlField->dontEscape = true; $fields->push(new HiddenField('URL', false, $file->getURL())); return $fields; }
/** * @return FieldList */ public function getCMSFields() { /** @var FieldList $fields */ $fields = FieldList::create(TabSet::create('Root')); $fields->addFieldToTab('Root.Main', ReadonlyField::create('FirstName', _t('ContactMessage.FirstName', 'First Name'))); $fields->addFieldToTab('Root.Main', ReadonlyField::create('LastName', _t('ContactMessage.LastName', 'Last Name'))); $fields->addFieldToTab('Root.Main', LiteralField::create('', '<div class="field"><label class="left">Email</label><div class="middlecolumn"><span class="readonly"><a href="mailto:' . $this->Email . '">' . $this->Email . '</a></span></div></div>')); $fields->addFieldToTab('Root.Main', ReadonlyField::create('Phone', _t('ContactMessage.Phone', 'Phone'))); $fields->addFieldToTab('Root.Main', ReadonlyField::create('Message', _t('ContactMessage.Message', 'Message'))); $this->extend('updateCMSFields', $fields); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('UploadToken'); if ($this->UploadToken) { $fields->addFieldToTab('Root.Main', ReadonlyField::create('TokenValue', 'Enter this token to process sync data', $this->UploadToken)); } else { $fields->removeByName('SuppliedToken'); $fields->addFieldToTab('Root.Main', ReadonlyField::create('TokenValue', 'You can process the data after saving and entering a process token')); } return $fields; }
/** * Gets fields used in the cms * @return {FieldList} Fields to be used */ public function getCMSFields() { $kapostBase = KapostAdmin::config()->kapost_base_url; if ($kapostBase[strlen($kapostBase) - 1] != '/') { $kapostBase .= '/'; } $fields = new FieldList(new ReadonlyField('Title', $this->fieldLabel('Title')), new ReadonlyField('Created', _t('KapostConversionHistory.CONVERSION_DATE', '_Conversion Date')), new ReadonlyField('ConverterName', $this->fieldLabel('ConverterName')), new ReadonlyField('KapostChangeTypeNice', $this->fieldLabel('KapostChangeType')), new ReadonlyField('KapostAuthor', $this->fieldLabel('KapostAuthor')), new ReadonlyField('DestinationTypeNice', $this->fieldLabel('DestinationType')), $kapostRef = ReadonlyField::create('KapostRefID_linked', $this->fieldLabel('KapostRefID'), !empty($kapostBase) ? '<a href="' . htmlentities($kapostBase . 'posts/' . $this->KapostRefID) . '" target="_blank">' . htmlentities($this->KapostRefID) . '</a>' : $this->KapostRefID), $destination = ReadonlyField::create('Destination', $this->fieldLabel('DestinationID'), '<a href="' . htmlentities($this->getDestinationLink()) . '" class="kapost-panel-link">' . _t('KapostConversionHistory.CONVERTED_TO_OBJECT', '_View Destination Object') . '</a>')); $kapostRef->dontEscape = true; $destination->dontEscape = true; //Allow extensions to add/remove fields $this->extend('updateCMSFields', $fields); return $fields; }
/** * Allow permission configuration for customisation of media. */ public function updateCMSFields(FieldList $fields) { $permissions = array('ADMIN' => 'Administrators and developers', 'SITETREE_EDIT_ALL' => 'Content authors'); Requirements::css(MEDIAWESOME_PATH . '/css/mediawesome.css'); // Confirm that the current CMS user has permission. if (Permission::check('EDIT_SITECONFIG') === false) { $fields->addFieldToTab('Root.Access', $options = ReadonlyField::create('Media', 'Who can customise media?', $permissions[$this->owner->MediaPermission])); } else { // Display the permission configuration. $fields->addFieldToTab('Root.Access', $options = OptionsetField::create('MediaPermission', 'Who can customise media?', $permissions)); } // Allow extension customisation. $this->owner->extend('updateSiteConfigMediaPermissionExtensionCMSFields', $fields); }
public function getCMSFields() { $fields = FieldList::create(); $fields->push(TabSet::create('Root', $mainTab = new Tab('Main'))); $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main")); $sort = 'ParentID'; if ($this->has_extension('Sortable')) { $sort .= ', SortOrder'; } $source = Block::get()->exclude('ClassName', 'VirtualBlock')->sort($sort)->map('ID', 'FullTitle'); $fields->addFieldsToTab('Root.Main', array(ReadonlyField::create('Title', _t('Block.TITLE', 'Title'), $this->getTitle()), DropdownField::create('OriginalBlockID', _t('VirtualBlock.SELECT_ORIGINAL', 'Select original'), $source))); $this->extend('updateCMSFields', $fields); return $fields; }