remove trailing spaces in the codebase

This commit is contained in:
Peter Thaleikis 2015-09-11 10:20:06 +12:00
parent 99e771f942
commit 20cc915236
38 changed files with 279 additions and 279 deletions

View File

@ -1,8 +1,8 @@
<?php <?php
/** /**
* Extension to the build in SilverStripe {@link GridField} to allow for * Extension to the build in SilverStripe {@link GridField} to allow for
* filtering {@link SubmittedForm} objects in the submissions tab by * filtering {@link SubmittedForm} objects in the submissions tab by
* entering the value of a field * entering the value of a field
* *
* @package userforms * @package userforms
@ -41,7 +41,7 @@ class UserFormsGridFieldFilterHeader extends GridFieldFilterHeader {
$selectedField = $state->filter; $selectedField = $state->filter;
$selectedValue = $state->value; $selectedValue = $state->value;
// show dropdown of all the fields available from the submitted form fields // show dropdown of all the fields available from the submitted form fields
// that have been saved. Takes the titles from the currently live form. // that have been saved. Takes the titles from the currently live form.
$columnField = new DropdownField('FieldNameFilter', ''); $columnField = new DropdownField('FieldNameFilter', '');
@ -58,7 +58,7 @@ class UserFormsGridFieldFilterHeader extends GridFieldFilterHeader {
$valueField->addExtraClass('ss-gridfield-sort'); $valueField->addExtraClass('ss-gridfield-sort');
$valueField->addExtraClass('no-change-track'); $valueField->addExtraClass('no-change-track');
$valueField->setAttribute( $valueField->setAttribute(
'placeholder', 'placeholder',
_t('UserFormsGridFieldFilterHeader.WHEREVALUEIS', 'where value is..' _t('UserFormsGridFieldFilterHeader.WHEREVALUEIS', 'where value is..'
)); ));
@ -114,10 +114,10 @@ class UserFormsGridFieldFilterHeader extends GridFieldFilterHeader {
if($filter = $state->UserFormsGridField->toArray()) { if($filter = $state->UserFormsGridField->toArray()) {
if(isset($filter['filter']) && $filter['filter'] && isset($filter['value']) && $filter['value']) { if(isset($filter['filter']) && $filter['filter'] && isset($filter['value']) && $filter['value']) {
$dataList = $dataList->where(sprintf(" $dataList = $dataList->where(sprintf("
SELECT COUNT(*) FROM SubmittedFormField SELECT COUNT(*) FROM SubmittedFormField
WHERE ( WHERE (
ParentID = SubmittedForm.ID AND ParentID = SubmittedForm.ID AND
Name = '%s' AND Name = '%s' AND
Value LIKE '%s' Value LIKE '%s'
) > 0", ) > 0",

View File

@ -33,7 +33,7 @@ class UserFormFieldEditorExtension extends DataExtension {
*/ */
public function getFieldEditorGrid() { public function getFieldEditorGrid() {
Requirements::javascript(USERFORMS_DIR . '/javascript/FieldEditor.js'); Requirements::javascript(USERFORMS_DIR . '/javascript/FieldEditor.js');
$fields = $this->owner->Fields(); $fields = $this->owner->Fields();
$this->createInitialFormStep(true); $this->createInitialFormStep(true);

View File

@ -120,7 +120,7 @@ class UserFormValidator extends RequiredFields {
return false; return false;
} }
} }
return true; return true;
} }
} }

View File

@ -14,7 +14,7 @@ class UserFormsGroupField extends UserFormsCompositeField {
// Legend defaults to title // Legend defaults to title
return parent::getLegend() ?: $this->Title(); return parent::getLegend() ?: $this->Title();
} }
public function processNext(EditableFormField $field) { public function processNext(EditableFormField $field) {
// When ending a group, jump up one level // When ending a group, jump up one level
if($field instanceof EditableFieldGroupEnd) { if($field instanceof EditableFieldGroupEnd) {

View File

@ -145,7 +145,7 @@ class GridFieldAddClassesButton extends Object implements GridField_HTMLProvider
} }
$this->modelClasses = $classes; $this->modelClasses = $classes;
} }
public function getHTMLFragments($grid) { public function getHTMLFragments($grid) {
// Check create permission // Check create permission
$singleton = singleton($grid->getModelClass()); $singleton = singleton($grid->getModelClass());

View File

@ -89,7 +89,7 @@ class UserForm extends Form {
} }
/** /**
* Generate the form actions for the UserDefinedForm. You * Generate the form actions for the UserDefinedForm. You
* can manipulate these by using {@link updateFormActions()} on * can manipulate these by using {@link updateFormActions()} on
* a decorator. * a decorator.
* *

View File

@ -42,7 +42,7 @@ class EditableCustomRule extends DataObject {
/** /**
* Publish this custom rule to the live site * Publish this custom rule to the live site
* *
* Wrapper for the {@link Versioned} publish function * Wrapper for the {@link Versioned} publish function
*/ */
public function doPublish($fromStage, $toStage, $createNewVersion = false) { public function doPublish($fromStage, $toStage, $createNewVersion = false) {

View File

@ -5,7 +5,7 @@
*/ */
class UserDefinedForm extends Page { class UserDefinedForm extends Page {
/** /**
* @var string * @var string
*/ */
@ -37,7 +37,7 @@ class UserDefinedForm extends Page {
private static $extensions = array( private static $extensions = array(
'UserFormFieldEditorExtension' 'UserFormFieldEditorExtension'
); );
/** /**
* @var array Fields on the user defined form page. * @var array Fields on the user defined form page.
*/ */
@ -53,10 +53,10 @@ class UserDefinedForm extends Page {
'DisableAuthenicatedFinishAction' => 'Boolean', 'DisableAuthenicatedFinishAction' => 'Boolean',
'DisableCsrfSecurityToken' => 'Boolean' 'DisableCsrfSecurityToken' => 'Boolean'
); );
/** /**
* @var array Default values of variables when this page is created * @var array Default values of variables when this page is created
*/ */
private static $defaults = array( private static $defaults = array(
'Content' => '$UserDefinedForm', 'Content' => '$UserDefinedForm',
'DisableSaveSubmissions' => 0, 'DisableSaveSubmissions' => 0,
@ -99,34 +99,34 @@ class UserDefinedForm extends Page {
*/ */
public function getCMSFields() { public function getCMSFields() {
Requirements::css(USERFORMS_DIR . '/css/UserForm_cms.css'); Requirements::css(USERFORMS_DIR . '/css/UserForm_cms.css');
$self = $this; $self = $this;
$this->beforeUpdateCMSFields(function($fields) use ($self) { $this->beforeUpdateCMSFields(function($fields) use ($self) {
// define tabs // define tabs
$fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration')); $fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration'));
$fields->findOrMakeTab('Root.Recipients', _t('UserDefinedForm.RECIPIENTS', 'Recipients')); $fields->findOrMakeTab('Root.Recipients', _t('UserDefinedForm.RECIPIENTS', 'Recipients'));
$fields->findOrMakeTab('Root.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions')); $fields->findOrMakeTab('Root.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'));
// text to show on complete // text to show on complete
$onCompleteFieldSet = new CompositeField( $onCompleteFieldSet = new CompositeField(
$label = new LabelField('OnCompleteMessageLabel',_t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion')), $label = new LabelField('OnCompleteMessageLabel',_t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion')),
$editor = new HtmlEditorField( 'OnCompleteMessage', '', _t('UserDefinedForm.ONCOMPLETEMESSAGE', $self->OnCompleteMessage)) $editor = new HtmlEditorField( 'OnCompleteMessage', '', _t('UserDefinedForm.ONCOMPLETEMESSAGE', $self->OnCompleteMessage))
); );
$onCompleteFieldSet->addExtraClass('field'); $onCompleteFieldSet->addExtraClass('field');
$editor->setRows(3); $editor->setRows(3);
$label->addExtraClass('left'); $label->addExtraClass('left');
// Define config for email recipients // Define config for email recipients
$emailRecipientsConfig = GridFieldConfig_RecordEditor::create(10); $emailRecipientsConfig = GridFieldConfig_RecordEditor::create(10);
$emailRecipientsConfig->getComponentByType('GridFieldAddNewButton') $emailRecipientsConfig->getComponentByType('GridFieldAddNewButton')
->setButtonName( ->setButtonName(
_t('UserDefinedForm.ADDEMAILRECIPIENT', 'Add Email Recipient') _t('UserDefinedForm.ADDEMAILRECIPIENT', 'Add Email Recipient')
); );
// who do we email on submission // who do we email on submission
$emailRecipients = new GridField( $emailRecipients = new GridField(
'EmailRecipients', 'EmailRecipients',
@ -138,22 +138,22 @@ class UserDefinedForm extends Page {
->getConfig() ->getConfig()
->getComponentByType('GridFieldDetailForm') ->getComponentByType('GridFieldDetailForm')
->setItemRequestClass('UserFormRecipientItemRequest'); ->setItemRequestClass('UserFormRecipientItemRequest');
$fields->addFieldsToTab('Root.FormOptions', $onCompleteFieldSet); $fields->addFieldsToTab('Root.FormOptions', $onCompleteFieldSet);
$fields->addFieldToTab('Root.Recipients', $emailRecipients); $fields->addFieldToTab('Root.Recipients', $emailRecipients);
$fields->addFieldsToTab('Root.FormOptions', $self->getFormOptions()); $fields->addFieldsToTab('Root.FormOptions', $self->getFormOptions());
// view the submissions // view the submissions
$submissions = new GridField( $submissions = new GridField(
'Submissions', 'Submissions',
_t('UserDefinedForm.SUBMISSIONS', 'Submissions'), _t('UserDefinedForm.SUBMISSIONS', 'Submissions'),
$self->Submissions()->sort('Created', 'DESC') $self->Submissions()->sort('Created', 'DESC')
); );
// make sure a numeric not a empty string is checked against this int column for SQL server // make sure a numeric not a empty string is checked against this int column for SQL server
$parentID = (!empty($self->ID)) ? $self->ID : 0; $parentID = (!empty($self->ID)) ? $self->ID : 0;
// get a list of all field names and values used for print and export CSV views of the GridField below. // get a list of all field names and values used for print and export CSV views of the GridField below.
$columnSQL = <<<SQL $columnSQL = <<<SQL
SELECT "Name", "Title" SELECT "Name", "Title"
@ -167,7 +167,7 @@ SQL;
foreach(DB::query($columnSQL)->map() as $name => $title) { foreach(DB::query($columnSQL)->map() as $name => $title) {
$columns[$name] = trim(strtr($title, '.', ' ')); $columns[$name] = trim(strtr($title, '.', ' '));
} }
$config = new GridFieldConfig(); $config = new GridFieldConfig();
$config->addComponent(new GridFieldToolbarHeader()); $config->addComponent(new GridFieldToolbarHeader());
$config->addComponent($sort = new GridFieldSortableHeader()); $config->addComponent($sort = new GridFieldSortableHeader());
@ -181,39 +181,39 @@ SQL;
$config->addComponent(new GridFieldButtonRow('after')); $config->addComponent(new GridFieldButtonRow('after'));
$config->addComponent($export = new GridFieldExportButton('buttons-after-left')); $config->addComponent($export = new GridFieldExportButton('buttons-after-left'));
$config->addComponent($print = new GridFieldPrintButton('buttons-after-left')); $config->addComponent($print = new GridFieldPrintButton('buttons-after-left'));
/** /**
* Support for {@link https://github.com/colymba/GridFieldBulkEditingTools} * Support for {@link https://github.com/colymba/GridFieldBulkEditingTools}
*/ */
if(class_exists('GridFieldBulkManager')) { if(class_exists('GridFieldBulkManager')) {
$config->addComponent(new GridFieldBulkManager()); $config->addComponent(new GridFieldBulkManager());
} }
$sort->setThrowExceptionOnBadDataType(false); $sort->setThrowExceptionOnBadDataType(false);
$filter->setThrowExceptionOnBadDataType(false); $filter->setThrowExceptionOnBadDataType(false);
$pagination->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false);
// attach every column to the print view form // attach every column to the print view form
$columns['Created'] = 'Created'; $columns['Created'] = 'Created';
$filter->setColumns($columns); $filter->setColumns($columns);
// print configuration // print configuration
$print->setPrintHasHeader(true); $print->setPrintHasHeader(true);
$print->setPrintColumns($columns); $print->setPrintColumns($columns);
// export configuration // export configuration
$export->setCsvHasHeader(true); $export->setCsvHasHeader(true);
$export->setExportColumns($columns); $export->setExportColumns($columns);
$submissions->setConfig($config); $submissions->setConfig($config);
$fields->addFieldToTab('Root.Submissions', $submissions); $fields->addFieldToTab('Root.Submissions', $submissions);
$fields->addFieldToTab('Root.FormOptions', new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server'))); $fields->addFieldToTab('Root.FormOptions', new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server')));
}); });
$fields = parent::getCMSFields(); $fields = parent::getCMSFields();
return $fields; return $fields;
} }
@ -239,7 +239,7 @@ SQL;
} }
/** /**
* Custom options for the form. You can extend the built in options by * Custom options for the form. You can extend the built in options by
* using {@link updateFormOptions()} * using {@link updateFormOptions()}
* *
* @return FieldList * @return FieldList
@ -247,7 +247,7 @@ SQL;
public function getFormOptions() { public function getFormOptions() {
$submit = ($this->SubmitButtonText) ? $this->SubmitButtonText : _t('UserDefinedForm.SUBMITBUTTON', 'Submit'); $submit = ($this->SubmitButtonText) ? $this->SubmitButtonText : _t('UserDefinedForm.SUBMITBUTTON', 'Submit');
$clear = ($this->ClearButtonText) ? $this->ClearButtonText : _t('UserDefinedForm.CLEARBUTTON', 'Clear'); $clear = ($this->ClearButtonText) ? $this->ClearButtonText : _t('UserDefinedForm.CLEARBUTTON', 'Clear');
$options = new FieldList( $options = new FieldList(
new TextField("SubmitButtonText", _t('UserDefinedForm.TEXTONSUBMIT', 'Text on submit button:'), $submit), new TextField("SubmitButtonText", _t('UserDefinedForm.TEXTONSUBMIT', 'Text on submit button:'), $submit),
new TextField("ClearButtonText", _t('UserDefinedForm.TEXTONCLEAR', 'Text on clear button:'), $clear), new TextField("ClearButtonText", _t('UserDefinedForm.TEXTONCLEAR', 'Text on clear button:'), $clear),
@ -258,9 +258,9 @@ SQL;
new CheckboxField('DisableCsrfSecurityToken', _t('UserDefinedForm.DISABLECSRFSECURITYTOKEN', 'Disable CSRF Token')), new CheckboxField('DisableCsrfSecurityToken', _t('UserDefinedForm.DISABLECSRFSECURITYTOKEN', 'Disable CSRF Token')),
new CheckboxField('DisableAuthenicatedFinishAction', _t('UserDefinedForm.DISABLEAUTHENICATEDFINISHACTION', 'Disable Authentication on finish action')) new CheckboxField('DisableAuthenicatedFinishAction', _t('UserDefinedForm.DISABLEAUTHENICATEDFINISHACTION', 'Disable Authentication on finish action'))
); );
$this->extend('updateFormOptions', $options); $this->extend('updateFormOptions', $options);
return $options; return $options;
} }
@ -285,7 +285,7 @@ SQL;
->create('UserFormsUpgradeService') ->create('UserFormsUpgradeService')
->setQuiet(true) ->setQuiet(true)
->run(); ->run();
DB::alteration_message('Migrated userforms', 'changed'); DB::alteration_message('Migrated userforms', 'changed');
} }
@ -305,7 +305,7 @@ SQL;
*/ */
class UserDefinedForm_Controller extends Page_Controller { class UserDefinedForm_Controller extends Page_Controller {
private static $finished_anchor = '#uff'; private static $finished_anchor = '#uff';
private static $allowed_actions = array( private static $allowed_actions = array(
@ -317,7 +317,7 @@ class UserDefinedForm_Controller extends Page_Controller {
public function init() { public function init() {
parent::init(); parent::init();
// load the jquery // load the jquery
$lang = i18n::get_lang_from_locale(i18n::get_locale()); $lang = i18n::get_lang_from_locale(i18n::get_locale());
Requirements::css(USERFORMS_DIR . '/css/UserForm.css'); Requirements::css(USERFORMS_DIR . '/css/UserForm.css');
@ -336,7 +336,7 @@ class UserDefinedForm_Controller extends Page_Controller {
Requirements::javascript(USERFORMS_DIR . '/thirdparty/Placeholders.js/Placeholders.min.js'); Requirements::javascript(USERFORMS_DIR . '/thirdparty/Placeholders.js/Placeholders.min.js');
} }
} }
/** /**
* Using $UserDefinedForm in the Content area of the page shows * Using $UserDefinedForm in the Content area of the page shows
* where the form should be rendered into. If it does not exist * where the form should be rendered into. If it does not exist
@ -444,7 +444,7 @@ class UserDefinedForm_Controller extends Page_Controller {
break; break;
case 'IsBlank': case 'IsBlank':
$expression = ($checkboxField || $radioField) ? '!($(this).is(":checked"))' : '$(this).val() == ""'; $expression = ($checkboxField || $radioField) ? '!($(this).is(":checked"))' : '$(this).val() == ""';
break; break;
case 'HasValue': case 'HasValue':
if ($checkboxField) { if ($checkboxField) {
@ -459,11 +459,11 @@ class UserDefinedForm_Controller extends Page_Controller {
break; break;
case 'ValueLessThan': case 'ValueLessThan':
$expression = '$(this).val() < parseFloat("'. $rule->FieldValue .'")'; $expression = '$(this).val() < parseFloat("'. $rule->FieldValue .'")';
break; break;
case 'ValueLessThanEqual': case 'ValueLessThanEqual':
$expression = '$(this).val() <= parseFloat("'. $rule->FieldValue .'")'; $expression = '$(this).val() <= parseFloat("'. $rule->FieldValue .'")';
break; break;
case 'ValueGreaterThan': case 'ValueGreaterThan':
$expression = '$(this).val() > parseFloat("'. $rule->FieldValue .'")'; $expression = '$(this).val() > parseFloat("'. $rule->FieldValue .'")';
@ -502,7 +502,7 @@ class UserDefinedForm_Controller extends Page_Controller {
} }
} }
} }
if($watch) { if($watch) {
foreach($watch as $key => $values) { foreach($watch as $key => $values) {
$logic = array(); $logic = array();
@ -614,7 +614,7 @@ JS
if(in_array("EditableFileField", $field->getClassAncestry())) { if(in_array("EditableFileField", $field->getClassAncestry())) {
if(isset($_FILES[$field->Name])) { if(isset($_FILES[$field->Name])) {
$foldername = $field->getFormField()->getFolderName(); $foldername = $field->getFormField()->getFolderName();
// create the file from post data // create the file from post data
$upload = new Upload(); $upload = new Upload();
$file = new File(); $file = new File();
@ -630,7 +630,7 @@ JS
// write file to form field // write file to form field
$submittedField->UploadedFileID = $file->ID; $submittedField->UploadedFileID = $file->ID;
// attach a file only if lower than 1MB // attach a file only if lower than 1MB
if($file->getAbsoluteSize() < 1024*1024*1) { if($file->getAbsoluteSize() < 1024*1024*1) {
$attachments[] = $file; $attachments[] = $file;
@ -640,7 +640,7 @@ JS
} }
$submittedField->extend('onPopulationFromField', $field); $submittedField->extend('onPopulationFromField', $field);
if(!$this->DisableSaveSubmissions) { if(!$this->DisableSaveSubmissions) {
$submittedField->write(); $submittedField->write();
} }
@ -664,8 +664,8 @@ JS
foreach($attachments as $file) { foreach($attachments as $file) {
if($file->ID != 0) { if($file->ID != 0) {
$email->attachFile( $email->attachFile(
$file->Filename, $file->Filename,
$file->Filename, $file->Filename,
HTTP::get_mime_type($file->Filename) HTTP::get_mime_type($file->Filename)
); );
} }
@ -685,7 +685,7 @@ JS
$email->setBody($parsedBody); $email->setBody($parsedBody);
$email->setTo($recipient->EmailAddress); $email->setTo($recipient->EmailAddress);
$email->setSubject($recipient->EmailSubject); $email->setSubject($recipient->EmailSubject);
if($recipient->EmailReplyTo) { if($recipient->EmailReplyTo) {
$email->setReplyTo($recipient->EmailReplyTo); $email->setReplyTo($recipient->EmailReplyTo);
} }
@ -701,12 +701,12 @@ JS
// check to see if they are a dynamic reciever eg based on a dropdown field a user selected // check to see if they are a dynamic reciever eg based on a dropdown field a user selected
if($recipient->SendEmailToField()) { if($recipient->SendEmailToField()) {
$submittedFormField = $submittedFields->find('Name', $recipient->SendEmailToField()->Name); $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailToField()->Name);
if($submittedFormField && is_string($submittedFormField->Value)) { if($submittedFormField && is_string($submittedFormField->Value)) {
$email->setTo($submittedFormField->Value); $email->setTo($submittedFormField->Value);
} }
} }
// check to see if there is a dynamic subject // check to see if there is a dynamic subject
if($recipient->SendEmailSubjectField()) { if($recipient->SendEmailSubjectField()) {
$submittedFormField = $submittedFields->find('Name', $recipient->SendEmailSubjectField()->Name); $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailSubjectField()->Name);
@ -739,10 +739,10 @@ JS
Session::clear("FormInfo.{$form->FormName()}.errors"); Session::clear("FormInfo.{$form->FormName()}.errors");
Session::clear("FormInfo.{$form->FormName()}.data"); Session::clear("FormInfo.{$form->FormName()}.data");
$referrer = (isset($data['Referrer'])) ? '?referrer=' . urlencode($data['Referrer']) : ""; $referrer = (isset($data['Referrer'])) ? '?referrer=' . urlencode($data['Referrer']) : "";
// set a session variable from the security ID to stop people accessing // set a session variable from the security ID to stop people accessing
// the finished method directly. // the finished method directly.
if(!$this->DisableAuthenicatedFinishAction) { if(!$this->DisableAuthenicatedFinishAction) {
if (isset($data['SecurityID'])) { if (isset($data['SecurityID'])) {
@ -783,7 +783,7 @@ JS
} }
/** /**
* This action handles rendering the "finished" message, which is * This action handles rendering the "finished" message, which is
* customizable by editing the ReceivedFormSubmission template. * customizable by editing the ReceivedFormSubmission template.
* *
* @return ViewableData * @return ViewableData
@ -796,7 +796,7 @@ JS
} }
$referrer = isset($_GET['referrer']) ? urldecode($_GET['referrer']) : null; $referrer = isset($_GET['referrer']) ? urldecode($_GET['referrer']) : null;
if(!$this->DisableAuthenicatedFinishAction) { if(!$this->DisableAuthenicatedFinishAction) {
$formProcessed = Session::get('FormProcessed'); $formProcessed = Session::get('FormProcessed');

View File

@ -3,14 +3,14 @@
* EditableCheckbox * EditableCheckbox
* *
* A user modifiable checkbox on a UserDefinedForm * A user modifiable checkbox on a UserDefinedForm
* *
* @package userforms * @package userforms
*/ */
class EditableCheckbox extends EditableFormField { class EditableCheckbox extends EditableFormField {
private static $singular_name = 'Checkbox Field'; private static $singular_name = 'Checkbox Field';
private static $plural_name = 'Checkboxes'; private static $plural_name = 'Checkboxes';
private static $db = array( private static $db = array(
@ -40,10 +40,10 @@ class EditableCheckbox extends EditableFormField {
return $field; return $field;
} }
public function getValueFromData($data) { public function getValueFromData($data) {
$value = (isset($data[$this->Name])) ? $data[$this->Name] : false; $value = (isset($data[$this->Name])) ? $data[$this->Name] : false;
return ($value) ? _t('EditableFormField.YES', 'Yes') : _t('EditableFormField.NO', 'No'); return ($value) ? _t('EditableFormField.YES', 'Yes') : _t('EditableFormField.NO', 'No');
} }
@ -53,7 +53,7 @@ class EditableCheckbox extends EditableFormField {
$this->CheckedDefault = (bool)$data['Default']; $this->CheckedDefault = (bool)$data['Default'];
unset($data['Default']); unset($data['Default']);
} }
parent::migrateSettings($data); parent::migrateSettings($data);
} }
} }

View File

@ -3,16 +3,16 @@
* EditableCheckboxGroup * EditableCheckboxGroup
* *
* Represents a set of selectable radio buttons * Represents a set of selectable radio buttons
* *
* @package userforms * @package userforms
*/ */
class EditableCheckboxGroupField extends EditableMultipleOptionField { class EditableCheckboxGroupField extends EditableMultipleOptionField {
private static $singular_name = "Checkbox Group"; private static $singular_name = "Checkbox Group";
private static $plural_name = "Checkbox Groups"; private static $plural_name = "Checkbox Groups";
public function getFormField() { public function getFormField() {
$field = new UserFormsCheckboxSetField($this->Name, $this->EscapedTitle, $this->getOptionsMap()); $field = new UserFormsCheckboxSetField($this->Name, $this->EscapedTitle, $this->getOptionsMap());
$field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder'); $field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder');
@ -26,11 +26,11 @@ class EditableCheckboxGroupField extends EditableMultipleOptionField {
$this->doUpdateFormField($field); $this->doUpdateFormField($field);
return $field; return $field;
} }
public function getValueFromData($data) { public function getValueFromData($data) {
$result = ''; $result = '';
$entries = (isset($data[$this->Name])) ? $data[$this->Name] : false; $entries = (isset($data[$this->Name])) ? $data[$this->Name] : false;
if($entries) { if($entries) {
if(!is_array($data[$this->Name])) { if(!is_array($data[$this->Name])) {
$entries = array($data[$this->Name]); $entries = array($data[$this->Name]);

View File

@ -8,7 +8,7 @@
class EditableCountryDropdownField extends EditableFormField { class EditableCountryDropdownField extends EditableFormField {
private static $singular_name = 'Country Dropdown'; private static $singular_name = 'Country Dropdown';
private static $plural_name = 'Country Dropdowns'; private static $plural_name = 'Country Dropdowns';
/** /**
@ -21,7 +21,7 @@ class EditableCountryDropdownField extends EditableFormField {
return $fields; return $fields;
} }
public function getFormField() { public function getFormField() {
$field = CountryDropdownField::create($this->Name, $this->EscapedTitle) $field = CountryDropdownField::create($this->Name, $this->EscapedTitle)
->setFieldHolderTemplate('UserFormsField_holder') ->setFieldHolderTemplate('UserFormsField_holder')
@ -31,14 +31,14 @@ class EditableCountryDropdownField extends EditableFormField {
return $field; return $field;
} }
public function getValueFromData($data) { public function getValueFromData($data) {
if(isset($data[$this->Name])) { if(isset($data[$this->Name])) {
$source = $this->getFormField()->getSource(); $source = $this->getFormField()->getSource();
return $source[$data[$this->Name]]; return $source[$data[$this->Name]];
} }
} }
public function getIcon() { public function getIcon() {
return USERFORMS_DIR . '/images/editabledropdown.png'; return USERFORMS_DIR . '/images/editabledropdown.png';
} }

View File

@ -8,9 +8,9 @@
*/ */
class EditableDateField extends EditableFormField { class EditableDateField extends EditableFormField {
private static $singular_name = 'Date Field'; private static $singular_name = 'Date Field';
private static $plural_name = 'Date Fields'; private static $plural_name = 'Date Fields';
private static $db = array( private static $db = array(
@ -34,7 +34,7 @@ class EditableDateField extends EditableFormField {
return parent::getCMSFields(); return parent::getCMSFields();
} }
/** /**
* Return the form field * Return the form field
* *

View File

@ -8,9 +8,9 @@
*/ */
class EditableDropdown extends EditableMultipleOptionField { class EditableDropdown extends EditableMultipleOptionField {
private static $singular_name = 'Dropdown Field'; private static $singular_name = 'Dropdown Field';
private static $plural_name = 'Dropdowns'; private static $plural_name = 'Dropdowns';
/** /**
@ -23,7 +23,7 @@ class EditableDropdown extends EditableMultipleOptionField {
return $fields; return $fields;
} }
/** /**
* @return DropdownField * @return DropdownField
*/ */

View File

@ -8,15 +8,15 @@
*/ */
class EditableEmailField extends EditableFormField { class EditableEmailField extends EditableFormField {
private static $singular_name = 'Email Field'; private static $singular_name = 'Email Field';
private static $plural_name = 'Email Fields'; private static $plural_name = 'Email Fields';
public function getSetsOwnError() { public function getSetsOwnError() {
return true; return true;
} }
public function getFormField() { public function getFormField() {
$field = EmailField::create($this->Name, $this->EscapedTitle, $this->Default) $field = EmailField::create($this->Name, $this->EscapedTitle, $this->Default)
->setFieldHolderTemplate('UserFormsField_holder') ->setFieldHolderTemplate('UserFormsField_holder')
@ -26,7 +26,7 @@ class EditableEmailField extends EditableFormField {
return $field; return $field;
} }
/** /**
* Updates a formfield with the additional metadata specified by this field * Updates a formfield with the additional metadata specified by this field
* *

View File

@ -34,7 +34,7 @@ class EditableFieldGroup extends EditableFormField {
$title = $this->getFieldNumber() $title = $this->getFieldNumber()
?: $this->Title ?: $this->Title
?: 'group'; ?: 'group';
return _t( return _t(
'EditableFieldGroupEnd.FIELD_GROUP_START', 'EditableFieldGroupEnd.FIELD_GROUP_START',
'Group {group}', 'Group {group}',
@ -66,7 +66,7 @@ class EditableFieldGroup extends EditableFormField {
// Since this field expects raw html, safely escape the user data prior // Since this field expects raw html, safely escape the user data prior
$field->setRightTitle(Convert::raw2xml($this->RightTitle)); $field->setRightTitle(Convert::raw2xml($this->RightTitle));
} }
// if this field has an extra class // if this field has an extra class
if($this->ExtraClass) { if($this->ExtraClass) {
$field->addExtraClass($this->ExtraClass); $field->addExtraClass($this->ExtraClass);
@ -88,5 +88,5 @@ class EditableFieldGroup extends EditableFormField {
$end->delete(); $end->delete();
} }
} }
} }

View File

@ -16,7 +16,7 @@ class EditableFieldGroupEnd extends EditableFormField {
* @var bool * @var bool
*/ */
private static $hidden = true; private static $hidden = true;
/** /**
* Non-data type * Non-data type
* *
@ -73,7 +73,7 @@ class EditableFieldGroupEnd extends EditableFormField {
->where('"EditableFieldGroup"."EndID" IS NULL OR "EditableFieldGroup"."EndID" = 0') ->where('"EditableFieldGroup"."EndID" IS NULL OR "EditableFieldGroup"."EndID" = 0')
->sort('"Sort" DESC') ->sort('"Sort" DESC')
->first(); ->first();
// When a group is found, attach it to this end // When a group is found, attach it to this end
if($group) { if($group) {
$group->EndID = $this->ID; $group->EndID = $this->ID;
@ -90,5 +90,5 @@ class EditableFieldGroupEnd extends EditableFormField {
$group->delete(); $group->delete();
} }
} }
} }

View File

@ -7,9 +7,9 @@
*/ */
class EditableFileField extends EditableFormField { class EditableFileField extends EditableFormField {
private static $singular_name = 'File Upload Field'; private static $singular_name = 'File Upload Field';
private static $plural_names = 'File Fields'; private static $plural_names = 'File Fields';
private static $has_one = array( private static $has_one = array(
@ -30,7 +30,7 @@ class EditableFileField extends EditableFormField {
*/ */
public function getCMSFields() { public function getCMSFields() {
$fields = parent::getCMSFields(); $fields = parent::getCMSFields();
$fields->addFieldToTab( $fields->addFieldToTab(
'Root.Main', 'Root.Main',
TreeDropdownField::create( TreeDropdownField::create(
@ -40,8 +40,8 @@ class EditableFileField extends EditableFormField {
) )
); );
$fields->addFieldToTab("Root.Main", new LiteralField("FileUploadWarning", $fields->addFieldToTab("Root.Main", new LiteralField("FileUploadWarning",
"<p class=\"message notice\">" . _t("UserDefinedForm.FileUploadWarning", "<p class=\"message notice\">" . _t("UserDefinedForm.FileUploadWarning",
"Files uploaded through this field could be publicly accessible if the exact URL is known") "Files uploaded through this field could be publicly accessible if the exact URL is known")
. "</p>"), "Type"); . "</p>"), "Type");
@ -72,8 +72,8 @@ class EditableFileField extends EditableFormField {
return $field; return $field;
} }
/** /**
* Return the value for the database, link to the file is stored as a * Return the value for the database, link to the file is stored as a
* relation so value for the field can be null. * relation so value for the field can be null.
@ -83,7 +83,7 @@ class EditableFileField extends EditableFormField {
public function getValueFromData() { public function getValueFromData() {
return null; return null;
} }
public function getSubmittedFormField() { public function getSubmittedFormField() {
return new SubmittedFileField(); return new SubmittedFileField();
} }

View File

@ -502,7 +502,7 @@ class EditableFormField extends DataObject {
if(!$form || !$form->exists() || !($fields = $form->Fields())) { if(!$form || !$form->exists() || !($fields = $form->Fields())) {
return null; return null;
} }
$prior = 0; // Number of prior group at this level $prior = 0; // Number of prior group at this level
$stack = array(); // Current stack of nested groups, where the top level = the page $stack = array(); // Current stack of nested groups, where the top level = the page
foreach($fields->map('ID', 'ClassName') as $id => $className) { foreach($fields->map('ID', 'ClassName') as $id => $className) {

View File

@ -8,7 +8,7 @@
class EditableFormHeading extends EditableFormField { class EditableFormHeading extends EditableFormField {
private static $singular_name = 'Heading'; private static $singular_name = 'Heading';
private static $plural_name = 'Headings'; private static $plural_name = 'Headings';
private static $literal = true; private static $literal = true;
@ -39,7 +39,7 @@ class EditableFormHeading extends EditableFormField {
'5' => '5', '5' => '5',
'6' => '6' '6' => '6'
); );
$fields->addFieldsToTab('Root.Main', array( $fields->addFieldsToTab('Root.Main', array(
DropdownField::create( DropdownField::create(
'Level', 'Level',
@ -74,11 +74,11 @@ class EditableFormHeading extends EditableFormField {
$field->addExtraClass($this->ExtraClass); $field->addExtraClass($this->ExtraClass);
} }
} }
public function showInReports() { public function showInReports() {
return !$this->HideFromReports; return !$this->HideFromReports;
} }
public function getFieldValidationOptions() { public function getFieldValidationOptions() {
return false; return false;
} }

View File

@ -3,14 +3,14 @@
/** /**
* Editable Literal Field. A literal field is just a blank slate where * Editable Literal Field. A literal field is just a blank slate where
* you can add your own HTML / Images / Flash * you can add your own HTML / Images / Flash
* *
* @package userforms * @package userforms
*/ */
class EditableLiteralField extends EditableFormField { class EditableLiteralField extends EditableFormField {
private static $singular_name = 'HTML Block'; private static $singular_name = 'HTML Block';
private static $plural_name = 'HTML Blocks'; private static $plural_name = 'HTML Blocks';
/** /**
@ -118,7 +118,7 @@ class EditableLiteralField extends EditableFormField {
} else { } else {
$label = "<label class='left'>{$this->EscapedTitle}</label>"; $label = "<label class='left'>{$this->EscapedTitle}</label>";
} }
$field = new LiteralField( $field = new LiteralField(
"LiteralField[{$this->ID}]", "LiteralField[{$this->ID}]",
sprintf( sprintf(
@ -136,7 +136,7 @@ class EditableLiteralField extends EditableFormField {
// When dealing with literal fields there is no further customisation that can be added at this point // When dealing with literal fields there is no further customisation that can be added at this point
return $field; return $field;
} }
public function showInReports() { public function showInReports() {
return ! $this->HideFromReports; return ! $this->HideFromReports;
} }

View File

@ -6,9 +6,9 @@
*/ */
class EditableMemberListField extends EditableFormField { class EditableMemberListField extends EditableFormField {
private static $singular_name = 'Member List Field'; private static $singular_name = 'Member List Field';
private static $plural_name = 'Member List Fields'; private static $plural_name = 'Member List Fields';
private static $has_one = array( private static $has_one = array(
@ -23,7 +23,7 @@ class EditableMemberListField extends EditableFormField {
$fields->removeByName('Default'); $fields->removeByName('Default');
$fields->removeByName('Validation'); $fields->removeByName('Validation');
$fields->addFieldToTab( $fields->addFieldToTab(
'Root.Main', 'Root.Main',
DropdownField::create( DropdownField::create(
@ -35,25 +35,25 @@ class EditableMemberListField extends EditableFormField {
return $fields; return $fields;
} }
public function getFormField() { public function getFormField() {
if(empty($this->GroupID)) { if(empty($this->GroupID)) {
return false; return false;
} }
$members = Member::map_in_groups($this->GroupID); $members = Member::map_in_groups($this->GroupID);
$field = new DropdownField($this->Name, $this->EscapedTitle, $members); $field = new DropdownField($this->Name, $this->EscapedTitle, $members);
$this->doUpdateFormField($field); $this->doUpdateFormField($field);
return $field; return $field;
} }
public function getValueFromData($data) { public function getValueFromData($data) {
if(isset($data[$this->Name])) { if(isset($data[$this->Name])) {
$memberID = $data[$this->Name]; $memberID = $data[$this->Name];
$member = Member::get()->byID($memberID); $member = Member::get()->byID($memberID);
return $member ? $member->getName() : ""; return $member ? $member->getName() : "";
} }
return false; return false;
} }
} }

View File

@ -1,10 +1,10 @@
<?php <?php
/** /**
* Base class for multiple option fields such as {@link EditableDropdownField} * Base class for multiple option fields such as {@link EditableDropdownField}
* and radio sets. * and radio sets.
* *
* Implemented as a class but should be viewed as abstract, you should * Implemented as a class but should be viewed as abstract, you should
* instantiate a subclass such as {@link EditableDropdownField} * instantiate a subclass such as {@link EditableDropdownField}
* *
* @see EditableCheckboxGroupField * @see EditableCheckboxGroupField
@ -22,7 +22,7 @@ class EditableMultipleOptionField extends EditableFormField {
* @var bool * @var bool
*/ */
private static $abstract = true; private static $abstract = true;
private static $has_many = array( private static $has_many = array(
"Options" => "EditableOption" "Options" => "EditableOption"
); );
@ -48,7 +48,7 @@ class EditableMultipleOptionField extends EditableFormField {
} }
) )
)); ));
$optionsConfig = GridFieldConfig::create() $optionsConfig = GridFieldConfig::create()
->addComponents( ->addComponents(
new GridFieldToolbarHeader(), new GridFieldToolbarHeader(),
@ -71,13 +71,13 @@ class EditableMultipleOptionField extends EditableFormField {
return $fields; return $fields;
} }
/** /**
* Publishing Versioning support. * Publishing Versioning support.
* *
* When publishing it needs to handle copying across / publishing * When publishing it needs to handle copying across / publishing
* each of the individual field options * each of the individual field options
* *
* @return void * @return void
*/ */
public function doPublish($fromStage, $toStage, $createNewVersion = false) { public function doPublish($fromStage, $toStage, $createNewVersion = false) {
@ -88,19 +88,19 @@ class EditableMultipleOptionField extends EditableFormField {
$option->delete(); $option->delete();
} }
} }
if($this->Options()) { if($this->Options()) {
foreach($this->Options() as $option) { foreach($this->Options() as $option) {
$option->publish($fromStage, $toStage, $createNewVersion); $option->publish($fromStage, $toStage, $createNewVersion);
} }
} }
$this->publish($fromStage, $toStage, $createNewVersion); $this->publish($fromStage, $toStage, $createNewVersion);
} }
/** /**
* Unpublishing Versioning support * Unpublishing Versioning support
* *
* When unpublishing the field it has to remove all options attached * When unpublishing the field it has to remove all options attached
* *
* @return void * @return void
@ -111,12 +111,12 @@ class EditableMultipleOptionField extends EditableFormField {
$option->deleteFromStage($stage); $option->deleteFromStage($stage);
} }
} }
$this->deleteFromStage($stage); $this->deleteFromStage($stage);
} }
/** /**
* Deletes all the options attached to this field before deleting the * Deletes all the options attached to this field before deleting the
* field. Keeps stray options from floating around * field. Keeps stray options from floating around
* *
* @return void * @return void
@ -129,31 +129,31 @@ class EditableMultipleOptionField extends EditableFormField {
$option->delete(); $option->delete();
} }
} }
parent::delete(); parent::delete();
} }
/** /**
* Duplicate a pages content. We need to make sure all the fields attached * Duplicate a pages content. We need to make sure all the fields attached
* to that page go with it * to that page go with it
* *
* @return DataObject * @return DataObject
*/ */
public function duplicate($doWrite = true) { public function duplicate($doWrite = true) {
$clonedNode = parent::duplicate(); $clonedNode = parent::duplicate();
foreach($this->Options() as $field) { foreach($this->Options() as $field) {
$newField = $field->duplicate(false); $newField = $field->duplicate(false);
$newField->ParentID = $clonedNode->ID; $newField->ParentID = $clonedNode->ID;
$newField->Version = 0; $newField->Version = 0;
$newField->write(); $newField->write();
} }
return $clonedNode; return $clonedNode;
} }
/** /**
* Return whether or not this field has addable options such as a * Return whether or not this field has addable options such as a
* {@link EditableDropdownField} or {@link EditableRadioField} * {@link EditableDropdownField} or {@link EditableRadioField}
* *
* @return bool * @return bool

View File

@ -10,18 +10,18 @@
class EditableNumericField extends EditableFormField { class EditableNumericField extends EditableFormField {
private static $singular_name = 'Numeric Field'; private static $singular_name = 'Numeric Field';
private static $plural_name = 'Numeric Fields'; private static $plural_name = 'Numeric Fields';
private static $db = array( private static $db = array(
'MinValue' => 'Int', 'MinValue' => 'Int',
'MaxValue' => 'Int' 'MaxValue' => 'Int'
); );
public function getSetsOwnError() { public function getSetsOwnError() {
return true; return true;
} }
/** /**
* @return NumericField * @return NumericField
*/ */

View File

@ -1,14 +1,14 @@
<?php <?php
/** /**
* Base Class for EditableOption Fields such as the ones used in * Base Class for EditableOption Fields such as the ones used in
* dropdown fields and in radio check box groups * dropdown fields and in radio check box groups
* *
* @package userforms * @package userforms
*/ */
class EditableOption extends DataObject { class EditableOption extends DataObject {
private static $default_sort = "Sort"; private static $default_sort = "Sort";
private static $db = array( private static $db = array(
@ -17,11 +17,11 @@ class EditableOption extends DataObject {
"Default" => "Boolean", "Default" => "Boolean",
"Sort" => "Int" "Sort" => "Int"
); );
private static $has_one = array( private static $has_one = array(
"Parent" => "EditableMultipleOptionField", "Parent" => "EditableMultipleOptionField",
); );
private static $extensions = array( private static $extensions = array(
"Versioned('Stage', 'Live')" "Versioned('Stage', 'Live')"
); );

View File

@ -8,9 +8,9 @@
*/ */
class EditableRadioField extends EditableMultipleOptionField { class EditableRadioField extends EditableMultipleOptionField {
private static $singular_name = 'Radio Group'; private static $singular_name = 'Radio Group';
private static $plural_name = 'Radio Groups'; private static $plural_name = 'Radio Groups';
/** /**
@ -23,7 +23,7 @@ class EditableRadioField extends EditableMultipleOptionField {
return $fields; return $fields;
} }
public function getFormField() { public function getFormField() {
$field = OptionsetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap()); $field = OptionsetField::create($this->Name, $this->EscapedTitle, $this->getOptionsMap());
$field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder'); $field->setFieldHolderTemplate('UserFormsMultipleOptionField_holder');

View File

@ -10,7 +10,7 @@
class EditableTextField extends EditableFormField { class EditableTextField extends EditableFormField {
private static $singular_name = 'Text Field'; private static $singular_name = 'Text Field';
private static $plural_name = 'Text Fields'; private static $plural_name = 'Text Fields';
private static $db = array( private static $db = array(

View File

@ -113,7 +113,7 @@ class UserDefinedForm_EmailRecipient extends DataObject {
*/ */
public function getCMSFields() { public function getCMSFields() {
Requirements::javascript(USERFORMS_DIR . '/javascript/Recipient.js'); Requirements::javascript(USERFORMS_DIR . '/javascript/Recipient.js');
// Determine optional field values // Determine optional field values
$form = $this->getFormParent(); $form = $this->getFormParent();

View File

@ -1,39 +1,39 @@
<?php <?php
/** /**
* A file uploaded on a {@link UserDefinedForm} and attached to a single * A file uploaded on a {@link UserDefinedForm} and attached to a single
* {@link SubmittedForm}. * {@link SubmittedForm}.
* *
* @package userforms * @package userforms
*/ */
class SubmittedFileField extends SubmittedFormField { class SubmittedFileField extends SubmittedFormField {
private static $has_one = array( private static $has_one = array(
"UploadedFile" => "File" "UploadedFile" => "File"
); );
/** /**
* Return the value of this field for inclusion into things such as * Return the value of this field for inclusion into things such as
* reports. * reports.
* *
* @return string * @return string
*/ */
public function getFormattedValue() { public function getFormattedValue() {
$name = $this->getFileName(); $name = $this->getFileName();
$link = $this->getLink(); $link = $this->getLink();
$title = _t('SubmittedFileField.DOWNLOADFILE', 'Download File'); $title = _t('SubmittedFileField.DOWNLOADFILE', 'Download File');
if($link) { if($link) {
return DBField::create_field('HTMLText', sprintf( return DBField::create_field('HTMLText', sprintf(
'%s - <a href="%s" target="_blank">%s</a>', '%s - <a href="%s" target="_blank">%s</a>',
$name, $link, $title $name, $link, $title
)); ));
} }
return false; return false;
} }
/** /**
* Return the value for this field in the CSV export. * Return the value for this field in the CSV export.
* *
@ -45,7 +45,7 @@ class SubmittedFileField extends SubmittedFormField {
/** /**
* Return the link for the file attached to this submitted form field. * Return the link for the file attached to this submitted form field.
* *
* @return string * @return string
*/ */
public function getLink() { public function getLink() {
@ -55,7 +55,7 @@ class SubmittedFileField extends SubmittedFormField {
} }
} }
} }
/** /**
* Return the name of the file, if present * Return the name of the file, if present
* *

View File

@ -6,13 +6,13 @@
*/ */
class SubmittedForm extends DataObject { class SubmittedForm extends DataObject {
private static $has_one = array( private static $has_one = array(
"SubmittedBy" => "Member", "SubmittedBy" => "Member",
"Parent" => "UserDefinedForm", "Parent" => "UserDefinedForm",
); );
private static $has_many = array( private static $has_many = array(
"Values" => "SubmittedFormField" "Values" => "SubmittedFormField"
); );
@ -20,13 +20,13 @@ class SubmittedForm extends DataObject {
'ID', 'ID',
'Created' 'Created'
); );
/** /**
* Returns the value of a relation or, in the case of this form, the value * Returns the value of a relation or, in the case of this form, the value
* of a given child {@link SubmittedFormField} * of a given child {@link SubmittedFormField}
* *
* @param string * @param string
* *
* @return mixed * @return mixed
*/ */
public function relField($fieldName) { public function relField($fieldName) {
@ -50,30 +50,30 @@ class SubmittedForm extends DataObject {
* @return FieldList * @return FieldList
*/ */
public function getCMSFields() { public function getCMSFields() {
$self = $this; $self = $this;
$this->beforeUpdateCMSFields(function($fields) use ($self) { $this->beforeUpdateCMSFields(function($fields) use ($self) {
$fields->removeByName('Values'); $fields->removeByName('Values');
$fields->dataFieldByName('SubmittedByID')->setDisabled(true); $fields->dataFieldByName('SubmittedByID')->setDisabled(true);
$values = new GridField( $values = new GridField(
'Values', 'Values',
'SubmittedFormField', 'SubmittedFormField',
$self->Values()->sort('Created', 'ASC') $self->Values()->sort('Created', 'ASC')
); );
$config = new GridFieldConfig(); $config = new GridFieldConfig();
$config->addComponent(new GridFieldDataColumns()); $config->addComponent(new GridFieldDataColumns());
$config->addComponent(new GridFieldExportButton()); $config->addComponent(new GridFieldExportButton());
$config->addComponent(new GridFieldPrintButton()); $config->addComponent(new GridFieldPrintButton());
$values->setConfig($config); $values->setConfig($config);
$fields->addFieldToTab('Root.Main', $values); $fields->addFieldToTab('Root.Main', $values);
}); });
$fields = parent::getCMSFields(); $fields = parent::getCMSFields();
return $fields; return $fields;
} }
@ -125,7 +125,7 @@ class SubmittedForm extends DataObject {
$value->delete(); $value->delete();
} }
} }
parent::onBeforeDelete(); parent::onBeforeDelete();
} }
} }

View File

@ -6,13 +6,13 @@
*/ */
class SubmittedFormField extends DataObject { class SubmittedFormField extends DataObject {
private static $db = array( private static $db = array(
"Name" => "Varchar", "Name" => "Varchar",
"Value" => "Text", "Value" => "Text",
"Title" => "Varchar(255)" "Title" => "Varchar(255)"
); );
private static $has_one = array( private static $has_one = array(
"Parent" => "SubmittedForm" "Parent" => "SubmittedForm"
); );
@ -68,7 +68,7 @@ class SubmittedFormField extends DataObject {
public function getFormattedValue() { public function getFormattedValue() {
return nl2br($this->dbObject('Value')->ATT()); return nl2br($this->dbObject('Value')->ATT());
} }
/** /**
* Return the value of this submitted form field suitable for inclusion * Return the value of this submitted form field suitable for inclusion
* into the CSV * into the CSV
@ -84,7 +84,7 @@ class SubmittedFormField extends DataObject {
* *
* Note the field may have been modified or deleted from the original form * Note the field may have been modified or deleted from the original form
* so this may not always return the data you expect. If you need to save * so this may not always return the data you expect. If you need to save
* a particular state of editable form field at time of submission, copy * a particular state of editable form field at time of submission, copy
* that value to the submission. * that value to the submission.
* *
* @return EditableFormField * @return EditableFormField

View File

@ -56,7 +56,7 @@ class UserFormsUpgradeService {
// Migrate custom settings // Migrate custom settings
$this->migrateCustomSettings($field, $stage); $this->migrateCustomSettings($field, $stage);
// Flag as migrated // Flag as migrated
$field->Migrated = true; $field->Migrated = true;
$field->write(); $field->write();
@ -214,5 +214,5 @@ class UserFormsUpgradeService {
public function getQuiet() { public function getQuiet() {
return $this->quiet; return $this->quiet;
} }
} }

View File

@ -15,14 +15,14 @@ class UserFormsVersionedTask extends MigrationTask {
protected $title = "UserForms Versioned Initial Migration"; protected $title = "UserForms Versioned Initial Migration";
protected $description = "Publishes the existing forms"; protected $description = "Publishes the existing forms";
/** /**
* Publish the existing forms. * Publish the existing forms.
* *
*/ */
public function run($request) { public function run($request) {
$forms = Versioned::get_by_stage('UserDefinedForm', 'Live'); $forms = Versioned::get_by_stage('UserDefinedForm', 'Live');
if($forms) { if($forms) {
foreach($forms as $form) { foreach($forms as $form) {
echo "Publishing $form->Title <br />"; echo "Publishing $form->Title <br />";

View File

@ -5,37 +5,37 @@
*/ */
class EditableFormFieldTest extends FunctionalTest { class EditableFormFieldTest extends FunctionalTest {
static $fixture_file = 'userforms/tests/EditableFormFieldTest.yml'; static $fixture_file = 'userforms/tests/EditableFormFieldTest.yml';
function testFormFieldPermissions() { function testFormFieldPermissions() {
$text = $this->objFromFixture('EditableTextField', 'basic-text'); $text = $this->objFromFixture('EditableTextField', 'basic-text');
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$this->assertTrue($text->canEdit()); $this->assertTrue($text->canEdit());
$this->assertTrue($text->canDelete()); $this->assertTrue($text->canDelete());
$text->setReadonly(true); $text->setReadonly(true);
$this->assertFalse($text->canEdit()); $this->assertFalse($text->canEdit());
$this->assertFalse($text->canDelete()); $this->assertFalse($text->canDelete());
$text->setReadonly(false); $text->setReadonly(false);
$this->assertTrue($text->canEdit()); $this->assertTrue($text->canEdit());
$this->assertTrue($text->canDelete()); $this->assertTrue($text->canDelete());
$member = Member::currentUser(); $member = Member::currentUser();
$member->logout(); $member->logout();
$this->logInWithPermission('SITETREE_VIEW_ALL'); $this->logInWithPermission('SITETREE_VIEW_ALL');
$text->setReadonly(false); $text->setReadonly(false);
$this->assertFalse($text->canEdit()); $this->assertFalse($text->canEdit());
$this->assertFalse($text->canDelete()); $this->assertFalse($text->canDelete());
$text->setReadonly(true); $text->setReadonly(true);
$this->assertFalse($text->canEdit()); $this->assertFalse($text->canEdit());
$this->assertFalse($text->canDelete()); $this->assertFalse($text->canDelete());
} }
function testCustomRules() { function testCustomRules() {
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$form = $this->objFromFixture('UserDefinedForm', 'custom-rules-form'); $form = $this->objFromFixture('UserDefinedForm', 'custom-rules-form');
@ -56,40 +56,40 @@ class EditableFormFieldTest extends FunctionalTest {
$this->assertEquals($checkboxRule->ConditionOption, 'HasValue'); $this->assertEquals($checkboxRule->ConditionOption, 'HasValue');
$this->assertEquals($checkboxRule->FieldValue, '6'); $this->assertEquals($checkboxRule->FieldValue, '6');
} }
function testEditableDropdownField() { function testEditableDropdownField() {
$dropdown = $this->objFromFixture('EditableDropdown', 'basic-dropdown'); $dropdown = $this->objFromFixture('EditableDropdown', 'basic-dropdown');
$field = $dropdown->getFormField(); $field = $dropdown->getFormField();
$this->assertThat($field, $this->isInstanceOf('DropdownField')); $this->assertThat($field, $this->isInstanceOf('DropdownField'));
$values = $field->getSource(); $values = $field->getSource();
$this->assertEquals(array('Option 1' => 'Option 1', 'Option 2' => 'Option 2'), $values); $this->assertEquals(array('Option 1' => 'Option 1', 'Option 2' => 'Option 2'), $values);
} }
function testEditableRadioField() { function testEditableRadioField() {
$radio = $this->objFromFixture('EditableRadioField', 'radio-field'); $radio = $this->objFromFixture('EditableRadioField', 'radio-field');
$field = $radio->getFormField(); $field = $radio->getFormField();
$this->assertThat($field, $this->isInstanceOf('OptionsetField')); $this->assertThat($field, $this->isInstanceOf('OptionsetField'));
$values = $field->getSource(); $values = $field->getSource();
$this->assertEquals(array('Option 5' => 'Option 5', 'Option 6' => 'Option 6'), $values); $this->assertEquals(array('Option 5' => 'Option 5', 'Option 6' => 'Option 6'), $values);
} }
function testMultipleOptionDuplication() { function testMultipleOptionDuplication() {
$dropdown = $this->objFromFixture('EditableDropdown','basic-dropdown'); $dropdown = $this->objFromFixture('EditableDropdown','basic-dropdown');
$clone = $dropdown->duplicate(); $clone = $dropdown->duplicate();
$this->assertEquals($clone->Options()->Count(), $dropdown->Options()->Count()); $this->assertEquals($clone->Options()->Count(), $dropdown->Options()->Count());
foreach($clone->Options() as $option) { foreach($clone->Options() as $option) {
$orginal = $dropdown->Options()->find('Title', $option->Title); $orginal = $dropdown->Options()->find('Title', $option->Title);
$this->assertEquals($orginal->Sort, $option->Sort); $this->assertEquals($orginal->Sort, $option->Sort);
} }
} }

View File

@ -24,7 +24,7 @@ class EditableLiteralFieldTest extends SapphireTest {
$rawContent = '<h1>Welcome</h1><script>alert("Hello!");</script><p>Giant Robots!</p>'; $rawContent = '<h1>Welcome</h1><script>alert("Hello!");</script><p>Giant Robots!</p>';
$safeContent = '<h1>Welcome</h1><p>Giant Robots!</p>'; $safeContent = '<h1>Welcome</h1><p>Giant Robots!</p>';
$field = new EditableLiteralField(); $field = new EditableLiteralField();
// Test with sanitisation enabled // Test with sanitisation enabled
Config::inst()->update('HtmlEditorField', 'sanitise_server_side', true); Config::inst()->update('HtmlEditorField', 'sanitise_server_side', true);
$field->setContent($rawContent); $field->setContent($rawContent);

View File

@ -11,7 +11,7 @@ class SecureEditableFileFieldTest extends SapphireTest {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
if(!class_exists('SecureFileExtension')) { if(!class_exists('SecureFileExtension')) {
$this->skipTest = true; $this->skipTest = true;
$this->markTestSkipped(get_class() . ' skipped unless running with securefiles'); $this->markTestSkipped(get_class() . ' skipped unless running with securefiles');

View File

@ -5,14 +5,14 @@
*/ */
class UserDefinedFormControllerTest extends FunctionalTest { class UserDefinedFormControllerTest extends FunctionalTest {
static $fixture_file = 'UserDefinedFormTest.yml'; static $fixture_file = 'UserDefinedFormTest.yml';
function testProcess() { function testProcess() {
$form = $this->setupFormFrontend(); $form = $this->setupFormFrontend();
$controller = new UserDefinedFormControllerTest_Controller($form); $controller = new UserDefinedFormControllerTest_Controller($form);
$this->autoFollowRedirection = false; $this->autoFollowRedirection = false;
$this->clearEmails(); $this->clearEmails();
@ -26,40 +26,40 @@ class UserDefinedFormControllerTest extends FunctionalTest {
// should have a submitted form field now // should have a submitted form field now
$submitted = DataObject::get('SubmittedFormField', "\"Name\" = 'basic-text-name'"); $submitted = DataObject::get('SubmittedFormField', "\"Name\" = 'basic-text-name'");
$this->assertDOSAllMatch(array('Name' => 'basic-text-name', 'Value' => 'Basic Value', 'Title' => 'Basic Text Field'), $submitted); $this->assertDOSAllMatch(array('Name' => 'basic-text-name', 'Value' => 'Basic Value', 'Title' => 'Basic Text Field'), $submitted);
// check emails // check emails
$this->assertEmailSent('test@example.com', 'no-reply@example.com', 'Email Subject'); $this->assertEmailSent('test@example.com', 'no-reply@example.com', 'Email Subject');
$email = $this->findEmail('test@example.com', 'no-reply@example.com', 'Email Subject'); $email = $this->findEmail('test@example.com', 'no-reply@example.com', 'Email Subject');
// assert that the email has the field title and the value html email // assert that the email has the field title and the value html email
$parser = new CSSContentParser($email['content']); $parser = new CSSContentParser($email['content']);
$title = $parser->getBySelector('strong'); $title = $parser->getBySelector('strong');
$this->assertEquals('Basic Text Field', (string) $title[0], 'Email contains the field name'); $this->assertEquals('Basic Text Field', (string) $title[0], 'Email contains the field name');
$value = $parser->getBySelector('dd'); $value = $parser->getBySelector('dd');
$this->assertEquals('Basic Value', (string) $value[0], 'Email contains the value'); $this->assertEquals('Basic Value', (string) $value[0], 'Email contains the value');
// no html // no html
$this->assertEmailSent('nohtml@example.com', 'no-reply@example.com', 'Email Subject'); $this->assertEmailSent('nohtml@example.com', 'no-reply@example.com', 'Email Subject');
$nohtml = $this->findEmail('nohtml@example.com', 'no-reply@example.com', 'Email Subject'); $nohtml = $this->findEmail('nohtml@example.com', 'no-reply@example.com', 'Email Subject');
$this->assertContains('Basic Text Field: Basic Value', $nohtml['content'], 'Email contains no html'); $this->assertContains('Basic Text Field: Basic Value', $nohtml['content'], 'Email contains no html');
// no data // no data
$this->assertEmailSent('nodata@example.com', 'no-reply@example.com', 'Email Subject'); $this->assertEmailSent('nodata@example.com', 'no-reply@example.com', 'Email Subject');
$nodata = $this->findEmail('nodata@example.com', 'no-reply@example.com', 'Email Subject'); $nodata = $this->findEmail('nodata@example.com', 'no-reply@example.com', 'Email Subject');
$parser = new CSSContentParser($nodata['content']); $parser = new CSSContentParser($nodata['content']);
$list = $parser->getBySelector('dl'); $list = $parser->getBySelector('dl');
$this->assertFalse(isset($list[0]), 'Email contains no fields'); $this->assertFalse(isset($list[0]), 'Email contains no fields');
// check to see if the user was redirected (301) // check to see if the user was redirected (301)
$this->assertEquals($response->getStatusCode(), 302); $this->assertEquals($response->getStatusCode(), 302);
$this->assertStringEndsWith('finished#uff', $response->getHeader('Location')); $this->assertStringEndsWith('finished#uff', $response->getHeader('Location'));
} }
function testFinished() { function testFinished() {
$form = $this->setupFormFrontend(); $form = $this->setupFormFrontend();
@ -68,7 +68,7 @@ class UserDefinedFormControllerTest extends FunctionalTest {
$this->session()->inst_set('FormProcessed', 1); $this->session()->inst_set('FormProcessed', 1);
$response = $this->get($form->URLSegment.'/finished'); $response = $this->get($form->URLSegment.'/finished');
$this->assertContains($form->OnCompleteMessage ,$response->getBody()); $this->assertContains($form->OnCompleteMessage ,$response->getBody());
} }
@ -80,16 +80,16 @@ class UserDefinedFormControllerTest extends FunctionalTest {
$this->session()->inst_set('FormProcessed', null); $this->session()->inst_set('FormProcessed', null);
$response = $this->get($form->URLSegment.'/finished'); $response = $this->get($form->URLSegment.'/finished');
$this->assertNotContains($form->OnCompleteMessage ,$response->getBody()); $this->assertNotContains($form->OnCompleteMessage ,$response->getBody());
} }
function testForm() { function testForm() {
$form = $this->objFromFixture('UserDefinedForm', 'basic-form-page'); $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
$controller = new UserDefinedFormControllerTest_Controller($form); $controller = new UserDefinedFormControllerTest_Controller($form);
// test form // test form
$this->assertEquals($controller->Form()->getName(), 'Form', 'The form is referenced as Form'); $this->assertEquals($controller->Form()->getName(), 'Form', 'The form is referenced as Form');
$this->assertEquals($controller->Form()->Fields()->Count(), 1); // disabled SecurityID token fields $this->assertEquals($controller->Form()->Fields()->Count(), 1); // disabled SecurityID token fields
$this->assertEquals($controller->Form()->Actions()->Count(), 1); $this->assertEquals($controller->Form()->Actions()->Count(), 1);
@ -102,23 +102,23 @@ class UserDefinedFormControllerTest extends FunctionalTest {
$this->assertEquals($controller->Form()->Actions()->Count(), 1); $this->assertEquals($controller->Form()->Actions()->Count(), 1);
$this->assertEquals(count($controller->Form()->getValidator()->getRequired()), 1); $this->assertEquals(count($controller->Form()->getValidator()->getRequired()), 1);
} }
function testGetFormFields() { function testGetFormFields() {
// generating the fieldset of fields // generating the fieldset of fields
$form = $this->objFromFixture('UserDefinedForm', 'basic-form-page'); $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
$controller = new UserDefinedFormControllerTest_Controller($form); $controller = new UserDefinedFormControllerTest_Controller($form);
$formSteps = $controller->Form()->getFormFields(); $formSteps = $controller->Form()->getFormFields();
$firstStep = $formSteps->first(); $firstStep = $formSteps->first();
$this->assertEquals($formSteps->Count(), 1); $this->assertEquals($formSteps->Count(), 1);
$this->assertEquals($firstStep->getChildren()->Count(), 1); $this->assertEquals($firstStep->getChildren()->Count(), 1);
// custom error message on a form field // custom error message on a form field
$requiredForm = $this->objFromFixture('UserDefinedForm', 'validation-form'); $requiredForm = $this->objFromFixture('UserDefinedForm', 'validation-form');
$controller = new UserDefinedFormControllerTest_Controller($requiredForm); $controller = new UserDefinedFormControllerTest_Controller($requiredForm);
UserDefinedForm::config()->required_identifier = "*"; UserDefinedForm::config()->required_identifier = "*";
$formSteps = $controller->Form()->getFormFields(); $formSteps = $controller->Form()->getFormFields();
@ -127,37 +127,37 @@ class UserDefinedFormControllerTest extends FunctionalTest {
$this->assertEquals('Custom Error Message', $firstField->getCustomValidationMessage()->getValue()); $this->assertEquals('Custom Error Message', $firstField->getCustomValidationMessage()->getValue());
$this->assertEquals($firstField->Title(), 'Required Text Field <span class=\'required-identifier\'>*</span>'); $this->assertEquals($firstField->Title(), 'Required Text Field <span class=\'required-identifier\'>*</span>');
// test custom right title // test custom right title
$field = $form->Fields()->limit(1, 1)->First(); $field = $form->Fields()->limit(1, 1)->First();
$field->RightTitle = 'Right Title'; $field->RightTitle = 'Right Title';
$field->write(); $field->write();
$controller = new UserDefinedFormControllerTest_Controller($form); $controller = new UserDefinedFormControllerTest_Controller($form);
$formSteps = $controller->Form()->getFormFields(); $formSteps = $controller->Form()->getFormFields();
$firstStep = $formSteps->first(); $firstStep = $formSteps->first();
$this->assertEquals($firstStep->getChildren()->First()->RightTitle(), "Right Title"); $this->assertEquals($firstStep->getChildren()->First()->RightTitle(), "Right Title");
// test empty form // test empty form
$emptyForm = $this->objFromFixture('UserDefinedForm', 'empty-form'); $emptyForm = $this->objFromFixture('UserDefinedForm', 'empty-form');
$controller = new UserDefinedFormControllerTest_Controller($emptyForm); $controller = new UserDefinedFormControllerTest_Controller($emptyForm);
$this->assertFalse($controller->Form()->getFormFields()->exists()); $this->assertFalse($controller->Form()->getFormFields()->exists());
} }
function testGetFormActions() { function testGetFormActions() {
// generating the fieldset of actions // generating the fieldset of actions
$form = $this->objFromFixture('UserDefinedForm', 'basic-form-page'); $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
$controller = new UserDefinedFormControllerTest_Controller($form); $controller = new UserDefinedFormControllerTest_Controller($form);
$actions = $controller->Form()->getFormActions(); $actions = $controller->Form()->getFormActions();
// by default will have 1 submit button which links to process // by default will have 1 submit button which links to process
$expected = new FieldList(new FormAction('process', 'Submit')); $expected = new FieldList(new FormAction('process', 'Submit'));
$this->assertEquals($actions, $expected); $this->assertEquals($actions, $expected);
// the custom popup should have a reset button and a custom text // the custom popup should have a reset button and a custom text
$custom = $this->objFromFixture('UserDefinedForm', 'form-with-reset-and-custom-action'); $custom = $this->objFromFixture('UserDefinedForm', 'form-with-reset-and-custom-action');
$controller = new UserDefinedFormControllerTest_Controller($custom); $controller = new UserDefinedFormControllerTest_Controller($custom);
@ -168,77 +168,77 @@ class UserDefinedFormControllerTest extends FunctionalTest {
$this->assertEquals($actions, $expected); $this->assertEquals($actions, $expected);
} }
function testRenderingIntoFormTemplate() { function testRenderingIntoFormTemplate() {
$form = $this->setupFormFrontend(); $form = $this->setupFormFrontend();
$form->Content = 'This is some content without a form nested between it'; $form->Content = 'This is some content without a form nested between it';
$form->doPublish(); $form->doPublish();
$controller = new UserDefinedFormControllerTest_Controller($form); $controller = new UserDefinedFormControllerTest_Controller($form);
// check to see if $Form is replaced to inside the content // check to see if $Form is replaced to inside the content
$index = new ArrayData($controller->index()); $index = new ArrayData($controller->index());
$parser = new CSSContentParser($index->renderWith(array('UserDefinedFormControllerTest'))); $parser = new CSSContentParser($index->renderWith(array('UserDefinedFormControllerTest')));
$this->checkTemplateIsCorrect($parser); $this->checkTemplateIsCorrect($parser);
} }
function testRenderingIntoTemplateWithSubstringReplacement() { function testRenderingIntoTemplateWithSubstringReplacement() {
$form = $this->setupFormFrontend(); $form = $this->setupFormFrontend();
$controller = new UserDefinedFormControllerTest_Controller($form); $controller = new UserDefinedFormControllerTest_Controller($form);
// check to see if $Form is replaced to inside the content // check to see if $Form is replaced to inside the content
$index = new ArrayData($controller->index()); $index = new ArrayData($controller->index());
$parser = new CSSContentParser($index->renderWith(array('UserDefinedFormControllerTest'))); $parser = new CSSContentParser($index->renderWith(array('UserDefinedFormControllerTest')));
$this->checkTemplateIsCorrect($parser); $this->checkTemplateIsCorrect($parser);
} }
function setupFormFrontend() { function setupFormFrontend() {
$form = $this->objFromFixture('UserDefinedForm', 'basic-form-page'); $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$form->doPublish(); $form->doPublish();
$member = Member::currentUser(); $member = Member::currentUser();
$member->logOut(); $member->logOut();
return $form; return $form;
} }
function checkTemplateIsCorrect($parser) { function checkTemplateIsCorrect($parser) {
$this->assertArrayHasKey(0, $parser->getBySelector('form#UserForm_Form')); $this->assertArrayHasKey(0, $parser->getBySelector('form#UserForm_Form'));
// check for the input // check for the input
$this->assertArrayHasKey(0, $parser->getBySelector('input.text')); $this->assertArrayHasKey(0, $parser->getBySelector('input.text'));
// check for the label and the text // check for the label and the text
$label = $parser->getBySelector('label.left'); $label = $parser->getBySelector('label.left');
$this->assertArrayHasKey(0, $label); $this->assertArrayHasKey(0, $label);
$this->assertEquals((string) $label[0][0], "Basic Text Field", "Label contains correct field name"); $this->assertEquals((string) $label[0][0], "Basic Text Field", "Label contains correct field name");
// check for the action // check for the action
$action = $parser->getBySelector('input.action'); $action = $parser->getBySelector('input.action');
$this->assertArrayHasKey(0, $action); $this->assertArrayHasKey(0, $action);
$this->assertEquals((string) $action[0]['value'], "Submit", "Submit button has default text"); $this->assertEquals((string) $action[0]['value'], "Submit", "Submit button has default text");
} }
} }
class UserDefinedFormControllerTest_Controller extends UserDefinedForM_Controller implements TestOnly { class UserDefinedFormControllerTest_Controller extends UserDefinedForM_Controller implements TestOnly {
/** /**
* Overloaded to avoid inconsistencies between 2.4.2 and 2.4.3 (disables all security tokens in unit tests by default) * Overloaded to avoid inconsistencies between 2.4.2 and 2.4.3 (disables all security tokens in unit tests by default)
*/ */
function Form() { function Form() {
$form = parent::Form(); $form = parent::Form();
if($form) $form->disableSecurityToken(); if($form) $form->disableSecurityToken();
return $form; return $form;
} }
} }

View File

@ -4,9 +4,9 @@
* @package userforms * @package userforms
*/ */
class UserDefinedFormTest extends FunctionalTest { class UserDefinedFormTest extends FunctionalTest {
static $fixture_file = 'UserDefinedFormTest.yml'; static $fixture_file = 'UserDefinedFormTest.yml';
public function testRollbackToVersion() { public function testRollbackToVersion() {
$this->markTestSkipped( $this->markTestSkipped(
'UserDefinedForm::rollback() has not been implemented completely' 'UserDefinedForm::rollback() has not been implemented completely'
@ -364,7 +364,7 @@ class UserDefinedFormTest extends FunctionalTest {
$this->assertFalse($result->isError()); $this->assertFalse($result->isError());
$this->assertContains('<p>Here is my form</p><form', $body); $this->assertContains('<p>Here is my form</p><form', $body);
$this->assertContains('</form><p>Thank you for filling it out</p>', $body); $this->assertContains('</form><p>Thank you for filling it out</p>', $body);
$this->assertNotContains('<p>$UserDefinedForm</p>', $body); $this->assertNotContains('<p>$UserDefinedForm</p>', $body);
$this->assertNotContains('<p></p>', $body); $this->assertNotContains('<p></p>', $body);
$this->assertNotContains('</p><p>Thank you for filling it out</p>', $body); $this->assertNotContains('</p><p>Thank you for filling it out</p>', $body);

View File

@ -121,7 +121,7 @@ class UserFormsUpgradeServiceTest extends SapphireTest {
$field1 = $this->objFromFixture('EditableTextField', 'text1'); $field1 = $this->objFromFixture('EditableTextField', 'text1');
$field2 = $this->objFromFixture('EditableTextField', 'text2'); $field2 = $this->objFromFixture('EditableTextField', 'text2');
$field3 = $this->objFromFixture('EditableTextField', 'text3'); $field3 = $this->objFromFixture('EditableTextField', 'text3');
$this->assertDOSEquals(array( $this->assertDOSEquals(array(
array( array(
'Display' => 'Show', 'Display' => 'Show',
@ -148,7 +148,7 @@ class UserFormsUpgradeServiceTest extends SapphireTest {
$group1 = $this->objFromFixture('Group', 'group1'); $group1 = $this->objFromFixture('Group', 'group1');
$form = $this->objFromFixture('UserDefinedForm', 'form-with-settings'); $form = $this->objFromFixture('UserDefinedForm', 'form-with-settings');
$folder = $this->objFromFixture('Folder', 'folder1'); $folder = $this->objFromFixture('Folder', 'folder1');
$this->assertDOSEquals(array( $this->assertDOSEquals(array(
array( array(
'ClassName' => 'EditableTextField', 'ClassName' => 'EditableTextField',