mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
BUG: Fix access to static configuration variables
- Make statics private - Use Config::get rather than eval to read private statics - Add a helper function to expose UserDefinedForm_EmailRecipient::$summary_fields (to make them available for i18n).
This commit is contained in:
parent
bd60ad80c0
commit
656a9fbb4e
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
class FieldEditor extends FormField {
|
class FieldEditor extends FormField {
|
||||||
|
|
||||||
public static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'addfield',
|
'addfield',
|
||||||
'addoptionfield'
|
'addoptionfield'
|
||||||
);
|
);
|
||||||
@ -102,7 +102,7 @@ class FieldEditor extends FormField {
|
|||||||
$output = new ArrayList();
|
$output = new ArrayList();
|
||||||
foreach($fields as $field => $title) {
|
foreach($fields as $field => $title) {
|
||||||
// get the nice title and strip out field
|
// get the nice title and strip out field
|
||||||
$niceTitle = trim(eval("return $title::\$singular_name;"));
|
$niceTitle = Config::inst()->get($title, 'singular_name');
|
||||||
if($niceTitle) {
|
if($niceTitle) {
|
||||||
$output->push(new ArrayData(array(
|
$output->push(new ArrayData(array(
|
||||||
'ClassName' => $field,
|
'ClassName' => $field,
|
||||||
|
@ -74,11 +74,11 @@ class UserDefinedForm extends Page {
|
|||||||
$editor->setRows(3);
|
$editor->setRows(3);
|
||||||
$label->addExtraClass('left');
|
$label->addExtraClass('left');
|
||||||
|
|
||||||
UserDefinedForm_EmailRecipient::$summary_fields = array(
|
UserDefinedForm_EmailRecipient::set_summary_fields(array(
|
||||||
'EmailAddress' => _t('UserDefinedForm.EMAILADDRESS', 'Email'),
|
'EmailAddress' => _t('UserDefinedForm.EMAILADDRESS', 'Email'),
|
||||||
'EmailSubject' => _t('UserDefinedForm.EMAILSUBJECT', 'Subject'),
|
'EmailSubject' => _t('UserDefinedForm.EMAILSUBJECT', 'Subject'),
|
||||||
'EmailFrom' => _t('UserDefinedForm.EMAILFROM', 'From')
|
'EmailFrom' => _t('UserDefinedForm.EMAILFROM', 'From')
|
||||||
);
|
));
|
||||||
|
|
||||||
// who do we email on submission
|
// who do we email on submission
|
||||||
$emailRecipients = new GridField("EmailRecipients", _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'), $this->EmailRecipients(), GridFieldConfig_RecordEditor::create(10));
|
$emailRecipients = new GridField("EmailRecipients", _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'), $this->EmailRecipients(), GridFieldConfig_RecordEditor::create(10));
|
||||||
@ -1016,7 +1016,7 @@ JS
|
|||||||
*/
|
*/
|
||||||
class UserDefinedForm_EmailRecipient extends DataObject {
|
class UserDefinedForm_EmailRecipient extends DataObject {
|
||||||
|
|
||||||
public static $db = array(
|
private static $db = array(
|
||||||
'EmailAddress' => 'Varchar(200)',
|
'EmailAddress' => 'Varchar(200)',
|
||||||
'EmailSubject' => 'Varchar(200)',
|
'EmailSubject' => 'Varchar(200)',
|
||||||
'EmailFrom' => 'Varchar(200)',
|
'EmailFrom' => 'Varchar(200)',
|
||||||
@ -1026,12 +1026,23 @@ class UserDefinedForm_EmailRecipient extends DataObject {
|
|||||||
'HideFormData' => 'Boolean'
|
'HideFormData' => 'Boolean'
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $has_one = array(
|
private static $has_one = array(
|
||||||
'Form' => 'UserDefinedForm',
|
'Form' => 'UserDefinedForm',
|
||||||
'SendEmailFromField' => 'EditableFormField',
|
'SendEmailFromField' => 'EditableFormField',
|
||||||
'SendEmailToField' => 'EditableFormField'
|
'SendEmailToField' => 'EditableFormField'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $summary_fields = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose the summary_fields static
|
||||||
|
*
|
||||||
|
* @param array $fields
|
||||||
|
*/
|
||||||
|
public static function set_summary_fields($fields) {
|
||||||
|
self::$summary_fields = $fields;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return FieldList
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
class EditableCheckbox extends EditableFormField {
|
class EditableCheckbox extends EditableFormField {
|
||||||
|
|
||||||
static $singular_name = 'Checkbox Field';
|
private static $singular_name = 'Checkbox Field';
|
||||||
|
|
||||||
static $plural_name = 'Checkboxes';
|
private static $plural_name = 'Checkboxes';
|
||||||
|
|
||||||
public function getFieldConfiguration() {
|
public function getFieldConfiguration() {
|
||||||
$options = parent::getFieldConfiguration();
|
$options = parent::getFieldConfiguration();
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
class EditableCheckboxGroupField extends EditableMultipleOptionField {
|
class EditableCheckboxGroupField extends EditableMultipleOptionField {
|
||||||
|
|
||||||
static $singular_name = "Checkbox Group";
|
private static $singular_name = "Checkbox Group";
|
||||||
|
|
||||||
static $plural_name = "Checkbox Groups";
|
private static $plural_name = "Checkbox Groups";
|
||||||
|
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
$optionSet = $this->Options();
|
$optionSet = $this->Options();
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
class EditableDateField extends EditableFormField {
|
class EditableDateField extends EditableFormField {
|
||||||
|
|
||||||
static $singular_name = 'Date Field';
|
private static $singular_name = 'Date Field';
|
||||||
|
|
||||||
static $plural_name = 'Date Fields';
|
private static $plural_name = 'Date Fields';
|
||||||
|
|
||||||
public function getFieldConfiguration() {
|
public function getFieldConfiguration() {
|
||||||
$default = ($this->getSetting('DefaultToToday')) ? $this->getSetting('DefaultToToday') : false;
|
$default = ($this->getSetting('DefaultToToday')) ? $this->getSetting('DefaultToToday') : false;
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
class EditableDropdown extends EditableMultipleOptionField {
|
class EditableDropdown extends EditableMultipleOptionField {
|
||||||
|
|
||||||
static $singular_name = 'Dropdown Field';
|
private static $singular_name = 'Dropdown Field';
|
||||||
|
|
||||||
static $plural_name = 'Dropdowns';
|
private static $plural_name = 'Dropdowns';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DropdownField
|
* @return DropdownField
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
class EditableEmailField extends EditableFormField {
|
class EditableEmailField extends EditableFormField {
|
||||||
|
|
||||||
static $singular_name = 'Email Field';
|
private static $singular_name = 'Email Field';
|
||||||
|
|
||||||
static $plural_name = 'Email Fields';
|
private static $plural_name = 'Email Fields';
|
||||||
|
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
return new EmailField($this->Name, $this->Title);
|
return new EmailField($this->Name, $this->Title);
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
class EditableFileField extends EditableFormField {
|
class EditableFileField extends EditableFormField {
|
||||||
|
|
||||||
public static $singular_name = 'File Upload Field';
|
private static $singular_name = 'File Upload Field';
|
||||||
|
|
||||||
public static $plural_names = 'File Fields';
|
private static $plural_names = 'File Fields';
|
||||||
|
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
$field = new FileField($this->Name, $this->Title);
|
$field = new FileField($this->Name, $this->Title);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
class EditableFormField extends DataObject {
|
class EditableFormField extends DataObject {
|
||||||
|
|
||||||
static $default_sort = "Sort";
|
private static $default_sort = "Sort";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of CSS classes that can be added
|
* A list of CSS classes that can be added
|
||||||
@ -17,7 +17,7 @@ class EditableFormField extends DataObject {
|
|||||||
*/
|
*/
|
||||||
public static $allowed_css = array();
|
public static $allowed_css = array();
|
||||||
|
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
"Name" => "Varchar",
|
"Name" => "Varchar",
|
||||||
"Title" => "Varchar(255)",
|
"Title" => "Varchar(255)",
|
||||||
"Default" => "Varchar",
|
"Default" => "Varchar",
|
||||||
@ -29,11 +29,11 @@ class EditableFormField extends DataObject {
|
|||||||
"CustomParameter" => "Varchar(200)"
|
"CustomParameter" => "Varchar(200)"
|
||||||
);
|
);
|
||||||
|
|
||||||
static $has_one = array(
|
private static $has_one = array(
|
||||||
"Parent" => "UserDefinedForm",
|
"Parent" => "UserDefinedForm",
|
||||||
);
|
);
|
||||||
|
|
||||||
static $extensions = array(
|
private static $extensions = array(
|
||||||
"Versioned('Stage', 'Live')"
|
"Versioned('Stage', 'Live')"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
class EditableFormHeading extends EditableFormField {
|
class EditableFormHeading extends EditableFormField {
|
||||||
|
|
||||||
static $singular_name = 'Heading';
|
private static $singular_name = 'Heading';
|
||||||
|
|
||||||
static $plural_name = 'Headings';
|
private static $plural_name = 'Headings';
|
||||||
|
|
||||||
public function getFieldConfiguration() {
|
public function getFieldConfiguration() {
|
||||||
$levels = array(
|
$levels = array(
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
class EditableLiteralField extends EditableFormField {
|
class EditableLiteralField extends EditableFormField {
|
||||||
|
|
||||||
static $singular_name = 'HTML Block';
|
private static $singular_name = 'HTML Block';
|
||||||
|
|
||||||
static $plural_name = 'HTML Blocks';
|
private static $plural_name = 'HTML Blocks';
|
||||||
|
|
||||||
public function getFieldConfiguration() {
|
public function getFieldConfiguration() {
|
||||||
$customSettings = unserialize($this->CustomSettings);
|
$customSettings = unserialize($this->CustomSettings);
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
class EditableMemberListField extends EditableFormField {
|
class EditableMemberListField extends EditableFormField {
|
||||||
|
|
||||||
static $singular_name = 'Member List Field';
|
private static $singular_name = 'Member List Field';
|
||||||
|
|
||||||
static $plural_name = 'Member List Fields';
|
private static $plural_name = 'Member List Fields';
|
||||||
|
|
||||||
public function getFieldConfiguration() {
|
public function getFieldConfiguration() {
|
||||||
$groupID = ($this->getSetting('GroupID')) ? $this->getSetting('GroupID') : 0;
|
$groupID = ($this->getSetting('GroupID')) ? $this->getSetting('GroupID') : 0;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
class EditableMultipleOptionField extends EditableFormField {
|
class EditableMultipleOptionField extends EditableFormField {
|
||||||
|
|
||||||
static $has_many = array(
|
private static $has_many = array(
|
||||||
"Options" => "EditableOption"
|
"Options" => "EditableOption"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -9,20 +9,20 @@
|
|||||||
|
|
||||||
class EditableOption extends DataObject {
|
class EditableOption extends DataObject {
|
||||||
|
|
||||||
static $default_sort = "Sort";
|
private static $default_sort = "Sort";
|
||||||
|
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
"Name" => "Varchar(255)",
|
"Name" => "Varchar(255)",
|
||||||
"Title" => "Varchar(255)",
|
"Title" => "Varchar(255)",
|
||||||
"Default" => "Boolean",
|
"Default" => "Boolean",
|
||||||
"Sort" => "Int"
|
"Sort" => "Int"
|
||||||
);
|
);
|
||||||
|
|
||||||
static $has_one = array(
|
private static $has_one = array(
|
||||||
"Parent" => "EditableMultipleOptionField",
|
"Parent" => "EditableMultipleOptionField",
|
||||||
);
|
);
|
||||||
|
|
||||||
static $extensions = array(
|
private static $extensions = array(
|
||||||
"Versioned('Stage', 'Live')"
|
"Versioned('Stage', 'Live')"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
class EditableRadioField extends EditableMultipleOptionField {
|
class EditableRadioField extends EditableMultipleOptionField {
|
||||||
|
|
||||||
static $singular_name = 'Radio field';
|
private static $singular_name = 'Radio field';
|
||||||
|
|
||||||
static $plural_name = 'Radio fields';
|
private static $plural_name = 'Radio fields';
|
||||||
|
|
||||||
public function getFormField() {
|
public function getFormField() {
|
||||||
$optionSet = $this->Options();
|
$optionSet = $this->Options();
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
class EditableTextField extends EditableFormField {
|
class EditableTextField extends EditableFormField {
|
||||||
|
|
||||||
static $singular_name = 'Text Field';
|
private static $singular_name = 'Text Field';
|
||||||
|
|
||||||
static $plural_name = 'Text Fields';
|
private static $plural_name = 'Text Fields';
|
||||||
|
|
||||||
public function getFieldConfiguration() {
|
public function getFieldConfiguration() {
|
||||||
$fields = parent::getFieldConfiguration();
|
$fields = parent::getFieldConfiguration();
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
class SubmittedFileField extends SubmittedFormField {
|
class SubmittedFileField extends SubmittedFormField {
|
||||||
|
|
||||||
public static $has_one = array(
|
private static $has_one = array(
|
||||||
"UploadedFile" => "File"
|
"UploadedFile" => "File"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -7,16 +7,16 @@
|
|||||||
|
|
||||||
class SubmittedForm extends DataObject {
|
class SubmittedForm extends DataObject {
|
||||||
|
|
||||||
public static $has_one = array(
|
private static $has_one = array(
|
||||||
"SubmittedBy" => "Member",
|
"SubmittedBy" => "Member",
|
||||||
"Parent" => "UserDefinedForm",
|
"Parent" => "UserDefinedForm",
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $has_many = array(
|
private static $has_many = array(
|
||||||
"Values" => "SubmittedFormField"
|
"Values" => "SubmittedFormField"
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $summary_fields = array(
|
private static $summary_fields = array(
|
||||||
'ID',
|
'ID',
|
||||||
'Created'
|
'Created'
|
||||||
);
|
);
|
||||||
|
@ -7,17 +7,17 @@
|
|||||||
|
|
||||||
class SubmittedFormField extends DataObject {
|
class SubmittedFormField extends DataObject {
|
||||||
|
|
||||||
public static $db = array(
|
private static $db = array(
|
||||||
"Name" => "Varchar",
|
"Name" => "Varchar",
|
||||||
"Value" => "Text",
|
"Value" => "Text",
|
||||||
"Title" => "Varchar(255)"
|
"Title" => "Varchar(255)"
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $has_one = array(
|
private static $has_one = array(
|
||||||
"Parent" => "SubmittedForm"
|
"Parent" => "SubmittedForm"
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $summary_fields = array(
|
private static $summary_fields = array(
|
||||||
'Title',
|
'Title',
|
||||||
'FormattedValue' => 'Value'
|
'FormattedValue' => 'Value'
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user