ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjAdvancedEditingGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 
35 include_once "./classes/class.ilObjectGUI.php";
36 
38 {
44 
45  function ilObjAdvancedEditingGUI($a_data,$a_id,$a_call_by_reference)
46  {
47  global $rbacsystem;
48 
49  $this->type = "adve";
50  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
51  $this->lng->loadLanguageModule('meta');
52 
53  if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
54  {
55  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read_adve"),$this->ilias->error_obj->WARNING);
56  }
57  }
58 
59  function &executeCommand()
60  {
61  $next_class = $this->ctrl->getNextClass($this);
62  $cmd = $this->ctrl->getCmd();
63  $this->prepareOutput();
64 
65  switch($next_class)
66  {
67 
68  case 'ilpermissiongui':
69  include_once("./classes/class.ilPermissionGUI.php");
70  $perm_gui =& new ilPermissionGUI($this);
71  $ret =& $this->ctrl->forwardCommand($perm_gui);
72  break;
73 
74  default:
75  if($cmd == "" || $cmd == "view")
76  {
77  $cmd = "settings";
78  }
79  $cmd .= "Object";
80  $this->$cmd();
81 
82  break;
83  }
84  return true;
85  }
86 
87 
92  function saveObject()
93  {
94  global $rbacadmin;
95 
96  // create and insert forum in objecttree
97  $newObj = parent::saveObject();
98 
99  // setup rolefolder & default local roles
100  //$roles = $newObj->initDefaultRoles();
101 
102  // put here object specific stuff
103 
104  // always send a message
105  ilUtil::sendInfo($this->lng->txt("object_added"),true);
106 
107  $this->ctrl->redirect($this);
108  //header("Location:".$this->getReturnLocation("save","adm_object.php?".$this->link_params));
109  //exit();
110  }
111 
112 
116  function settingsObject()
117  {
118  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing.html");
119 
120  $this->tpl->setCurrentBlock("adm_content");
121  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
122  $this->tpl->setVariable("TXT_ADVANCED_EDITING_SETTINGS", $this->lng->txt("advanced_editing_settings"));
123  $this->tpl->setVariable("TXT_ALLOW_JAVASCRIPT_EDITOR", $this->lng->txt("advanced_editing_allow_javascript_editor"));
124  $this->tpl->setVariable("NO_RTE_EDITOR", $this->lng->txt("advanced_editing_no_rte"));
125  $this->tpl->setVariable("TINY_MCE_EDITOR", $this->lng->txt("advanced_editing_tinymce"));
126  $editor = $this->object->_getRichTextEditor();
127  switch ($editor)
128  {
129  case "tinymce":
130  $this->tpl->setVariable("SELECTED_TINY_MCE_EDITOR", " selected=\"selected\"");
131  break;
132  }
133 
134  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
135 
136  $this->tpl->parseCurrentBlock();
137  }
138 
142  function assessmentObject()
143  {
144  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_assessment.html");
145 
146  $alltags =& $this->object->getHTMLTags();
147  $usedtags =& $this->object->_getUsedHTMLTags("assessment");
148  foreach ($alltags as $tag)
149  {
150  $this->tpl->setCurrentBlock("html_tag_row");
151  $this->tpl->setVariable("HTML_TAG", $tag);
152  if (is_array($usedtags))
153  {
154  if (in_array($tag, $usedtags))
155  {
156  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
157  }
158  }
159  $this->tpl->parseCurrentBlock();
160  }
161 
162  $this->tpl->setCurrentBlock("adm_content");
163  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
164  $this->tpl->setVariable("TXT_ASSESSMENT_SETTINGS", $this->lng->txt("advanced_editing_assessment_settings"));
165  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
166  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
167 
168  $this->tpl->parseCurrentBlock();
169  }
170 
171 
175  function surveyObject()
176  {
177  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_survey.html");
178 
179  $alltags =& $this->object->getHTMLTags();
180  $usedtags =& $this->object->_getUsedHTMLTags("survey");
181  foreach ($alltags as $tag)
182  {
183  $this->tpl->setCurrentBlock("html_tag_row");
184  $this->tpl->setVariable("HTML_TAG", $tag);
185  if (is_array($usedtags))
186  {
187  if (in_array($tag, $usedtags))
188  {
189  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
190  }
191  }
192  $this->tpl->parseCurrentBlock();
193  }
194 
195  $this->tpl->setCurrentBlock("adm_content");
196  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
197  $this->tpl->setVariable("TXT_SURVEY_SETTINGS", $this->lng->txt("advanced_editing_survey_settings"));
198  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
199  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
200 
201  $this->tpl->parseCurrentBlock();
202  }
203 
208  {
209  global $ilSetting;
210 
211  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_learning_module.html");
212 
213  $this->tpl->setCurrentBlock("adm_content");
214  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
215  $this->tpl->setVariable("TXT_LM_SETTINGS", $this->lng->txt("advanced_editing_lm_settings"));
216  $this->tpl->setVariable("TXT_LM_JS_EDITING", $this->lng->txt("advanced_editing_lm_js_editing"));
217  $this->tpl->setVariable("TXT_LM_JS_EDITING_DESC", $this->lng->txt("advanced_editing_lm_js_editing_desc"));
218  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
219 
220  if ($ilSetting->get("enable_js_edit", 1))
221  {
222  $this->tpl->setVariable("JS_EDIT", "checked=\"checked\"");
223  }
224 
225  $this->tpl->parseCurrentBlock();
226  }
227 
232  {
233  global $ilSetting;
234 
235  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
236  $ilSetting->set("enable_js_edit", $_POST["js_edit"]);
237  $this->ctrl->redirect($this, 'learningmodule');
238  }
239 
243  function categoryObject()
244  {
245  global $ilSetting, $tree;
246 
247  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_category.html");
248 
249  $this->tpl->setCurrentBlock("adm_content");
250  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
251  $this->tpl->setVariable("TXT_CAT_SETTINGS", $this->lng->txt("adve_cat_settings"));
252  $this->tpl->setVariable("TXT_CAT_PAGE_EDITING", $this->lng->txt("advanced_editing_cat_page_editing"));
253  $this->tpl->setVariable("TXT_CAT_PAGE_EDITING_DESC", $this->lng->txt("advanced_editing_cat_page_editing_desc"));
254  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
255 
256  $this->tpl->setVariable("TXT_CAT_PAGES",
257  $this->lng->txt("cat_pages"));
258  $this->tpl->setVariable("TXT_UNDO_LAST_CAT_CHANGES",
259  $this->lng->txt("cat_undo_last_page_changes"));
260  $this->tpl->setVariable("TXT_CLEAR_CAT_PAGE",
261  $this->lng->txt("cat_clear_page"));
262 
263  $root_node = $tree->getNodeData(ROOT_FOLDER_ID);
264  $nodes = $tree->getSubTree($root_node, true, "cat");
265  $cats[0] = $this->lng->txt("please_select");
266  $cats[$root_node["ref_id"]] = "- ".$this->lng->txt("repository");
267  foreach($nodes as $node)
268  {
269  $cats[$node["ref_id"]] = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",($node["depth"]-1))."- ".$node["title"];
270  }
271  $this->tpl->setVariable("SELECT_CATEGORY",
272  ilUtil::formSelect("", "cat_id", $cats, false, true));
273 
274  if ($ilSetting->get("enable_cat_page_edit"))
275  {
276  $this->tpl->setVariable("CAT_PAGE_EDIT", "checked=\"checked\"");
277  }
278 
279  $this->tpl->parseCurrentBlock();
280  }
281 
286  {
287  global $ilSetting;
288 
289  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
290  $ilSetting->set("enable_cat_page_edit", $_POST["cat_page_edit"]);
291  $this->ctrl->redirect($this, 'category');
292  }
293 
298  {
299  global $ilSetting;
300 
301  include_once("./Services/Container/classes/class.ilContainer.php");
303  ilObject::_lookupObjId($_POST["cat_id"]),
304  "xhtml_page");
305  if ($xpage_id > 0)
306  {
307  ilUtil::sendInfo($this->lng->txt("cat_pages_undone"), true);
308  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
309  $xpage = new ilXHTMLPage($xpage_id);
310  $xpage->undo();
311  }
312  else
313  {
314  ilUtil::sendInfo($this->lng->txt("cat_pages_not_created"), true);
315  }
316 
317  $this->ctrl->redirect($this, 'category');
318  }
319 
324  {
325  global $ilSetting;
326 
327  include_once("./Services/Container/classes/class.ilContainer.php");
329  ilObject::_lookupObjId($_POST["cat_id"]),
330  "xhtml_page");
331  if ($xpage_id > 0)
332  {
333  ilUtil::sendInfo($this->lng->txt("cat_pages_clear"), true);
334  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
335  $xpage = new ilXHTMLPage($xpage_id);
336  $xpage->clear();
337  }
338  else
339  {
340  ilUtil::sendInfo($this->lng->txt("cat_pages_not_created"), true);
341  }
342 
343  $this->ctrl->redirect($this, 'category');
344  }
345 
350  {
351  $this->object->_setRichTextEditor($_POST["rte"]);
352  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
353 
354  $this->ctrl->redirect($this,'settings');
355  }
356 
358  {
359  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
360 
361  $this->object->_setUsedHTMLTags($_POST["html_tags"], "assessment");
362  $this->ctrl->redirect($this,'assessment');
363  }
364 
366  {
367  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
368 
369  $this->object->_setUsedHTMLTags($_POST["html_tags"], "survey");
370  $this->ctrl->redirect($this,'survey');
371  }
372 
373  function getAdminTabs(&$tabs_gui)
374  {
375  $this->getTabs($tabs_gui);
376  }
377 
378  function addSubtabs(&$tabs_gui)
379  {
380  global $ilCtrl;
381 
382  if ($ilCtrl->getNextClass() != "ilpermissiongui")
383  {
384  $tabs_gui->addSubTabTarget("adve_general_settings",
385  $this->ctrl->getLinkTarget($this, "settings"),
386  array("", "view", "settings", "saveSettings"),
387  "", "");
388  $tabs_gui->addSubTabTarget("adve_assessment_settings",
389  $this->ctrl->getLinkTarget($this, "assessment"),
390  array("assessment", "saveAssessmentSettings"),
391  "", "");
392  $tabs_gui->addSubTabTarget("adve_survey_settings",
393  $this->ctrl->getLinkTarget($this, "survey"),
394  array("survey", "saveSurveySettings"),
395  "", "");
396  $tabs_gui->addSubTabTarget("adve_cat_settings",
397  $this->ctrl->getLinkTarget($this, "category"),
398  array("category", "saveCategorySettings"),
399  "", "");
400  $tabs_gui->addSubTabTarget("adve_lm_settings",
401  $this->ctrl->getLinkTarget($this, "learningModule"),
402  array("learningModule", "saveLearningModuleSettings"),
403  "", "");
404  }
405  }
406 
412  function getTabs(&$tabs_gui)
413  {
414  global $rbacsystem;
415 
416  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
417  {
418  $tabs_gui->addTarget("settings",
419  $this->ctrl->getLinkTarget($this, "settings"),
420  array("settings","","view", "assessment", "survey", "learningModule",
421  "category"), "", "");
422 
423  }
424 
425  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
426  {
427  $tabs_gui->addTarget("perm_settings",
428  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
429  }
430  $this->addSubtabs($tabs_gui);
431  }
432 } // END class.ilObjAdvancedEditingGUI
433 ?>