Permalink
Browse files

NEW Let shortcodes be disabled in HTMLText & HTMLVarchar

  • Loading branch information...
1 parent 252e6bc commit cd41a536b9e0e8f67209e27606bd7749ff794d51 Hamish Friedlander committed with sminnee Mar 11, 2013
Showing with 34 additions and 5 deletions.
  1. +16 −2 model/fieldtypes/HTMLText.php
  2. +18 −3 model/fieldtypes/HTMLVarchar.php
@@ -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 @@ public function FirstSentence() {
}
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';
-
+
+ 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() {
- return ShortcodeParser::get_active()->parse($this->value);
+ if ($this->processShortcodes) {
+ return ShortcodeParser::get_active()->parse($this->value);
+ }
+ else {
+ return $this->value;
+ }
}
-
+
public function exists() {
return parent::exists() && $this->value != '<p></p>';
}

0 comments on commit cd41a53

Please sign in to comment.