mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
NEW Let shortcodes be disabled in HTMLText & HTMLVarchar
This commit is contained in:
parent
252e6bce28
commit
cd41a536b9
@ -11,7 +11,6 @@
|
||||
* @subpackage model
|
||||
*/
|
||||
class HTMLText extends Text {
|
||||
|
||||
public static $escape_type = 'xml';
|
||||
|
||||
static $casting = array(
|
||||
@ -33,6 +32,16 @@ class HTMLText extends Text {
|
||||
'NoHTML' => 'Text',
|
||||
);
|
||||
|
||||
protected $processShortcodes = true;
|
||||
|
||||
public function setOptions(array $options = array()) {
|
||||
parent::setOptions($options);
|
||||
|
||||
if(array_key_exists("shortcodes", $options)) {
|
||||
$this->processShortcodes = !!$options["shortcodes"];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a summary of the content. This will be some section of the first paragraph, limited by
|
||||
* $maxWords. All internal tags are stripped out - the return value is a string
|
||||
@ -133,7 +142,12 @@ class HTMLText extends Text {
|
||||
}
|
||||
|
||||
public function forTemplate() {
|
||||
return ShortcodeParser::get_active()->parse($this->value);
|
||||
if ($this->processShortcodes) {
|
||||
return ShortcodeParser::get_active()->parse($this->value);
|
||||
}
|
||||
else {
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,11 +9,26 @@
|
||||
class HTMLVarchar extends Varchar {
|
||||
|
||||
public static $escape_type = 'xml';
|
||||
|
||||
public function forTemplate() {
|
||||
return ShortcodeParser::get_active()->parse($this->value);
|
||||
|
||||
protected $processShortcodes = true;
|
||||
|
||||
public function setOptions(array $options = array()) {
|
||||
parent::setOptions($options);
|
||||
|
||||
if(array_key_exists("shortcodes", $options)) {
|
||||
$this->processShortcodes = !!$options["shortcodes"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function forTemplate() {
|
||||
if ($this->processShortcodes) {
|
||||
return ShortcodeParser::get_active()->parse($this->value);
|
||||
}
|
||||
else {
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
public function exists() {
|
||||
return parent::exists() && $this->value != '<p></p>';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user