ILIAS  Release_3_10_x_branch Revision 61812
 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 
99  function initDefaultRoles()
100  {
101  global $rbacadmin;
102 
103  // create a local role folder
104  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
105 
106  // create moderator role and assign role to rolefolder...
107  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
108  //$roles[] = $roleObj->getId();
109 
110  //unset($rfoldObj);
111  //unset($roleObj);
112 
113  return $roles ? $roles : array();
114  }
115 
129  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
130  {
131  global $tree;
132 
133  switch ($a_event)
134  {
135  case "link":
136 
137  //var_dump("<pre>",$a_params,"</pre>");
138  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
139  //exit;
140  break;
141 
142  case "cut":
143 
144  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
145  //exit;
146  break;
147 
148  case "copy":
149 
150  //var_dump("<pre>",$a_params,"</pre>");
151  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
152  //exit;
153  break;
154 
155  case "paste":
156 
157  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
158  //exit;
159  break;
160 
161  case "new":
162 
163  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
164  //exit;
165  break;
166  }
167 
168  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
169  if ($a_node_id==$_GET["ref_id"])
170  {
171  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
172  $parent_type = $parent_obj->getType();
173  if($parent_type == $this->getType())
174  {
175  $a_node_id = (int) $tree->getParentId($a_node_id);
176  }
177  }
178 
179  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
180  }
181 
190  function &_getUsedHTMLTags($a_module = "")
191  {
192  $usedtags = array();
193  include_once "./Services/Administration/classes/class.ilSetting.php";
194  $setting = new ilSetting("advanced_editing");
195  $tags = $setting->get("advanced_editing_used_html_tags_" . $a_module);
196  if (strlen($tags))
197  {
198  $usedtags = unserialize($tags);
199  }
200  else
201  {
202  // default: everything but tables
203  $usedtags = array(
204  "a",
205  "blockquote",
206  "br",
207  "cite",
208  "code",
209  "dd",
210  "div",
211  "dl",
212  "dt",
213  "em",
214  "h1",
215  "h2",
216  "h3",
217  "h4",
218  "h5",
219  "h6",
220  "hr",
221  "img",
222  "li",
223  "ol",
224  "p",
225  "pre",
226  "span",
227  "strike",
228  "strong",
229  "sub",
230  "sup",
231  "u",
232  "ul"
233  );
234  }
235  return $usedtags;
236  }
237 
246  function &_getUsedHTMLTagsAsString($a_module = "")
247  {
248  $result = "";
249  $tags =& ilObjAdvancedEditing::_getUsedHTMLTags($a_module);
250  foreach ($tags as $tag)
251  {
252  $result .= "<$tag>";
253  }
254  return $result;
255  }
256 
265  {
266  include_once "./Services/Administration/classes/class.ilSetting.php";
267  $setting = new ilSetting("advanced_editing");
268  $js = $setting->get("advanced_editing_javascript_editor");
269  return $js;
270  }
271 
279  function _setRichTextEditor($a_js_editor)
280  {
281  include_once "./Services/Administration/classes/class.ilSetting.php";
282  $setting = new ilSetting("advanced_editing");
283  $setting->set("advanced_editing_javascript_editor", $a_js_editor);
284  }
285 
294  function _setUsedHTMLTags($a_html_tags, $a_module)
295  {
296  if (strlen($a_module))
297  {
298  include_once "./Services/Administration/classes/class.ilSetting.php";
299  $setting = new ilSetting("advanced_editing");
300  $setting->set("advanced_editing_used_html_tags_" . $a_module, serialize($a_html_tags));
301  }
302  }
303 
311  function &getHTMLTags()
312  {
313  $tags = array(
314  "a",
315  "blockquote",
316  "br",
317  "cite",
318  "code",
319  "dd",
320  "div",
321  "dl",
322  "dt",
323  "em",
324  "h1",
325  "h2",
326  "h3",
327  "h4",
328  "h5",
329  "h6",
330  "hr",
331  "img",
332  "li",
333  "object",
334  "ol",
335  "p",
336  "param",
337  "pre",
338  "span",
339  "strike",
340  "strong",
341  "sub",
342  "sup",
343  "table",
344  "td",
345  "tr",
346  "u",
347  "ul",
348  "ruby", // Ruby Annotation XHTML module
349  "rbc",
350  "rtc",
351  "rb",
352  "rt",
353  "rp"
354  );
355  return $tags;
356  }
357 
365  function &_getAllHTMLTags()
366  {
367  $tags = array(
368  "a",
369  "abbr",
370  "acronym",
371  "address",
372  "applet",
373  "area",
374  "b",
375  "base",
376  "basefont",
377  "bdo",
378  "big",
379  "blockquote",
380  "br",
381  "button",
382  "caption",
383  "center",
384  "cite",
385  "code",
386  "col",
387  "colgroup",
388  "dd",
389  "del",
390  "dfn",
391  "dir",
392  "div",
393  "dl",
394  "dt",
395  "em",
396  "fieldset",
397  "font",
398  "form",
399  "h1",
400  "h2",
401  "h3",
402  "h4",
403  "h5",
404  "h6",
405  "hr",
406  "i",
407  "iframe",
408  "img",
409  "input",
410  "ins",
411  "isindex",
412  "kbd",
413  "label",
414  "legend",
415  "li",
416  "link",
417  "map",
418  "menu",
419  "object",
420  "ol",
421  "optgroup",
422  "option",
423  "p",
424  "param",
425  "pre",
426  "q",
427  "s",
428  "samp",
429  "select",
430  "small",
431  "span",
432  "strike",
433  "strong",
434  "sub",
435  "sup",
436  "table",
437  "tbody",
438  "td",
439  "textarea",
440  "tfoot",
441  "th",
442  "thead",
443  "tr",
444  "tt",
445  "u",
446  "ul",
447  "var",
448  "ruby", // Ruby Annotation XHTML module
449  "rbc",
450  "rtc",
451  "rb",
452  "rt",
453  "rp"
454  );
455  return $tags;
456  }
465  {
466  $result = "";
468  foreach ($tags as $tag)
469  {
470  $result .= "<$tag>";
471  }
472  return $result;
473  }
474 
482  function _setRichTextEditorUserState($a_state)
483  {
484  global $ilUser;
485  $ilUser->writePref("show_rte", $a_state);
486  }
487 
496  {
497  global $ilUser;
498  if (strlen($ilUser->getPref("show_rte")) > 0)
499  {
500  return $ilUser->getPref("show_rte");
501  }
502  return 1;
503  }
504 
505 } // END class.ilObjAdvancedEditing
506 ?>