2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
2008-02-25 03:10:37 +01:00
|
|
|
/**
|
|
|
|
* Represents a short text field that is intended to contain HTML content.
|
|
|
|
*
|
|
|
|
* This behaves similarly to Varchar, but the template processor won't escape any HTML content within it.
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2008-02-25 03:10:37 +01:00
|
|
|
* @subpackage model
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
class HTMLVarchar extends Varchar {
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2013-03-21 19:48:54 +01:00
|
|
|
private static $escape_type = 'xml';
|
2013-03-11 21:52:30 +01:00
|
|
|
|
|
|
|
protected $processShortcodes = true;
|
|
|
|
|
|
|
|
public function setOptions(array $options = array()) {
|
|
|
|
parent::setOptions($options);
|
|
|
|
|
|
|
|
if(array_key_exists("shortcodes", $options)) {
|
|
|
|
$this->processShortcodes = !!$options["shortcodes"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-11 02:06:58 +02:00
|
|
|
public function forTemplate() {
|
2016-06-30 16:46:23 +02:00
|
|
|
return $this->RAW();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function RAW() {
|
2013-03-11 21:52:30 +01:00
|
|
|
if ($this->processShortcodes) {
|
|
|
|
return ShortcodeParser::get_active()->parse($this->value);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return $this->value;
|
|
|
|
}
|
2016-06-30 16:54:44 +02:00
|
|
|
|
2009-10-11 02:06:58 +02:00
|
|
|
}
|
2013-03-11 21:52:30 +01:00
|
|
|
|
2012-04-11 04:48:06 +02:00
|
|
|
public function exists() {
|
2016-06-30 16:54:44 +02:00
|
|
|
return parent::exists() && $this->RAW() != '<p></p>';
|
2009-10-11 02:06:58 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2008-10-14 00:20:41 +02:00
|
|
|
public function scaffoldFormField($title = null, $params = null) {
|
2008-10-19 02:18:55 +02:00
|
|
|
return new HtmlEditorField($this->name, $title, 1);
|
2008-08-06 04:43:46 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2008-08-06 04:43:46 +02:00
|
|
|
public function scaffoldSearchField($title = null) {
|
|
|
|
return new TextField($this->name, $title);
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|