Skip to content

Commit

Permalink
Merge branch '4.4' into 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Aug 21, 2017
2 parents 81f5335 + 792d040 commit d953603
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 65 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ sudo: false

language: php

dist: precise

matrix:
include:
- php: 5.3
Expand Down
14 changes: 10 additions & 4 deletions code/model/editableformfields/EditableFileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ public function getCMSFields()
)
);

$fields->addFieldToTab("Root.Main", new LiteralField("FileUploadWarning",
"<p class=\"message notice\">" . _t("UserDefinedForm.FileUploadWarning",
"Files uploaded through this field could be publicly accessible if the exact URL is known")
. "</p>"), "Type");
$fields->addFieldToTab("Root.Main", new LiteralField(
"FileUploadWarning",
"<p class=\"message notice\">"
. _t(
"UserDefinedForm.FileUploadWarning",
"Files uploaded through this field could be publicly accessible if the exact URL is known"
) . "</p>"
), "Type");

$fields->addFieldToTab(
'Root.Main',
Expand All @@ -57,6 +61,8 @@ public function getCMSFields()
->setDescription("Note: Maximum php allowed size is {$this->getPHPMaxFileSizeMB()} MB")
);

$fields->removeByName('Default');

return $fields;
}

Expand Down
14 changes: 7 additions & 7 deletions code/model/recipients/UserDefinedForm_EmailRecipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,9 @@ public function getCMSFields()
->addExtraClass('toggle-html-only'),
TextareaField::create('EmailBody', _t('UserDefinedForm.EMAILBODY', 'Body'))
->addExtraClass('toggle-plain-only'),
LiteralField::create(
'EmailPreview',
'<div id="EmailPreview" class="field toggle-html-only">' . $preview . '</div>'
)
LiteralField::create('EmailPreview', $preview)
));

$fields->fieldByName('Root.EmailContent')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILCONTENTTAB', 'Email Content'));

// Custom rules for sending this field
Expand All @@ -291,7 +288,7 @@ public function getCMSFields()
),
$grid
));

$fields->fieldByName('Root.CustomRules')->setTitle(_t('UserDefinedForm_EmailRecipient.CUSTOMRULESTAB', 'Custom Rules'));

$this->extend('updateCMSFields', $fields);
Expand Down Expand Up @@ -421,7 +418,10 @@ public function emailTemplateExists($template = '')
*/
public function getEmailBodyContent()
{
return $this->SendPlain ? $this->EmailBody : $this->EmailBodyHtml;
if ($this->SendPlain) {
return DBField::create_field('HTMLText', $this->EmailBody)->NoHTML();
}
return DBField::create_field('HTMLText', $this->EmailBodyHtml)->RAW();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion code/model/submissions/SubmittedFileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getLink()
{
if ($file = $this->UploadedFile()) {
if (trim($file->getFilename(), '/') != trim(ASSETS_DIR, '/')) {
return $this->UploadedFile()->URL;
return $this->UploadedFile()->AbsoluteLink();
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion code/model/submissions/SubmittedForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,14 @@ public function getCMSFields()
$self->Values()->sort('Created', 'ASC')
);

$exportColumns = array(
'Title' => 'Title',
'ExportValue' => 'Value'
);

$config = new GridFieldConfig();
$config->addComponent(new GridFieldDataColumns());
$config->addComponent(new GridFieldExportButton());
$config->addComponent(new GridFieldExportButton('after', $exportColumns));
$config->addComponent(new GridFieldPrintButton());
$values->setConfig($config);

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"require": {
"silverstripe/framework": "~3.2",
"silverstripe/cms": "~3.2",
"silverstripe-australia/gridfieldextensions": "~1.1",
"symbiote/silverstripe-gridfieldextensions": "~1.1",
"silverstripe/segment-field": "^1.0"
},
"suggest": {
Expand Down
12 changes: 0 additions & 12 deletions css/UserForm_cms.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
/**
* Animations
*/
@keyframes rowSlide {
0% {
top: 20%;
}
100% {
top: 80%;
}
}
@keyframes flashBackground {
0% {
background-color: white;
Expand Down Expand Up @@ -42,10 +34,6 @@
.cms .uf-field-editor table.ss-gridfield-table .ss-gridfield-item .handle {
min-height: 46px;
}
.cms .uf-field-editor table.ss-gridfield-table .ss-gridfield-item.newField {
position: fixed;
animation: rowSlide .5s ease forwards;
}
.cms .uf-field-editor table.ss-gridfield-table .ss-gridfield-item.flashBackground {
animation: flashBackground 2s linear;
}
Expand Down
26 changes: 9 additions & 17 deletions javascript/FieldEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

$(".uf-field-editor tbody").entwine({
onmatch: function() {
var i,
thisLevel,
var i,
thisLevel,
depth = 0,
$buttonrow = $('.uf-field-editor .ss-gridfield-buttonrow').addClass('stickyButtons'),
navHeight = $('.cms-content-header.north').height() + parseInt($('.stickyButtons').css('padding-top'), 10),
fieldEditor = $('.uf-field-editor'),
self = this;

this._super();

// Loop through all rows and set necessary styles
this.find('.ss-gridfield-item').each(function() {
switch($(this).data('class')) {
Expand All @@ -37,7 +37,7 @@
thisLevel = depth;
}
}

$(this).toggleClass('inFieldGroup', thisLevel > 0);
for(i = 1; i <= 5; i++) {
$(this).toggleClass('inFieldGroup-level-'+i, thisLevel >= i);
Expand Down Expand Up @@ -76,7 +76,7 @@
var self = this;

this._super();

// When the 'Add field' button is clicked set a one time listener.
// When the GridField is reloaded focus on the newly added field.
this.on('addnewinline', function () {
Expand All @@ -92,19 +92,11 @@
$newField.find('.col-Title input').focus();
}

// animate the row positioning (add the first class)
if (document.createElement('div').style.animationName !== void 0) {
$newField.addClass('newField');
$newField.addClass('flashBackground');
$(".cms-content-fields").scrollTop($(".cms-content-fields")[0].scrollHeight);
if($groupEnd) {
$groupEnd.css('visibility', 'visible');
}

// Once the animation has completed
setTimeout(function () {
$newField.removeClass('newField').addClass('flashBackground');
$(".cms-content-fields").scrollTop($(".cms-content-fields")[0].scrollHeight);
if($groupEnd) {
$groupEnd.css('visibility', 'visible');
}
}, 500);
});
});
},
Expand Down
7 changes: 3 additions & 4 deletions javascript/Recipient.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
(function ($) {
$(document).ready(function () {

var sendPlain = $('input[name="SendPlain"]');
var recipient = {
// Some fields are only visible when HTML email are being sent.
updateFormatSpecificFields: function () {
var sendPlainChecked = $('#SendPlain')
.find('input[type="checkbox"]')
.is(':checked');
var sendPlainChecked = sendPlain.is(':checked');

$(".field.toggle-html-only")[sendPlainChecked ? 'hide' : 'show']();
$(".field.toggle-plain-only")[sendPlainChecked ? 'show' : 'hide']();
Expand All @@ -27,7 +26,7 @@
}
});

$('#SendPlain').entwine({
sendPlain.entwine({
onchange: function () {
recipient.updateFormatSpecificFields();
}
Expand Down
26 changes: 8 additions & 18 deletions scss/UserForm_cms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
* Animations
*/

@keyframes rowSlide {
0% {top: 20%;}
100% {top: 80%;}
}

@keyframes flashBackground {
0% {background-color: white;}
10% {background-color: #dcfedd;}
Expand All @@ -30,11 +25,11 @@
&, &:hover {
background: white;
}

td {
border-right-width: 0;
border-top: 1px solid #EEE;

&:last-child {
border-right-width: 1px;
}
Expand All @@ -44,11 +39,6 @@
min-height: 46px;
}

&.newField {
position: fixed;
animation: rowSlide .5s ease forwards;
}

&.flashBackground {
animation: flashBackground 2s linear;
}
Expand All @@ -62,24 +52,24 @@
&, &:hover {
background: #f2f9fd;
}

td {
border-bottom: 0;
border-top: 1px solid #eee;
}

.col-reorder, .handle {
background: #BEE0F8;
border-top: 0;
}

&.inFieldGroup-level-2 {
.col-reorder, .handle {
background: #99CEF4;
border-top: 0;
}
}

&.inFieldGroup-level-3 {
.col-reorder, .handle {
background: #89BEF4;
Expand Down Expand Up @@ -116,7 +106,7 @@
td {
border-top: 1px solid #a8d7f5;
}

label {
font-weight: bold;
color: #444;
Expand All @@ -135,7 +125,7 @@
.col-buttons .action{
display: none;
}

label {
color: #777;
}
Expand Down
24 changes: 24 additions & 0 deletions tests/model/recipients/UserDefinedForm_EmailRecipientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

class UserDefinedForm_EmailRecipientTest extends SapphireTest
{
protected static $fixture_file = 'UserDefinedForm_EmailRecipientTest.yml';

public function testShortcodesAreRenderedInEmailPreviewContent()
{
$page = $this->objFromFixture('SiteTree', 'about_us');

$recipient = UserDefinedForm_EmailRecipient::create();
$recipient->SendPlain = false;
$recipient->EmailBodyHtml = '<p>Some email content. About us: [sitetree_link,id=' . $page->ID . '].</p>';

$result = $recipient->getEmailBodyContent();
$this->assertContains('/about-us/', $result);

$recipient->SendPlain = true;
$recipient->EmailBody = 'Some email content. About us: [sitetree_link,id=' . $page->ID . '].';

$result = $recipient->getEmailBodyContent();
$this->assertContains('/about-us/', $result);
}
}
4 changes: 4 additions & 0 deletions tests/model/recipients/UserDefinedForm_EmailRecipientTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SiteTree:
about_us:
Title: About Us
URLSegment: about-us

0 comments on commit d953603

Please sign in to comment.