ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjAdvancedEditing.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24require_once "./Services/Object/classes/class.ilObject.php";
25
35{
36 public $setting;
37
44 public function __construct($a_id = 0, $a_call_by_reference = true)
45 {
46 global $DIC;
47
48 $this->lng = $DIC->language();
49 include_once "./Services/Administration/classes/class.ilSetting.php";
50 $this->setting = new ilSetting("advanced_editing");
51 $this->type = "adve";
52 parent::__construct($a_id, $a_call_by_reference);
53 }
54
61 public function update()
62 {
63 if (!parent::update()) {
64 return false;
65 }
66
67 // put here object specific stuff
68
69 return true;
70 }
71
72
79 public function delete()
80 {
81 // always call parent delete function first!!
82 if (!parent::delete()) {
83 return false;
84 }
85
86 //put here your module specific stuff
87
88 return true;
89 }
90
99 public static function _getUsedHTMLTags($a_module = "")
100 {
101 $usedtags = array();
102 include_once "./Services/Administration/classes/class.ilSetting.php";
103 $setting = new ilSetting("advanced_editing");
104 $tags = $setting->get("advanced_editing_used_html_tags_" . $a_module);
105 if (strlen($tags)) {
106 $usedtags = unserialize($tags);
107 } else {
108 if ($a_module == 'frm_post' || $a_module == 'exc_ass') {
109 $usedtags = array(
110 "a",
111 "blockquote",
112 "br",
113 "code",
114 "div",
115 "em",
116 "img",
117 "li",
118 "ol",
119 "p",
120 "strong",
121 "u",
122 "ul",
123 "span"
124 );
125 } else {
126 // default: everything but tables
127 $usedtags = array(
128 "a",
129 "blockquote",
130 "br",
131 "cite",
132 "code",
133 "dd",
134 "div",
135 "dl",
136 "dt",
137 "em",
138 "h1",
139 "h2",
140 "h3",
141 "h4",
142 "h5",
143 "h6",
144 "hr",
145 "img",
146 "li",
147 "ol",
148 "p",
149 "pre",
150 "span",
151 "strike",
152 "strong",
153 "sub",
154 "sup",
155 "u",
156 "ul"
157 );
158 }
159 }
160
161 // frm_posts need blockquote and div urgently
162 if ($a_module === 'frm_post') {
163 if (!in_array('div', $usedtags)) {
164 $usedtags[] = 'div';
165 }
166
167 if (!in_array('blockquote', $usedtags)) {
168 $usedtags[] = 'blockquote';
169 }
170 }
171
172 return $usedtags;
173 }
174
183 public static function _getUsedHTMLTagsAsString($a_module = "")
184 {
185 $result = "";
187 foreach ($tags as $tag) {
188 $result .= "<$tag>";
189 }
190 return $result;
191 }
192
200 public static function _getRichTextEditor()
201 {
202 include_once "./Services/Administration/classes/class.ilSetting.php";
203 $setting = new ilSetting("advanced_editing");
204 $js = $setting->get("advanced_editing_javascript_editor");
205 return $js;
206 }
207
215 public function setRichTextEditor($a_js_editor)
216 {
217 include_once "./Services/Administration/classes/class.ilSetting.php";
218 $setting = new ilSetting("advanced_editing");
219 $setting->set("advanced_editing_javascript_editor", $a_js_editor);
220 }
221
232 public function setUsedHTMLTags($a_html_tags, $a_module)
233 {
235
236 if (strlen($a_module)) {
237 $auto_added_tags = array();
238
239 // frm_posts need blockquote and div urgently
240 if ($a_module == 'frm_post') {
241 if (!in_array('div', $a_html_tags)) {
242 $auto_added_tags[] = 'div';
243 }
244
245 if (!in_array('blockquote', $a_html_tags)) {
246 $auto_added_tags[] = 'blockquote';
247 }
248 }
249
250 include_once "./Services/Administration/classes/class.ilSetting.php";
251 $setting = new ilSetting("advanced_editing");
252 $setting->set("advanced_editing_used_html_tags_" . $a_module, serialize(array_merge((array) $a_html_tags, $auto_added_tags)));
253
254 if (count($auto_added_tags)) {
255 require_once 'Services/AdvancedEditing/exceptions/class.ilAdvancedEditingRequiredTagsException.php';
257 sprintf(
258 $lng->txt('advanced_editing_required_tags'),
259 implode(', ', $auto_added_tags)
260 )
261 );
262 }
263 }
264 }
265
273 public function &getHTMLTags()
274 {
275 $tags = array(
276 "a",
277 "blockquote",
278 "br",
279 "cite",
280 "code",
281 "dd",
282 "div",
283 "dl",
284 "dt",
285 "em",
286 "h1",
287 "h2",
288 "h3",
289 "h4",
290 "h5",
291 "h6",
292 "hr",
293 "img",
294 "li",
295 "object",
296 "ol",
297 "p",
298 "param",
299 "pre",
300 "span",
301 "strike",
302 "strong",
303 "sub",
304 "sup",
305 "table",
306 "td",
307 "tr",
308 "u",
309 "ul",
310 "ruby", // Ruby Annotation XHTML module
311 "rbc",
312 "rtc",
313 "rb",
314 "rt",
315 "rp"
316 );
317 return $tags;
318 }
319
327 public static function _getAllHTMLTags()
328 {
329 $tags = array(
330 "a",
331 "abbr",
332 "acronym",
333 "address",
334 "applet",
335 "area",
336 "b",
337 "base",
338 "basefont",
339 "bdo",
340 "big",
341 "blockquote",
342 "br",
343 "button",
344 "caption",
345 "center",
346 "cite",
347 "code",
348 "col",
349 "colgroup",
350 "dd",
351 "del",
352 "dfn",
353 "dir",
354 "div",
355 "dl",
356 "dt",
357 "em",
358 "fieldset",
359 "font",
360 "form",
361 "h1",
362 "h2",
363 "h3",
364 "h4",
365 "h5",
366 "h6",
367 "hr",
368 "i",
369 "iframe",
370 "img",
371 "input",
372 "ins",
373 "isindex",
374 "kbd",
375 "label",
376 "legend",
377 "li",
378 "link",
379 "map",
380 "menu",
381 "object",
382 "ol",
383 "optgroup",
384 "option",
385 "p",
386 "param",
387 "pre",
388 "q",
389 "s",
390 "samp",
391 "select",
392 "small",
393 "span",
394 "strike",
395 "strong",
396 "sub",
397 "sup",
398 "table",
399 "tbody",
400 "td",
401 "textarea",
402 "tfoot",
403 "th",
404 "thead",
405 "tr",
406 "tt",
407 "u",
408 "ul",
409 "var",
410 "ruby", // Ruby Annotation XHTML module
411 "rbc",
412 "rtc",
413 "rb",
414 "rt",
415 "rp"
416 );
417 return $tags;
418 }
419
427 public static function _setRichTextEditorUserState($a_state)
428 {
429 global $DIC;
430
431 $ilUser = $DIC->user();
432 $ilUser->writePref("show_rte", $a_state);
433 }
434
443 public static function _getRichTextEditorUserState()
444 {
445 global $DIC;
446
447 $ilUser = $DIC->user();
448 if (strlen($ilUser->getPref("show_rte")) > 0) {
449 return $ilUser->getPref("show_rte");
450 }
451 return 1;
452 }
453} // END class.ilObjAdvancedEditing
$result
An exception for terminatinating execution or to throw for unit testing.
Class for advanced editing exception handling in ILIAS.
Class ilObjAdvancedEditing.
static _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
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.
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
setRichTextEditor($a_js_editor)
Sets wheather a Rich Text Editor should be used or not.
static _setRichTextEditorUserState($a_state)
Sets the state of the rich text editor visibility for the current user.
setUsedHTMLTags($a_html_tags, $a_module)
Writes an array with allowed HTML tags to the ILIAS settings.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
& getHTMLTags()
Returns an array of all possible HTML tags for text editing.
Class ilObject Basic functions for all objects.
ILIAS Setting Class.
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc