ILIAS  Release_4_0_x_branch Revision 61816
 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  // setup rolefolder & default local roles
101  //$roles = $newObj->initDefaultRoles();
102 
103  // put here object specific stuff
104 
105  // always send a message
106  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
107 
108  $this->ctrl->redirect($this);
109  //header("Location:".$this->getReturnLocation("save","adm_object.php?".$this->link_params));
110  //exit();
111  }
112 
113 
117  function settingsObject()
118  {
119  global $ilAccess;
120 
121  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing.html");
122 
123  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
124  {
125  $this->tpl->setCurrentBlock("save");
126  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
127  $this->tpl->parseCurrentBlock();
128  }
129  $this->tpl->setCurrentBlock("adm_content");
130  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
131  $this->tpl->setVariable("TXT_ADVANCED_EDITING_SETTINGS", $this->lng->txt("advanced_editing_settings"));
132  $this->tpl->setVariable("TXT_ALLOW_JAVASCRIPT_EDITOR", $this->lng->txt("advanced_editing_allow_javascript_editor"));
133  $this->tpl->setVariable("NO_RTE_EDITOR", $this->lng->txt("advanced_editing_no_rte"));
134  $this->tpl->setVariable("TINY_MCE_EDITOR", $this->lng->txt("advanced_editing_tinymce"));
135  $editor = $this->object->_getRichTextEditor();
136  switch ($editor)
137  {
138  case "tinymce":
139  $this->tpl->setVariable("SELECTED_TINY_MCE_EDITOR", " selected=\"selected\"");
140  break;
141  }
142 
143  $this->tpl->parseCurrentBlock();
144  }
145 
149  function assessmentObject()
150  {
151  global $ilAccess;
152 
153  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_assessment.html");
154 
155  $alltags =& $this->object->getHTMLTags();
156  $usedtags =& $this->object->_getUsedHTMLTags("assessment");
157  foreach ($alltags as $tag)
158  {
159  $this->tpl->setCurrentBlock("html_tag_row");
160  $this->tpl->setVariable("HTML_TAG", $tag);
161  if (is_array($usedtags))
162  {
163  if (in_array($tag, $usedtags))
164  {
165  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
166  }
167  }
168  $this->tpl->parseCurrentBlock();
169  }
170 
171  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
172  {
173  $this->tpl->setCurrentBlock("save");
174  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
175  $this->tpl->parseCurrentBlock();
176  }
177 
178  $this->tpl->setCurrentBlock("adm_content");
179  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
180  $this->tpl->setVariable("TXT_ASSESSMENT_SETTINGS", $this->lng->txt("advanced_editing_assessment_settings"));
181  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
182 
183  $this->tpl->parseCurrentBlock();
184  }
185 
186 
190  function surveyObject()
191  {
192  global $ilAccess;
193 
194  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_survey.html");
195 
196  $alltags =& $this->object->getHTMLTags();
197  $usedtags =& $this->object->_getUsedHTMLTags("survey");
198  foreach ($alltags as $tag)
199  {
200  $this->tpl->setCurrentBlock("html_tag_row");
201  $this->tpl->setVariable("HTML_TAG", $tag);
202  if (is_array($usedtags))
203  {
204  if (in_array($tag, $usedtags))
205  {
206  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
207  }
208  }
209  $this->tpl->parseCurrentBlock();
210  }
211 
212  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
213  {
214  $this->tpl->setCurrentBlock("save");
215  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
216  $this->tpl->parseCurrentBlock();
217  }
218 
219  $this->tpl->setCurrentBlock("adm_content");
220  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
221  $this->tpl->setVariable("TXT_SURVEY_SETTINGS", $this->lng->txt("advanced_editing_survey_settings"));
222  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
223 
224  $this->tpl->parseCurrentBlock();
225  }
226 
231  {
232  global $ilSetting;
233 
234  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_learning_module.html");
235 
236  $this->tpl->setCurrentBlock("adm_content");
237  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
238  $this->tpl->setVariable("TXT_LM_SETTINGS", $this->lng->txt("advanced_editing_lm_settings"));
239  $this->tpl->setVariable("TXT_LM_JS_EDITING", $this->lng->txt("advanced_editing_lm_js_editing"));
240  $this->tpl->setVariable("TXT_LM_JS_EDITING_DESC", $this->lng->txt("advanced_editing_lm_js_editing_desc"));
241  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
242 
243  if ($ilSetting->get("enable_js_edit", 1))
244  {
245  $this->tpl->setVariable("JS_EDIT", "checked=\"checked\"");
246  }
247 
248  $this->tpl->parseCurrentBlock();
249  }
250 
255  {
256  global $ilSetting;
257 
258  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
259  $ilSetting->set("enable_js_edit", $_POST["js_edit"]);
260  $this->ctrl->redirect($this, 'learningmodule');
261  }
262 
267  {
268  global $ilSetting, $tree, $ilCtrl, $lng, $tpl;
269 
270  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
271  $this->form = new ilPropertyFormGUI();
272 
273  // allow editing
274  $cb = new ilCheckboxInputGUI($this->lng->txt("advanced_editing_rep_page_editing"), "cat_page_edit");
275  $cb->setInfo($this->lng->txt("advanced_editing_rep_page_editing_desc"));
276  if ($ilSetting->get("enable_cat_page_edit"))
277  {
278  $cb->setChecked(true);
279  }
280  $this->form->addItem($cb);
281 
282  $this->form->addCommandButton("saveRepositorySettings", $lng->txt("save"));
283 
284  $this->form->setTitle($lng->txt("adve_rep_settings"));
285  $this->form->setFormAction($ilCtrl->getFormAction($this));
286 
287  $tpl->setContent($this->form->getHTML());
288 
289 return;
290  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_category.html");
291  $this->tpl->setCurrentBlock("adm_content");
292  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
293  $this->tpl->setVariable("TXT_CAT_SETTINGS", $this->lng->txt("adve_cat_settings"));
294  $this->tpl->setVariable("TXT_CAT_PAGE_EDITING", $this->lng->txt("advanced_editing_cat_page_editing"));
295  $this->tpl->setVariable("TXT_CAT_PAGE_EDITING_DESC", $this->lng->txt("advanced_editing_cat_page_editing_desc"));
296  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
297 
298  $this->tpl->setVariable("TXT_CAT_PAGES",
299  $this->lng->txt("cat_pages"));
300  $this->tpl->setVariable("TXT_UNDO_LAST_CAT_CHANGES",
301  $this->lng->txt("cat_undo_last_page_changes"));
302  $this->tpl->setVariable("TXT_CLEAR_CAT_PAGE",
303  $this->lng->txt("cat_clear_page"));
304 
305  $root_node = $tree->getNodeData(ROOT_FOLDER_ID);
306  $nodes = $tree->getSubTree($root_node, true, "cat");
307  $cats[0] = $this->lng->txt("please_select");
308  $cats[$root_node["ref_id"]] = "- ".$this->lng->txt("repository");
309  foreach($nodes as $node)
310  {
311  $cats[$node["ref_id"]] = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",($node["depth"]-1))."- ".$node["title"];
312  }
313  $this->tpl->setVariable("SELECT_CATEGORY",
314  ilUtil::formSelect("", "cat_id", $cats, false, true));
315 
316  if ($ilSetting->get("enable_cat_page_edit"))
317  {
318  $this->tpl->setVariable("CAT_PAGE_EDIT", "checked=\"checked\"");
319  }
320 
321  $this->tpl->parseCurrentBlock();
322  }
323 
328  {
329  global $ilSetting;
330 
331  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
332  $ilSetting->set("enable_cat_page_edit", $_POST["cat_page_edit"]);
333  $this->ctrl->redirect($this, 'repositorySettings');
334  }
335 
339 /*
340  function undoLastCategoryChangeObject()
341  {
342  global $ilSetting;
343 
344  include_once("./Services/Container/classes/class.ilContainer.php");
345  $xpage_id = ilContainer::_lookupContainerSetting(
346  ilObject::_lookupObjId($_POST["cat_id"]),
347  "xhtml_page");
348  if ($xpage_id > 0)
349  {
350  ilUtil::sendSuccess($this->lng->txt("cat_pages_undone"), true);
351  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
352  $xpage = new ilXHTMLPage($xpage_id);
353  $xpage->undo();
354  }
355  else
356  {
357  ilUtil::sendFailure($this->lng->txt("cat_pages_not_created"), true);
358  }
359 
360  $this->ctrl->redirect($this, 'category');
361  }
362 */
366 /*
367  function clearCategoryPageObject()
368  {
369  global $ilSetting;
370 
371  include_once("./Services/Container/classes/class.ilContainer.php");
372  $xpage_id = ilContainer::_lookupContainerSetting(
373  ilObject::_lookupObjId($_POST["cat_id"]),
374  "xhtml_page");
375  if ($xpage_id > 0)
376  {
377  ilUtil::sendSuccess($this->lng->txt("cat_pages_clear"), true);
378  include_once("./Services/XHTMLPage/classes/class.ilXHTMLPage.php");
379  $xpage = new ilXHTMLPage($xpage_id);
380  $xpage->clear();
381  }
382  else
383  {
384  ilUtil::sendFailure($this->lng->txt("cat_pages_not_created"), true);
385  }
386 
387  $this->ctrl->redirect($this, 'category');
388  }
389 */
394  {
395  $this->object->_setRichTextEditor($_POST["rte"]);
396  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
397 
398  $this->ctrl->redirect($this,'settings');
399  }
400 
402  {
403  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
404 
405  $this->object->_setUsedHTMLTags($_POST["html_tags"], "assessment");
406  $this->ctrl->redirect($this,'assessment');
407  }
408 
410  {
411  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
412 
413  $this->object->_setUsedHTMLTags($_POST["html_tags"], "survey");
414  $this->ctrl->redirect($this,'survey');
415  }
416 
417  function getAdminTabs(&$tabs_gui)
418  {
419  $this->getTabs($tabs_gui);
420  }
421 
426  {
427  global $tpl, $ilTabs, $ilCtrl;
428 
429  $this->addPageEditorSettingsSubTabs();
430 
431  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
433 
434  $this->cgrp = $_GET["grp"];
435  if ($this->cgrp == "")
436  {
437  $this->cgrp = key($grps);
438  }
439 
440  $ilCtrl->setParameter($this, "grp", $this->cgrp);
441  $ilTabs->setSubTabActive("adve_grp_".$this->cgrp);
442 
443  $this->initPageEditorForm();
444  $tpl->setContent($this->form->getHtml());
445  }
446 
452  public function initPageEditorForm($a_mode = "edit")
453  {
454  global $lng;
455 
456  $lng->loadLanguageModule("content");
457 
458  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
459  $this->form = new ilPropertyFormGUI();
460 
461  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
462 
463  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
465  foreach ($buttons as $b => $t)
466  {
467  // command button activation
468  $cb = new ilCheckboxInputGUI(str_replace(":", "", $this->lng->txt("cont_text_".$b)), "active_".$b);
469  $cb->setChecked(ilPageEditorSettings::lookupSetting($this->cgrp, "active_".$b, true));
470  $this->form->addItem($cb);
471  }
472 
473  // save and cancel commands
474  $this->form->addCommandButton("savePageEditorSettings", $lng->txt("save"));
475 
476  $this->form->setTitle($lng->txt("adve_text_content_features"));
477  $this->form->setFormAction($this->ctrl->getFormAction($this));
478 
479  }
480 
486  {
487  global $tpl, $lng, $ilCtrl;
488 
489  $this->initPageEditorForm();
490  if ($this->form->checkInput())
491  {
492  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
493  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
495  foreach ($buttons as $b => $t)
496  {
497  ilPageEditorSettings::writeSetting($_GET["grp"], "active_".$b,
498  $this->form->getInput("active_".$b));
499  }
500  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
501  }
502 
503  $ilCtrl->setParameter($this, "grp", $_GET["grp"]);
504  $ilCtrl->redirect($this, "showPageEditorSettings");
505  }
506 
510  function addSubtabs(&$tabs_gui)
511  {
512  global $ilCtrl;
513 
514  if ($ilCtrl->getNextClass() != "ilpermissiongui" &&
515  $ilCtrl->getCmd() != "showPageEditorSettings")
516  {
517  $tabs_gui->addSubTabTarget("adve_general_settings",
518  $this->ctrl->getLinkTarget($this, "settings"),
519  array("", "view", "settings", "saveSettings"),
520  "", "");
521  $tabs_gui->addSubTabTarget("adve_assessment_settings",
522  $this->ctrl->getLinkTarget($this, "assessment"),
523  array("assessment", "saveAssessmentSettings"),
524  "", "");
525  $tabs_gui->addSubTabTarget("adve_survey_settings",
526  $this->ctrl->getLinkTarget($this, "survey"),
527  array("survey", "saveSurveySettings"),
528  "", "");
529  $tabs_gui->addSubTabTarget("adve_rep_settings",
530  $this->ctrl->getLinkTarget($this, "repositorySettings"),
531  array("repositorySettings"),
532  "", "");
533  $tabs_gui->addSubTabTarget("adve_lm_settings",
534  $this->ctrl->getLinkTarget($this, "learningModule"),
535  array("learningModule", "saveLearningModuleSettings"),
536  "", "");
537  $tabs_gui->addSubTabTarget("adve_frm_post_settings",
538  $this->ctrl->getLinkTarget($this, "frmPost"),
539  array("frmPost", "saveFrmPostSettings"),
540  "", "");
541  }
542  }
543 
544  public function saveFrmPostSettingsObject()
545  {
546  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
547 
548  try
549  {
550  $this->object->_setUsedHTMLTags((array)$_POST['html_tags'], 'frm_post');
551  }
553  {
554  ilUtil::sendInfo($e->getMessage(), true);
555  }
556 
557  $this->ctrl->redirect($this,'frmPost');
558  }
559 
560  public function frmPostObject()
561  {
562  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_frm_post.html");
563 
564  $alltags =& $this->object->getHTMLTags();
565  $usedtags =& $this->object->_getUsedHTMLTags("frm_post");
566  foreach ($alltags as $tag)
567  {
568  $this->tpl->setCurrentBlock("html_tag_row");
569  $this->tpl->setVariable("HTML_TAG", $tag);
570  if (is_array($usedtags))
571  {
572  if (in_array($tag, $usedtags))
573  {
574  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
575  }
576  }
577  $this->tpl->parseCurrentBlock();
578  }
579 
580  $this->tpl->setCurrentBlock("adm_content");
581  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
582  $this->tpl->setVariable("TXT_FRM_POST_SETTINGS", $this->lng->txt("advanced_editing_frm_post_settings"));
583  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
584  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
585 
586  $this->tpl->parseCurrentBlock();
587  }
588 
589 
594  {
595  global $ilCtrl, $ilTabs;
596 
597  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
599 
600  foreach ($grps as $g => $types)
601  {
602  $ilCtrl->setParameter($this, "grp", $g);
603  $ilTabs->addSubTabTarget("adve_grp_".$g,
604  $ilCtrl->getLinkTarget($this, "showPageEditorSettings"),
605  array("showPageEditorSettings"));
606  }
607  $ilCtrl->setParameter($this, "grp", $_GET["grp"]);
608  }
609 
610 
616  function getTabs(&$tabs_gui)
617  {
618  global $rbacsystem;
619 
620  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
621  {
622  $tabs_gui->addTarget("adve_rte_settings",
623  $this->ctrl->getLinkTarget($this, "settings"),
624  array("settings","","view", "assessment", "survey", "learningModule",
625  "category"), "", "");
626 
627  $tabs_gui->addTarget("adve_page_editor_settings",
628  $this->ctrl->getLinkTarget($this, "showPageEditorSettings"),
629  array("showPageEditorSettings"));
630  }
631 
632  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
633  {
634  $tabs_gui->addTarget("perm_settings",
635  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
636  }
637  $this->addSubtabs($tabs_gui);
638  }
639 } // END class.ilObjAdvancedEditingGUI
640 ?>