本文整理汇总了PHP中ReadonlyField::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ReadonlyField::create方法的具体用法?PHP ReadonlyField::create怎么用?PHP ReadonlyField::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadonlyField
的用法示例。
在下文中一共展示了ReadonlyField::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCMSFields
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);
}
}
}
}
开发者ID:silbinarywolf,项目名称:silverstripe-wordpressmigrationtools,代码行数:25,代码来源:WordpressImportDataExtension.php
示例2: updateCMSFields
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.')));
}
}
开发者ID:graphiques-digitale,项目名称:silverstripe-seo-open-graph,代码行数:25,代码来源:SEO_OpenGraph_SiteTree_DataExtension.php
示例3: getCMSFields
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;
}
开发者ID:helpfulrobot,项目名称:silverstripe-australia-silverstripe-schedulizer,代码行数:25,代码来源:ScheduleRange.php
示例4: getEditForm
/**
* 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;
}
开发者ID:webbuilders-group,项目名称:silverstripe-kapost-bridge-logger,代码行数:34,代码来源:KapostBridgeLogViewer.php
示例5: getCMSFields
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;
}
示例6: updateCMSFields
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));
}
}
}
示例7: getCMSFields
/**
* 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;
}
示例8: __construct
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);
}
示例9: getCMSFields
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;
}
示例10: SyncButton
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;
}
示例11: getCMSFields
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;
}
示例12: getCMSFields
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;
}
示例13: getCMSFields
/**
* 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;
}
示例14: getCMSFields
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;
}
示例15: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
if ($this->ID && $this->RegionCode) {
$readOnlyCode = ReadonlyField::create('RegionCode', 'Region code');
$fields->replaceField('RegionCode', $readOnlyCode);
}
return $fields;
}