ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjContentObjectGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./Services/Object/classes/class.ilObjectGUI.php";
5 include_once "./Modules/LearningModule/classes/class.ilObjContentObject.php";
6 include_once ("./Modules/LearningModule/classes/class.ilLMPageObjectGUI.php");
7 include_once ("./Modules/LearningModule/classes/class.ilStructureObjectGUI.php");
8 require_once 'Services/LinkChecker/interfaces/interface.ilLinkCheckerGUIRowHandling.php';
9 
22 {
23  var $ctrl;
24 
30  function ilObjContentObjectGUI($a_data,$a_id = 0,$a_call_by_reference = true, $a_prepare_output = false)
31  {
32  global $lng, $ilCtrl;
33 //echo "<br>ilobjcontobjgui-constructor-id-$a_id";
34  $this->ctrl =& $ilCtrl;
35  $lng->loadLanguageModule("content");
36  $lng->loadLanguageModule("obj");
37  parent::ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
38  }
39 
43  function &executeCommand()
44  {
45  global $ilAccess, $lng, $ilTabs, $ilCtrl, $ilErr;
46 
47  if ($this->ctrl->getRedirectSource() == "ilinternallinkgui")
48  {
49  $this->explorer();
50  return;
51  }
52 
53  if ($this->ctrl->getCmdClass() == "ilinternallinkgui")
54  {
55  $this->ctrl->setReturn($this, "explorer");
56  }
57 
58  // get next class that processes or forwards current command
59  $next_class = $this->ctrl->getNextClass($this);
60 
61  // get current command
62 // $cmd = $this->ctrl->getCmd("", array("downloadExportFile"));
63  if ($_GET["to_props"] == 1)
64  {
65  $cmd = $this->ctrl->getCmd("properties");
66  }
67  else
68  {
69  $cmd = $this->ctrl->getCmd("chapters");
70  }
71 
72 
73 //echo "-$cmd-".$next_class."-";
74  switch($next_class)
75  {
76  case "illearningprogressgui":
77  $this->addHeaderAction();
78  $this->addLocations();
79  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
80  $this->setTabs("learning_progress");
81 
82  $new_gui =& new ilLearningProgressGUI(ilLearningProgressGUI::LP_CONTEXT_REPOSITORY,$this->object->getRefId());
83  $new_gui->activateStatistics();
84  $this->ctrl->forwardCommand($new_gui);
85 
86  break;
87 
88  case 'ilmdeditorgui':
89  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
90  {
91  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
92  }
93 
94  $this->addHeaderAction();
95  $this->addLocations();
96  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
97  $this->setTabs("meta");
98  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
99  $md_gui->addObserver($this->object,'MDUpdateListener','General');
100 
101  $this->ctrl->forwardCommand($md_gui);
102  break;
103 
104  case "ilobjstylesheetgui":
105  $this->addLocations();
106  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
107  $this->ctrl->setReturn($this, "editStyleProperties");
108  $style_gui =& new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
109  $style_gui->omitLocator();
110  if ($cmd == "create" || $_GET["new_type"]=="sty")
111  {
112  $style_gui->setCreationMode(true);
113  }
114  $ret =& $this->ctrl->forwardCommand($style_gui);
115  //$ret =& $style_gui->executeCommand();
116 
117  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
118  {
119  $style_id = $ret;
120  $this->object->setStyleSheetId($style_id);
121  $this->object->update();
122  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
123  }
124  break;
125 
126  case "illmpageobjectgui":
127 
128  $ilTabs->setBackTarget($lng->txt("learning module"),
129  $ilCtrl->getLinkTarget($this, "chapters"));
130  $this->ctrl->saveParameter($this, array("obj_id"));
131  $this->addLocations();
132  $this->ctrl->setReturn($this, "chapters");
133 //echo "!";
134  //$this->lm_obj =& $this->ilias->obj_factory->getInstanceByRefId($this->ref_id);
135 
136  $pg_gui =& new ilLMPageObjectGUI($this->object);
137  if ($_GET["obj_id"] != "")
138  {
139  $obj =& ilLMObjectFactory::getInstance($this->object, $_GET["obj_id"]);
140  $pg_gui->setLMPageObject($obj);
141  }
142  //$ret =& $pg_gui->executeCommand();
143  $ret =& $this->ctrl->forwardCommand($pg_gui);
144  if ($cmd == "save" || $cmd == "cancel")
145  {
146 // $this->ctrl->redirect($this, "pages");
147  }
148  break;
149 
150  case "ilstructureobjectgui":
151  $ilTabs->setBackTarget($lng->txt("learning module"),
152  $ilCtrl->getLinkTarget($this, "chapters"));
153 
154  $this->ctrl->saveParameter($this, array("obj_id"));
155  $this->addLocations();
156  $this->ctrl->setReturn($this, "chapters");
157  $st_gui =& new ilStructureObjectGUI($this->object, $this->object->lm_tree);
158  if ($_GET["obj_id"] != "")
159  {
160  $obj =& ilLMObjectFactory::getInstance($this->object, $_GET["obj_id"]);
161  $st_gui->setStructureObject($obj);
162  }
163  //$ret =& $st_gui->executeCommand();
164  $ret =& $this->ctrl->forwardCommand($st_gui);
165  if ($cmd == "save" || $cmd == "cancel")
166  {
167  if ($_GET["obj_id"] == "")
168  {
169  $this->ctrl->redirect($this, "chapters");
170  }
171  else
172  {
173  $this->ctrl->setCmd("subchap");
174  $this->executeCommand();
175  }
176  }
177  break;
178 
179  case 'ilpermissiongui':
180  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
181  {
182  $this->prepareOutput();
183  }
184  else
185  {
186  $this->addHeaderAction();
187  $this->addLocations(true);
188  $this->setTabs("perm");
189  }
190  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
191  $perm_gui =& new ilPermissionGUI($this);
192  $ret =& $this->ctrl->forwardCommand($perm_gui);
193  break;
194 
195  // infoscreen
196  case 'ilinfoscreengui':
197  $this->addHeaderAction();
198  $this->addLocations(true);
199  $this->setTabs("info");
200  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
201  $info = new ilInfoScreenGUI($this);
202  $info->enablePrivateNotes();
203  $info->enableLearningProgress();
204 
205  $info->enableNews();
206  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
207  {
208  $info->enableNewsEditing();
209  $info->setBlockProperty("news", "settings", true);
210  }
211 
212  // show standard meta data section
213  $info->addMetaDataSections($this->object->getId(), 0,
214  $this->object->getType());
215 
216  $ret =& $this->ctrl->forwardCommand($info);
217  break;
218 
219  case "ilexportgui":
220  $this->addHeaderAction();
221  $this->addLocations(true);
222  $this->setTabs("export");
223  include_once("./Services/Export/classes/class.ilExportGUI.php");
224  $exp_gui = new ilExportGUI($this);
225  $exp_gui->addFormat("xml", "", $this, "export");
226  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
227  $ot = ilObjectTranslation::getInstance($this->object->getId());
228  if ($ot->getContentActivated())
229  {
230  $lng->loadLanguageModule("meta");
231  $langs = $ot->getLanguages();
232  foreach ($langs as $l => $ldata)
233  {
234  $exp_gui->addFormat("html_".$l, "HTML (".$lng->txt("meta_l_".$l).")", $this, "exportHTML");
235  }
236  }
237  else
238  {
239  $exp_gui->addFormat("html", "", $this, "exportHTML");
240  }
241 
242  $exp_gui->addFormat("scorm", "", $this, "exportSCORM");
243  $exp_gui->addCustomColumn($lng->txt("cont_public_access"),
244  $this, "getPublicAccessColValue");
245  $exp_gui->addCustomMultiCommand($lng->txt("cont_public_access"),
246  $this, "publishExportFile");
247  $ret = $this->ctrl->forwardCommand($exp_gui);
248  break;
249 
250  case 'ilobjecttranslationgui':
251  $this->addHeaderAction();
252  $this->addLocations(true);
253  //$this->checkPermissionBool("write");
254  //$this->prepareOutput();
255  //$this->tabs_gui->setTabActive('export');
256  $this->setTabs("settings");
257  $this->setSubTabs("obj_multilinguality");
258  include_once("./Services/Object/classes/class.ilObjectTranslationGUI.php");
259  $transgui = new ilObjectTranslationGUI($this);
260  $transgui->setTitleDescrOnlyMode(false);
261  $this->ctrl->forwardCommand($transgui);
262  break;
263 
264 
265  case "ilcommonactiondispatchergui":
266  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
268  $this->ctrl->forwardCommand($gui);
269  break;
270 
271 /* case "ilpagemultilanggui":
272  $this->addHeaderAction();
273  $this->addLocations(true);
274  $ilCtrl->setReturn($this, "properties");
275  include_once("./Services/COPage/classes/class.ilPageMultiLangGUI.php");
276  $ml_gui = new ilPageMultiLangGUI("lm", $this->object->getId());
277  $this->setTabs("settings");
278  $this->setSubTabs("cont_multilinguality");
279  $ret = $this->ctrl->forwardCommand($ml_gui);
280  break;*/
281 
282  default:
283  $new_type = $_POST["new_type"]
284  ? $_POST["new_type"]
285  : $_GET["new_type"];
286 
287 
288  if ($cmd == "create" &&
289  !in_array($new_type, array("dbk", "lm")))
290  {
291  //$this->addLocations();
292  switch ($new_type)
293  {
294  case "pg":
295  $this->setTabs();
296  $this->ctrl->setCmdClass("ilLMPageObjectGUI");
297  $ret =& $this->executeCommand();
298  break;
299 
300  case "st":
301  $this->setTabs();
302  $this->ctrl->setCmdClass("ilStructureObjectGUI");
303  $ret =& $this->executeCommand();
304  break;
305  }
306  }
307  else
308  {
309  // creation of new dbk/lm in repository
310  if ($this->getCreationMode() == true &&
311  in_array($new_type, array("dbk", "lm")))
312  {
313  $this->prepareOutput();
314  if ($cmd == "") // this may be due to too big upload files
315  {
316  $cmd = "create";
317  }
318  $cmd .= "Object";
319  $ret =& $this->$cmd();
320  }
321  else
322  {
323  $this->addHeaderAction();
324  $this->addLocations();
325  $ret =& $this->$cmd();
326  }
327  }
328  break;
329  }
330  return $ret;
331  }
332 
333  function _forwards()
334  {
335  return array("ilLMPageObjectGUI", "ilStructureObjectGUI","ilObjStyleSheetGUI");
336  }
337 
341  function properties()
342  {
343  global $lng;
344 
345  $lng->loadLanguageModule("style");
346  $this->setTabs("settings");
347  $this->setSubTabs("cont_general_properties");
348 
349  // lm properties
350  $this->initPropertiesForm();
351  $this->getPropertiesFormValues();
352 
353  if($this->object->getType() == "lm")
354  {
355  // Edit ecs export settings
356  include_once 'Modules/LearningModule/classes/class.ilECSLearningModuleSettings.php';
357  $ecs = new ilECSLearningModuleSettings($this->object);
358  $ecs->addSettingsToForm($this->form, 'lm');
359  }
360 
361  $this->tpl->setContent($this->form->getHTML());
362  }
363 
368  {
369  global $ilCtrl, $lng;
370 
371  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
372  $this->form = new ilPropertyFormGUI();
373 
374  // title
375  $ti = new ilTextInputGUI($lng->txt("title"), "title");
376  //$ti->setMaxLength();
377  //$ti->setSize();
378  //$ti->setInfo($lng->txt(""));
379  $ti->setRequired(true);
380  $this->form->addItem($ti);
381 
382  // description
383  $ta = new ilTextAreaInputGUI($lng->txt("desc"), "description");
384  //$ta->setCols();
385  //$ta->setRows();
386  //$ta->setInfo($lng->txt(""));
387  $this->form->addItem($ta);
388 
389  // online
390  $online = new ilCheckboxInputGUI($lng->txt("cont_online"), "cobj_online");
391  $this->form->addItem($online);
392 
393  // default layout
394  $layout = self::getLayoutOption($lng->txt("cont_def_layout"), "lm_layout");
395  $this->form->addItem($layout);
396 
397  // page header
398  $page_header = new ilSelectInputGUI($lng->txt("cont_page_header"), "lm_pg_header");
399  $option = array ("st_title" => $this->lng->txt("cont_st_title"),
400  "pg_title" => $this->lng->txt("cont_pg_title"),
401  "none" => $this->lng->txt("cont_none"));
402  $page_header->setOptions($option);
403  $this->form->addItem($page_header);
404 
405  // chapter numeration
406  $chap_num = new ilCheckboxInputGUI($lng->txt("cont_act_number"), "cobj_act_number");
407  $this->form->addItem($chap_num);
408 
409  // toc mode
410  $toc_mode = new ilSelectInputGUI($lng->txt("cont_toc_mode"), "toc_mode");
411  $option = array ("chapters" => $this->lng->txt("cont_chapters_only"),
412  "pages" => $this->lng->txt("cont_chapters_and_pages"));
413  $toc_mode->setOptions($option);
414  $this->form->addItem($toc_mode);
415 
416  // public notes
417  if (!$this->ilias->getSetting('disable_comments'))
418  {
419  $this->lng->loadLanguageModule("notes");
420  $pub_nodes = new ilCheckboxInputGUI($lng->txt("notes_comments"), "cobj_pub_notes");
421  $pub_nodes->setInfo($this->lng->txt("cont_lm_comments_desc"));
422  $this->form->addItem($pub_nodes);
423  }
424 
425  // layout per page
426  $lpp = new ilCheckboxInputGUI($lng->txt("cont_layout_per_page"), "layout_per_page");
427  $lpp->setInfo($this->lng->txt("cont_layout_per_page_info"));
428  $this->form->addItem($lpp);
429 
430  // synchronize frames
431  $synch = new ilCheckboxInputGUI($lng->txt("cont_synchronize_frames"), "cobj_clean_frames");
432  $synch->setInfo($this->lng->txt("cont_synchronize_frames_desc"));
433  $this->form->addItem($synch);
434 
435  // history user comments
436  $com = new ilCheckboxInputGUI($lng->txt("enable_hist_user_comments"), "cobj_user_comments");
437  $com->setInfo($this->lng->txt("enable_hist_user_comments_desc"));
438  $this->form->addItem($com);
439 
440  // rating
441  $this->lng->loadLanguageModule('rating');
442  $rate = new ilCheckboxInputGUI($this->lng->txt('rating_activate_rating'), 'rating');
443  $rate->setInfo($this->lng->txt('rating_activate_rating_info'));
444  $this->form->addItem($rate);
445  $ratep = new ilCheckboxInputGUI($this->lng->txt('lm_activate_rating'), 'rating_pages');
446  $this->form->addItem($ratep);
447 
448  // disable default feedback for questions
449  $qfeed = new ilCheckboxInputGUI($lng->txt("cont_disable_def_feedback"), "disable_def_feedback");
450  $qfeed->setInfo($this->lng->txt("cont_disable_def_feedback_info"));
451  $this->form->addItem($qfeed);
452 
453  $this->form->setTitle($lng->txt("cont_general_properties"));
454  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
455  $this->form->setFormAction($ilCtrl->getFormAction($this));
456  }
457 
462  {
463  $values = array();
464 
465  $title = $this->object->getTitle();
466  $description = $this->object->getDescription();
467  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
468  $ot = ilObjectTranslation::getInstance($this->object->getId());
469  if ($ot->getContentActivated())
470  {
471  $title = $ot->getDefaultTitle();
472  $description = $ot->getDefaultDescription();
473  }
474 
475  $values["title"] = $title;
476  $values["description"] = $description;
477  if ($this->object->getOnline())
478  {
479  $values["cobj_online"] = true;
480  }
481  $values["lm_layout"] = $this->object->getLayout();
482  $values["lm_pg_header"] = $this->object->getPageHeader();
483  if ($this->object->isActiveNumbering())
484  {
485  $values["cobj_act_number"] = true;
486  }
487  $values["toc_mode"] = $this->object->getTOCMode();
488  if ($this->object->publicNotes())
489  {
490  $values["cobj_pub_notes"] = true;
491  }
492  if ($this->object->cleanFrames())
493  {
494  $values["cobj_clean_frames"] = true;
495  }
496  if ($this->object->isActiveHistoryUserComments())
497  {
498  $values["cobj_user_comments"] = true;
499  }
500  $values["layout_per_page"] = $this->object->getLayoutPerPage();
501  $values["rating"] = $this->object->hasRating();
502  $values["rating_pages"] = $this->object->hasRatingPages();
503  $values["disable_def_feedback"] = $this->object->getDisableDefaultFeedback();
504 
505  $this->form->setValuesByArray($values);
506  }
507 
511  function saveProperties()
512  {
513  global $lng;
514 
515  $valid = false;
516  $this->initPropertiesForm();
517  if ($this->form->checkInput())
518  {
519  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
520  $ot = ilObjectTranslation::getInstance($this->object->getId());
521  if ($ot->getContentActivated())
522  {
523  $ot->setDefaultTitle($_POST['title']);
524  $ot->setDefaultDescription($_POST['description']);
525  $ot->save();
526  }
527 
528  $this->object->setTitle($_POST['title']);
529  $this->object->setDescription($_POST['description']);
530  $this->object->setLayout($_POST["lm_layout"]);
531  $this->object->setPageHeader($_POST["lm_pg_header"]);
532  $this->object->setTOCMode($_POST["toc_mode"]);
533  $this->object->setOnline($_POST["cobj_online"]);
534  $this->object->setActiveNumbering($_POST["cobj_act_number"]);
535  $this->object->setCleanFrames($_POST["cobj_clean_frames"]);
536  if (!$this->ilias->getSetting('disable_comments'))
537  {
538  $this->object->setPublicNotes($_POST["cobj_pub_notes"]);
539  }
540  $this->object->setHistoryUserComments($_POST["cobj_user_comments"]);
541  $this->object->setLayoutPerPage($_POST["layout_per_page"]);
542  $this->object->setRating($_POST["rating"]);
543  $this->object->setRatingPages($_POST["rating_pages"]);
544  $this->object->setDisableDefaultFeedback((int) $_POST["disable_def_feedback"]);
545  $this->object->updateProperties();
546  $this->object->update();
547 
548  if($this->object->getType() == 'lm')
549  {
550  // Update ecs export settings
551  include_once 'Modules/LearningModule/classes/class.ilECSLearningModuleSettings.php';
552  $ecs = new ilECSLearningModuleSettings($this->object);
553  if($ecs->handleSettingsUpdate())
554  {
555  $valid = true;
556  }
557  }
558  else
559  {
560  $valid = true;
561  }
562  }
563 
564  if($valid)
565  {
566  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
567  $this->ctrl->redirect($this, "properties");
568  }
569  else
570  {
571  $lng->loadLanguageModule("style");
572  $this->setTabs("settings");
573  $this->setSubTabs("cont_general_properties");
574 
575  $this->form->setValuesByPost();
576  $this->tpl->setContent($this->form->getHTML());
577  }
578  }
579 
584  {
585  global $tpl;
586 
587  $this->initStylePropertiesForm();
588  $tpl->setContent($this->form->getHTML());
589  }
590 
595  {
596  global $ilCtrl, $lng, $ilTabs, $ilSetting;
597 
598  $lng->loadLanguageModule("style");
599  $this->setTabs();
600  $ilTabs->setTabActive("settings");
601  $this->setSubTabs("cont_style");
602 
603  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
604  $this->form = new ilPropertyFormGUI();
605 
606  $fixed_style = $ilSetting->get("fixed_content_style_id");
607  $style_id = $this->object->getStyleSheetId();
608 
609  if ($fixed_style > 0)
610  {
611  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
612  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
613  $this->lng->txt("global_fixed").")");
614  $this->form->addItem($st);
615  }
616  else
617  {
618  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
619  $_GET["ref_id"]);
620 
621  $st_styles[0] = $this->lng->txt("default");
622  ksort($st_styles);
623 
624  if ($style_id > 0)
625  {
626  // individual style
627  if (!ilObjStyleSheet::_lookupStandard($style_id))
628  {
629  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
630  $st->setValue(ilObject::_lookupTitle($style_id));
631  $this->form->addItem($st);
632 
633 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
634 
635  // delete command
636  $this->form->addCommandButton("editStyle",
637  $lng->txt("cont_edit_style"));
638  $this->form->addCommandButton("deleteStyle",
639  $lng->txt("cont_delete_style"));
640 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
641  }
642  }
643 
644  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
645  {
646  $style_sel = ilUtil::formSelect ($style_id, "style_id",
647  $st_styles, false, true);
648  $style_sel = new ilSelectInputGUI($lng->txt("cont_current_style"), "style_id");
649  $style_sel->setOptions($st_styles);
650  $style_sel->setValue($style_id);
651  $this->form->addItem($style_sel);
652 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
653  $this->form->addCommandButton("saveStyleSettings",
654  $lng->txt("save"));
655  $this->form->addCommandButton("createStyle",
656  $lng->txt("sty_create_ind_style"));
657  }
658  }
659  $this->form->setTitle($lng->txt("cont_style"));
660  $this->form->setFormAction($ilCtrl->getFormAction($this));
661  }
662 
666  function createStyle()
667  {
668  global $ilCtrl;
669 
670  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
671  }
672 
676  function editStyle()
677  {
678  global $ilCtrl;
679 
680  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
681  }
682 
686  function deleteStyle()
687  {
688  global $ilCtrl;
689 
690  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
691  }
692 
696  function saveStyleSettings()
697  {
698  global $ilSetting;
699 
700  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
701  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
702  || $this->object->getStyleSheetId() == 0))
703  {
704  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
705  $this->object->update();
706  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
707  }
708  $this->ctrl->redirect($this, "editStyleProperties");
709  }
710 
714  public function initMenuForm()
715  {
716  global $lng, $ilCtrl;
717 
718  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
719  $form = new ilPropertyFormGUI();
720 
721  // enable menu
722  $menu = new ilCheckboxInputGUI($this->lng->txt("cont_active"), "cobj_act_lm_menu");
723  $menu->setChecked($this->object->isActiveLMMenu());
724  $form->addItem($menu);
725 
726  // toc
727  $toc = new ilCheckboxInputGUI($this->lng->txt("cont_toc"), "cobj_act_toc");
728  $toc->setChecked($this->object->isActiveTOC());
729  $form->addItem($toc);
730 
731  // print view
732  $print = new ilCheckboxInputGUI($this->lng->txt("cont_print_view"), "cobj_act_print");
733  $print->setChecked($this->object->isActivePrintView());
734  $form->addItem($print);
735 
736  // prevent glossary appendix
737  $glo = new ilCheckboxInputGUI($this->lng->txt("cont_print_view_pre_glo"), "cobj_act_print_prev_glo");
738  $glo->setChecked($this->object->isActivePreventGlossaryAppendix());
739  $print->addSubItem($glo);
740 
741  // hide header and footer in print view
742  $hhfp = new ilCheckboxInputGUI($this->lng->txt("cont_hide_head_foot_print"), "hide_head_foot_print");
743  $hhfp->setChecked($this->object->getHideHeaderFooterPrint());
744  $print->addSubItem($hhfp);
745 
746  // downloads
747  $no_download_file_available =
748  " ".$lng->txt("cont_no_download_file_available").
749  " <a href='".$ilCtrl->getLinkTargetByClass("ilexportgui", "")."'>".$lng->txt("change")."</a>";
750  $types = array("xml", "html", "scorm");
751  foreach($types as $type)
752  {
753  if ($this->object->getPublicExportFile($type) != "")
754  {
755  if (is_file($this->object->getExportDirectory($type)."/".
756  $this->object->getPublicExportFile($type)))
757  {
758  $no_download_file_available = "";
759  }
760  }
761  }
762  $dl = new ilCheckboxInputGUI($this->lng->txt("cont_downloads"), "cobj_act_downloads");
763  $dl->setInfo($this->lng->txt("cont_downloads_desc").$no_download_file_available);
764  $dl->setChecked($this->object->isActiveDownloads());
765  $form->addItem($dl);
766 
767  // downloads in public area
768  $pdl = new ilCheckboxInputGUI($this->lng->txt("cont_downloads_public_desc"), "cobj_act_downloads_public");
769  $pdl->setChecked($this->object->isActiveDownloadsPublic());
770  $dl->addSubItem($pdl);
771 
772  $form->addCommandButton("saveMenuProperties", $lng->txt("save"));
773 
774  $form->setTitle($lng->txt("cont_lm_menu"));
775  $form->setFormAction($ilCtrl->getFormAction($this));
776 
777  return $form;
778  }
779 
784  {
785  global $lng, $ilTabs, $ilCtrl, $tpl, $ilToolbar;
786 
787  $lng->loadLanguageModule("style");
788  $this->setTabs();
789  $ilTabs->setTabActive("settings");
790  $this->setSubTabs("cont_lm_menu");
791 
792  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
793  $ilToolbar->addFormButton($this->lng->txt("add_menu_entry"), "addMenuEntry");
794  $ilToolbar->setCloseFormTag(false);
795 
796  $form = $this->initMenuForm();
797  $form->setOpenTag(false);
798  $form->setCloseTag(false);
799 
800  $this->__initLMMenuEditor();
801  $entries = $this->lmme_obj->getMenuEntries();
802  include_once("./Modules/LearningModule/classes/class.ilLMMenuItemsTableGUI.php");
803  $table = new ilLMMenuItemsTableGUI($this, "editMenuProperties", $this->lmme_obj);
804  $table->setOpenFormTag(false);
805 
806  $tpl->setContent($form->getHTML()."<br />".$table->getHTML());
807  }
808 
813  {
814  global $ilias;
815 
816  $this->object->setActiveLMMenu((int) $_POST["cobj_act_lm_menu"]);
817  $this->object->setActiveTOC((int) $_POST["cobj_act_toc"]);
818  $this->object->setActivePrintView((int) $_POST["cobj_act_print"]);
819  $this->object->setActivePreventGlossaryAppendix((int) $_POST["cobj_act_print_prev_glo"]);
820  $this->object->setHideHeaderFooterPrint((int) $_POST["hide_head_foot_print"]);
821  $this->object->setActiveDownloads((int) $_POST["cobj_act_downloads"]);
822  $this->object->setActiveDownloadsPublic((int) $_POST["cobj_act_downloads_public"]);
823  $this->object->updateProperties();
824 
825  $this->__initLMMenuEditor();
826 //var_dump($_POST["menu_entries"]); exit;
827  $this->lmme_obj->updateActiveStatus($_POST["menu_entries"]);
828 
829  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
830  $this->ctrl->redirect($this, "editMenuProperties");
831  }
832 
836  function explorer()
837  {
838  global $ilUser, $ilias, $ilCtrl;
839 
840  switch ($this->object->getType())
841  {
842  case "lm":
843  $gui_class = "ilobjlearningmodulegui";
844  break;
845 
846  case "dlb":
847  $gui_class = "ilobjdlbookgui";
848  break;
849  }
850 
851  $ilCtrl->setParameterByClass($gui_class, "active_node", $_GET["active_node"]);
852 
853  $this->tpl = new ilTemplate("tpl.main.html", true, true);
854  // get learning module object
855  //$this->lm_obj =& new ilObjLearningModule($this->ref_id, true);
856 
857  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
858 
859  //$this->tpl = new ilTemplate("tpl.explorer.html", false, false);
860  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
861  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
862 
863  require_once ("./Modules/LearningModule/classes/class.ilLMEditorExplorer.php");
864  $exp = new ilLMEditorExplorer($this->ctrl->getLinkTarget($this, "view"),
865  $this->object, $gui_class);
866 
867  $exp->setTargetGet("obj_id");
868  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, "explorer"));
869 
870  if ($_GET["lmmovecopy"] == "1")
871  {
872  $this->proceedDragDrop();
873  }
874 
875 
876  if ($_GET["lmexpand"] == "")
877  {
878  $mtree = new ilTree($this->object->getId());
879  $mtree->setTableNames('lm_tree','lm_data');
880  $mtree->setTreeTablePK("lm_id");
881  $expanded = $mtree->readRootId();
882  }
883  else
884  {
885  $expanded = $_GET["lmexpand"];
886  }
887  if ($_GET["active_node"] != "")
888  {
889  $path = $this->lm_tree->getPathId($_GET["active_node"]);
890  $exp->setForceOpenPath($path);
891 
892  $exp->highlightNode($_GET["active_node"]);
893  }
894  $exp->setExpand($expanded);
895 
896  // build html-output
897  $exp->setOutput(0);
898  $output = $exp->getOutput();
899 
900  // asynchronous output
901  if ($ilCtrl->isAsynch())
902  {
903  echo $output; exit;
904  }
905 
906  include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
907 
908  /*if (ilPageEditorGUI::_doJSEditing())
909  {
910  //$this->tpl->touchBlock("includejavascript");
911 
912  $IDS = "";
913  for ($i=0;$i<count($exp->iconList);$i++)
914  {
915  if ($i>0) $IDS .= ",";
916  $IDS .= "'".$exp->iconList[$i]."'";
917  }
918  $this->tpl->setVariable("ICONIDS",$IDS);
919  //$this->ctrl->setParameter($this, "lmovecopy", 1);
920  $this->tpl->setVariable("TESTPFAD",$this->ctrl->getLinkTarget($this, "explorer")."&lmmovecopy=1");
921  //$this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode");
922  $this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode");
923  }*/
924 
925  $this->tpl->setCurrentBlock("content");
926  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_chap_and_pages"));
927  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
928  $this->tpl->setVariable("EXPLORER",$output);
929  $this->ctrl->setParameter($this, "lmexpand", $_GET["lmexpand"]);
930  $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, "explorer"));
931  $this->tpl->parseCurrentBlock();
932  $this->tpl->show(false);
933  exit;
934  }
935 
939  function popup()
940  {
941  include_once "./Services/COPage/classes/class.ilWysiwygUtil.php";
942  $popup = new ilWysiwygUtil();
943  $popup->show($_GET["ptype"]);
944  exit;
945  }
946 
950  function proceedDragDrop()
951  {
952  global $ilCtrl;
953 
954  $this->object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
955  $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
956  $ilCtrl->redirect($this, "chapters");
957  }
958 
959  protected function initCreationForms($a_new_type)
960  {
961  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
962  self::CFORM_IMPORT => $this->initImportForm());
963 
964  return $forms;
965  }
966 
967  protected function afterSave(ilObject $a_new_object)
968  {
969  $a_new_object->notify("new", $_GET["ref_id"], $_GET["parent_non_rbac_id"],
970  $_GET["ref_id"], $a_new_object->getRefId());
971  $a_new_object->setCleanFrames(true);
972  $a_new_object->update();
973 
974  // create content object tree
975  $a_new_object->createLMTree();
976 
977  // create a first chapter
978  $a_new_object->addFirstChapterAndPage();
979 
980  // always send a message
981  ilUtil::sendSuccess($this->lng->txt($this->type."_added"), true);
982  ilUtil::redirect("ilias.php?ref_id=".$a_new_object->getRefId().
983  "&baseClass=ilLMEditorGUI");
984  }
985 
989  public function initImportForm()
990  {
991  global $lng, $ilCtrl;
992 
993  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
994  $form = new ilPropertyFormGUI();
995 
996  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
997  $this->ctrl->setParameter($this, "new_type", $new_type);
998 
999  $form->setTarget(ilFrameTargetInfo::_getFrame("MainContent"));
1000  $form->setTableWidth("600px");
1001 
1002  // import file
1003  $fi = new ilFileInputGUI($this->lng->txt("file"), "xmldoc");
1004  $fi->setSuffixes(array("zip"));
1005  $fi->setRequired(true);
1006  $fi->setSize(30);
1007  $form->addItem($fi);
1008 
1009  // validation
1010  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_validate_file"), "validate");
1011  $cb->setInfo($this->lng->txt(""));
1012  $form->addItem($cb);
1013 
1014  $form->addCommandButton("importFile", $lng->txt("import"));
1015  $form->addCommandButton("cancel", $lng->txt("cancel"));
1016 
1017  $form->setTitle($this->lng->txt("import_".$new_type));
1018  $form->setFormAction($ilCtrl->getFormAction($this));
1019 
1020  return $form;
1021  }
1022 
1026  function addBibItemObject($a_target = "")
1027  {
1028  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1029  $bib_gui =& new ilBibItemGUI();
1030  $bib_gui->setObject($this->object);
1031  $bibItemName = $_POST["bibItemName"] ? $_POST["bibItemName"] : $_GET["bibItemName"];
1032  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1033  if ($bibItemIndex == "")
1034  $bibItemIndex = 0;
1035  $bibItemPath = $_POST["bibItemPath"] ? $_POST["bibItemPath"] : $_GET["bibItemPath"];
1036  if ($bibItemName != "")
1037  {
1038  $bib_gui->bib_obj->add($bibItemName, $bibItemPath, $bibItemIndex);
1039  $data = $bib_gui->bib_obj->getElement("BibItem");
1040  $bibItemIndex = (count($data) - 1);
1041  }
1042  else
1043  {
1044  ilUtil::sendInfo($this->lng->txt("bibitem_choose_element"), true);
1045  }
1046  if ($a_target == "")
1047  {
1048  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1049  }
1050 
1051  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1052  }
1053 
1057  function addBibItem()
1058  {
1059  $this->setTabs();
1060 
1061  // questionable workaround to make this old stuff work
1062  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1063 
1064  $this->addBibItemObject($this->ctrl->getLinkTarget($this));
1065  }
1066 
1070  function deleteBibItemObject($a_target = "")
1071  {
1072  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1073  $bib_gui =& new ilBibItemGUI();
1074  $bib_gui->setObject($this->object);
1075  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1076  $bib_gui->bib_obj->delete($_GET["bibItemName"], $_GET["bibItemPath"], $bibItemIndex);
1077  if (strpos($bibItemIndex, ",") > 0)
1078  {
1079  $bibItemIndex = substr($bibItemIndex, 0, strpos($bibItemIndex, ","));
1080  }
1081  if ($a_target == "")
1082  {
1083  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1084  }
1085 
1086  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1087  }
1088 
1092  function deleteBibItem()
1093  {
1094  $this->setTabs();
1095 
1096  // questionable workaround to make this old stuff work
1097  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1098 
1099  $this->deleteBibItemObject($this->ctrl->getLinkTarget($this));
1100  }
1101 
1102 
1106  function editBibItemObject($a_target = "")
1107  {
1108  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1109  $bib_gui =& new ilBibItemGUI();
1110  $bib_gui->setObject($this->object);
1111  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1112  $bibItemIndex *= 1;
1113  if ($bibItemIndex < 0)
1114  {
1115  $bibItemIndex = 0;
1116  }
1117  if ($a_target == "")
1118  {
1119  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1120  }
1121 
1122  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1123  }
1124 
1128  function editBibItem()
1129  {
1130  $this->setTabs();
1131 
1132  // questionable workaround to make this old stuff work
1133  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1134 
1135  $this->editBibItemObject($this->ctrl->getLinkTarget($this));
1136  }
1137 
1141  function saveBibItemObject($a_target = "")
1142  {
1143  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1144  $bib_gui =& new ilBibItemGUI();
1145  $bib_gui->setObject($this->object);
1146  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1147  $bibItemIndex *= 1;
1148  if ($bibItemIndex < 0)
1149  {
1150  $bibItemIndex = 0;
1151  }
1152  $bibItemIndex = $bib_gui->save($bibItemIndex);
1153 
1154  if ($a_target == "")
1155  {
1156  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1157  }
1158 
1159  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1160  }
1161 
1165  function saveBibItem()
1166  {
1167  $this->setTabs();
1168 
1169  // questionable workaround to make this old stuff work
1170  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1171 
1172  $this->saveBibItemObject($this->ctrl->getLinkTarget($this));
1173  }
1174 
1180  function exportObject()
1181  {
1182  return;
1183  }
1184 
1190  function importObject()
1191  {
1192  $this->createObject();
1193  return;
1194  }
1195 
1196 
1203  function importFileObject()
1204  {
1205  global $_FILES, $rbacsystem, $ilDB, $tpl;
1206 
1207  include_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
1208 
1209  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
1210  {
1211  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
1212  return;
1213  }
1214 
1215  $form = $this->initImportForm();
1216  if ($form->checkInput())
1217  {
1218  // create and insert object in objecttree
1219  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
1220  $newObj = new ilObjContentObject();
1221  $newObj->setType($_GET["new_type"]);
1222  $newObj->setTitle($_FILES["xmldoc"]["name"]);
1223  $newObj->setDescription("");
1224  $newObj->create(true);
1225  $newObj->createReference();
1226  $newObj->putInTree($_GET["ref_id"]);
1227  $newObj->setPermissions($_GET["ref_id"]);
1228  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
1229 
1230  // create learning module tree
1231  $newObj->createLMTree();
1232 
1233  // import lm from file
1234  $mess = $newObj->importFromZipFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"],
1235  $_POST["validate"]);
1236 
1237  if ($mess == "")
1238  {
1239  ilUtil::sendSuccess($this->lng->txt($this->type."_added"),true);
1240  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1241  "&baseClass=ilLMEditorGUI");
1242  }
1243  else
1244  {
1245  $link = '<a href="'."ilias.php?ref_id=".$newObj->getRefId().
1246  "&baseClass=ilLMEditorGUI".'" target="_top">'.$this->lng->txt("btn_next").'</a>';
1247  $tpl->setContent("<br />".$link."<br /><br />".$mess.$link);
1248  }
1249  }
1250  else
1251  {
1252  $form->setValuesByPost();
1253  $tpl->setContent($form->getHtml());
1254  }
1255  }
1256 
1260  function chapters()
1261  {
1262  global $tree, $lng, $ilCtrl, $ilUser;
1263 
1264  $this->setTabs();
1265  $this->setContentSubTabs("chapters");
1266 
1267  $ilCtrl->setParameter($this, "backcmd", "chapters");
1268 
1269  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1270  $form_gui = new ilChapterHierarchyFormGUI($this->object->getType(), $_GET["transl"]);
1271  $form_gui->setFormAction($ilCtrl->getFormAction($this));
1272  $form_gui->setTitle($this->object->getTitle());
1273  $form_gui->setIcon(ilUtil::getImagePath("icon_lm.png"));
1274  $form_gui->setTree($this->lm_tree);
1275  $form_gui->setMaxDepth(0);
1276  $form_gui->setCurrentTopNodeId($this->tree->getRootId());
1277  $form_gui->addMultiCommand($lng->txt("delete"), "delete");
1278  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
1279  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
1280  if ($this->object->getLayoutPerPage())
1281  {
1282  $form_gui->addMultiCommand($lng->txt("cont_set_layout"), "setPageLayoutInHierarchy");
1283  }
1284  $form_gui->setDragIcon(ilUtil::getImagePath("icon_st_s.png"));
1285  $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
1286  $up_gui = ($this->object->getType() == "dbk")
1287  ? "ilobjdlbookgui"
1288  : "ilobjlearningmodulegui";
1289  $form_gui->setExplorerUpdater("tree", "tree_div",
1290  $ilCtrl->getLinkTargetByClass($up_gui, "explorer", "", true));
1291 
1292  $ctpl = new ilTemplate("tpl.chap_and_pages.html", true, true, "Modules/LearningModule");
1293  $ctpl->setVariable("HIERARCHY_FORM", $form_gui->getHTML());
1294  $ilCtrl->setParameter($this, "obj_id", "");
1295 
1296  $ml_head = self::getMultiLangHeader($this->object->getId(), $this);
1297 
1298  $this->tpl->setContent($ml_head.$ctpl->get());
1299  }
1300 
1307  static function getMultiLangHeader($a_lm_id, $a_gui_class)
1308  {
1309  global $lng, $ilCtrl;
1310 
1311  // multi language
1312  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
1313  $ot = ilObjectTranslation::getInstance($a_lm_id);
1314  //include_once("./Services/COPage/classes/class.ilPageMultiLang.php");
1315  //$ml = new ilPageMultiLang("lm", $a_lm_id);
1316  if ($ot->getContentActivated())
1317  {
1318  $lng->loadLanguageModule("meta");
1319 
1320  // info
1321  include_once("./Services/COPage/classes/class.ilPageMultiLangGUI.php");
1322  $ml_gui = new ilPageMultiLangGUI("lm", $a_lm_id);
1323  $ml_head = $ml_gui->getMultiLangInfo($_GET["transl"]);
1324 
1325  // language switch
1326  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
1327  $list = new ilAdvancedSelectionListGUI();
1328  $list->setListTitle($lng->txt("actions"));
1329  $list->setId("copage_act");
1330  $entries = false;
1331  if (!in_array($_GET["transl"], array("", "-")))
1332  {
1333  $l = $ot->getMasterLanguage();
1334  $list->addItem($lng->txt("cont_edit_language_version").": ".
1335  $lng->txt("meta_l_".$l), "",
1336  $ilCtrl->getLinkTarget($a_gui_class, "editMasterLanguage"));
1337  $entries = true;
1338  }
1339 
1340  foreach ($ot->getLanguages() as $al => $lang)
1341  {
1342  if ($_GET["transl"] != $al &&
1343  $al != $ot->getMasterLanguage())
1344  {
1345  $ilCtrl->setParameter($a_gui_class, "totransl", $al);
1346  $list->addItem($lng->txt("cont_edit_language_version").": ".
1347  $lng->txt("meta_l_".$al), "",
1348  $ilCtrl->getLinkTarget($a_gui_class, "switchToLanguage"));
1349  $ilCtrl->setParameter($a_gui_class, "totransl", $_GET["totransl"]);
1350  }
1351  $entries = true;
1352  }
1353 
1354  if ($entries)
1355  {
1356  $ml_head = '<div class="ilFloatLeft">'.$ml_head.'</div><div style="margin: 5px 0;" class="small ilRight">'.$list->getHTML()."</div>";
1357  }
1358 
1359  }
1360 
1361  return $ml_head;
1362  }
1363 
1364 
1365  /*
1366  * List all pages of learning module
1367  */
1368  function pages()
1369  {
1370  global $tree, $tpl, $ilToolbar, $ilCtrl, $lng;
1371 
1372  $this->setTabs();
1373  $this->setContentSubTabs("pages");
1374 
1375  if (!false)
1376  {
1377  $ilCtrl->setParameter($this, "backcmd", "pages");
1378  $ilCtrl->setParameterByClass("illmpageobjectgui", "new_type", "pg");
1379  $ilToolbar->addButton($lng->txt("pg_add"),
1380  $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "create"));
1381  $ilCtrl->setParameterByClass("illmpageobjectgui", "new_type", "");
1382 
1383  include_once("./Modules/LearningModule/classes/class.ilLMPagesTableGUI.php");
1384  $t = new ilLMPagesTableGUI($this, "pages", $this->object);
1385  $tpl->setContent($t->getHTML());
1386 
1387  return;
1388  }
1389 
1390 
1391  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.all_pages.html", "Modules/LearningModule");
1392  $num = 0;
1393 
1394  $this->tpl->setCurrentBlock("form");
1395  $this->ctrl->setParameter($this, "backcmd", "pages");
1396  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1397  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_pages"));
1398  $this->tpl->setVariable("CONTEXT", $this->lng->txt("cont_usage"));
1399  $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
1400 
1401  $cnt = 0;
1402  $pages = ilLMPageObject::getPageList($this->object->getId());
1403  foreach ($pages as $page)
1404  {
1405  $this->tpl->setCurrentBlock("table_row");
1406 
1407  // check activation
1408  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
1409  $lm_set = new ilSetting("lm");
1410  $active = ilLMPage::_lookupActive($page["obj_id"], $this->object->getType(),
1411  $lm_set->get("time_scheduled_page_activation"));
1412 
1413  // is page scheduled?
1414  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
1415  ilLMPage::_isScheduledActivation($page["obj_id"], $this->object->getType()))
1416  ? "_sc"
1417  : "";
1418 
1419  if (!$active)
1420  {
1421  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg_d".$img_sc.".png"));
1422  $this->tpl->setVariable("IMG_ALT",
1423  $this->lng->txt("cont_page_deactivated"));
1424  }
1425  else
1426  {
1428  $this->object->getType()))
1429  {
1430  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg_del".$img_sc.".png"));
1431  $this->tpl->setVariable("IMG_ALT",
1432  $this->lng->txt("cont_page_deactivated_elements"));
1433  }
1434  else
1435  {
1436  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg".$img_sc.".png"));
1437  $this->tpl->setVariable("IMG_ALT",
1438  $this->lng->txt("pg"));
1439  }
1440  }
1441 
1442  // color changing
1443  $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
1444 
1445  // checkbox
1446  $this->tpl->setVariable("CHECKBOX_ID", $page["obj_id"]);
1447  $this->tpl->setVariable("CSS_ROW", $css_row);
1448 
1449  // link
1450  $this->ctrl->setParameter($this, "backcmd", "");
1451  $this->ctrl->setParameterByClass("ilLMPageObjectGUI", "obj_id", $page["obj_id"]);
1452 //echo "<br>:".$this->ctrl->getLinkTargetByClass("ilLMPageObjectGUI", "view").":";
1453  $this->tpl->setVariable("LINK_TARGET",
1454  $this->ctrl->getLinkTargetByClass("ilLMPageObjectGUI", "edit"));
1455 
1456  // title
1457  $this->tpl->setVariable("TEXT_CONTENT", $page["title"]);
1458 
1459  // context
1460  if ($this->lm_tree->isInTree($page["obj_id"]))
1461  {
1462  $path_str = $this->getContextPath($page["obj_id"]);
1463  }
1464  else
1465  {
1466  $path_str = "---";
1467  }
1468 
1469  // check whether page is header or footer
1470  $add_str = "";
1471  if ($page["obj_id"] == $this->object->getHeaderPage())
1472  {
1473  $add_str = " <b>(".$this->lng->txt("cont_header").")</b>";
1474  }
1475  if ($page["obj_id"] == $this->object->getFooterPage())
1476  {
1477  $add_str = " <b>(".$this->lng->txt("cont_footer").")</b>";
1478  }
1479 
1480  $this->tpl->setVariable("TEXT_CONTEXT", $path_str.$add_str);
1481 
1482 
1483  $this->tpl->parseCurrentBlock();
1484  }
1485  if($cnt == 0)
1486  {
1487  $this->tpl->setCurrentBlock("notfound");
1488  $this->tpl->setVariable("NUM_COLS", 4);
1489  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1490  $this->tpl->parseCurrentBlock();
1491  }
1492  else
1493  {
1494  $acts = array("delete" => "delete", "movePage" => "movePage", "copyPage" => "copyPage",
1495  "selectHeader" => "selectHeader", "selectFooter" => "selectFooter",
1496  "activatePages" => "cont_de_activate");
1498  ilEditClipboard::getAction() == "copy")
1499  {
1500  $acts["pastePage"] = "pastePage";
1501  }
1502 
1503  /*
1504  if (ilEditClipboard::getContentObjectType() == "st")
1505  {
1506  $acts["pasteChapter"] = "pasteChapter";
1507  }*/
1508  $this->tpl->setVariable("NUM_COLS", 4);
1509  $this->showActions($acts);
1510 
1511  // SHOW VALID ACTIONS
1512  /*
1513  $this->tpl->setCurrentBlock("operation_btn");
1514  $this->tpl->setVariable("BTN_NAME", "delete");
1515  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1516  $this->tpl->parseCurrentBlock();*/
1517 
1518  }
1519 
1520  // SHOW POSSIBLE SUB OBJECTS
1521  $this->tpl->setVariable("NUM_COLS", 4);
1522  //$this->showPossibleSubObjects("st");
1523  $subobj = array("pg");
1524  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1525  $this->tpl->setCurrentBlock("add_object");
1526  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1527  $this->tpl->setVariable("BTN_NAME", "create");
1528  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("create"));
1529  $this->tpl->parseCurrentBlock();
1530 
1531 
1532  $this->tpl->setCurrentBlock("form");
1533  $this->tpl->parseCurrentBlock();
1534 
1535  }
1536 
1540  function listLinks()
1541  {
1542  global $tpl;
1543 
1544  $this->setTabs();
1545  $this->setContentSubTabs("internal_links");
1546 
1547  include_once("./Modules/LearningModule/classes/class.ilLinksTableGUI.php");
1548  $table_gui = new ilLinksTableGUI($this, "listLinks",
1549  $this->object->getId(), $this->object->getType());
1550 
1551  $tpl->setContent($table_gui->getHTML());
1552  }
1553 
1557  function showMaintenance()
1558  {
1559  global $tpl, $ilToolbar;
1560 
1561  $this->setTabs();
1562  $this->setContentSubTabs("maintenance");
1563 
1564  $ilToolbar->addButton($this->lng->txt("cont_fix_tree"),
1565  $this->ctrl->getLinkTarget($this, "fixTreeConfirm"));
1566  }
1567 
1571  function activatePages()
1572  {
1573  if (is_array($_POST["id"]))
1574  {
1575  foreach($_POST["id"] as $id)
1576  {
1577  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
1578  $act = ilLMPage::_lookupActive($id, $this->object->getType());
1579  ilLMPage::_writeActive($id, $this->object->getType(), !$act);
1580  }
1581  }
1582 
1583  $this->ctrl->redirect($this, "pages");
1584  }
1585 
1589  function pastePage()
1590  {
1592  {
1593  $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
1594  }
1595 
1596  // paste selected object
1598 
1599  // copy page, if action is copy
1600  if (ilEditClipboard::getAction() == "copy")
1601  {
1602  // check wether page belongs to lm
1604  == $this->object->getID())
1605  {
1606  $lm_page = new ilLMPageObject($this->object, $id);
1607  $new_page =& $lm_page->copy();
1608  $id = $new_page->getId();
1609  }
1610  else
1611  {
1612  // get page from other content object into current content object
1614  $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
1615  $lm_page = new ilLMPageObject($lm_obj, $id);
1616  $copied_nodes = array();
1617  $new_page =& $lm_page->copyToOtherContObject($this->object, $copied_nodes);
1618  $id = $new_page->getId();
1619  ilLMObject::updateInternalLinks($copied_nodes);
1620  }
1621  }
1622 
1623  // cut is not be possible in "all pages" form yet
1624  if (ilEditClipboard::getAction() == "cut")
1625  {
1626  // check wether page belongs not to lm
1628  != $this->object->getID())
1629  {
1631  $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
1632  $lm_page = new ilLMPageObject($lm_obj, $id);
1633  $lm_page->setLMId($this->object->getID());
1634  $lm_page->update();
1635  $page =& $lm_page->getPageObject();
1636  $page->buildDom();
1637  $page->setParentId($this->object->getID());
1638  $page->update();
1639  }
1640  }
1641 
1642 
1644  $this->ctrl->redirect($this, "pages");
1645  }
1646 
1650  function copyPage()
1651  {
1652  global $ilUser;
1653 
1654  if(!isset($_POST["id"]))
1655  {
1656  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1657  }
1658 
1659  $items = ilUtil::stripSlashesArray($_POST["id"]);
1660  ilLMObject::clipboardCopy($this->object->getId(), $items);
1662 
1663  ilUtil::sendInfo($this->lng->txt("cont_selected_items_have_been_copied"), true);
1664 
1665  $this->ctrl->redirect($this, "pages");
1666  }
1667 
1675  function delete($a_parent_subobj_id = 0)
1676  {
1677  if(!isset($_POST["id"]))
1678  {
1679  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1680  }
1681 
1682  if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
1683  {
1684  $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
1685  }
1686 
1687  if ($a_parent_subobj_id == 0)
1688  {
1689  $this->setTabs();
1690  }
1691 
1692  if ($a_parent_subobj_id != 0)
1693  {
1694  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "backcmd", $_GET["backcmd"]);
1695  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $a_parent_subobj_id);
1696  $form_action = $this->ctrl->getFormActionByClass("ilStructureObjectGUI");
1697  }
1698  else
1699  {
1700  $this->ctrl->setParameter($this, "backcmd", $_GET["backcmd"]);
1701  $form_action = $this->ctrl->getFormAction($this);
1702  }
1703 
1704  // display confirmation message
1705  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1706  $cgui = new ilConfirmationGUI();
1707  $cgui->setFormAction($form_action);
1708  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
1709  $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
1710  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
1711 
1712  foreach($_POST["id"] as $id)
1713  {
1714  if ($id != IL_FIRST_NODE)
1715  {
1716  $obj = new ilLMObject($this->object, $id);
1717  $caption = ilUtil::getImageTagByType($obj->getType(), $this->tpl->tplPath).
1718  " ".$obj->getTitle();
1719 
1720  $cgui->addItem("id[]", $id, $caption);
1721  }
1722  }
1723 
1724  $this->tpl->setContent($cgui->getHTML());
1725  }
1726 
1730  function cancelDelete()
1731  {
1732  $this->ctrl->redirect($this, $_GET["backcmd"]);
1733 
1734  }
1735 
1743  function confirmedDelete($a_parent_subobj_id = 0)
1744  {
1745  $tree = new ilTree($this->object->getId());
1746  $tree->setTableNames('lm_tree','lm_data');
1747  $tree->setTreeTablePK("lm_id");
1748 
1749  // check number of objects
1750  if (!$_POST["id"])
1751  {
1752  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1753  }
1754 
1755  // delete all selected objects
1756  foreach ($_POST["id"] as $id)
1757  {
1758  if ($id != IL_FIRST_NODE)
1759  {
1760  $obj =& ilLMObjectFactory::getInstance($this->object, $id, false);
1761  $node_data = $tree->getNodeData($id);
1762  if (is_object($obj))
1763  {
1764  $obj->setLMId($this->object->getId());
1765 
1766  include_once("./Services/History/classes/class.ilHistory.php");
1767  ilHistory::_createEntry($this->object->getId(), "delete_".$obj->getType(),
1768  array(ilLMObject::_lookupTitle($id), $id),
1769  $this->object->getType());
1770 
1771  $obj->delete();
1772  }
1773  if($tree->isInTree($id))
1774  {
1775  $tree->deleteTree($node_data);
1776  }
1777  }
1778  }
1779 
1780  // check the tree
1781  $this->object->checkTree();
1782 
1783  // feedback
1784  ilUtil::sendSuccess($this->lng->txt("info_deleted"),true);
1785 
1786  if ($a_parent_subobj_id == 0)
1787  {
1788  $this->ctrl->redirect($this, $_GET["backcmd"]);
1789  }
1790  }
1791 
1792 
1793 
1800  function getContextPath($a_endnode_id, $a_startnode_id = 1)
1801  {
1802  $path = "";
1803 
1804  $tmpPath = $this->lm_tree->getPathFull($a_endnode_id, $a_startnode_id);
1805 
1806  // count -1, to exclude the learning module itself
1807  for ($i = 1; $i < (count($tmpPath) - 1); $i++)
1808  {
1809  if ($path != "")
1810  {
1811  $path .= " > ";
1812  }
1813 
1814  $path .= $tmpPath[$i]["title"];
1815  }
1816 
1817  return $path;
1818  }
1819 
1820 
1821 
1827  function showActions($a_actions)
1828  {
1829  foreach ($a_actions as $name => $lng)
1830  {
1831  $d[$name] = array("name" => $name, "lng" => $lng);
1832  }
1833 
1834  $notoperations = array();
1835 
1836  $operations = array();
1837 
1838  if (is_array($d))
1839  {
1840  foreach ($d as $row)
1841  {
1842  if (!in_array($row["name"], $notoperations))
1843  {
1844  $operations[] = $row;
1845  }
1846  }
1847  }
1848 
1849  if (count($operations)>0)
1850  {
1851  foreach ($operations as $val)
1852  {
1853  $this->tpl->setCurrentBlock("operation_btn");
1854  $this->tpl->setVariable("BTN_NAME", $val["name"]);
1855  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
1856  $this->tpl->parseCurrentBlock();
1857  }
1858 
1859  $this->tpl->setCurrentBlock("operation");
1860  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.png"));
1861  $this->tpl->parseCurrentBlock();
1862  }
1863  }
1864 
1868  function perm()
1869  {
1870  $this->setTabs();
1871 
1872  $this->setFormAction("addRole", $this->ctrl->getLinkTarget($this, "addRole"));
1873  $this->setFormAction("permSave", $this->ctrl->getLinkTarget($this, "permSave"));
1874  $this->permObject();
1875  }
1876 
1877 
1881  function permSave()
1882  {
1883  $this->setReturnLocation("permSave", $this->ctrl->getLinkTarget($this, "perm"));
1884  $this->permSaveObject();
1885  }
1886 
1890  function info()
1891  {
1892  $this->setTabs();
1893  $this->infoObject();
1894  }
1895 
1896 
1900  function addRole()
1901  {
1902  $this->setReturnLocation("addRole", $this->ctrl->getLinkTarget($this, "perm"));
1903  $this->addRoleObject();
1904  }
1905 
1906 
1910  function owner()
1911  {
1912  $this->setTabs();
1913  $this->ownerObject();
1914  }
1915 
1916 
1920  function view()
1921  {
1922  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
1923  {
1924  $this->prepareOutput();
1926  }
1927  else
1928  {
1929  $this->viewObject();
1930  }
1931  }
1932 
1933 
1937  function moveChapter($a_parent_subobj_id = 0)
1938  {
1939  if(!isset($_POST["id"]))
1940  {
1941  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1942  }
1943 //echo "Hallo::"; exit;
1944  if(count($_POST["id"]) > 1)
1945  {
1946  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1947  }
1948 
1949  if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
1950  {
1951  $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
1952  }
1953 
1954  // SAVE POST VALUES
1955  ilEditClipboard::storeContentObject("st", $_POST["id"][0], "move");
1956 
1957  ilUtil::sendInfo($this->lng->txt("cont_chap_select_target_now"), true);
1958 
1959  if ($a_parent_subobj_id == 0)
1960  {
1961  $this->ctrl->redirect($this, "chapters");
1962  }
1963  }
1964 
1965 
1969  function copyChapter($a_parent_subobj_id = 0)
1970  {
1971  $this->copyItems();
1972  }
1973 
1977  function pasteChapter($a_parent_subobj_id = 0)
1978  {
1979  return $this->insertChapterClip(false);
1980  }
1981 
1985  function movePage()
1986  {
1987  global $ilUser;
1988 
1989  if(!isset($_POST["id"]))
1990  {
1991  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1992  }
1993 
1994  ilUtil::sendInfo($this->lng->txt("cont_selected_items_have_been_cut"), true);
1995 
1996  $items = ilUtil::stripSlashesArray($_POST["id"]);
1997  ilLMObject::clipboardCut($this->object->getId(), $items);
1999 
2000  $this->ctrl->redirect($this, "pages");
2001  }
2002 
2006  function cancel()
2007  {
2008  if ($_GET["new_type"] == "pg")
2009  {
2010  $this->ctrl->redirect($this, "pages");
2011  }
2012  else
2013  {
2014  $this->ctrl->redirect($this, "chapters");
2015  }
2016  }
2017 
2018 
2022  function export()
2023  {
2024  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2025  $cont_exp = new ilContObjectExport($this->object);
2026  $cont_exp->buildExportFile();
2027 // $this->ctrl->redirect($this, "exportList");
2028  }
2029 
2033  function getPublicAccessColValue($a_type, $a_file)
2034  {
2035  global $lng, $ilCtrl;
2036 
2037  $changelink = "<a href='".$ilCtrl->getLinkTarget($this, "editMenuProperties")."'>".$lng->txt("change")."</a>";
2038  if (!$this->object->isActiveLMMenu())
2039  {
2040  $add = "<br />".$lng->txt("cont_download_no_menu")." ".$changelink;
2041  }
2042  else if (!$this->object->isActiveDownloads())
2043  {
2044  $add = "<br />".$lng->txt("cont_download_no_download")." ".$changelink;
2045  }
2046 
2047 
2048  if ($this->object->getPublicExportFile($a_type) == $a_file)
2049  {
2050  return $lng->txt("yes").$add;
2051  }
2052 
2053  return " ";
2054  }
2055 
2056 
2057 
2061  function publishExportFile($a_files)
2062  {
2063  global $ilCtrl;
2064 
2065  if(!isset($a_files))
2066  {
2067  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
2068  }
2069  else
2070  {
2071  foreach ($a_files as $f)
2072  {
2073  $file = explode(":", $f);
2074  $export_dir = $this->object->getExportDirectory($file[0]);
2075 
2076  if ($this->object->getPublicExportFile($file[0]) ==
2077  $file[1])
2078  {
2079  $this->object->setPublicExportFile($file[0], "");
2080  }
2081  else
2082  {
2083  $this->object->setPublicExportFile($file[0], $file[1]);
2084  }
2085  }
2086  $this->object->update();
2087  }
2088  $ilCtrl->redirectByClass("ilexportgui");
2089  }
2090 
2094  function downloadPDFFile()
2095  {
2096  if(!isset($_POST["file"]))
2097  {
2098  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2099  }
2100 
2101  if (count($_POST["file"]) > 1)
2102  {
2103  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2104  }
2105 
2106 
2107  $export_dir = $this->object->getOfflineDirectory();
2108 
2109  $file = basename($_POST["file"][0]);
2110 
2111  ilUtil::deliverFile($export_dir."/".$file, $file);
2112  }
2113 
2114 
2119  function fixTreeConfirm()
2120  {
2121  $this->setTabs();
2122  $this->setContentSubTabs("maintenance");
2123 
2124  // display confirmation message
2125  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2126  $cgui = new ilConfirmationGUI();
2127  $cgui->setFormAction($this->ctrl->getFormAction($this));
2128  $cgui->setHeaderText($this->lng->txt("cont_fix_tree_confirm"));
2129  $cgui->setCancel($this->lng->txt("cancel"), "showMaintenance");
2130  $cgui->setConfirm($this->lng->txt("cont_fix_tree"), "fixTree");
2131 
2132  $this->tpl->setContent($cgui->getHTML());
2133  }
2134 
2138  function fixTree()
2139  {
2140  $this->object->fixTree();
2141  ilUtil::sendSuccess($this->lng->txt("cont_tree_fixed"), true);
2142  $this->ctrl->redirect($this, "showMaintenance");
2143  }
2144 
2148  function setilLMMenu($a_offline = false, $a_export_format = "",
2149  $a_active = "content", $a_use_global_tabs = false, $a_as_subtabs = false,
2150  $a_cur_page = 0)
2151  {
2152  global $ilCtrl,$ilUser, $ilAccess, $ilTabs, $rbacsystem, $ilPluginAdmin, $ilHelp;
2153 
2154  $ilHelp->setScreenIdComponent("lm");
2155 
2156  if ($a_as_subtabs)
2157  {
2158  $addcmd = "addSubTabTarget";
2159  $getcmd = "getSubTabHTML";
2160  }
2161  else
2162  {
2163  $addcmd = "addTarget";
2164  $getcmd = "getHTML";
2165  }
2166 
2167  $active[$a_active] = true;
2168 
2169  if (!$this->object->isActiveLMMenu())
2170  {
2171  return "";
2172  }
2173 
2174  if ($a_use_global_tabs)
2175  {
2176  $tabs_gui = $ilTabs;
2177  }
2178  else
2179  {
2180  $tabs_gui = new ilTabsGUI();
2181  }
2182 
2183  // Determine whether the view of a learning resource should
2184  // be shown in the frameset of ilias, or in a separate window.
2185  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
2186  $showViewInFrameset = true;
2187 
2188  if ($showViewInFrameset && !$a_offline)
2189  {
2190  $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
2191  }
2192  else
2193  {
2194  $buttonTarget = "_top";
2195  }
2196 
2197  if ($a_export_format == "scorm")
2198  {
2199  $buttonTarget = "";
2200  }
2201 
2202  include_once("./Services/Payment/classes/class.ilPaymentObject.php");
2203  $requires_purchase_to_access = ilPaymentObject::_requiresPurchaseToAccess((int)$_GET['ref_id']);
2204 
2205  // content
2206  if (!$a_offline && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2207  {
2208  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2209  $tabs_gui->$addcmd("content",
2210  $ilCtrl->getLinkTargetByClass("illmpresentationgui", "layout"),
2211  "", "", $buttonTarget, $active["content"]);
2212  if ($active["content"])
2213  {
2214  $ilHelp->setScreenId("content");
2215  $ilHelp->setSubScreenId("content");
2216  }
2217  }
2218 
2219  // table of contents
2220  if (!$requires_purchase_to_access && $this->object->isActiveTOC() && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2221  {
2222  if (!$a_offline)
2223  {
2224  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2225  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showTableOfContents");
2226  }
2227  else
2228  {
2229  $link = "./table_of_contents.html";
2230  }
2231 
2232  $tabs_gui->$addcmd("cont_toc", $link,
2233  "", "", $buttonTarget, $active["toc"]);
2234  }
2235 
2236  // print view
2237  if (!$requires_purchase_to_access && $this->object->isActivePrintView() && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2238  {
2239  if (!$a_offline) // has to be implemented for offline mode
2240  {
2241  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2242  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showPrintViewSelection");
2243  $tabs_gui->$addcmd("cont_print_view", $link,
2244  "", "", $buttonTarget, $active["print"]);
2245  }
2246  }
2247 
2248  // download
2249  if (!$requires_purchase_to_access && $ilUser->getId() == ANONYMOUS_USER_ID)
2250  {
2251  $is_public = $this->object->isActiveDownloadsPublic();
2252  }
2253  else if(!$requires_purchase_to_access)
2254  {
2255  $is_public = true;
2256  }
2257 
2258  if (!$requires_purchase_to_access && $this->object->isActiveDownloads() && !$a_offline && $is_public &&
2259  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2260  {
2261  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2262  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showDownloadList");
2263  $tabs_gui->$addcmd("download", $link,
2264  "", "", $buttonTarget, $active["download"]);
2265  }
2266 
2267  // info button
2268  if ($a_export_format != "scorm" && !$a_offline)
2269  {
2270  if (!$a_offline)
2271  {
2272  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2273  $link = $this->ctrl->getLinkTargetByClass(
2274  array("illmpresentationgui", "ilinfoscreengui"), "showSummary");
2275  }
2276  else
2277  {
2278  $link = "./info.html";
2279  }
2280 
2281  $tabs_gui->$addcmd(($requires_purchase_to_access ? 'buy' : 'info_short'), $link,
2282  "", "", $buttonTarget, $active["info"]);
2283  }
2284 
2285  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
2286  if(!$a_offline &&
2287  $ilAccess->checkAccess("read", "", $_GET["ref_id"]) && // #14075
2288  ilLearningProgressAccess::checkAccess($_GET["ref_id"]))
2289  {
2290  include_once './Services/Object/classes/class.ilObjectLP.php';
2291  $olp = ilObjectLP::getInstance($this->object->getId());
2292  if($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL)
2293  {
2294  $tabs_gui->$addcmd("learning_progress",
2295  $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "editmanual"),
2296  "", "", $buttonTarget, $active["learning_progress"]);
2297  }
2298  else if($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT)
2299  {
2300  $tabs_gui->$addcmd("learning_progress",
2301  $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "showtlt"),
2302  "", "", $buttonTarget, $active["learning_progress"]);
2303  }
2304  }
2305 
2306  // edit learning module
2307  if (!$a_offline && $a_cur_page > 0)
2308  {
2309  if ($rbacsystem->checkAccess("write", $_GET["ref_id"]))
2310  {
2311  //$page_id = $this->getCurrentPageId();
2312  $page_id = $a_cur_page;
2313  $tabs_gui->$addcmd("edit_page", ILIAS_HTTP_PATH."/ilias.php?baseClass=ilLMEditorGUI&ref_id=".$_GET["ref_id"].
2314  "&obj_id=".$page_id."&to_page=1",
2315  "", "", $buttonTarget, $active["edit_page"]);
2316  }
2317  }
2318 
2319  if(!$requires_purchase_to_access)
2320  {
2321  // get user defined menu entries
2322  $this->__initLMMenuEditor();
2323  $entries = $this->lmme_obj->getMenuEntries(true);
2324 
2325  if (count($entries) > 0 && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2326  {
2327  foreach ($entries as $entry)
2328  {
2329  // build goto-link for internal resources
2330  if ($entry["type"] == "intern")
2331  {
2332  $entry["link"] = ILIAS_HTTP_PATH."/goto.php?target=".$entry["link"];
2333  }
2334 
2335  // add http:// prefix if not exist
2336  if (!strstr($entry["link"],'://') && !strstr($entry["link"],'mailto:'))
2337  {
2338  $entry["link"] = "http://".$entry["link"];
2339  }
2340 
2341  if (!strstr($entry["link"],'mailto:'))
2342  {
2343  $entry["link"] = ilUtil::appendUrlParameterString($entry["link"], "ref_id=".$this->ref_id."&structure_id=".$this->obj_id);
2344  }
2345  $tabs_gui->$addcmd($entry["title"],
2346  $entry["link"],
2347  "", "", "_blank", "", true);
2348  }
2349  }
2350  }
2351 
2352  // user interface hook [uihk]
2353  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
2354  $plugin_html = false;
2355  foreach ($pl_names as $pl)
2356  {
2357  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
2358  $gui_class = $ui_plugin->getUIClassInstance();
2359  $resp = $gui_class->modifyGUI("Modules/LearningModule", "lm_menu_tabs",
2360  array("lm_menu_tabs" => $tabs_gui));
2361  }
2362 
2363 
2364  return $tabs_gui->$getcmd();
2365  }
2366 
2370  function createPDF()
2371  {
2372  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2373  $cont_exp = new ilContObjectExport($this->object, "pdf");
2374  $cont_exp->buildExportFile();
2375  $this->offlineList();
2376  }
2377 
2381  function exportHTML()
2382  {
2383  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
2384  $ot = ilObjectTranslation::getInstance($this->object->getId());
2385  $lang = "";
2386  if ($ot->getContentActivated())
2387  {
2388  $format = explode("_", $_POST["format"]);
2389  $lang = ilUtil::stripSlashes($format[1]);
2390  }
2391  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2392  $cont_exp = new ilContObjectExport($this->object, "html", $lang);
2393  $cont_exp->buildExportFile();
2394 //echo $this->tpl->get();
2395 // $this->ctrl->redirect($this, "exportList");
2396  }
2397 
2401  function exportSCORM()
2402  {
2403  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2404  $cont_exp = new ilContObjectExport($this->object, "scorm");
2405  $cont_exp->buildExportFile();
2406 //echo $this->tpl->get();
2407 // $this->ctrl->redirect($this, "exportList");
2408  }
2409 
2415  function addLocations($a_omit_obj_id = false)
2416  {
2417  global $lng, $tree, $ilLocator, $ilCtrl;
2418 
2419  $par_id = $tree->getParentId($_GET["ref_id"]);
2420  $parent_title = ilObject::_lookupTitle(ilObject::_lookupObjId($par_id));
2421 
2422  // parent is not root folder, "shorten" locator
2423  if($par_id != ROOT_FOLDER_ID)
2424  {
2425  $this->ctrl->addLocation("...",
2426  "");
2427  }
2428  else
2429  {
2430  // if parent is root folder and has no custom title
2431  // we adapt it [see $ilLocator->addRepositoryItems()]
2432  if ($parent_title == "ILIAS")
2433  {
2434  $parent_title = $lng->txt("repository");
2435  }
2436  }
2437 
2438  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $par_id);
2439  $this->ctrl->addLocation($parent_title,
2440  $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"),
2441  ilFrameTargetInfo::_getFrame("MainContent"), $par_id);
2442  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
2443 
2444  if (!$a_omit_obj_id)
2445  {
2446  $obj_id = $_GET["obj_id"];
2447  }
2448  $lmtree =& $this->object->getTree();
2449 
2450  if (($obj_id != 0) && $lmtree->isInTree($obj_id))
2451  {
2452  $path = $lmtree->getPathFull($obj_id);
2453  }
2454  else
2455  {
2456  $path = $lmtree->getPathFull($lmtree->getRootId());
2457  if ($obj_id != 0)
2458  {
2459  $path[] = array("type" => "pg", "child" => $this->obj_id,
2460  "title" => ilLMPageObject::_getPresentationTitle($this->obj_id));
2461  }
2462  }
2463 
2464  $modifier = 1;
2465 
2466  foreach ($path as $key => $row)
2467  {
2468  if ($row["child"] == 1)
2469  {
2470  $this->ctrl->setParameter($this, "obj_id", "");
2471  $this->ctrl->addLocation(
2472  $this->object->getTitle(),
2473  $this->ctrl->getLinkTarget($this, "chapters"), "", $_GET["ref_id"]);
2474  }
2475  else
2476  {
2477  $title = $row["title"];
2478  switch($row["type"])
2479  {
2480  case "st":
2481  $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $row["child"]);
2482  $this->ctrl->addLocation(
2483  $title,
2484  $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view"));
2485  break;
2486 
2487  case "pg":
2488  $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $row["child"]);
2489  $this->ctrl->addLocation(
2490  $title,
2491  $this->ctrl->getLinkTargetByClass("illmpageobjectgui", "edit"));
2492  break;
2493  }
2494  }
2495  }
2496  if (!$a_omit_obj_id)
2497  {
2498  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
2499  }
2500  }
2501 
2505 
2506 
2513  function listQuestions()
2514  {
2515  global $tpl;
2516 
2517  $this->setTabs();
2518  $this->setContentSubTabs("export_ids");
2519 
2520  include_once("./Modules/LearningModule/classes/class.ilLMQuestionListTableGUI.php");
2521  $table = new ilLMQuestionListTableGUI($this, "listQuestions", $this->object);
2522  $tpl->setContent($table->getHTML());
2523 
2524  }
2525 
2529 
2530 
2534  function setTabs($a_act = "")
2535  {
2536  global $lng, $ilHelp;
2537 
2538  $ilHelp->setScreenIdComponent("lm");
2539 
2540  $this->addTabs($a_act);
2541  $this->tpl->setTitle($this->object->getTitle());
2542  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.png"),
2543  $lng->txt("obj_lm"));
2544  }
2545 
2552  function setContentSubTabs($a_active)
2553  {
2554  global $ilTabs, $lng, $ilCtrl;
2555 
2556  $lm_set = new ilSetting("lm");
2557 
2558  // chapters
2559  $ilTabs->addSubtab("chapters",
2560  $lng->txt("cont_chapters"),
2561  $ilCtrl->getLinkTarget($this, "chapters"));
2562 
2563  // all pages
2564  $ilTabs->addSubtab("pages",
2565  $lng->txt("cont_all_pages"),
2566  $ilCtrl->getLinkTarget($this, "pages"));
2567 
2568  // questions
2569  $ilTabs->addSubtab("questions",
2570  $lng->txt("objs_qst"),
2571  $ilCtrl->getLinkTarget($this, "listQuestions"));
2572 
2573  // export ids
2574  if ($lm_set->get("html_export_ids"))
2575  {
2576  if (!ilObjContentObject::isOnlineHelpModule($this->object->getRefId()))
2577  {
2578  $ilTabs->addSubtab("export_ids",
2579  $lng->txt("cont_html_export_ids"),
2580  $ilCtrl->getLinkTarget($this, "showExportIDsOverview"));
2581  }
2582  }
2583  if (ilObjContentObject::isOnlineHelpModule($this->object->getRefId()))
2584  {
2585  $lng->loadLanguageModule("help");
2586  $ilTabs->addSubtab("export_ids",
2587  $lng->txt("cont_online_help_ids"),
2588  $ilCtrl->getLinkTarget($this, "showExportIDsOverview"));
2589 
2590  $ilTabs->addSubtab("help_tooltips",
2591  $lng->txt("help_tooltips"),
2592  $ilCtrl->getLinkTarget($this, "showTooltipList"));
2593  }
2594 
2595  // list links
2596  $ilTabs->addSubtab("internal_links",
2597  $lng->txt("cont_internal_links"),
2598  $ilCtrl->getLinkTarget($this, "listLinks"));
2599 
2600  // web link checker
2601  if ($this->object->getType() == "lm")
2602  {
2603  if(@include_once('HTTP/Request.php'))
2604  {
2605  $ilTabs->addSubtab("link_check",
2606  $lng->txt("link_check"),
2607  $ilCtrl->getLinkTarget($this, "linkChecker"));
2608  }
2609  }
2610 
2611  // maintenance
2612  $ilTabs->addSubtab("maintenance",
2613  $lng->txt("cont_maintenance"),
2614  $ilCtrl->getLinkTarget($this, "showMaintenance"));
2615 
2616  $ilTabs->activateSubTab($a_active);
2617  $ilTabs->activateTab("content");
2618  }
2619 
2623  function addTabs($a_act = "")
2624  {
2625  global $rbacsystem, $ilUser, $ilTabs, $lng;
2626 
2627 $tabs_gui = $ilTabs;
2628 
2629  // content
2630  $ilTabs->addTab("content",
2631  $lng->txt("content"),
2632  $this->ctrl->getLinkTarget($this, "chapters"));
2633 
2634  // info
2635  $ilTabs->addTab("info",
2636  $lng->txt("info_short"),
2637  $this->ctrl->getLinkTargetByClass("ilinfoscreengui",'showSummary'));
2638 
2639  // settings
2640  $ilTabs->addTab("settings",
2641  $lng->txt("settings"),
2642  $this->ctrl->getLinkTarget($this,'properties'));
2643 
2644 
2645  // learning progress
2646  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
2647  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()) and ($this->object->getType() == 'lm' or $this->object->getType() == 'dbk'))
2648  {
2649  $ilTabs->addTab('learning_progress',
2650  $lng->txt("learning_progress"),
2651  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''));
2652  }
2653 
2654  if ($this->object->getType() != "lm")
2655  {
2656  // bibliographical data
2657  $ilTabs->addTab("bib_data",
2658  $lng->txt("bib_data"),
2659  $this->ctrl->getLinkTarget($this, "editBibItem"));
2660  }
2661 
2662  // history
2663  $ilTabs->addTab("history",
2664  $lng->txt("history"),
2665  $this->ctrl->getLinkTarget($this, "history"));
2666 
2667  // meta data
2668  $ilTabs->addTab("meta",
2669  $lng->txt("meta_data"),
2670  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''));
2671 
2672  if ($this->object->getType() == "lm")
2673  {
2674  // export
2675  $ilTabs->addTab("export",
2676  $lng->txt("export"),
2677  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
2678  }
2679 
2680  // permissions
2681  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
2682  {
2683  $ilTabs->addTab("perm",
2684  $lng->txt("perm_settings"),
2685  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"));
2686  }
2687 
2688  if ($a_act != "")
2689  {
2690  $ilTabs->activateTab($a_act);
2691  }
2692 
2693  // presentation view
2694  $ilTabs->addNonTabbedLink("pres_mode", $lng->txt("cont_presentation_view"),
2695  "ilias.php?baseClass=ilLMPresentationGUI&ref_id=".$this->object->getRefID(), "_top");
2696  }
2697 
2701  function setSubTabs($a_active)
2702  {
2703  global $ilTabs, $ilSetting;
2704 
2705  if (in_array($a_active,
2706  array("cont_general_properties", "cont_style", "cont_lm_menu", "public_section",
2707  "cont_glossaries", "cont_multilinguality", "obj_multilinguality")))
2708  {
2709  // general properties
2710  $ilTabs->addSubTabTarget("cont_general_properties",
2711  $this->ctrl->getLinkTarget($this, 'properties'),
2712  "", "");
2713 
2714  // style properties
2715  $ilTabs->addSubTabTarget("cont_style",
2716  $this->ctrl->getLinkTarget($this, 'editStyleProperties'),
2717  "", "");
2718 
2719  // menu properties
2720  $ilTabs->addSubTabTarget("cont_lm_menu",
2721  $this->ctrl->getLinkTarget($this, 'editMenuProperties'),
2722  "", "");
2723 
2724  // glossaries
2725  $ilTabs->addSubTabTarget("cont_glossaries",
2726  $this->ctrl->getLinkTarget($this, 'editGlossaries'),
2727  "", "");
2728 
2729  if ($ilSetting->get("pub_section"))
2730  {
2731  if ($this->object->getType() != "dbk")
2732  {
2733  // public section
2734  $ilTabs->addSubTabTarget("public_section",
2735  $this->ctrl->getLinkTarget($this, 'editPublicSection'),
2736  "", "");
2737  }
2738  }
2739 
2740  // multilinguality
2741  /* $ilTabs->addSubTabTarget("cont_multilinguality",
2742  $this->ctrl->getLinkTargetByClass("ilPageMultiLangGUI", ''),
2743  "", "");*/
2744 
2745  $ilTabs->addSubTabTarget("obj_multilinguality",
2746  $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", ""));
2747 
2748  $ilTabs->setSubTabActive($a_active);
2749  }
2750  }
2751 
2753  {
2754  global $ilTabs, $ilToobar, $ilAccess;
2755 
2756 
2757  if (!$ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, "read", "", $this->object->getRefId()))
2758  {
2759  ilUtil::sendInfo($this->lng->txt("cont_anonymous_user_missing_perm"));
2760  }
2761 
2762  $this->setTabs();
2763  $this->setSubTabs("public_section");
2764  $ilTabs->setTabActive("settings");
2765 
2766  switch ($this->object->getType())
2767  {
2768  case "lm":
2769  $gui_class = "ilobjlearningmodulegui";
2770  break;
2771 
2772  case "dlb":
2773  $gui_class = "ilobjdlbookgui";
2774  break;
2775  }
2776 
2777  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_public_selector.html",
2778  "Modules/LearningModule");
2779 
2780  // get learning module object
2781  $this->lm_obj = new ilObjLearningModule($this->ref_id, true);
2782 
2783  // public mode
2784  $my_toolbar = new ilToolbarGUI();
2785  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
2786  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
2787  $si = new ilSelectInputGUI($this->lng->txt("choose_public_mode"), "lm_public_mode");
2788  $si->setOptions($modes);
2789  $si->setValue($this->object->getPublicAccessMode());
2790  $my_toolbar->addInputItem($si, true);
2791  $my_toolbar->setOpenFormTag(false);
2792  $my_toolbar->setCloseFormTag(false);
2793  $my_toolbar->addFormButton($this->lng->txt("save"), "savePublicSection");
2794  $this->tpl->setVariable("TOOLBAR", $my_toolbar->getHTML());
2795  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
2796 
2797  if ($this->object->getPublicAccessMode() == "selected")
2798  {
2799  $this->tpl->setCurrentBlock("select_pages");
2800  require_once ("./Modules/LearningModule/classes/class.ilPublicSectionSelector.php");
2801  $exp = new ilPublicSectionSelector($this->ctrl->getLinkTarget($this, "view"),
2802  $this->object, $gui_class);
2803 
2804  $exp->setTargetGet("obj_id");
2805 
2806  // build html-output
2807  $exp->setOutput(0);
2808  $output = $exp->getOutput();
2809 
2810  // get page ids
2811  foreach ($exp->format_options as $node)
2812  {
2813  if (!$node["container"])
2814  {
2815  $pages[] = $node["child"];
2816  }
2817  }
2818 
2819  $js_pages = ilUtil::array_php2js($pages);
2820  $this->tpl->setVariable("EXPLORER",$output);
2821  $this->tpl->setVariable("ONCLICK",$js_pages);
2822  $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
2823  $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
2824  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2825 
2826  $this->tpl->parseCurrentBlock();
2827  }
2828  }
2829 
2831  {
2832  //var_dump($_POST["lm_public_mode"]);exit;
2833  $this->object->setPublicAccessMode($_POST["lm_public_mode"]);
2834  $this->object->updateProperties();
2835  ilLMObject::_writePublicAccessStatus($_POST["pages"],$this->object->getId());
2836  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2837  $this->ctrl->redirect($this, "editPublicSection");
2838  }
2839 
2845  function history()
2846  {
2847  $this->setTabs("history");
2848 
2849  require_once("./Services/History/classes/class.ilHistoryGUI.php");
2850  $hist_gui =& new ilHistoryGUI($this->object->getId() ,
2851  $this->object->getType());
2852  $hist_html = $hist_gui->getHistoryTable(
2853  $this->ctrl->getParameterArray($this, "history"),
2854  $this->object->isActiveHistoryUserComments()
2855  );
2856 
2857  $this->tpl->setVariable("ADM_CONTENT", $hist_html);
2858  }
2859 
2868  public function formatInvalidLinkArray(Array $row)
2869  {
2870  $row['title'] = ilLMPageObject::_getPresentationTitle($row['page_id'], $this->object->getPageHeader());
2871 
2872  require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
2874  $actions->setSelectionHeaderClass('small');
2875  $actions->setItemLinkClass('xsmall');
2876  $actions->setListTitle($this->lng->txt('actions'));
2877  $actions->setId($row['page_id']);
2878  $this->ctrl->setParameterByClass('ilLMPageObjectGUI', 'obj_id', $row['page_id']);
2879  $actions->addItem(
2880  $this->lng->txt('edit'),
2881  '',
2882  $this->ctrl->getLinkTargetByClass('ilLMPageObjectGUI', 'edit')
2883  );
2884  $this->ctrl->clearParametersByClass('ilLMPageObjectGUI');
2885  $row['action_html'] = $actions->getHTML();
2886 
2887  return $row;
2888  }
2889 
2890  function linkChecker()
2891  {
2892  global $ilias, $ilUser, $tpl;
2893 
2894  $this->__initLinkChecker();
2895 
2896  $this->setTabs();
2897  $this->setContentSubTabs("link_check");
2898 
2899  require_once './Services/LinkChecker/classes/class.ilLinkCheckerTableGUI.php';
2900 
2901  $toolbar = new ilToolbarGUI();
2902 
2903  // #13684
2904  include_once "Services/Cron/classes/class.ilCronManager.php";
2905  if(ilCronManager::isJobActive("lm_link_check"))
2906  {
2907  include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
2908  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
2909 
2910  $chb = new ilCheckboxInputGUI($this->lng->txt('link_check_message_a'), 'link_check_message');
2911  $chb->setValue(1);
2912  $chb->setChecked((bool)ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(),$this->object->getId()));
2913  $chb->setOptionTitle($this->lng->txt('link_check_message_b'));
2914 
2915  $toolbar->addInputItem($chb);
2916  $toolbar->addFormButton($this->lng->txt('save'), 'saveLinkCheck');
2917  $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'saveLinkCheck'));
2918  }
2919 
2920  $tgui = new ilLinkCheckerTableGUI($this, 'linkChecker');
2921  $tgui->setLinkChecker($this->link_checker_obj)
2922  ->setRowHandler($this)
2923  ->setRefreshButton($this->lng->txt('refresh'), 'refreshLinkCheck');
2924 
2925  return $tpl->setContent($tgui->prepareHTML()->getHTML().$toolbar->getHTML());
2926  }
2927 
2928  function saveLinkCheck()
2929  {
2930  global $ilDB,$ilUser;
2931 
2932  include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
2933 
2934  $link_check_notify =& new ilLinkCheckNotify($ilDB);
2935  $link_check_notify->setUserId($ilUser->getId());
2936  $link_check_notify->setObjId($this->object->getId());
2937 
2938  if($_POST['link_check_message'])
2939  {
2940  ilUtil::sendSuccess($this->lng->txt('link_check_message_enabled'));
2941  $link_check_notify->addNotifier();
2942  }
2943  else
2944  {
2945  ilUtil::sendSuccess($this->lng->txt('link_check_message_disabled'));
2946  $link_check_notify->deleteNotifier();
2947  }
2948  $this->linkChecker();
2949 
2950  return true;
2951  }
2952 
2953 
2954 
2955  function refreshLinkCheck()
2956  {
2957  $this->__initLinkChecker();
2958 
2959  if(!$this->link_checker_obj->checkPear())
2960  {
2961  ilUtil::sendFailure($this->lng->txt('missing_pear_library'));
2962  $this->linkChecker();
2963 
2964  return false;
2965  }
2966 
2967  $this->link_checker_obj->checkLinks();
2968  ilUtil::sendSuccess($this->lng->txt('link_checker_refreshed'));
2969 
2970  $this->linkChecker();
2971 
2972  return true;
2973  }
2974 
2976  {
2977  global $ilDB;
2978 
2979  include_once './Services/LinkChecker/classes/class.ilLinkChecker.php';
2980 
2981  $this->link_checker_obj =& new ilLinkChecker($ilDB,false);
2982  $this->link_checker_obj->setObjId($this->object->getId());
2983 
2984  return true;
2985  }
2986 
2988  {
2989  include_once './Modules/LearningModule/classes/class.ilLMMenuEditor.php';
2990 
2991  $this->lmme_obj =& new ilLMMenuEditor();
2992  $this->lmme_obj->setObjId($this->object->getId());
2993 
2994  return true;
2995  }
2996 
3000  function addMenuEntry()
3001  {
3002  global $ilTabs, $ilToolbar, $tpl, $ilCtrl;
3003 
3004  $this->setTabs();
3005 
3006  $ilTabs->setTabActive("settings");
3007  $this->setSubTabs("cont_lm_menu");
3008 
3009  $ilToolbar->addButton($this->lng->txt("lm_menu_select_internal_object"),
3010  $ilCtrl->getLinkTarget($this, "showEntrySelector"));
3011 
3012  $form = $this->initMenuEntryForm("create");
3013  $this->tpl->setContent($form->getHTML());
3014  }
3015 
3021  public function initMenuEntryForm($a_mode = "edit")
3022  {
3023  global $lng, $ilCtrl;
3024 
3025  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3026  $form = new ilPropertyFormGUI();
3027 
3028  // title
3029  $ti = new ilTextInputGUI($this->lng->txt("lm_menu_entry_title"), "title");
3030  $ti->setMaxLength(255);
3031  $ti->setSize(40);
3032  $form->addItem($ti);
3033 
3034  // target
3035  $ta = new ilTextInputGUI($this->lng->txt("lm_menu_entry_target"), "target");
3036  $ta->setMaxLength(255);
3037  $ta->setSize(40);
3038  $form->addItem($ta);
3039 
3040  if ($a_mode == "edit")
3041  {
3042  $this->__initLMMenuEditor();
3043  $this->lmme_obj->readEntry($_REQUEST["menu_entry"]);
3044  $ti->setValue($this->lmme_obj->getTitle());
3045  $ta->setValue($this->lmme_obj->getTarget());
3046  }
3047 
3048  if (isset($_GET["link_ref_id"]))
3049  {
3050  $link_ref_id = (int) $_GET["link_ref_id"];
3051  $obj_type = ilObject::_lookupType($link_ref_id,true);
3052  $obj_id = ilObject::_lookupObjectId($link_ref_id);
3053  $title = ilObject::_lookupTitle($obj_id);
3054 
3055  $target_link = $obj_type."_".$link_ref_id;
3056  $ti->setValue($title);
3057  $ta->setValue($target_link);
3058 
3059  // link ref id
3060  $hi = new ilHiddenInputGUI("link_ref_id");
3061  $hi->setValue($link_ref_id);
3062  $form->addItem($hi);
3063  }
3064 
3065 
3066  // save and cancel commands
3067  if ($a_mode == "create")
3068  {
3069  $form->addCommandButton("saveMenuEntry", $lng->txt("save"));
3070  $form->addCommandButton("editMenuProperties", $lng->txt("cancel"));
3071  $form->setTitle($lng->txt("lm_menu_new_entry"));
3072  }
3073  else
3074  {
3075  $form->addCommandButton("updateMenuEntry", $lng->txt("save"));
3076  $form->addCommandButton("editMenuProperties", $lng->txt("cancel"));
3077  $form->setTitle($lng->txt("lm_menu_edit_entry"));
3078  }
3079 
3080  $form->setFormAction($ilCtrl->getFormAction($this));
3081 
3082  return $form;
3083  }
3084 
3088  function saveMenuEntry()
3089  {
3090  global $ilCtrl;
3091 
3092  // check title and target
3093  if (empty($_POST["title"]))
3094  {
3095  //$this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
3096  ilUtil::sendFailure($this->lng->txt("please_enter_title") , true);
3097  $ilCtrl->redirect($this, "addMenuEntry");
3098  }
3099  if (empty($_POST["target"]))
3100  {
3101  //$this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
3102  ilUtil::sendFailure($this->lng->txt("please_enter_target"), true);
3103  $ilCtrl->redirect($this, "addMenuEntry");
3104  }
3105 
3106  $this->__initLMMenuEditor();
3107  $this->lmme_obj->setTitle($_POST["title"]);
3108  $this->lmme_obj->setTarget($_POST["target"]);
3109  $this->lmme_obj->setLinkRefId($_POST["link_ref_id"]);
3110 
3111  if ($_POST["link_ref_id"])
3112  {
3113  $this->lmme_obj->setLinkType("intern");
3114  }
3115 
3116  $this->lmme_obj->create();
3117 
3118  ilUtil::sendSuccess($this->lng->txt("msg_entry_added"), true);
3119  $this->ctrl->redirect($this, "editMenuProperties");
3120  }
3121 
3125  function deleteMenuEntry()
3126  {
3127  if (empty($_GET["menu_entry"]))
3128  {
3129  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3130  }
3131 
3132  $this->__initLMMenuEditor();
3133  $this->lmme_obj->delete($_GET["menu_entry"]);
3134 
3135  ilUtil::sendSuccess($this->lng->txt("msg_entry_removed"), true);
3136  $this->ctrl->redirect($this, "editMenuProperties");
3137  }
3138 
3142  function editMenuEntry()
3143  {
3144  global $ilToolbar, $ilCtrl;
3145 
3146  if (empty($_GET["menu_entry"]))
3147  {
3148  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3149  }
3150 
3151  $ilCtrl->saveParameter($this, array("menu_entry"));
3152  $ilToolbar->addButton($this->lng->txt("lm_menu_select_internal_object"),
3153  $ilCtrl->getLinkTarget($this, "showEntrySelector"));
3154 
3155  $form = $this->initMenuEntryForm("edit");
3156  $this->tpl->setContent($form->getHTML());
3157  }
3158 
3162  function updateMenuEntry()
3163  {
3164  if (empty($_REQUEST["menu_entry"]))
3165  {
3166  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3167  }
3168 
3169  // check title and target
3170  if (empty($_POST["title"]))
3171  {
3172  $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
3173  }
3174  if (empty($_POST["target"]))
3175  {
3176  $this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
3177  }
3178 
3179  $this->__initLMMenuEditor();
3180  $this->lmme_obj->readEntry($_REQUEST["menu_entry"]);
3181  $this->lmme_obj->setTitle($_POST["title"]);
3182  $this->lmme_obj->setTarget($_POST["target"]);
3183  $this->lmme_obj->update();
3184 
3185  ilUtil::sendSuccess($this->lng->txt("msg_entry_updated"), true);
3186  $this->ctrl->redirect($this, "editMenuProperties");
3187  }
3188 
3190  {
3191  global $ilTabs, $ilCtrl;
3192 
3193  $this->setTabs();
3194 
3195  $ilTabs->setTabActive("settings");
3196  $this->setSubTabs("cont_lm_menu");
3197 
3198  $ilCtrl->saveParameter($this, array("menu_entry"));
3199 
3200  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_object_selector.html","Modules/LearningModule");
3201 
3202  ilUtil::sendInfo($this->lng->txt("lm_menu_select_object_to_add"));
3203 
3204  require_once ("./Modules/LearningModule/classes/class.ilLMMenuObjectSelector.php");
3205  $exp = new ilLMMenuObjectSelector($this->ctrl->getLinkTarget($this,'test'),$this);
3206 
3207  $exp->setExpand($_GET["lm_menu_expand"] ? $_GET["lm_menu_expand"] : $this->tree->readRootId());
3208  $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showEntrySelector'));
3209  $exp->setTargetGet("ref_id");
3210  $exp->setRefId($this->cur_ref_id);
3211 
3212  $sel_types = array('mcst', 'mep', 'cat', 'lm','dbk','glo','frm','exc','tst','svy', 'chat', 'wiki', 'sahs',
3213  "crs", "grp", "book", "tst", "file");
3214  $exp->setSelectableTypes($sel_types);
3215 
3216  //$exp->setTargetGet("obj_id");
3217 
3218  // build html-output
3219  $exp->setOutput(0);
3220  $output = $exp->getOutput();
3221 
3222  // get page ids
3223  foreach ($exp->format_options as $node)
3224  {
3225  if (!$node["container"])
3226  {
3227  $pages[] = $node["child"];
3228  }
3229  }
3230 
3231  //$this->tpl->setCurrentBlock("content");
3232  //var_dump($this->object->getPublicAccessMode());
3233  // access mode selector
3234  $this->tpl->setVariable("TXT_SET_PUBLIC_MODE", $this->lng->txt("set_public_mode"));
3235  $this->tpl->setVariable("TXT_CHOOSE_PUBLIC_MODE", $this->lng->txt("choose_public_mode"));
3236  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
3237  $select_public_mode = ilUtil::formSelect ($this->object->getPublicAccessMode(),"lm_public_mode",$modes, false, true);
3238  $this->tpl->setVariable("SELECT_PUBLIC_MODE", $select_public_mode);
3239 
3240  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("choose_public_pages"));
3241  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
3242  $this->tpl->setVariable("EXPLORER",$output);
3243  $this->tpl->setVariable("ONCLICK",$js_pages);
3244  $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
3245  $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
3246  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3247  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
3248  //$this->tpl->parseCurrentBlock();
3249  }
3250 
3254  function selectHeader()
3255  {
3256  if(!isset($_POST["id"]))
3257  {
3258  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3259  }
3260  if(count($_POST["id"]) > 1)
3261  {
3262  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3263  }
3264  if ($_POST["id"][0] != $this->object->getHeaderPage())
3265  {
3266  $this->object->setHeaderPage($_POST["id"][0]);
3267  }
3268  else
3269  {
3270  $this->object->setHeaderPage(0);
3271  }
3272  $this->object->updateProperties();
3273  $this->ctrl->redirect($this, "pages");
3274  }
3275 
3279  function selectFooter()
3280  {
3281  if(!isset($_POST["id"]))
3282  {
3283  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3284  }
3285  if(count($_POST["id"]) > 1)
3286  {
3287  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3288  }
3289  if ($_POST["id"][0] != $this->object->getFooterPage())
3290  {
3291  $this->object->setFooterPage($_POST["id"][0]);
3292  }
3293  else
3294  {
3295  $this->object->setFooterPage(0);
3296  }
3297  $this->object->updateProperties();
3298  $this->ctrl->redirect($this, "pages");
3299  }
3300 
3304  function saveAllTitles()
3305  {
3306  global $ilCtrl;
3307 
3308  ilLMObject::saveTitles($this->object, ilUtil::stripSlashesArray($_POST["title"]), $_GET["transl"]);
3309 
3310  $ilCtrl->redirect($this, "chapters");
3311  }
3312 
3316  function insertChapter()
3317  {
3318  global $ilCtrl, $lng;
3319 
3320  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
3321 
3324 
3325  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
3326  {
3327  $parent_id = $this->lm_tree->getParentId($node_id);
3328  $target = $node_id;
3329  }
3330  else // insert as first child
3331  {
3332  $parent_id = $node_id;
3333  $target = IL_FIRST_NODE;
3334  }
3335 
3336  for ($i = 1; $i <= $num; $i++)
3337  {
3338  $chap = new ilStructureObject($this->object);
3339  $chap->setType("st");
3340  $chap->setTitle($lng->txt("cont_new_chap"));
3341  $chap->setLMId($this->object->getId());
3342  $chap->create();
3343  ilLMObject::putInTree($chap, $parent_id, $target);
3344  }
3345 
3346  $ilCtrl->redirect($this, "chapters");
3347  }
3348 
3353  {
3354  global $ilUser, $ilCtrl, $ilLog;
3355 
3356  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
3357 
3360 
3361  $ilLog->write("InsertChapterClip, num: $num, node_id: $node_id, ".
3362  " getPostFirstChild ".ilChapterHierarchyFormGUI::getPostFirstChild());
3363 
3364  if (!$first_child) // insert after node id
3365  {
3366  $parent_id = $this->lm_tree->getParentId($node_id);
3367  $target = $node_id;
3368  }
3369  else // insert as first child
3370  {
3371  $parent_id = $node_id;
3372  $target = IL_FIRST_NODE;
3373  }
3374 
3375  // copy and paste
3376  $chapters = $ilUser->getClipboardObjects("st", true);
3377  $copied_nodes = array();
3378  foreach ($chapters as $chap)
3379  {
3380  $ilLog->write("Call pasteTree, Target LM: ".$this->object->getId().", Chapter ID: ".$chap["id"]
3381  .", Parent ID: ".$parent_id.", Target: ".$target);
3382  $cid = ilLMObject::pasteTree($this->object, $chap["id"], $parent_id,
3383  $target, $chap["insert_time"], $copied_nodes,
3384  (ilEditClipboard::getAction() == "copy"));
3385  $target = $cid;
3386  }
3387  ilLMObject::updateInternalLinks($copied_nodes);
3388 
3389  if (ilEditClipboard::getAction() == "cut")
3390  {
3391  $ilUser->clipboardDeleteObjectsOfType("pg");
3392  $ilUser->clipboardDeleteObjectsOfType("st");
3394  }
3395 
3396  $this->object->checkTree();
3397  $ilCtrl->redirect($this, "chapters");
3398  }
3399 
3405  function _goto($a_target)
3406  {
3407  global $ilAccess, $ilErr, $lng;
3408 
3409  if ($ilAccess->checkAccess("read", "", $a_target))
3410  {
3411  $_GET["baseClass"] = "ilLMPresentationGUI";
3412  $_GET["ref_id"] = $a_target;
3413  include("ilias.php");
3414  exit;
3415  } else if ($ilAccess->checkAccess("visible", "", $a_target))
3416  {
3417  $_GET["baseClass"] = "ilLMPresentationGUI";
3418  $_GET["ref_id"] = $a_target;
3419  $_GET["cmd"] = "infoScreen";
3420  include("ilias.php");
3421  exit;
3422  }
3423  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
3424  {
3425  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
3426  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
3428  }
3429 
3430 
3431  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
3432  }
3433 
3437  function cutItems($a_return = "chapters")
3438  {
3439  global $ilCtrl, $lng;
3440 
3441  $items = ilUtil::stripSlashesArray($_POST["id"]);
3442  if (!is_array($items))
3443  {
3444  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3445  $ilCtrl->redirect($this, $a_return);
3446  }
3447 
3448  $todel = array(); // delete IDs < 0 (needed for non-js editing)
3449  foreach($items as $k => $item)
3450  {
3451  if ($item < 0)
3452  {
3453  $todel[] = $k;
3454  }
3455  }
3456  foreach($todel as $k)
3457  {
3458  unset($items[$k]);
3459  }
3460  ilLMObject::clipboardCut($this->object->getId(), $items);
3462  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
3463 
3464  $ilCtrl->redirect($this, $a_return);
3465  }
3466 
3470  function copyItems()
3471  {
3472  global $ilCtrl, $lng;
3473 
3474  $items = ilUtil::stripSlashesArray($_POST["id"]);
3475  if (!is_array($items))
3476  {
3477  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3478  $ilCtrl->redirect($this, "chapters");
3479  }
3480 
3481  $todel = array(); // delete IDs < 0 (needed for non-js editing)
3482  foreach($items as $k => $item)
3483  {
3484  if ($item < 0)
3485  {
3486  $todel[] = $k;
3487  }
3488  }
3489  foreach($todel as $k)
3490  {
3491  unset($items[$k]);
3492  }
3493  ilLMObject::clipboardCopy($this->object->getId(), $items);
3495  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
3496  $ilCtrl->redirect($this, "chapters");
3497  }
3498 
3502  function cutChapter()
3503  {
3504  $this->cutItems("chapters");
3505  }
3506 
3510 
3517  function showExportIDsOverview($a_validation = false)
3518  {
3519  global $tpl, $ilToolbar, $lng, $ilCtrl;
3520 
3521  $this->setTabs();
3522  $this->setContentSubTabs("export_ids");
3523 
3524  if (ilObjContentObject::isOnlineHelpModule($this->object->getRefId()))
3525  {
3526  // toolbar
3527  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
3528  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
3529  $lm_tree = $this->object->getTree();
3530  $childs = $lm_tree->getChilds($lm_tree->readRootId());
3531  $options = array("" => $lng->txt("all"));
3532  foreach ($childs as $c)
3533  {
3534  $options[$c["child"]] = $c["title"];
3535  }
3536  $si = new ilSelectInputGUI($this->lng->txt("help_component"), "help_chap");
3537  $si->setOptions($options);
3538  $si->setValue(ilSession::get("help_chap"));
3539  $ilToolbar->addInputItem($si, true);
3540  $ilToolbar->addFormButton($lng->txt("help_filter"), "filterHelpChapters");
3541 
3542  include_once("./Modules/LearningModule/classes/class.ilHelpMappingTableGUI.php");
3543  $tbl = new ilHelpMappingTableGUI($this, "showExportIDsOverview", $a_validation, false);
3544  }
3545  else
3546  {
3547  include_once("./Modules/LearningModule/classes/class.ilExportIDTableGUI.php");
3548  $tbl = new ilExportIDTableGUI($this, "showExportIDsOverview", $a_validation, false);
3549  }
3550 
3551  $tpl->setContent($tbl->getHTML());
3552  }
3553 
3561  {
3562  global $ilCtrl;
3563 
3564  ilSession::set("help_chap", ilUtil::stripSlashes($_POST["help_chap"]));
3565  $ilCtrl->redirect($this, "showExportIDsOverview");
3566  }
3567 
3568 
3572  function saveExportIds()
3573  {
3574  global $ilCtrl, $lng;
3575 
3576  // check all export ids
3577  $ok = true;
3578  if (is_array($_POST["exportid"]))
3579  {
3580  foreach ($_POST["exportid"] as $pg_id => $exp_id)
3581  {
3582  if ($exp_id != "" && !preg_match("/^([a-zA-Z]+)[0-9a-zA-Z_]*$/",
3583  trim($exp_id)))
3584  {
3585  $ok = false;
3586  }
3587  }
3588  }
3589  if (!$ok)
3590  {
3591  ilUtil::sendFailure($lng->txt("cont_exp_ids_not_resp_format1").": a-z, A-Z, 0-9, '_'. ".
3592  $lng->txt("cont_exp_ids_not_resp_format3")." ".
3593  $lng->txt("cont_exp_ids_not_resp_format2"));
3594  $this->showExportIDsOverview(true);
3595  return;
3596  }
3597 
3598 
3599  if (is_array($_POST["exportid"]))
3600  {
3601  foreach ($_POST["exportid"] as $pg_id => $exp_id)
3602  {
3603  ilLMPageObject::saveExportId($this->object->getId(), $pg_id,
3604  ilUtil::stripSlashes($exp_id), ilLMObject::_lookupType($pg_id));
3605  }
3606  }
3607 
3608  ilUtil::sendSuccess($lng->txt("cont_saved_export_ids"), true);
3609  $ilCtrl->redirect($this, "showExportIdsOverview");
3610  }
3611 
3618  function saveHelpMapping()
3619  {
3620  global $lng, $ilCtrl;
3621 
3622  include_once("./Services/Help/classes/class.ilHelpMapping.php");
3623  if (is_array($_POST["screen_ids"]))
3624  {
3625  foreach ($_POST["screen_ids"] as $chap => $ids)
3626  {
3627  $ids = explode("\n", $ids);
3629  }
3630  }
3631  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3632  $ilCtrl->redirect($this, "showExportIdsOverview");
3633  }
3634 
3638 
3645  function showTooltipList()
3646  {
3647  global $tpl, $ilToolbar, $ilCtrl, $lng;
3648 
3649  $this->setTabs();
3650  $this->setContentSubTabs("help_tooltips");
3651 
3652  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
3653  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
3654  $ti = new ilTextInputGUI($this->lng->txt("help_tooltip_id"), "tooltip_id");
3655  $ti->setMaxLength(200);
3656  $ti->setSize(20);
3657  $ilToolbar->addInputItem($ti, true);
3658  $ilToolbar->addFormButton($lng->txt("add"), "addTooltip");
3659  $ilToolbar->addSeparator();
3660 
3661  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
3663  if (ilSession::get("help_tt_comp") != "")
3664  {
3665  $options[ilSession::get("help_tt_comp")] = ilSession::get("help_tt_comp");
3666  }
3667  $si = new ilSelectInputGUI($this->lng->txt("help_component"), "help_tt_comp");
3668  $si->setOptions($options);
3669  $si->setValue(ilSession::get("help_tt_comp"));
3670  $ilToolbar->addInputItem($si, true);
3671  $ilToolbar->addFormButton($lng->txt("help_filter"), "filterTooltips");
3672 
3673  include_once("./Modules/LearningModule/classes/class.ilHelpTooltipTableGUI.php");
3674  $tbl = new ilHelpTooltipTableGUI($this, "showTooltipList", ilSession::get("help_tt_comp"));
3675 
3676  $tpl->setContent($tbl->getHTML());
3677  }
3678 
3685  function addTooltip()
3686  {
3687  global $lng, $ilCtrl;
3688 
3689  $tt_id = ilUtil::stripSlashes($_POST["tooltip_id"]);
3690  if (trim($tt_id) != "")
3691  {
3692  if (is_int(strpos($tt_id, "_")))
3693  {
3694  include_once("./Services/Help/classes/class.ilHelp.php");
3695  ilHelp::addTooltip(trim($tt_id), "");
3696  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3697 
3698  $fu = strpos($tt_id, "_");
3699  $comp = substr($tt_id, 0, $fu);
3700  ilSession::set("help_tt_comp", ilUtil::stripSlashes($comp));
3701  }
3702  else
3703  {
3704  ilUtil::sendFailure($lng->txt("cont_help_no_valid_tooltip_id"), true);
3705  }
3706  }
3707  $ilCtrl->redirect($this, "showTooltipList");
3708  }
3709 
3716  function filterTooltips()
3717  {
3718  global $lng, $ilCtrl;
3719 
3720  ilSession::set("help_tt_comp", ilUtil::stripSlashes($_POST["help_tt_comp"]));
3721  $ilCtrl->redirect($this, "showTooltipList");
3722  }
3723 
3724 
3731  function saveTooltips()
3732  {
3733  global $ilCtrl, $lng;
3734 
3735  include_once("./Services/Help/classes/class.ilHelp.php");
3736 
3737  if (is_array($_POST["text"]))
3738  {
3739  foreach ($_POST["text"] as $id => $text)
3740  {
3741  ilHelp::updateTooltip((int) $id, ilUtil::stripSlashes($text),
3742  ilUtil::stripSlashes($_POST["tt_id"][(int) $id]));
3743  }
3744  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3745  }
3746  $ilCtrl->redirect($this, "showTooltipList");
3747  }
3748 
3752  function deleteTooltips()
3753  {
3754  global $lng, $ilCtrl;
3755 
3756  if (is_array($_POST["id"]))
3757  {
3758  include_once("./Services/Help/classes/class.ilHelp.php");
3759  foreach ($_POST["id"] as $id)
3760  {
3761  ilHelp::deleteTooltip((int) $id);
3762  }
3763  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3764  }
3765  $ilCtrl->redirect($this, "showTooltipList");
3766  }
3767 
3774 /* function saveHelpMapping()
3775  {
3776  global $lng, $ilCtrl;
3777 
3778  include_once("./Services/Help/classes/class.ilHelpMapping.php");
3779  if (is_array($_POST["screen_ids"]))
3780  {
3781  foreach ($_POST["screen_ids"] as $chap => $ids)
3782  {
3783  $ids = explode("\n", $ids);
3784  ilHelpMapping::saveScreenIdsForChapter($chap, $ids);
3785  }
3786  }
3787  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3788  $ilCtrl->redirect($this, "showExportIdsOverview");
3789  }*/
3790 
3791 
3795 
3801  static function getLayoutOption($a_txt, $a_var, $a_def_option = "")
3802  {
3803  global $lng;
3804 
3805  // default layout
3806  $layout = new ilRadioGroupInputGUI($a_txt, $a_var);
3807  if ($a_def_option != "")
3808  {
3809  if (is_file($im = ilUtil::getImagePath("layout_".$a_def_option.".png")))
3810  {
3811  $im_tag = ilUtil::img($im, $a_def_option);
3812  }
3813  $layout->addOption(new ilRadioOption("<table><tr><td>".$im_tag."</td><td><b>".
3814  $lng->txt("cont_lm_default_layout").
3815  "</b>: ".$lng->txt("cont_layout_".$a_def_option).
3816  "</td></tr></table>", ""));
3817  }
3819  {
3820  $im_tag = "";
3821  if (is_file($im = ilUtil::getImagePath("layout_".$l.".png")))
3822  {
3823  $im_tag = ilUtil::img($im, $l);
3824  }
3825  $layout->addOption(new ilRadioOption("<table><tr><td style='padding: 0px 5px 5px;'>".
3826  $im_tag."</td><td style='padding:5px;'><b>".$lng->txt("cont_layout_".$l)."</b>: ".
3827  $lng->txt("cont_layout_".$l."_desc")."</td></tr></table>", $l));
3828  }
3829 
3830  return $layout;
3831  }
3832 
3837  {
3838  global $ilCtrl;
3839  $ilCtrl->setParameter($this, "hierarchy", "1");
3840  $this->setPageLayout(true);
3841  }
3842 
3843 
3847  function setPageLayout($a_in_hierarchy = false)
3848  {
3849  global $tpl, $ilCtrl, $lng;
3850 
3851  if (!is_array($_POST["id"]))
3852  {
3853  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3854 
3855  if ($a_in_hierarchy)
3856  {
3857  $ilCtrl->redirect($this, "chapters");
3858  }
3859  else
3860  {
3861  $ilCtrl->redirect($this, "pages");
3862  }
3863  }
3864 
3865  $this->initSetPageLayoutForm();
3866 
3867  $tpl->setContent($this->form->getHTML());
3868  }
3869 
3873  public function initSetPageLayoutForm()
3874  {
3875  global $lng, $ilCtrl;
3876 
3877  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3878  $this->form = new ilPropertyFormGUI();
3879 
3880  if (is_array($_POST["id"]))
3881  {
3882  foreach ($_POST["id"] as $id)
3883  {
3884  $hi = new ilHiddenInputGUI("id[]");
3885  $hi->setValue($id);
3886  $this->form->addItem($hi);
3887  }
3888  }
3889  $layout = self::getLayoutOption($lng->txt("cont_layout"), "layout",
3890  $this->object->getLayout());
3891  $this->form->addItem($layout);
3892 
3893  $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
3894  $this->form->addCommandButton("pages", $lng->txt("cancel"));
3895 
3896  $this->form->setTitle($lng->txt("cont_set_layout"));
3897  $this->form->setFormAction($ilCtrl->getFormAction($this));
3898 
3899  }
3900 
3904  function savePageLayout()
3905  {
3906  global $lng, $ilCtrl;
3907 
3908  $ilCtrl->setParameter($this, "hierarchy", $_GET["hierarchy"]);
3909 
3910  foreach ($_POST["id"] as $id)
3911  {
3913  ilUtil::stripSlashes($_POST["layout"]),
3914  $this->object);
3915  }
3916  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3917 
3918  if ($_GET["hierarchy"] == 1)
3919  {
3920  $ilCtrl->redirect($this, "chapters");
3921  }
3922  else
3923  {
3924  $ilCtrl->redirect($this, "pages");
3925  }
3926  }
3927 
3928  //
3929  // Auto glossaries
3930  //
3931 
3938  function editGlossaries()
3939  {
3940  global $tpl, $ilToolbar, $lng, $ilCtrl, $ilTabs;
3941 
3942  $this->setTabs();
3943  $ilTabs->setTabActive("settings");
3944  $this->setSubTabs("cont_glossaries");
3945 
3946  $ilToolbar->addButton($lng->txt("add"),
3947  $ilCtrl->getLinkTarget($this, "showLMGlossarySelector"));
3948 
3949  include_once("./Modules/LearningModule/classes/class.ilLMGlossaryTableGUI.php");
3950  $tab = new ilLMGlossaryTableGUI($this->object, $this, "editGlossaries");
3951 
3952  $tpl->setContent($tab->getHTML());
3953  }
3954 
3962  {
3963  global $tpl, $lng, $ilCtrl, $tree, $ilUser, $ilTabs;
3964 
3965  $this->setTabs();
3966  $ilTabs->setTabActive("settings");
3967  $this->setSubTabs("cont_glossaries");
3968 
3969  include_once 'Services/Search/classes/class.ilSearchRootSelector.php';
3970 
3971  $exp = new ilSearchRootSelector($ilCtrl->getLinkTarget($this,'showLMGlossarySelector'));
3972  $exp->setExpand($_GET["search_root_expand"] ? $_GET["search_root_expand"] : $tree->readRootId());
3973  $exp->setExpandTarget($ilCtrl->getLinkTarget($this,'showLMGlossarySelector'));
3974  $exp->setTargetClass(get_class($this));
3975  $exp->setCmd('confirmGlossarySelection');
3976  $exp->setClickableTypes(array("glo"));
3977  $exp->addFilter("glo");
3978 
3979  // build html-output
3980  $exp->setOutput(0);
3981  $tpl->setContent($exp->getOutput());
3982 
3983  }
3984 
3989  {
3990  global $ilCtrl, $tpl, $lng;
3991 
3992  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
3993  $cgui = new ilConfirmationGUI();
3994  $ilCtrl->setParameter($this, "glo_ref_id", $_GET["root_id"]);
3995  $cgui->setFormAction($ilCtrl->getFormAction($this));
3996  $cgui->setHeaderText($lng->txt("cont_link_glo_in_lm"));
3997  $cgui->setCancel($lng->txt("no"), "selectLMGlossary");
3998  $cgui->setConfirm($lng->txt("yes"), "selectLMGlossaryLink");
3999  $tpl->setContent($cgui->getHTML());
4000  }
4001 
4009  {
4010  $glo_ref_id = (int) $_GET["glo_ref_id"];
4011  $glo_id = ilObject::_lookupObjId($glo_ref_id);
4012  $this->object->autoLinkGlossaryTerms($glo_id);
4013  $this->selectLMGlossary();
4014  }
4015 
4016 
4023  function selectLMGlossary()
4024  {
4025  global $ilCtrl, $lng;
4026 
4027  $glos = $this->object->getAutoGlossaries();
4028  $glo_ref_id = (int) $_GET["glo_ref_id"];
4029  $glo_id = ilObject::_lookupObjId($glo_ref_id);
4030  if (!in_array($glo_id, $glos))
4031  {
4032  $glos[] = $glo_id;
4033  }
4034  $this->object->setAutoGlossaries($glos);
4035  $this->object->update();
4036 
4037  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
4038  $ilCtrl->redirect($this, "editGlossaries");
4039  }
4040 
4047  function removeLMGlossary()
4048  {
4049  global $ilCtrl, $lng;
4050 
4051  $this->object->removeAutoGlossary((int) $_GET["glo_id"]);
4052  $this->object->update();
4053 
4054  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
4055  $ilCtrl->redirect($this, "editGlossaries");
4056  }
4057 
4065  {
4066  global $ilCtrl;
4067 
4068  $ilCtrl->setParameter($this, "transl", "");
4069  $ilCtrl->redirect($this, "chapters");
4070  }
4071 
4078  function switchToLanguage()
4079  {
4080  global $ilCtrl;
4081 
4082  $ilCtrl->setParameter($this, "transl", $_GET["totransl"]);
4083  $ilCtrl->redirect($this, "chapters");
4084  }
4085 
4087  {
4088  // #12281
4090  }
4091 
4092 }
4093 ?>