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