Total Complexity | 8 |
Total Lines | 159 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
3 | class Nip_Form_Element_Texteditor extends Nip_Form_Element_Textarea |
||
|
|||
4 | { |
||
5 | protected $_type = 'texteditor'; |
||
6 | |||
7 | protected $inputFilter; |
||
8 | |||
9 | protected $allowedTags = [ |
||
10 | "a", |
||
11 | "b", |
||
12 | "blink", |
||
13 | "blockquote", |
||
14 | "br", |
||
15 | "caption", |
||
16 | "center", |
||
17 | "col", |
||
18 | "colgroup", |
||
19 | "comment", |
||
20 | "em", |
||
21 | "font", |
||
22 | "h1", |
||
23 | "h2", |
||
24 | "h3", |
||
25 | "h4", |
||
26 | "h5", |
||
27 | "h6", |
||
28 | "hr", |
||
29 | "img", |
||
30 | "li", |
||
31 | "marquee", |
||
32 | "ol", |
||
33 | "p", |
||
34 | "pre", |
||
35 | "s", |
||
36 | "small", |
||
37 | "span", |
||
38 | "strike", |
||
39 | "strong", |
||
40 | "sub", |
||
41 | "sup", |
||
42 | "table", |
||
43 | "tbody", |
||
44 | "td", |
||
45 | "tfoot", |
||
46 | "th", |
||
47 | "thead", |
||
48 | "tr", |
||
49 | "tt", |
||
50 | "u", |
||
51 | "ul" |
||
52 | ]; |
||
53 | |||
54 | protected $allowedAttributes = [ |
||
55 | "abbr", |
||
56 | "align", |
||
57 | "alt", |
||
58 | "axis", |
||
59 | "background", |
||
60 | "behavior", |
||
61 | "bgcolor", |
||
62 | "border", |
||
63 | "bordercolor", |
||
64 | "bordercolordark", |
||
65 | "bordercolorlight", |
||
66 | "bottompadding", |
||
67 | "cellpadding", |
||
68 | "cellspacing", |
||
69 | "char", |
||
70 | "charoff", |
||
71 | "cite", |
||
72 | "clear", |
||
73 | "color", |
||
74 | "cols", |
||
75 | "direction", |
||
76 | "face", |
||
77 | "font-weight", |
||
78 | "headers", |
||
79 | "height", |
||
80 | "href", |
||
81 | "hspace", |
||
82 | "leftpadding", |
||
83 | "loop", |
||
84 | "noshade", |
||
85 | "nowrap", |
||
86 | "point-size", |
||
87 | "rel", |
||
88 | "rev", |
||
89 | "rightpadding", |
||
90 | "rowspan", |
||
91 | "rules", |
||
92 | "scope", |
||
93 | "scrollamount", |
||
94 | "scrolldelay", |
||
95 | "size", |
||
96 | "span", |
||
97 | "src", |
||
98 | "start", |
||
99 | "style", |
||
100 | "summary", |
||
101 | "target", |
||
102 | "title", |
||
103 | "toppadding", |
||
104 | "type", |
||
105 | "valign", |
||
106 | "value", |
||
107 | "vspace", |
||
108 | "width", |
||
109 | "wrap" |
||
110 | ]; |
||
111 | |||
112 | |||
113 | /** |
||
114 | * @param $request |
||
115 | * @return $this |
||
116 | */ |
||
117 | public function getDataFromRequest($request) |
||
118 | { |
||
119 | $this->setValue($request); |
||
120 | $this->filterHTML(); |
||
121 | return $this; |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * @return $this |
||
126 | */ |
||
127 | protected function filterHTML() |
||
128 | { |
||
129 | $this->setValue($this->getInputFilter()->purify($this->getValue())); |
||
130 | return $this; |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * @return HTMLPurifier |
||
135 | */ |
||
136 | protected function getInputFilter() |
||
137 | { |
||
138 | if (!$this->inputFilter) { |
||
139 | $config = HTMLPurifier_Config::createDefault(); |
||
140 | $config->set('HTML.AllowedElements', $this->allowedTags); |
||
141 | $config->set('HTML.AllowedAttributes', $this->allowedAttributes); |
||
142 | $purifier = new HTMLPurifier($config); |
||
143 | $this->inputFilter = $purifier; |
||
144 | } |
||
145 | |||
146 | return $this->inputFilter; |
||
147 | } |
||
148 | |||
149 | public function addAllowedTags() |
||
154 | } |
||
155 | } |
||
156 | |||
157 | public function addAllowedAttributes() |
||
162 | } |
||
163 | } |
||
164 | } |
||
165 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.