ILIAS  Release_4_2_x_branch Revision 61807
 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 "./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 
67 
72  function saveObject()
73  {
74  global $rbacadmin;
75 
76  // create and insert forum in objecttree
77  $newObj = parent::saveObject();
78 
79  // put here object specific stuff
80 
81  // always send a message
82  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
83 
84  $this->ctrl->redirect($this);
85  //header("Location:".$this->getReturnLocation("save","adm_object.php?".$this->link_params));
86  //exit();
87  }
88 
89 
93  function settingsObject()
94  {
95  global $ilAccess, $tpl, $ilCtrl, $lng;
96 
97  $editor = $this->object->_getRichTextEditor();
98 
99  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
100  $this->form = new ilPropertyFormGUI();
101  $this->form->setFormAction($ilCtrl->getFormAction($this));
102  $this->form->setTitle($lng->txt("adve_activation"));
103  $cb = new ilCheckboxInputGUI($this->lng->txt("adve_use_tiny_mce"), "use_tiny");
104  if ($editor == "tinymce")
105  {
106  $cb->setChecked(true);
107  }
108  $this->form->addItem($cb);
109  $this->form->addCommandButton("saveSettings", $lng->txt("save"));
110 
111  $tpl->setContent($this->form->getHTML());
112  }
113 
117  function assessmentObject()
118  {
119  global $ilAccess;
120 
121  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_assessment.html");
122 
123  $alltags =& $this->object->getHTMLTags();
124  $usedtags =& $this->object->_getUsedHTMLTags("assessment");
125  foreach ($alltags as $tag)
126  {
127  $this->tpl->setCurrentBlock("html_tag_row");
128  $this->tpl->setVariable("HTML_TAG", $tag);
129  if (is_array($usedtags))
130  {
131  if (in_array($tag, $usedtags))
132  {
133  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
134  }
135  }
136  $this->tpl->parseCurrentBlock();
137  }
138 
139  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
140  {
141  $this->tpl->setCurrentBlock("save");
142  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
143  $this->tpl->parseCurrentBlock();
144  }
145 
146  $this->tpl->setCurrentBlock("adm_content");
147  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
148  $this->tpl->setVariable("TXT_ASSESSMENT_SETTINGS", $this->lng->txt("advanced_editing_assessment_settings"));
149  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
150 
151  $this->tpl->parseCurrentBlock();
152  }
153 
154 
158  function surveyObject()
159  {
160  global $ilAccess;
161 
162  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_survey.html");
163 
164  $alltags =& $this->object->getHTMLTags();
165  $usedtags =& $this->object->_getUsedHTMLTags("survey");
166  foreach ($alltags as $tag)
167  {
168  $this->tpl->setCurrentBlock("html_tag_row");
169  $this->tpl->setVariable("HTML_TAG", $tag);
170  if (is_array($usedtags))
171  {
172  if (in_array($tag, $usedtags))
173  {
174  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
175  }
176  }
177  $this->tpl->parseCurrentBlock();
178  }
179 
180  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
181  {
182  $this->tpl->setCurrentBlock("save");
183  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
184  $this->tpl->parseCurrentBlock();
185  }
186 
187  $this->tpl->setCurrentBlock("adm_content");
188  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
189  $this->tpl->setVariable("TXT_SURVEY_SETTINGS", $this->lng->txt("advanced_editing_survey_settings"));
190  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
191 
192  $this->tpl->parseCurrentBlock();
193  }
194 
198 /*
199  function learningModuleObject()
200  {
201  global $ilSetting;
202 
203  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_learning_module.html");
204 
205  $this->tpl->setCurrentBlock("adm_content");
206  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
207  $this->tpl->setVariable("TXT_LM_SETTINGS", $this->lng->txt("advanced_editing_lm_settings"));
208  $this->tpl->setVariable("TXT_LM_JS_EDITING", $this->lng->txt("advanced_editing_lm_js_editing"));
209  $this->tpl->setVariable("TXT_LM_JS_EDITING_DESC", $this->lng->txt("advanced_editing_lm_js_editing_desc"));
210  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
211 
212  if ($ilSetting->get("enable_js_edit", 1))
213  {
214  $this->tpl->setVariable("JS_EDIT", "checked=\"checked\"");
215  }
216 
217  $this->tpl->parseCurrentBlock();
218  }
219 */
223 /*
224  function saveLearningModuleSettingsObject()
225  {
226  global $ilSetting;
227 
228  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
229  $ilSetting->set("enable_js_edit", (int) $_POST["js_edit"]);
230  $this->ctrl->redirect($this, 'learningmodule');
231  }
232 */
237  {
238  if ($_POST["use_tiny"])
239  {
240  $this->object->_setRichTextEditor("tinymce");
241  }
242  else
243  {
244  $this->object->_setRichTextEditor("");
245  }
246  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
247 
248  $this->ctrl->redirect($this,'settings');
249  }
250 
252  {
253  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
254 
255  $this->object->_setUsedHTMLTags($_POST["html_tags"], "assessment");
256  $this->ctrl->redirect($this,'assessment');
257  }
258 
260  {
261  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
262 
263  $this->object->_setUsedHTMLTags($_POST["html_tags"], "survey");
264  $this->ctrl->redirect($this,'survey');
265  }
266 
267  function getAdminTabs(&$tabs_gui)
268  {
269  $this->getTabs($tabs_gui);
270  }
271 
276  {
277  global $tpl, $ilTabs, $ilCtrl;
278 
279  $this->addPageEditorSettingsSubTabs();
280 
281  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
283 
284  $this->cgrp = $_GET["grp"];
285  if ($this->cgrp == "")
286  {
287  $this->cgrp = key($grps);
288  }
289 
290  $ilCtrl->setParameter($this, "grp", $this->cgrp);
291  $ilTabs->setSubTabActive("adve_grp_".$this->cgrp);
292 
293  $this->initPageEditorForm();
294  $tpl->setContent($this->form->getHtml());
295  }
296 
302  public function initPageEditorForm($a_mode = "edit")
303  {
304  global $lng, $ilSetting;
305 
306  $lng->loadLanguageModule("content");
307 
308  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
309  $this->form = new ilPropertyFormGUI();
310 
311  if ($this->cgrp == "rep")
312  {
313  $this->form->setTitle($lng->txt("adve_activation"));
314  $cb = new ilCheckboxInputGUI($this->lng->txt("advanced_editing_rep_page_editing"), "cat_page_edit");
315  $cb->setInfo($this->lng->txt("advanced_editing_rep_page_editing_desc"));
316  if ($ilSetting->get("enable_cat_page_edit"))
317  {
318  $cb->setChecked(true);
319  }
320  $this->form->addItem($cb);
321 
322  $sh = new ilFormSectionHeaderGUI();
323  $sh->setTitle($lng->txt("adve_text_content_features"));
324  $this->form->addItem($sh);
325  }
326  else
327  {
328  $this->form->setTitle($lng->txt("adve_text_content_features"));
329  }
330 
331 
332  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
333 
334  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
336  foreach ($buttons as $b => $t)
337  {
338  // command button activation
339  $cb = new ilCheckboxInputGUI(str_replace(":", "", $this->lng->txt("cont_text_".$b)), "active_".$b);
340  $cb->setChecked(ilPageEditorSettings::lookupSetting($this->cgrp, "active_".$b, true));
341  $this->form->addItem($cb);
342  }
343 
344  // save and cancel commands
345  $this->form->addCommandButton("savePageEditorSettings", $lng->txt("save"));
346 
347  $this->form->setFormAction($this->ctrl->getFormAction($this));
348 
349  }
350 
356  {
357  global $tpl, $lng, $ilCtrl, $ilSetting;
358 
359  $this->initPageEditorForm();
360  if ($this->form->checkInput())
361  {
362  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
363  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
365  foreach ($buttons as $b => $t)
366  {
367  ilPageEditorSettings::writeSetting($_GET["grp"], "active_".$b,
368  $this->form->getInput("active_".$b));
369  }
370 
371  if ($_GET["grp"] == "rep")
372  {
373  $ilSetting->set("enable_cat_page_edit", (int) $_POST["cat_page_edit"]);
374  }
375 
376  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
377  }
378 
379  $ilCtrl->setParameter($this, "grp", $_GET["grp"]);
380  $ilCtrl->redirect($this, "showPageEditorSettings");
381  }
382 
387  {
388  global $tpl, $ilTabs;
389 
390  $this->addPageEditorSettingsSubTabs();
391  $ilTabs->activateTab("adve_page_editor_settings");
392 
393  $form = $this->initGeneralPageSettingsForm();
394  $tpl->setContent($form->getHTML());
395  }
396 
400  public function initGeneralPageSettingsForm()
401  {
402  global $lng, $ilCtrl;
403 
404  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
405  $form = new ilPropertyFormGUI();
406 
407  $aset = new ilSetting("adve");
408 
409  // use physical character styles
410  $cb = new ilCheckboxInputGUI($this->lng->txt("adve_use_physical"), "use_physical");
411  $cb->setInfo($this->lng->txt("adve_use_physical_info"));
412  $cb->setChecked($aset->get("use_physical"));
413  $form->addItem($cb);
414 
415  $form->addCommandButton("saveGeneralPageSettings", $lng->txt("save"));
416 
417  $form->setTitle($lng->txt("adve_pe_general"));
418  $form->setFormAction($ilCtrl->getFormAction($this));
419 
420  return $form;
421  }
422 
427  {
428  global $ilCtrl, $lng;
429 
430  $form = $this->initGeneralPageSettingsForm();
431  if ($form->checkInput())
432  {
433  $aset = new ilSetting("adve");
434  $aset->set("use_physical", $_POST["use_physical"]);
435  }
436  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
437  $ilCtrl->redirect($this, "showGeneralPageEditorSettings");
438  }
439 
443  function addSubtabs(&$tabs_gui)
444  {
445  global $ilCtrl;
446 
447  if ($ilCtrl->getNextClass() != "ilpermissiongui" &&
448  !in_array($ilCtrl->getCmd(), array("showPageEditorSettings",
449  "showGeneralPageEditorSettings", "", "view")))
450  {
451  $tabs_gui->addSubTabTarget("adve_general_settings",
452  $this->ctrl->getLinkTarget($this, "settings"),
453  array("settings", "saveSettings"),
454  "", "");
455  $tabs_gui->addSubTabTarget("adve_assessment_settings",
456  $this->ctrl->getLinkTarget($this, "assessment"),
457  array("assessment", "saveAssessmentSettings"),
458  "", "");
459  $tabs_gui->addSubTabTarget("adve_survey_settings",
460  $this->ctrl->getLinkTarget($this, "survey"),
461  array("survey", "saveSurveySettings"),
462  "", "");
463  /*$tabs_gui->addSubTabTarget("adve_lm_settings",
464  $this->ctrl->getLinkTarget($this, "learningModule"),
465  array("learningModule", "saveLearningModuleSettings"),
466  "", "");*/
467  $tabs_gui->addSubTabTarget("adve_frm_post_settings",
468  $this->ctrl->getLinkTarget($this, "frmPost"),
469  array("frmPost", "saveFrmPostSettings"),
470  "", "");
471  }
472  }
473 
474  public function saveFrmPostSettingsObject()
475  {
476  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
477 
478  try
479  {
480  $this->object->_setUsedHTMLTags((array)$_POST['html_tags'], 'frm_post');
481  }
483  {
484  ilUtil::sendInfo($e->getMessage(), true);
485  }
486 
487  $this->ctrl->redirect($this,'frmPost');
488  }
489 
490  public function frmPostObject()
491  {
492  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_frm_post.html");
493 
494  $alltags =& $this->object->getHTMLTags();
495  $usedtags =& $this->object->_getUsedHTMLTags("frm_post");
496  foreach ($alltags as $tag)
497  {
498  $this->tpl->setCurrentBlock("html_tag_row");
499  $this->tpl->setVariable("HTML_TAG", $tag);
500  if (is_array($usedtags))
501  {
502  if (in_array($tag, $usedtags))
503  {
504  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
505  }
506  }
507  $this->tpl->parseCurrentBlock();
508  }
509 
510  $this->tpl->setCurrentBlock("adm_content");
511  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
512  $this->tpl->setVariable("TXT_FRM_POST_SETTINGS", $this->lng->txt("advanced_editing_frm_post_settings"));
513  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
514  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
515 
516  $this->tpl->parseCurrentBlock();
517  }
518 
519 
524  {
525  global $ilCtrl, $ilTabs;
526 
527  $ilTabs->addSubTabTarget("adve_pe_general",
528  $ilCtrl->getLinkTarget($this, "showGeneralPageEditorSettings"),
529  array("showGeneralPageEditorSettings", "", "view"));
530 
531  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
533 
534  foreach ($grps as $g => $types)
535  {
536  $ilCtrl->setParameter($this, "grp", $g);
537  $ilTabs->addSubTabTarget("adve_grp_".$g,
538  $ilCtrl->getLinkTarget($this, "showPageEditorSettings"),
539  array("showPageEditorSettings"));
540  }
541  $ilCtrl->setParameter($this, "grp", $_GET["grp"]);
542  }
543 
544 
550  function getTabs(&$tabs_gui)
551  {
552  global $rbacsystem;
553 
554  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
555  {
556  $tabs_gui->addTarget("adve_page_editor_settings",
557  $this->ctrl->getLinkTarget($this, "showGeneralPageEditorSettings"),
558  array("showPageEditorSettings", "","view"));
559 
560  $tabs_gui->addTarget("adve_rte_settings",
561  $this->ctrl->getLinkTarget($this, "settings"),
562  array("settings","assessment", "survey", "learningModule",
563  "frmPost"), "", "");
564  }
565 
566  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
567  {
568  $tabs_gui->addTarget("perm_settings",
569  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
570  }
571  $this->addSubtabs($tabs_gui);
572  }
573 } // END class.ilObjAdvancedEditingGUI
574 ?>