ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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{
37
44 function __construct($a_id = 0,$a_call_by_reference = true)
45 {
46 include_once "./Services/Administration/classes/class.ilSetting.php";
47 $this->setting = new ilSetting("advanced_editing");
48 $this->type = "adve";
49 parent::__construct($a_id,$a_call_by_reference);
50 }
51
58 function update()
59 {
60 if (!parent::update())
61 {
62 return false;
63 }
64
65 // put here object specific stuff
66
67 return true;
68 }
69
70
77 function delete()
78 {
79 // always call parent delete function first!!
80 if (!parent::delete())
81 {
82 return false;
83 }
84
85 //put here your module specific stuff
86
87 return true;
88 }
89
98 public static function _getUsedHTMLTags($a_module = "")
99 {
100 $usedtags = array();
101 include_once "./Services/Administration/classes/class.ilSetting.php";
102 $setting = new ilSetting("advanced_editing");
103 $tags = $setting->get("advanced_editing_used_html_tags_" . $a_module);
104 if (strlen($tags))
105 {
106 $usedtags = unserialize($tags);
107 }
108 else
109 {
110 if($a_module == 'frm_post' || $a_module == 'exc_ass')
111 {
112 $usedtags = array(
113 "a",
114 "blockquote",
115 "br",
116 "code",
117 "div",
118 "em",
119 "img",
120 "li",
121 "ol",
122 "p",
123 "strong",
124 "u",
125 "ul",
126 "span"
127 );
128 }
129 else
130 {
131 // default: everything but tables
132 $usedtags = array(
133 "a",
134 "blockquote",
135 "br",
136 "cite",
137 "code",
138 "dd",
139 "div",
140 "dl",
141 "dt",
142 "em",
143 "h1",
144 "h2",
145 "h3",
146 "h4",
147 "h5",
148 "h6",
149 "hr",
150 "img",
151 "li",
152 "ol",
153 "p",
154 "pre",
155 "span",
156 "strike",
157 "strong",
158 "sub",
159 "sup",
160 "u",
161 "ul"
162 );
163 }
164 }
165
166 // frm_posts need blockquote and div urgently
167 if($a_module === 'frm_post')
168 {
169 if(!in_array('div', $usedtags))
170 {
171 $usedtags[] = 'div';
172 }
173
174 if(!in_array('blockquote', $usedtags))
175 {
176 $usedtags[] = 'blockquote';
177 }
178 }
179
180 return $usedtags;
181 }
182
191 public static function _getUsedHTMLTagsAsString($a_module = "")
192 {
193 $result = "";
195 foreach ($tags as $tag)
196 {
197 $result .= "<$tag>";
198 }
199 return $result;
200 }
201
209 static function _getRichTextEditor()
210 {
211 include_once "./Services/Administration/classes/class.ilSetting.php";
212 $setting = new ilSetting("advanced_editing");
213 $js = $setting->get("advanced_editing_javascript_editor");
214 return $js;
215 }
216
224 function setRichTextEditor($a_js_editor)
225 {
226 include_once "./Services/Administration/classes/class.ilSetting.php";
227 $setting = new ilSetting("advanced_editing");
228 $setting->set("advanced_editing_javascript_editor", $a_js_editor);
229 }
230
241 function setUsedHTMLTags($a_html_tags, $a_module)
242 {
243 global $lng;
244
245 if (strlen($a_module))
246 {
247 $auto_added_tags = array();
248
249 // frm_posts need blockquote and div urgently
250 if($a_module == 'frm_post')
251 {
252 if(!in_array('div', $a_html_tags))
253 {
254 $auto_added_tags[] = 'div';
255 }
256
257 if(!in_array('blockquote', $a_html_tags))
258 {
259 $auto_added_tags[] = 'blockquote';
260 }
261 }
262
263 include_once "./Services/Administration/classes/class.ilSetting.php";
264 $setting = new ilSetting("advanced_editing");
265 $setting->set("advanced_editing_used_html_tags_" . $a_module, serialize(array_merge((array)$a_html_tags, $auto_added_tags)));
266
267 if(count($auto_added_tags))
268 {
269 require_once 'Services/AdvancedEditing/exceptions/class.ilAdvancedEditingRequiredTagsException.php';
271 sprintf(
272 $lng->txt('advanced_editing_required_tags'),
273 implode(', ', $auto_added_tags)
274 )
275 );
276 }
277 }
278 }
279
287 function &getHTMLTags()
288 {
289 $tags = array(
290 "a",
291 "blockquote",
292 "br",
293 "cite",
294 "code",
295 "dd",
296 "div",
297 "dl",
298 "dt",
299 "em",
300 "h1",
301 "h2",
302 "h3",
303 "h4",
304 "h5",
305 "h6",
306 "hr",
307 "img",
308 "li",
309 "object",
310 "ol",
311 "p",
312 "param",
313 "pre",
314 "span",
315 "strike",
316 "strong",
317 "sub",
318 "sup",
319 "table",
320 "td",
321 "tr",
322 "u",
323 "ul",
324 "ruby", // Ruby Annotation XHTML module
325 "rbc",
326 "rtc",
327 "rb",
328 "rt",
329 "rp"
330 );
331 return $tags;
332 }
333
341 public static function _getAllHTMLTags()
342 {
343 $tags = array(
344 "a",
345 "abbr",
346 "acronym",
347 "address",
348 "applet",
349 "area",
350 "b",
351 "base",
352 "basefont",
353 "bdo",
354 "big",
355 "blockquote",
356 "br",
357 "button",
358 "caption",
359 "center",
360 "cite",
361 "code",
362 "col",
363 "colgroup",
364 "dd",
365 "del",
366 "dfn",
367 "dir",
368 "div",
369 "dl",
370 "dt",
371 "em",
372 "fieldset",
373 "font",
374 "form",
375 "h1",
376 "h2",
377 "h3",
378 "h4",
379 "h5",
380 "h6",
381 "hr",
382 "i",
383 "iframe",
384 "img",
385 "input",
386 "ins",
387 "isindex",
388 "kbd",
389 "label",
390 "legend",
391 "li",
392 "link",
393 "map",
394 "menu",
395 "object",
396 "ol",
397 "optgroup",
398 "option",
399 "p",
400 "param",
401 "pre",
402 "q",
403 "s",
404 "samp",
405 "select",
406 "small",
407 "span",
408 "strike",
409 "strong",
410 "sub",
411 "sup",
412 "table",
413 "tbody",
414 "td",
415 "textarea",
416 "tfoot",
417 "th",
418 "thead",
419 "tr",
420 "tt",
421 "u",
422 "ul",
423 "var",
424 "ruby", // Ruby Annotation XHTML module
425 "rbc",
426 "rtc",
427 "rb",
428 "rt",
429 "rp"
430 );
431 return $tags;
432 }
433
441 public static function _setRichTextEditorUserState($a_state)
442 {
443 global $ilUser;
444 $ilUser->writePref("show_rte", $a_state);
445 }
446
455 public static function _getRichTextEditorUserState()
456 {
457 global $ilUser;
458 if (strlen($ilUser->getPref("show_rte")) > 0)
459 {
460 return $ilUser->getPref("show_rte");
461 }
462 return 1;
463 }
464
465} // END class.ilObjAdvancedEditing
466?>
sprintf('%.4f', $callTime)
$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.
$js
$ilUser
Definition: imgupload.php:18