ILIAS  Release_4_0_x_branch Revision 61816
 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  if($a_module == 'frm_post')
203  {
204  $usedtags = array(
205  "a",
206  "blockquote",
207  "br",
208  "code",
209  "div",
210  "em",
211  "img",
212  "li",
213  "ol",
214  "p",
215  "strong",
216  "u",
217  "ul",
218  "span"
219  );
220  }
221  else
222  {
223  // default: everything but tables
224  $usedtags = array(
225  "a",
226  "blockquote",
227  "br",
228  "cite",
229  "code",
230  "dd",
231  "div",
232  "dl",
233  "dt",
234  "em",
235  "h1",
236  "h2",
237  "h3",
238  "h4",
239  "h5",
240  "h6",
241  "hr",
242  "img",
243  "li",
244  "ol",
245  "p",
246  "pre",
247  "span",
248  "strike",
249  "strong",
250  "sub",
251  "sup",
252  "u",
253  "ul"
254  );
255  }
256  }
257 
258  // frm_posts need blockquote and div urgently
259  if($a_module === 'frm_post')
260  {
261  if(!in_array('div', $usedtags))
262  {
263  $usedtags[] = 'div';
264  }
265 
266  if(!in_array('blockquote', $usedtags))
267  {
268  $usedtags[] = 'blockquote';
269  }
270  }
271 
272  return $usedtags;
273  }
274 
283  function &_getUsedHTMLTagsAsString($a_module = "")
284  {
285  $result = "";
286  $tags =& ilObjAdvancedEditing::_getUsedHTMLTags($a_module);
287  foreach ($tags as $tag)
288  {
289  $result .= "<$tag>";
290  }
291  return $result;
292  }
293 
302  {
303  include_once "./Services/Administration/classes/class.ilSetting.php";
304  $setting = new ilSetting("advanced_editing");
305  $js = $setting->get("advanced_editing_javascript_editor");
306  return $js;
307  }
308 
316  function _setRichTextEditor($a_js_editor)
317  {
318  include_once "./Services/Administration/classes/class.ilSetting.php";
319  $setting = new ilSetting("advanced_editing");
320  $setting->set("advanced_editing_javascript_editor", $a_js_editor);
321  }
322 
333  function _setUsedHTMLTags($a_html_tags, $a_module)
334  {
335  global $lng;
336 
337  if (strlen($a_module))
338  {
339  $auto_added_tags = array();
340 
341  // frm_posts need blockquote and div urgently
342  if($a_module == 'frm_post')
343  {
344  if(!in_array('div', $a_html_tags))
345  {
346  $auto_added_tags[] = 'div';
347  }
348 
349  if(!in_array('blockquote', $a_html_tags))
350  {
351  $auto_added_tags[] = 'blockquote';
352  }
353  }
354 
355  include_once "./Services/Administration/classes/class.ilSetting.php";
356  $setting = new ilSetting("advanced_editing");
357  $setting->set("advanced_editing_used_html_tags_" . $a_module, serialize(array_merge((array)$a_html_tags, $auto_added_tags)));
358 
359  if(count($auto_added_tags))
360  {
361  require_once 'Services/AdvancedEditing/exceptions/class.ilAdvancedEditingRequiredTagsException.php';
363  sprintf(
364  $lng->txt('advanced_editing_required_tags'),
365  implode(', ', $auto_added_tags)
366  )
367  );
368  }
369  }
370  }
371 
379  function &getHTMLTags()
380  {
381  $tags = array(
382  "a",
383  "blockquote",
384  "br",
385  "cite",
386  "code",
387  "dd",
388  "div",
389  "dl",
390  "dt",
391  "em",
392  "h1",
393  "h2",
394  "h3",
395  "h4",
396  "h5",
397  "h6",
398  "hr",
399  "img",
400  "li",
401  "object",
402  "ol",
403  "p",
404  "param",
405  "pre",
406  "span",
407  "strike",
408  "strong",
409  "sub",
410  "sup",
411  "table",
412  "td",
413  "tr",
414  "u",
415  "ul",
416  "ruby", // Ruby Annotation XHTML module
417  "rbc",
418  "rtc",
419  "rb",
420  "rt",
421  "rp"
422  );
423  return $tags;
424  }
425 
433  function &_getAllHTMLTags()
434  {
435  $tags = array(
436  "a",
437  "abbr",
438  "acronym",
439  "address",
440  "applet",
441  "area",
442  "b",
443  "base",
444  "basefont",
445  "bdo",
446  "big",
447  "blockquote",
448  "br",
449  "button",
450  "caption",
451  "center",
452  "cite",
453  "code",
454  "col",
455  "colgroup",
456  "dd",
457  "del",
458  "dfn",
459  "dir",
460  "div",
461  "dl",
462  "dt",
463  "em",
464  "fieldset",
465  "font",
466  "form",
467  "h1",
468  "h2",
469  "h3",
470  "h4",
471  "h5",
472  "h6",
473  "hr",
474  "i",
475  "iframe",
476  "img",
477  "input",
478  "ins",
479  "isindex",
480  "kbd",
481  "label",
482  "legend",
483  "li",
484  "link",
485  "map",
486  "menu",
487  "object",
488  "ol",
489  "optgroup",
490  "option",
491  "p",
492  "param",
493  "pre",
494  "q",
495  "s",
496  "samp",
497  "select",
498  "small",
499  "span",
500  "strike",
501  "strong",
502  "sub",
503  "sup",
504  "table",
505  "tbody",
506  "td",
507  "textarea",
508  "tfoot",
509  "th",
510  "thead",
511  "tr",
512  "tt",
513  "u",
514  "ul",
515  "var",
516  "ruby", // Ruby Annotation XHTML module
517  "rbc",
518  "rtc",
519  "rb",
520  "rt",
521  "rp"
522  );
523  return $tags;
524  }
533  {
534  $result = "";
536  foreach ($tags as $tag)
537  {
538  $result .= "<$tag>";
539  }
540  return $result;
541  }
542 
550  function _setRichTextEditorUserState($a_state)
551  {
552  global $ilUser;
553  $ilUser->writePref("show_rte", $a_state);
554  }
555 
564  {
565  global $ilUser;
566  if (strlen($ilUser->getPref("show_rte")) > 0)
567  {
568  return $ilUser->getPref("show_rte");
569  }
570  return 1;
571  }
572 
573 } // END class.ilObjAdvancedEditing
574 ?>