ILIAS  eassessment Revision 61809
 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-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "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;
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-";
63  switch($next_class)
64  {
65  case "illearningprogressgui":
66  $this->addLocations();
67  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
68  $this->setTabs();
69 
70  $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,$this->object->getRefId());
71  $new_gui->activateStatistics();
72  $this->ctrl->forwardCommand($new_gui);
73 
74  break;
75 
76  case 'ilmdeditorgui':
77  $this->addLocations();
78  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
79  $this->setTabs();
80  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
81  $md_gui->addObserver($this->object,'MDUpdateListener','General');
82 
83  $this->ctrl->forwardCommand($md_gui);
84  break;
85 
86  case "ilobjstylesheetgui":
87  $this->addLocations();
88  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
89  $this->ctrl->setReturn($this, "editStyleProperties");
90  $style_gui =& new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
91  $style_gui->omitLocator();
92  if ($cmd == "create" || $_GET["new_type"]=="sty")
93  {
94  $style_gui->setCreationMode(true);
95  }
96  $ret =& $this->ctrl->forwardCommand($style_gui);
97  //$ret =& $style_gui->executeCommand();
98 
99  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
100  {
101  $style_id = $ret;
102  $this->object->setStyleSheetId($style_id);
103  $this->object->update();
104  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
105  }
106  break;
107 
108  case "illmpageobjectgui":
109  $this->ctrl->saveParameter($this, array("obj_id"));
110  $this->addLocations();
111  $this->ctrl->setReturn($this, "chapters");
112 //echo "!";
113  //$this->lm_obj =& $this->ilias->obj_factory->getInstanceByRefId($this->ref_id);
114 
115  $pg_gui =& new ilLMPageObjectGUI($this->object);
116  if ($_GET["obj_id"] != "")
117  {
118  $obj =& ilLMObjectFactory::getInstance($this->object, $_GET["obj_id"]);
119  $pg_gui->setLMPageObject($obj);
120  }
121  //$ret =& $pg_gui->executeCommand();
122  $ret =& $this->ctrl->forwardCommand($pg_gui);
123  if ($cmd == "save" || $cmd == "cancel")
124  {
125 // $this->ctrl->redirect($this, "pages");
126  }
127  break;
128 
129  case "ilstructureobjectgui":
130  $this->ctrl->saveParameter($this, array("obj_id"));
131  $this->addLocations();
132  $this->ctrl->setReturn($this, "chapters");
133  $st_gui =& new ilStructureObjectGUI($this->object, $this->object->lm_tree);
134  if ($_GET["obj_id"] != "")
135  {
136  $obj =& ilLMObjectFactory::getInstance($this->object, $_GET["obj_id"]);
137  $st_gui->setStructureObject($obj);
138  }
139  //$ret =& $st_gui->executeCommand();
140  $ret =& $this->ctrl->forwardCommand($st_gui);
141  if ($cmd == "save" || $cmd == "cancel")
142  {
143  if ($_GET["obj_id"] == "")
144  {
145  $this->ctrl->redirect($this, "chapters");
146  }
147  else
148  {
149  $this->ctrl->setCmd("subchap");
150  $this->executeCommand();
151  }
152  }
153  break;
154 
155  case 'ilpermissiongui':
156  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
157  {
158  $this->prepareOutput();
159  }
160  else
161  {
162  $this->addLocations(true);
163  $this->setTabs();
164  }
165  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
166  $perm_gui =& new ilPermissionGUI($this);
167  $ret =& $this->ctrl->forwardCommand($perm_gui);
168  break;
169 
170  // infoscreen
171  case 'ilinfoscreengui':
172  $this->addLocations(true);
173  $this->setTabs();
174  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
175  $info = new ilInfoScreenGUI($this);
176  $info->enablePrivateNotes();
177  $info->enableLearningProgress();
178 
179  $info->enableNews();
180  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
181  {
182  $info->enableNewsEditing();
183  $info->setBlockProperty("news", "settings", true);
184  }
185 
186  // show standard meta data section
187  $info->addMetaDataSections($this->object->getId(), 0,
188  $this->object->getType());
189 
190  $ret =& $this->ctrl->forwardCommand($info);
191  break;
192 
193  case "ilexportgui":
194  $this->addLocations(true);
195  $this->setTabs();
196  include_once("./Services/Export/classes/class.ilExportGUI.php");
197  $exp_gui = new ilExportGUI($this);
198  $exp_gui->addFormat("xml", "", $this, "export");
199  $exp_gui->addFormat("html", "", $this, "exportHTML");
200  $exp_gui->addFormat("scorm", "", $this, "exportSCORM");
201  $exp_gui->addCustomColumn($lng->txt("cont_public_access"),
202  $this, "getPublicAccessColValue");
203  $exp_gui->addCustomMultiCommand($lng->txt("cont_public_access"),
204  $this, "publishExportFile");
205  $ret = $this->ctrl->forwardCommand($exp_gui);
206  break;
207 
208 
209  default:
210  $new_type = $_POST["new_type"]
211  ? $_POST["new_type"]
212  : $_GET["new_type"];
213 
214 
215  if ($cmd == "create" &&
216  !in_array($new_type, array("dbk", "lm")))
217  {
218  //$this->addLocations();
219  switch ($new_type)
220  {
221  case "pg":
222  $this->setTabs();
223  $this->ctrl->setCmdClass("ilLMPageObjectGUI");
224  $ret =& $this->executeCommand();
225  break;
226 
227  case "st":
228  $this->setTabs();
229  $this->ctrl->setCmdClass("ilStructureObjectGUI");
230  $ret =& $this->executeCommand();
231  break;
232  }
233  }
234  else
235  {
236  // creation of new dbk/lm in repository
237  if ($this->getCreationMode() == true &&
238  in_array($new_type, array("dbk", "lm")))
239  {
240  $this->prepareOutput();
241  if ($cmd == "") // this may be due to too big upload files
242  {
243  $cmd = "create";
244  }
245  $cmd .= "Object";
246  $ret =& $this->$cmd();
247  }
248  else
249  {
250  $this->addLocations();
251  $ret =& $this->$cmd();
252  }
253  }
254  break;
255  }
256  return $ret;
257  }
258 
259  function _forwards()
260  {
261  return array("ilLMPageObjectGUI", "ilStructureObjectGUI","ilObjStyleSheetGUI");
262  }
263 
267  function properties()
268  {
269  global $lng;
270 
271  $lng->loadLanguageModule("style");
272  $this->setTabs();
273  $this->setSubTabs("cont_general_properties");
274 
275  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
276  $showViewInFrameset = true;
277 
278  if ($showViewInFrameset)
279  {
280  $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
281  }
282  else
283  {
284  $buttonTarget = "ilContObj".$this->object->getID();
285  }
286 
287  //add template for view button
288  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
289 
290  // view button
291  $this->tpl->setCurrentBlock("btn_cell");
292  $this->tpl->setVariable("BTN_LINK", "ilias.php?baseClass=ilLMPresentationGUI&ref_id=".$this->object->getRefID());
293  $this->tpl->setVariable("BTN_TARGET"," target=\"".$buttonTarget."\" ");
294  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
295  $this->tpl->parseCurrentBlock();
296 
297  $this->tpl->setCurrentBlock("btn_cell");
298  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "fixTreeConfirm"));
299  //$this->tpl->setVariable("BTN_TARGET"," target=\"_top\" ");
300  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_fix_tree"));
301  $this->tpl->parseCurrentBlock();
302 
303  //$this->tpl->touchBlock("btn_row");
304 
305  // lm properties
306  $this->initPropertiesForm();
307  $this->getPropertiesFormValues();
308  $this->tpl->setContent($this->form->getHTML());
309  }
310 
315  {
316  global $ilCtrl, $lng;
317 
318  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
319  $this->form = new ilPropertyFormGUI();
320 
321  // title
322  $ti = new ilTextInputGUI($lng->txt("title"), "title");
323  //$ti->setMaxLength();
324  //$ti->setSize();
325  //$ti->setInfo($lng->txt(""));
326  $ti->setRequired(true);
327  $this->form->addItem($ti);
328 
329  // description
330  $ta = new ilTextAreaInputGUI($lng->txt("desc"), "description");
331  //$ta->setCols();
332  //$ta->setRows();
333  //$ta->setInfo($lng->txt(""));
334  $this->form->addItem($ta);
335 
336  // online
337  $online = new ilCheckboxInputGUI($lng->txt("cont_online"), "cobj_online");
338  $this->form->addItem($online);
339 
340  // default layout
341  $layout = new ilRadioMatrixInputGUI($lng->txt("cont_def_layout"), "lm_layout");
342  $option = array();
344  {
345  $im_tag = "";
346  if (is_file($im = ilUtil::getImagePath("layout_".$l.".gif")))
347  {
348  $im_tag = ilUtil::img($im, $l);
349  }
350  $option[$l] = "<table><tr><td>".$im_tag."</td><td><b>".$lng->txt("cont_layout_".$l)."</b>: ".$lng->txt("cont_layout_".$l."_desc")."</td></tr></table>";
351  }
352  $layout->setOptions($option);
353  $this->form->addItem($layout);
354 
355  // page header
356  $page_header = new ilSelectInputGUI($lng->txt("cont_page_header"), "lm_pg_header");
357  $option = array ("st_title" => $this->lng->txt("cont_st_title"),
358  "pg_title" => $this->lng->txt("cont_pg_title"),
359  "none" => $this->lng->txt("cont_none"));
360  $page_header->setOptions($option);
361  $this->form->addItem($page_header);
362 
363  // chapter numeration
364  $chap_num = new ilCheckboxInputGUI($lng->txt("cont_act_number"), "cobj_act_number");
365  $this->form->addItem($chap_num);
366 
367  // toc mode
368  $toc_mode = new ilSelectInputGUI($lng->txt("cont_toc_mode"), "toc_mode");
369  $option = array ("chapters" => $this->lng->txt("cont_chapters_only"),
370  "pages" => $this->lng->txt("cont_chapters_and_pages"));
371  $toc_mode->setOptions($option);
372  $this->form->addItem($toc_mode);
373 
374  // public notes
375  if (!$this->ilias->getSetting('disable_notes'))
376  {
377  $pub_nodes = new ilCheckboxInputGUI($lng->txt("cont_public_notes"), "cobj_pub_notes");
378  $pub_nodes->setInfo($this->lng->txt("cont_public_notes_desc"));
379  $this->form->addItem($pub_nodes);
380  }
381 
382  // layout per page
383  $lpp = new ilCheckboxInputGUI($lng->txt("cont_layout_per_page"), "layout_per_page");
384  $lpp->setInfo($this->lng->txt("cont_layout_per_page_info"));
385  $this->form->addItem($lpp);
386 
387  // synchronize frames
388  $synch = new ilCheckboxInputGUI($lng->txt("cont_synchronize_frames"), "cobj_clean_frames");
389  $synch->setInfo($this->lng->txt("cont_synchronize_frames_desc"));
390  $this->form->addItem($synch);
391 
392  // history user comments
393  $com = new ilCheckboxInputGUI($lng->txt("enable_hist_user_comments"), "cobj_user_comments");
394  $com->setInfo($this->lng->txt("enable_hist_user_comments_desc"));
395  $this->form->addItem($com);
396 
397  $this->form->setTitle($lng->txt("cont_general_properties"));
398  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
399  $this->form->setFormAction($ilCtrl->getFormAction($this));
400  }
401 
406  {
407  $values = array();
408  $values["title"] = $this->object->getTitle();
409  $values["description"] = $this->object->getDescription();
410  if ($this->object->getOnline())
411  {
412  $values["cobj_online"] = true;
413  }
414  $values["lm_layout"] = $this->object->getLayout();
415  $values["lm_pg_header"] = $this->object->getPageHeader();
416  if ($this->object->isActiveNumbering())
417  {
418  $values["cobj_act_number"] = true;
419  }
420  $values["toc_mode"] = $this->object->getTOCMode();
421  if ($this->object->publicNotes())
422  {
423  $values["cobj_pub_notes"] = true;
424  }
425  if ($this->object->cleanFrames())
426  {
427  $values["cobj_clean_frames"] = true;
428  }
429  if ($this->object->isActiveHistoryUserComments())
430  {
431  $values["cobj_user_comments"] = true;
432  }
433  $values["layout_per_page"] = $this->object->getLayoutPerPage();
434 
435  $this->form->setValuesByArray($values);
436  }
437 
441  function saveProperties()
442  {
443  global $ilias;
444 
445  $this->initPropertiesForm();
446  if ($this->form->checkInput())
447  {
448  $this->object->setTitle($_POST['title']);
449  $this->object->setDescription($_POST['description']);
450  $this->object->setLayout($_POST["lm_layout"]);
451  $this->object->setPageHeader($_POST["lm_pg_header"]);
452  $this->object->setTOCMode($_POST["toc_mode"]);
453  $this->object->setOnline($_POST["cobj_online"]);
454  $this->object->setActiveNumbering($_POST["cobj_act_number"]);
455  $this->object->setCleanFrames($_POST["cobj_clean_frames"]);
456  $this->object->setPublicNotes($_POST["cobj_pub_notes"]);
457  $this->object->setHistoryUserComments($_POST["cobj_user_comments"]);
458  $this->object->setLayoutPerPage($_POST["layout_per_page"]);
459  $this->object->updateProperties();
460  $this->object->update();
461  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
462  $this->ctrl->redirect($this, "properties");
463  }
464  else
465  {
466  $this->form->setValuesByPost();
467  $tpl->setContent($this->form->getHTML());
468  }
469  }
470 
475  {
476  global $tpl;
477 
478  $this->initStylePropertiesForm();
479  $tpl->setContent($this->form->getHTML());
480  }
481 
486  {
487  global $ilCtrl, $lng, $ilTabs, $ilSetting;
488 
489  $lng->loadLanguageModule("style");
490  $this->setTabs();
491  $ilTabs->setTabActive("settings");
492  $this->setSubTabs("cont_style");
493 
494  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
495  $this->form = new ilPropertyFormGUI();
496 
497  $fixed_style = $ilSetting->get("fixed_content_style_id");
498  $style_id = $this->object->getStyleSheetId();
499 
500  if ($fixed_style > 0)
501  {
502  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
503  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
504  $this->lng->txt("global_fixed").")");
505  $this->form->addItem($st);
506  }
507  else
508  {
509  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
510  $_GET["ref_id"]);
511 
512  $st_styles[0] = $this->lng->txt("default");
513  ksort($st_styles);
514 
515  if ($style_id > 0)
516  {
517  // individual style
518  if (!ilObjStyleSheet::_lookupStandard($style_id))
519  {
520  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
521  $st->setValue(ilObject::_lookupTitle($style_id));
522  $this->form->addItem($st);
523 
524 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
525 
526  // delete command
527  $this->form->addCommandButton("editStyle",
528  $lng->txt("cont_edit_style"));
529  $this->form->addCommandButton("deleteStyle",
530  $lng->txt("cont_delete_style"));
531 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
532  }
533  }
534 
535  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
536  {
537  $style_sel = ilUtil::formSelect ($style_id, "style_id",
538  $st_styles, false, true);
539  $style_sel = new ilSelectInputGUI($lng->txt("cont_current_style"), "style_id");
540  $style_sel->setOptions($st_styles);
541  $style_sel->setValue($style_id);
542  $this->form->addItem($style_sel);
543 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
544  $this->form->addCommandButton("saveStyleSettings",
545  $lng->txt("save"));
546  $this->form->addCommandButton("createStyle",
547  $lng->txt("sty_create_ind_style"));
548  }
549  }
550  $this->form->setTitle($lng->txt("cont_style"));
551  $this->form->setFormAction($ilCtrl->getFormAction($this));
552  }
553 
557  function createStyle()
558  {
559  global $ilCtrl;
560 
561  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
562  }
563 
567  function editStyle()
568  {
569  global $ilCtrl;
570 
571  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
572  }
573 
577  function deleteStyle()
578  {
579  global $ilCtrl;
580 
581  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
582  }
583 
587  function saveStyleSettings()
588  {
589  global $ilSetting;
590 
591  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
592  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
593  || $this->object->getStyleSheetId() == 0))
594  {
595  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
596  $this->object->update();
597  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
598  }
599  $this->ctrl->redirect($this, "editStyleProperties");
600  }
601 
606  {
607  global $lng, $ilTabs, $ilCtrl;
608 
609  $lng->loadLanguageModule("style");
610  $this->setTabs();
611  $ilTabs->setTabActive("settings");
612  $this->setSubTabs("cont_lm_menu");
613 
614  // lm menu properties
615  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_properties.html", "Modules/LearningModule");
616  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
617 
618  $this->tpl->setVariable("TXT_LM_MENU", $this->lng->txt("cont_lm_menu"));
619  $this->tpl->setVariable("TXT_ACT_MENU", $this->lng->txt("cont_active"));
620  $this->tpl->setVariable("CBOX_LM_MENU", "cobj_act_lm_menu");
621  $this->tpl->setVariable("VAL_LM_MENU", "y");
622  if ($this->object->isActiveLMMenu())
623  {
624  $this->tpl->setVariable("CHK_LM_MENU", "checked");
625  }
626 
627  // toc
628  $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
629  $this->tpl->setVariable("CBOX_TOC", "cobj_act_toc");
630  $this->tpl->setVariable("VAL_TOC", "y");
631  if ($this->object->isActiveTOC())
632  {
633  $this->tpl->setVariable("CHK_TOC", "checked");
634  }
635 
636  // print view
637  $this->tpl->setVariable("TXT_PRINT", $this->lng->txt("cont_print_view"));
638  $this->tpl->setVariable("CBOX_PRINT", "cobj_act_print");
639  $this->tpl->setVariable("VAL_PRINT", "y");
640  if ($this->object->isActivePrintView())
641  {
642  $this->tpl->setVariable("CHK_PRINT", "checked");
643  }
644 
645  // prevent glossary appendix
646  $this->tpl->setVariable("TXT_PRINT_PREV_GLO", $this->lng->txt("cont_print_view_pre_glo"));
647  $this->tpl->setVariable("CBOX_PRINT_PREV_GLO", "cobj_act_print_prev_glo");
648  $this->tpl->setVariable("VAL_PRINT_PREV_GLO", "y");
649  if ($this->object->isActivePreventGlossaryAppendix())
650  {
651  $this->tpl->setVariable("CHK_PRINT_PREV_GLO", "checked");
652  }
653 
654  // downloads
655  $no_download_file_available =
656  " ".$lng->txt("cont_no_download_file_available").
657  " <a href='".$ilCtrl->getLinkTargetByClass("ilexportgui", "")."'>".$lng->txt("change")."</a>";
658  $types = array("xml", "html", "scorm");
659  foreach($types as $type)
660  {
661  if ($this->object->getPublicExportFile($type) != "")
662  {
663  if (is_file($this->object->getExportDirectory($type)."/".
664  $this->object->getPublicExportFile($type)))
665  {
666  $no_download_file_available = "";
667  }
668  }
669  }
670  $this->tpl->setVariable("TXT_DOWNLOADS", $this->lng->txt("cont_downloads"));
671  $this->tpl->setVariable("TXT_DOWNLOADS_DESC", $this->lng->txt("cont_downloads_desc").$no_download_file_available);
672  $this->tpl->setVariable("CBOX_DOWNLOADS", "cobj_act_downloads");
673  $this->tpl->setVariable("VAL_DOWNLOADS", "y");
674 
675  if ($this->object->isActiveDownloads())
676  {
677  $this->tpl->setVariable("CHK_DOWNLOADS", "checked=\"checked\"");
678  }
679 
680  $this->tpl->setVariable("TXT_DOWNLOADS_PUBLIC_DESC", $this->lng->txt("cont_downloads_public_desc"));
681  $this->tpl->setVariable("CBOX_DOWNLOADS_PUBLIC", "cobj_act_downloads_public");
682  $this->tpl->setVariable("VAL_DOWNLOADS_PUBLIC", "y");
683 
684  if ($this->object->isActiveDownloadsPublic())
685  {
686  $this->tpl->setVariable("CHK_DOWNLOADS_PUBLIC", "checked=\"checked\"");
687  }
688 
689  if (!$this->object->isActiveDownloads())
690  {
691  $this->tpl->setVariable("CHK2_DOWNLOADS_PUBLIC", "disabled=\"disabled\"");
692  }
693 
694  // get user defined menu entries
695  $this->__initLMMenuEditor();
696  $entries = $this->lmme_obj->getMenuEntries();
697 
698  if (count($entries) > 0)
699  {
700  foreach ($entries as $entry)
701  {
702  $this->ctrl->setParameter($this, "menu_entry", $entry["id"]);
703 
704  $this->tpl->setCurrentBlock("menu_entries");
705 
706  if ($entry["type"] == "intern")
707  {
708  $entry["link"] = ILIAS_HTTP_PATH."/goto.php?target=".$entry["link"];
709  }
710 
711  // add http:// prefix if not exist
712  if (!strstr($entry["link"],'://') && !strstr($entry["link"],'mailto:'))
713  {
714  $entry["link"] = "http://".$entry["link"];
715  }
716 
717  $this->tpl->setVariable("ENTRY_LINK", $entry["link"]);
718  $this->tpl->setVariable("ENTRY_TITLE", $entry["title"]);
719 
720  $this->tpl->setVariable("CBOX_ENTRY", "menu_entries[]");
721  $this->tpl->setVariable("VAL_ENTRY", $entry["id"]);
722 
723  if (ilUtil::yn2tf($entry["active"]))
724  {
725  $this->tpl->setVariable("CHK_ENTRY", "checked=\"checked\"");
726  }
727 
728 
729  $this->tpl->setVariable("LINK_EDIT", $this->ctrl->getLinkTarget($this,"editMenuEntry"));
730  $this->tpl->setVariable("TARGET_EDIT", "content");
731  $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
732  $this->tpl->setVariable("IMG_EDIT", ilUtil::getImagePath("icon_pencil.gif"));
733 
734  $this->tpl->setVariable("LINK_DROP", $this->ctrl->getLinkTarget($this,"deleteMenuEntry"));
735  $this->tpl->setVariable("TARGET_DROP", "content");
736  $this->tpl->setVariable("TXT_DROP", $this->lng->txt("drop"));
737  $this->tpl->setVariable("IMG_DROP", ilUtil::getImagePath("delete.gif"));
738 
739  $this->tpl->parseCurrentBlock();
740  }
741  }
742 
743  // add entry link
744 
745 
746  $this->tpl->setCurrentBlock("commands");
747  $this->tpl->setVariable("BTN_NAME", "saveMenuProperties");
748  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
749  $this->tpl->setVariable("BTN_NAME2", "addMenuEntry");
750  $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("add_menu_entry"));
751  $this->tpl->parseCurrentBlock();
752  }
753 
758  {
759  global $ilias;
760 
761  $this->object->setActiveLMMenu(ilUtil::yn2tf($_POST["cobj_act_lm_menu"]));
762  $this->object->setActiveTOC(ilUtil::yn2tf($_POST["cobj_act_toc"]));
763  $this->object->setActivePrintView(ilUtil::yn2tf($_POST["cobj_act_print"]));
764  $this->object->setActivePreventGlossaryAppendix(ilUtil::yn2tf($_POST["cobj_act_print_prev_glo"]));
765  $this->object->setActiveDownloads(ilUtil::yn2tf($_POST["cobj_act_downloads"]));
766  $this->object->setActiveDownloadsPublic(ilUtil::yn2tf($_POST["cobj_act_downloads_public"]));
767  $this->object->updateProperties();
768 
769  $this->__initLMMenuEditor();
770 //var_dump($_POST["menu_entries"]); exit;
771  $this->lmme_obj->updateActiveStatus($_POST["menu_entries"]);
772 
773  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
774  $this->ctrl->redirect($this, "editMenuProperties");
775  }
776 
780  function explorer()
781  {
782  global $ilUser, $ilias, $ilCtrl;
783 
784  switch ($this->object->getType())
785  {
786  case "lm":
787  $gui_class = "ilobjlearningmodulegui";
788  break;
789 
790  case "dlb":
791  $gui_class = "ilobjdlbookgui";
792  break;
793  }
794 
795  $ilCtrl->setParameterByClass($gui_class, "active_node", $_GET["active_node"]);
796 
797  $this->tpl = new ilTemplate("tpl.main.html", true, true);
798  // get learning module object
799  //$this->lm_obj =& new ilObjLearningModule($this->ref_id, true);
800 
801  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
802 
803  //$this->tpl = new ilTemplate("tpl.explorer.html", false, false);
804  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
805  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
806 
807  require_once ("./Modules/LearningModule/classes/class.ilLMEditorExplorer.php");
808  $exp = new ilLMEditorExplorer($this->ctrl->getLinkTarget($this, "view"),
809  $this->object, $gui_class);
810 
811  $exp->setTargetGet("obj_id");
812  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, "explorer"));
813 
814  if ($_GET["lmmovecopy"] == "1")
815  {
816  $this->proceedDragDrop();
817  }
818 
819 
820  if ($_GET["lmexpand"] == "")
821  {
822  $mtree = new ilTree($this->object->getId());
823  $mtree->setTableNames('lm_tree','lm_data');
824  $mtree->setTreeTablePK("lm_id");
825  $expanded = $mtree->readRootId();
826  }
827  else
828  {
829  $expanded = $_GET["lmexpand"];
830  }
831  if ($_GET["active_node"] != "")
832  {
833  $path = $this->lm_tree->getPathId($_GET["active_node"]);
834  $exp->setForceOpenPath($path);
835 
836  $exp->highlightNode($_GET["active_node"]);
837  }
838  $exp->setExpand($expanded);
839 
840  // build html-output
841  $exp->setOutput(0);
842  $output = $exp->getOutput();
843 
844  // asynchronous output
845  if ($ilCtrl->isAsynch())
846  {
847  echo $output; exit;
848  }
849 
850  include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
851 
852  /*if (ilPageEditorGUI::_doJSEditing())
853  {
854  //$this->tpl->touchBlock("includejavascript");
855 
856  $IDS = "";
857  for ($i=0;$i<count($exp->iconList);$i++)
858  {
859  if ($i>0) $IDS .= ",";
860  $IDS .= "'".$exp->iconList[$i]."'";
861  }
862  $this->tpl->setVariable("ICONIDS",$IDS);
863  //$this->ctrl->setParameter($this, "lmovecopy", 1);
864  $this->tpl->setVariable("TESTPFAD",$this->ctrl->getLinkTarget($this, "explorer")."&lmmovecopy=1");
865  //$this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode");
866  $this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode");
867  }*/
868 
869  $this->tpl->setCurrentBlock("content");
870  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_chap_and_pages"));
871  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
872  $this->tpl->setVariable("EXPLORER",$output);
873  $this->ctrl->setParameter($this, "lmexpand", $_GET["lmexpand"]);
874  $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, "explorer"));
875  $this->tpl->parseCurrentBlock();
876  $this->tpl->show(false);
877  exit;
878  }
879 
883  function popup()
884  {
885  include_once "./Services/COPage/classes/class.ilWysiwygUtil.php";
886  $popup = new ilWysiwygUtil();
887  $popup->show($_GET["ptype"]);
888  exit;
889  }
890 
894  function proceedDragDrop()
895  {
896  global $ilCtrl;
897 
898  $this->object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
899  $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
900  $ilCtrl->redirect($this, "chapters");
901  }
902 
906  function createObject()
907  {
908  global $rbacsystem, $tpl;
909 
910  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
911 
912  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
913  {
914  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
915  }
916  else
917  {
918  $this->initCreationForm();
919  $f1 = $this->form->getHTML();
920  $this->initImportForm();
921  $f2 = $this->form->getHTML();
922  $this->tpl->setContent($f1."<br />".$f2);
923 
924 
925 
926 return;
927  // fill in saved values in case of error
928  $data = array();
929  $data["fields"] = array();
930  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
931  $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
932 
933  $this->getTemplateFile("create", $new_type);
934 
935  $this->tpl->setVariable("TYPE_IMG",
936  ilUtil::getImagePath("icon_".$new_type.".gif"));
937  $this->tpl->setVariable("ALT_IMG",
938  $this->lng->txt("obj_".$new_type));
939 
940  foreach ($data["fields"] as $key => $val)
941  {
942  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
943  $this->tpl->setVariable(strtoupper($key), $val);
944 
945  if ($this->prepare_output)
946  {
947  $this->tpl->parseCurrentBlock();
948  }
949  }
950 
951 
952  //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save",
953  // "adm_object.php?cmd=gateway&ref_id=".
954  // $_GET["ref_id"]."&new_type=".$new_type));
955  $this->ctrl->setParameter($this, "new_type", $new_type);
956  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "save"));
957 
958 
959  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
960  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
961  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
962  $this->tpl->setVariable("CMD_SUBMIT", "save");
963  $this->tpl->setVariable("TARGET", ' target="'.
964  ilFrameTargetInfo::_getFrame("MainContent").'" ');
965  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
966 
967  $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_".$new_type));
968  $this->tpl->setVariable("TXT_LM_FILE", $this->lng->txt("file"));
969  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
970 
971  // get the value for the maximal uploadable filesize from the php.ini (if available)
972  $umf=get_cfg_var("upload_max_filesize");
973  // get the value for the maximal post data from the php.ini (if available)
974  $pms=get_cfg_var("post_max_size");
975 
976  // use the smaller one as limit
977  $max_filesize = ((int) $umf < (int) $pms)
978  ? $umf
979  : $pms;
980  if ((int) $pms == 0) $max_filesize = $umf;
981 
982  if (!$max_filesize) $max_filesize=max($umf, $pms);
983 
984  // gives out the limit as a littel notice :)
985  $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." $max_filesize.");
986 
987  }
988  }
989 
995  public function initCreationForm($a_mode = "create")
996  {
997  global $lng, $ilCtrl;
998 
999  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1000  $this->form = new ilPropertyFormGUI();
1001 
1002  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
1003  $this->ctrl->setParameter($this, "new_type", $new_type);
1004 
1005  $this->form->setTarget(ilFrameTargetInfo::_getFrame("MainContent"));
1006  $this->form->setTableWidth("600px");
1007 
1008  // title
1009  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1010  $ti->setMaxLength(128);
1011  $ti->setRequired(true);
1012  //$ti->setSize();
1013  $this->form->addItem($ti);
1014 
1015  // text area
1016  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
1017  //$ta->setCols();
1018  //$ta->setRows();
1019  $this->form->addItem($ta);
1020 
1021  $this->form->addCommandButton("save", $this->lng->txt($new_type."_add"));
1022  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
1023  $this->form->setTitle($this->lng->txt($new_type."_new"));
1024  $this->form->setFormAction($this->ctrl->getFormAction($this, "save"));
1025  }
1026 
1030  public function initImportForm()
1031  {
1032  global $lng, $ilCtrl;
1033 
1034  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1035  $this->form = new ilPropertyFormGUI();
1036 
1037  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
1038  $this->ctrl->setParameter($this, "new_type", $new_type);
1039 
1040  $this->form->setTarget(ilFrameTargetInfo::_getFrame("MainContent"));
1041  $this->form->setTableWidth("600px");
1042 
1043  // import file
1044  $fi = new ilFileInputGUI($this->lng->txt("file"), "xmldoc");
1045  $fi->setSuffixes(array("zip"));
1046  $fi->setRequired(true);
1047  $fi->setSize(30);
1048  $this->form->addItem($fi);
1049 
1050  // validation
1051  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_validate_file"), "validate");
1052  $cb->setInfo($this->lng->txt(""));
1053  $this->form->addItem($cb);
1054 
1055  $this->form->addCommandButton("importFile", $lng->txt("import"));
1056  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
1057 
1058  $this->form->setTitle($this->lng->txt("import_".$new_type));
1059  $this->form->setFormAction($ilCtrl->getFormAction($this));
1060 
1061  }
1062 
1066  function saveObject()
1067  {
1068  global $rbacadmin, $rbacsystem, $tpl;
1069 
1070  // always call parent method first to create an object_data entry & a reference
1071  //$newObj = parent::saveObject();
1072  // TODO: fix MetaDataGUI implementation to make it compatible to use parent call
1073  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
1074  {
1075  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
1076  return;
1077  }
1078 
1079  $this->initCreationForm();
1080  if ($this->form->checkInput())
1081  {
1082  // create and insert object in objecttree
1083  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
1084  $newObj = new ilObjContentObject();
1085  $newObj->setType($this->type);
1086  $newObj->setTitle($_POST["title"]);#"content object ".$newObj->getId()); // set by meta_gui->save
1087  $newObj->setDescription($_POST["desc"]); // set by meta_gui->save
1088  $newObj->create();
1089  $newObj->createReference();
1090  $newObj->putInTree($_GET["ref_id"]);
1091  $newObj->setPermissions($_GET["ref_id"]);
1092  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
1093  $newObj->setCleanFrames(true);
1094  $newObj->update();
1095 
1096  // create content object tree
1097  $newObj->createLMTree();
1098 
1099  // always send a message
1100  ilUtil::sendSuccess($this->lng->txt($this->type."_added"), true);
1101  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1102  "&baseClass=ilLMEditorGUI");
1103 
1104  }
1105  else
1106  {
1107  $this->form->setValuesByPost();
1108  $tpl->setContent($this->form->getHtml());
1109  }
1110  }
1111 
1115  function addBibItemObject($a_target = "")
1116  {
1117  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1118  $bib_gui =& new ilBibItemGUI();
1119  $bib_gui->setObject($this->object);
1120  $bibItemName = $_POST["bibItemName"] ? $_POST["bibItemName"] : $_GET["bibItemName"];
1121  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1122  if ($bibItemIndex == "")
1123  $bibItemIndex = 0;
1124  $bibItemPath = $_POST["bibItemPath"] ? $_POST["bibItemPath"] : $_GET["bibItemPath"];
1125  if ($bibItemName != "")
1126  {
1127  $bib_gui->bib_obj->add($bibItemName, $bibItemPath, $bibItemIndex);
1128  $data = $bib_gui->bib_obj->getElement("BibItem");
1129  $bibItemIndex = (count($data) - 1);
1130  }
1131  else
1132  {
1133  ilUtil::sendInfo($this->lng->txt("bibitem_choose_element"), true);
1134  }
1135  if ($a_target == "")
1136  {
1137  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1138  }
1139 
1140  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1141  }
1142 
1146  function addBibItem()
1147  {
1148  $this->setTabs();
1149 
1150  // questionable workaround to make this old stuff work
1151  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1152 
1153  $this->addBibItemObject($this->ctrl->getLinkTarget($this));
1154  }
1155 
1159  function deleteBibItemObject($a_target = "")
1160  {
1161  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1162  $bib_gui =& new ilBibItemGUI();
1163  $bib_gui->setObject($this->object);
1164  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1165  $bib_gui->bib_obj->delete($_GET["bibItemName"], $_GET["bibItemPath"], $bibItemIndex);
1166  if (strpos($bibItemIndex, ",") > 0)
1167  {
1168  $bibItemIndex = substr($bibItemIndex, 0, strpos($bibItemIndex, ","));
1169  }
1170  if ($a_target == "")
1171  {
1172  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1173  }
1174 
1175  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1176  }
1177 
1181  function deleteBibItem()
1182  {
1183  $this->setTabs();
1184 
1185  // questionable workaround to make this old stuff work
1186  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1187 
1188  $this->deleteBibItemObject($this->ctrl->getLinkTarget($this));
1189  }
1190 
1191 
1195  function editBibItemObject($a_target = "")
1196  {
1197  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1198  $bib_gui =& new ilBibItemGUI();
1199  $bib_gui->setObject($this->object);
1200  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1201  $bibItemIndex *= 1;
1202  if ($bibItemIndex < 0)
1203  {
1204  $bibItemIndex = 0;
1205  }
1206  if ($a_target == "")
1207  {
1208  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1209  }
1210 
1211  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1212  }
1213 
1217  function editBibItem()
1218  {
1219  $this->setTabs();
1220 
1221  // questionable workaround to make this old stuff work
1222  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1223 
1224  $this->editBibItemObject($this->ctrl->getLinkTarget($this));
1225  }
1226 
1230  function saveBibItemObject($a_target = "")
1231  {
1232  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1233  $bib_gui =& new ilBibItemGUI();
1234  $bib_gui->setObject($this->object);
1235  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1236  $bibItemIndex *= 1;
1237  if ($bibItemIndex < 0)
1238  {
1239  $bibItemIndex = 0;
1240  }
1241  $bibItemIndex = $bib_gui->save($bibItemIndex);
1242 
1243  if ($a_target == "")
1244  {
1245  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1246  }
1247 
1248  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1249  }
1250 
1254  function saveBibItem()
1255  {
1256  $this->setTabs();
1257 
1258  // questionable workaround to make this old stuff work
1259  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1260 
1261  $this->saveBibItemObject($this->ctrl->getLinkTarget($this));
1262  }
1263 
1269  function exportObject()
1270  {
1271  return;
1272  }
1273 
1279  function importObject()
1280  {
1281  $this->createObject();
1282  return;
1283  }
1284 
1285 
1292  function importFileObject()
1293  {
1294  global $_FILES, $rbacsystem, $ilDB, $tpl;
1295 
1296  include_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
1297 
1298  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
1299  {
1300  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
1301  return;
1302  }
1303 
1304  $this->initImportForm();
1305  if ($this->form->checkInput())
1306  {
1307  // create and insert object in objecttree
1308  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
1309  $newObj = new ilObjContentObject();
1310  $newObj->setType($_GET["new_type"]);
1311  $newObj->setTitle($_FILES["xmldoc"]["name"]);
1312  $newObj->setDescription("");
1313  $newObj->create(true);
1314  $newObj->createReference();
1315  $newObj->putInTree($_GET["ref_id"]);
1316  $newObj->setPermissions($_GET["ref_id"]);
1317  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
1318 
1319  // create learning module tree
1320  $newObj->createLMTree();
1321 
1322  // import lm from file
1323  $mess = $newObj->importFromZipFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"],
1324  $_POST["validate"]);
1325 
1326  if ($mess == "")
1327  {
1328  ilUtil::sendSuccess($this->lng->txt($this->type."_added"),true);
1329  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1330  "&baseClass=ilLMEditorGUI");
1331  }
1332  else
1333  {
1334  $link = '<a href="'."ilias.php?ref_id=".$newObj->getRefId().
1335  "&baseClass=ilLMEditorGUI".'" target="_top">'.$this->lng->txt("btn_next").'</a>';
1336  $tpl->setContent("<br />".$link."<br /><br />".$mess.$link);
1337  }
1338  }
1339  else
1340  {
1341  $this->form->setValuesByPost();
1342  $tpl->setContent($this->form->getHtml());
1343  }
1344  }
1345 
1349  function chapters()
1350  {
1351  global $tree, $lng, $ilCtrl, $ilUser;
1352 
1353  $this->setTabs();
1354 
1355  if ($ilUser->getPref("lm_js_chapter_editing") != "disable")
1356  {
1357  $ilCtrl->setParameter($this, "backcmd", "chapters");
1358 
1359  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1360  $form_gui = new ilChapterHierarchyFormGUI($this->object->getType());
1361  $form_gui->setFormAction($ilCtrl->getFormAction($this));
1362  $form_gui->setTitle($this->object->getTitle());
1363  $form_gui->setIcon(ilUtil::getImagePath("icon_lm.gif"));
1364  $form_gui->setTree($this->lm_tree);
1365  $form_gui->setMaxDepth(0);
1366  $form_gui->setCurrentTopNodeId($this->tree->getRootId());
1367  $form_gui->addMultiCommand($lng->txt("delete"), "delete");
1368  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
1369  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
1370  $form_gui->setDragIcon(ilUtil::getImagePath("icon_st_s.gif"));
1371  $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
1372  $up_gui = ($this->object->getType() == "dbk")
1373  ? "ilobjdlbookgui"
1374  : "ilobjlearningmodulegui";
1375  $form_gui->setExplorerUpdater("tree", "tree_div",
1376  $ilCtrl->getLinkTargetByClass($up_gui, "explorer", "", true));
1377 
1378  $ctpl = new ilTemplate("tpl.chap_and_pages.html", true, true, "Modules/LearningModule");
1379  $ctpl->setVariable("HIERARCHY_FORM", $form_gui->getHTML());
1380  $ilCtrl->setParameter($this, "obj_id", "");
1381  $ctpl->setVariable("HREF_NO_JS_EDIT",
1382  $ilCtrl->getLinkTarget($this, "deactivateJSChapterEditing"));
1383  $ctpl->setVariable("TXT_NO_JS_EDIT",
1384  $lng->txt("cont_not_js_chap_editing"));
1385 
1386  $this->tpl->setContent($ctpl->get());
1387  }
1388  else
1389  {
1390  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", "Modules/LearningModule");
1391  $num = 0;
1392 
1393  $this->ctrl->setParameter($this, "backcmd", "chapters");
1394  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1395  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_chapters"));
1396  $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
1397 
1398  $cnt = 0;
1399  $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
1400  foreach ($childs as $child)
1401  {
1402  if($child["type"] != "st")
1403  {
1404  continue;
1405  }
1406 
1407  $this->tpl->setCurrentBlock("table_row");
1408  // color changing
1409  $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
1410 
1411  // checkbox
1412  $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
1413  $this->tpl->setVariable("CSS_ROW", $css_row);
1414  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.gif"));
1415 
1416  // link
1417  $this->ctrl->setParameter($this, "backcmd", "");
1418  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
1419  $this->tpl->setVariable("LINK_TARGET",
1420  $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view"));
1421 
1422  // title
1423  $this->tpl->setVariable("TEXT_CONTENT",
1425  $this->object->isActiveNumbering()));
1426 
1427  $this->tpl->parseCurrentBlock();
1428  }
1429 
1430  $paste_active = false;
1431  if ($ilUser->clipboardHasObjectsOfType("st"))
1432  {
1433  $paste_active = true;
1434  }
1435 
1436  if($cnt == 0 && !$paste_active)
1437  {
1438  $this->tpl->setCurrentBlock("notfound");
1439  $this->tpl->setVariable("NUM_COLS", 3);
1440  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1441  $this->tpl->parseCurrentBlock();
1442  }
1443  else
1444  {
1445  // SHOW VALID ACTIONS
1446  $this->tpl->setVariable("NUM_COLS", 3);
1447  if ($cnt > 0)
1448  {
1449  $acts = array("delete" => "delete", "cutChapter" => "cut",
1450  "copyChapter" => "copyChapter");
1451  }
1452  if ($paste_active)
1453  {
1454  $acts["pasteChapter"] = "pasteChapter";
1455  }
1456  $this->showActions($acts);
1457  }
1458 
1459  // SHOW POSSIBLE SUB OBJECTS
1460  $this->tpl->setVariable("NUM_COLS", 3);
1461  $subobj = array("st");
1462  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1463  $this->tpl->setCurrentBlock("add_object");
1464  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1465  $this->tpl->setVariable("BTN_NAME", "create");
1466  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
1467  $this->tpl->parseCurrentBlock();
1468 
1469  $this->tpl->setCurrentBlock("form");
1470  $this->tpl->parseCurrentBlock();
1471 
1472  $this->tpl->setVariable("HREF_JS_EDIT",
1473  $ilCtrl->getLinkTarget($this, "activateJSChapterEditing"));
1474  $this->tpl->setVariable("TXT_JS_EDIT",
1475  $lng->txt("cont_js_chap_editing"));
1476  }
1477  }
1478 
1479 
1480  /*
1481  * list all pages of learning module
1482  */
1483  function pages()
1484  {
1485  global $tree;
1486 
1487  $this->setTabs();
1488 
1489  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.all_pages.html", "Modules/LearningModule");
1490  $num = 0;
1491 
1492  $this->tpl->setCurrentBlock("form");
1493  $this->ctrl->setParameter($this, "backcmd", "pages");
1494  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1495  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_pages"));
1496  $this->tpl->setVariable("CONTEXT", $this->lng->txt("cont_usage"));
1497  $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
1498 
1499  $cnt = 0;
1500  $pages = ilLMPageObject::getPageList($this->object->getId());
1501  foreach ($pages as $page)
1502  {
1503  $this->tpl->setCurrentBlock("table_row");
1504 
1505  // check activation
1506  include_once("./Services/COPage/classes/class.ilPageObject.php");
1507  $lm_set = new ilSetting("lm");
1508  $active = ilPageObject::_lookupActive($page["obj_id"], $this->object->getType(),
1509  $lm_set->get("time_scheduled_page_activation"));
1510 
1511  // is page scheduled?
1512  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
1513  ilPageObject::_isScheduledActivation($page["obj_id"], $this->object->getType()))
1514  ? "_sc"
1515  : "";
1516 
1517  if (!$active)
1518  {
1519  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg_d".$img_sc.".gif"));
1520  $this->tpl->setVariable("IMG_ALT",
1521  $this->lng->txt("cont_page_deactivated"));
1522  }
1523  else
1524  {
1526  $this->object->getType()))
1527  {
1528  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg_del".$img_sc.".gif"));
1529  $this->tpl->setVariable("IMG_ALT",
1530  $this->lng->txt("cont_page_deactivated_elements"));
1531  }
1532  else
1533  {
1534  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg".$img_sc.".gif"));
1535  $this->tpl->setVariable("IMG_ALT",
1536  $this->lng->txt("pg"));
1537  }
1538  }
1539 
1540  // color changing
1541  $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
1542 
1543  // checkbox
1544  $this->tpl->setVariable("CHECKBOX_ID", $page["obj_id"]);
1545  $this->tpl->setVariable("CSS_ROW", $css_row);
1546 
1547  // link
1548  $this->ctrl->setParameter($this, "backcmd", "");
1549  $this->ctrl->setParameterByClass("ilLMPageObjectGUI", "obj_id", $page["obj_id"]);
1550 //echo "<br>:".$this->ctrl->getLinkTargetByClass("ilLMPageObjectGUI", "view").":";
1551  $this->tpl->setVariable("LINK_TARGET",
1552  $this->ctrl->getLinkTargetByClass("ilLMPageObjectGUI", "edit"));
1553 
1554  // title
1555  $this->tpl->setVariable("TEXT_CONTENT", $page["title"]);
1556 
1557  // context
1558  if ($this->lm_tree->isInTree($page["obj_id"]))
1559  {
1560  $path_str = $this->getContextPath($page["obj_id"]);
1561  }
1562  else
1563  {
1564  $path_str = "---";
1565  }
1566 
1567  // check whether page is header or footer
1568  $add_str = "";
1569  if ($page["obj_id"] == $this->object->getHeaderPage())
1570  {
1571  $add_str = " <b>(".$this->lng->txt("cont_header").")</b>";
1572  }
1573  if ($page["obj_id"] == $this->object->getFooterPage())
1574  {
1575  $add_str = " <b>(".$this->lng->txt("cont_footer").")</b>";
1576  }
1577 
1578  $this->tpl->setVariable("TEXT_CONTEXT", $path_str.$add_str);
1579 
1580 
1581  $this->tpl->parseCurrentBlock();
1582  }
1583  if($cnt == 0)
1584  {
1585  $this->tpl->setCurrentBlock("notfound");
1586  $this->tpl->setVariable("NUM_COLS", 4);
1587  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1588  $this->tpl->parseCurrentBlock();
1589  }
1590  else
1591  {
1592  $acts = array("delete" => "delete", "movePage" => "movePage", "copyPage" => "copyPage",
1593  "selectHeader" => "selectHeader", "selectFooter" => "selectFooter",
1594  "activatePages" => "cont_de_activate");
1596  ilEditClipboard::getAction() == "copy")
1597  {
1598  $acts["pastePage"] = "pastePage";
1599  }
1600 
1601  /*
1602  if (ilEditClipboard::getContentObjectType() == "st")
1603  {
1604  $acts["pasteChapter"] = "pasteChapter";
1605  }*/
1606  $this->tpl->setVariable("NUM_COLS", 4);
1607  $this->showActions($acts);
1608 
1609  // SHOW VALID ACTIONS
1610  /*
1611  $this->tpl->setCurrentBlock("operation_btn");
1612  $this->tpl->setVariable("BTN_NAME", "delete");
1613  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1614  $this->tpl->parseCurrentBlock();*/
1615 
1616  }
1617 
1618  // SHOW POSSIBLE SUB OBJECTS
1619  $this->tpl->setVariable("NUM_COLS", 4);
1620  //$this->showPossibleSubObjects("st");
1621  $subobj = array("pg");
1622  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1623  $this->tpl->setCurrentBlock("add_object");
1624  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1625  $this->tpl->setVariable("BTN_NAME", "create");
1626  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("create"));
1627  $this->tpl->parseCurrentBlock();
1628 
1629 
1630  $this->tpl->setCurrentBlock("form");
1631  $this->tpl->parseCurrentBlock();
1632 
1633  }
1634 
1638  function listLinks()
1639  {
1640  global $tpl;
1641 
1642  $this->setTabs();
1643  $this->setLinkSubTabs("internal_links");
1644 
1645  include_once("./Modules/LearningModule/classes/class.ilLinksTableGUI.php");
1646  $table_gui = new ilLinksTableGUI($this, "listLinks",
1647  $this->object->getId(), $this->object->getType());
1648 
1649  $tpl->setContent($table_gui->getHTML());
1650  }
1651 
1652 
1656  function activatePages()
1657  {
1658  if (is_array($_POST["id"]))
1659  {
1660  foreach($_POST["id"] as $id)
1661  {
1662  include_once("./Services/COPage/classes/class.ilPageObject.php");
1663  $act = ilPageObject::_lookupActive($id, $this->object->getType());
1664  ilPageObject::_writeActive($id, $this->object->getType(), !$act);
1665  }
1666  }
1667 
1668  $this->ctrl->redirect($this, "pages");
1669  }
1670 
1675  {
1676  global $ilCtrl, $ilUser;
1677 
1678  $ilUser->writePref("lm_js_chapter_editing", "disable");
1679  $ilCtrl->redirect($this, "chapters");
1680  }
1681 
1686  {
1687  global $ilCtrl, $ilUser;
1688 
1689  $ilUser->writePref("lm_js_chapter_editing", "enable");
1690  $ilCtrl->redirect($this, "chapters");
1691  }
1692 
1696  function pastePage()
1697  {
1699  {
1700  $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
1701  }
1702 
1703  // paste selected object
1705 
1706  // copy page, if action is copy
1707  if (ilEditClipboard::getAction() == "copy")
1708  {
1709  // check wether page belongs to lm
1711  == $this->object->getID())
1712  {
1713  $lm_page = new ilLMPageObject($this->object, $id);
1714  $new_page =& $lm_page->copy();
1715  $id = $new_page->getId();
1716  }
1717  else
1718  {
1719  // get page from other content object into current content object
1721  $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
1722  $lm_page = new ilLMPageObject($lm_obj, $id);
1723  $copied_nodes = array();
1724  $new_page =& $lm_page->copyToOtherContObject($this->object, $copied_nodes);
1725  $id = $new_page->getId();
1726  ilLMObject::updateInternalLinks($copied_nodes);
1727  }
1728  }
1729 
1730  // cut is not be possible in "all pages" form yet
1731  if (ilEditClipboard::getAction() == "cut")
1732  {
1733  // check wether page belongs not to lm
1735  != $this->object->getID())
1736  {
1738  $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
1739  $lm_page = new ilLMPageObject($lm_obj, $id);
1740  $lm_page->setLMId($this->object->getID());
1741  $lm_page->update();
1742  $page =& $lm_page->getPageObject();
1743  $page->buildDom();
1744  $page->setParentId($this->object->getID());
1745  $page->update();
1746  }
1747  }
1748 
1749 
1751  $this->ctrl->redirect($this, "pages");
1752  }
1753 
1757  function copyPage()
1758  {
1759  if(!isset($_POST["id"]))
1760  {
1761  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1762  }
1763 
1764  $items = ilUtil::stripSlashesArray($_POST["id"]);
1765  ilLMObject::clipboardCopy($this->object->getId(), $items);
1767 
1768  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"), true);
1769 
1770  $this->ctrl->redirect($this, "pages");
1771  }
1772 
1780  function delete($a_parent_subobj_id = 0)
1781  {
1782  if(!isset($_POST["id"]))
1783  {
1784  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1785  }
1786 
1787  if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
1788  {
1789  $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
1790  }
1791 
1792  if ($a_parent_subobj_id == 0)
1793  {
1794  $this->setTabs();
1795  }
1796 
1797  // SAVE POST VALUES
1798  $_SESSION["saved_post"] = $_POST["id"];
1799 
1800  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/LearningModule");
1801 
1802  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1803 
1804  if ($a_parent_subobj_id != 0)
1805  {
1806  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "backcmd", $_GET["backcmd"]);
1807  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $a_parent_subobj_id);
1808  $this->tpl->setVariable("FORMACTION",
1809  $this->ctrl->getFormActionByClass("ilStructureObjectGUI"));
1810  }
1811  else
1812  {
1813  $this->ctrl->setParameter($this, "backcmd", $_GET["backcmd"]);
1814  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1815  }
1816  // BEGIN TABLE HEADER
1817  $this->tpl->setCurrentBlock("table_header");
1818  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
1819  $this->tpl->parseCurrentBlock();
1820 
1821  // END TABLE HEADER
1822 
1823  // BEGIN TABLE DATA
1824  $counter = 0;
1825 //var_dump($_POST);
1826  foreach($_POST["id"] as $id)
1827  {
1828  if ($id != IL_FIRST_NODE)
1829  {
1830  $obj =& new ilLMObject($this->object, $id);
1831  switch($obj->getType()) // ok that's not so nice, could be done better
1832  {
1833  case "pg":
1834  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg.gif"));
1835  break;
1836  case "st":
1837  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.gif"));
1838  break;
1839  }
1840  $this->tpl->setCurrentBlock("table_row");
1841  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow2","tblrow1"));
1842  $this->tpl->setVariable("TEXT_CONTENT", $obj->getTitle());
1843  $this->tpl->parseCurrentBlock();
1844  }
1845  }
1846 
1847  // cancel/confirm button
1848  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
1849  $buttons = array( "cancelDelete" => $this->lng->txt("cancel"),
1850  "confirmedDelete" => $this->lng->txt("confirm"));
1851  foreach ($buttons as $name => $value)
1852  {
1853  $this->tpl->setCurrentBlock("operation_btn");
1854  $this->tpl->setVariable("BTN_NAME",$name);
1855  $this->tpl->setVariable("BTN_VALUE",$value);
1856  $this->tpl->parseCurrentBlock();
1857  }
1858  }
1859 
1863  function cancelDelete()
1864  {
1865  session_unregister("saved_post");
1866 
1867  $this->ctrl->redirect($this, $_GET["backcmd"]);
1868 
1869  }
1870 
1878  function confirmedDelete($a_parent_subobj_id = 0)
1879  {
1880  $tree = new ilTree($this->object->getId());
1881  $tree->setTableNames('lm_tree','lm_data');
1882  $tree->setTreeTablePK("lm_id");
1883 
1884  // check number of objects
1885  if (!isset($_SESSION["saved_post"]))
1886  {
1887  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1888  }
1889 
1890  // delete all selected objects
1891  foreach ($_SESSION["saved_post"] as $id)
1892  {
1893  if ($id != IL_FIRST_NODE)
1894  {
1895  $obj =& ilLMObjectFactory::getInstance($this->object, $id, false);
1896  $node_data = $tree->getNodeData($id);
1897  if (is_object($obj))
1898  {
1899  $obj->setLMId($this->object->getId());
1900 
1901  include_once("classes/class.ilHistory.php");
1902  ilHistory::_createEntry($this->object->getId(), "delete_".$obj->getType(),
1903  array(ilLMObject::_lookupTitle($id), $id),
1904  $this->object->getType());
1905 
1906  $obj->delete();
1907  }
1908  if($tree->isInTree($id))
1909  {
1910  $tree->deleteTree($node_data);
1911  }
1912  }
1913  }
1914 
1915  // check the tree
1916  $this->object->checkTree();
1917 
1918  // feedback
1919  ilUtil::sendSuccess($this->lng->txt("info_deleted"),true);
1920 
1921  if ($a_parent_subobj_id == 0)
1922  {
1923  $this->ctrl->redirect($this, $_GET["backcmd"]);
1924  }
1925  }
1926 
1927 
1928 
1935  function getContextPath($a_endnode_id, $a_startnode_id = 1)
1936  {
1937  $path = "";
1938 
1939  $tmpPath = $this->lm_tree->getPathFull($a_endnode_id, $a_startnode_id);
1940 
1941  // count -1, to exclude the learning module itself
1942  for ($i = 1; $i < (count($tmpPath) - 1); $i++)
1943  {
1944  if ($path != "")
1945  {
1946  $path .= " > ";
1947  }
1948 
1949  $path .= $tmpPath[$i]["title"];
1950  }
1951 
1952  return $path;
1953  }
1954 
1955 
1956 
1962  function showActions($a_actions)
1963  {
1964  foreach ($a_actions as $name => $lng)
1965  {
1966  $d[$name] = array("name" => $name, "lng" => $lng);
1967  }
1968 
1969  $notoperations = array();
1970 
1971  $operations = array();
1972 
1973  if (is_array($d))
1974  {
1975  foreach ($d as $row)
1976  {
1977  if (!in_array($row["name"], $notoperations))
1978  {
1979  $operations[] = $row;
1980  }
1981  }
1982  }
1983 
1984  if (count($operations)>0)
1985  {
1986  foreach ($operations as $val)
1987  {
1988  $this->tpl->setCurrentBlock("operation_btn");
1989  $this->tpl->setVariable("BTN_NAME", $val["name"]);
1990  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
1991  $this->tpl->parseCurrentBlock();
1992  }
1993 
1994  $this->tpl->setCurrentBlock("operation");
1995  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
1996  $this->tpl->parseCurrentBlock();
1997  }
1998  }
1999 
2003  function perm()
2004  {
2005  $this->setTabs();
2006 
2007  $this->setFormAction("addRole", $this->ctrl->getLinkTarget($this, "addRole"));
2008  $this->setFormAction("permSave", $this->ctrl->getLinkTarget($this, "permSave"));
2009  $this->permObject();
2010  }
2011 
2012 
2016  function permSave()
2017  {
2018  $this->setReturnLocation("permSave", $this->ctrl->getLinkTarget($this, "perm"));
2019  $this->permSaveObject();
2020  }
2021 
2025  function info()
2026  {
2027  $this->setTabs();
2028  $this->infoObject();
2029  }
2030 
2031 
2035  function addRole()
2036  {
2037  $this->setReturnLocation("addRole", $this->ctrl->getLinkTarget($this, "perm"));
2038  $this->addRoleObject();
2039  }
2040 
2041 
2045  function owner()
2046  {
2047  $this->setTabs();
2048  $this->ownerObject();
2049  }
2050 
2051 
2055  function view()
2056  {
2057  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
2058  {
2059  $this->prepareOutput();
2061  }
2062  else
2063  {
2064  $this->viewObject();
2065  }
2066  }
2067 
2068 
2072  function moveChapter($a_parent_subobj_id = 0)
2073  {
2074  if(!isset($_POST["id"]))
2075  {
2076  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2077  }
2078 //echo "Hallo::"; exit;
2079  if(count($_POST["id"]) > 1)
2080  {
2081  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2082  }
2083 
2084  if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
2085  {
2086  $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
2087  }
2088 
2089  // SAVE POST VALUES
2090  ilEditClipboard::storeContentObject("st", $_POST["id"][0], "move");
2091 
2092  ilUtil::sendInfo($this->lng->txt("cont_chap_select_target_now"), true);
2093 
2094  if ($a_parent_subobj_id == 0)
2095  {
2096  $this->ctrl->redirect($this, "chapters");
2097  }
2098  }
2099 
2100 
2104  function copyChapter($a_parent_subobj_id = 0)
2105  {
2106  $this->copyItems();
2107  return;
2108 
2109  if(!isset($_POST["id"]))
2110  {
2111  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2112  }
2113 
2114  if(count($_POST["id"]) > 1)
2115  {
2116  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2117  }
2118 
2119  if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
2120  {
2121  $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
2122  }
2123 
2124  // SAVE POST VALUES
2125  ilEditClipboard::storeContentObject("st", $_POST["id"][0], "copy");
2126 
2127  ilUtil::sendInfo($this->lng->txt("cont_chap_copy_select_target_now"), true);
2128 
2129  if ($a_parent_subobj_id == 0)
2130  {
2131  $this->ctrl->redirect($this, "chapters");
2132  }
2133  }
2134 
2138  function pasteChapter($a_parent_subobj_id = 0)
2139  {
2140  return $this->insertChapterClip(false);
2141  return;
2142 
2144  {
2145  $this->ilias->raiseError($this->lng->txt("no_chapter_in_clipboard"),$this->ilias->error_obj->MESSAGE);
2146  }
2147 
2148  $target_tree = new ilTree($this->object->getId());
2149  $target_tree->setTableNames('lm_tree','lm_data');
2150  $target_tree->setTreeTablePK("lm_id");
2151 
2152  // check wether page belongs to lm
2154  != $this->object->getID())
2155  {
2157  $source_tree->setTableNames('lm_tree','lm_data');
2158  $source_tree->setTreeTablePK("lm_id");
2159  }
2160  else
2161  {
2162  $source_tree =& $target_tree;
2163  }
2164 
2165  // check, if target is within subtree
2167  $node = $source_tree->getNodeData($id);
2168  $subnodes = $source_tree->getSubtree($node);
2169  foreach ($subnodes as $subnode)
2170  {
2171  if($subnode["obj_id"] == $a_parent_subobj_id)
2172  {
2173  $this->ilias->raiseError($this->lng->txt("cont_target_within_source"),$this->ilias->error_obj->MESSAGE);
2174  }
2175  }
2176  if($_POST["id"][0] == $id)
2177  {
2179  $this->ctrl->redirect($this, "chapters");
2180  }
2181 
2182  // determin parent
2183  $parent = ($a_parent_subobj_id == 0)
2184  ? $target_tree->getRootId()
2185  : $a_parent_subobj_id;
2186 
2187  // determine target position
2188  if(!isset($_POST["id"]))
2189  {
2190  $target = IL_LAST_NODE;
2191  }
2192  else
2193  {
2194  $target = $_POST["id"][0];
2195  }
2196  if($target == IL_FIRST_NODE) // do not move a chapter in front of a page
2197  {
2198  $childs =& $target_tree->getChildsByType($parent, "pg");
2199  if (count($childs) != 0)
2200  {
2201  $target = $childs[count($childs) - 1]["obj_id"];
2202  }
2203  }
2204 
2205  //echo ":".$id.":";
2206  // delete old tree entries
2207 //echo "-".ilEditClipboard::getAction()."-";
2208  if (ilEditClipboard::getAction() == "move")
2209  {
2211  != $this->object->getID())
2212  {
2213  // we should never reach these lines, moving chapters from on
2214  // lm to another is not supported
2216  if ($a_parent_subobj_id == 0)
2217  {
2218  $this->ctrl->redirect($this, "chapters");
2219  }
2220  return;
2221  }
2222 
2223  $target_tree->deleteTree($node);
2224 
2225  if (!$target_tree->isInTree($id))
2226  {
2227  $target_tree->insertNode($id, $parent, $target);
2228 
2229  foreach ($subnodes as $node)
2230  {
2231  //$obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
2232  //$obj_data->putInTree($node["parent"]);
2233  if($node["obj_id"] != $id)
2234  {
2235  $target_tree->insertNode($node["obj_id"], $node["parent"]);
2236  }
2237  }
2238  }
2239  }
2240  else // copy
2241  {
2243 
2244  $copied_nodes = array();
2246  == $this->object->getID())
2247  {
2248  $source_obj = ilLMObjectFactory::getInstance($this->object, $id, true);
2249  $source_obj->setLMId($this->object->getId());
2250  $source_obj->copy($target_tree, $parent, $target, $copied_nodes);
2251  }
2252  else
2253  {
2254  $lm_id = ilLMObject::_lookupContObjID($id);
2255 
2256  $source_lm =& ilObjectFactory::getInstanceByObjId($lm_id);
2257  $source_obj = ilLMObjectFactory::getInstance($source_lm, $id, true);
2258  $source_obj->setLMId($lm_id);
2259  $source_obj->copy($target_tree, $parent, $target, $copied_nodes);
2260  }
2261  }
2262 
2263  ilLMObject::updateInternalLinks($copied_nodes);
2264 
2266 
2267  // check the tree
2268  $this->object->checkTree();
2269 
2270  if ($a_parent_subobj_id == 0)
2271  {
2272  $this->ctrl->redirect($this, "chapters");
2273  }
2274  }
2275 
2279  function movePage()
2280  {
2281  if(!isset($_POST["id"]))
2282  {
2283  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2284  }
2285 
2286  $items = ilUtil::stripSlashesArray($_POST["id"]);
2287  ilLMObject::clipboardCut($this->object->getId(), $items);
2289 
2290  $this->ctrl->redirect($this, "pages");
2291  }
2292 
2296  function cancel()
2297  {
2298  if ($_GET["new_type"] == "pg")
2299  {
2300  $this->ctrl->redirect($this, "pages");
2301  }
2302  else
2303  {
2304  $this->ctrl->redirect($this, "chapters");
2305  }
2306  }
2307 
2308 
2312  function export()
2313  {
2314  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2315  $cont_exp = new ilContObjectExport($this->object);
2316  $cont_exp->buildExportFile();
2317 // $this->ctrl->redirect($this, "exportList");
2318  }
2319 
2323  function getPublicAccessColValue($a_type, $a_file)
2324  {
2325  global $lng, $ilCtrl;
2326 
2327  $changelink = "<a href='".$ilCtrl->getLinkTarget($this, "editMenuProperties")."'>".$lng->txt("change")."</a>";
2328  if (!$this->object->isActiveLMMenu())
2329  {
2330  $add = "<br />".$lng->txt("cont_download_no_menu")." ".$changelink;
2331  }
2332  else if (!$this->object->isActiveDownloads())
2333  {
2334  $add = "<br />".$lng->txt("cont_download_no_download")." ".$changelink;
2335  }
2336 
2337 
2338  if ($this->object->getPublicExportFile($a_type) == $a_file)
2339  {
2340  return $lng->txt("yes").$add;
2341  }
2342 
2343  return " ";
2344  }
2345 
2346 
2347 
2351  function publishExportFile($a_files)
2352  {
2353  global $ilCtrl;
2354 
2355  if(!isset($a_files))
2356  {
2357  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
2358  }
2359  else
2360  {
2361  foreach ($a_files as $f)
2362  {
2363  $file = explode(":", $f);
2364  $export_dir = $this->object->getExportDirectory($file[0]);
2365 
2366  if ($this->object->getPublicExportFile($file[0]) ==
2367  $file[1])
2368  {
2369  $this->object->setPublicExportFile($file[0], "");
2370  }
2371  else
2372  {
2373  $this->object->setPublicExportFile($file[0], $file[1]);
2374  }
2375  }
2376  $this->object->update();
2377  }
2378  $ilCtrl->redirectByClass("ilexportgui");
2379  }
2380 
2384  function downloadPDFFile()
2385  {
2386  if(!isset($_POST["file"]))
2387  {
2388  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2389  }
2390 
2391  if (count($_POST["file"]) > 1)
2392  {
2393  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2394  }
2395 
2396 
2397  $export_dir = $this->object->getOfflineDirectory();
2398  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
2399  $_POST["file"][0]);
2400  }
2401 
2402 
2407  function fixTreeConfirm()
2408  {
2409  $this->setTabs();
2410 
2411  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm.html");
2412 
2413  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2414 
2415  //
2416  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirmation"));
2417  $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("cont_fix_tree_confirm"));
2418  $this->tpl->setVariable("CMD_CANCEL", "cancelFixTree");
2419  $this->tpl->setVariable("CMD_OK", "fixTree");
2420  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2421  $this->tpl->setVariable("TXT_OK", $this->lng->txt("cont_fix_tree"));
2422  }
2423 
2429  function cancelObject($in_rep = false)
2430  {
2431  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
2432  //$this->ctrl->redirectByClass("ilrepositorygui", "frameset");
2433  }
2434 
2438  function cancelFixTree()
2439  {
2440  $this->ctrl->redirect($this, "properties");
2441  }
2442 
2446  function fixTree()
2447  {
2448  $this->object->fixTree();
2449  ilUtil::sendSuccess($this->lng->txt("cont_tree_fixed"), true);
2450  $this->ctrl->redirect($this, "properties");
2451  }
2452 
2456  function setilLMMenu($a_offline = false, $a_export_format = "",
2457  $a_active = "content", $a_use_global_tabs = false, $a_as_subtabs = false,
2458  $a_cur_page = 0)
2459  {
2460  global $ilCtrl,$ilUser, $ilAccess, $ilTabs, $rbacsystem, $ilPluginAdmin;
2461 
2462 
2463  if ($a_as_subtabs)
2464  {
2465  $addcmd = "addSubTabTarget";
2466  $getcmd = "getSubTabHTML";
2467  }
2468  else
2469  {
2470  $addcmd = "addTarget";
2471  $getcmd = "getHTML";
2472  }
2473 
2474  $active[$a_active] = true;
2475 
2476  if (!$this->object->isActiveLMMenu())
2477  {
2478  return "";
2479  }
2480 
2481  if ($a_use_global_tabs)
2482  {
2483  $tabs_gui = $ilTabs;
2484  }
2485  else
2486  {
2487  $tabs_gui = new ilTabsGUI();
2488  }
2489 
2490  // Determine whether the view of a learning resource should
2491  // be shown in the frameset of ilias, or in a separate window.
2492  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
2493  $showViewInFrameset = true;
2494 
2495  if ($showViewInFrameset && !$a_offline)
2496  {
2497  $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
2498  }
2499  else
2500  {
2501  $buttonTarget = "_top";
2502  }
2503 
2504  if ($a_export_format == "scorm")
2505  {
2506  $buttonTarget = "";
2507  }
2508 
2509  $requires_purchase_to_access = ilPaymentObject::_requiresPurchaseToAccess((int)$_GET['ref_id']);
2510 
2511  // content
2512  if (!$a_offline && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2513  {
2514  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2515  $tabs_gui->$addcmd("content",
2516  $ilCtrl->getLinkTargetByClass("illmpresentationgui", "layout"),
2517  "", "", $buttonTarget, $active["content"]);
2518  }
2519 
2520  // table of contents
2521  if (!$requires_purchase_to_access && $this->object->isActiveTOC() && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2522  {
2523  if (!$a_offline)
2524  {
2525  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2526  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showTableOfContents");
2527  }
2528  else
2529  {
2530  $link = "./table_of_contents.html";
2531  }
2532 
2533  $tabs_gui->$addcmd("cont_toc", $link,
2534  "", "", $buttonTarget, $active["toc"]);
2535  }
2536 
2537  // print view
2538  if (!$requires_purchase_to_access && $this->object->isActivePrintView() && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2539  {
2540  if (!$a_offline) // has to be implemented for offline mode
2541  {
2542  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2543  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showPrintViewSelection");
2544  $tabs_gui->$addcmd("cont_print_view", $link,
2545  "", "", $buttonTarget, $active["print"]);
2546  }
2547  }
2548 
2549  // download
2550  if (!$requires_purchase_to_access && $ilUser->getId() == ANONYMOUS_USER_ID)
2551  {
2552  $is_public = $this->object->isActiveDownloadsPublic();
2553  }
2554  else if(!$requires_purchase_to_access)
2555  {
2556  $is_public = true;
2557  }
2558 
2559  if (!$requires_purchase_to_access && $this->object->isActiveDownloads() && !$a_offline && $is_public &&
2560  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2561  {
2562  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2563  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showDownloadList");
2564  $tabs_gui->$addcmd("download", $link,
2565  "", "", $buttonTarget, $active["download"]);
2566  }
2567 
2568  // info button
2569  if ($a_export_format != "scorm" && !$a_offline)
2570  {
2571  if (!$a_offline)
2572  {
2573  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2574  $link = $this->ctrl->getLinkTargetByClass(
2575  array("illmpresentationgui", "ilinfoscreengui"), "showSummary");
2576  }
2577  else
2578  {
2579  $link = "./info.html";
2580  }
2581 
2582  $tabs_gui->$addcmd(($requires_purchase_to_access ? 'buy' : 'info_short'), $link,
2583  "", "", $buttonTarget, $active["info"]);
2584  }
2585 
2586  // edit learning module
2587  if (!$a_offline && $a_cur_page > 0)
2588  {
2589  if ($rbacsystem->checkAccess("write", $_GET["ref_id"]))
2590  {
2591  //$page_id = $this->getCurrentPageId();
2592  $page_id = $a_cur_page;
2593  $tabs_gui->$addcmd("edit_page", ILIAS_HTTP_PATH."/ilias.php?baseClass=ilLMEditorGUI&ref_id=".$_GET["ref_id"].
2594  "&obj_id=".$page_id."&to_page=1",
2595  "", "", $buttonTarget, $active["edit_page"]);
2596  }
2597  }
2598 
2599  if(!$requires_purchase_to_access)
2600  {
2601  // get user defined menu entries
2602  $this->__initLMMenuEditor();
2603  $entries = $this->lmme_obj->getMenuEntries(true);
2604 
2605  if (count($entries) > 0 && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2606  {
2607  foreach ($entries as $entry)
2608  {
2609  // build goto-link for internal resources
2610  if ($entry["type"] == "intern")
2611  {
2612  $entry["link"] = ILIAS_HTTP_PATH."/goto.php?target=".$entry["link"];
2613  }
2614 
2615  // add http:// prefix if not exist
2616  if (!strstr($entry["link"],'://') && !strstr($entry["link"],'mailto:'))
2617  {
2618  $entry["link"] = "http://".$entry["link"];
2619  }
2620 
2621  if (!strstr($entry["link"],'mailto:'))
2622  {
2623  $entry["link"] = ilUtil::appendUrlParameterString($entry["link"], "ref_id=".$this->ref_id."&structure_id=".$this->obj_id);
2624  }
2625  $tabs_gui->$addcmd($entry["title"],
2626  $entry["link"],
2627  "", "", "_blank", "", true);
2628  }
2629  }
2630  }
2631 
2632  // user interface hook [uihk]
2633  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
2634  $plugin_html = false;
2635  foreach ($pl_names as $pl)
2636  {
2637  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
2638  $gui_class = $ui_plugin->getUIClassInstance();
2639  $resp = $gui_class->modifyGUI("Modules/LearningModule", "lm_menu_tabs",
2640  array("lm_menu_tabs" => $tabs_gui));
2641  }
2642 
2643 
2644  return $tabs_gui->$getcmd();
2645  }
2646 
2650  function createPDF()
2651  {
2652  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2653  $cont_exp = new ilContObjectExport($this->object, "pdf");
2654  $cont_exp->buildExportFile();
2655  $this->offlineList();
2656  }
2657 
2661  function exportHTML()
2662  {
2663  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2664  $cont_exp = new ilContObjectExport($this->object, "html");
2665  $cont_exp->buildExportFile();
2666 //echo $this->tpl->get();
2667 // $this->ctrl->redirect($this, "exportList");
2668  }
2669 
2673  function exportSCORM()
2674  {
2675  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2676  $cont_exp = new ilContObjectExport($this->object, "scorm");
2677  $cont_exp->buildExportFile();
2678 //echo $this->tpl->get();
2679 // $this->ctrl->redirect($this, "exportList");
2680  }
2681 
2687  function addLocations($a_omit_obj_id = false)
2688  {
2689  global $lng, $tree, $ilLocator;
2690 
2691  //$ilLocator->clearItems();
2692 
2693  $this->ctrl->addLocation(
2694  "...",
2695  "");
2696 
2697  $par_id = $tree->getParentId($_GET["ref_id"]);
2698  $this->ctrl->addLocation(
2700  "repository.php?cmd=frameset&amp;ref_id=".$par_id,
2701  ilFrameTargetInfo::_getFrame("MainContent"), $par_id);
2702  if (!$a_omit_obj_id)
2703  {
2704  $obj_id = $_GET["obj_id"];
2705  }
2706  $lmtree =& $this->object->getTree();
2707 
2708  if (($obj_id != 0) && $lmtree->isInTree($obj_id))
2709  {
2710  $path = $lmtree->getPathFull($obj_id);
2711  }
2712  else
2713  {
2714  $path = $lmtree->getPathFull($lmtree->getRootId());
2715  if ($obj_id != 0)
2716  {
2717  $path[] = array("type" => "pg", "child" => $this->obj_id,
2718  "title" => ilLMPageObject::_getPresentationTitle($this->obj_id));
2719  }
2720  }
2721 
2722  $modifier = 1;
2723 
2724  foreach ($path as $key => $row)
2725  {
2726  if ($row["child"] == 1)
2727  {
2728  $this->ctrl->setParameter($this, "obj_id", "");
2729  $this->ctrl->addLocation(
2730  $this->object->getTitle(),
2731  $this->ctrl->getLinkTarget($this, "chapters"), "", $_GET["ref_id"]);
2732  }
2733  else
2734  {
2735  $title = $row["title"];
2736  switch($row["type"])
2737  {
2738  case "st":
2739  $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $row["child"]);
2740  $this->ctrl->addLocation(
2741  $title,
2742  $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view"));
2743  break;
2744 
2745  case "pg":
2746  $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $row["child"]);
2747  $this->ctrl->addLocation(
2748  $title,
2749  $this->ctrl->getLinkTargetByClass("illmpageobjectgui", "edit"));
2750  break;
2751  }
2752  }
2753  }
2754  if (!$a_omit_obj_id)
2755  {
2756  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
2757  }
2758  }
2759 
2763 
2764 
2771  function listQuestions()
2772  {
2773  global $tpl;
2774 
2775  $this->setTabs();
2776 
2777  include_once("./Modules/LearningModule/classes/class.ilLMQuestionListTableGUI.php");
2778  $table = new ilLMQuestionListTableGUI($this, "listQuestions", $this->object);
2779  $tpl->setContent($table->getHTML());
2780 
2781  }
2782 
2786 
2787 
2791  function setTabs()
2792  {
2793  // catch feedback message
2794  #include_once("classes/class.ilTabsGUI.php");
2795  #$tabs_gui =& new ilTabsGUI();
2796  $this->getTabs($this->tabs_gui);
2797  $this->tpl->setCurrentBlock("header_image");
2798  $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm_b.gif"));
2799  $this->tpl->parseCurrentBlock();
2800  $this->tpl->setCurrentBlock("content");
2801  #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
2802  $this->tpl->setVariable("HEADER", $this->object->getTitle());
2803  }
2804 
2811  function setLinkSubTabs($a_active)
2812  {
2813  global $ilTabs, $lng, $ilCtrl;
2814 
2815  $ilTabs->addSubtab("internal_links",
2816  $lng->txt("cont_internal_links"),
2817  $ilCtrl->getLinkTarget($this, "listLinks"));
2818 
2819  if ($this->object->getType() == "lm")
2820  {
2821  if(@include_once('HTTP/Request.php'))
2822  {
2823  $ilTabs->addSubtab("link_check",
2824  $lng->txt("link_check"),
2825  $ilCtrl->getLinkTarget($this, "linkChecker"));
2826  }
2827  }
2828 
2829  $ilTabs->activateSubTab($a_active);
2830  $ilTabs->activateTab("cont_links");
2831  }
2832 
2833 
2839  function getTabs(&$tabs_gui)
2840  {
2841  global $rbacsystem,$ilUser;
2842 
2843  // back to upper context
2844  //$tabs_gui->getTargetsByObjectType($this, $this->object->getType());
2845 
2846  // chapters
2847  $tabs_gui->addTarget("cont_chapters",
2848  $this->ctrl->getLinkTarget($this, "chapters"),
2849  "chapters", get_class($this));
2850 
2851  // pages
2852  $tabs_gui->addTarget("cont_all_pages",
2853  $this->ctrl->getLinkTarget($this, "pages"),
2854  "pages", get_class($this));
2855 
2856  // questions
2857  $tabs_gui->addTarget("objs_qst",
2858  $this->ctrl->getLinkTarget($this, "listQuestions"),
2859  "listQuestions", get_class($this));
2860 
2861  // info
2862  $tabs_gui->addTarget("info_short",
2863  $this->ctrl->getLinkTargetByClass("ilinfoscreengui",'showSummary'),
2864  "", "ilinfoscreengui");
2865 
2866  // properties
2867  $tabs_gui->addTarget("settings",
2868  $this->ctrl->getLinkTarget($this,'properties'),
2869  "properties", get_class($this));
2870 
2871  // learning progress
2872  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
2873  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()) and ($this->object->getType() == 'lm' or $this->object->getType() == 'dbk'))
2874  {
2875  $tabs_gui->addTarget('learning_progress',
2876  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
2877  '',
2878  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui','illmstatisticsgui'));
2879  }
2880 
2881  // links
2882  $tabs_gui->addTarget("cont_links",
2883  $this->ctrl->getLinkTarget($this,'listLinks'),
2884  "listLinks", get_class($this));
2885 
2886  if ($this->object->getType() != "lm")
2887  {
2888  // bibliographical data
2889  $tabs_gui->addTarget("bib_data",
2890  $this->ctrl->getLinkTarget($this, "editBibItem"),
2891  "editBibItem", get_class($this));
2892  }
2893 
2894  $tabs_gui->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
2895  , "history", get_class($this));
2896 
2897  $tabs_gui->addTarget("meta_data",
2898  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
2899  "", "ilmdeditorgui");
2900 
2901  if ($this->object->getType() == "lm")
2902  {
2903  // export
2904  $tabs_gui->addTarget("export",
2905  $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
2906  "", "ilexportgui");
2907  }
2908 
2909  // permissions
2910  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
2911  {
2912  $tabs_gui->addTarget("perm_settings",
2913  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
2914  }
2915  }
2916 
2920  function setSubTabs($a_active)
2921  {
2922  global $ilTabs, $ilSetting;
2923 
2924  if (in_array($a_active,
2925  array("cont_general_properties", "cont_style", "cont_lm_menu", "public_section")))
2926  {
2927  // general properties
2928  $ilTabs->addSubTabTarget("cont_general_properties",
2929  $this->ctrl->getLinkTarget($this, 'properties'),
2930  "", "");
2931 
2932  // style properties
2933  $ilTabs->addSubTabTarget("cont_style",
2934  $this->ctrl->getLinkTarget($this, 'editStyleProperties'),
2935  "", "");
2936 
2937  // menu properties
2938  $ilTabs->addSubTabTarget("cont_lm_menu",
2939  $this->ctrl->getLinkTarget($this, 'editMenuProperties'),
2940  "", "");
2941 
2942  if ($ilSetting->get("pub_section"))
2943  {
2944  if ($this->object->getType() != "dbk")
2945  {
2946  // public section
2947  $ilTabs->addSubTabTarget("public_section",
2948  $this->ctrl->getLinkTarget($this, 'editPublicSection'),
2949  "", "");
2950  }
2951  }
2952 
2953  $ilTabs->setSubTabActive($a_active);
2954  }
2955  }
2956 
2958  {
2959  global $ilTabs;
2960 
2961  $this->setTabs();
2962  $this->setSubTabs("public_section");
2963  $ilTabs->setTabActive("settings");
2964 
2965  switch ($this->object->getType())
2966  {
2967  case "lm":
2968  $gui_class = "ilobjlearningmodulegui";
2969  break;
2970 
2971  case "dlb":
2972  $gui_class = "ilobjdlbookgui";
2973  break;
2974  }
2975 
2976  // get learning module object
2977  $this->lm_obj =& new ilObjLearningModule($this->ref_id, true);
2978 
2979  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_public_selector.html");
2980  //$this->tpl->setVariable("ADM_CONTENT", "adm_content", "bla");
2981 
2982  require_once ("./Modules/LearningModule/classes/class.ilPublicSectionSelector.php");
2983  $exp = new ilPublicSectionSelector($this->ctrl->getLinkTarget($this, "view"),
2984  $this->object, $gui_class);
2985 
2986  $exp->setTargetGet("obj_id");
2987 
2988  // build html-output
2989  $exp->setOutput(0);
2990  $output = $exp->getOutput();
2991 
2992  // get page ids
2993  foreach ($exp->format_options as $node)
2994  {
2995  if (!$node["container"])
2996  {
2997  $pages[] = $node["child"];
2998  }
2999  }
3000 
3001  $js_pages = ilUtil::array_php2js($pages);
3002 
3003  //$this->tpl->setCurrentBlock("content");
3004  //var_dump($this->object->getPublicAccessMode());
3005  // access mode selector
3006  $this->tpl->setVariable("TXT_SET_PUBLIC_MODE", $this->lng->txt("set_public_mode"));
3007  $this->tpl->setVariable("TXT_CHOOSE_PUBLIC_MODE", $this->lng->txt("choose_public_mode"));
3008  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
3009  $select_public_mode = ilUtil::formSelect ($this->object->getPublicAccessMode(),"lm_public_mode",$modes, false, true);
3010  $this->tpl->setVariable("SELECT_PUBLIC_MODE", $select_public_mode);
3011 
3012  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("choose_public_pages"));
3013  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
3014  $this->tpl->setVariable("EXPLORER",$output);
3015  $this->tpl->setVariable("ONCLICK",$js_pages);
3016  $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
3017  $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
3018  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3019  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
3020  //$this->tpl->parseCurrentBlock();
3021 
3022  }
3023 
3025  {
3026  //var_dump($_POST["lm_public_mode"]);exit;
3027  $this->object->setPublicAccessMode($_POST["lm_public_mode"]);
3028  $this->object->updateProperties();
3029  ilLMObject::_writePublicAccessStatus($_POST["pages"],$this->object->getId());
3030  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3031  $this->ctrl->redirect($this, "editPublicSection");
3032  }
3033 
3039  function history()
3040  {
3041  $this->setTabs();
3042 
3043  require_once("classes/class.ilHistoryGUI.php");
3044  $hist_gui =& new ilHistoryGUI($this->object->getId() ,
3045  $this->object->getType());
3046  $hist_html = $hist_gui->getHistoryTable(
3047  $this->ctrl->getParameterArray($this, "history"),
3048  $this->object->isActiveHistoryUserComments()
3049  );
3050 
3051  $this->tpl->setVariable("ADM_CONTENT", $hist_html);
3052  }
3053 
3062  public function formatInvalidLinkArray(Array $row)
3063  {
3064  $row['title'] = ilLMPageObject::_getPresentationTitle($row['page_id'], $this->object->getPageHeader());
3065 
3066  require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
3068  $actions->setSelectionHeaderClass('small');
3069  $actions->setItemLinkClass('xsmall');
3070  $actions->setListTitle($this->lng->txt('actions'));
3071  $actions->setId($row['page_id']);
3072  $this->ctrl->setParameterByClass('ilLMPageObjectGUI', 'obj_id', $row['page_id']);
3073  $actions->addItem(
3074  $this->lng->txt('edit'),
3075  '',
3076  $this->ctrl->getLinkTargetByClass('ilLMPageObjectGUI', 'edit')
3077  );
3078  $this->ctrl->clearParametersByClass('ilLMPageObjectGUI');
3079  $row['action_html'] = $actions->getHTML();
3080 
3081  return $row;
3082  }
3083 
3084  function linkChecker()
3085  {
3086  global $ilias, $ilUser, $tpl;
3087 
3088  $this->__initLinkChecker();
3089 
3090  $this->setTabs();
3091  $this->setLinkSubTabs("link_check");
3092 
3093  require_once 'Services/LinkChecker/classes/class.ilLinkCheckerTableGUI.php';
3094 
3095  $toolbar = new ilToolbarGUI();
3096 
3097  if((bool)$ilias->getSetting('cron_web_resource_check'))
3098  {
3099  include_once 'classes/class.ilLinkCheckNotify.php';
3100  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
3101 
3102  $chb = new ilCheckboxInputGUI($this->lng->txt('link_check_message_a'), 'link_check_message');
3103  $chb->setValue(1);
3104  $chb->setChecked((bool)ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(),$this->object->getId()));
3105  $chb->setOptionTitle($this->lng->txt('link_check_message_b'));
3106 
3107  $toolbar->addInputItem($chb);
3108  $toolbar->addFormButton($this->lng->txt('save'), 'saveLinkCheck');
3109  $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'saveLinkCheck'));
3110  }
3111 
3112  $tgui = new ilLinkCheckerTableGUI($this, 'linkChecker');
3113  $tgui->setLinkChecker($this->link_checker_obj)
3114  ->setRowHandler($this)
3115  ->setRefreshButton($this->lng->txt('refresh'), 'refreshLinkCheck');
3116 
3117  return $tpl->setContent($tgui->prepareHTML()->getHTML().$toolbar->getHTML());
3118  }
3119 
3120  function saveLinkCheck()
3121  {
3122  global $ilDB,$ilUser;
3123 
3124  include_once './classes/class.ilLinkCheckNotify.php';
3125 
3126  $link_check_notify =& new ilLinkCheckNotify($ilDB);
3127  $link_check_notify->setUserId($ilUser->getId());
3128  $link_check_notify->setObjId($this->object->getId());
3129 
3130  if($_POST['link_check_message'])
3131  {
3132  ilUtil::sendSuccess($this->lng->txt('link_check_message_enabled'));
3133  $link_check_notify->addNotifier();
3134  }
3135  else
3136  {
3137  ilUtil::sendSuccess($this->lng->txt('link_check_message_disabled'));
3138  $link_check_notify->deleteNotifier();
3139  }
3140  $this->linkChecker();
3141 
3142  return true;
3143  }
3144 
3145 
3146 
3147  function refreshLinkCheck()
3148  {
3149  $this->__initLinkChecker();
3150 
3151  if(!$this->link_checker_obj->checkPear())
3152  {
3153  ilUtil::sendFailure($this->lng->txt('missing_pear_library'));
3154  $this->linkChecker();
3155 
3156  return false;
3157  }
3158 
3159  $this->link_checker_obj->checkLinks();
3160  ilUtil::sendSuccess($this->lng->txt('link_checker_refreshed'));
3161 
3162  $this->linkChecker();
3163 
3164  return true;
3165  }
3166 
3168  {
3169  global $ilDB;
3170 
3171  include_once './classes/class.ilLinkChecker.php';
3172 
3173  $this->link_checker_obj =& new ilLinkChecker($ilDB,false);
3174  $this->link_checker_obj->setObjId($this->object->getId());
3175 
3176  return true;
3177  }
3178 
3180  {
3181  include_once './Modules/LearningModule/classes/class.ilLMMenuEditor.php';
3182 
3183  $this->lmme_obj =& new ilLMMenuEditor();
3184  $this->lmme_obj->setObjId($this->object->getId());
3185 
3186  return true;
3187  }
3188 
3192  function addMenuEntry()
3193  {
3194  $this->setTabs();
3195 
3196  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_entry_form.html","Modules/LearningModule");
3197 
3198  if (isset($_GET["link_ref_id"]))
3199  {
3200  $obj_type = ilObject::_lookupType($_GET["link_ref_id"],true);
3201  $obj_id = ilObject::_lookupObjectId($_GET["link_ref_id"]);
3203 
3204  $target_link = $obj_type."_".$_GET["link_ref_id"];
3205  $this->tpl->setVariable("TITLE", $title);
3206  $this->tpl->setVariable("TARGET", $target_link);
3207  $this->tpl->setVariable("LINK_REF_ID", $_GET["link_ref_id"]);
3208  }
3209 
3210 
3211  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "saveMenuEntry"));
3212  $this->tpl->setVariable("TXT_NEW_ENTRY", $this->lng->txt("lm_menu_new_entry"));
3213  $this->tpl->setVariable("TXT_TARGET", $this->lng->txt("lm_menu_entry_target"));
3214  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("lm_menu_entry_title"));
3215  $this->tpl->setVariable("BTN_NAME", "saveMenuEntry");
3216  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
3217  $this->tpl->setVariable("BTN_NAME2", "showEntrySelector");
3218  $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("lm_menu_select_internal_object"));
3219  //$this->tpl->parseCurrentBlock();
3220 
3221  }
3222 
3226  function saveMenuEntry()
3227  {
3228  global $ilCtrl;
3229 
3230  // check title and target
3231  if (empty($_POST["title"]))
3232  {
3233  //$this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
3234  ilUtil::sendFailure($this->lng->txt("please_enter_title") , true);
3235  $ilCtrl->redirect($this, "addMenuEntry");
3236  }
3237  if (empty($_POST["target"]))
3238  {
3239  //$this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
3240  ilUtil::sendFailure($this->lng->txt("please_enter_target"), true);
3241  $ilCtrl->redirect($this, "addMenuEntry");
3242  }
3243 
3244  $this->__initLMMenuEditor();
3245  $this->lmme_obj->setTitle($_POST["title"]);
3246  $this->lmme_obj->setTarget($_POST["target"]);
3247  $this->lmme_obj->setLinkRefId($_POST["link_ref_id"]);
3248 
3249  if ($_POST["link_ref_id"])
3250  {
3251  $this->lmme_obj->setLinkType("intern");
3252  }
3253 
3254  $this->lmme_obj->create();
3255 
3256  ilUtil::sendSuccess($this->lng->txt("msg_entry_added"), true);
3257  $this->ctrl->redirect($this, "editMenuProperties");
3258  }
3259 
3263  function deleteMenuEntry()
3264  {
3265  if (empty($_GET["menu_entry"]))
3266  {
3267  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3268  }
3269 
3270  $this->__initLMMenuEditor();
3271  $this->lmme_obj->delete($_GET["menu_entry"]);
3272 
3273  ilUtil::sendSuccess($this->lng->txt("msg_entry_removed"), true);
3274  $this->ctrl->redirect($this, "editMenuProperties");
3275  }
3276 
3280  function editMenuEntry()
3281  {
3282  if (empty($_GET["menu_entry"]))
3283  {
3284  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3285  }
3286 
3287  $this->__initLMMenuEditor();
3288  $this->lmme_obj->readEntry($_GET["menu_entry"]);
3289 
3290  $this->setTabs();
3291 
3292  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_entry_form.html","Modules/LearningModule");
3293 
3294  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
3295  $this->tpl->setVariable("TXT_NEW_ENTRY", $this->lng->txt("lm_menu_edit_entry"));
3296  $this->tpl->setVariable("TXT_TARGET", $this->lng->txt("lm_menu_entry_target"));
3297  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("lm_menu_entry_title"));
3298  $this->tpl->setVariable("TITLE", $this->lmme_obj->getTitle());
3299  $this->tpl->setVariable("TARGET", $this->lmme_obj->getTarget());
3300  $this->tpl->setVariable("ENTRY_ID", $this->lmme_obj->getEntryId());
3301  $this->tpl->setVariable("BTN_NAME", "updateMenuEntry");
3302  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
3303  $this->tpl->setVariable("BTN_NAME2", "showEntrySelector");
3304  $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("lm_menu_select_internal_object"));
3305  //$this->tpl->parseCurrentBlock();
3306  }
3307 
3311  function updateMenuEntry()
3312  {
3313  if (empty($_POST["menu_entry"]))
3314  {
3315  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3316  }
3317 
3318  // check title and target
3319  if (empty($_POST["title"]))
3320  {
3321  $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
3322  }
3323  if (empty($_POST["target"]))
3324  {
3325  $this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
3326  }
3327 
3328  $this->__initLMMenuEditor();
3329  $this->lmme_obj->readEntry($_POST["menu_entry"]);
3330  $this->lmme_obj->setTitle($_POST["title"]);
3331  $this->lmme_obj->setTarget($_POST["target"]);
3332  $this->lmme_obj->update();
3333 
3334  ilUtil::sendSuccess($this->lng->txt("msg_entry_updated"), true);
3335  $this->ctrl->redirect($this, "editMenuProperties");
3336  }
3337 
3339  {
3340  $this->setTabs();
3341 
3342  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_object_selector.html","Modules/LearningModule");
3343 
3344  ilUtil::sendInfo($this->lng->txt("lm_menu_select_object_to_add"));
3345 
3346  require_once ("./Modules/LearningModule/classes/class.ilLMMenuObjectSelector.php");
3347  $exp = new ilLMMenuObjectSelector($this->ctrl->getLinkTarget($this,'test'),$this);
3348 
3349  $exp->setExpand($_GET["lm_menu_expand"] ? $_GET["lm_menu_expand"] : $this->tree->readRootId());
3350  $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showEntrySelector'));
3351  $exp->setTargetGet("ref_id");
3352  $exp->setRefId($this->cur_ref_id);
3353 
3354  $sel_types = array('mcst', 'mep', 'cat', 'lm','dbk','glo','exc','tst','svy', 'sahs',
3355  "crs", "grp", "book", "tst", "file");
3356  $exp->setSelectableTypes($sel_types);
3357 
3358  //$exp->setTargetGet("obj_id");
3359 
3360  // build html-output
3361  $exp->setOutput(0);
3362  $output = $exp->getOutput();
3363 
3364  // get page ids
3365  foreach ($exp->format_options as $node)
3366  {
3367  if (!$node["container"])
3368  {
3369  $pages[] = $node["child"];
3370  }
3371  }
3372 
3373  //$this->tpl->setCurrentBlock("content");
3374  //var_dump($this->object->getPublicAccessMode());
3375  // access mode selector
3376  $this->tpl->setVariable("TXT_SET_PUBLIC_MODE", $this->lng->txt("set_public_mode"));
3377  $this->tpl->setVariable("TXT_CHOOSE_PUBLIC_MODE", $this->lng->txt("choose_public_mode"));
3378  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
3379  $select_public_mode = ilUtil::formSelect ($this->object->getPublicAccessMode(),"lm_public_mode",$modes, false, true);
3380  $this->tpl->setVariable("SELECT_PUBLIC_MODE", $select_public_mode);
3381 
3382  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("choose_public_pages"));
3383  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
3384  $this->tpl->setVariable("EXPLORER",$output);
3385  $this->tpl->setVariable("ONCLICK",$js_pages);
3386  $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
3387  $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
3388  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3389  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
3390  //$this->tpl->parseCurrentBlock();
3391  }
3392 
3396  function selectHeader()
3397  {
3398  if(!isset($_POST["id"]))
3399  {
3400  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3401  }
3402  if(count($_POST["id"]) > 1)
3403  {
3404  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3405  }
3406  if ($_POST["id"][0] != $this->object->getHeaderPage())
3407  {
3408  $this->object->setHeaderPage($_POST["id"][0]);
3409  }
3410  else
3411  {
3412  $this->object->setHeaderPage(0);
3413  }
3414  $this->object->updateProperties();
3415  $this->ctrl->redirect($this, "pages");
3416  }
3417 
3421  function selectFooter()
3422  {
3423  if(!isset($_POST["id"]))
3424  {
3425  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3426  }
3427  if(count($_POST["id"]) > 1)
3428  {
3429  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3430  }
3431  if ($_POST["id"][0] != $this->object->getFooterPage())
3432  {
3433  $this->object->setFooterPage($_POST["id"][0]);
3434  }
3435  else
3436  {
3437  $this->object->setFooterPage(0);
3438  }
3439  $this->object->updateProperties();
3440  $this->ctrl->redirect($this, "pages");
3441  }
3442 
3446  function saveAllTitles()
3447  {
3448  global $ilCtrl;
3449 
3450  ilLMObject::saveTitles($this->object, ilUtil::stripSlashesArray($_POST["title"]));
3451 
3452  $ilCtrl->redirect($this, "chapters");
3453  }
3454 
3458  function insertChapter()
3459  {
3460  global $ilCtrl, $lng;
3461 
3462  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
3463 
3466 
3467  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
3468  {
3469  $parent_id = $this->lm_tree->getParentId($node_id);
3470  $target = $node_id;
3471  }
3472  else // insert as first child
3473  {
3474  $parent_id = $node_id;
3475  $target = IL_FIRST_NODE;
3476  }
3477 
3478  for ($i = 1; $i <= $num; $i++)
3479  {
3480  $chap = new ilStructureObject($this->object);
3481  $chap->setType("st");
3482  $chap->setTitle($lng->txt("cont_new_chap"));
3483  $chap->setLMId($this->object->getId());
3484  $chap->create();
3485  ilLMObject::putInTree($chap, $parent_id, $target);
3486  }
3487 
3488  $ilCtrl->redirect($this, "chapters");
3489  }
3490 
3495  {
3496  global $ilUser, $ilCtrl, $ilLog;
3497 
3498  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
3499 
3500  if ($ilUser->getPref("lm_js_chapter_editing") != "disable")
3501  {
3502  //$num = ilChapterHierarchyFormGUI::getPostMulti();
3505  }
3506  else
3507  {
3508  if (!isset($_POST["id"]) || $_POST["id"][0] == -1)
3509  {
3510  $node_id = $this->lm_tree->getRootId();
3511  $first_child = true;
3512  }
3513  else
3514  {
3515  $node_id = $_POST["id"][0];
3516  $first_child = false;
3517  }
3518  }
3519 
3520  $ilLog->write("InsertChapterClip, num: $num, node_id: $node_id, ".
3521  " getPostFirstChild ".ilChapterHierarchyFormGUI::getPostFirstChild());
3522 
3523  if (!$first_child) // insert after node id
3524  {
3525  $parent_id = $this->lm_tree->getParentId($node_id);
3526  $target = $node_id;
3527  }
3528  else // insert as first child
3529  {
3530  $parent_id = $node_id;
3531  $target = IL_FIRST_NODE;
3532  }
3533 
3534  // copy and paste
3535  $chapters = $ilUser->getClipboardObjects("st", true);
3536  $copied_nodes = array();
3537  foreach ($chapters as $chap)
3538  {
3539  $ilLog->write("Call pasteTree, Target LM: ".$this->object->getId().", Chapter ID: ".$chap["id"]
3540  .", Parent ID: ".$parent_id.", Target: ".$target);
3541  $cid = ilLMObject::pasteTree($this->object, $chap["id"], $parent_id,
3542  $target, $chap["insert_time"], $copied_nodes,
3543  (ilEditClipboard::getAction() == "copy"));
3544  $target = $cid;
3545  }
3546  ilLMObject::updateInternalLinks($copied_nodes);
3547 
3548  if (ilEditClipboard::getAction() == "cut")
3549  {
3550  $ilUser->clipboardDeleteObjectsOfType("pg");
3551  $ilUser->clipboardDeleteObjectsOfType("st");
3553  }
3554 
3555  $this->object->checkTree();
3556  $ilCtrl->redirect($this, "chapters");
3557  }
3558 
3564  function _goto($a_target)
3565  {
3566  global $ilAccess, $ilErr, $lng;
3567 
3568  if ($ilAccess->checkAccess("read", "", $a_target))
3569  {
3570  $_GET["baseClass"] = "ilLMPresentationGUI";
3571  $_GET["ref_id"] = $a_target;
3572  include("ilias.php");
3573  exit;
3574  } else if ($ilAccess->checkAccess("visible", "", $a_target))
3575  {
3576  $_GET["baseClass"] = "ilLMPresentationGUI";
3577  $_GET["ref_id"] = $a_target;
3578  $_GET["cmd"] = "infoScreen";
3579  include("ilias.php");
3580  exit;
3581  }
3582  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
3583  {
3584  $_GET["cmd"] = "frameset";
3585  $_GET["target"] = "";
3586  $_GET["ref_id"] = ROOT_FOLDER_ID;
3587  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
3588  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
3589  include("repository.php");
3590  exit;
3591  }
3592 
3593 
3594  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
3595  }
3596 
3600  function cutItems($a_return = "chapters")
3601  {
3602  global $ilCtrl, $lng;
3603 
3604  $items = ilUtil::stripSlashesArray($_POST["id"]);
3605  if (!is_array($items))
3606  {
3607  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3608  $ilCtrl->redirect($this, $a_return);
3609  }
3610 
3611  $todel = array(); // delete IDs < 0 (needed for non-js editing)
3612  foreach($items as $k => $item)
3613  {
3614  if ($item < 0)
3615  {
3616  $todel[] = $k;
3617  }
3618  }
3619  foreach($todel as $k)
3620  {
3621  unset($items[$k]);
3622  }
3623  ilLMObject::clipboardCut($this->object->getId(), $items);
3625  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
3626 
3627  $ilCtrl->redirect($this, $a_return);
3628  }
3629 
3633  function copyItems()
3634  {
3635  global $ilCtrl, $lng;
3636 
3637  $items = ilUtil::stripSlashesArray($_POST["id"]);
3638  if (!is_array($items))
3639  {
3640  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3641  $ilCtrl->redirect($this, "chapters");
3642  }
3643 
3644  $todel = array(); // delete IDs < 0 (needed for non-js editing)
3645  foreach($items as $k => $item)
3646  {
3647  if ($item < 0)
3648  {
3649  $todel[] = $k;
3650  }
3651  }
3652  foreach($todel as $k)
3653  {
3654  unset($items[$k]);
3655  }
3656  ilLMObject::clipboardCopy($this->object->getId(), $items);
3658  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
3659  $ilCtrl->redirect($this, "chapters");
3660  }
3661 
3665  function cutChapter()
3666  {
3667  $this->cutItems("chapters");
3668  }
3669 
3670 } // END class.ilObjContentObjectGUI
3671 ?>