ILIAS  Release_5_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 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "./Services/Object/classes/class.ilObjectGUI.php";
6 
18 {
20 
24  function ilObjAdvancedEditingGUI($a_data,$a_id,$a_call_by_reference)
25  {
26  global $rbacsystem, $lng;
27 
28  $this->type = "adve";
29  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
30  $this->lng->loadLanguageModule('adve');
31  $this->lng->loadLanguageModule('meta');
32 
33  if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
34  {
35  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read_adve"),$this->ilias->error_obj->WARNING);
36  }
37  }
38 
39  function &executeCommand()
40  {
41  $next_class = $this->ctrl->getNextClass($this);
42  $cmd = $this->ctrl->getCmd();
43  $this->prepareOutput();
44 
45  switch($next_class)
46  {
47 
48  case 'ilpermissiongui':
49  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
50  $perm_gui =& new ilPermissionGUI($this);
51  $ret =& $this->ctrl->forwardCommand($perm_gui);
52  break;
53 
54  default:
55  if($cmd == "" || $cmd == "view")
56  {
57  $cmd = "showGeneralPageEditorSettings";
58  }
59  $cmd .= "Object";
60  $this->$cmd();
61 
62  break;
63  }
64  return true;
65  }
66 
71  function saveObject()
72  {
73  global $rbacadmin;
74 
75  // create and insert forum in objecttree
76  $newObj = parent::saveObject();
77 
78  // put here object specific stuff
79 
80  // always send a message
81  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
82 
83  $this->ctrl->redirect($this);
84  //header("Location:".$this->getReturnLocation("save","adm_object.php?".$this->link_params));
85  //exit();
86  }
87 
88  function getAdminTabs(&$tabs_gui)
89  {
90  $this->getTabs($tabs_gui);
91  }
92 
96  function addSubtabs(&$tabs_gui)
97  {
98  global $ilCtrl;
99 
100  if ($ilCtrl->getNextClass() != "ilpermissiongui" &&
101  !in_array($ilCtrl->getCmd(), array("showPageEditorSettings",
102  "showGeneralPageEditorSettings", "showCharSelectorSettings", "", "view")))
103  {
104  $tabs_gui->addSubTabTarget("adve_general_settings",
105  $this->ctrl->getLinkTarget($this, "settings"),
106  array("settings", "saveSettings"),
107  "", "");
108  $tabs_gui->addSubTabTarget("adve_assessment_settings",
109  $this->ctrl->getLinkTarget($this, "assessment"),
110  array("assessment", "saveAssessmentSettings"),
111  "", "");
112  $tabs_gui->addSubTabTarget("adve_survey_settings",
113  $this->ctrl->getLinkTarget($this, "survey"),
114  array("survey", "saveSurveySettings"),
115  "", "");
116  $tabs_gui->addSubTabTarget("adve_frm_post_settings",
117  $this->ctrl->getLinkTarget($this, "frmPost"),
118  array("frmPost", "saveFrmPostSettings"),
119  "", "");
120  $tabs_gui->addSubTabTarget("adve_excass_settings",
121  $this->ctrl->getLinkTarget($this, "excass"),
122  array("excass", "saveExcAssSettings"),
123  "", "");
124  }
125  }
126 
131  {
132  global $ilCtrl, $ilTabs;
133 
134  $ilTabs->addSubTabTarget("adve_pe_general",
135  $ilCtrl->getLinkTarget($this, "showGeneralPageEditorSettings"),
136  array("showGeneralPageEditorSettings", "", "view"));
137 
138  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
140 
141  foreach ($grps as $g => $types)
142  {
143  $ilCtrl->setParameter($this, "grp", $g);
144  $ilTabs->addSubTabTarget("adve_grp_".$g,
145  $ilCtrl->getLinkTarget($this, "showPageEditorSettings"),
146  array("showPageEditorSettings"));
147  }
148  $ilCtrl->setParameter($this, "grp", $_GET["grp"]);
149  }
150 
156  function getTabs(&$tabs_gui)
157  {
158  global $rbacsystem;
159 
160  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
161  {
162  $tabs_gui->addTarget("adve_page_editor_settings",
163  $this->ctrl->getLinkTarget($this, "showGeneralPageEditorSettings"),
164  array("showPageEditorSettings", "","view"));
165 
166  $tabs_gui->addTarget("adve_rte_settings",
167  $this->ctrl->getLinkTarget($this, "settings"),
168  array("settings","assessment", "survey", "frmPost"), "", "");
169 
170  $tabs_gui->addTarget("adve_char_selector_settings",
171  $this->ctrl->getLinkTarget($this, "showCharSelectorSettings"),
172  array("showCharSelectorSettings", "","view"));
173  }
174 
175  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
176  {
177  $tabs_gui->addTarget("perm_settings",
178  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
179  }
180  $this->addSubtabs($tabs_gui);
181  }
182 
183 
187  function settingsObject()
188  {
189  global $tpl, $ilCtrl, $lng;
190 
191  $editor = $this->object->_getRichTextEditor();
192 
193  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
194  $this->form = new ilPropertyFormGUI();
195  $this->form->setFormAction($ilCtrl->getFormAction($this));
196  $this->form->setTitle($lng->txt("adve_activation"));
197  $cb = new ilCheckboxInputGUI($this->lng->txt("adve_use_tiny_mce"), "use_tiny");
198  if ($editor == "tinymce")
199  {
200  $cb->setChecked(true);
201  }
202  $this->form->addItem($cb);
203  $this->form->addCommandButton("saveSettings", $lng->txt("save"));
204 
205  $tpl->setContent($this->form->getHTML());
206  }
207 
212  {
213  if ($_POST["use_tiny"])
214  {
215  $this->object->_setRichTextEditor("tinymce");
216  }
217  else
218  {
219  $this->object->_setRichTextEditor("");
220  }
221  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
222 
223  $this->ctrl->redirect($this,'settings');
224  }
225 
226 
230  function assessmentObject()
231  {
232  $form = $this->initTagsForm("assessment", "saveAssessmentSettings",
233  "advanced_editing_assessment_settings");
234 
235  $this->tpl->setContent($form->getHTML());
236  }
237 
239  {
240  $this->saveTags("assessment", "assessment");
241  }
242 
243 
247  function surveyObject()
248  {
249  $form = $this->initTagsForm("survey", "saveSurveySettings",
250  "advanced_editing_survey_settings");
251 
252  $this->tpl->setContent($form->getHTML());
253  }
254 
256  {
257  $this->saveTags("survey", "survey");
258  }
259 
260 
264  public function frmPostObject()
265  {
266  $form = $this->initTagsForm("frm_post", "saveFrmPostSettings",
267  "advanced_editing_frm_post_settings");
268 
269  $this->tpl->setContent($form->getHTML());
270  }
271 
272  public function saveFrmPostSettingsObject()
273  {
274  $this->saveTags("frm_post", "frmPost");
275  }
276 
277 
281  public function excAssObject()
282  {
283  $form = $this->initTagsForm("exc_ass", "saveExcAssSettings",
284  "advanced_editing_excass_settings");
285 
286  $this->tpl->setContent($form->getHTML());
287  }
288 
289  public function saveExcAssSettingsObject()
290  {
291  $this->saveTags("exc_ass", "excAss");
292  }
293 
294 
295  protected function initTagsForm($a_id, $a_cmd, $a_title)
296  {
297  global $ilAccess;
298 
299  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
300  $form = new ilPropertyFormGUI();
301  $form->setFormAction($this->ctrl->getFormAction($this, $a_cmd));
302  $form->setTitle($this->lng->txt($a_title));
303 
304  $alltags = $this->object->getHTMLTags();
305  $alltags = array_combine($alltags, $alltags);
306 
307  include_once "Services/Form/classes/class.ilMultiSelectInputGUI.php";
308  $tags = new ilMultiSelectInputGUI($this->lng->txt("advanced_editing_allow_html_tags"), "html_tags");
309  $tags->setHeight(400);
310  $tags->enableSelectAll(true);
311  $tags->enableSelectedFirst(true);
312  $tags->setOptions($alltags);
313  $tags->setValue($this->object->_getUsedHTMLTags($a_id));
314  $form->addItem($tags);
315 
316  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
317  {
318  $form->addCommandButton($a_cmd, $this->lng->txt("save"));
319  }
320 
321  return $form;
322  }
323 
324  protected function saveTags($a_id, $a_cmd)
325  {
326  try
327  {
328  // get rid of select all
329  if(is_array($_POST['html_tags']) && $_POST['html_tags'][0] == "")
330  {
331  unset($_POST['html_tags'][0]);
332  }
333 
334  $this->object->_setUsedHTMLTags((array)$_POST['html_tags'], $a_id);
335  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
336  }
338  {
339  ilUtil::sendInfo($e->getMessage(), true);
340  }
341 
342  $this->ctrl->redirect($this, $a_cmd);
343  }
344 
345 
350  {
351  global $tpl, $ilTabs, $ilCtrl;
352 
353  $this->addPageEditorSettingsSubTabs();
354 
355  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
357 
358  $this->cgrp = $_GET["grp"];
359  if ($this->cgrp == "")
360  {
361  $this->cgrp = key($grps);
362  }
363 
364  $ilCtrl->setParameter($this, "grp", $this->cgrp);
365  $ilTabs->setSubTabActive("adve_grp_".$this->cgrp);
366 
367  $this->initPageEditorForm();
368  $tpl->setContent($this->form->getHtml());
369  }
370 
376  public function initPageEditorForm($a_mode = "edit")
377  {
378  global $lng, $ilSetting;
379 
380  $lng->loadLanguageModule("content");
381 
382  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
383  $this->form = new ilPropertyFormGUI();
384 
385  if( $this->cgrp == "test" )
386  {
387  require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
388 
389  $this->form->setTitle($lng->txt("adve_activation"));
390  $cb = new ilCheckboxInputGUI($this->lng->txt("advanced_editing_tst_editing"), "tst_page_edit");
391  $cb->setInfo($this->lng->txt("advanced_editing_tst_editing_desc"));
393  {
394  $cb->setChecked(true);
395  }
396  $this->form->addItem($cb);
397 
398  $sh = new ilFormSectionHeaderGUI();
399  $sh->setTitle($lng->txt("adve_text_content_features"));
400  $this->form->addItem($sh);
401  }
402  elseif ($this->cgrp == "rep")
403  {
404  $this->form->setTitle($lng->txt("adve_activation"));
405  $cb = new ilCheckboxInputGUI($this->lng->txt("advanced_editing_rep_page_editing"), "cat_page_edit");
406  $cb->setInfo($this->lng->txt("advanced_editing_rep_page_editing_desc"));
407  if ($ilSetting->get("enable_cat_page_edit"))
408  {
409  $cb->setChecked(true);
410  }
411  $this->form->addItem($cb);
412 
413  $sh = new ilFormSectionHeaderGUI();
414  $sh->setTitle($lng->txt("adve_text_content_features"));
415  $this->form->addItem($sh);
416  }
417  else
418  {
419  $this->form->setTitle($lng->txt("adve_text_content_features"));
420  }
421 
422 
423  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
424 
425  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
427  foreach ($buttons as $b => $t)
428  {
429  // command button activation
430  $cb = new ilCheckboxInputGUI(str_replace(":", "", $this->lng->txt("cont_text_".$b)), "active_".$b);
431  $cb->setChecked(ilPageEditorSettings::lookupSetting($this->cgrp, "active_".$b, true));
432  $this->form->addItem($cb);
433  }
434 
435  // save and cancel commands
436  $this->form->addCommandButton("savePageEditorSettings", $lng->txt("save"));
437 
438  $this->form->setFormAction($this->ctrl->getFormAction($this));
439 
440  }
441 
447  {
448  global $tpl, $lng, $ilCtrl, $ilSetting;
449 
450  $this->initPageEditorForm();
451  if ($this->form->checkInput())
452  {
453  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
454  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
456  foreach ($buttons as $b => $t)
457  {
458  ilPageEditorSettings::writeSetting($_GET["grp"], "active_".$b,
459  $this->form->getInput("active_".$b));
460  }
461 
462  if ($_GET["grp"] == "test")
463  {
464  $ilSetting->set("enable_tst_page_edit", (int) $_POST["tst_page_edit"]);
465  }
466  elseif ($_GET["grp"] == "rep")
467  {
468  $ilSetting->set("enable_cat_page_edit", (int) $_POST["cat_page_edit"]);
469  }
470 
471  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
472  }
473 
474  $ilCtrl->setParameter($this, "grp", $_GET["grp"]);
475  $ilCtrl->redirect($this, "showPageEditorSettings");
476  }
477 
478 
483  {
484  global $tpl, $ilTabs;
485 
486  $this->addPageEditorSettingsSubTabs();
487  $ilTabs->activateTab("adve_page_editor_settings");
488 
489  $form = $this->initGeneralPageSettingsForm();
490  $tpl->setContent($form->getHTML());
491  }
492 
496  public function initGeneralPageSettingsForm()
497  {
498  global $lng, $ilCtrl;
499 
500  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
501  $form = new ilPropertyFormGUI();
502 
503  $aset = new ilSetting("adve");
504 
505  // use physical character styles
506  $cb = new ilCheckboxInputGUI($this->lng->txt("adve_use_physical"), "use_physical");
507  $cb->setInfo($this->lng->txt("adve_use_physical_info"));
508  $cb->setChecked($aset->get("use_physical"));
509  $form->addItem($cb);
510 
511  // blocking mode
512  $cb = new ilCheckboxInputGUI($this->lng->txt("adve_blocking_mode"), "block_mode_act");
513  $cb->setChecked($aset->get("block_mode_minutes") > 0);
514  $form->addItem($cb);
515 
516  // number of minutes
517  $ni = new ilNumberInputGUI($this->lng->txt("adve_minutes"), "block_mode_minutes");
518  $ni->setMinValue(2);
519  $ni->setMaxLength(5);
520  $ni->setSize(5);
521  $ni->setRequired(true);
522  $ni->setInfo($this->lng->txt("adve_minutes_info"));
523  $ni->setValue($aset->get("block_mode_minutes"));
524  $cb->addSubItem($ni);
525 
526  $form->addCommandButton("saveGeneralPageSettings", $lng->txt("save"));
527 
528  $form->setTitle($lng->txt("adve_pe_general"));
529  $form->setFormAction($ilCtrl->getFormAction($this));
530 
531  return $form;
532  }
533 
538  {
539  global $ilCtrl, $lng, $tpl;
540 
541  $form = $this->initGeneralPageSettingsForm();
542  if ($form->checkInput())
543  {
544  $aset = new ilSetting("adve");
545  $aset->set("use_physical", $_POST["use_physical"]);
546  if ($_POST["block_mode_act"])
547  {
548  $aset->set("block_mode_minutes", (int) $_POST["block_mode_minutes"]);
549  }
550  else
551  {
552  $aset->set("block_mode_minutes", 0);
553  }
554 
555  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
556  $ilCtrl->redirect($this, "showGeneralPageEditorSettings");
557  }
558 
559  $form->setValuesByPost();
560  $tpl->setContent($form->getHTML());
561  }
562 
566  public function initCharSelectorSettingsForm(ilCharSelectorGUI $char_selector)
567  {
568  global $lng, $ilCtrl;
569 
570  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
571  $form = new ilPropertyFormGUI();
572  $form->setTitle($lng->txt('settings'));
573  $form->setFormAction($ilCtrl->getFormAction($this));
574  $form->addCommandButton("saveCharSelectorSettings", $lng->txt("save"));
575  $char_selector->addFormProperties($form);
576 
577  return $form;
578  }
579 
580 
585  {
586  global $ilTabs, $ilSetting, $tpl;
587 
588  $ilTabs->activateTab("adve_char_selector_settings");
589 
590  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
592  $char_selector->getConfig()->setAvailability($ilSetting->get('char_selector_availability'));
593  $char_selector->getConfig()->setDefinition($ilSetting->get('char_selector_definition'));
594  $form = $this->initCharSelectorSettingsForm($char_selector);
595  $char_selector->setFormValues($form);
596  $tpl->setContent($form->getHTML());
597  }
598 
599 
604  {
605  global $ilSetting, $ilCtrl, $lng, $tpl;
606 
607  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
609  $form = $this->initCharSelectorSettingsForm($char_selector);
610  if ($form->checkInput())
611  {
612  $char_selector->getFormValues($form);
613 
614  $ilSetting->set('char_selector_availability', $char_selector->getConfig()->getAvailability());
615  $ilSetting->set('char_selector_definition', $char_selector->getConfig()->getDefinition());
616 
617  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
618  $ilCtrl->redirect($this, "showCharSelectorSettings");
619  }
620  $form->setValuesByPost();
621  $tpl->setContent($form->getHTML());
622  }
623 
624 
625 } // END class.ilObjAdvancedEditingGUI
626 ?>