ILIAS  Release_5_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 "./Services/Object/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 
90 
104  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
105  {
106  global $tree;
107 
108  switch ($a_event)
109  {
110  case "link":
111 
112  //var_dump("<pre>",$a_params,"</pre>");
113  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
114  //exit;
115  break;
116 
117  case "cut":
118 
119  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
120  //exit;
121  break;
122 
123  case "copy":
124 
125  //var_dump("<pre>",$a_params,"</pre>");
126  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
127  //exit;
128  break;
129 
130  case "paste":
131 
132  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
133  //exit;
134  break;
135 
136  case "new":
137 
138  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
139  //exit;
140  break;
141  }
142 
143  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
144  if ($a_node_id==$_GET["ref_id"])
145  {
146  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
147  $parent_type = $parent_obj->getType();
148  if($parent_type == $this->getType())
149  {
150  $a_node_id = (int) $tree->getParentId($a_node_id);
151  }
152  }
153 
154  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
155  }
156 
165  function &_getUsedHTMLTags($a_module = "")
166  {
167  $usedtags = array();
168  include_once "./Services/Administration/classes/class.ilSetting.php";
169  $setting = new ilSetting("advanced_editing");
170  $tags = $setting->get("advanced_editing_used_html_tags_" . $a_module);
171  if (strlen($tags))
172  {
173  $usedtags = unserialize($tags);
174  }
175  else
176  {
177  if($a_module == 'frm_post' || $a_module == 'exc_ass')
178  {
179  $usedtags = array(
180  "a",
181  "blockquote",
182  "br",
183  "code",
184  "div",
185  "em",
186  "img",
187  "li",
188  "ol",
189  "p",
190  "strong",
191  "u",
192  "ul",
193  "span"
194  );
195  }
196  else
197  {
198  // default: everything but tables
199  $usedtags = array(
200  "a",
201  "blockquote",
202  "br",
203  "cite",
204  "code",
205  "dd",
206  "div",
207  "dl",
208  "dt",
209  "em",
210  "h1",
211  "h2",
212  "h3",
213  "h4",
214  "h5",
215  "h6",
216  "hr",
217  "img",
218  "li",
219  "ol",
220  "p",
221  "pre",
222  "span",
223  "strike",
224  "strong",
225  "sub",
226  "sup",
227  "u",
228  "ul"
229  );
230  }
231  }
232 
233  // frm_posts need blockquote and div urgently
234  if($a_module === 'frm_post')
235  {
236  if(!in_array('div', $usedtags))
237  {
238  $usedtags[] = 'div';
239  }
240 
241  if(!in_array('blockquote', $usedtags))
242  {
243  $usedtags[] = 'blockquote';
244  }
245  }
246 
247  return $usedtags;
248  }
249 
258  function &_getUsedHTMLTagsAsString($a_module = "")
259  {
260  $result = "";
261  $tags =& ilObjAdvancedEditing::_getUsedHTMLTags($a_module);
262  foreach ($tags as $tag)
263  {
264  $result .= "<$tag>";
265  }
266  return $result;
267  }
268 
277  {
278  include_once "./Services/Administration/classes/class.ilSetting.php";
279  $setting = new ilSetting("advanced_editing");
280  $js = $setting->get("advanced_editing_javascript_editor");
281  return $js;
282  }
283 
291  function _setRichTextEditor($a_js_editor)
292  {
293  include_once "./Services/Administration/classes/class.ilSetting.php";
294  $setting = new ilSetting("advanced_editing");
295  $setting->set("advanced_editing_javascript_editor", $a_js_editor);
296  }
297 
308  function _setUsedHTMLTags($a_html_tags, $a_module)
309  {
310  global $lng;
311 
312  if (strlen($a_module))
313  {
314  $auto_added_tags = array();
315 
316  // frm_posts need blockquote and div urgently
317  if($a_module == 'frm_post')
318  {
319  if(!in_array('div', $a_html_tags))
320  {
321  $auto_added_tags[] = 'div';
322  }
323 
324  if(!in_array('blockquote', $a_html_tags))
325  {
326  $auto_added_tags[] = 'blockquote';
327  }
328  }
329 
330  include_once "./Services/Administration/classes/class.ilSetting.php";
331  $setting = new ilSetting("advanced_editing");
332  $setting->set("advanced_editing_used_html_tags_" . $a_module, serialize(array_merge((array)$a_html_tags, $auto_added_tags)));
333 
334  if(count($auto_added_tags))
335  {
336  require_once 'Services/AdvancedEditing/exceptions/class.ilAdvancedEditingRequiredTagsException.php';
338  sprintf(
339  $lng->txt('advanced_editing_required_tags'),
340  implode(', ', $auto_added_tags)
341  )
342  );
343  }
344  }
345  }
346 
354  function &getHTMLTags()
355  {
356  $tags = array(
357  "a",
358  "blockquote",
359  "br",
360  "cite",
361  "code",
362  "dd",
363  "div",
364  "dl",
365  "dt",
366  "em",
367  "h1",
368  "h2",
369  "h3",
370  "h4",
371  "h5",
372  "h6",
373  "hr",
374  "img",
375  "li",
376  "object",
377  "ol",
378  "p",
379  "param",
380  "pre",
381  "span",
382  "strike",
383  "strong",
384  "sub",
385  "sup",
386  "table",
387  "td",
388  "tr",
389  "u",
390  "ul",
391  "ruby", // Ruby Annotation XHTML module
392  "rbc",
393  "rtc",
394  "rb",
395  "rt",
396  "rp"
397  );
398  return $tags;
399  }
400 
408  function &_getAllHTMLTags()
409  {
410  $tags = array(
411  "a",
412  "abbr",
413  "acronym",
414  "address",
415  "applet",
416  "area",
417  "b",
418  "base",
419  "basefont",
420  "bdo",
421  "big",
422  "blockquote",
423  "br",
424  "button",
425  "caption",
426  "center",
427  "cite",
428  "code",
429  "col",
430  "colgroup",
431  "dd",
432  "del",
433  "dfn",
434  "dir",
435  "div",
436  "dl",
437  "dt",
438  "em",
439  "fieldset",
440  "font",
441  "form",
442  "h1",
443  "h2",
444  "h3",
445  "h4",
446  "h5",
447  "h6",
448  "hr",
449  "i",
450  "iframe",
451  "img",
452  "input",
453  "ins",
454  "isindex",
455  "kbd",
456  "label",
457  "legend",
458  "li",
459  "link",
460  "map",
461  "menu",
462  "object",
463  "ol",
464  "optgroup",
465  "option",
466  "p",
467  "param",
468  "pre",
469  "q",
470  "s",
471  "samp",
472  "select",
473  "small",
474  "span",
475  "strike",
476  "strong",
477  "sub",
478  "sup",
479  "table",
480  "tbody",
481  "td",
482  "textarea",
483  "tfoot",
484  "th",
485  "thead",
486  "tr",
487  "tt",
488  "u",
489  "ul",
490  "var",
491  "ruby", // Ruby Annotation XHTML module
492  "rbc",
493  "rtc",
494  "rb",
495  "rt",
496  "rp"
497  );
498  return $tags;
499  }
508  {
509  $result = "";
511  foreach ($tags as $tag)
512  {
513  $result .= "<$tag>";
514  }
515  return $result;
516  }
517 
525  public static function _setRichTextEditorUserState($a_state)
526  {
527  global $ilUser;
528  $ilUser->writePref("show_rte", $a_state);
529  }
530 
539  public static function _getRichTextEditorUserState()
540  {
541  global $ilUser;
542  if (strlen($ilUser->getPref("show_rte")) > 0)
543  {
544  return $ilUser->getPref("show_rte");
545  }
546  return 1;
547  }
548 
549 } // END class.ilObjAdvancedEditing
550 ?>