本文整理汇总了PHP中LiteralField类的典型用法代码示例。如果您正苦于以下问题:PHP LiteralField类的具体用法?PHP LiteralField怎么用?PHP LiteralField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LiteralField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ItemEditForm
/**
* Additional magic happens here. Trick LeftAndMain into thinking we're a previewable SiteTree object.
*
* @return Form
*/
public function ItemEditForm()
{
Requirements::javascript(MODULATOR_PATH . '/javascript/LeftAndMain.Preview.js');
$form = parent::ItemEditForm();
$record = $this->getRecord();
// Hide the 'Save & publish' button if we're on a brand new module.
if ($record && $record->ID == 0) {
$actions = $form->Actions();
// Remove the publish button on the pre-module state
$actions->removeByName('action_publish');
// Remove the save action if there are no sub-classes to instantiate
$classes = ClassInfo::subclassesFor('PageModule');
unset($classes['PageModule']);
if (!count($classes)) {
$actions->removeByName('action_save');
}
}
// Enable CMS preview
// .cms-previewable enables the preview panel in the front-end
// .cms-pagemodule CSS class is used by our javascript to handle previews
if ($form && is_object($form)) {
$form->addExtraClass('cms-previewable cms-pagemodule');
}
// Creat a navigaor and point it at the parent page
$navigator = new SilverStripeNavigator($this->record->Page());
$navField = new LiteralField('SilverStripeNavigator', $navigator->renderWith('LeftAndMain_SilverStripeNavigator'));
$navField->setAllowHTML(true);
$fields = $form->Fields();
$fields->push($navField);
return $form;
}
示例2: getEditForm
/**
* @return Form
*/
public function getEditForm($id = null, $fields = null)
{
$siteConfig = SiteConfig::current_site_config();
$fields = $siteConfig->getCMSFields();
// Tell the CMS what URL the preview should show
$fields->push(new HiddenField('PreviewURL', 'Preview URL', RootURLController::get_homepage_link()));
// Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load
$fields->push($navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator()));
$navField->setAllowHTML(true);
$actions = $siteConfig->getCMSActions();
$form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
$form->setResponseNegotiator($this->getResponseNegotiator());
$form->addExtraClass('cms-content center cms-edit-form');
// don't add data-pjax-fragment=CurrentForm, its added in the content template instead
if ($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
}
$form->setHTMLID('Form_EditForm');
$form->loadDataFrom($siteConfig);
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
// Use <button> to allow full jQuery UI styling
$actions = $actions->dataFields();
if ($actions) {
foreach ($actions as $action) {
$action->setUseButtonTag(true);
}
}
$this->extend('updateEditForm', $form);
return $form;
}
示例3: getCompositeField
/**
* @return Comosite FieldSet with Categorys and Items
*/
function getCompositeField()
{
//create new composite field group for each category
$oCatFieldSet = new CompositeField();
// Set the field group ID
$oCatFieldSet->setID('Cat' . $this->ID);
$oCatFieldSet->addExtraClass('category');
//create new composite field group for each category
$oCatField = new TextField($this->ID . '_' . $this->FieldName, $this->Title, null, null);
$oCatField->addExtraClass('category-field');
//Add Category Percentage Field to the Form
$oCatFieldSet->push($oCatField);
if ($this->Description) {
$oCatDescField = new LiteralField($this->ID . '_Description', '<p class="category-field-desc">' . $this->Description . '</p>');
$oCatDescField->addExtraClass('category-field');
$oCatFieldSet->push($oCatDescField);
}
//Add item Composite Field to this Composite Field
//now get all of the items matched with this category
$oFormCategoryItems = self::FormCategoryItems();
foreach ($oFormCategoryItems as $item) {
$oCatFieldSet->push($item->getFormField());
}
return $oCatFieldSet;
}
示例4: injectNavigatorAndPreview
private function injectNavigatorAndPreview(&$form, &$fields)
{
$editForm = $fields->fieldByName('EditForm');
//TODO: Do we need to verify we are in the right controller?
$template = Controller::curr()->getTemplatesWithSuffix('_SilverStripeNavigator');
$navigator = new SilverStripeNavigator($this->owner->record);
$field = new LiteralField('SilverStripeNavigator', $navigator->renderWith($template));
$field->setAllowHTML(true);
$fields->push($field);
$form->addExtraClass('cms-previewable');
$form->addExtraClass(' cms-previewabledataobject');
$form->removeExtraClass('cms-panel-padded center');
}
开发者ID:helpfulrobot,项目名称:jotham-silverstripe-dataobject-preview,代码行数:13,代码来源:PreviewableDataObjectExt.php
示例5: ItemEditForm
public function ItemEditForm()
{
$form = parent::ItemEditForm();
// Do these action update only when the current record is_a newsletter
if ($this->record && $this->record instanceof Newsletter) {
$form->setActions($this->updateCMSActions($form->Actions()));
$form->Fields()->push(new HiddenField("PreviewURL", "PreviewURL", $this->LinkPreview()));
// Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load
$navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator());
$navField->setAllowHTML(true);
$form->Fields()->push($navField);
}
return $form;
}
示例6: index
public function index()
{
$site = SiteConfig::current_site_config();
$order = $this->order;
// Setup the paypal gateway URL
if (Director::isDev()) {
$gateway_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
} else {
$gateway_url = "https://www.paypal.com/cgi-bin/webscr";
}
$callback_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, "callback", $this->payment_gateway->ID);
$success_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete');
$error_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete', 'error');
$back_url = Controller::join_links(Director::absoluteBaseURL(), Checkout_Controller::config()->url_segment, "finish");
$fields = new FieldList(HiddenField::create('business', null, $this->payment_gateway->BusinessID), HiddenField::create('item_name', null, $site->Title), HiddenField::create('cmd', null, "_cart"), HiddenField::create('paymentaction', null, "sale"), HiddenField::create('invoice', null, $order->OrderNumber), HiddenField::create('custom', null, $order->OrderNumber), HiddenField::create('upload', null, 1), HiddenField::create('discount_amount_cart', null, $order->DiscountAmount), HiddenField::create('amount', null, $order->Total), HiddenField::create('currency_code', null, $site->Currency()->GatewayCode), HiddenField::create('first_name', null, $order->FirstName), HiddenField::create('last_name', null, $order->Surname), HiddenField::create('address1', null, $order->Address1), HiddenField::create('address2', null, $order->Address2), HiddenField::create('city', null, $order->City), HiddenField::create('zip', null, $order->PostCode), HiddenField::create('country', null, $order->Country), HiddenField::create('email', null, $order->Email), HiddenField::create('return', null, $success_url), HiddenField::create('notify_url', null, $callback_url), HiddenField::create('cancel_return', null, $error_url));
$i = 1;
foreach ($order->Items() as $item) {
$fields->add(HiddenField::create('item_name_' . $i, null, $item->Title));
$fields->add(HiddenField::create('amount_' . $i, null, number_format($item->Price + $item->Tax, 2)));
$fields->add(HiddenField::create('quantity_' . $i, null, $item->Quantity));
$i++;
}
// Add shipping as an extra product
$fields->add(HiddenField::create('item_name_' . $i, null, _t("Commerce.Postage", "Postage")));
$fields->add(HiddenField::create('amount_' . $i, null, number_format($order->PostageCost + $order->PostageTax, 2)));
$fields->add(HiddenField::create('quantity_' . $i, null, "1"));
$actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $back_url . '" class="btn btn-red commerce-action-back">' . _t('Commerce.Back', 'Back') . '</a>'), FormAction::create('Submit', _t('Commerce.ConfirmPay', 'Confirm and Pay'))->addExtraClass('btn')->addExtraClass('btn-green'));
$form = Form::create($this, 'Form', $fields, $actions)->addExtraClass('forms')->setFormMethod('POST')->setFormAction($gateway_url);
$this->extend('updateForm', $form);
return array("Title" => _t('Commerce.CheckoutSummary', "Summary"), "MetaTitle" => _t('Commerce.CheckoutSummary', "Summary"), "Form" => $form);
}
示例7: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeByName('Features');
$fields->removeByName('ExtraContent');
$regContent = $fields->dataFieldByName('RegistrationContent');
$afterContent = $fields->dataFieldByName('AfterRegistrationContent');
$profileContent = $fields->dataFieldByName('ProfileContent');
$regContent->addExtraClass('no-pagebreak');
$afterContent->addExtraClass('no-pagebreak');
$profileContent->addExtraClass('no-pagebreak');
$fields->insertAfter(TextareaField::create('ApprovalEmailTemplate', 'Approval Email Template'), 'EmailTemplate');
$fields->insertAfter(TextField::create('ApprovalEmailSubject', 'Approval Email Subject'), 'EmailTemplate');
$fields->insertAfter(TextareaField::create('ExpiryReminderEmailTemplate', 'Expiry Reminder Email Template'), 'ApprovalEmailTemplate');
$fields->insertAfter(TextField::create('ExpiryReminderEmailSubject', 'Expiry Reminder Email Subject'), 'ApprovalEmailTemplate');
$fields->insertAfter(TextareaField::create('ExpiryEmailTemplate', 'Expiry Email Template'), 'ExpiryReminderEmailTemplate');
$fields->insertAfter(TextField::create('ExpiryEmailSubject', 'Expiry Email Subject'), 'ExpiryReminderEmailTemplate');
$fields->addFieldToTab('Root.Members', LiteralField::create('MembersNote', '<p class="message"><strong>Note:</strong> This list has been filtered to include current and pending members only. Use the Members admin area for handling expired memberships and non-member website users.</p>'));
$members = Member::get()->exclude(array('MembershipStatus' => 'Not applied'))->exclude(array('MembershipStatus' => 'Expired'))->sort(array('ExpiryDate' => 'ASC'));
$gridField = new GridField('Members', 'NZLARP Members', $members, $config = GridFieldConfig_RecordEditor::create());
$gridField->setModelClass('Member');
$columns = $config->getComponentByType('GridFieldDataColumns');
$columns->setFieldFormatting(array('LastEdited' => function ($value, $item) {
return $item->LastEditedNice();
}));
$columns->setDisplayFields(array('getName' => 'Name', 'Region.Title' => 'Region', 'MembershipStatus' => 'Status', 'ExpiryDate' => 'Expires', 'LastEdited' => 'Last Activity'));
$fields->addFieldToTab('Root.Members', $gridField);
$config->getComponentByType('GridFieldPaginator')->setItemsPerPage(200);
return $fields;
}
示例8: ShortcodeForm
/**
* Provides a GUI for the insert/edit shortcode popup
* @return Form
**/
public function ShortcodeForm()
{
if (!Permission::check('CMS_ACCESS_CMSMain')) {
return;
}
Config::inst()->update('SSViewer', 'theme_enabled', false);
// create a list of shortcodable classes for the ShortcodeType dropdown
$classList = ClassInfo::implementorsOf('Shortcodable');
$classes = array();
foreach ($classList as $class) {
$classes[$class] = singleton($class)->singular_name();
}
// load from the currently selected ShortcodeType or Shortcode data
$classname = false;
$shortcodeData = false;
if ($shortcode = $this->request->requestVar('Shortcode')) {
$shortcode = str_replace("", '', $shortcode);
//remove BOM inside string on cursor position...
$shortcodeData = singleton('ShortcodableParser')->the_shortcodes(array(), $shortcode);
if (isset($shortcodeData[0])) {
$shortcodeData = $shortcodeData[0];
$classname = $shortcodeData['name'];
}
} else {
$classname = $this->request->requestVar('ShortcodeType');
}
if ($shortcodeData) {
$headingText = _t('Shortcodable.EDITSHORTCODE', 'Edit Shortcode');
} else {
$headingText = _t('Shortcodable.INSERTSHORTCODE', 'Insert Shortcode');
}
// essential fields
$fields = FieldList::create(array(CompositeField::create(LiteralField::create('Heading', sprintf('<h3 class="htmleditorfield-shortcodeform-heading insert">%s</h3>', $headingText)))->addExtraClass('CompositeField composite cms-content-header nolabel'), LiteralField::create('shortcodablefields', '<div class="ss-shortcodable content">'), DropdownField::create('ShortcodeType', 'ShortcodeType', $classes, $classname)->setHasEmptyDefault(true)->addExtraClass('shortcode-type')));
// attribute and object id fields
if ($classname) {
if (class_exists($classname)) {
$class = singleton($classname);
if (is_subclass_of($class, 'DataObject')) {
if (singleton($classname)->hasMethod('get_shortcodable_records')) {
$dataObjectSource = $classname::get_shortcodable_records();
} else {
$dataObjectSource = $classname::get()->map()->toArray();
}
$fields->push(DropdownField::create('id', $class->singular_name(), $dataObjectSource)->setHasEmptyDefault(true));
}
if ($attrFields = $classname::shortcode_attribute_fields()) {
$fields->push(CompositeField::create($attrFields)->addExtraClass('attributes-composite'));
}
}
}
// actions
$actions = FieldList::create(array(FormAction::create('insert', _t('Shortcodable.BUTTONINSERTSHORTCODE', 'Insert shortcode'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
// form
$form = Form::create($this, "ShortcodeForm", $fields, $actions)->loadDataFrom($this)->addExtraClass('htmleditorfield-form htmleditorfield-shortcodable cms-dialog-content');
if ($shortcodeData) {
$form->loadDataFrom($shortcodeData['atts']);
}
$this->extend('updateShortcodeForm', $form);
return $form;
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-shortcodable,代码行数:64,代码来源:ShortcodableController.php
示例9: updateDynamicListCMSFields
public function updateDynamicListCMSFields($fields)
{
// Make sure the draft records are being looked at.
$stage = Versioned::current_stage();
Versioned::reading_stage('Stage');
$used = EditableFormField::get()->filter(array('ClassName:PartialMatch' => 'DynamicList'));
// Determine whether this dynamic list is being used anywhere.
$found = array();
foreach ($used as $field) {
// This information is stored using a serialised list, therefore we need to iterate through.
if ($field->getSetting('ListTitle') === $this->owner->Title) {
// Make sure there are no duplicates recorded.
if (!isset($found[$field->ParentID]) && ($form = UserDefinedForm::get()->byID($field->ParentID))) {
$found[$field->ParentID] = "<a href='{$form->CMSEditLink()}'>{$form->Title}</a>";
}
}
}
// Display whether there were any dynamic lists found on user defined forms.
if (count($found)) {
$fields->removeByName('UsedOnHeader');
$fields->addFieldToTab('Root.Main', HeaderField::create('UsedOnHeader', 'Used On', 5));
}
$display = count($found) ? implode('<br>', $found) : 'This dynamic list is <strong>not</strong> used.';
$fields->removeByName('UsedOn');
$fields->addFieldToTab('Root.Main', LiteralField::create('UsedOn', '<div>' . $display . '</div>'));
Versioned::reading_stage($stage);
}
示例10: getCMSFields
public function getCMSFields($params = null)
{
//fields that shouldn't be changed once coupon is used
$fields = new FieldList(array($tabset = new TabSet("Root", $maintab = new Tab("Main", TextField::create("Title"), CheckboxField::create("Active", "Active")->setDescription("Enable/disable all use of this discount."), HeaderField::create("ActionTitle", "Action", 3), $typefield = SelectionGroup::create("Type", array(new SelectionGroup_Item("Percent", $percentgroup = FieldGroup::create($percentfield = NumericField::create("Percent", "Percentage", "0.00")->setDescription("e.g. 0.05 = 5%, 0.5 = 50%, and 5 = 500%"), $maxamountfield = CurrencyField::create("MaxAmount", _t("MaxAmount", "Maximum Amount"))->setDescription("The total allowable discount. 0 means unlimited.")), "Discount by percentage"), new SelectionGroup_Item("Amount", $amountfield = CurrencyField::create("Amount", "Amount", "\$0.00"), "Discount by fixed amount")))->setTitle("Type"), OptionSetField::create("For", "Applies to", array("Order" => "Entire Order", "Cart" => "Cart Subtotal", "Shipping" => "Shipping Subtotal", "Items" => "Each Individual Item")), new Tab("Main", HeaderField::create("ConstraintsTitle", "Constraints", 3), LabelField::create("ConstraintsDescription", "Configure the requirements an order must meet for this discount to be valid:")), new TabSet("Constraints")))));
if (!$this->isInDB()) {
$fields->addFieldToTab("Root.Main", LiteralField::create("SaveNote", "<p class=\"message good\">More constraints will show up after you save for the first time.</p>"), "Constraints");
}
$this->extend("updateCMSFields", $fields, $params);
if ($count = $this->getUseCount()) {
$fields->addFieldsToTab("Root.Usage", array(HeaderField::create("UseCount", sprintf("This discount has been used {$count} time%s.", $count > 1 ? "s" : "")), HeaderField::create("TotalSavings", sprintf("A total of %s has been saved by customers using this discount.", $this->SavingsTotal), "3"), GridField::create("Orders", "Orders", $this->getAppliedOrders(), GridFieldConfig_RecordViewer::create()->removeComponentsByType("GridFieldViewButton"))));
}
if ($params && isset($params['forcetype'])) {
$valuefield = $params['forcetype'] == "Percent" ? $percentfield : $amountfield;
$fields->insertAfter($valuefield, "Type");
$fields->removeByName("Type");
} elseif ($this->Type && (double) $this->{$this->Type}) {
$valuefield = $this->Type == "Percent" ? $percentfield : $amountfield;
$fields->removeByName("Type");
$fields->insertAfter($valuefield, "ActionTitle");
$fields->replaceField($this->Type, $valuefield->performReadonlyTransformation());
if ($this->Type == "Percent") {
$fields->insertAfter($maxamountfield, "Percent");
}
}
return $fields;
}
示例11: 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;
}
示例12: 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;
}
示例13: 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;
}
示例14: 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;
}
示例15: 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;
}