ILIAS  release_4-3 Revision
 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 
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  "Services/AdvancedEditing");
123 
124  $alltags =& $this->object->getHTMLTags();
125  $usedtags =& $this->object->_getUsedHTMLTags("assessment");
126  foreach ($alltags as $tag)
127  {
128  $this->tpl->setCurrentBlock("html_tag_row");
129  $this->tpl->setVariable("HTML_TAG", $tag);
130  if (is_array($usedtags))
131  {
132  if (in_array($tag, $usedtags))
133  {
134  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
135  }
136  }
137  $this->tpl->parseCurrentBlock();
138  }
139 
140  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
141  {
142  $this->tpl->setCurrentBlock("save");
143  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
144  $this->tpl->parseCurrentBlock();
145  }
146 
147  $this->tpl->setCurrentBlock("adm_content");
148  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
149  $this->tpl->setVariable("TXT_ASSESSMENT_SETTINGS", $this->lng->txt("advanced_editing_assessment_settings"));
150  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
151 
152  $this->tpl->parseCurrentBlock();
153  }
154 
155 
159  function surveyObject()
160  {
161  global $ilAccess;
162 
163  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_survey.html",
164  "Services/AdvancedEditing");
165 
166  $alltags =& $this->object->getHTMLTags();
167  $usedtags =& $this->object->_getUsedHTMLTags("survey");
168  foreach ($alltags as $tag)
169  {
170  $this->tpl->setCurrentBlock("html_tag_row");
171  $this->tpl->setVariable("HTML_TAG", $tag);
172  if (is_array($usedtags))
173  {
174  if (in_array($tag, $usedtags))
175  {
176  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
177  }
178  }
179  $this->tpl->parseCurrentBlock();
180  }
181 
182  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
183  {
184  $this->tpl->setCurrentBlock("save");
185  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
186  $this->tpl->parseCurrentBlock();
187  }
188 
189  $this->tpl->setCurrentBlock("adm_content");
190  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
191  $this->tpl->setVariable("TXT_SURVEY_SETTINGS", $this->lng->txt("advanced_editing_survey_settings"));
192  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
193 
194  $this->tpl->parseCurrentBlock();
195  }
196 
200 /*
201  function learningModuleObject()
202  {
203  global $ilSetting;
204 
205  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_learning_module.html",
206  "Services/AdvancedEditing");
207 
208  $this->tpl->setCurrentBlock("adm_content");
209  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
210  $this->tpl->setVariable("TXT_LM_SETTINGS", $this->lng->txt("advanced_editing_lm_settings"));
211  $this->tpl->setVariable("TXT_LM_JS_EDITING", $this->lng->txt("advanced_editing_lm_js_editing"));
212  $this->tpl->setVariable("TXT_LM_JS_EDITING_DESC", $this->lng->txt("advanced_editing_lm_js_editing_desc"));
213  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
214 
215  if ($ilSetting->get("enable_js_edit", 1))
216  {
217  $this->tpl->setVariable("JS_EDIT", "checked=\"checked\"");
218  }
219 
220  $this->tpl->parseCurrentBlock();
221  }
222 */
226 /*
227  function saveLearningModuleSettingsObject()
228  {
229  global $ilSetting;
230 
231  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
232  $ilSetting->set("enable_js_edit", (int) $_POST["js_edit"]);
233  $this->ctrl->redirect($this, 'learningmodule');
234  }
235 */
240  {
241  if ($_POST["use_tiny"])
242  {
243  $this->object->_setRichTextEditor("tinymce");
244  }
245  else
246  {
247  $this->object->_setRichTextEditor("");
248  }
249  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
250 
251  $this->ctrl->redirect($this,'settings');
252  }
253 
255  {
256  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
257 
258  $this->object->_setUsedHTMLTags($_POST["html_tags"], "assessment");
259  $this->ctrl->redirect($this,'assessment');
260  }
261 
263  {
264  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
265 
266  $this->object->_setUsedHTMLTags($_POST["html_tags"], "survey");
267  $this->ctrl->redirect($this,'survey');
268  }
269 
270  function getAdminTabs(&$tabs_gui)
271  {
272  $this->getTabs($tabs_gui);
273  }
274 
279  {
280  global $tpl, $ilTabs, $ilCtrl;
281 
282  $this->addPageEditorSettingsSubTabs();
283 
284  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
286 
287  $this->cgrp = $_GET["grp"];
288  if ($this->cgrp == "")
289  {
290  $this->cgrp = key($grps);
291  }
292 
293  $ilCtrl->setParameter($this, "grp", $this->cgrp);
294  $ilTabs->setSubTabActive("adve_grp_".$this->cgrp);
295 
296  $this->initPageEditorForm();
297  $tpl->setContent($this->form->getHtml());
298  }
299 
305  public function initPageEditorForm($a_mode = "edit")
306  {
307  global $lng, $ilSetting;
308 
309  $lng->loadLanguageModule("content");
310 
311  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
312  $this->form = new ilPropertyFormGUI();
313 
314  if ($this->cgrp == "rep")
315  {
316  $this->form->setTitle($lng->txt("adve_activation"));
317  $cb = new ilCheckboxInputGUI($this->lng->txt("advanced_editing_rep_page_editing"), "cat_page_edit");
318  $cb->setInfo($this->lng->txt("advanced_editing_rep_page_editing_desc"));
319  if ($ilSetting->get("enable_cat_page_edit"))
320  {
321  $cb->setChecked(true);
322  }
323  $this->form->addItem($cb);
324 
325  $sh = new ilFormSectionHeaderGUI();
326  $sh->setTitle($lng->txt("adve_text_content_features"));
327  $this->form->addItem($sh);
328  }
329  else
330  {
331  $this->form->setTitle($lng->txt("adve_text_content_features"));
332  }
333 
334 
335  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
336 
337  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
339  foreach ($buttons as $b => $t)
340  {
341  // command button activation
342  $cb = new ilCheckboxInputGUI(str_replace(":", "", $this->lng->txt("cont_text_".$b)), "active_".$b);
343  $cb->setChecked(ilPageEditorSettings::lookupSetting($this->cgrp, "active_".$b, true));
344  $this->form->addItem($cb);
345  }
346 
347  // save and cancel commands
348  $this->form->addCommandButton("savePageEditorSettings", $lng->txt("save"));
349 
350  $this->form->setFormAction($this->ctrl->getFormAction($this));
351 
352  }
353 
359  {
360  global $tpl, $lng, $ilCtrl, $ilSetting;
361 
362  $this->initPageEditorForm();
363  if ($this->form->checkInput())
364  {
365  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
366  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
368  foreach ($buttons as $b => $t)
369  {
370  ilPageEditorSettings::writeSetting($_GET["grp"], "active_".$b,
371  $this->form->getInput("active_".$b));
372  }
373 
374  if ($_GET["grp"] == "rep")
375  {
376  $ilSetting->set("enable_cat_page_edit", (int) $_POST["cat_page_edit"]);
377  }
378 
379  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
380  }
381 
382  $ilCtrl->setParameter($this, "grp", $_GET["grp"]);
383  $ilCtrl->redirect($this, "showPageEditorSettings");
384  }
385 
390  {
391  global $tpl, $ilTabs;
392 
393  $this->addPageEditorSettingsSubTabs();
394  $ilTabs->activateTab("adve_page_editor_settings");
395 
396  $form = $this->initGeneralPageSettingsForm();
397  $tpl->setContent($form->getHTML());
398  }
399 
403  public function initGeneralPageSettingsForm()
404  {
405  global $lng, $ilCtrl;
406 
407  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
408  $form = new ilPropertyFormGUI();
409 
410  $aset = new ilSetting("adve");
411 
412  // use physical character styles
413  $cb = new ilCheckboxInputGUI($this->lng->txt("adve_use_physical"), "use_physical");
414  $cb->setInfo($this->lng->txt("adve_use_physical_info"));
415  $cb->setChecked($aset->get("use_physical"));
416  $form->addItem($cb);
417 
418  $form->addCommandButton("saveGeneralPageSettings", $lng->txt("save"));
419 
420  $form->setTitle($lng->txt("adve_pe_general"));
421  $form->setFormAction($ilCtrl->getFormAction($this));
422 
423  return $form;
424  }
425 
430  {
431  global $ilCtrl, $lng;
432 
433  $form = $this->initGeneralPageSettingsForm();
434  if ($form->checkInput())
435  {
436  $aset = new ilSetting("adve");
437  $aset->set("use_physical", $_POST["use_physical"]);
438  }
439  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
440  $ilCtrl->redirect($this, "showGeneralPageEditorSettings");
441  }
442 
446  function addSubtabs(&$tabs_gui)
447  {
448  global $ilCtrl;
449 
450  if ($ilCtrl->getNextClass() != "ilpermissiongui" &&
451  !in_array($ilCtrl->getCmd(), array("showPageEditorSettings",
452  "showGeneralPageEditorSettings", "", "view")))
453  {
454  $tabs_gui->addSubTabTarget("adve_general_settings",
455  $this->ctrl->getLinkTarget($this, "settings"),
456  array("settings", "saveSettings"),
457  "", "");
458  $tabs_gui->addSubTabTarget("adve_assessment_settings",
459  $this->ctrl->getLinkTarget($this, "assessment"),
460  array("assessment", "saveAssessmentSettings"),
461  "", "");
462  $tabs_gui->addSubTabTarget("adve_survey_settings",
463  $this->ctrl->getLinkTarget($this, "survey"),
464  array("survey", "saveSurveySettings"),
465  "", "");
466  /*$tabs_gui->addSubTabTarget("adve_lm_settings",
467  $this->ctrl->getLinkTarget($this, "learningModule"),
468  array("learningModule", "saveLearningModuleSettings"),
469  "", "");*/
470  $tabs_gui->addSubTabTarget("adve_frm_post_settings",
471  $this->ctrl->getLinkTarget($this, "frmPost"),
472  array("frmPost", "saveFrmPostSettings"),
473  "", "");
474  }
475  }
476 
477  public function saveFrmPostSettingsObject()
478  {
479  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
480 
481  try
482  {
483  $this->object->_setUsedHTMLTags((array)$_POST['html_tags'], 'frm_post');
484  }
486  {
487  ilUtil::sendInfo($e->getMessage(), true);
488  }
489 
490  $this->ctrl->redirect($this,'frmPost');
491  }
492 
493  public function frmPostObject()
494  {
495  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.advanced_editing_frm_post.html",
496  "Services/AdvancedEditing");
497 
498  $alltags =& $this->object->getHTMLTags();
499  $usedtags =& $this->object->_getUsedHTMLTags("frm_post");
500  foreach ($alltags as $tag)
501  {
502  $this->tpl->setCurrentBlock("html_tag_row");
503  $this->tpl->setVariable("HTML_TAG", $tag);
504  if (is_array($usedtags))
505  {
506  if (in_array($tag, $usedtags))
507  {
508  $this->tpl->setVariable("HTML_TAG_SELECTED", " selected=\"selected\"");
509  }
510  }
511  $this->tpl->parseCurrentBlock();
512  }
513 
514  $this->tpl->setCurrentBlock("adm_content");
515  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
516  $this->tpl->setVariable("TXT_FRM_POST_SETTINGS", $this->lng->txt("advanced_editing_frm_post_settings"));
517  $this->tpl->setVariable("TXT_ALLOW_HTML_TAGS", $this->lng->txt("advanced_editing_allow_html_tags"));
518  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
519 
520  $this->tpl->parseCurrentBlock();
521  }
522 
523 
528  {
529  global $ilCtrl, $ilTabs;
530 
531  $ilTabs->addSubTabTarget("adve_pe_general",
532  $ilCtrl->getLinkTarget($this, "showGeneralPageEditorSettings"),
533  array("showGeneralPageEditorSettings", "", "view"));
534 
535  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
537 
538  foreach ($grps as $g => $types)
539  {
540  $ilCtrl->setParameter($this, "grp", $g);
541  $ilTabs->addSubTabTarget("adve_grp_".$g,
542  $ilCtrl->getLinkTarget($this, "showPageEditorSettings"),
543  array("showPageEditorSettings"));
544  }
545  $ilCtrl->setParameter($this, "grp", $_GET["grp"]);
546  }
547 
548 
554  function getTabs(&$tabs_gui)
555  {
556  global $rbacsystem;
557 
558  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
559  {
560  $tabs_gui->addTarget("adve_page_editor_settings",
561  $this->ctrl->getLinkTarget($this, "showGeneralPageEditorSettings"),
562  array("showPageEditorSettings", "","view"));
563 
564  $tabs_gui->addTarget("adve_rte_settings",
565  $this->ctrl->getLinkTarget($this, "settings"),
566  array("settings","assessment", "survey", "learningModule",
567  "frmPost"), "", "");
568  }
569 
570  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
571  {
572  $tabs_gui->addTarget("perm_settings",
573  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
574  }
575  $this->addSubtabs($tabs_gui);
576  }
577 } // END class.ilObjAdvancedEditingGUI
578 ?>