ILIAS  release_4-3 Revision
 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  parent::ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
37  }
38 
42  function &executeCommand()
43  {
44  global $ilAccess, $lng, $ilTabs, $ilCtrl, $ilErr;
45 
46  if ($this->ctrl->getRedirectSource() == "ilinternallinkgui")
47  {
48  $this->explorer();
49  return;
50  }
51 
52  if ($this->ctrl->getCmdClass() == "ilinternallinkgui")
53  {
54  $this->ctrl->setReturn($this, "explorer");
55  }
56 
57  // get next class that processes or forwards current command
58  $next_class = $this->ctrl->getNextClass($this);
59 
60  // get current command
61  $cmd = $this->ctrl->getCmd("", array("downloadExportFile"));
62 //echo "-$cmd-".$next_class."-";
63  switch($next_class)
64  {
65  case "illearningprogressgui":
66  $this->addHeaderAction();
67  $this->addLocations();
68  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
69  $this->setTabs("learning_progress");
70 
71  $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,$this->object->getRefId());
72  $new_gui->activateStatistics();
73  $this->ctrl->forwardCommand($new_gui);
74 
75  break;
76 
77  case 'ilmdeditorgui':
78  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
79  {
80  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
81  }
82 
83  $this->addHeaderAction();
84  $this->addLocations();
85  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
86  $this->setTabs("meta");
87  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
88  $md_gui->addObserver($this->object,'MDUpdateListener','General');
89 
90  $this->ctrl->forwardCommand($md_gui);
91  break;
92 
93  case "ilobjstylesheetgui":
94  $this->addLocations();
95  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
96  $this->ctrl->setReturn($this, "editStyleProperties");
97  $style_gui =& new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
98  $style_gui->omitLocator();
99  if ($cmd == "create" || $_GET["new_type"]=="sty")
100  {
101  $style_gui->setCreationMode(true);
102  }
103  $ret =& $this->ctrl->forwardCommand($style_gui);
104  //$ret =& $style_gui->executeCommand();
105 
106  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
107  {
108  $style_id = $ret;
109  $this->object->setStyleSheetId($style_id);
110  $this->object->update();
111  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
112  }
113  break;
114 
115  case "illmpageobjectgui":
116 
117  $ilTabs->setBackTarget($lng->txt("learning module"),
118  $ilCtrl->getLinkTarget($this, "chapters"));
119  $this->ctrl->saveParameter($this, array("obj_id"));
120  $this->addLocations();
121  $this->ctrl->setReturn($this, "chapters");
122 //echo "!";
123  //$this->lm_obj =& $this->ilias->obj_factory->getInstanceByRefId($this->ref_id);
124 
125  $pg_gui =& new ilLMPageObjectGUI($this->object);
126  if ($_GET["obj_id"] != "")
127  {
128  $obj =& ilLMObjectFactory::getInstance($this->object, $_GET["obj_id"]);
129  $pg_gui->setLMPageObject($obj);
130  }
131  //$ret =& $pg_gui->executeCommand();
132  $ret =& $this->ctrl->forwardCommand($pg_gui);
133  if ($cmd == "save" || $cmd == "cancel")
134  {
135 // $this->ctrl->redirect($this, "pages");
136  }
137  break;
138 
139  case "ilstructureobjectgui":
140  $ilTabs->setBackTarget($lng->txt("learning module"),
141  $ilCtrl->getLinkTarget($this, "chapters"));
142 
143  $this->ctrl->saveParameter($this, array("obj_id"));
144  $this->addLocations();
145  $this->ctrl->setReturn($this, "chapters");
146  $st_gui =& new ilStructureObjectGUI($this->object, $this->object->lm_tree);
147  if ($_GET["obj_id"] != "")
148  {
149  $obj =& ilLMObjectFactory::getInstance($this->object, $_GET["obj_id"]);
150  $st_gui->setStructureObject($obj);
151  }
152  //$ret =& $st_gui->executeCommand();
153  $ret =& $this->ctrl->forwardCommand($st_gui);
154  if ($cmd == "save" || $cmd == "cancel")
155  {
156  if ($_GET["obj_id"] == "")
157  {
158  $this->ctrl->redirect($this, "chapters");
159  }
160  else
161  {
162  $this->ctrl->setCmd("subchap");
163  $this->executeCommand();
164  }
165  }
166  break;
167 
168  case 'ilpermissiongui':
169  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
170  {
171  $this->prepareOutput();
172  }
173  else
174  {
175  $this->addHeaderAction();
176  $this->addLocations(true);
177  $this->setTabs("perm");
178  }
179  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
180  $perm_gui =& new ilPermissionGUI($this);
181  $ret =& $this->ctrl->forwardCommand($perm_gui);
182  break;
183 
184  // infoscreen
185  case 'ilinfoscreengui':
186  $this->addHeaderAction();
187  $this->addLocations(true);
188  $this->setTabs("info");
189  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
190  $info = new ilInfoScreenGUI($this);
191  $info->enablePrivateNotes();
192  $info->enableLearningProgress();
193 
194  $info->enableNews();
195  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
196  {
197  $info->enableNewsEditing();
198  $info->setBlockProperty("news", "settings", true);
199  }
200 
201  // show standard meta data section
202  $info->addMetaDataSections($this->object->getId(), 0,
203  $this->object->getType());
204 
205  $ret =& $this->ctrl->forwardCommand($info);
206  break;
207 
208  case "ilexportgui":
209  $this->addHeaderAction();
210  $this->addLocations(true);
211  $this->setTabs("export");
212  include_once("./Services/Export/classes/class.ilExportGUI.php");
213  $exp_gui = new ilExportGUI($this);
214  $exp_gui->addFormat("xml", "", $this, "export");
215  $exp_gui->addFormat("html", "", $this, "exportHTML");
216  $exp_gui->addFormat("scorm", "", $this, "exportSCORM");
217  $exp_gui->addCustomColumn($lng->txt("cont_public_access"),
218  $this, "getPublicAccessColValue");
219  $exp_gui->addCustomMultiCommand($lng->txt("cont_public_access"),
220  $this, "publishExportFile");
221  $ret = $this->ctrl->forwardCommand($exp_gui);
222  break;
223 
224  case "ilcommonactiondispatchergui":
225  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
227  $this->ctrl->forwardCommand($gui);
228  break;
229 
230  default:
231  $new_type = $_POST["new_type"]
232  ? $_POST["new_type"]
233  : $_GET["new_type"];
234 
235 
236  if ($cmd == "create" &&
237  !in_array($new_type, array("dbk", "lm")))
238  {
239  //$this->addLocations();
240  switch ($new_type)
241  {
242  case "pg":
243  $this->setTabs();
244  $this->ctrl->setCmdClass("ilLMPageObjectGUI");
245  $ret =& $this->executeCommand();
246  break;
247 
248  case "st":
249  $this->setTabs();
250  $this->ctrl->setCmdClass("ilStructureObjectGUI");
251  $ret =& $this->executeCommand();
252  break;
253  }
254  }
255  else
256  {
257  // creation of new dbk/lm in repository
258  if ($this->getCreationMode() == true &&
259  in_array($new_type, array("dbk", "lm")))
260  {
261  $this->prepareOutput();
262  if ($cmd == "") // this may be due to too big upload files
263  {
264  $cmd = "create";
265  }
266  $cmd .= "Object";
267  $ret =& $this->$cmd();
268  }
269  else
270  {
271  $this->addHeaderAction();
272  $this->addLocations();
273  $ret =& $this->$cmd();
274  }
275  }
276  break;
277  }
278  return $ret;
279  }
280 
281  function _forwards()
282  {
283  return array("ilLMPageObjectGUI", "ilStructureObjectGUI","ilObjStyleSheetGUI");
284  }
285 
289  function properties()
290  {
291  global $lng;
292 
293  $lng->loadLanguageModule("style");
294  $this->setTabs("settings");
295  $this->setSubTabs("cont_general_properties");
296 
297  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
298  $showViewInFrameset = true;
299 
300  if ($showViewInFrameset)
301  {
302  $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
303  }
304  else
305  {
306  $buttonTarget = "ilContObj".$this->object->getID();
307  }
308 
309  // lm properties
310  $this->initPropertiesForm();
311  $this->getPropertiesFormValues();
312 
313  if($this->object->getType() == "lm")
314  {
315  // Edit ecs export settings
316  include_once 'Modules/LearningModule/classes/class.ilECSLearningModuleSettings.php';
317  $ecs = new ilECSLearningModuleSettings($this->object);
318  $ecs->addSettingsToForm($this->form, 'lm');
319  }
320 
321  $this->tpl->setContent($this->form->getHTML());
322  }
323 
328  {
329  global $ilCtrl, $lng;
330 
331  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
332  $this->form = new ilPropertyFormGUI();
333 
334  // title
335  $ti = new ilTextInputGUI($lng->txt("title"), "title");
336  //$ti->setMaxLength();
337  //$ti->setSize();
338  //$ti->setInfo($lng->txt(""));
339  $ti->setRequired(true);
340  $this->form->addItem($ti);
341 
342  // description
343  $ta = new ilTextAreaInputGUI($lng->txt("desc"), "description");
344  //$ta->setCols();
345  //$ta->setRows();
346  //$ta->setInfo($lng->txt(""));
347  $this->form->addItem($ta);
348 
349  // online
350  $online = new ilCheckboxInputGUI($lng->txt("cont_online"), "cobj_online");
351  $this->form->addItem($online);
352 
353  // default layout
354  $layout = self::getLayoutOption($lng->txt("cont_def_layout"), "lm_layout");
355  $this->form->addItem($layout);
356 
357  // page header
358  $page_header = new ilSelectInputGUI($lng->txt("cont_page_header"), "lm_pg_header");
359  $option = array ("st_title" => $this->lng->txt("cont_st_title"),
360  "pg_title" => $this->lng->txt("cont_pg_title"),
361  "none" => $this->lng->txt("cont_none"));
362  $page_header->setOptions($option);
363  $this->form->addItem($page_header);
364 
365  // chapter numeration
366  $chap_num = new ilCheckboxInputGUI($lng->txt("cont_act_number"), "cobj_act_number");
367  $this->form->addItem($chap_num);
368 
369  // toc mode
370  $toc_mode = new ilSelectInputGUI($lng->txt("cont_toc_mode"), "toc_mode");
371  $option = array ("chapters" => $this->lng->txt("cont_chapters_only"),
372  "pages" => $this->lng->txt("cont_chapters_and_pages"));
373  $toc_mode->setOptions($option);
374  $this->form->addItem($toc_mode);
375 
376  // public notes
377  if (!$this->ilias->getSetting('disable_comments'))
378  {
379  $this->lng->loadLanguageModule("notes");
380  $pub_nodes = new ilCheckboxInputGUI($lng->txt("notes_comments"), "cobj_pub_notes");
381  $pub_nodes->setInfo($this->lng->txt("cont_lm_comments_desc"));
382  $this->form->addItem($pub_nodes);
383  }
384 
385  // layout per page
386  $lpp = new ilCheckboxInputGUI($lng->txt("cont_layout_per_page"), "layout_per_page");
387  $lpp->setInfo($this->lng->txt("cont_layout_per_page_info"));
388  $this->form->addItem($lpp);
389 
390  // synchronize frames
391  $synch = new ilCheckboxInputGUI($lng->txt("cont_synchronize_frames"), "cobj_clean_frames");
392  $synch->setInfo($this->lng->txt("cont_synchronize_frames_desc"));
393  $this->form->addItem($synch);
394 
395  // history user comments
396  $com = new ilCheckboxInputGUI($lng->txt("enable_hist_user_comments"), "cobj_user_comments");
397  $com->setInfo($this->lng->txt("enable_hist_user_comments_desc"));
398  $this->form->addItem($com);
399 
400  $this->form->setTitle($lng->txt("cont_general_properties"));
401  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
402  $this->form->setFormAction($ilCtrl->getFormAction($this));
403  }
404 
409  {
410  $values = array();
411  $values["title"] = $this->object->getTitle();
412  $values["description"] = $this->object->getDescription();
413  if ($this->object->getOnline())
414  {
415  $values["cobj_online"] = true;
416  }
417  $values["lm_layout"] = $this->object->getLayout();
418  $values["lm_pg_header"] = $this->object->getPageHeader();
419  if ($this->object->isActiveNumbering())
420  {
421  $values["cobj_act_number"] = true;
422  }
423  $values["toc_mode"] = $this->object->getTOCMode();
424  if ($this->object->publicNotes())
425  {
426  $values["cobj_pub_notes"] = true;
427  }
428  if ($this->object->cleanFrames())
429  {
430  $values["cobj_clean_frames"] = true;
431  }
432  if ($this->object->isActiveHistoryUserComments())
433  {
434  $values["cobj_user_comments"] = true;
435  }
436  $values["layout_per_page"] = $this->object->getLayoutPerPage();
437 
438  $this->form->setValuesByArray($values);
439  }
440 
444  function saveProperties()
445  {
446  $valid = false;
447  $this->initPropertiesForm();
448  if ($this->form->checkInput())
449  {
450  $this->object->setTitle($_POST['title']);
451  $this->object->setDescription($_POST['description']);
452  $this->object->setLayout($_POST["lm_layout"]);
453  $this->object->setPageHeader($_POST["lm_pg_header"]);
454  $this->object->setTOCMode($_POST["toc_mode"]);
455  $this->object->setOnline($_POST["cobj_online"]);
456  $this->object->setActiveNumbering($_POST["cobj_act_number"]);
457  $this->object->setCleanFrames($_POST["cobj_clean_frames"]);
458  if (!$this->ilias->getSetting('disable_comments'))
459  {
460  $this->object->setPublicNotes($_POST["cobj_pub_notes"]);
461  }
462  $this->object->setHistoryUserComments($_POST["cobj_user_comments"]);
463  $this->object->setLayoutPerPage($_POST["layout_per_page"]);
464  $this->object->updateProperties();
465  $this->object->update();
466 
467  if($this->object->getType() == 'lm')
468  {
469  // Update ecs export settings
470  include_once 'Modules/LearningModule/classes/class.ilECSLearningModuleSettings.php';
471  $ecs = new ilECSLearningModuleSettings($this->object);
472  if($ecs->handleSettingsUpdate())
473  {
474  $valid = true;
475  }
476  }
477  else
478  {
479  $valid = true;
480  }
481  }
482 
483  if($valid)
484  {
485  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
486  $this->ctrl->redirect($this, "properties");
487  }
488  else
489  {
490  $this->form->setValuesByPost();
491  $tpl->setContent($this->form->getHTML());
492  }
493  }
494 
499  {
500  global $tpl;
501 
502  $this->initStylePropertiesForm();
503  $tpl->setContent($this->form->getHTML());
504  }
505 
510  {
511  global $ilCtrl, $lng, $ilTabs, $ilSetting;
512 
513  $lng->loadLanguageModule("style");
514  $this->setTabs();
515  $ilTabs->setTabActive("settings");
516  $this->setSubTabs("cont_style");
517 
518  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
519  $this->form = new ilPropertyFormGUI();
520 
521  $fixed_style = $ilSetting->get("fixed_content_style_id");
522  $style_id = $this->object->getStyleSheetId();
523 
524  if ($fixed_style > 0)
525  {
526  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
527  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
528  $this->lng->txt("global_fixed").")");
529  $this->form->addItem($st);
530  }
531  else
532  {
533  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
534  $_GET["ref_id"]);
535 
536  $st_styles[0] = $this->lng->txt("default");
537  ksort($st_styles);
538 
539  if ($style_id > 0)
540  {
541  // individual style
542  if (!ilObjStyleSheet::_lookupStandard($style_id))
543  {
544  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
545  $st->setValue(ilObject::_lookupTitle($style_id));
546  $this->form->addItem($st);
547 
548 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
549 
550  // delete command
551  $this->form->addCommandButton("editStyle",
552  $lng->txt("cont_edit_style"));
553  $this->form->addCommandButton("deleteStyle",
554  $lng->txt("cont_delete_style"));
555 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
556  }
557  }
558 
559  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
560  {
561  $style_sel = ilUtil::formSelect ($style_id, "style_id",
562  $st_styles, false, true);
563  $style_sel = new ilSelectInputGUI($lng->txt("cont_current_style"), "style_id");
564  $style_sel->setOptions($st_styles);
565  $style_sel->setValue($style_id);
566  $this->form->addItem($style_sel);
567 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
568  $this->form->addCommandButton("saveStyleSettings",
569  $lng->txt("save"));
570  $this->form->addCommandButton("createStyle",
571  $lng->txt("sty_create_ind_style"));
572  }
573  }
574  $this->form->setTitle($lng->txt("cont_style"));
575  $this->form->setFormAction($ilCtrl->getFormAction($this));
576  }
577 
581  function createStyle()
582  {
583  global $ilCtrl;
584 
585  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
586  }
587 
591  function editStyle()
592  {
593  global $ilCtrl;
594 
595  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
596  }
597 
601  function deleteStyle()
602  {
603  global $ilCtrl;
604 
605  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
606  }
607 
611  function saveStyleSettings()
612  {
613  global $ilSetting;
614 
615  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
616  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
617  || $this->object->getStyleSheetId() == 0))
618  {
619  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
620  $this->object->update();
621  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
622  }
623  $this->ctrl->redirect($this, "editStyleProperties");
624  }
625 
629  public function initMenuForm()
630  {
631  global $lng, $ilCtrl;
632 
633  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
634  $form = new ilPropertyFormGUI();
635 
636  // enable menu
637  $menu = new ilCheckboxInputGUI($this->lng->txt("cont_active"), "cobj_act_lm_menu");
638  $menu->setChecked($this->object->isActiveLMMenu());
639  $form->addItem($menu);
640 
641  // toc
642  $toc = new ilCheckboxInputGUI($this->lng->txt("cont_toc"), "cobj_act_toc");
643  $toc->setChecked($this->object->isActiveTOC());
644  $form->addItem($toc);
645 
646  // print view
647  $print = new ilCheckboxInputGUI($this->lng->txt("cont_print_view"), "cobj_act_print");
648  $print->setChecked($this->object->isActivePrintView());
649  $form->addItem($print);
650 
651  // prevent glossary appendix
652  $glo = new ilCheckboxInputGUI($this->lng->txt("cont_print_view_pre_glo"), "cobj_act_print_prev_glo");
653  $glo->setChecked($this->object->isActivePreventGlossaryAppendix());
654  $print->addSubItem($glo);
655 
656  // downloads
657  $no_download_file_available =
658  " ".$lng->txt("cont_no_download_file_available").
659  " <a href='".$ilCtrl->getLinkTargetByClass("ilexportgui", "")."'>".$lng->txt("change")."</a>";
660  $types = array("xml", "html", "scorm");
661  foreach($types as $type)
662  {
663  if ($this->object->getPublicExportFile($type) != "")
664  {
665  if (is_file($this->object->getExportDirectory($type)."/".
666  $this->object->getPublicExportFile($type)))
667  {
668  $no_download_file_available = "";
669  }
670  }
671  }
672  $dl = new ilCheckboxInputGUI($this->lng->txt("cont_downloads"), "cobj_act_downloads");
673  $dl->setInfo($this->lng->txt("cont_downloads_desc").$no_download_file_available);
674  $dl->setChecked($this->object->isActiveDownloads());
675  $form->addItem($dl);
676 
677  // downloads in public area
678  $pdl = new ilCheckboxInputGUI($this->lng->txt("cont_downloads_public_desc"), "cobj_act_downloads_public");
679  $pdl->setChecked($this->object->isActiveDownloadsPublic());
680  $dl->addSubItem($pdl);
681 
682  $form->addCommandButton("saveMenuProperties", $lng->txt("save"));
683 
684  $form->setTitle($lng->txt("cont_lm_menu"));
685  $form->setFormAction($ilCtrl->getFormAction($this));
686 
687  return $form;
688  }
689 
694  {
695  global $lng, $ilTabs, $ilCtrl, $tpl, $ilToolbar;
696 
697  $lng->loadLanguageModule("style");
698  $this->setTabs();
699  $ilTabs->setTabActive("settings");
700  $this->setSubTabs("cont_lm_menu");
701 
702  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
703  $ilToolbar->addFormButton($this->lng->txt("add_menu_entry"), "addMenuEntry");
704  $ilToolbar->setCloseFormTag(false);
705 
706  $form = $this->initMenuForm();
707  $form->setOpenTag(false);
708  $form->setCloseTag(false);
709 
710  $this->__initLMMenuEditor();
711  $entries = $this->lmme_obj->getMenuEntries();
712  include_once("./Modules/LearningModule/classes/class.ilLMMenuItemsTableGUI.php");
713  $table = new ilLMMenuItemsTableGUI($this, "editMenuProperties", $this->lmme_obj);
714  $table->setOpenFormTag(false);
715 
716  $tpl->setContent($form->getHTML()."<br />".$table->getHTML());
717  }
718 
723  {
724  global $ilias;
725 
726  $this->object->setActiveLMMenu((int) $_POST["cobj_act_lm_menu"]);
727  $this->object->setActiveTOC((int) $_POST["cobj_act_toc"]);
728  $this->object->setActivePrintView((int) $_POST["cobj_act_print"]);
729  $this->object->setActivePreventGlossaryAppendix((int) $_POST["cobj_act_print_prev_glo"]);
730  $this->object->setActiveDownloads((int) $_POST["cobj_act_downloads"]);
731  $this->object->setActiveDownloadsPublic((int) $_POST["cobj_act_downloads_public"]);
732  $this->object->updateProperties();
733 
734  $this->__initLMMenuEditor();
735 //var_dump($_POST["menu_entries"]); exit;
736  $this->lmme_obj->updateActiveStatus($_POST["menu_entries"]);
737 
738  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
739  $this->ctrl->redirect($this, "editMenuProperties");
740  }
741 
745  function explorer()
746  {
747  global $ilUser, $ilias, $ilCtrl;
748 
749  switch ($this->object->getType())
750  {
751  case "lm":
752  $gui_class = "ilobjlearningmodulegui";
753  break;
754 
755  case "dlb":
756  $gui_class = "ilobjdlbookgui";
757  break;
758  }
759 
760  $ilCtrl->setParameterByClass($gui_class, "active_node", $_GET["active_node"]);
761 
762  $this->tpl = new ilTemplate("tpl.main.html", true, true);
763  // get learning module object
764  //$this->lm_obj =& new ilObjLearningModule($this->ref_id, true);
765 
766  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
767 
768  //$this->tpl = new ilTemplate("tpl.explorer.html", false, false);
769  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
770  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
771 
772  require_once ("./Modules/LearningModule/classes/class.ilLMEditorExplorer.php");
773  $exp = new ilLMEditorExplorer($this->ctrl->getLinkTarget($this, "view"),
774  $this->object, $gui_class);
775 
776  $exp->setTargetGet("obj_id");
777  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, "explorer"));
778 
779  if ($_GET["lmmovecopy"] == "1")
780  {
781  $this->proceedDragDrop();
782  }
783 
784 
785  if ($_GET["lmexpand"] == "")
786  {
787  $mtree = new ilTree($this->object->getId());
788  $mtree->setTableNames('lm_tree','lm_data');
789  $mtree->setTreeTablePK("lm_id");
790  $expanded = $mtree->readRootId();
791  }
792  else
793  {
794  $expanded = $_GET["lmexpand"];
795  }
796  if ($_GET["active_node"] != "")
797  {
798  $path = $this->lm_tree->getPathId($_GET["active_node"]);
799  $exp->setForceOpenPath($path);
800 
801  $exp->highlightNode($_GET["active_node"]);
802  }
803  $exp->setExpand($expanded);
804 
805  // build html-output
806  $exp->setOutput(0);
807  $output = $exp->getOutput();
808 
809  // asynchronous output
810  if ($ilCtrl->isAsynch())
811  {
812  echo $output; exit;
813  }
814 
815  include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
816 
817  /*if (ilPageEditorGUI::_doJSEditing())
818  {
819  //$this->tpl->touchBlock("includejavascript");
820 
821  $IDS = "";
822  for ($i=0;$i<count($exp->iconList);$i++)
823  {
824  if ($i>0) $IDS .= ",";
825  $IDS .= "'".$exp->iconList[$i]."'";
826  }
827  $this->tpl->setVariable("ICONIDS",$IDS);
828  //$this->ctrl->setParameter($this, "lmovecopy", 1);
829  $this->tpl->setVariable("TESTPFAD",$this->ctrl->getLinkTarget($this, "explorer")."&lmmovecopy=1");
830  //$this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode");
831  $this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode");
832  }*/
833 
834  $this->tpl->setCurrentBlock("content");
835  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_chap_and_pages"));
836  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
837  $this->tpl->setVariable("EXPLORER",$output);
838  $this->ctrl->setParameter($this, "lmexpand", $_GET["lmexpand"]);
839  $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, "explorer"));
840  $this->tpl->parseCurrentBlock();
841  $this->tpl->show(false);
842  exit;
843  }
844 
848  function popup()
849  {
850  include_once "./Services/COPage/classes/class.ilWysiwygUtil.php";
851  $popup = new ilWysiwygUtil();
852  $popup->show($_GET["ptype"]);
853  exit;
854  }
855 
859  function proceedDragDrop()
860  {
861  global $ilCtrl;
862 
863  $this->object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
864  $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
865  $ilCtrl->redirect($this, "chapters");
866  }
867 
868  protected function initCreationForms($a_new_type)
869  {
870  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
871  self::CFORM_IMPORT => $this->initImportForm());
872 
873  return $forms;
874  }
875 
876  protected function afterSave(ilObject $a_new_object)
877  {
878  $a_new_object->notify("new", $_GET["ref_id"], $_GET["parent_non_rbac_id"],
879  $_GET["ref_id"], $a_new_object->getRefId());
880  $a_new_object->setCleanFrames(true);
881  $a_new_object->update();
882 
883  // create content object tree
884  $a_new_object->createLMTree();
885 
886  // create a first chapter
887  $a_new_object->addFirstChapterAndPage();
888 
889  // always send a message
890  ilUtil::sendSuccess($this->lng->txt($this->type."_added"), true);
891  ilUtil::redirect("ilias.php?ref_id=".$a_new_object->getRefId().
892  "&baseClass=ilLMEditorGUI");
893  }
894 
898  public function initImportForm()
899  {
900  global $lng, $ilCtrl;
901 
902  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
903  $form = new ilPropertyFormGUI();
904 
905  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
906  $this->ctrl->setParameter($this, "new_type", $new_type);
907 
908  $form->setTarget(ilFrameTargetInfo::_getFrame("MainContent"));
909  $form->setTableWidth("600px");
910 
911  // import file
912  $fi = new ilFileInputGUI($this->lng->txt("file"), "xmldoc");
913  $fi->setSuffixes(array("zip"));
914  $fi->setRequired(true);
915  $fi->setSize(30);
916  $form->addItem($fi);
917 
918  // validation
919  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_validate_file"), "validate");
920  $cb->setInfo($this->lng->txt(""));
921  $form->addItem($cb);
922 
923  $form->addCommandButton("importFile", $lng->txt("import"));
924  $form->addCommandButton("cancel", $lng->txt("cancel"));
925 
926  $form->setTitle($this->lng->txt("import_".$new_type));
927  $form->setFormAction($ilCtrl->getFormAction($this));
928 
929  return $form;
930  }
931 
935  function addBibItemObject($a_target = "")
936  {
937  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
938  $bib_gui =& new ilBibItemGUI();
939  $bib_gui->setObject($this->object);
940  $bibItemName = $_POST["bibItemName"] ? $_POST["bibItemName"] : $_GET["bibItemName"];
941  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
942  if ($bibItemIndex == "")
943  $bibItemIndex = 0;
944  $bibItemPath = $_POST["bibItemPath"] ? $_POST["bibItemPath"] : $_GET["bibItemPath"];
945  if ($bibItemName != "")
946  {
947  $bib_gui->bib_obj->add($bibItemName, $bibItemPath, $bibItemIndex);
948  $data = $bib_gui->bib_obj->getElement("BibItem");
949  $bibItemIndex = (count($data) - 1);
950  }
951  else
952  {
953  ilUtil::sendInfo($this->lng->txt("bibitem_choose_element"), true);
954  }
955  if ($a_target == "")
956  {
957  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
958  }
959 
960  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
961  }
962 
966  function addBibItem()
967  {
968  $this->setTabs();
969 
970  // questionable workaround to make this old stuff work
971  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
972 
973  $this->addBibItemObject($this->ctrl->getLinkTarget($this));
974  }
975 
979  function deleteBibItemObject($a_target = "")
980  {
981  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
982  $bib_gui =& new ilBibItemGUI();
983  $bib_gui->setObject($this->object);
984  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
985  $bib_gui->bib_obj->delete($_GET["bibItemName"], $_GET["bibItemPath"], $bibItemIndex);
986  if (strpos($bibItemIndex, ",") > 0)
987  {
988  $bibItemIndex = substr($bibItemIndex, 0, strpos($bibItemIndex, ","));
989  }
990  if ($a_target == "")
991  {
992  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
993  }
994 
995  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
996  }
997 
1001  function deleteBibItem()
1002  {
1003  $this->setTabs();
1004 
1005  // questionable workaround to make this old stuff work
1006  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1007 
1008  $this->deleteBibItemObject($this->ctrl->getLinkTarget($this));
1009  }
1010 
1011 
1015  function editBibItemObject($a_target = "")
1016  {
1017  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1018  $bib_gui =& new ilBibItemGUI();
1019  $bib_gui->setObject($this->object);
1020  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1021  $bibItemIndex *= 1;
1022  if ($bibItemIndex < 0)
1023  {
1024  $bibItemIndex = 0;
1025  }
1026  if ($a_target == "")
1027  {
1028  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1029  }
1030 
1031  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1032  }
1033 
1037  function editBibItem()
1038  {
1039  $this->setTabs();
1040 
1041  // questionable workaround to make this old stuff work
1042  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1043 
1044  $this->editBibItemObject($this->ctrl->getLinkTarget($this));
1045  }
1046 
1050  function saveBibItemObject($a_target = "")
1051  {
1052  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1053  $bib_gui =& new ilBibItemGUI();
1054  $bib_gui->setObject($this->object);
1055  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1056  $bibItemIndex *= 1;
1057  if ($bibItemIndex < 0)
1058  {
1059  $bibItemIndex = 0;
1060  }
1061  $bibItemIndex = $bib_gui->save($bibItemIndex);
1062 
1063  if ($a_target == "")
1064  {
1065  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1066  }
1067 
1068  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1069  }
1070 
1074  function saveBibItem()
1075  {
1076  $this->setTabs();
1077 
1078  // questionable workaround to make this old stuff work
1079  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1080 
1081  $this->saveBibItemObject($this->ctrl->getLinkTarget($this));
1082  }
1083 
1089  function exportObject()
1090  {
1091  return;
1092  }
1093 
1099  function importObject()
1100  {
1101  $this->createObject();
1102  return;
1103  }
1104 
1105 
1112  function importFileObject()
1113  {
1114  global $_FILES, $rbacsystem, $ilDB, $tpl;
1115 
1116  include_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
1117 
1118  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
1119  {
1120  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
1121  return;
1122  }
1123 
1124  $form = $this->initImportForm();
1125  if ($form->checkInput())
1126  {
1127  // create and insert object in objecttree
1128  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
1129  $newObj = new ilObjContentObject();
1130  $newObj->setType($_GET["new_type"]);
1131  $newObj->setTitle($_FILES["xmldoc"]["name"]);
1132  $newObj->setDescription("");
1133  $newObj->create(true);
1134  $newObj->createReference();
1135  $newObj->putInTree($_GET["ref_id"]);
1136  $newObj->setPermissions($_GET["ref_id"]);
1137  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
1138 
1139  // create learning module tree
1140  $newObj->createLMTree();
1141 
1142  // import lm from file
1143  $mess = $newObj->importFromZipFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"],
1144  $_POST["validate"]);
1145 
1146  if ($mess == "")
1147  {
1148  ilUtil::sendSuccess($this->lng->txt($this->type."_added"),true);
1149  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1150  "&baseClass=ilLMEditorGUI");
1151  }
1152  else
1153  {
1154  $link = '<a href="'."ilias.php?ref_id=".$newObj->getRefId().
1155  "&baseClass=ilLMEditorGUI".'" target="_top">'.$this->lng->txt("btn_next").'</a>';
1156  $tpl->setContent("<br />".$link."<br /><br />".$mess.$link);
1157  }
1158  }
1159  else
1160  {
1161  $form->setValuesByPost();
1162  $tpl->setContent($form->getHtml());
1163  }
1164  }
1165 
1169  function chapters()
1170  {
1171  global $tree, $lng, $ilCtrl, $ilUser;
1172 
1173  $this->setTabs();
1174  $this->setContentSubTabs("chapters");
1175 
1176  if ($ilUser->getPref("lm_js_chapter_editing") != "disable")
1177  {
1178  $ilCtrl->setParameter($this, "backcmd", "chapters");
1179 
1180  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1181  $form_gui = new ilChapterHierarchyFormGUI($this->object->getType());
1182  $form_gui->setFormAction($ilCtrl->getFormAction($this));
1183  $form_gui->setTitle($this->object->getTitle());
1184  $form_gui->setIcon(ilUtil::getImagePath("icon_lm.png"));
1185  $form_gui->setTree($this->lm_tree);
1186  $form_gui->setMaxDepth(0);
1187  $form_gui->setCurrentTopNodeId($this->tree->getRootId());
1188  $form_gui->addMultiCommand($lng->txt("delete"), "delete");
1189  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
1190  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
1191  if ($this->object->getLayoutPerPage())
1192  {
1193  $form_gui->addMultiCommand($lng->txt("cont_set_layout"), "setPageLayoutInHierarchy");
1194  }
1195  $form_gui->setDragIcon(ilUtil::getImagePath("icon_st_s.png"));
1196  $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
1197  $up_gui = ($this->object->getType() == "dbk")
1198  ? "ilobjdlbookgui"
1199  : "ilobjlearningmodulegui";
1200  $form_gui->setExplorerUpdater("tree", "tree_div",
1201  $ilCtrl->getLinkTargetByClass($up_gui, "explorer", "", true));
1202 
1203  $ctpl = new ilTemplate("tpl.chap_and_pages.html", true, true, "Modules/LearningModule");
1204  $ctpl->setVariable("HIERARCHY_FORM", $form_gui->getHTML());
1205  $ilCtrl->setParameter($this, "obj_id", "");
1206  $ctpl->setVariable("HREF_NO_JS_EDIT",
1207  $ilCtrl->getLinkTarget($this, "deactivateJSChapterEditing"));
1208  $ctpl->setVariable("TXT_NO_JS_EDIT",
1209  $lng->txt("cont_not_js_chap_editing"));
1210 
1211  $this->tpl->setContent($ctpl->get());
1212  }
1213  else
1214  {
1215  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", "Modules/LearningModule");
1216  $num = 0;
1217 
1218  $this->ctrl->setParameter($this, "backcmd", "chapters");
1219  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1220  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_chapters"));
1221  $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
1222 
1223  $cnt = 0;
1224  $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
1225  foreach ($childs as $child)
1226  {
1227  if($child["type"] != "st")
1228  {
1229  continue;
1230  }
1231 
1232  $this->tpl->setCurrentBlock("table_row");
1233  // color changing
1234  $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
1235 
1236  // checkbox
1237  $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
1238  $this->tpl->setVariable("CSS_ROW", $css_row);
1239  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.png"));
1240 
1241  // link
1242  $this->ctrl->setParameter($this, "backcmd", "");
1243  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
1244  $this->tpl->setVariable("LINK_TARGET",
1245  $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view"));
1246 
1247  // title
1248  $this->tpl->setVariable("TEXT_CONTENT",
1250  $this->object->isActiveNumbering()));
1251 
1252  $this->tpl->parseCurrentBlock();
1253  }
1254 
1255  $paste_active = false;
1256  if ($ilUser->clipboardHasObjectsOfType("st"))
1257  {
1258  $paste_active = true;
1259  }
1260 
1261  if($cnt == 0 && !$paste_active)
1262  {
1263  $this->tpl->setCurrentBlock("notfound");
1264  $this->tpl->setVariable("NUM_COLS", 3);
1265  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1266  $this->tpl->parseCurrentBlock();
1267  }
1268  else
1269  {
1270  // SHOW VALID ACTIONS
1271  $this->tpl->setVariable("NUM_COLS", 3);
1272  if ($cnt > 0)
1273  {
1274  $acts = array("delete" => "delete", "cutChapter" => "cut",
1275  "copyChapter" => "copyChapter");
1276  }
1277  if ($paste_active)
1278  {
1279  $acts["pasteChapter"] = "pasteChapter";
1280  }
1281  $this->showActions($acts);
1282  }
1283 
1284  // SHOW POSSIBLE SUB OBJECTS
1285  $this->tpl->setVariable("NUM_COLS", 3);
1286  $subobj = array("st");
1287  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1288  $this->tpl->setCurrentBlock("add_object");
1289  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1290  $this->tpl->setVariable("BTN_NAME", "create");
1291  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
1292  $this->tpl->parseCurrentBlock();
1293 
1294  $this->tpl->setCurrentBlock("form");
1295  $this->tpl->parseCurrentBlock();
1296 
1297  $this->tpl->setVariable("HREF_JS_EDIT",
1298  $ilCtrl->getLinkTarget($this, "activateJSChapterEditing"));
1299  $this->tpl->setVariable("TXT_JS_EDIT",
1300  $lng->txt("cont_js_chap_editing"));
1301  }
1302  }
1303 
1304 
1305  /*
1306  * List all pages of learning module
1307  */
1308  function pages()
1309  {
1310  global $tree, $tpl, $ilToolbar, $ilCtrl, $lng;
1311 
1312  $this->setTabs();
1313  $this->setContentSubTabs("pages");
1314 
1315  if (!false)
1316  {
1317  $ilCtrl->setParameter($this, "backcmd", "pages");
1318  $ilCtrl->setParameterByClass("illmpageobjectgui", "new_type", "pg");
1319  $ilToolbar->addButton($lng->txt("pg_add"),
1320  $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "create"));
1321  $ilCtrl->setParameterByClass("illmpageobjectgui", "new_type", "");
1322 
1323  include_once("./Modules/LearningModule/classes/class.ilLMPagesTableGUI.php");
1324  $t = new ilLMPagesTableGUI($this, "pages", $this->object);
1325  $tpl->setContent($t->getHTML());
1326 
1327  return;
1328  }
1329 
1330 
1331  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.all_pages.html", "Modules/LearningModule");
1332  $num = 0;
1333 
1334  $this->tpl->setCurrentBlock("form");
1335  $this->ctrl->setParameter($this, "backcmd", "pages");
1336  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1337  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_pages"));
1338  $this->tpl->setVariable("CONTEXT", $this->lng->txt("cont_usage"));
1339  $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
1340 
1341  $cnt = 0;
1342  $pages = ilLMPageObject::getPageList($this->object->getId());
1343  foreach ($pages as $page)
1344  {
1345  $this->tpl->setCurrentBlock("table_row");
1346 
1347  // check activation
1348  include_once("./Services/COPage/classes/class.ilPageObject.php");
1349  $lm_set = new ilSetting("lm");
1350  $active = ilPageObject::_lookupActive($page["obj_id"], $this->object->getType(),
1351  $lm_set->get("time_scheduled_page_activation"));
1352 
1353  // is page scheduled?
1354  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
1355  ilPageObject::_isScheduledActivation($page["obj_id"], $this->object->getType()))
1356  ? "_sc"
1357  : "";
1358 
1359  if (!$active)
1360  {
1361  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg_d".$img_sc.".png"));
1362  $this->tpl->setVariable("IMG_ALT",
1363  $this->lng->txt("cont_page_deactivated"));
1364  }
1365  else
1366  {
1368  $this->object->getType()))
1369  {
1370  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg_del".$img_sc.".png"));
1371  $this->tpl->setVariable("IMG_ALT",
1372  $this->lng->txt("cont_page_deactivated_elements"));
1373  }
1374  else
1375  {
1376  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg".$img_sc.".png"));
1377  $this->tpl->setVariable("IMG_ALT",
1378  $this->lng->txt("pg"));
1379  }
1380  }
1381 
1382  // color changing
1383  $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
1384 
1385  // checkbox
1386  $this->tpl->setVariable("CHECKBOX_ID", $page["obj_id"]);
1387  $this->tpl->setVariable("CSS_ROW", $css_row);
1388 
1389  // link
1390  $this->ctrl->setParameter($this, "backcmd", "");
1391  $this->ctrl->setParameterByClass("ilLMPageObjectGUI", "obj_id", $page["obj_id"]);
1392 //echo "<br>:".$this->ctrl->getLinkTargetByClass("ilLMPageObjectGUI", "view").":";
1393  $this->tpl->setVariable("LINK_TARGET",
1394  $this->ctrl->getLinkTargetByClass("ilLMPageObjectGUI", "edit"));
1395 
1396  // title
1397  $this->tpl->setVariable("TEXT_CONTENT", $page["title"]);
1398 
1399  // context
1400  if ($this->lm_tree->isInTree($page["obj_id"]))
1401  {
1402  $path_str = $this->getContextPath($page["obj_id"]);
1403  }
1404  else
1405  {
1406  $path_str = "---";
1407  }
1408 
1409  // check whether page is header or footer
1410  $add_str = "";
1411  if ($page["obj_id"] == $this->object->getHeaderPage())
1412  {
1413  $add_str = " <b>(".$this->lng->txt("cont_header").")</b>";
1414  }
1415  if ($page["obj_id"] == $this->object->getFooterPage())
1416  {
1417  $add_str = " <b>(".$this->lng->txt("cont_footer").")</b>";
1418  }
1419 
1420  $this->tpl->setVariable("TEXT_CONTEXT", $path_str.$add_str);
1421 
1422 
1423  $this->tpl->parseCurrentBlock();
1424  }
1425  if($cnt == 0)
1426  {
1427  $this->tpl->setCurrentBlock("notfound");
1428  $this->tpl->setVariable("NUM_COLS", 4);
1429  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1430  $this->tpl->parseCurrentBlock();
1431  }
1432  else
1433  {
1434  $acts = array("delete" => "delete", "movePage" => "movePage", "copyPage" => "copyPage",
1435  "selectHeader" => "selectHeader", "selectFooter" => "selectFooter",
1436  "activatePages" => "cont_de_activate");
1438  ilEditClipboard::getAction() == "copy")
1439  {
1440  $acts["pastePage"] = "pastePage";
1441  }
1442 
1443  /*
1444  if (ilEditClipboard::getContentObjectType() == "st")
1445  {
1446  $acts["pasteChapter"] = "pasteChapter";
1447  }*/
1448  $this->tpl->setVariable("NUM_COLS", 4);
1449  $this->showActions($acts);
1450 
1451  // SHOW VALID ACTIONS
1452  /*
1453  $this->tpl->setCurrentBlock("operation_btn");
1454  $this->tpl->setVariable("BTN_NAME", "delete");
1455  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1456  $this->tpl->parseCurrentBlock();*/
1457 
1458  }
1459 
1460  // SHOW POSSIBLE SUB OBJECTS
1461  $this->tpl->setVariable("NUM_COLS", 4);
1462  //$this->showPossibleSubObjects("st");
1463  $subobj = array("pg");
1464  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1465  $this->tpl->setCurrentBlock("add_object");
1466  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1467  $this->tpl->setVariable("BTN_NAME", "create");
1468  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("create"));
1469  $this->tpl->parseCurrentBlock();
1470 
1471 
1472  $this->tpl->setCurrentBlock("form");
1473  $this->tpl->parseCurrentBlock();
1474 
1475  }
1476 
1480  function listLinks()
1481  {
1482  global $tpl;
1483 
1484  $this->setTabs();
1485  $this->setContentSubTabs("internal_links");
1486 
1487  include_once("./Modules/LearningModule/classes/class.ilLinksTableGUI.php");
1488  $table_gui = new ilLinksTableGUI($this, "listLinks",
1489  $this->object->getId(), $this->object->getType());
1490 
1491  $tpl->setContent($table_gui->getHTML());
1492  }
1493 
1497  function showMaintenance()
1498  {
1499  global $tpl, $ilToolbar;
1500 
1501  $this->setTabs();
1502  $this->setContentSubTabs("maintenance");
1503 
1504  $ilToolbar->addButton($this->lng->txt("cont_fix_tree"),
1505  $this->ctrl->getLinkTarget($this, "fixTreeConfirm"));
1506  }
1507 
1511  function activatePages()
1512  {
1513  if (is_array($_POST["id"]))
1514  {
1515  foreach($_POST["id"] as $id)
1516  {
1517  include_once("./Services/COPage/classes/class.ilPageObject.php");
1518  $act = ilPageObject::_lookupActive($id, $this->object->getType());
1519  ilPageObject::_writeActive($id, $this->object->getType(), !$act);
1520  }
1521  }
1522 
1523  $this->ctrl->redirect($this, "pages");
1524  }
1525 
1530  {
1531  global $ilCtrl, $ilUser;
1532 
1533  $ilUser->writePref("lm_js_chapter_editing", "disable");
1534  $ilCtrl->redirect($this, "chapters");
1535  }
1536 
1541  {
1542  global $ilCtrl, $ilUser;
1543 
1544  $ilUser->writePref("lm_js_chapter_editing", "enable");
1545  $ilCtrl->redirect($this, "chapters");
1546  }
1547 
1551  function pastePage()
1552  {
1554  {
1555  $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
1556  }
1557 
1558  // paste selected object
1560 
1561  // copy page, if action is copy
1562  if (ilEditClipboard::getAction() == "copy")
1563  {
1564  // check wether page belongs to lm
1566  == $this->object->getID())
1567  {
1568  $lm_page = new ilLMPageObject($this->object, $id);
1569  $new_page =& $lm_page->copy();
1570  $id = $new_page->getId();
1571  }
1572  else
1573  {
1574  // get page from other content object into current content object
1576  $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
1577  $lm_page = new ilLMPageObject($lm_obj, $id);
1578  $copied_nodes = array();
1579  $new_page =& $lm_page->copyToOtherContObject($this->object, $copied_nodes);
1580  $id = $new_page->getId();
1581  ilLMObject::updateInternalLinks($copied_nodes);
1582  }
1583  }
1584 
1585  // cut is not be possible in "all pages" form yet
1586  if (ilEditClipboard::getAction() == "cut")
1587  {
1588  // check wether page belongs not to lm
1590  != $this->object->getID())
1591  {
1593  $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
1594  $lm_page = new ilLMPageObject($lm_obj, $id);
1595  $lm_page->setLMId($this->object->getID());
1596  $lm_page->update();
1597  $page =& $lm_page->getPageObject();
1598  $page->buildDom();
1599  $page->setParentId($this->object->getID());
1600  $page->update();
1601  }
1602  }
1603 
1604 
1606  $this->ctrl->redirect($this, "pages");
1607  }
1608 
1612  function copyPage()
1613  {
1614  global $ilUser;
1615 
1616  if(!isset($_POST["id"]))
1617  {
1618  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1619  }
1620 
1621  $items = ilUtil::stripSlashesArray($_POST["id"]);
1622  ilLMObject::clipboardCopy($this->object->getId(), $items);
1624 
1625  if ($ilUser->getPref("lm_js_chapter_editing") != "disable")
1626  {
1627  ilUtil::sendInfo($this->lng->txt("cont_selected_items_have_been_copied"), true);
1628  }
1629  else
1630  {
1631  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"), true);
1632  }
1633 
1634  $this->ctrl->redirect($this, "pages");
1635  }
1636 
1644  function delete($a_parent_subobj_id = 0)
1645  {
1646  if(!isset($_POST["id"]))
1647  {
1648  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1649  }
1650 
1651  if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
1652  {
1653  $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
1654  }
1655 
1656  if ($a_parent_subobj_id == 0)
1657  {
1658  $this->setTabs();
1659  }
1660 
1661  if ($a_parent_subobj_id != 0)
1662  {
1663  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "backcmd", $_GET["backcmd"]);
1664  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $a_parent_subobj_id);
1665  $form_action = $this->ctrl->getFormActionByClass("ilStructureObjectGUI");
1666  }
1667  else
1668  {
1669  $this->ctrl->setParameter($this, "backcmd", $_GET["backcmd"]);
1670  $form_action = $this->ctrl->getFormAction($this);
1671  }
1672 
1673  // display confirmation message
1674  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1675  $cgui = new ilConfirmationGUI();
1676  $cgui->setFormAction($form_action);
1677  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
1678  $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
1679  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
1680 
1681  foreach($_POST["id"] as $id)
1682  {
1683  if ($id != IL_FIRST_NODE)
1684  {
1685  $obj = new ilLMObject($this->object, $id);
1686  $caption = ilUtil::getImageTagByType($obj->getType(), $this->tpl->tplPath).
1687  " ".$obj->getTitle();
1688 
1689  $cgui->addItem("id[]", $id, $caption);
1690  }
1691  }
1692 
1693  $this->tpl->setContent($cgui->getHTML());
1694  }
1695 
1699  function cancelDelete()
1700  {
1701  $this->ctrl->redirect($this, $_GET["backcmd"]);
1702 
1703  }
1704 
1712  function confirmedDelete($a_parent_subobj_id = 0)
1713  {
1714  $tree = new ilTree($this->object->getId());
1715  $tree->setTableNames('lm_tree','lm_data');
1716  $tree->setTreeTablePK("lm_id");
1717 
1718  // check number of objects
1719  if (!$_POST["id"])
1720  {
1721  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1722  }
1723 
1724  // delete all selected objects
1725  foreach ($_POST["id"] as $id)
1726  {
1727  if ($id != IL_FIRST_NODE)
1728  {
1729  $obj =& ilLMObjectFactory::getInstance($this->object, $id, false);
1730  $node_data = $tree->getNodeData($id);
1731  if (is_object($obj))
1732  {
1733  $obj->setLMId($this->object->getId());
1734 
1735  include_once("./Services/History/classes/class.ilHistory.php");
1736  ilHistory::_createEntry($this->object->getId(), "delete_".$obj->getType(),
1737  array(ilLMObject::_lookupTitle($id), $id),
1738  $this->object->getType());
1739 
1740  $obj->delete();
1741  }
1742  if($tree->isInTree($id))
1743  {
1744  $tree->deleteTree($node_data);
1745  }
1746  }
1747  }
1748 
1749  // check the tree
1750  $this->object->checkTree();
1751 
1752  // feedback
1753  ilUtil::sendSuccess($this->lng->txt("info_deleted"),true);
1754 
1755  if ($a_parent_subobj_id == 0)
1756  {
1757  $this->ctrl->redirect($this, $_GET["backcmd"]);
1758  }
1759  }
1760 
1761 
1762 
1769  function getContextPath($a_endnode_id, $a_startnode_id = 1)
1770  {
1771  $path = "";
1772 
1773  $tmpPath = $this->lm_tree->getPathFull($a_endnode_id, $a_startnode_id);
1774 
1775  // count -1, to exclude the learning module itself
1776  for ($i = 1; $i < (count($tmpPath) - 1); $i++)
1777  {
1778  if ($path != "")
1779  {
1780  $path .= " > ";
1781  }
1782 
1783  $path .= $tmpPath[$i]["title"];
1784  }
1785 
1786  return $path;
1787  }
1788 
1789 
1790 
1796  function showActions($a_actions)
1797  {
1798  foreach ($a_actions as $name => $lng)
1799  {
1800  $d[$name] = array("name" => $name, "lng" => $lng);
1801  }
1802 
1803  $notoperations = array();
1804 
1805  $operations = array();
1806 
1807  if (is_array($d))
1808  {
1809  foreach ($d as $row)
1810  {
1811  if (!in_array($row["name"], $notoperations))
1812  {
1813  $operations[] = $row;
1814  }
1815  }
1816  }
1817 
1818  if (count($operations)>0)
1819  {
1820  foreach ($operations as $val)
1821  {
1822  $this->tpl->setCurrentBlock("operation_btn");
1823  $this->tpl->setVariable("BTN_NAME", $val["name"]);
1824  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
1825  $this->tpl->parseCurrentBlock();
1826  }
1827 
1828  $this->tpl->setCurrentBlock("operation");
1829  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.png"));
1830  $this->tpl->parseCurrentBlock();
1831  }
1832  }
1833 
1837  function perm()
1838  {
1839  $this->setTabs();
1840 
1841  $this->setFormAction("addRole", $this->ctrl->getLinkTarget($this, "addRole"));
1842  $this->setFormAction("permSave", $this->ctrl->getLinkTarget($this, "permSave"));
1843  $this->permObject();
1844  }
1845 
1846 
1850  function permSave()
1851  {
1852  $this->setReturnLocation("permSave", $this->ctrl->getLinkTarget($this, "perm"));
1853  $this->permSaveObject();
1854  }
1855 
1859  function info()
1860  {
1861  $this->setTabs();
1862  $this->infoObject();
1863  }
1864 
1865 
1869  function addRole()
1870  {
1871  $this->setReturnLocation("addRole", $this->ctrl->getLinkTarget($this, "perm"));
1872  $this->addRoleObject();
1873  }
1874 
1875 
1879  function owner()
1880  {
1881  $this->setTabs();
1882  $this->ownerObject();
1883  }
1884 
1885 
1889  function view()
1890  {
1891  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
1892  {
1893  $this->prepareOutput();
1895  }
1896  else
1897  {
1898  $this->viewObject();
1899  }
1900  }
1901 
1902 
1906  function moveChapter($a_parent_subobj_id = 0)
1907  {
1908  if(!isset($_POST["id"]))
1909  {
1910  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1911  }
1912 //echo "Hallo::"; exit;
1913  if(count($_POST["id"]) > 1)
1914  {
1915  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1916  }
1917 
1918  if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
1919  {
1920  $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
1921  }
1922 
1923  // SAVE POST VALUES
1924  ilEditClipboard::storeContentObject("st", $_POST["id"][0], "move");
1925 
1926  ilUtil::sendInfo($this->lng->txt("cont_chap_select_target_now"), true);
1927 
1928  if ($a_parent_subobj_id == 0)
1929  {
1930  $this->ctrl->redirect($this, "chapters");
1931  }
1932  }
1933 
1934 
1938  function copyChapter($a_parent_subobj_id = 0)
1939  {
1940  $this->copyItems();
1941  }
1942 
1946  function pasteChapter($a_parent_subobj_id = 0)
1947  {
1948  return $this->insertChapterClip(false);
1949  }
1950 
1954  function movePage()
1955  {
1956  global $ilUser;
1957 
1958  if(!isset($_POST["id"]))
1959  {
1960  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1961  }
1962 
1963  if ($ilUser->getPref("lm_js_chapter_editing") != "disable")
1964  {
1965  ilUtil::sendInfo($this->lng->txt("cont_selected_items_have_been_cut"), true);
1966  }
1967  else
1968  {
1969  ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
1970  }
1971 
1972  $items = ilUtil::stripSlashesArray($_POST["id"]);
1973  ilLMObject::clipboardCut($this->object->getId(), $items);
1975 
1976  $this->ctrl->redirect($this, "pages");
1977  }
1978 
1982  function cancel()
1983  {
1984  if ($_GET["new_type"] == "pg")
1985  {
1986  $this->ctrl->redirect($this, "pages");
1987  }
1988  else
1989  {
1990  $this->ctrl->redirect($this, "chapters");
1991  }
1992  }
1993 
1994 
1998  function export()
1999  {
2000  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2001  $cont_exp = new ilContObjectExport($this->object);
2002  $cont_exp->buildExportFile();
2003 // $this->ctrl->redirect($this, "exportList");
2004  }
2005 
2009  function getPublicAccessColValue($a_type, $a_file)
2010  {
2011  global $lng, $ilCtrl;
2012 
2013  $changelink = "<a href='".$ilCtrl->getLinkTarget($this, "editMenuProperties")."'>".$lng->txt("change")."</a>";
2014  if (!$this->object->isActiveLMMenu())
2015  {
2016  $add = "<br />".$lng->txt("cont_download_no_menu")." ".$changelink;
2017  }
2018  else if (!$this->object->isActiveDownloads())
2019  {
2020  $add = "<br />".$lng->txt("cont_download_no_download")." ".$changelink;
2021  }
2022 
2023 
2024  if ($this->object->getPublicExportFile($a_type) == $a_file)
2025  {
2026  return $lng->txt("yes").$add;
2027  }
2028 
2029  return " ";
2030  }
2031 
2032 
2033 
2037  function publishExportFile($a_files)
2038  {
2039  global $ilCtrl;
2040 
2041  if(!isset($a_files))
2042  {
2043  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
2044  }
2045  else
2046  {
2047  foreach ($a_files as $f)
2048  {
2049  $file = explode(":", $f);
2050  $export_dir = $this->object->getExportDirectory($file[0]);
2051 
2052  if ($this->object->getPublicExportFile($file[0]) ==
2053  $file[1])
2054  {
2055  $this->object->setPublicExportFile($file[0], "");
2056  }
2057  else
2058  {
2059  $this->object->setPublicExportFile($file[0], $file[1]);
2060  }
2061  }
2062  $this->object->update();
2063  }
2064  $ilCtrl->redirectByClass("ilexportgui");
2065  }
2066 
2070  function downloadPDFFile()
2071  {
2072  if(!isset($_POST["file"]))
2073  {
2074  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2075  }
2076 
2077  if (count($_POST["file"]) > 1)
2078  {
2079  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2080  }
2081 
2082 
2083  $export_dir = $this->object->getOfflineDirectory();
2084 
2085  $file = basename($_POST["file"][0]);
2086 
2087  ilUtil::deliverFile($export_dir."/".$file, $file);
2088  }
2089 
2090 
2095  function fixTreeConfirm()
2096  {
2097  $this->setTabs();
2098  $this->setContentSubTabs("maintenance");
2099 
2100  // display confirmation message
2101  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2102  $cgui = new ilConfirmationGUI();
2103  $cgui->setFormAction($this->ctrl->getFormAction($this));
2104  $cgui->setHeaderText($this->lng->txt("cont_fix_tree_confirm"));
2105  $cgui->setCancel($this->lng->txt("cancel"), "showMaintenance");
2106  $cgui->setConfirm($this->lng->txt("cont_fix_tree"), "fixTree");
2107 
2108  $this->tpl->setContent($cgui->getHTML());
2109  }
2110 
2114  function fixTree()
2115  {
2116  $this->object->fixTree();
2117  ilUtil::sendSuccess($this->lng->txt("cont_tree_fixed"), true);
2118  $this->ctrl->redirect($this, "showMaintenance");
2119  }
2120 
2124  function setilLMMenu($a_offline = false, $a_export_format = "",
2125  $a_active = "content", $a_use_global_tabs = false, $a_as_subtabs = false,
2126  $a_cur_page = 0)
2127  {
2128  global $ilCtrl,$ilUser, $ilAccess, $ilTabs, $rbacsystem, $ilPluginAdmin;
2129 
2130 
2131  if ($a_as_subtabs)
2132  {
2133  $addcmd = "addSubTabTarget";
2134  $getcmd = "getSubTabHTML";
2135  }
2136  else
2137  {
2138  $addcmd = "addTarget";
2139  $getcmd = "getHTML";
2140  }
2141 
2142  $active[$a_active] = true;
2143 
2144  if (!$this->object->isActiveLMMenu())
2145  {
2146  return "";
2147  }
2148 
2149  if ($a_use_global_tabs)
2150  {
2151  $tabs_gui = $ilTabs;
2152  }
2153  else
2154  {
2155  $tabs_gui = new ilTabsGUI();
2156  }
2157 
2158  // Determine whether the view of a learning resource should
2159  // be shown in the frameset of ilias, or in a separate window.
2160  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
2161  $showViewInFrameset = true;
2162 
2163  if ($showViewInFrameset && !$a_offline)
2164  {
2165  $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
2166  }
2167  else
2168  {
2169  $buttonTarget = "_top";
2170  }
2171 
2172  if ($a_export_format == "scorm")
2173  {
2174  $buttonTarget = "";
2175  }
2176 
2177  include_once("./Services/Payment/classes/class.ilPaymentObject.php");
2178  $requires_purchase_to_access = ilPaymentObject::_requiresPurchaseToAccess((int)$_GET['ref_id']);
2179 
2180  // content
2181  if (!$a_offline && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2182  {
2183  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2184  $tabs_gui->$addcmd("content",
2185  $ilCtrl->getLinkTargetByClass("illmpresentationgui", "layout"),
2186  "", "", $buttonTarget, $active["content"]);
2187  }
2188 
2189  // table of contents
2190  if (!$requires_purchase_to_access && $this->object->isActiveTOC() && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2191  {
2192  if (!$a_offline)
2193  {
2194  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2195  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showTableOfContents");
2196  }
2197  else
2198  {
2199  $link = "./table_of_contents.html";
2200  }
2201 
2202  $tabs_gui->$addcmd("cont_toc", $link,
2203  "", "", $buttonTarget, $active["toc"]);
2204  }
2205 
2206  // print view
2207  if (!$requires_purchase_to_access && $this->object->isActivePrintView() && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2208  {
2209  if (!$a_offline) // has to be implemented for offline mode
2210  {
2211  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2212  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showPrintViewSelection");
2213  $tabs_gui->$addcmd("cont_print_view", $link,
2214  "", "", $buttonTarget, $active["print"]);
2215  }
2216  }
2217 
2218  // download
2219  if (!$requires_purchase_to_access && $ilUser->getId() == ANONYMOUS_USER_ID)
2220  {
2221  $is_public = $this->object->isActiveDownloadsPublic();
2222  }
2223  else if(!$requires_purchase_to_access)
2224  {
2225  $is_public = true;
2226  }
2227 
2228  if (!$requires_purchase_to_access && $this->object->isActiveDownloads() && !$a_offline && $is_public &&
2229  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2230  {
2231  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2232  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showDownloadList");
2233  $tabs_gui->$addcmd("download", $link,
2234  "", "", $buttonTarget, $active["download"]);
2235  }
2236 
2237  // info button
2238  if ($a_export_format != "scorm" && !$a_offline)
2239  {
2240  if (!$a_offline)
2241  {
2242  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2243  $link = $this->ctrl->getLinkTargetByClass(
2244  array("illmpresentationgui", "ilinfoscreengui"), "showSummary");
2245  }
2246  else
2247  {
2248  $link = "./info.html";
2249  }
2250 
2251  $tabs_gui->$addcmd(($requires_purchase_to_access ? 'buy' : 'info_short'), $link,
2252  "", "", $buttonTarget, $active["info"]);
2253  }
2254 
2255  // edit learning module
2256  if (!$a_offline && $a_cur_page > 0)
2257  {
2258  if ($rbacsystem->checkAccess("write", $_GET["ref_id"]))
2259  {
2260  //$page_id = $this->getCurrentPageId();
2261  $page_id = $a_cur_page;
2262  $tabs_gui->$addcmd("edit_page", ILIAS_HTTP_PATH."/ilias.php?baseClass=ilLMEditorGUI&ref_id=".$_GET["ref_id"].
2263  "&obj_id=".$page_id."&to_page=1",
2264  "", "", $buttonTarget, $active["edit_page"]);
2265  }
2266  }
2267 
2268  if(!$requires_purchase_to_access)
2269  {
2270  // get user defined menu entries
2271  $this->__initLMMenuEditor();
2272  $entries = $this->lmme_obj->getMenuEntries(true);
2273 
2274  if (count($entries) > 0 && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2275  {
2276  foreach ($entries as $entry)
2277  {
2278  // build goto-link for internal resources
2279  if ($entry["type"] == "intern")
2280  {
2281  $entry["link"] = ILIAS_HTTP_PATH."/goto.php?target=".$entry["link"];
2282  }
2283 
2284  // add http:// prefix if not exist
2285  if (!strstr($entry["link"],'://') && !strstr($entry["link"],'mailto:'))
2286  {
2287  $entry["link"] = "http://".$entry["link"];
2288  }
2289 
2290  if (!strstr($entry["link"],'mailto:'))
2291  {
2292  $entry["link"] = ilUtil::appendUrlParameterString($entry["link"], "ref_id=".$this->ref_id."&structure_id=".$this->obj_id);
2293  }
2294  $tabs_gui->$addcmd($entry["title"],
2295  $entry["link"],
2296  "", "", "_blank", "", true);
2297  }
2298  }
2299  }
2300 
2301  // user interface hook [uihk]
2302  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
2303  $plugin_html = false;
2304  foreach ($pl_names as $pl)
2305  {
2306  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
2307  $gui_class = $ui_plugin->getUIClassInstance();
2308  $resp = $gui_class->modifyGUI("Modules/LearningModule", "lm_menu_tabs",
2309  array("lm_menu_tabs" => $tabs_gui));
2310  }
2311 
2312 
2313  return $tabs_gui->$getcmd();
2314  }
2315 
2319  function createPDF()
2320  {
2321  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2322  $cont_exp = new ilContObjectExport($this->object, "pdf");
2323  $cont_exp->buildExportFile();
2324  $this->offlineList();
2325  }
2326 
2330  function exportHTML()
2331  {
2332  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2333  $cont_exp = new ilContObjectExport($this->object, "html");
2334  $cont_exp->buildExportFile();
2335 //echo $this->tpl->get();
2336 // $this->ctrl->redirect($this, "exportList");
2337  }
2338 
2342  function exportSCORM()
2343  {
2344  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2345  $cont_exp = new ilContObjectExport($this->object, "scorm");
2346  $cont_exp->buildExportFile();
2347 //echo $this->tpl->get();
2348 // $this->ctrl->redirect($this, "exportList");
2349  }
2350 
2356  function addLocations($a_omit_obj_id = false)
2357  {
2358  global $lng, $tree, $ilLocator, $ilCtrl;
2359 
2360  $par_id = $tree->getParentId($_GET["ref_id"]);
2361  $parent_title = ilObject::_lookupTitle(ilObject::_lookupObjId($par_id));
2362 
2363  // parent is not root folder, "shorten" locator
2364  if($par_id != ROOT_FOLDER_ID)
2365  {
2366  $this->ctrl->addLocation("...",
2367  "");
2368  }
2369  else
2370  {
2371  // if parent is root folder and has no custom title
2372  // we adapt it [see $ilLocator->addRepositoryItems()]
2373  if ($parent_title == "ILIAS")
2374  {
2375  $parent_title = $lng->txt("repository");
2376  }
2377  }
2378 
2379  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $par_id);
2380  $this->ctrl->addLocation($parent_title,
2381  $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"),
2382  ilFrameTargetInfo::_getFrame("MainContent"), $par_id);
2383  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
2384 
2385  if (!$a_omit_obj_id)
2386  {
2387  $obj_id = $_GET["obj_id"];
2388  }
2389  $lmtree =& $this->object->getTree();
2390 
2391  if (($obj_id != 0) && $lmtree->isInTree($obj_id))
2392  {
2393  $path = $lmtree->getPathFull($obj_id);
2394  }
2395  else
2396  {
2397  $path = $lmtree->getPathFull($lmtree->getRootId());
2398  if ($obj_id != 0)
2399  {
2400  $path[] = array("type" => "pg", "child" => $this->obj_id,
2401  "title" => ilLMPageObject::_getPresentationTitle($this->obj_id));
2402  }
2403  }
2404 
2405  $modifier = 1;
2406 
2407  foreach ($path as $key => $row)
2408  {
2409  if ($row["child"] == 1)
2410  {
2411  $this->ctrl->setParameter($this, "obj_id", "");
2412  $this->ctrl->addLocation(
2413  $this->object->getTitle(),
2414  $this->ctrl->getLinkTarget($this, "chapters"), "", $_GET["ref_id"]);
2415  }
2416  else
2417  {
2418  $title = $row["title"];
2419  switch($row["type"])
2420  {
2421  case "st":
2422  $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $row["child"]);
2423  $this->ctrl->addLocation(
2424  $title,
2425  $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view"));
2426  break;
2427 
2428  case "pg":
2429  $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $row["child"]);
2430  $this->ctrl->addLocation(
2431  $title,
2432  $this->ctrl->getLinkTargetByClass("illmpageobjectgui", "edit"));
2433  break;
2434  }
2435  }
2436  }
2437  if (!$a_omit_obj_id)
2438  {
2439  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
2440  }
2441  }
2442 
2446 
2447 
2454  function listQuestions()
2455  {
2456  global $tpl;
2457 
2458  $this->setTabs();
2459  $this->setContentSubTabs("export_ids");
2460 
2461  include_once("./Modules/LearningModule/classes/class.ilLMQuestionListTableGUI.php");
2462  $table = new ilLMQuestionListTableGUI($this, "listQuestions", $this->object);
2463  $tpl->setContent($table->getHTML());
2464 
2465  }
2466 
2470 
2471 
2475  function setTabs($a_act = "")
2476  {
2477  global $lng, $ilHelp;
2478 
2479  $ilHelp->setScreenIdComponent("lm");
2480 
2481  $this->addTabs($a_act);
2482  $this->tpl->setTitle($this->object->getTitle());
2483  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.png"),
2484  $lng->txt("obj_lm"));
2485  }
2486 
2493  function setContentSubTabs($a_active)
2494  {
2495  global $ilTabs, $lng, $ilCtrl;
2496 
2497  $lm_set = new ilSetting("lm");
2498 
2499  // chapters
2500  $ilTabs->addSubtab("chapters",
2501  $lng->txt("cont_chapters"),
2502  $ilCtrl->getLinkTarget($this, "chapters"));
2503 
2504  // all pages
2505  $ilTabs->addSubtab("pages",
2506  $lng->txt("cont_all_pages"),
2507  $ilCtrl->getLinkTarget($this, "pages"));
2508 
2509  // questions
2510  $ilTabs->addSubtab("questions",
2511  $lng->txt("objs_qst"),
2512  $ilCtrl->getLinkTarget($this, "listQuestions"));
2513 
2514  // export ids
2515  if ($lm_set->get("html_export_ids"))
2516  {
2517  if (!ilObjContentObject::isOnlineHelpModule($this->object->getRefId()))
2518  {
2519  $ilTabs->addSubtab("export_ids",
2520  $lng->txt("cont_html_export_ids"),
2521  $ilCtrl->getLinkTarget($this, "showExportIDsOverview"));
2522  }
2523  }
2524  if (ilObjContentObject::isOnlineHelpModule($this->object->getRefId()))
2525  {
2526  $lng->loadLanguageModule("help");
2527  $ilTabs->addSubtab("export_ids",
2528  $lng->txt("cont_online_help_ids"),
2529  $ilCtrl->getLinkTarget($this, "showExportIDsOverview"));
2530 
2531  $ilTabs->addSubtab("help_tooltips",
2532  $lng->txt("help_tooltips"),
2533  $ilCtrl->getLinkTarget($this, "showTooltipList"));
2534  }
2535 
2536  // list links
2537  $ilTabs->addSubtab("internal_links",
2538  $lng->txt("cont_internal_links"),
2539  $ilCtrl->getLinkTarget($this, "listLinks"));
2540 
2541  // web link checker
2542  if ($this->object->getType() == "lm")
2543  {
2544  if(@include_once('HTTP/Request.php'))
2545  {
2546  $ilTabs->addSubtab("link_check",
2547  $lng->txt("link_check"),
2548  $ilCtrl->getLinkTarget($this, "linkChecker"));
2549  }
2550  }
2551 
2552  // maintenance
2553  $ilTabs->addSubtab("maintenance",
2554  $lng->txt("cont_maintenance"),
2555  $ilCtrl->getLinkTarget($this, "showMaintenance"));
2556 
2557  $ilTabs->activateSubTab($a_active);
2558  $ilTabs->activateTab("content");
2559  }
2560 
2564  function addTabs($a_act = "")
2565  {
2566  global $rbacsystem, $ilUser, $ilTabs, $lng;
2567 
2568 $tabs_gui = $ilTabs;
2569 
2570  // content
2571  $ilTabs->addTab("content",
2572  $lng->txt("content"),
2573  $this->ctrl->getLinkTarget($this, "chapters"));
2574 
2575  // info
2576  $ilTabs->addTab("info",
2577  $lng->txt("info_short"),
2578  $this->ctrl->getLinkTargetByClass("ilinfoscreengui",'showSummary'));
2579 
2580  // settings
2581  $ilTabs->addTab("settings",
2582  $lng->txt("settings"),
2583  $this->ctrl->getLinkTarget($this,'properties'));
2584 
2585  // learning progress
2586  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
2587  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()) and ($this->object->getType() == 'lm' or $this->object->getType() == 'dbk'))
2588  {
2589  $ilTabs->addTab('learning_progress',
2590  $lng->txt("learning_progress"),
2591  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''));
2592  }
2593 
2594  if ($this->object->getType() != "lm")
2595  {
2596  // bibliographical data
2597  $ilTabs->addTab("bib_data",
2598  $lng->txt("bib_data"),
2599  $this->ctrl->getLinkTarget($this, "editBibItem"));
2600  }
2601 
2602  // history
2603  $ilTabs->addTab("history",
2604  $lng->txt("history"),
2605  $this->ctrl->getLinkTarget($this, "history"));
2606 
2607  // meta data
2608  $ilTabs->addTab("meta",
2609  $lng->txt("meta_data"),
2610  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''));
2611 
2612  if ($this->object->getType() == "lm")
2613  {
2614  // export
2615  $ilTabs->addTab("export",
2616  $lng->txt("export"),
2617  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
2618  }
2619 
2620  // permissions
2621  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
2622  {
2623  $ilTabs->addTab("perm",
2624  $lng->txt("perm_settings"),
2625  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"));
2626  }
2627 
2628  if ($a_act != "")
2629  {
2630  $ilTabs->activateTab($a_act);
2631  }
2632 
2633  // presentation view
2634  $ilTabs->addNonTabbedLink("pres_mode", $lng->txt("cont_presentation_view"),
2635  "ilias.php?baseClass=ilLMPresentationGUI&ref_id=".$this->object->getRefID(), "_top");
2636  }
2637 
2641  function setSubTabs($a_active)
2642  {
2643  global $ilTabs, $ilSetting;
2644 
2645  if (in_array($a_active,
2646  array("cont_general_properties", "cont_style", "cont_lm_menu", "public_section")))
2647  {
2648  // general properties
2649  $ilTabs->addSubTabTarget("cont_general_properties",
2650  $this->ctrl->getLinkTarget($this, 'properties'),
2651  "", "");
2652 
2653  // style properties
2654  $ilTabs->addSubTabTarget("cont_style",
2655  $this->ctrl->getLinkTarget($this, 'editStyleProperties'),
2656  "", "");
2657 
2658  // menu properties
2659  $ilTabs->addSubTabTarget("cont_lm_menu",
2660  $this->ctrl->getLinkTarget($this, 'editMenuProperties'),
2661  "", "");
2662 
2663  if ($ilSetting->get("pub_section"))
2664  {
2665  if ($this->object->getType() != "dbk")
2666  {
2667  // public section
2668  $ilTabs->addSubTabTarget("public_section",
2669  $this->ctrl->getLinkTarget($this, 'editPublicSection'),
2670  "", "");
2671  }
2672  }
2673 
2674  $ilTabs->setSubTabActive($a_active);
2675  }
2676  }
2677 
2679  {
2680  global $ilTabs, $ilToobar, $ilAccess;
2681 
2682 
2683  if (!$ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, "read", "", $this->object->getRefId()))
2684  {
2685  ilUtil::sendInfo($this->lng->txt("cont_anonymous_user_missing_perm"));
2686  }
2687 
2688  $this->setTabs();
2689  $this->setSubTabs("public_section");
2690  $ilTabs->setTabActive("settings");
2691 
2692  switch ($this->object->getType())
2693  {
2694  case "lm":
2695  $gui_class = "ilobjlearningmodulegui";
2696  break;
2697 
2698  case "dlb":
2699  $gui_class = "ilobjdlbookgui";
2700  break;
2701  }
2702 
2703  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_public_selector.html",
2704  "Modules/LearningModule");
2705 
2706  // get learning module object
2707  $this->lm_obj = new ilObjLearningModule($this->ref_id, true);
2708 
2709  // public mode
2710  $my_toolbar = new ilToolbarGUI();
2711  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
2712  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
2713  $si = new ilSelectInputGUI($this->lng->txt("choose_public_mode"), "lm_public_mode");
2714  $si->setOptions($modes);
2715  $si->setValue($this->object->getPublicAccessMode());
2716  $my_toolbar->addInputItem($si, true);
2717  $my_toolbar->setOpenFormTag(false);
2718  $my_toolbar->setCloseFormTag(false);
2719  $my_toolbar->addFormButton($this->lng->txt("save"), "savePublicSection");
2720  $this->tpl->setVariable("TOOLBAR", $my_toolbar->getHTML());
2721  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
2722 
2723  if ($this->object->getPublicAccessMode() == "selected")
2724  {
2725  $this->tpl->setCurrentBlock("select_pages");
2726  require_once ("./Modules/LearningModule/classes/class.ilPublicSectionSelector.php");
2727  $exp = new ilPublicSectionSelector($this->ctrl->getLinkTarget($this, "view"),
2728  $this->object, $gui_class);
2729 
2730  $exp->setTargetGet("obj_id");
2731 
2732  // build html-output
2733  $exp->setOutput(0);
2734  $output = $exp->getOutput();
2735 
2736  // get page ids
2737  foreach ($exp->format_options as $node)
2738  {
2739  if (!$node["container"])
2740  {
2741  $pages[] = $node["child"];
2742  }
2743  }
2744 
2745  $js_pages = ilUtil::array_php2js($pages);
2746  $this->tpl->setVariable("EXPLORER",$output);
2747  $this->tpl->setVariable("ONCLICK",$js_pages);
2748  $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
2749  $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
2750  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2751 
2752  $this->tpl->parseCurrentBlock();
2753  }
2754  }
2755 
2757  {
2758  //var_dump($_POST["lm_public_mode"]);exit;
2759  $this->object->setPublicAccessMode($_POST["lm_public_mode"]);
2760  $this->object->updateProperties();
2761  ilLMObject::_writePublicAccessStatus($_POST["pages"],$this->object->getId());
2762  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2763  $this->ctrl->redirect($this, "editPublicSection");
2764  }
2765 
2771  function history()
2772  {
2773  $this->setTabs("history");
2774 
2775  require_once("./Services/History/classes/class.ilHistoryGUI.php");
2776  $hist_gui =& new ilHistoryGUI($this->object->getId() ,
2777  $this->object->getType());
2778  $hist_html = $hist_gui->getHistoryTable(
2779  $this->ctrl->getParameterArray($this, "history"),
2780  $this->object->isActiveHistoryUserComments()
2781  );
2782 
2783  $this->tpl->setVariable("ADM_CONTENT", $hist_html);
2784  }
2785 
2794  public function formatInvalidLinkArray(Array $row)
2795  {
2796  $row['title'] = ilLMPageObject::_getPresentationTitle($row['page_id'], $this->object->getPageHeader());
2797 
2798  require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
2800  $actions->setSelectionHeaderClass('small');
2801  $actions->setItemLinkClass('xsmall');
2802  $actions->setListTitle($this->lng->txt('actions'));
2803  $actions->setId($row['page_id']);
2804  $this->ctrl->setParameterByClass('ilLMPageObjectGUI', 'obj_id', $row['page_id']);
2805  $actions->addItem(
2806  $this->lng->txt('edit'),
2807  '',
2808  $this->ctrl->getLinkTargetByClass('ilLMPageObjectGUI', 'edit')
2809  );
2810  $this->ctrl->clearParametersByClass('ilLMPageObjectGUI');
2811  $row['action_html'] = $actions->getHTML();
2812 
2813  return $row;
2814  }
2815 
2816  function linkChecker()
2817  {
2818  global $ilias, $ilUser, $tpl;
2819 
2820  $this->__initLinkChecker();
2821 
2822  $this->setTabs();
2823  $this->setContentSubTabs("link_check");
2824 
2825  require_once './Services/LinkChecker/classes/class.ilLinkCheckerTableGUI.php';
2826 
2827  $toolbar = new ilToolbarGUI();
2828 
2829  // #13684
2830  if((bool)$ilias->getSetting('cron_link_check'))
2831  {
2832  include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
2833  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
2834 
2835  $chb = new ilCheckboxInputGUI($this->lng->txt('link_check_message_a'), 'link_check_message');
2836  $chb->setValue(1);
2837  $chb->setChecked((bool)ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(),$this->object->getId()));
2838  $chb->setOptionTitle($this->lng->txt('link_check_message_b'));
2839 
2840  $toolbar->addInputItem($chb);
2841  $toolbar->addFormButton($this->lng->txt('save'), 'saveLinkCheck');
2842  $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'saveLinkCheck'));
2843  }
2844 
2845  $tgui = new ilLinkCheckerTableGUI($this, 'linkChecker');
2846  $tgui->setLinkChecker($this->link_checker_obj)
2847  ->setRowHandler($this)
2848  ->setRefreshButton($this->lng->txt('refresh'), 'refreshLinkCheck');
2849 
2850  return $tpl->setContent($tgui->prepareHTML()->getHTML().$toolbar->getHTML());
2851  }
2852 
2853  function saveLinkCheck()
2854  {
2855  global $ilDB,$ilUser;
2856 
2857  include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
2858 
2859  $link_check_notify =& new ilLinkCheckNotify($ilDB);
2860  $link_check_notify->setUserId($ilUser->getId());
2861  $link_check_notify->setObjId($this->object->getId());
2862 
2863  if($_POST['link_check_message'])
2864  {
2865  ilUtil::sendSuccess($this->lng->txt('link_check_message_enabled'));
2866  $link_check_notify->addNotifier();
2867  }
2868  else
2869  {
2870  ilUtil::sendSuccess($this->lng->txt('link_check_message_disabled'));
2871  $link_check_notify->deleteNotifier();
2872  }
2873  $this->linkChecker();
2874 
2875  return true;
2876  }
2877 
2878 
2879 
2880  function refreshLinkCheck()
2881  {
2882  $this->__initLinkChecker();
2883 
2884  if(!$this->link_checker_obj->checkPear())
2885  {
2886  ilUtil::sendFailure($this->lng->txt('missing_pear_library'));
2887  $this->linkChecker();
2888 
2889  return false;
2890  }
2891 
2892  $this->link_checker_obj->checkLinks();
2893  ilUtil::sendSuccess($this->lng->txt('link_checker_refreshed'));
2894 
2895  $this->linkChecker();
2896 
2897  return true;
2898  }
2899 
2901  {
2902  global $ilDB;
2903 
2904  include_once './Services/LinkChecker/classes/class.ilLinkChecker.php';
2905 
2906  $this->link_checker_obj =& new ilLinkChecker($ilDB,false);
2907  $this->link_checker_obj->setObjId($this->object->getId());
2908 
2909  return true;
2910  }
2911 
2913  {
2914  include_once './Modules/LearningModule/classes/class.ilLMMenuEditor.php';
2915 
2916  $this->lmme_obj =& new ilLMMenuEditor();
2917  $this->lmme_obj->setObjId($this->object->getId());
2918 
2919  return true;
2920  }
2921 
2925  function addMenuEntry()
2926  {
2927  global $ilTabs, $ilToolbar, $tpl, $ilCtrl;
2928 
2929  $this->setTabs();
2930 
2931  $ilTabs->setTabActive("settings");
2932  $this->setSubTabs("cont_lm_menu");
2933 
2934  $ilToolbar->addButton($this->lng->txt("lm_menu_select_internal_object"),
2935  $ilCtrl->getLinkTarget($this, "showEntrySelector"));
2936 
2937  $form = $this->initMenuEntryForm("create");
2938  $this->tpl->setContent($form->getHTML());
2939  }
2940 
2946  public function initMenuEntryForm($a_mode = "edit")
2947  {
2948  global $lng, $ilCtrl;
2949 
2950  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2951  $form = new ilPropertyFormGUI();
2952 
2953  // title
2954  $ti = new ilTextInputGUI($this->lng->txt("lm_menu_entry_title"), "title");
2955  $ti->setMaxLength(255);
2956  $ti->setSize(40);
2957  $form->addItem($ti);
2958 
2959  // target
2960  $ta = new ilTextInputGUI($this->lng->txt("lm_menu_entry_target"), "target");
2961  $ta->setMaxLength(255);
2962  $ta->setSize(40);
2963  $form->addItem($ta);
2964 
2965  if ($a_mode == "edit")
2966  {
2967  $this->__initLMMenuEditor();
2968  $this->lmme_obj->readEntry($_REQUEST["menu_entry"]);
2969  $ti->setValue($this->lmme_obj->getTitle());
2970  $ta->setValue($this->lmme_obj->getTarget());
2971  }
2972 
2973  if (isset($_GET["link_ref_id"]))
2974  {
2975  $link_ref_id = (int) $_GET["link_ref_id"];
2976  $obj_type = ilObject::_lookupType($link_ref_id,true);
2977  $obj_id = ilObject::_lookupObjectId($link_ref_id);
2979 
2980  $target_link = $obj_type."_".$link_ref_id;
2981  $ti->setValue($title);
2982  $ta->setValue($target_link);
2983 
2984  // link ref id
2985  $hi = new ilHiddenInputGUI("link_ref_id");
2986  $hi->setValue($link_ref_id);
2987  $form->addItem($hi);
2988  }
2989 
2990 
2991  // save and cancel commands
2992  if ($a_mode == "create")
2993  {
2994  $form->addCommandButton("saveMenuEntry", $lng->txt("save"));
2995  $form->addCommandButton("editMenuProperties", $lng->txt("cancel"));
2996  $form->setTitle($lng->txt("lm_menu_new_entry"));
2997  }
2998  else
2999  {
3000  $form->addCommandButton("updateMenuEntry", $lng->txt("save"));
3001  $form->addCommandButton("editMenuProperties", $lng->txt("cancel"));
3002  $form->setTitle($lng->txt("lm_menu_edit_entry"));
3003  }
3004 
3005  $form->setFormAction($ilCtrl->getFormAction($this));
3006 
3007  return $form;
3008  }
3009 
3013  function saveMenuEntry()
3014  {
3015  global $ilCtrl;
3016 
3017  // check title and target
3018  if (empty($_POST["title"]))
3019  {
3020  //$this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
3021  ilUtil::sendFailure($this->lng->txt("please_enter_title") , true);
3022  $ilCtrl->redirect($this, "addMenuEntry");
3023  }
3024  if (empty($_POST["target"]))
3025  {
3026  //$this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
3027  ilUtil::sendFailure($this->lng->txt("please_enter_target"), true);
3028  $ilCtrl->redirect($this, "addMenuEntry");
3029  }
3030 
3031  $this->__initLMMenuEditor();
3032  $this->lmme_obj->setTitle($_POST["title"]);
3033  $this->lmme_obj->setTarget($_POST["target"]);
3034  $this->lmme_obj->setLinkRefId($_POST["link_ref_id"]);
3035 
3036  if ($_POST["link_ref_id"])
3037  {
3038  $this->lmme_obj->setLinkType("intern");
3039  }
3040 
3041  $this->lmme_obj->create();
3042 
3043  ilUtil::sendSuccess($this->lng->txt("msg_entry_added"), true);
3044  $this->ctrl->redirect($this, "editMenuProperties");
3045  }
3046 
3050  function deleteMenuEntry()
3051  {
3052  if (empty($_GET["menu_entry"]))
3053  {
3054  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3055  }
3056 
3057  $this->__initLMMenuEditor();
3058  $this->lmme_obj->delete($_GET["menu_entry"]);
3059 
3060  ilUtil::sendSuccess($this->lng->txt("msg_entry_removed"), true);
3061  $this->ctrl->redirect($this, "editMenuProperties");
3062  }
3063 
3067  function editMenuEntry()
3068  {
3069  global $ilToolbar, $ilCtrl;
3070 
3071  if (empty($_GET["menu_entry"]))
3072  {
3073  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3074  }
3075 
3076  $ilCtrl->saveParameter($this, array("menu_entry"));
3077  $ilToolbar->addButton($this->lng->txt("lm_menu_select_internal_object"),
3078  $ilCtrl->getLinkTarget($this, "showEntrySelector"));
3079 
3080  $form = $this->initMenuEntryForm("edit");
3081  $this->tpl->setContent($form->getHTML());
3082  }
3083 
3087  function updateMenuEntry()
3088  {
3089  if (empty($_REQUEST["menu_entry"]))
3090  {
3091  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3092  }
3093 
3094  // check title and target
3095  if (empty($_POST["title"]))
3096  {
3097  $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
3098  }
3099  if (empty($_POST["target"]))
3100  {
3101  $this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
3102  }
3103 
3104  $this->__initLMMenuEditor();
3105  $this->lmme_obj->readEntry($_REQUEST["menu_entry"]);
3106  $this->lmme_obj->setTitle($_POST["title"]);
3107  $this->lmme_obj->setTarget($_POST["target"]);
3108  $this->lmme_obj->update();
3109 
3110  ilUtil::sendSuccess($this->lng->txt("msg_entry_updated"), true);
3111  $this->ctrl->redirect($this, "editMenuProperties");
3112  }
3113 
3115  {
3116  global $ilTabs, $ilCtrl;
3117 
3118  $this->setTabs();
3119 
3120  $ilTabs->setTabActive("settings");
3121  $this->setSubTabs("cont_lm_menu");
3122 
3123  $ilCtrl->saveParameter($this, array("menu_entry"));
3124 
3125  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_object_selector.html","Modules/LearningModule");
3126 
3127  ilUtil::sendInfo($this->lng->txt("lm_menu_select_object_to_add"));
3128 
3129  require_once ("./Modules/LearningModule/classes/class.ilLMMenuObjectSelector.php");
3130  $exp = new ilLMMenuObjectSelector($this->ctrl->getLinkTarget($this,'test'),$this);
3131 
3132  $exp->setExpand($_GET["lm_menu_expand"] ? $_GET["lm_menu_expand"] : $this->tree->readRootId());
3133  $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showEntrySelector'));
3134  $exp->setTargetGet("ref_id");
3135  $exp->setRefId($this->cur_ref_id);
3136 
3137  $sel_types = array('mcst', 'mep', 'cat', 'lm','dbk','glo','frm','exc','tst','svy', 'chat', 'wiki', 'sahs',
3138  "crs", "grp", "book", "tst", "file");
3139  $exp->setSelectableTypes($sel_types);
3140 
3141  //$exp->setTargetGet("obj_id");
3142 
3143  // build html-output
3144  $exp->setOutput(0);
3145  $output = $exp->getOutput();
3146 
3147  // get page ids
3148  foreach ($exp->format_options as $node)
3149  {
3150  if (!$node["container"])
3151  {
3152  $pages[] = $node["child"];
3153  }
3154  }
3155 
3156  //$this->tpl->setCurrentBlock("content");
3157  //var_dump($this->object->getPublicAccessMode());
3158  // access mode selector
3159  $this->tpl->setVariable("TXT_SET_PUBLIC_MODE", $this->lng->txt("set_public_mode"));
3160  $this->tpl->setVariable("TXT_CHOOSE_PUBLIC_MODE", $this->lng->txt("choose_public_mode"));
3161  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
3162  $select_public_mode = ilUtil::formSelect ($this->object->getPublicAccessMode(),"lm_public_mode",$modes, false, true);
3163  $this->tpl->setVariable("SELECT_PUBLIC_MODE", $select_public_mode);
3164 
3165  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("choose_public_pages"));
3166  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
3167  $this->tpl->setVariable("EXPLORER",$output);
3168  $this->tpl->setVariable("ONCLICK",$js_pages);
3169  $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
3170  $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
3171  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3172  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
3173  //$this->tpl->parseCurrentBlock();
3174  }
3175 
3179  function selectHeader()
3180  {
3181  if(!isset($_POST["id"]))
3182  {
3183  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3184  }
3185  if(count($_POST["id"]) > 1)
3186  {
3187  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3188  }
3189  if ($_POST["id"][0] != $this->object->getHeaderPage())
3190  {
3191  $this->object->setHeaderPage($_POST["id"][0]);
3192  }
3193  else
3194  {
3195  $this->object->setHeaderPage(0);
3196  }
3197  $this->object->updateProperties();
3198  $this->ctrl->redirect($this, "pages");
3199  }
3200 
3204  function selectFooter()
3205  {
3206  if(!isset($_POST["id"]))
3207  {
3208  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3209  }
3210  if(count($_POST["id"]) > 1)
3211  {
3212  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3213  }
3214  if ($_POST["id"][0] != $this->object->getFooterPage())
3215  {
3216  $this->object->setFooterPage($_POST["id"][0]);
3217  }
3218  else
3219  {
3220  $this->object->setFooterPage(0);
3221  }
3222  $this->object->updateProperties();
3223  $this->ctrl->redirect($this, "pages");
3224  }
3225 
3229  function saveAllTitles()
3230  {
3231  global $ilCtrl;
3232 
3233  ilLMObject::saveTitles($this->object, ilUtil::stripSlashesArray($_POST["title"]));
3234 
3235  $ilCtrl->redirect($this, "chapters");
3236  }
3237 
3241  function insertChapter()
3242  {
3243  global $ilCtrl, $lng;
3244 
3245  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
3246 
3249 
3250  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
3251  {
3252  $parent_id = $this->lm_tree->getParentId($node_id);
3253  $target = $node_id;
3254  }
3255  else // insert as first child
3256  {
3257  $parent_id = $node_id;
3258  $target = IL_FIRST_NODE;
3259  }
3260 
3261  for ($i = 1; $i <= $num; $i++)
3262  {
3263  $chap = new ilStructureObject($this->object);
3264  $chap->setType("st");
3265  $chap->setTitle($lng->txt("cont_new_chap"));
3266  $chap->setLMId($this->object->getId());
3267  $chap->create();
3268  ilLMObject::putInTree($chap, $parent_id, $target);
3269  }
3270 
3271  $ilCtrl->redirect($this, "chapters");
3272  }
3273 
3278  {
3279  global $ilUser, $ilCtrl, $ilLog;
3280 
3281  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
3282 
3283  if ($ilUser->getPref("lm_js_chapter_editing") != "disable")
3284  {
3285  //$num = ilChapterHierarchyFormGUI::getPostMulti();
3288  }
3289  else
3290  {
3291  if (!isset($_POST["id"]) || $_POST["id"][0] == -1)
3292  {
3293  $node_id = $this->lm_tree->getRootId();
3294  $first_child = true;
3295  }
3296  else
3297  {
3298  $node_id = $_POST["id"][0];
3299  $first_child = false;
3300  }
3301  }
3302 
3303  $ilLog->write("InsertChapterClip, num: $num, node_id: $node_id, ".
3304  " getPostFirstChild ".ilChapterHierarchyFormGUI::getPostFirstChild());
3305 
3306  if (!$first_child) // insert after node id
3307  {
3308  $parent_id = $this->lm_tree->getParentId($node_id);
3309  $target = $node_id;
3310  }
3311  else // insert as first child
3312  {
3313  $parent_id = $node_id;
3314  $target = IL_FIRST_NODE;
3315  }
3316 
3317  // copy and paste
3318  $chapters = $ilUser->getClipboardObjects("st", true);
3319  $copied_nodes = array();
3320  foreach ($chapters as $chap)
3321  {
3322  $ilLog->write("Call pasteTree, Target LM: ".$this->object->getId().", Chapter ID: ".$chap["id"]
3323  .", Parent ID: ".$parent_id.", Target: ".$target);
3324  $cid = ilLMObject::pasteTree($this->object, $chap["id"], $parent_id,
3325  $target, $chap["insert_time"], $copied_nodes,
3326  (ilEditClipboard::getAction() == "copy"));
3327  $target = $cid;
3328  }
3329  ilLMObject::updateInternalLinks($copied_nodes);
3330 
3331  if (ilEditClipboard::getAction() == "cut")
3332  {
3333  $ilUser->clipboardDeleteObjectsOfType("pg");
3334  $ilUser->clipboardDeleteObjectsOfType("st");
3336  }
3337 
3338  $this->object->checkTree();
3339  $ilCtrl->redirect($this, "chapters");
3340  }
3341 
3347  function _goto($a_target)
3348  {
3349  global $ilAccess, $ilErr, $lng;
3350 
3351  if ($ilAccess->checkAccess("read", "", $a_target))
3352  {
3353  $_GET["baseClass"] = "ilLMPresentationGUI";
3354  $_GET["ref_id"] = $a_target;
3355  include("ilias.php");
3356  exit;
3357  } else if ($ilAccess->checkAccess("visible", "", $a_target))
3358  {
3359  $_GET["baseClass"] = "ilLMPresentationGUI";
3360  $_GET["ref_id"] = $a_target;
3361  $_GET["cmd"] = "infoScreen";
3362  include("ilias.php");
3363  exit;
3364  }
3365  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
3366  {
3367  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
3368  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
3370  }
3371 
3372 
3373  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
3374  }
3375 
3379  function cutItems($a_return = "chapters")
3380  {
3381  global $ilCtrl, $lng;
3382 
3383  $items = ilUtil::stripSlashesArray($_POST["id"]);
3384  if (!is_array($items))
3385  {
3386  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3387  $ilCtrl->redirect($this, $a_return);
3388  }
3389 
3390  $todel = array(); // delete IDs < 0 (needed for non-js editing)
3391  foreach($items as $k => $item)
3392  {
3393  if ($item < 0)
3394  {
3395  $todel[] = $k;
3396  }
3397  }
3398  foreach($todel as $k)
3399  {
3400  unset($items[$k]);
3401  }
3402  ilLMObject::clipboardCut($this->object->getId(), $items);
3404  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
3405 
3406  $ilCtrl->redirect($this, $a_return);
3407  }
3408 
3412  function copyItems()
3413  {
3414  global $ilCtrl, $lng;
3415 
3416  $items = ilUtil::stripSlashesArray($_POST["id"]);
3417  if (!is_array($items))
3418  {
3419  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3420  $ilCtrl->redirect($this, "chapters");
3421  }
3422 
3423  $todel = array(); // delete IDs < 0 (needed for non-js editing)
3424  foreach($items as $k => $item)
3425  {
3426  if ($item < 0)
3427  {
3428  $todel[] = $k;
3429  }
3430  }
3431  foreach($todel as $k)
3432  {
3433  unset($items[$k]);
3434  }
3435  ilLMObject::clipboardCopy($this->object->getId(), $items);
3437  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
3438  $ilCtrl->redirect($this, "chapters");
3439  }
3440 
3444  function cutChapter()
3445  {
3446  $this->cutItems("chapters");
3447  }
3448 
3452 
3459  function showExportIDsOverview($a_validation = false)
3460  {
3461  global $tpl, $ilToolbar, $lng, $ilCtrl;
3462 
3463  $this->setTabs();
3464  $this->setContentSubTabs("export_ids");
3465 
3466  if (ilObjContentObject::isOnlineHelpModule($this->object->getRefId()))
3467  {
3468  // toolbar
3469  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
3470  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
3471  $lm_tree = $this->object->getTree();
3472  $childs = $lm_tree->getChilds($lm_tree->readRootId());
3473  $options = array("" => $lng->txt("all"));
3474  foreach ($childs as $c)
3475  {
3476  $options[$c["child"]] = $c["title"];
3477  }
3478  $si = new ilSelectInputGUI($this->lng->txt("help_component"), "help_chap");
3479  $si->setOptions($options);
3480  $si->setValue(ilSession::get("help_chap"));
3481  $ilToolbar->addInputItem($si, true);
3482  $ilToolbar->addFormButton($lng->txt("help_filter"), "filterHelpChapters");
3483 
3484  include_once("./Modules/LearningModule/classes/class.ilHelpMappingTableGUI.php");
3485  $tbl = new ilHelpMappingTableGUI($this, "showExportIDsOverview", $a_validation, false);
3486  }
3487  else
3488  {
3489  include_once("./Modules/LearningModule/classes/class.ilExportIDTableGUI.php");
3490  $tbl = new ilExportIDTableGUI($this, "showExportIDsOverview", $a_validation, false);
3491  }
3492 
3493  $tpl->setContent($tbl->getHTML());
3494  }
3495 
3503  {
3504  global $ilCtrl;
3505 
3506  ilSession::set("help_chap", ilUtil::stripSlashes($_POST["help_chap"]));
3507  $ilCtrl->redirect($this, "showExportIDsOverview");
3508  }
3509 
3510 
3514  function saveExportIds()
3515  {
3516  global $ilCtrl, $lng;
3517 
3518  // check all export ids
3519  $ok = true;
3520  if (is_array($_POST["exportid"]))
3521  {
3522  foreach ($_POST["exportid"] as $pg_id => $exp_id)
3523  {
3524  if ($exp_id != "" && !preg_match("/^([a-zA-Z]+)[0-9a-zA-Z_]*$/",
3525  trim($exp_id)))
3526  {
3527  $ok = false;
3528  }
3529  }
3530  }
3531  if (!$ok)
3532  {
3533  ilUtil::sendFailure($lng->txt("cont_exp_ids_not_resp_format1").": a-z, A-Z, 0-9, '_'. ".
3534  $lng->txt("cont_exp_ids_not_resp_format3")." ".
3535  $lng->txt("cont_exp_ids_not_resp_format2"));
3536  $this->showExportIDsOverview(true);
3537  return;
3538  }
3539 
3540 
3541  if (is_array($_POST["exportid"]))
3542  {
3543  foreach ($_POST["exportid"] as $pg_id => $exp_id)
3544  {
3545  ilLMPageObject::saveExportId($this->object->getId(), $pg_id,
3546  ilUtil::stripSlashes($exp_id), ilLMObject::_lookupType($pg_id));
3547  }
3548  }
3549 
3550  ilUtil::sendSuccess($lng->txt("cont_saved_export_ids"), true);
3551  $ilCtrl->redirect($this, "showExportIdsOverview");
3552  }
3553 
3560  function saveHelpMapping()
3561  {
3562  global $lng, $ilCtrl;
3563 
3564  include_once("./Services/Help/classes/class.ilHelpMapping.php");
3565  if (is_array($_POST["screen_ids"]))
3566  {
3567  foreach ($_POST["screen_ids"] as $chap => $ids)
3568  {
3569  $ids = explode("\n", $ids);
3571  }
3572  }
3573  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3574  $ilCtrl->redirect($this, "showExportIdsOverview");
3575  }
3576 
3580 
3587  function showTooltipList()
3588  {
3589  global $tpl, $ilToolbar, $ilCtrl, $lng;
3590 
3591  $this->setTabs();
3592  $this->setContentSubTabs("help_tooltips");
3593 
3594  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
3595  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
3596  $ti = new ilTextInputGUI($this->lng->txt("help_tooltip_id"), "tooltip_id");
3597  $ti->setMaxLength(200);
3598  $ti->setSize(20);
3599  $ilToolbar->addInputItem($ti, true);
3600  $ilToolbar->addFormButton($lng->txt("add"), "addTooltip");
3601  $ilToolbar->addSeparator();
3602 
3603  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
3604  $options = ilHelp::getTooltipComponents();
3605  if (ilSession::get("help_tt_comp") != "")
3606  {
3607  $options[ilSession::get("help_tt_comp")] = ilSession::get("help_tt_comp");
3608  }
3609  $si = new ilSelectInputGUI($this->lng->txt("help_component"), "help_tt_comp");
3610  $si->setOptions($options);
3611  $si->setValue(ilSession::get("help_tt_comp"));
3612  $ilToolbar->addInputItem($si, true);
3613  $ilToolbar->addFormButton($lng->txt("help_filter"), "filterTooltips");
3614 
3615  include_once("./Modules/LearningModule/classes/class.ilHelpTooltipTableGUI.php");
3616  $tbl = new ilHelpTooltipTableGUI($this, "showTooltipList", ilSession::get("help_tt_comp"));
3617 
3618  $tpl->setContent($tbl->getHTML());
3619  }
3620 
3627  function addTooltip()
3628  {
3629  global $lng, $ilCtrl;
3630 
3631  $tt_id = ilUtil::stripSlashes($_POST["tooltip_id"]);
3632  if (trim($tt_id) != "")
3633  {
3634  include_once("./Services/Help/classes/class.ilHelp.php");
3635  ilHelp::addTooltip(trim($tt_id), "");
3636  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3637 
3638  $fu = strpos($tt_id, "_");
3639  $comp = substr($tt_id, 0, $fu);
3640  ilSession::set("help_tt_comp", ilUtil::stripSlashes($comp));
3641  }
3642  $ilCtrl->redirect($this, "showTooltipList");
3643  }
3644 
3651  function filterTooltips()
3652  {
3653  global $lng, $ilCtrl;
3654 
3655  ilSession::set("help_tt_comp", ilUtil::stripSlashes($_POST["help_tt_comp"]));
3656  $ilCtrl->redirect($this, "showTooltipList");
3657  }
3658 
3659 
3666  function saveTooltips()
3667  {
3668  global $ilCtrl, $lng;
3669 
3670  include_once("./Services/Help/classes/class.ilHelp.php");
3671 
3672  if (is_array($_POST["text"]))
3673  {
3674  foreach ($_POST["text"] as $id => $text)
3675  {
3676  ilHelp::updateTooltip((int) $id, ilUtil::stripSlashes($text),
3677  ilUtil::stripSlashes($_POST["tt_id"][(int) $id]));
3678  }
3679  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3680  }
3681  $ilCtrl->redirect($this, "showTooltipList");
3682  }
3683 
3687  function deleteTooltips()
3688  {
3689  global $lng, $ilCtrl;
3690 
3691  if (is_array($_POST["id"]))
3692  {
3693  include_once("./Services/Help/classes/class.ilHelp.php");
3694  foreach ($_POST["id"] as $id)
3695  {
3696  ilHelp::deleteTooltip((int) $id);
3697  }
3698  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3699  }
3700  $ilCtrl->redirect($this, "showTooltipList");
3701  }
3702 
3709 /* function saveHelpMapping()
3710  {
3711  global $lng, $ilCtrl;
3712 
3713  include_once("./Services/Help/classes/class.ilHelpMapping.php");
3714  if (is_array($_POST["screen_ids"]))
3715  {
3716  foreach ($_POST["screen_ids"] as $chap => $ids)
3717  {
3718  $ids = explode("\n", $ids);
3719  ilHelpMapping::saveScreenIdsForChapter($chap, $ids);
3720  }
3721  }
3722  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3723  $ilCtrl->redirect($this, "showExportIdsOverview");
3724  }*/
3725 
3726 
3730 
3736  static function getLayoutOption($a_txt, $a_var, $a_def_option = "")
3737  {
3738  global $lng;
3739 
3740  // default layout
3741  $layout = new ilRadioMatrixInputGUI($a_txt, $a_var);
3742  $option = array();
3743  if ($a_def_option != "")
3744  {
3745  if (is_file($im = ilUtil::getImagePath("layout_".$a_def_option.".png")))
3746  {
3747  $im_tag = ilUtil::img($im, $a_def_option);
3748  }
3749  $option[""] =
3750  "<table><tr><td>".$im_tag."</td><td><b>".$lng->txt("cont_lm_default_layout").
3751  "</b>: ".$lng->txt("cont_layout_".$a_def_option)."</td></tr></table>";
3752  }
3754  {
3755  $im_tag = "";
3756  if (is_file($im = ilUtil::getImagePath("layout_".$l.".png")))
3757  {
3758  $im_tag = ilUtil::img($im, $l);
3759  }
3760  $option[$l] = "<table><tr><td style='padding: 0px 5px 5px;'>".$im_tag."</td><td style='padding:5px;'><b>".$lng->txt("cont_layout_".$l)."</b>: ".$lng->txt("cont_layout_".$l."_desc")."</td></tr></table>";
3761  //$option[$l] = " ".$im_tag." <b>".$lng->txt("cont_layout_".$l)."</b>: ".$lng->txt("cont_layout_".$l."_desc");
3762  }
3763  $layout->setOptions($option);
3764 
3765  return $layout;
3766  }
3767 
3772  {
3773  global $ilCtrl;
3774  $ilCtrl->setParameter($this, "hierarchy", "1");
3775  $this->setPageLayout(true);
3776  }
3777 
3778 
3782  function setPageLayout($a_in_hierarchy = false)
3783  {
3784  global $tpl, $ilCtrl, $lng;
3785 
3786  if (!is_array($_POST["id"]))
3787  {
3788  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3789 
3790  if ($a_in_hierarchy)
3791  {
3792  $ilCtrl->redirect($this, "chapters");
3793  }
3794  else
3795  {
3796  $ilCtrl->redirect($this, "pages");
3797  }
3798  }
3799 
3800  $this->initSetPageLayoutForm();
3801 
3802  $tpl->setContent($this->form->getHTML());
3803  }
3804 
3808  public function initSetPageLayoutForm()
3809  {
3810  global $lng, $ilCtrl;
3811 
3812  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3813  $this->form = new ilPropertyFormGUI();
3814 
3815  if (is_array($_POST["id"]))
3816  {
3817  foreach ($_POST["id"] as $id)
3818  {
3819  $hi = new ilHiddenInputGUI("id[]");
3820  $hi->setValue($id);
3821  $this->form->addItem($hi);
3822  }
3823  }
3824  $layout = self::getLayoutOption($lng->txt("cont_layout"), "layout",
3825  $this->object->getLayout());
3826  $this->form->addItem($layout);
3827 
3828  $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
3829  $this->form->addCommandButton("pages", $lng->txt("cancel"));
3830 
3831  $this->form->setTitle($lng->txt("cont_set_layout"));
3832  $this->form->setFormAction($ilCtrl->getFormAction($this));
3833 
3834  }
3835 
3839  function savePageLayout()
3840  {
3841  global $lng, $ilCtrl;
3842 
3843  $ilCtrl->setParameter($this, "hierarchy", $_GET["hierarchy"]);
3844 
3845  foreach ($_POST["id"] as $id)
3846  {
3848  ilUtil::stripSlashes($_POST["layout"]),
3849  $this->object);
3850  }
3851  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3852 
3853  if ($_GET["hierarchy"] == 1)
3854  {
3855  $ilCtrl->redirect($this, "chapters");
3856  }
3857  else
3858  {
3859  $ilCtrl->redirect($this, "pages");
3860  }
3861  }
3862 }
3863 ?>