/** * 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; }
/** * @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; }
/** * @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; }
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'); }
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; }
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); }
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; }
/** * 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; }
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); }
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; }
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; }
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; }
public function __construct($name, $options = array()) { // Set map defaults $defaults = ["width" => "100%", "height" => "500px", "heading" => "", "lng_field" => "Form_ItemEditForm_Lng", "lat_field" => "Form_ItemEditForm_Lat", "tab" => "Root_Location", "address_field" => "Address", "map_zoom" => 18, "start_lat" => "51.508515", "start_lng" => "-0.125487"]; // Merge provided options with defaults to create params $params = array_replace_recursive($defaults, $options); // Set css of map $css = "style='width: " . $params['width'] . "; height: " . $params['height'] . ";'"; if (defined('GOOGLE_MAP_KEY') && empty($google_map_api_key)) { $google_map_api_key = GOOGLE_MAP_KEY; } if (empty($google_map_api_key)) { throw new InvalidArgumentException('you must provide a valid google maps api key!'); } // Set up array to be fed to the JS $js = ["lat_field" => $params['lat_field'], "lng_field" => $params['lng_field'], "tab" => $params['tab'], "address_field" => $params['address_field'], "zoom" => $params['map_zoom'], "start_lat" => $params['start_lat'], "start_lng" => $params['start_lng'], "key" => $google_map_api_key]; // Build content of form field $content = ""; if ($params['heading']) { $content .= "<h4>" . $params['heading'] . "</h4>"; } $content .= "<div id='admin-map-" . $name . "' class='admin-google-map' " . $css . " data-setup='" . json_encode($js) . "'></div>"; $this->content = $content; // Establish requirements Requirements::javascript(ADMIN_GOOGLE_MAP_DIR . "/js/admin-google-map.js"); if (!$this->stat('jquery_included')) { Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js"); } parent::__construct($name, $this->content); }
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; }
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; }
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 __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); }
/** * 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 updateCMSFields(FieldList $fields) { $fields->removeByName(array('Lat', 'Lng')); // Adds Lat/Lng fields for viewing in the CMS $compositeField = CompositeField::create(); $compositeField->push($overrideField = CheckboxField::create('LatLngOverride', 'Override Latitude and Longitude?')); $overrideField->setDescription('Check this box and save to be able to edit the latitude and longitude manually.'); if ($this->owner->Lng && $this->owner->Lat) { $googleMapURL = 'http://maps.google.com/?q=' . $this->owner->Lat . ',' . $this->owner->Lng; $googleMapDiv = '<div class="field"><label class="left" for="Form_EditForm_MapURL_Readonly">Google Map</label><div class="middleColumn"><a href="' . $googleMapURL . '" target="_blank">' . $googleMapURL . '</a></div></div>'; $compositeField->push(LiteralField::create('MapURL_Readonly', $googleMapDiv)); } if ($this->owner->LatLngOverride) { $compositeField->push(TextField::create('Lat', 'Lat')); $compositeField->push(TextField::create('Lng', 'Lng')); } else { $compositeField->push(ReadonlyField::create('Lat_Readonly', 'Lat', $this->owner->Lat)); $compositeField->push(ReadonlyField::create('Lng_Readonly', 'Lng', $this->owner->Lng)); } if ($this->owner->hasExtension('Addressable')) { // If using addressable, put the fields with it $fields->addFieldToTab('Root.Address', ToggleCompositeField::create('Coordinates', 'Coordinates', $compositeField)); } else { if ($this->owner instanceof SiteTree) { // If SIteTree but not using Addressable, put after 'Metadata' toggle composite field $fields->insertAfter($compositeField, 'ExtraMeta'); } else { $fields->addFieldToTab('Root.Main', ToggleCompositeField::create('Coordinates', 'Coordinates', $compositeField)); } } }
public function 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; }
/** * @param FieldList $fields */ public function updateCMSFields(FieldList $fields) { Requirements::add_i18n_javascript(ADVANCED_WORKFLOW_DIR . '/javascript/lang'); // Add timepicker functionality // @see https://github.com/trentrichardson/jQuery-Timepicker-Addon Requirements::css(ADVANCED_WORKFLOW_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-timepicker-addon.css'); Requirements::css(ADVANCED_WORKFLOW_DIR . '/css/WorkflowCMS.css'); Requirements::javascript(ADVANCED_WORKFLOW_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-sliderAccess.js'); Requirements::javascript(ADVANCED_WORKFLOW_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-timepicker-addon.js'); Requirements::javascript(ADVANCED_WORKFLOW_DIR . '/javascript/WorkflowField.js'); $this->setIsWorkflowInEffect(); $fields->findOrMakeTab('Root.PublishingSchedule', _t('WorkflowEmbargoExpiryExtension.TabTitle', 'Publishing Schedule')); if ($this->getIsWorkflowInEffect()) { $fields->addFieldsToTab('Root.PublishingSchedule', array(HeaderField::create('PublishDateHeader', _t('WorkflowEmbargoExpiryExtension.REQUESTED_PUBLISH_DATE_H3', 'Expiry and Embargo'), 3), LiteralField::create('PublishDateIntro', $this->getIntroMessage('PublishDateIntro')), $dt = Datetimefield::create('DesiredPublishDate', _t('WorkflowEmbargoExpiryExtension.REQUESTED_PUBLISH_DATE', 'Requested publish date')), $ut = Datetimefield::create('DesiredUnPublishDate', _t('WorkflowEmbargoExpiryExtension.REQUESTED_UNPUBLISH_DATE', 'Requested un-publish date')), Datetimefield::create('PublishOnDate', _t('WorkflowEmbargoExpiryExtension.PUBLISH_ON', 'Scheduled publish date'))->setDisabled(true), Datetimefield::create('UnPublishOnDate', _t('WorkflowEmbargoExpiryExtension.UNPUBLISH_ON', 'Scheduled un-publish date'))->setDisabled(true))); } else { $fields->addFieldsToTab('Root.PublishingSchedule', array(HeaderField::create('PublishDateHeader', _t('WorkflowEmbargoExpiryExtension.REQUESTED_PUBLISH_DATE_H3', 'Expiry and Embargo'), 3), LiteralField::create('PublishDateIntro', $this->getIntroMessage('PublishDateIntro')), $dt = Datetimefield::create('PublishOnDate', _t('WorkflowEmbargoExpiryExtension.PUBLISH_ON', 'Scheduled publish date')), $ut = Datetimefield::create('UnPublishOnDate', _t('WorkflowEmbargoExpiryExtension.UNPUBLISH_ON', 'Scheduled un-publish date')))); } $dt->getDateField()->setConfig('showcalendar', true); $ut->getDateField()->setConfig('showcalendar', true); $dt->getTimeField()->setConfig('timeformat', 'HH:mm:ss'); $ut->getTimeField()->setConfig('timeformat', 'HH:mm:ss'); // Enable a jQuery-UI timepicker widget if (self::$showTimePicker) { $dt->getTimeField()->addExtraClass('hasTimePicker'); $ut->getTimeField()->addExtraClass('hasTimePicker'); } }
/** * @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)); }
/** * updateCMSFields. * Update Silverstripe CMS Fields for SEO Module * * @param FieldList * @return none */ public function updateCMSFields(FieldList $fields) { // exclude SEO tab from some pages if (in_array($this->owner->getClassName(), Config::inst()->get("SeoObjectExtension", "excluded_page_types"))) { return; } Requirements::css(SEO_DIR . '/css/seo.css'); Requirements::javascript(SEO_DIR . '/javascript/seo.js'); // better do this below in some init method? : $this->getSEOScoreCalculation(); $this->setSEOScoreTipsUL(); // lets create a new tab on top $fields->addFieldsToTab('Root.SEO', array(LiteralField::create('googlesearchsnippetintro', '<h3>' . _t('SEO.SEOGoogleSearchPreviewTitle', 'Preview google search') . '</h3>'), LiteralField::create('googlesearchsnippet', '<div id="google_search_snippet"></div>'), LiteralField::create('siteconfigtitle', '<div id="ss_siteconfig_title">' . $this->owner->getSiteConfig()->Title . '</div>'))); // move Metadata field from Root.Main to SEO tab for visualising direct impact on search result $fields->removeFieldFromTab('Root.Main', 'Metadata'); /*$fields->addFieldToTab("Root.SEO", new TabSet('Options', new Tab('Metadata', _t('SEO.SEOMetaData', 'Meta Data')), new Tab('HelpAndSEOScore', _t('SEO.SEOHelpAndScore', 'Help and SEO Score')) ));*/ $fields->addFieldsToTab('Root.SEO', array(TextareaField::create("MetaDescription", $this->owner->fieldLabel('MetaDescription'))->setRightTitle(_t('SiteTree.METADESCHELP', "Search engines use this content for displaying search results (although it will not influence their ranking)."))->addExtraClass('help'), TextareaField::create("ExtraMeta", $this->owner->fieldLabel('ExtraMeta'))->setRightTitle(_t('SiteTree.METAEXTRAHELP', "HTML tags for additional meta information. For example <meta name=\"customName\" content=\"your custom content here\" />"))->addExtraClass('help'))); $fields->addFieldsToTab('Root.SEO', array(GoogleSuggestField::create("SEOPageSubject", _t('SEO.SEOPageSubjectTitle', 'Subject of this page (required to view this page SEO score)')), LiteralField::create('', '<div class="message notice"><p>' . _t('SEO.SEOSaveNotice', "After making changes save this page to view the updated SEO score") . '</p></div>'), LiteralField::create('ScoreTitle', '<h4 class="seo_score">' . _t('SEO.SEOScore', 'SEO Score') . '</h4>'), LiteralField::create('Score', $this->getHTMLStars()), LiteralField::create('ScoreClear', '<div class="score_clear"></div>'))); if ($this->checkPageSubjectDefined()) { $fields->addFieldsToTab('Root.SEO', array(LiteralField::create('SimplePageSubjectCheckValues', $this->getHTMLSimplePageSubjectTest()))); } if ($this->seo_score < 12) { $fields->addFieldsToTab('Root.SEO', array(LiteralField::create('ScoreTipsTitle', '<h4 class="seo_score">' . _t('SEO.SEOScoreTips', 'SEO Score Tips') . '</h4>'), LiteralField::create('ScoreTips', $this->seo_score_tips))); } }
public function updateSettingsFields(FieldList $fields) { //removing view settings $fields->removeByName("CanViewType"); $fields->removeByName("ViewerGroups"); //adding view settings displaying the custom hard coded view settings $groups = $this->owner->DictatedViewerGroups(); $groupsStr = ''; if ($groups) { foreach ($groups as $g) { $groupsStr .= "{$g->Title}, "; } $groupsStr = rtrim($groupsStr, ', '); } else { $groupsStr = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users"); } $fields->addFieldToTab('Root', LiteralField::create('CanViewTypeExpl', ' <div class="field fieldgroup fieldgroup"> <label class="left">' . _t('SiteTree.ACCESSHEADER', "Who can view this page?") . '</label> <div class="middleColumn fieldgroup "> <p> <em>' . $groupsStr . '</em> </p> </div> </div> '), 'CanEditType'); }
/** * Returns array of fields to be added to Gallery Images Tab * * @return array */ public function getFieldsForImagesTab() { $aFields[] = new HeaderField(_t('ResponsiveGalleryExtension.SOURCE_HEADER', 'Choose your desired image source')); $aFields[] = new OptionsetField("Source", _t('ResponsiveGalleryExtension.SOURCE_LABEL', 'Source'), array("sf" => _t('ResponsiveGalleryExtension.SOURCEFOLDER_LABEL', 'Source Folder'), "dl" => _t('ResponsiveGalleryExtension.DATALIST_LABEL', 'Data List')), "sf"); switch ($this->owner->Source) { case "dl": $oGridFieldConfig = GridFieldConfig_RelationEditor::create()->addComponents(new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm(), new GridFieldBulkUpload('GalleryImage'), new GridFieldSortableRows('SortOrder')); $oGridFieldConfig->getComponentByType('GridFieldBulkUpload')->setUfSetup('setFolderName', $this->getUploadFolder())->setUfConfig('sequentialUploads', true); $aFields[] = new HeaderField(_t('ResponsiveGalleryExtension.DATALIST_HEADER', 'Create your image list')); $aFields[] = LiteralField::create("DataListInfo", '<div class="field"><p>' . _t('ResponsiveGalleryExtension.DATALIST_INFO', 'You can select images from files or upload images and add them to your customized image list. ' . 'Use "Target Folder" field to select a default target folder for your image uploads.') . '</p></div>'); $aFields[] = new TreeDropdownField('UploadFolderID', _t('ResponsiveGalleryExtension.UPLOADFOLDER_LABEL', 'Target Folder'), 'Folder'); $aFields[] = new GridField("GalleryImages", _t('ResponsiveGalleryExtension.IMAGES_LABEL', 'Images'), $this->getImages(), $oGridFieldConfig); break; case "sf": $iImageCount = $this->countImages(); $aFields[] = new HeaderField(_t('ResponsiveGalleryExtension.SOURCEFOLDER_HEADER', 'Select source folder of gallery')); $aFields[] = new TreeDropdownField('SourceFolderID', _t('ResponsiveGalleryExtension.SOURCEFOLDER_LABEL', 'Source Folder'), 'Folder'); if ($this->isSourcefolderSelected()) { $aFields[] = LiteralField::create("ImageCountInfo", '<div class="field">' . '<p class="info-message">' . _t('ResponsiveGalleryExtension.IMAGECOUNTINFO', 'There are {imageCount} images in your selected folder.', 'The number of images in this gallery', array('imageCount' => $iImageCount)) . '</p></div>'); } else { $aFields[] = LiteralField::create("NoSelectedFolderInfo", '<div class="field">' . '<p><span class="info-message">' . _t('ResponsiveGalleryExtension.NOSELECTEDFOLDER_INFO', 'Please select a folder that contains the images to be displayed in this gallery.') . '</p></div>'); } break; default: $aFields[] = LiteralField::create("SelectSourceInfo", '<div class="field">' . '<p><span class="info-message">' . _t('ResponsiveGalleryExtension.SELECTSOURCEINFO_HEADER', 'Please select your desired image source type in field above.') . '</span><br/>' . _t('ResponsiveGalleryExtension.SELECTSOURCE_INFO', 'Then click on save button below, to be able to configure this gallery.') . '</p></div>'); } return $aFields; }
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); }
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; }
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); }
public function FieldHolder($properties = array()) { Requirements::css(LINKABLE_PATH . '/css/embeddedobjectfield.css'); Requirements::javascript(LINKABLE_PATH . '/javascript/embeddedobjectfield.js'); if ($this->object && $this->object->ID) { $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL')); if (strlen($this->object->SourceURL)) { $properties['ObjectTitle'] = TextField::create($this->getName() . '[title]', _t('Linkable.TITLE', 'Title')); $properties['Width'] = TextField::create($this->getName() . '[width]', _t('Linkable.WIDTH', 'Width')); $properties['Height'] = TextField::create($this->getName() . '[height]', _t('Linkable.HEIGHT', 'Height')); $properties['ThumbURL'] = HiddenField::create($this->getName() . '[thumburl]', ''); $properties['Type'] = HiddenField::create($this->getName() . '[type]', ''); $properties['EmbedHTML'] = HiddenField::create($this->getName() . '[embedhtml]', ''); $properties['ObjectDescription'] = TextAreaField::create($this->getName() . '[description]', _t('Linkable.DESCRIPTION', 'Description')); $properties['ExtraClass'] = TextField::create($this->getName() . '[extraclass]', _t('Linkable.CSSCLASS', 'CSS class')); foreach ($properties as $key => $field) { if ($key == 'ObjectTitle') { $key = 'Title'; } elseif ($key == 'ObjectDescription') { $key = 'Description'; } $field->setValue($this->object->{$key}); } if ($this->object->ThumbURL) { $properties['ThumbImage'] = LiteralField::create($this->getName(), '<img src="' . $this->object->ThumbURL . '" />'); } } } else { $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL')); } $field = parent::FieldHolder($properties); return $field; }
/** * @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; }