本文整理汇总了PHP中LiteralField::create方法的典型用法代码示例。如果您正苦于以下问题:PHP LiteralField::create方法的具体用法?PHP LiteralField::create怎么用?PHP LiteralField::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LiteralField
的用法示例。
在下文中一共展示了LiteralField::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCMSFields
/**
* @param FieldList $fields
*/
public function updateCMSFields(FieldList $fields)
{
/** =========================================
* @var TextareaField $address
* @var TextareaField $postalAddress
* @var TextField $mailChimpAPI
* @var TextareaField $mailChimpSuccessMessage
===========================================*/
if (!$fields->fieldByName('Root.Settings')) {
$fields->addFieldToTab('Root', TabSet::create('Settings'));
}
/** -----------------------------------------
* Details
* ----------------------------------------*/
$address = TextareaField::create('Address', 'Address');
$address->setRows(8);
$postalAddress = TextareaField::create('PostalAddress', 'Postal Address');
$postalAddress->setRows(8);
$fields->findOrMakeTab('Root.Settings.Details');
$fields->addFieldsToTab('Root.Settings.Details', array(HeaderField::create('', 'Company Details'), Textfield::create('Phone', 'Phone Number'), Textfield::create('Email', 'Public Email Address'), $address, $postalAddress, TextField::create('Facebook', 'Facebook'), TextField::create('LinkedIn', 'LinkedIn'), TextField::create('Pinterest', 'Pinterest'), TextField::create('TwitterHandle', 'Twitter Handle')));
/** -----------------------------------------
* Subscription
* ----------------------------------------*/
$mailChimpAPI = TextField::create('MailChimpAPI', 'API Key');
$mailChimpSuccessMessage = TextareaField::create('MailChimpSuccessMessage', 'Success Message (optional)');
$mailChimpAPI->setRightTitle('<a href="https://us9.admin.mailchimp.com/account/api-key-popup/" target="_blank"><i>How do I get my MailChimp API Key?</i></a>');
$mailChimpSuccessMessage->setRows(2)->setRightTitle('Message displayed when a user has successfully subscribed to a list.');
$fields->findOrMakeTab('Root.Settings.Subscription', 'Subscription');
$fields->addFieldsToTab('Root.Settings.Subscription', array(HeaderField::create('', 'Newsletter Subscription'), LiteralField::create('', '<p>The API key, and list ID are necessary for the Newsletter Subscription form to function.</p>'), $mailChimpAPI, TextField::create('MailChimpListID', 'List ID'), $mailChimpSuccessMessage));
}
示例2: getModularCMSFields
function getModularCMSFields($relationName = 'Modules', $title = 'Content Modules')
{
$fields = array();
$GLOBALS['_CONTENT_MODULE_PARENT_PAGEID'] = $this->owner->ID;
$area = $this->owner->obj($relationName);
if ($area && $area->exists()) {
$fields[] = HeaderField::create($relationName . 'Header', $title, 2);
$fields[] = GridField::create($relationName, $title, $area->Modules(), GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldOrderableRows('SortOrder'))->removeComponentsByType('GridFieldAddNewButton')->addComponent($add = new GridFieldAddNewMultiClass()));
if (($allowed_modules = $this->owner->Config()->get('allowed_modules')) && is_array($allowed_modules) && count($allowed_modules)) {
if (isset($allowed_modules[$relationName])) {
$add->setClasses($allowed_modules[$relationName]);
} else {
$add->setClasses($allowed_modules);
}
} else {
// Remove the base "ContentModule" from allowed modules.
$classes = array_values(ClassInfo::subclassesFor('ContentModule'));
sort($classes);
if (($key = array_search('ContentModule', $classes)) !== false) {
unset($classes[$key]);
}
$add->setClasses($classes);
}
} else {
$fields[] = LiteralField::create('SaveFirstToAddModules', '<div class="message">You must save first before you can add modules.</div>');
}
return $fields;
}
示例3: 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));
}
}
}
示例4: getCMSFields
public function getCMSFields()
{
$datetimeField = DatetimeField::create("Date")->setTitle($this->fieldLabel("Date"));
$datetimeField->getDateField()->setConfig("dmyfields", true);
// Check if NewsImage should be saved in a seperate folder
if (self::config()->save_image_in_seperate_folder == false) {
$UploadField = UploadField::create("NewsImage")->setTitle($this->fieldLabel("NewsImage"))->setFolderName("news");
} else {
if ($this->ID == "0") {
$UploadField = FieldGroup::create(LiteralField::create("Save", $this->fieldLabel("SaveHelp")))->setTitle($this->fieldLabel("NewsImage"));
} else {
$UploadField = UploadField::create("NewsImage")->setTitle($this->fieldLabel("NewsImage"))->setFolderName("news/" . $this->URLSegment);
}
}
// Create direct link to NewsArticle
if ($this->ID == "0") {
// Little hack to hide $urlsegment when article isn't saved yet.
$urlsegment = LiteralField::create("NoURLSegmentYet", "");
} else {
if ($NewsHolder = $this->NewsHolder()) {
$baseLink = Controller::join_links(Director::absoluteBaseURL(), $NewsHolder->Link(), $this->URLSegment);
}
$urlsegment = Fieldgroup::create(LiteralField::create("URLSegment", "URLSegment")->setContent('<a href="' . $baseLink . '" target="_blank">' . $baseLink . '</a>'))->setTitle("URLSegment");
}
$fields = FieldList::create(new TabSet("Root", new Tab("Main", $urlsegment, TextField::create("Title")->setTitle($this->fieldLabel("Title")), $datetimeField, HTMLEditorField::create("Content")->setTitle($this->fieldLabel("Content")), $UploadField)));
$this->extend("updateCMSFields", $fields);
return $fields;
}
示例5: getCMSFields
public function getCMSFields()
{
$fields = new FieldList([TextField::create('Title')]);
if ($this->exists()) {
$folderName = 'Documents';
$config = $this->Page()->exists() ? $this->Page()->config()->get('page_documents') : null;
if (is_array($config)) {
if (isset($config['folder'])) {
$folderName = $config['folder'];
}
if (isset($config['section']) && $config['section']) {
$filter = new URLSegmentFilter();
$section = implode('-', array_map(function ($string) {
return ucfirst($string);
}, explode('-', $filter->filter($this->Title))));
$folderName .= '/' . $section;
}
}
$fields->push(SortableUploadField::create('Documents', 'Documents')->setDescription('Drag documents by thumbnail to sort')->setFolderName($folderName));
} else {
$fields->push(LiteralField::create('DocumentsNotSaved', '<p>Save category to add documents</p>'));
}
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例6: getCMSFields
public function getCMSFields()
{
Requirements::css('widgetify/thirdparty/codemirror-3.18/lib/codemirror.css');
Requirements::css('widgetify/css/widgetify_cms.css');
Requirements::javascript('framework/thirdparty/jquery/jquery.js');
Requirements::javascript('widgetify/thirdparty/codemirror-3.18/lib/codemirror.js');
Requirements::javascript('widgetify/thirdparty/codemirror-3.18/mode/xml/xml.js');
Requirements::javascript('widgetify/thirdparty/codemirror-3.18/mode/javascript/javascript.js');
Requirements::javascript('widgetify/thirdparty/codemirror-3.18/mode/css/css.js');
Requirements::javascript('widgetify/scripts/template_editor.js');
$fields = FieldList::create();
$fields->push(TextField::create('Title', 'Template Title', false, 100));
$fields->push(HeaderField::create('WidgetifyPreviewTitle', 'Preview', 4));
$fields->push(LiteralField::create('WidgetifyPreview', '<div id="widgetifyPreview" class="widgetifyTemplate"><p><strong>Click "Refresh & validate" to load preview</strong></p></div><p><a href="javascript:;" id="refreshAndValidate" class="ss-ui-action-constructive ss-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary">Refresh & validate</a></p>'));
$fields->push(LiteralField::create('WidgetifyLog', '<p><strong>Validation log:</strong></p><div id="widgetifyLog"></div>'));
$fields->push(HeaderField::create('WidgetifyEditorTitle', 'Template editor', 4));
$fields->push(LiteralField::create('WidgetifyEditorHelp', '<p><strong>Note:</strong> in the HTML tab, insert the tag <strong>{widget-UniqueIdentifier}</strong> where widgets should be placed. <em>Example: {widget-1} {widget-2} ...</em></p>'));
$fields->push(LiteralField::create('Tabs', '<p class="tabs"><a href="javascript:;" id="tabTemplate" class="selected tabChange">HTML</a><a href="javascript:;" id="tabCSS" class="tabChange">Stylesheet</a><a href="javascript:;" id="tabJS" class="tabChange">Javascript</a></p>'));
$fields->push(TextareaField::create('TemplateContent', false));
$fields->push(TextareaField::create('CSSContent', false));
$fields->push(TextareaField::create('JSContent', false));
if ($this->ID) {
$fields->push(HeaderField::create('WidgetifyRelatedTitle', 'Pages using this template', 4));
$fields->push(LiteralField::create('AppliedTo', $this->_getTablePages()));
}
return $fields;
}
示例7: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
//adding upload field - if item has already been saved
if ($this->ID && $this->AssetsFolderID != 0) {
//this is the default, for non multi-language sites
if (!class_exists('Translatable') || $this->Locale == Translatable::default_locale()) {
//Use SortableUploadField instead of UploadField!
//The upload directory is expected to have been set in {@see UploadDirRules},
//and should be something like: "assets/ID-Pagename"
//TODO: This could easily be configurable through yml files (to e.g. "assets/galleries/ID"),
//so this module could do without the upload dir rules
//
//read more about adding additinoal metadata to images here:
//http://doc.silverstripe.org/framework/en/reference/uploadfield
$imageField = new SortableUploadField('Images', '');
$fields->addFieldToTab('Root.Images', $imageField);
} else {
$orig = $this->getTranslation(Translatable::default_locale());
$html = sprintf('<a href="%s">%s</a>', Controller::join_links($orig->CMSEditLink(), '?locale=' . $orig->Locale), 'Images are administered through ' . i18n::get_locale_name($orig->Locale));
$fields->addFieldToTab('Root.Images', LiteralField::create('ImagesDesc', $html));
}
}
return $fields;
}
示例8: 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;
}
示例9: __construct
public function __construct($controller, $name, Order $order)
{
$this->order = $order;
$fields = FieldList::create(HiddenField::create('OrderID', '', $order->ID));
$actions = FieldList::create();
//payment
if (self::config()->allow_paying && $order->canPay()) {
$gateways = GatewayInfo::get_supported_gateways();
//remove manual gateways
foreach ($gateways as $gateway => $gatewayname) {
if (GatewayInfo::is_manual($gateway)) {
unset($gateways[$gateway]);
}
}
if (!empty($gateways)) {
$fields->push(HeaderField::create("MakePaymentHeader", _t("OrderActionsForm.MAKEPAYMENT", "Make Payment")));
$outstandingfield = Currency::create();
$outstandingfield->setValue($order->TotalOutstanding());
$fields->push(LiteralField::create("Outstanding", sprintf(_t("OrderActionsForm.OUTSTANDING", "Outstanding: %s"), $outstandingfield->Nice())));
$fields->push(OptionsetField::create('PaymentMethod', _t("OrderActionsForm.PAYMENTMETHOD", "Payment Method"), $gateways, key($gateways)));
$actions->push(FormAction::create('dopayment', _t('OrderActionsForm.PAYORDER', 'Pay outstanding balance')));
}
}
//cancelling
if (self::config()->allow_cancelling && $order->canCancel()) {
$actions->push(FormAction::create('docancel', _t('OrderActionsForm.CANCELORDER', 'Cancel this order')));
}
parent::__construct($controller, $name, $fields, $actions);
$this->extend("updateForm", $order);
}
示例10: 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;
}
示例11: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
// Payment Methods
$payment_table = GridField::create('PaymentMethods', _t("CheckoutAdmin.PaymentMethods", "Payment Methods"), $this->owner->PaymentMethods(), GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldAddNewButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(20), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm()));
// setup compressed payment options
$payment_fields = ToggleCompositeField::create('PaymentSettings', _t("CheckoutAdmin.Payments", "Payment Settings"), array(TextField::create('PaymentNumberPrefix', _t("CheckoutAdmin.OrderPrefix", "Add prefix to order numbers"), null, 9)->setAttribute("placeholder", _t("CheckoutAdmin.OrderPrefixPlaceholder", "EG 'abc'")), TextAreaField::create('PaymentSuccessContent', _t("CheckoutAdmin.PaymentSuccessContent", "Payment successfull content"))->setRows(4)->setColumns(30)->addExtraClass('stacked'), TextAreaField::create('PaymentFailerContent', _t("CheckoutAdmin.PaymentFailerContent", "Payment failer content"))->setRows(4)->setColumns(30)->addExtraClass('stacked'), $payment_table));
// Add html description of how to edit contries
$country_html = "<div class=\"field\">";
$country_html .= "<p>First select valid countries using the 2 character ";
$country_html .= "shortcode (see http://fasteri.com/list/2/short-names-of-countries-and-iso-3166-codes).</p>";
$country_html .= "<p>You can add multiple countries seperating them with";
$country_html .= "a comma or use a '*' for all countries.</p>";
$country_html .= "</div>";
$country_html_field = LiteralField::create("CountryDescription", $country_html);
// Deal with product features
$postage_field = new GridField('PostageAreas', '', $this->owner->PostageAreas(), GridFieldConfig::create()->addComponents(new GridFieldButtonRow('before'), new GridFieldToolbarHeader(), new GridFieldTitleHeader(), new GridFieldEditableColumns(), new GridFieldDeleteAction(), new GridFieldAddNewInlineButton('toolbar-header-left')));
// Add country dropdown to inline editing
$postage_field->getConfig()->getComponentByType('GridFieldEditableColumns')->setDisplayFields(array('Title' => array('title' => 'Title', 'field' => 'TextField'), 'Country' => array('title' => 'ISO 3166 codes', 'field' => 'TextField'), 'ZipCode' => array('title' => 'Zip/Post Codes', 'field' => 'TextField'), 'Calculation' => array('title' => 'Base unit', 'callback' => function ($record, $column, $grid) {
return DropdownField::create($column, "Based on", singleton('PostageArea')->dbObject('Calculation')->enumValues())->setValue("Weight");
}), 'Unit' => array('title' => 'Unit (equals or above)', 'field' => 'NumericField'), 'Cost' => array('title' => 'Cost', 'field' => 'NumericField'), 'Tax' => array('title' => 'Tax (percentage)', 'field' => 'NumericField')));
// Setup compressed postage options
$postage_fields = ToggleCompositeField::create('PostageFields', 'Postage Options', array($country_html_field, $postage_field));
// Setup compressed postage options
$discount_fields = ToggleCompositeField::create('DiscountFields', 'Discounts', array(GridField::create('Discounts', '', $this->owner->Discounts(), GridFieldConfig_RecordEditor::create())));
// Add config sets
$fields->addFieldToTab('Root.Checkout', $payment_fields);
$fields->addFieldToTab('Root.Checkout', $postage_fields);
$fields->addFieldToTab('Root.Checkout', $discount_fields);
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-checkout,代码行数:29,代码来源:CheckoutSiteConfigExtension.php
示例12: __construct
public function __construct($controller, $name = "PostagePaymentForm")
{
// Get delivery data and postage areas from session
$delivery_data = Session::get("Commerce.DeliveryDetailsForm.data");
$country = $delivery_data['DeliveryCountry'];
$postcode = $delivery_data['DeliveryPostCode'];
$postage_areas = $controller->getPostageAreas($country, $postcode);
// Loop through all postage areas and generate a new list
$postage_array = array();
foreach ($postage_areas as $area) {
$area_currency = new Currency("Cost");
$area_currency->setValue($area->Cost);
$postage_array[$area->ID] = $area->Title . " (" . $area_currency->Nice() . ")";
}
$postage_id = Session::get('Commerce.PostageID') ? Session::get('Commerce.PostageID') : 0;
// Setup postage fields
$postage_field = CompositeField::create(HeaderField::create("PostageHeader", _t('Commerce.Postage', "Postage")), OptionsetField::create("PostageID", _t('Commerce.PostageSelection', 'Please select your prefered postage'), $postage_array)->setValue($postage_id))->setName("PostageFields")->addExtraClass("unit")->addExtraClass("size1of2")->addExtraClass("unit-50");
// Get available payment methods and setup payment
$payment_methods = SiteConfig::current_site_config()->PaymentMethods();
// Deal with payment methods
if ($payment_methods->exists()) {
$payment_map = $payment_methods->map('ID', 'Label');
$payment_value = $payment_methods->filter('Default', 1)->first()->ID;
} else {
$payment_map = array();
$payment_value = 0;
}
$payment_field = CompositeField::create(HeaderField::create('PaymentHeading', _t('Commerce.Payment', 'Payment'), 2), OptionsetField::create('PaymentMethodID', _t('Commerce.PaymentSelection', 'Please choose how you would like to pay'), $payment_map, $payment_value))->setName("PaymentFields")->addExtraClass("unit")->addExtraClass("size1of2")->addExtraClass("unit-50");
$fields = FieldList::create(CompositeField::create($postage_field, $payment_field)->setName("PostagePaymentFields")->addExtraClass("units-row")->addExtraClass("line"));
$back_url = $controller->Link("billing");
$actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $back_url . '" class="btn btn-red commerce-action-back">' . _t('Commerce.Back', 'Back') . '</a>'), FormAction::create('doContinue', _t('Commerce.PaymentDetails', 'Enter Payment Details'))->addExtraClass('btn')->addExtraClass('commerce-action-next')->addExtraClass('btn-green'));
$validator = RequiredFields::create(array("PostageID", "PaymentMethod"));
parent::__construct($controller, $name, $fields, $actions, $validator);
}
示例13: getCMSFields
/**
* @return FieldList
*/
public function getCMSFields()
{
// Get NotifiedOn implementors
$types = ClassInfo::implementorsOf('NotifiedOn');
$types = array_combine($types, $types);
unset($types['NotifyOnThis']);
if (!$types) {
$types = array();
}
array_unshift($types, '');
// Available keywords
$keywords = $this->getKeywords();
if (count($keywords)) {
$availableKeywords = '<div class="field"><div class="middleColumn"><p><u>Available Keywords:</u> </p><ul><li>$' . implode('</li><li>$', $keywords) . '</li></ul></div></div>';
} else {
$availableKeywords = "Available keywords will be shown if you select a NotifyOnClass";
}
// Identifiers
$identifiers = $this->config()->get('identifiers');
if (count($identifiers)) {
$identifiers = array_combine($identifiers, $identifiers);
}
$fields = FieldList::create();
$relevantMsg = 'Relevant for (note: this notification will only be sent if the context of raising the notification is of this type)';
$fields->push(TabSet::create('Root', Tab::create('Main', DropdownField::create('Identifier', _t('SystemNotification.IDENTIFIER', 'Identifier'), $identifiers), TextField::create('Title', _t('SystemNotification.TITLE', 'Title')), TextField::create('Description', _t('SystemNotification.DESCRIPTION', 'Description')), DropdownField::create('NotifyOnClass', _t('SystemNotification.NOTIFY_ON_CLASS', $relevantMsg), $types), TextField::create('CustomTemplate', _t('SystemNotification.TEMPLATE', 'Template (Optional)'))->setAttribute('placeholder', $this->config()->get('default_template')), LiteralField::create('AvailableKeywords', $availableKeywords))));
if ($this->config()->html_notifications) {
$fields->insertBefore(HTMLEditorField::create('NotificationHTML', _t('SystemNotification.TEXT', 'Text')), 'AvailableKeywords');
} else {
$fields->insertBefore(TextareaField::create('NotificationText', _t('SystemNotification.TEXT', 'Text')), 'AvailableKeywords');
}
return $fields;
}
示例14: getCMSFields
public function getCMSFields()
{
Requirements::css('widgetify/css/widgetify_cms.css');
Requirements::javascript('framework/thirdparty/jquery/jquery.js');
Requirements::javascript('widgetify/scripts/widgetify_page.js');
$fields = parent::getCMSFields();
$fields->push(HiddenField::create('WidgetifyContent', 'WidgetifyContent'));
$fields->push(HiddenField::create('ThisID', 'ThisID', $this->ID));
$tab = $fields->findOrMakeTab('Root.Main');
$tab->insertAfter(HeaderField::create('WidgetifyTitle', 'Widgetify Template', 3), 'Metadata');
if (!$this->WidgetifyTemplateID) {
$this->WidgetifyTemplateID = 0;
}
$templatesMap = DataList::create('WidgetifyTemplate')->map();
$tab->insertAfter(DropdownField::create('WidgetifyTemplateID', 'Select Template', $templatesMap)->setEmptyString('- Select -'), 'WidgetifyTitle');
$tab->insertAfter(CheckboxField::create('CSSFrontend', 'Apply template Stylesheet to front-end page'), 'WidgetifyTemplateID');
$tab->insertAfter(CheckboxField::create('JSFrontend', 'Apply template Javascript to front-end page'), 'CSSFrontend');
$tab->insertAfter(HeaderField::create('WidgetifyPreviewTitle', 'Widgetify Content', 3), 'JSFrontend');
$tab->insertAfter(LiteralField::create('WidgetifyPreview', '<div id="widgetifyPreview" class="widgetifyTemplate"></div>'), 'WidgetifyPreviewTitle');
$htmlField = HtmlEditorField::create('WidgetDynamicContent', false);
$editorFieldContents = '
<div id="WidgetDynamicContentHolder" class="WidgetDynamicContentHolder">
<p id="edit-widget-title">Edit content</p>' . $htmlField->forTemplate() . '
<p class="widget-edit-actions">
<a href="javascript:;" id="save-widget-content" class="ss-ui-action-constructive ss-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary">Update</a>
<a href="javascript:;" id="cancel-widget-content" class="ss-ui-action-destructive ui-button ui-widget ui-state-default ui-button-text-icon-primary ui-corner-left ss-ui-button">Cancel</a>
</p>
</div>';
$tab->insertAfter(LiteralField::create('WidgetDynamicContentPlaceHolder', $editorFieldContents), 'WidgetifyPreview');
$fields->removeFieldFromTab('Root.Main', 'Content');
return $fields;
}
示例15: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeFieldFromTab('Root', 'Pages');
$fields->removeFieldsFromTab('Root.Main', array('SortOrder', 'showBlockbyClass', 'shownInClass', 'MemberVisibility'));
$fields->addFieldToTab('Root.Main', LiteralField::create('Status', 'Published: ' . $this->Published()), 'Title');
$memberGroups = Group::get();
$sourcemap = $memberGroups->map('Code', 'Title');
$source = array('anonymous' => 'Anonymous visitors');
foreach ($sourcemap as $mapping => $key) {
$source[$mapping] = $key;
}
$memberVisibility = new CheckboxSetField($name = "MemberVisibility", $title = "Show block for specific groups", $source);
$memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
$availabelClasses = $this->availableClasses();
$inClass = new CheckboxSetField($name = "shownInClass", $title = "Show block for specific content types", $availabelClasses);
$filterSelector = OptionsetField::create('showBlockbyClass', 'Choose filter set', array('0' => 'by page', '1' => 'by page/data type'))->setDescription('<p><br /><strong>by page</strong>: block will be displayed in the selected page(s)<br /><strong>by page/data type</strong>: block will be displayed on the pages created with the particular page/data type. e.g. is <strong>"InternalPage"</strong> is picked, the block will be displayed, and will ONLY be displayed on all <strong>Internal Pages</strong></p>');
$availablePages = Page::get()->exclude('ClassName', array('ErrorPage', 'RedirectorPage', 'VirtualPage'));
$pageSelector = new CheckboxSetField($name = "Pages", $title = "Show on Page(s)", $availablePages->map('ID', 'Title'));
if ($this->canConfigPageAndType(Member::currentUser())) {
$fields->addFieldsToTab('Root.VisibilitySettings', array($filterSelector, $pageSelector, $inClass));
}
if ($this->canConfigMemberVisibility(Member::currentUser())) {
$fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility);
}
if (!$fields->fieldByName('Options')) {
$fields->insertBefore($right = RightSidebar::create('Options'), 'Root');
}
$fields->addFieldsToTab('Options', array(CheckboxField::create('addMarginTop', 'add "margin-top" class to block wrapper'), CheckboxField::create('addMarginBottom', 'add "margin-bottom" class to block wrapper')));
return $fields;
}