|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @link http://www.newicon.net/neon |
|
4
|
|
|
* @copyright Copyright (c) 2016 Newicon Ltd |
|
5
|
|
|
* @license http://www.newicon.net/neon/license |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace neon\core\form\fields; |
|
9
|
|
|
|
|
10
|
|
|
use neon\core\grid\query\IQuery; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class Text |
|
14
|
|
|
* @package neon\core\form |
|
15
|
|
|
*/ |
|
16
|
|
|
class HtmlRaw extends TextArea |
|
17
|
|
|
{ |
|
18
|
|
|
const TEXT_TRUNCATE_LENGTH=250; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Set some allowable tags for single text fields |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $allowableTags = "<br><em><i><u><b><s><mark><strong>"; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* The DDS data type to store the value of the field |
|
28
|
|
|
* text data type can be up to 20000 characters long |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
public $ddsDataType = 'text'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @inheritdoc |
|
35
|
|
|
*/ |
|
36
|
|
|
public function getValueDisplay($context='') |
|
37
|
|
|
{ |
|
38
|
|
|
$text = parent::getValueDisplay(); |
|
39
|
|
|
if (strlen($text) > self::TEXT_TRUNCATE_LENGTH) |
|
40
|
|
|
return substr($text, 0, self::TEXT_TRUNCATE_LENGTH).'...'; |
|
41
|
|
|
return $text; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @inheritdoc |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getFilterField() |
|
48
|
|
|
{ |
|
49
|
|
|
return [ |
|
50
|
|
|
'class' => 'text' |
|
51
|
|
|
]; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @inheritdoc |
|
56
|
|
|
*/ |
|
57
|
|
|
public function processAsFilter(IQuery $query, $searchData=null) |
|
58
|
|
|
{ |
|
59
|
|
|
$searchData = ($searchData === null) ? $this->getValue() : $searchData; |
|
60
|
|
|
if ($searchData !== '') { |
|
61
|
|
|
$query->where($this->getDataKey(), 'like', $searchData); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @inheritdoc |
|
67
|
|
|
*/ |
|
68
|
|
|
public function fake() |
|
69
|
|
|
{ |
|
70
|
|
|
return faker()->realText(mt_rand(10, 20000)); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @inheritdoc |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getComponentDetails() |
|
77
|
|
|
{ |
|
78
|
|
|
return [ |
|
79
|
|
|
'icon' => 'fa fa-paragraph', |
|
80
|
|
|
'group' => 'Formatted Text', |
|
81
|
|
|
'order' => 210, |
|
82
|
|
|
'label' => 'Raw Html', |
|
83
|
|
|
]; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
} |