silverstripe-userforms/code/model/formfields/EditableLiteralField.php
Fred Condo 656a9fbb4e 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).
2013-04-03 14:31:37 -07:00

53 lines
1.3 KiB
PHP

<?php
/**
* Editable Literal Field. A literal field is just a blank slate where
* you can add your own HTML / Images / Flash
*
* @package userforms
*/
class EditableLiteralField extends EditableFormField {
private static $singular_name = 'HTML Block';
private static $plural_name = 'HTML Blocks';
public function getFieldConfiguration() {
$customSettings = unserialize($this->CustomSettings);
$content = (isset($customSettings['Content'])) ? $customSettings['Content'] : '';
$textAreaField = new TextareaField(
$this->getSettingName('Content'),
"HTML",
$content
);
$textAreaField->setRows(4);
$textAreaField->setColumns(20);
return new FieldList(
$textAreaField,
new CheckboxField(
$this->getSettingName('HideFromReports'),
_t('EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?'),
$this->getSetting('HideFromReports')
)
);
}
public function getFormField() {
$label = $this->Title ? "<label class='left'>$this->Title</label>":"";
$classes = $this->Title ? "" : " nolabel";
return new LiteralField("LiteralField[$this->ID]",
"<div id='$this->Name' class='field text$classes'>
$label
<div class='middleColumn literalFieldArea'>". $this->getSetting('Content') ."</div>".
"</div>"
);
}
public function showInReports() {
return (!$this->getSetting('HideFromReports'));
}
}