ILIAS  Release_4_1_x_branch Revision 61804
 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, $lng;
48 
49  $this->type = "adve";
50  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
51  $this->lng->loadLanguageModule('adve');
52  $this->lng->loadLanguageModule('meta');
53 
54  if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
55  {
56  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read_adve"),$this->ilias->error_obj->WARNING);
57  }
58  }
59 
60  function &executeCommand()
61  {
62  $next_class = $this->ctrl->getNextClass($this);
63  $cmd = $this->ctrl->getCmd();
64  $this->prepareOutput();
65 
66  switch($next_class)
67  {
68 
69  case 'ilpermissiongui':
70  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
71  $perm_gui =& new ilPermissionGUI($this);
72  $ret =& $this->ctrl->forwardCommand($perm_gui);
73  break;
74 
75  default:
76  if($cmd == "" || $cmd == "view")
77  {
78  $cmd = "settings";
79  }
80  $cmd .= "Object";
81  $this->$cmd();
82 
83  break;
84  }
85  return true;
86  }
87 
88 
93  function saveObject()
94  {
95  global $rbacadmin;
96 
97  // create and insert forum in objecttree
98  $newObj = parent::saveObject();
99 
100  // put here object specific stuff
101 
102  // always send a message
103  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
104 
105  $this->ctrl->redirect($this);
106  //header("Location:".$this->getReturnLocation("save","adm_object.php?".$this->link_params));
107  //exit();
108  }
109 
110 
114  function settingsObject()
115  {
116  global $ilAccess;
117 
118  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing.html");
119 
120  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
121  {
122  $this->tpl->setCurrentBlock("save");
123  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
124  $this->tpl->parseCurrentBlock();
125  }
126  $this->tpl->setCurrentBlock("adm_content");
127  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
128  $this->tpl->setVariable("TXT_ADVANCED_EDITING_SETTINGS", $this->lng->txt("advanced_editing_settings"));
129  $this->tpl->setVariable("TXT_ALLOW_JAVASCRIPT_EDITOR", $this->lng->txt("advanced_editing_allow_javascript_editor"));
130  $this->tpl->setVariable("NO_RTE_EDITOR", $this->lng->txt("advanced_editing_no_rte"));
131  $this->tpl->setVariable("TINY_MCE_EDITOR", $this->lng->txt("advanced_editing_tinymce"));
132  $editor = $this->object->_getRichTextEditor();
133  switch ($editor)
134  {
135  case "tinymce":
136  $this->tpl->setVariable("SELECTED_TINY_MCE_EDITOR", " selected=\"selected\"");
137  break;
138  }
139 
140  $this->tpl->parseCurrentBlock();
141  }
142 
146  function assessmentObject()
147  {
148  global $ilAccess;
149 
150  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_assessment.html");
151 
152  $alltags =& $this->object->getHTMLTags();
153  $usedtags =& $this->object->_getUsedHTMLTags("assessment");
154  foreach ($alltags as $tag)
155  {
156  $this->tpl->setCurrentBlock("html_tag_row");
157  $this->tpl->setVariable("HTML_TAG", $tag);
158  if (is_array($usedtags))
159  {
160  if (in_array($tag, $usedtags))
161  {
162  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
163  }
164  }
165  $this->tpl->parseCurrentBlock();
166  }
167 
168  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
169  {
170  $this->tpl->setCurrentBlock("save");
171  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
172  $this->tpl->parseCurrentBlock();
173  }
174 
175  $this->tpl->setCurrentBlock("adm_content");
176  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
177  $this->tpl->setVariable("TXT_ASSESSMENT_SETTINGS", $this->lng->txt("advanced_editing_assessment_settings"));
178  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
179 
180  $this->tpl->parseCurrentBlock();
181  }
182 
183 
187  function surveyObject()
188  {
189  global $ilAccess;
190 
191  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_survey.html");
192 
193  $alltags =& $this->object->getHTMLTags();
194  $usedtags =& $this->object->_getUsedHTMLTags("survey");
195  foreach ($alltags as $tag)
196  {
197  $this->tpl->setCurrentBlock("html_tag_row");
198  $this->tpl->setVariable("HTML_TAG", $tag);
199  if (is_array($usedtags))
200  {
201  if (in_array($tag, $usedtags))
202  {
203  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
204  }
205  }
206  $this->tpl->parseCurrentBlock();
207  }
208 
209  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
210  {
211  $this->tpl->setCurrentBlock("save");
212  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
213  $this->tpl->parseCurrentBlock();
214  }
215 
216  $this->tpl->setCurrentBlock("adm_content");
217  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
218  $this->tpl->setVariable("TXT_SURVEY_SETTINGS", $this->lng->txt("advanced_editing_survey_settings"));
219  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
220 
221  $this->tpl->parseCurrentBlock();
222  }
223 
228  {
229  global $ilSetting;
230 
231  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_learning_module.html");
232 
233  $this->tpl->setCurrentBlock("adm_content");
234  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
235  $this->tpl->setVariable("TXT_LM_SETTINGS", $this->lng->txt("advanced_editing_lm_settings"));
236  $this->tpl->setVariable("TXT_LM_JS_EDITING", $this->lng->txt("advanced_editing_lm_js_editing"));
237  $this->tpl->setVariable("TXT_LM_JS_EDITING_DESC", $this->lng->txt("advanced_editing_lm_js_editing_desc"));
238  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
239 
240  if ($ilSetting->get("enable_js_edit", 1))
241  {
242  $this->tpl->setVariable("JS_EDIT", "checked=\"checked\"");
243  }
244 
245  $this->tpl->parseCurrentBlock();
246  }
247 
252  {
253  global $ilSetting;
254 
255  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
256  $ilSetting->set("enable_js_edit", $_POST["js_edit"]);
257  $this->ctrl->redirect($this, 'learningmodule');
258  }
259 
264  {
265  global $ilSetting, $tree, $ilCtrl, $lng, $tpl;
266 
267  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
268  $this->form = new ilPropertyFormGUI();
269 
270  // allow editing
271  $cb = new ilCheckboxInputGUI($this->lng->txt("advanced_editing_rep_page_editing"), "cat_page_edit");
272  $cb->setInfo($this->lng->txt("advanced_editing_rep_page_editing_desc"));
273  if ($ilSetting->get("enable_cat_page_edit"))
274  {
275  $cb->setChecked(true);
276  }
277  $this->form->addItem($cb);
278 
279  $this->form->addCommandButton("saveRepositorySettings", $lng->txt("save"));
280 
281  $this->form->setTitle($lng->txt("adve_rep_settings"));
282  $this->form->setFormAction($ilCtrl->getFormAction($this));
283 
284  $tpl->setContent($this->form->getHTML());
285 
286 return;
287  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_category.html");
288  $this->tpl->setCurrentBlock("adm_content");
289  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
290  $this->tpl->setVariable("TXT_CAT_SETTINGS", $this->lng->txt("adve_cat_settings"));
291  $this->tpl->setVariable("TXT_CAT_PAGE_EDITING", $this->lng->txt("advanced_editing_cat_page_editing"));
292  $this->tpl->setVariable("TXT_CAT_PAGE_EDITING_DESC", $this->lng->txt("advanced_editing_cat_page_editing_desc"));
293  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
294 
295  $this->tpl->setVariable("TXT_CAT_PAGES",
296  $this->lng->txt("cat_pages"));
297  $this->tpl->setVariable("TXT_UNDO_LAST_CAT_CHANGES",
298  $this->lng->txt("cat_undo_last_page_changes"));
299  $this->tpl->setVariable("TXT_CLEAR_CAT_PAGE",
300  $this->lng->txt("cat_clear_page"));
301 
302  $root_node = $tree->getNodeData(ROOT_FOLDER_ID);
303  $nodes = $tree->getSubTree($root_node, true, "cat");
304  $cats[0] = $this->lng->txt("please_select");
305  $cats[$root_node["ref_id"]] = "- ".$this->lng->txt("repository");
306  foreach($nodes as $node)
307  {
308  $cats[$node["ref_id"]] = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",($node["depth"]-1))."- ".$node["title"];
309  }
310  $this->tpl->setVariable("SELECT_CATEGORY",
311  ilUtil::formSelect("", "cat_id", $cats, false, true));
312 
313  if ($ilSetting->get("enable_cat_page_edit"))
314  {
315  $this->tpl->setVariable("CAT_PAGE_EDIT", "checked=\"checked\"");
316  }
317 
318  $this->tpl->parseCurrentBlock();
319  }
320 
325  {
326  global $ilSetting;
327 
328  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
329  $ilSetting->set("enable_cat_page_edit", $_POST["cat_page_edit"]);
330  $this->ctrl->redirect($this, 'repositorySettings');
331  }
332 
336 /*
337  function undoLastCategoryChangeObject()
338  {
339  global $ilSetting;
340 
341  include_once("./Services/Container/classes/class.ilContainer.php");
342  $xpage_id = ilContainer::_lookupContainerSetting(
343  ilObject::_lookupObjId($_POST["cat_id"]),
344  "xhtml_page");
345  if ($xpage_id > 0)
346  {
347  ilUtil::sendSuccess($this->lng->txt("cat_pages_undone"), true);
348  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
349  $xpage = new ilXHTMLPage($xpage_id);
350  $xpage->undo();
351  }
352  else
353  {
354  ilUtil::sendFailure($this->lng->txt("cat_pages_not_created"), true);
355  }
356 
357  $this->ctrl->redirect($this, 'category');
358  }
359 */
363 /*
364  function clearCategoryPageObject()
365  {
366  global $ilSetting;
367 
368  include_once("./Services/Container/classes/class.ilContainer.php");
369  $xpage_id = ilContainer::_lookupContainerSetting(
370  ilObject::_lookupObjId($_POST["cat_id"]),
371  "xhtml_page");
372  if ($xpage_id > 0)
373  {
374  ilUtil::sendSuccess($this->lng->txt("cat_pages_clear"), true);
375  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
376  $xpage = new ilXHTMLPage($xpage_id);
377  $xpage->clear();
378  }
379  else
380  {
381  ilUtil::sendFailure($this->lng->txt("cat_pages_not_created"), true);
382  }
383 
384  $this->ctrl->redirect($this, 'category');
385  }
386 */
391  {
392  $this->object->_setRichTextEditor($_POST["rte"]);
393  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
394 
395  $this->ctrl->redirect($this,'settings');
396  }
397 
399  {
400  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
401 
402  $this->object->_setUsedHTMLTags($_POST["html_tags"], "assessment");
403  $this->ctrl->redirect($this,'assessment');
404  }
405 
407  {
408  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
409 
410  $this->object->_setUsedHTMLTags($_POST["html_tags"], "survey");
411  $this->ctrl->redirect($this,'survey');
412  }
413 
414  function getAdminTabs(&$tabs_gui)
415  {
416  $this->getTabs($tabs_gui);
417  }
418 
423  {
424  global $tpl, $ilTabs, $ilCtrl;
425 
426  $this->addPageEditorSettingsSubTabs();
427 
428  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
430 
431  $this->cgrp = $_GET["grp"];
432  if ($this->cgrp == "")
433  {
434  $this->cgrp = key($grps);
435  }
436 
437  $ilCtrl->setParameter($this, "grp", $this->cgrp);
438  $ilTabs->setSubTabActive("adve_grp_".$this->cgrp);
439 
440  $this->initPageEditorForm();
441  $tpl->setContent($this->form->getHtml());
442  }
443 
449  public function initPageEditorForm($a_mode = "edit")
450  {
451  global $lng;
452 
453  $lng->loadLanguageModule("content");
454 
455  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
456  $this->form = new ilPropertyFormGUI();
457 
458  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
459 
460  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
462  foreach ($buttons as $b => $t)
463  {
464  // command button activation
465  $cb = new ilCheckboxInputGUI(str_replace(":", "", $this->lng->txt("cont_text_".$b)), "active_".$b);
466  $cb->setChecked(ilPageEditorSettings::lookupSetting($this->cgrp, "active_".$b, true));
467  $this->form->addItem($cb);
468  }
469 
470  // save and cancel commands
471  $this->form->addCommandButton("savePageEditorSettings", $lng->txt("save"));
472 
473  $this->form->setTitle($lng->txt("adve_text_content_features"));
474  $this->form->setFormAction($this->ctrl->getFormAction($this));
475 
476  }
477 
483  {
484  global $tpl, $lng, $ilCtrl;
485 
486  $this->initPageEditorForm();
487  if ($this->form->checkInput())
488  {
489  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
490  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
492  foreach ($buttons as $b => $t)
493  {
494  ilPageEditorSettings::writeSetting($_GET["grp"], "active_".$b,
495  $this->form->getInput("active_".$b));
496  }
497  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
498  }
499 
500  $ilCtrl->setParameter($this, "grp", $_GET["grp"]);
501  $ilCtrl->redirect($this, "showPageEditorSettings");
502  }
503 
507  function addSubtabs(&$tabs_gui)
508  {
509  global $ilCtrl;
510 
511  if ($ilCtrl->getNextClass() != "ilpermissiongui" &&
512  $ilCtrl->getCmd() != "showPageEditorSettings")
513  {
514  $tabs_gui->addSubTabTarget("adve_general_settings",
515  $this->ctrl->getLinkTarget($this, "settings"),
516  array("", "view", "settings", "saveSettings"),
517  "", "");
518  $tabs_gui->addSubTabTarget("adve_assessment_settings",
519  $this->ctrl->getLinkTarget($this, "assessment"),
520  array("assessment", "saveAssessmentSettings"),
521  "", "");
522  $tabs_gui->addSubTabTarget("adve_survey_settings",
523  $this->ctrl->getLinkTarget($this, "survey"),
524  array("survey", "saveSurveySettings"),
525  "", "");
526  $tabs_gui->addSubTabTarget("adve_rep_settings",
527  $this->ctrl->getLinkTarget($this, "repositorySettings"),
528  array("repositorySettings"),
529  "", "");
530  $tabs_gui->addSubTabTarget("adve_lm_settings",
531  $this->ctrl->getLinkTarget($this, "learningModule"),
532  array("learningModule", "saveLearningModuleSettings"),
533  "", "");
534  $tabs_gui->addSubTabTarget("adve_frm_post_settings",
535  $this->ctrl->getLinkTarget($this, "frmPost"),
536  array("frmPost", "saveFrmPostSettings"),
537  "", "");
538  }
539  }
540 
541  public function saveFrmPostSettingsObject()
542  {
543  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
544 
545  try
546  {
547  $this->object->_setUsedHTMLTags((array)$_POST['html_tags'], 'frm_post');
548  }
550  {
551  ilUtil::sendInfo($e->getMessage(), true);
552  }
553 
554  $this->ctrl->redirect($this,'frmPost');
555  }
556 
557  public function frmPostObject()
558  {
559  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_frm_post.html");
560 
561  $alltags =& $this->object->getHTMLTags();
562  $usedtags =& $this->object->_getUsedHTMLTags("frm_post");
563  foreach ($alltags as $tag)
564  {
565  $this->tpl->setCurrentBlock("html_tag_row");
566  $this->tpl->setVariable("HTML_TAG", $tag);
567  if (is_array($usedtags))
568  {
569  if (in_array($tag, $usedtags))
570  {
571  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
572  }
573  }
574  $this->tpl->parseCurrentBlock();
575  }
576 
577  $this->tpl->setCurrentBlock("adm_content");
578  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
579  $this->tpl->setVariable("TXT_FRM_POST_SETTINGS", $this->lng->txt("advanced_editing_frm_post_settings"));
580  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
581  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
582 
583  $this->tpl->parseCurrentBlock();
584  }
585 
586 
591  {
592  global $ilCtrl, $ilTabs;
593 
594  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
596 
597  foreach ($grps as $g => $types)
598  {
599  $ilCtrl->setParameter($this, "grp", $g);
600  $ilTabs->addSubTabTarget("adve_grp_".$g,
601  $ilCtrl->getLinkTarget($this, "showPageEditorSettings"),
602  array("showPageEditorSettings"));
603  }
604  $ilCtrl->setParameter($this, "grp", $_GET["grp"]);
605  }
606 
607 
613  function getTabs(&$tabs_gui)
614  {
615  global $rbacsystem;
616 
617  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
618  {
619  $tabs_gui->addTarget("adve_rte_settings",
620  $this->ctrl->getLinkTarget($this, "settings"),
621  array("settings","","view", "assessment", "survey", "learningModule",
622  "category"), "", "");
623 
624  $tabs_gui->addTarget("adve_page_editor_settings",
625  $this->ctrl->getLinkTarget($this, "showPageEditorSettings"),
626  array("showPageEditorSettings"));
627  }
628 
629  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
630  {
631  $tabs_gui->addTarget("perm_settings",
632  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
633  }
634  $this->addSubtabs($tabs_gui);
635  }
636 } // END class.ilObjAdvancedEditingGUI
637 ?>