2016-06-03 10:51:02 +02:00
|
|
|
<?php
|
|
|
|
|
2016-08-19 00:51:35 +02:00
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
|
2016-06-03 10:51:02 +02:00
|
|
|
/**
|
|
|
|
* Readonly field equivalent for literal HTML
|
|
|
|
*
|
2021-12-13 09:05:33 +01:00
|
|
|
* Unlike HTMLEditorField_Readonly, does not process shortcodes
|
2016-06-03 10:51:02 +02:00
|
|
|
*/
|
2016-11-29 00:31:16 +01:00
|
|
|
class HTMLReadonlyField extends ReadonlyField
|
|
|
|
{
|
|
|
|
private static $casting = [
|
|
|
|
'Value' => 'HTMLFragment',
|
|
|
|
'ValueEntities' => 'HTMLFragment',
|
|
|
|
];
|
2016-07-14 04:43:53 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
protected $schemaDataType = self::SCHEMA_DATA_TYPE_STRUCTURAL;
|
2016-08-16 00:50:41 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
|
|
|
* @skipUpgrade
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $schemaComponent = 'HtmlReadonlyField';
|
2016-08-16 00:50:41 +02:00
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
public function Field($properties = [])
|
2016-11-29 00:31:16 +01:00
|
|
|
{
|
|
|
|
return $this->renderWith($this->getTemplates());
|
|
|
|
}
|
2016-07-14 04:43:53 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
|
|
|
* Return value with all values encoded in html entities
|
|
|
|
*
|
|
|
|
* @return string Raw HTML
|
|
|
|
*/
|
|
|
|
public function ValueEntities()
|
|
|
|
{
|
2022-04-14 03:12:59 +02:00
|
|
|
return htmlentities($this->Value() ?? '', ENT_COMPAT, 'UTF-8');
|
2016-11-29 00:31:16 +01:00
|
|
|
}
|
2016-06-03 10:51:02 +02:00
|
|
|
}
|