ILIAS  release_8 Revision v8.24
class.ilObjAdvancedEditing.php
Go to the documentation of this file.
1<?php
2
22{
24
25 public function __construct(
26 int $a_id = 0,
27 bool $a_call_by_reference = true
28 ) {
29 global $DIC;
30
31 $this->lng = $DIC->language();
32 $this->setting = new ilSetting("advanced_editing");
33 $this->type = "adve";
34 parent::__construct($a_id, $a_call_by_reference);
35 }
36
42 public static function _getUsedHTMLTags(string $a_module = ""): array
43 {
44 $setting = new ilSetting("advanced_editing");
45 $tags = $setting->get("advanced_editing_used_html_tags_" . $a_module, '');
46 if ($tags !== '') {
47 $usedtags = unserialize($tags, ["allowed_classes" => false]);
48 } elseif ($a_module === 'frm_post' || $a_module === 'exc_ass') {
49 $usedtags = array(
50 "a",
51 "blockquote",
52 "br",
53 "code",
54 "div",
55 "em",
56 "img",
57 "li",
58 "ol",
59 "p",
60 "strong",
61 "u",
62 "ul",
63 "span"
64 );
65 } else {
66 // default: everything but tables
67 $usedtags = array(
68 "a",
69 "blockquote",
70 "br",
71 "cite",
72 "code",
73 "dd",
74 "div",
75 "dl",
76 "dt",
77 "em",
78 "h1",
79 "h2",
80 "h3",
81 "h4",
82 "h5",
83 "h6",
84 "hr",
85 "img",
86 "li",
87 "ol",
88 "p",
89 "pre",
90 "span",
91 "strike",
92 "strong",
93 "sub",
94 "sup",
95 "u",
96 "ul"
97 );
98 }
99
100 // frm_posts need blockquote and div urgently
101 if ($a_module === 'frm_post') {
102 if (!in_array('div', $usedtags, true)) {
103 $usedtags[] = 'div';
104 }
105
106 if (!in_array('blockquote', $usedtags, true)) {
107 $usedtags[] = 'blockquote';
108 }
109 }
110
111 return $usedtags;
112 }
113
119 public static function _getUsedHTMLTagsAsString(string $a_module = ""): string
120 {
121 $result = "";
122 $tags = self::_getUsedHTMLTags($a_module);
123 foreach ($tags as $tag) {
124 $result .= "<$tag>";
125 }
126 return $result;
127 }
128
133 public static function _getRichTextEditor(): string
134 {
135 return (new ilSetting("advanced_editing"))->get("advanced_editing_javascript_editor", "0");
136 }
137
138 public function setRichTextEditor(string $a_js_editor): void
139 {
140 $setting = new ilSetting("advanced_editing");
141 $setting->set("advanced_editing_javascript_editor", $a_js_editor);
142 }
143
150 public function setUsedHTMLTags(
151 array $a_html_tags,
152 string $a_module
153 ): void {
154 $lng = $this->lng;
155
156 if ($a_module !== '') {
157 $auto_added_tags = array();
158
159 // frm_posts need blockquote and div urgently
160 if ($a_module === 'frm_post') {
161 if (!in_array('div', $a_html_tags, true)) {
162 $auto_added_tags[] = 'div';
163 }
164
165 if (!in_array('blockquote', $a_html_tags, true)) {
166 $auto_added_tags[] = 'blockquote';
167 }
168 }
169
170 $setting = new ilSetting("advanced_editing");
171 $setting->set("advanced_editing_used_html_tags_" . $a_module, serialize(array_merge($a_html_tags, $auto_added_tags)));
172
173 if (count($auto_added_tags)) {
175 sprintf(
176 $lng->txt('advanced_editing_required_tags'),
177 implode(', ', $auto_added_tags)
178 )
179 );
180 }
181 }
182 }
183
188 public function &getHTMLTags(): array
189 {
190 $tags = array(
191 "a",
192 "blockquote",
193 "br",
194 "cite",
195 "code",
196 "dd",
197 "div",
198 "dl",
199 "dt",
200 "em",
201 "h1",
202 "h2",
203 "h3",
204 "h4",
205 "h5",
206 "h6",
207 "hr",
208 "img",
209 "li",
210 "object",
211 "ol",
212 "p",
213 "param",
214 "pre",
215 "span",
216 "strike",
217 "strong",
218 "sub",
219 "sup",
220 "table",
221 "td",
222 "tr",
223 "u",
224 "ul",
225 "ruby", // Ruby Annotation XHTML module
226 "rbc",
227 "rtc",
228 "rb",
229 "rt",
230 "rp"
231 );
232 return $tags;
233 }
234
239 public static function _getAllHTMLTags(): array
240 {
241 return array(
242 "a",
243 "abbr",
244 "acronym",
245 "address",
246 "applet",
247 "area",
248 "b",
249 "base",
250 "basefont",
251 "bdo",
252 "big",
253 "blockquote",
254 "br",
255 "button",
256 "caption",
257 "center",
258 "cite",
259 "code",
260 "col",
261 "colgroup",
262 "dd",
263 "del",
264 "dfn",
265 "dir",
266 "div",
267 "dl",
268 "dt",
269 "em",
270 "fieldset",
271 "font",
272 "form",
273 "h1",
274 "h2",
275 "h3",
276 "h4",
277 "h5",
278 "h6",
279 "hr",
280 "i",
281 "iframe",
282 "img",
283 "input",
284 "ins",
285 "isindex",
286 "kbd",
287 "label",
288 "legend",
289 "li",
290 "link",
291 "map",
292 "menu",
293 "object",
294 "ol",
295 "optgroup",
296 "option",
297 "p",
298 "param",
299 "pre",
300 "q",
301 "s",
302 "samp",
303 "select",
304 "small",
305 "span",
306 "strike",
307 "strong",
308 "sub",
309 "sup",
310 "table",
311 "tbody",
312 "td",
313 "textarea",
314 "tfoot",
315 "th",
316 "thead",
317 "tr",
318 "tt",
319 "u",
320 "ul",
321 "var",
322 "ruby", // Ruby Annotation XHTML module
323 "rbc",
324 "rtc",
325 "rb",
326 "rt",
327 "rp"
328 );
329 }
330
334 public static function _setRichTextEditorUserState(int $a_state): void
335 {
336 global $DIC;
337
338 $ilUser = $DIC->user();
339 $ilUser->writePref("show_rte", (string) $a_state);
340 }
341
346 public static function _getRichTextEditorUserState(): int
347 {
348 global $DIC;
349
350 $ilUser = $DIC->user();
351 if ($ilUser->getPref("show_rte") != '') {
352 return (int) $ilUser->getPref("show_rte");
353 }
354 return 1;
355 }
356}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _setRichTextEditorUserState(int $a_state)
Sets the state of the rich text editor visibility for the current user.
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
__construct(int $a_id=0, bool $a_call_by_reference=true)
static _getAllHTMLTags()
Returns an array of all possible HTML tags for text editing.
static _getRichTextEditorUserState()
Gets the state of the rich text editor visibility for the current user.
setUsedHTMLTags(array $a_html_tags, string $a_module)
Writes an array with allowed HTML tags to the ILIAS settings.
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
setRichTextEditor(string $a_js_editor)
& getHTMLTags()
Returns an array of all possible HTML tags for text editing.
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
set(string $a_key, string $a_val)
get(string $a_keyword, ?string $a_default_value=null)
get setting
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc