NEW Let shortcodes be disabled in HTMLText & HTMLVarchar

This commit is contained in:
Hamish Friedlander 2013-03-12 09:52:30 +13:00 committed by Sam Minnee
parent 252e6bce28
commit cd41a536b9
2 changed files with 35 additions and 6 deletions

View File

@ -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;
}
}
/**

View File

@ -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>';
}