ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 __construct($a_data,$a_id,$a_call_by_reference)
25  {
26  global $rbacsystem;
27 
28  $this->type = "adve";
29  parent::__construct($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()
89  {
90  $this->getTabs();
91  }
92 
96  function addSubtabs()
97  {
98  global $ilCtrl;
99 
100  if ($ilCtrl->getNextClass() != "ilpermissiongui" &&
101  !in_array($ilCtrl->getCmd(), array("showPageEditorSettings",
102  "showGeneralPageEditorSettings", "showCharSelectorSettings", "", "view")))
103  {
104  $this->tabs_gui->addSubTabTarget("adve_general_settings",
105  $this->ctrl->getLinkTarget($this, "settings"),
106  array("settings", "saveSettings"),
107  "", "");
108  $this->tabs_gui->addSubTabTarget("adve_assessment_settings",
109  $this->ctrl->getLinkTarget($this, "assessment"),
110  array("assessment", "saveAssessmentSettings"),
111  "", "");
112  $this->tabs_gui->addSubTabTarget("adve_survey_settings",
113  $this->ctrl->getLinkTarget($this, "survey"),
114  array("survey", "saveSurveySettings"),
115  "", "");
116  $this->tabs_gui->addSubTabTarget("adve_frm_post_settings",
117  $this->ctrl->getLinkTarget($this, "frmPost"),
118  array("frmPost", "saveFrmPostSettings"),
119  "", "");
120  $this->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()
157  {
158  global $rbacsystem;
159 
160  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
161  {
162  $this->tabs_gui->addTarget("adve_page_editor_settings",
163  $this->ctrl->getLinkTarget($this, "showGeneralPageEditorSettings"),
164  array("showPageEditorSettings", "","view"));
165 
166  $this->tabs_gui->addTarget("adve_rte_settings",
167  $this->ctrl->getLinkTarget($this, "settings"),
168  array("settings","assessment", "survey", "frmPost", "excass"), "", "");
169 
170  $this->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  $this->tabs_gui->addTarget("perm_settings",
178  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
179  }
180  $this->addSubtabs($this->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(ilObjAdvancedEditing::_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  // auto url linking
527  $cb = new ilCheckboxInputGUI($this->lng->txt("adve_auto_url_linking"), "auto_url_linking");
528  $cb->setChecked($aset->get("auto_url_linking"));
529  $cb->setInfo($this->lng->txt("adve_auto_url_linking_info"));
530  $form->addItem($cb);
531 
532  $form->addCommandButton("saveGeneralPageSettings", $lng->txt("save"));
533 
534  $form->setTitle($lng->txt("adve_pe_general"));
535  $form->setFormAction($ilCtrl->getFormAction($this));
536 
537  return $form;
538  }
539 
544  {
545  global $ilCtrl, $lng, $tpl;
546 
547  $form = $this->initGeneralPageSettingsForm();
548  if ($form->checkInput())
549  {
550  $aset = new ilSetting("adve");
551  $aset->set("use_physical", $_POST["use_physical"]);
552  if ($_POST["block_mode_act"])
553  {
554  $aset->set("block_mode_minutes", (int) $_POST["block_mode_minutes"]);
555  }
556  else
557  {
558  $aset->set("block_mode_minutes", 0);
559  }
560  $aset->set("auto_url_linking", $_POST["auto_url_linking"]);
561 
562  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
563  $ilCtrl->redirect($this, "showGeneralPageEditorSettings");
564  }
565 
566  $form->setValuesByPost();
567  $tpl->setContent($form->getHTML());
568  }
569 
573  public function initCharSelectorSettingsForm(ilCharSelectorGUI $char_selector)
574  {
575  global $lng, $ilCtrl;
576 
577  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
578  $form = new ilPropertyFormGUI();
579  $form->setTitle($lng->txt('settings'));
580  $form->setFormAction($ilCtrl->getFormAction($this));
581  $form->addCommandButton("saveCharSelectorSettings", $lng->txt("save"));
582  $char_selector->addFormProperties($form);
583 
584  return $form;
585  }
586 
587 
592  {
593  global $ilTabs, $ilSetting, $tpl;
594 
595  $ilTabs->activateTab("adve_char_selector_settings");
596 
597  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
599  $char_selector->getConfig()->setAvailability($ilSetting->get('char_selector_availability'));
600  $char_selector->getConfig()->setDefinition($ilSetting->get('char_selector_definition'));
601  $form = $this->initCharSelectorSettingsForm($char_selector);
602  $char_selector->setFormValues($form);
603  $tpl->setContent($form->getHTML());
604  }
605 
606 
611  {
612  global $ilSetting, $ilCtrl, $lng, $tpl;
613 
614  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
616  $form = $this->initCharSelectorSettingsForm($char_selector);
617  if ($form->checkInput())
618  {
619  $char_selector->getFormValues($form);
620 
621  $ilSetting->set('char_selector_availability', $char_selector->getConfig()->getAvailability());
622  $ilSetting->set('char_selector_definition', $char_selector->getConfig()->getDefinition());
623 
624  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
625  $ilCtrl->redirect($this, "showCharSelectorSettings");
626  }
627  $form->setValuesByPost();
628  $tpl->setContent($form->getHTML());
629  }
630 
631 
632 } // END class.ilObjAdvancedEditingGUI
633 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
ILIAS Setting Class.
frmPostObject()
Display settings for forums.
surveyObject()
Display settings for surveys.
setHeight($a_height)
Sets the height of this field.
This class represents a property form user interface.
$_GET["client_id"]
excAssObject()
Display settings for exercise assignments.
This shows a character selector.
This class represents a section header in a property form.
static lookupSetting($a_grp, $a_name, $a_default=false)
Lookup setting.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
$cmd
Definition: sahs_server.php:35
addPageEditorSettingsSubtabs()
Show page editor settings subtabs.
saveCharSelectorSettingsObject()
Save the settings for the selector of unicode characters.
showGeneralPageEditorSettingsObject()
Show general page editor settings.
This class represents a checkbox property in a property form.
assessmentObject()
Display settings for test and assessment.
saveGeneralPageSettingsObject()
Save general page settings.
static getGroups()
Get all settings groups.
settingsObject()
Display assessment folder settings form.
__construct($a_data, $a_id, $a_call_by_reference)
Constructor.
Class for advanced editing exception handling in ILIAS.
initTagsForm($a_id, $a_cmd, $a_title)
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static writeSetting($a_grp, $a_name, $a_value)
Write Setting.
initPageEditorForm($a_mode="edit")
Init page editor form.
saveSettingsObject()
Save Assessment settings.
setChecked($a_checked)
Set Checked.
prepareOutput($a_show_subobjects=true)
prepare output
This class represents a multi selection list property in a property form.
showPageEditorSettingsObject()
Show page editor settings.
setMinValue($a_minvalue, $a_display_always=false)
Set Minimum Value.
addFormProperties(ilPropertyFormGUI $a_form)
add the configuration elements to a property form
const ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_DISABLED
This class represents a number property in a property form.
Class ilObjectGUI Basic methods of all Output classes.
showCharSelectorSettingsObject()
Show the settings for the selector of unicode characters.
redirection script todo: (a better solution should control the processing via a xml file) ...
Create styles array
The data for the language used.
initCharSelectorSettingsForm(ilCharSelectorGUI $char_selector)
Init the settings form for the selector of unicode characters.
global $ilSetting
Definition: privfeed.php:17
static _getCommonBBButtons()
Get common bb buttons.
$ret
Definition: parser.php:6
savePageEditorSettingsObject()
Save page editor settings form.
Class ilObjAdvancedEditingGUI.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
initGeneralPageSettingsForm()
Init general page editor settings form.
$_POST["username"]