ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
24 require_once "./classes/class.ilObject.php";
25 
35 {
36  var $setting;
37 
44  function ilObjAdvancedEditing($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  $this->ilObject($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  function initDefaultRoles()
99  {
100  global $rbacadmin;
101 
102  return $roles ? $roles : array();
103  }
104 
118  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
119  {
120  global $tree;
121 
122  switch ($a_event)
123  {
124  case "link":
125 
126  //var_dump("<pre>",$a_params,"</pre>");
127  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
128  //exit;
129  break;
130 
131  case "cut":
132 
133  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
134  //exit;
135  break;
136 
137  case "copy":
138 
139  //var_dump("<pre>",$a_params,"</pre>");
140  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
141  //exit;
142  break;
143 
144  case "paste":
145 
146  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
147  //exit;
148  break;
149 
150  case "new":
151 
152  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
153  //exit;
154  break;
155  }
156 
157  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
158  if ($a_node_id==$_GET["ref_id"])
159  {
160  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
161  $parent_type = $parent_obj->getType();
162  if($parent_type == $this->getType())
163  {
164  $a_node_id = (int) $tree->getParentId($a_node_id);
165  }
166  }
167 
168  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
169  }
170 
179  function &_getUsedHTMLTags($a_module = "")
180  {
181  $usedtags = array();
182  include_once "./Services/Administration/classes/class.ilSetting.php";
183  $setting = new ilSetting("advanced_editing");
184  $tags = $setting->get("advanced_editing_used_html_tags_" . $a_module);
185  if (strlen($tags))
186  {
187  $usedtags = unserialize($tags);
188  }
189  else
190  {
191  // default: everything but tables
192  $usedtags = array(
193  "a",
194  "blockquote",
195  "br",
196  "cite",
197  "code",
198  "dd",
199  "div",
200  "dl",
201  "dt",
202  "em",
203  "h1",
204  "h2",
205  "h3",
206  "h4",
207  "h5",
208  "h6",
209  "hr",
210  "img",
211  "li",
212  "ol",
213  "p",
214  "pre",
215  "span",
216  "strike",
217  "strong",
218  "sub",
219  "sup",
220  "u",
221  "ul"
222  );
223  }
224 
225  return $usedtags;
226  }
227 
236  function &_getUsedHTMLTagsAsString($a_module = "")
237  {
238  $result = "";
239  $tags =& ilObjAdvancedEditing::_getUsedHTMLTags($a_module);
240  foreach ($tags as $tag)
241  {
242  $result .= "<$tag>";
243  }
244  return $result;
245  }
246 
255  {
256  include_once "./Services/Administration/classes/class.ilSetting.php";
257  $setting = new ilSetting("advanced_editing");
258  $js = $setting->get("advanced_editing_javascript_editor");
259  return $js;
260  }
261 
269  function _setRichTextEditor($a_js_editor)
270  {
271  include_once "./Services/Administration/classes/class.ilSetting.php";
272  $setting = new ilSetting("advanced_editing");
273  $setting->set("advanced_editing_javascript_editor", $a_js_editor);
274  }
275 
286  function _setUsedHTMLTags($a_html_tags, $a_module)
287  {
288  global $lng;
289 
290  if (strlen($a_module))
291  {
292  $auto_added_tags = array();
293 
294  include_once "./Services/Administration/classes/class.ilSetting.php";
295  $setting = new ilSetting("advanced_editing");
296  $setting->set("advanced_editing_used_html_tags_" . $a_module, serialize(array_merge((array)$a_html_tags, $auto_added_tags)));
297 
298  if(count($auto_added_tags))
299  {
300  require_once 'Services/AdvancedEditing/exceptions/class.ilAdvancedEditingRequiredTagsException.php';
302  sprintf(
303  $lng->txt('advanced_editing_required_tags'),
304  implode(', ', $auto_added_tags)
305  )
306  );
307  }
308  }
309  }
310 
318  function &getHTMLTags()
319  {
320  $tags = array(
321  "a",
322  "blockquote",
323  "br",
324  "cite",
325  "code",
326  "dd",
327  "div",
328  "dl",
329  "dt",
330  "em",
331  "h1",
332  "h2",
333  "h3",
334  "h4",
335  "h5",
336  "h6",
337  "hr",
338  "img",
339  "li",
340  "object",
341  "ol",
342  "p",
343  "param",
344  "pre",
345  "span",
346  "strike",
347  "strong",
348  "sub",
349  "sup",
350  "table",
351  "td",
352  "tr",
353  "u",
354  "ul",
355  "ruby", // Ruby Annotation XHTML module
356  "rbc",
357  "rtc",
358  "rb",
359  "rt",
360  "rp"
361  );
362  return $tags;
363  }
364 
372  function &_getAllHTMLTags()
373  {
374  $tags = array(
375  "a",
376  "abbr",
377  "acronym",
378  "address",
379  "applet",
380  "area",
381  "b",
382  "base",
383  "basefont",
384  "bdo",
385  "big",
386  "blockquote",
387  "br",
388  "button",
389  "caption",
390  "center",
391  "cite",
392  "code",
393  "col",
394  "colgroup",
395  "dd",
396  "del",
397  "dfn",
398  "dir",
399  "div",
400  "dl",
401  "dt",
402  "em",
403  "fieldset",
404  "font",
405  "form",
406  "h1",
407  "h2",
408  "h3",
409  "h4",
410  "h5",
411  "h6",
412  "hr",
413  "i",
414  "iframe",
415  "img",
416  "input",
417  "ins",
418  "isindex",
419  "kbd",
420  "label",
421  "legend",
422  "li",
423  "link",
424  "map",
425  "menu",
426  "object",
427  "ol",
428  "optgroup",
429  "option",
430  "p",
431  "param",
432  "pre",
433  "q",
434  "s",
435  "samp",
436  "select",
437  "small",
438  "span",
439  "strike",
440  "strong",
441  "sub",
442  "sup",
443  "table",
444  "tbody",
445  "td",
446  "textarea",
447  "tfoot",
448  "th",
449  "thead",
450  "tr",
451  "tt",
452  "u",
453  "ul",
454  "var",
455  "ruby", // Ruby Annotation XHTML module
456  "rbc",
457  "rtc",
458  "rb",
459  "rt",
460  "rp"
461  );
462  return $tags;
463  }
472  {
473  $result = "";
475  foreach ($tags as $tag)
476  {
477  $result .= "<$tag>";
478  }
479  return $result;
480  }
481 
489  function _setRichTextEditorUserState($a_state)
490  {
491  global $ilUser;
492  $ilUser->writePref("show_rte", $a_state);
493  }
494 
503  {
504  global $ilUser;
505  if (strlen($ilUser->getPref("show_rte")) > 0)
506  {
507  return $ilUser->getPref("show_rte");
508  }
509  return 1;
510  }
511 
512 } // END class.ilObjAdvancedEditing
513 ?>