ILIAS  Release_4_1_x_branch Revision 61804
 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 = false;
2510  if(IS_PAYMENT_ENABLED)
2511  {
2512  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
2513  $requires_purchase_to_access = ilPaymentObject::_requiresPurchaseToAccess((int)$_GET['ref_id']);
2514  }
2515 
2516  // content
2517  if (!$a_offline && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2518  {
2519  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2520  $tabs_gui->$addcmd("content",
2521  $ilCtrl->getLinkTargetByClass("illmpresentationgui", "layout"),
2522  "", "", $buttonTarget, $active["content"]);
2523  }
2524 
2525  // table of contents
2526  if (!$requires_purchase_to_access && $this->object->isActiveTOC() && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2527  {
2528  if (!$a_offline)
2529  {
2530  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2531  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showTableOfContents");
2532  }
2533  else
2534  {
2535  $link = "./table_of_contents.html";
2536  }
2537 
2538  $tabs_gui->$addcmd("cont_toc", $link,
2539  "", "", $buttonTarget, $active["toc"]);
2540  }
2541 
2542  // print view
2543  if (!$requires_purchase_to_access && $this->object->isActivePrintView() && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2544  {
2545  if (!$a_offline) // has to be implemented for offline mode
2546  {
2547  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2548  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showPrintViewSelection");
2549  $tabs_gui->$addcmd("cont_print_view", $link,
2550  "", "", $buttonTarget, $active["print"]);
2551  }
2552  }
2553 
2554  // download
2555  if (!$requires_purchase_to_access && $ilUser->getId() == ANONYMOUS_USER_ID)
2556  {
2557  $is_public = $this->object->isActiveDownloadsPublic();
2558  }
2559  else if(!$requires_purchase_to_access)
2560  {
2561  $is_public = true;
2562  }
2563 
2564  if (!$requires_purchase_to_access && $this->object->isActiveDownloads() && !$a_offline && $is_public &&
2565  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2566  {
2567  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2568  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showDownloadList");
2569  $tabs_gui->$addcmd("download", $link,
2570  "", "", $buttonTarget, $active["download"]);
2571  }
2572 
2573  // info button
2574  if ($a_export_format != "scorm" && !$a_offline)
2575  {
2576  if (!$a_offline)
2577  {
2578  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2579  $link = $this->ctrl->getLinkTargetByClass(
2580  array("illmpresentationgui", "ilinfoscreengui"), "showSummary");
2581  }
2582  else
2583  {
2584  $link = "./info.html";
2585  }
2586 
2587  $tabs_gui->$addcmd(($requires_purchase_to_access ? 'buy' : 'info_short'), $link,
2588  "", "", $buttonTarget, $active["info"]);
2589  }
2590 
2591  // edit learning module
2592  if (!$a_offline && $a_cur_page > 0)
2593  {
2594  if ($rbacsystem->checkAccess("write", $_GET["ref_id"]))
2595  {
2596  //$page_id = $this->getCurrentPageId();
2597  $page_id = $a_cur_page;
2598  $tabs_gui->$addcmd("edit_page", ILIAS_HTTP_PATH."/ilias.php?baseClass=ilLMEditorGUI&ref_id=".$_GET["ref_id"].
2599  "&obj_id=".$page_id."&to_page=1",
2600  "", "", $buttonTarget, $active["edit_page"]);
2601  }
2602  }
2603 
2604  if(!$requires_purchase_to_access)
2605  {
2606  // get user defined menu entries
2607  $this->__initLMMenuEditor();
2608  $entries = $this->lmme_obj->getMenuEntries(true);
2609 
2610  if (count($entries) > 0 && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2611  {
2612  foreach ($entries as $entry)
2613  {
2614  // build goto-link for internal resources
2615  if ($entry["type"] == "intern")
2616  {
2617  $entry["link"] = ILIAS_HTTP_PATH."/goto.php?target=".$entry["link"];
2618  }
2619 
2620  // add http:// prefix if not exist
2621  if (!strstr($entry["link"],'://') && !strstr($entry["link"],'mailto:'))
2622  {
2623  $entry["link"] = "http://".$entry["link"];
2624  }
2625 
2626  if (!strstr($entry["link"],'mailto:'))
2627  {
2628  $entry["link"] = ilUtil::appendUrlParameterString($entry["link"], "ref_id=".$this->ref_id."&structure_id=".$this->obj_id);
2629  }
2630  $tabs_gui->$addcmd($entry["title"],
2631  $entry["link"],
2632  "", "", "_blank", "", true);
2633  }
2634  }
2635  }
2636 
2637  // user interface hook [uihk]
2638  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
2639  $plugin_html = false;
2640  foreach ($pl_names as $pl)
2641  {
2642  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
2643  $gui_class = $ui_plugin->getUIClassInstance();
2644  $resp = $gui_class->modifyGUI("Modules/LearningModule", "lm_menu_tabs",
2645  array("lm_menu_tabs" => $tabs_gui));
2646  }
2647 
2648 
2649  return $tabs_gui->$getcmd();
2650  }
2651 
2655  function createPDF()
2656  {
2657  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2658  $cont_exp = new ilContObjectExport($this->object, "pdf");
2659  $cont_exp->buildExportFile();
2660  $this->offlineList();
2661  }
2662 
2666  function exportHTML()
2667  {
2668  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2669  $cont_exp = new ilContObjectExport($this->object, "html");
2670  $cont_exp->buildExportFile();
2671 //echo $this->tpl->get();
2672 // $this->ctrl->redirect($this, "exportList");
2673  }
2674 
2678  function exportSCORM()
2679  {
2680  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2681  $cont_exp = new ilContObjectExport($this->object, "scorm");
2682  $cont_exp->buildExportFile();
2683 //echo $this->tpl->get();
2684 // $this->ctrl->redirect($this, "exportList");
2685  }
2686 
2692  function addLocations($a_omit_obj_id = false)
2693  {
2694  global $lng, $tree, $ilLocator;
2695 
2696  //$ilLocator->clearItems();
2697 
2698  $this->ctrl->addLocation(
2699  "...",
2700  "");
2701 
2702  $par_id = $tree->getParentId($_GET["ref_id"]);
2703  $this->ctrl->addLocation(
2705  "repository.php?cmd=frameset&amp;ref_id=".$par_id,
2706  ilFrameTargetInfo::_getFrame("MainContent"), $par_id);
2707  if (!$a_omit_obj_id)
2708  {
2709  $obj_id = $_GET["obj_id"];
2710  }
2711  $lmtree =& $this->object->getTree();
2712 
2713  if (($obj_id != 0) && $lmtree->isInTree($obj_id))
2714  {
2715  $path = $lmtree->getPathFull($obj_id);
2716  }
2717  else
2718  {
2719  $path = $lmtree->getPathFull($lmtree->getRootId());
2720  if ($obj_id != 0)
2721  {
2722  $path[] = array("type" => "pg", "child" => $this->obj_id,
2723  "title" => ilLMPageObject::_getPresentationTitle($this->obj_id));
2724  }
2725  }
2726 
2727  $modifier = 1;
2728 
2729  foreach ($path as $key => $row)
2730  {
2731  if ($row["child"] == 1)
2732  {
2733  $this->ctrl->setParameter($this, "obj_id", "");
2734  $this->ctrl->addLocation(
2735  $this->object->getTitle(),
2736  $this->ctrl->getLinkTarget($this, "chapters"), "", $_GET["ref_id"]);
2737  }
2738  else
2739  {
2740  $title = $row["title"];
2741  switch($row["type"])
2742  {
2743  case "st":
2744  $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $row["child"]);
2745  $this->ctrl->addLocation(
2746  $title,
2747  $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view"));
2748  break;
2749 
2750  case "pg":
2751  $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $row["child"]);
2752  $this->ctrl->addLocation(
2753  $title,
2754  $this->ctrl->getLinkTargetByClass("illmpageobjectgui", "edit"));
2755  break;
2756  }
2757  }
2758  }
2759  if (!$a_omit_obj_id)
2760  {
2761  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
2762  }
2763  }
2764 
2768 
2769 
2776  function listQuestions()
2777  {
2778  global $tpl;
2779 
2780  $this->setTabs();
2781 
2782  include_once("./Modules/LearningModule/classes/class.ilLMQuestionListTableGUI.php");
2783  $table = new ilLMQuestionListTableGUI($this, "listQuestions", $this->object);
2784  $tpl->setContent($table->getHTML());
2785 
2786  }
2787 
2791 
2792 
2796  function setTabs()
2797  {
2798  // catch feedback message
2799  #include_once("classes/class.ilTabsGUI.php");
2800  #$tabs_gui =& new ilTabsGUI();
2801  $this->getTabs($this->tabs_gui);
2802  $this->tpl->setCurrentBlock("header_image");
2803  $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm_b.gif"));
2804  $this->tpl->parseCurrentBlock();
2805  $this->tpl->setCurrentBlock("content");
2806  #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
2807  $this->tpl->setVariable("HEADER", $this->object->getTitle());
2808  }
2809 
2816  function setLinkSubTabs($a_active)
2817  {
2818  global $ilTabs, $lng, $ilCtrl;
2819 
2820  $ilTabs->addSubtab("internal_links",
2821  $lng->txt("cont_internal_links"),
2822  $ilCtrl->getLinkTarget($this, "listLinks"));
2823 
2824  if ($this->object->getType() == "lm")
2825  {
2826  if(@include_once('HTTP/Request.php'))
2827  {
2828  $ilTabs->addSubtab("link_check",
2829  $lng->txt("link_check"),
2830  $ilCtrl->getLinkTarget($this, "linkChecker"));
2831  }
2832  }
2833 
2834  $ilTabs->activateSubTab($a_active);
2835  $ilTabs->activateTab("cont_links");
2836  }
2837 
2838 
2844  function getTabs(&$tabs_gui)
2845  {
2846  global $rbacsystem,$ilUser;
2847 
2848  // back to upper context
2849  //$tabs_gui->getTargetsByObjectType($this, $this->object->getType());
2850 
2851  // chapters
2852  $tabs_gui->addTarget("cont_chapters",
2853  $this->ctrl->getLinkTarget($this, "chapters"),
2854  "chapters", get_class($this));
2855 
2856  // pages
2857  $tabs_gui->addTarget("cont_all_pages",
2858  $this->ctrl->getLinkTarget($this, "pages"),
2859  "pages", get_class($this));
2860 
2861  // questions
2862  $tabs_gui->addTarget("objs_qst",
2863  $this->ctrl->getLinkTarget($this, "listQuestions"),
2864  "listQuestions", get_class($this));
2865 
2866  // info
2867  $tabs_gui->addTarget("info_short",
2868  $this->ctrl->getLinkTargetByClass("ilinfoscreengui",'showSummary'),
2869  "", "ilinfoscreengui");
2870 
2871  // properties
2872  $tabs_gui->addTarget("settings",
2873  $this->ctrl->getLinkTarget($this,'properties'),
2874  "properties", get_class($this));
2875 
2876  // learning progress
2877  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
2878  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()) and ($this->object->getType() == 'lm' or $this->object->getType() == 'dbk'))
2879  {
2880  $tabs_gui->addTarget('learning_progress',
2881  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
2882  '',
2883  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui','illmstatisticsgui'));
2884  }
2885 
2886  // links
2887  $tabs_gui->addTarget("cont_links",
2888  $this->ctrl->getLinkTarget($this,'listLinks'),
2889  "listLinks", get_class($this));
2890 
2891  if ($this->object->getType() != "lm")
2892  {
2893  // bibliographical data
2894  $tabs_gui->addTarget("bib_data",
2895  $this->ctrl->getLinkTarget($this, "editBibItem"),
2896  "editBibItem", get_class($this));
2897  }
2898 
2899  $tabs_gui->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
2900  , "history", get_class($this));
2901 
2902  $tabs_gui->addTarget("meta_data",
2903  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
2904  "", "ilmdeditorgui");
2905 
2906  if ($this->object->getType() == "lm")
2907  {
2908  // export
2909  $tabs_gui->addTarget("export",
2910  $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
2911  "", "ilexportgui");
2912  }
2913 
2914  // permissions
2915  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
2916  {
2917  $tabs_gui->addTarget("perm_settings",
2918  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
2919  }
2920  }
2921 
2925  function setSubTabs($a_active)
2926  {
2927  global $ilTabs, $ilSetting;
2928 
2929  if (in_array($a_active,
2930  array("cont_general_properties", "cont_style", "cont_lm_menu", "public_section")))
2931  {
2932  // general properties
2933  $ilTabs->addSubTabTarget("cont_general_properties",
2934  $this->ctrl->getLinkTarget($this, 'properties'),
2935  "", "");
2936 
2937  // style properties
2938  $ilTabs->addSubTabTarget("cont_style",
2939  $this->ctrl->getLinkTarget($this, 'editStyleProperties'),
2940  "", "");
2941 
2942  // menu properties
2943  $ilTabs->addSubTabTarget("cont_lm_menu",
2944  $this->ctrl->getLinkTarget($this, 'editMenuProperties'),
2945  "", "");
2946 
2947  if ($ilSetting->get("pub_section"))
2948  {
2949  if ($this->object->getType() != "dbk")
2950  {
2951  // public section
2952  $ilTabs->addSubTabTarget("public_section",
2953  $this->ctrl->getLinkTarget($this, 'editPublicSection'),
2954  "", "");
2955  }
2956  }
2957 
2958  $ilTabs->setSubTabActive($a_active);
2959  }
2960  }
2961 
2963  {
2964  global $ilTabs;
2965 
2966  $this->setTabs();
2967  $this->setSubTabs("public_section");
2968  $ilTabs->setTabActive("settings");
2969 
2970  switch ($this->object->getType())
2971  {
2972  case "lm":
2973  $gui_class = "ilobjlearningmodulegui";
2974  break;
2975 
2976  case "dlb":
2977  $gui_class = "ilobjdlbookgui";
2978  break;
2979  }
2980 
2981  // get learning module object
2982  $this->lm_obj =& new ilObjLearningModule($this->ref_id, true);
2983 
2984  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_public_selector.html");
2985  //$this->tpl->setVariable("ADM_CONTENT", "adm_content", "bla");
2986 
2987  require_once ("./Modules/LearningModule/classes/class.ilPublicSectionSelector.php");
2988  $exp = new ilPublicSectionSelector($this->ctrl->getLinkTarget($this, "view"),
2989  $this->object, $gui_class);
2990 
2991  $exp->setTargetGet("obj_id");
2992 
2993  // build html-output
2994  $exp->setOutput(0);
2995  $output = $exp->getOutput();
2996 
2997  // get page ids
2998  foreach ($exp->format_options as $node)
2999  {
3000  if (!$node["container"])
3001  {
3002  $pages[] = $node["child"];
3003  }
3004  }
3005 
3006  $js_pages = ilUtil::array_php2js($pages);
3007 
3008  //$this->tpl->setCurrentBlock("content");
3009  //var_dump($this->object->getPublicAccessMode());
3010  // access mode selector
3011  $this->tpl->setVariable("TXT_SET_PUBLIC_MODE", $this->lng->txt("set_public_mode"));
3012  $this->tpl->setVariable("TXT_CHOOSE_PUBLIC_MODE", $this->lng->txt("choose_public_mode"));
3013  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
3014  $select_public_mode = ilUtil::formSelect ($this->object->getPublicAccessMode(),"lm_public_mode",$modes, false, true);
3015  $this->tpl->setVariable("SELECT_PUBLIC_MODE", $select_public_mode);
3016 
3017  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("choose_public_pages"));
3018  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
3019  $this->tpl->setVariable("EXPLORER",$output);
3020  $this->tpl->setVariable("ONCLICK",$js_pages);
3021  $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
3022  $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
3023  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3024  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
3025  //$this->tpl->parseCurrentBlock();
3026 
3027  }
3028 
3030  {
3031  //var_dump($_POST["lm_public_mode"]);exit;
3032  $this->object->setPublicAccessMode($_POST["lm_public_mode"]);
3033  $this->object->updateProperties();
3034  ilLMObject::_writePublicAccessStatus($_POST["pages"],$this->object->getId());
3035  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3036  $this->ctrl->redirect($this, "editPublicSection");
3037  }
3038 
3044  function history()
3045  {
3046  $this->setTabs();
3047 
3048  require_once("classes/class.ilHistoryGUI.php");
3049  $hist_gui =& new ilHistoryGUI($this->object->getId() ,
3050  $this->object->getType());
3051  $hist_html = $hist_gui->getHistoryTable(
3052  $this->ctrl->getParameterArray($this, "history"),
3053  $this->object->isActiveHistoryUserComments()
3054  );
3055 
3056  $this->tpl->setVariable("ADM_CONTENT", $hist_html);
3057  }
3058 
3067  public function formatInvalidLinkArray(Array $row)
3068  {
3069  $row['title'] = ilLMPageObject::_getPresentationTitle($row['page_id'], $this->object->getPageHeader());
3070 
3071  require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
3073  $actions->setSelectionHeaderClass('small');
3074  $actions->setItemLinkClass('xsmall');
3075  $actions->setListTitle($this->lng->txt('actions'));
3076  $actions->setId($row['page_id']);
3077  $this->ctrl->setParameterByClass('ilLMPageObjectGUI', 'obj_id', $row['page_id']);
3078  $actions->addItem(
3079  $this->lng->txt('edit'),
3080  '',
3081  $this->ctrl->getLinkTargetByClass('ilLMPageObjectGUI', 'edit')
3082  );
3083  $this->ctrl->clearParametersByClass('ilLMPageObjectGUI');
3084  $row['action_html'] = $actions->getHTML();
3085 
3086  return $row;
3087  }
3088 
3089  function linkChecker()
3090  {
3091  global $ilias, $ilUser, $tpl;
3092 
3093  $this->__initLinkChecker();
3094 
3095  $this->setTabs();
3096  $this->setLinkSubTabs("link_check");
3097 
3098  require_once 'Services/LinkChecker/classes/class.ilLinkCheckerTableGUI.php';
3099 
3100  $toolbar = new ilToolbarGUI();
3101 
3102  if((bool)$ilias->getSetting('cron_web_resource_check'))
3103  {
3104  include_once 'classes/class.ilLinkCheckNotify.php';
3105  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
3106 
3107  $chb = new ilCheckboxInputGUI($this->lng->txt('link_check_message_a'), 'link_check_message');
3108  $chb->setValue(1);
3109  $chb->setChecked((bool)ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(),$this->object->getId()));
3110  $chb->setOptionTitle($this->lng->txt('link_check_message_b'));
3111 
3112  $toolbar->addInputItem($chb);
3113  $toolbar->addFormButton($this->lng->txt('save'), 'saveLinkCheck');
3114  $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'saveLinkCheck'));
3115  }
3116 
3117  $tgui = new ilLinkCheckerTableGUI($this, 'linkChecker');
3118  $tgui->setLinkChecker($this->link_checker_obj)
3119  ->setRowHandler($this)
3120  ->setRefreshButton($this->lng->txt('refresh'), 'refreshLinkCheck');
3121 
3122  return $tpl->setContent($tgui->prepareHTML()->getHTML().$toolbar->getHTML());
3123  }
3124 
3125  function saveLinkCheck()
3126  {
3127  global $ilDB,$ilUser;
3128 
3129  include_once './classes/class.ilLinkCheckNotify.php';
3130 
3131  $link_check_notify =& new ilLinkCheckNotify($ilDB);
3132  $link_check_notify->setUserId($ilUser->getId());
3133  $link_check_notify->setObjId($this->object->getId());
3134 
3135  if($_POST['link_check_message'])
3136  {
3137  ilUtil::sendSuccess($this->lng->txt('link_check_message_enabled'));
3138  $link_check_notify->addNotifier();
3139  }
3140  else
3141  {
3142  ilUtil::sendSuccess($this->lng->txt('link_check_message_disabled'));
3143  $link_check_notify->deleteNotifier();
3144  }
3145  $this->linkChecker();
3146 
3147  return true;
3148  }
3149 
3150 
3151 
3152  function refreshLinkCheck()
3153  {
3154  $this->__initLinkChecker();
3155 
3156  if(!$this->link_checker_obj->checkPear())
3157  {
3158  ilUtil::sendFailure($this->lng->txt('missing_pear_library'));
3159  $this->linkChecker();
3160 
3161  return false;
3162  }
3163 
3164  $this->link_checker_obj->checkLinks();
3165  ilUtil::sendSuccess($this->lng->txt('link_checker_refreshed'));
3166 
3167  $this->linkChecker();
3168 
3169  return true;
3170  }
3171 
3173  {
3174  global $ilDB;
3175 
3176  include_once './classes/class.ilLinkChecker.php';
3177 
3178  $this->link_checker_obj =& new ilLinkChecker($ilDB,false);
3179  $this->link_checker_obj->setObjId($this->object->getId());
3180 
3181  return true;
3182  }
3183 
3185  {
3186  include_once './Modules/LearningModule/classes/class.ilLMMenuEditor.php';
3187 
3188  $this->lmme_obj =& new ilLMMenuEditor();
3189  $this->lmme_obj->setObjId($this->object->getId());
3190 
3191  return true;
3192  }
3193 
3197  function addMenuEntry()
3198  {
3199  $this->setTabs();
3200 
3201  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_entry_form.html","Modules/LearningModule");
3202 
3203  if (isset($_GET["link_ref_id"]))
3204  {
3205  $obj_type = ilObject::_lookupType($_GET["link_ref_id"],true);
3206  $obj_id = ilObject::_lookupObjectId($_GET["link_ref_id"]);
3208 
3209  $target_link = $obj_type."_".$_GET["link_ref_id"];
3210  $this->tpl->setVariable("TITLE", $title);
3211  $this->tpl->setVariable("TARGET", $target_link);
3212  $this->tpl->setVariable("LINK_REF_ID", $_GET["link_ref_id"]);
3213  }
3214 
3215 
3216  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "saveMenuEntry"));
3217  $this->tpl->setVariable("TXT_NEW_ENTRY", $this->lng->txt("lm_menu_new_entry"));
3218  $this->tpl->setVariable("TXT_TARGET", $this->lng->txt("lm_menu_entry_target"));
3219  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("lm_menu_entry_title"));
3220  $this->tpl->setVariable("BTN_NAME", "saveMenuEntry");
3221  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
3222  $this->tpl->setVariable("BTN_NAME2", "showEntrySelector");
3223  $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("lm_menu_select_internal_object"));
3224  //$this->tpl->parseCurrentBlock();
3225 
3226  }
3227 
3231  function saveMenuEntry()
3232  {
3233  global $ilCtrl;
3234 
3235  // check title and target
3236  if (empty($_POST["title"]))
3237  {
3238  //$this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
3239  ilUtil::sendFailure($this->lng->txt("please_enter_title") , true);
3240  $ilCtrl->redirect($this, "addMenuEntry");
3241  }
3242  if (empty($_POST["target"]))
3243  {
3244  //$this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
3245  ilUtil::sendFailure($this->lng->txt("please_enter_target"), true);
3246  $ilCtrl->redirect($this, "addMenuEntry");
3247  }
3248 
3249  $this->__initLMMenuEditor();
3250  $this->lmme_obj->setTitle($_POST["title"]);
3251  $this->lmme_obj->setTarget($_POST["target"]);
3252  $this->lmme_obj->setLinkRefId($_POST["link_ref_id"]);
3253 
3254  if ($_POST["link_ref_id"])
3255  {
3256  $this->lmme_obj->setLinkType("intern");
3257  }
3258 
3259  $this->lmme_obj->create();
3260 
3261  ilUtil::sendSuccess($this->lng->txt("msg_entry_added"), true);
3262  $this->ctrl->redirect($this, "editMenuProperties");
3263  }
3264 
3268  function deleteMenuEntry()
3269  {
3270  if (empty($_GET["menu_entry"]))
3271  {
3272  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3273  }
3274 
3275  $this->__initLMMenuEditor();
3276  $this->lmme_obj->delete($_GET["menu_entry"]);
3277 
3278  ilUtil::sendSuccess($this->lng->txt("msg_entry_removed"), true);
3279  $this->ctrl->redirect($this, "editMenuProperties");
3280  }
3281 
3285  function editMenuEntry()
3286  {
3287  if (empty($_GET["menu_entry"]))
3288  {
3289  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3290  }
3291 
3292  $this->__initLMMenuEditor();
3293  $this->lmme_obj->readEntry($_GET["menu_entry"]);
3294 
3295  $this->setTabs();
3296 
3297  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_entry_form.html","Modules/LearningModule");
3298 
3299  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
3300  $this->tpl->setVariable("TXT_NEW_ENTRY", $this->lng->txt("lm_menu_edit_entry"));
3301  $this->tpl->setVariable("TXT_TARGET", $this->lng->txt("lm_menu_entry_target"));
3302  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("lm_menu_entry_title"));
3303  $this->tpl->setVariable("TITLE", $this->lmme_obj->getTitle());
3304  $this->tpl->setVariable("TARGET", $this->lmme_obj->getTarget());
3305  $this->tpl->setVariable("ENTRY_ID", $this->lmme_obj->getEntryId());
3306  $this->tpl->setVariable("BTN_NAME", "updateMenuEntry");
3307  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
3308  $this->tpl->setVariable("BTN_NAME2", "showEntrySelector");
3309  $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("lm_menu_select_internal_object"));
3310  //$this->tpl->parseCurrentBlock();
3311  }
3312 
3316  function updateMenuEntry()
3317  {
3318  if (empty($_POST["menu_entry"]))
3319  {
3320  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3321  }
3322 
3323  // check title and target
3324  if (empty($_POST["title"]))
3325  {
3326  $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
3327  }
3328  if (empty($_POST["target"]))
3329  {
3330  $this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
3331  }
3332 
3333  $this->__initLMMenuEditor();
3334  $this->lmme_obj->readEntry($_POST["menu_entry"]);
3335  $this->lmme_obj->setTitle($_POST["title"]);
3336  $this->lmme_obj->setTarget($_POST["target"]);
3337  $this->lmme_obj->update();
3338 
3339  ilUtil::sendSuccess($this->lng->txt("msg_entry_updated"), true);
3340  $this->ctrl->redirect($this, "editMenuProperties");
3341  }
3342 
3344  {
3345  $this->setTabs();
3346 
3347  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_object_selector.html","Modules/LearningModule");
3348 
3349  ilUtil::sendInfo($this->lng->txt("lm_menu_select_object_to_add"));
3350 
3351  require_once ("./Modules/LearningModule/classes/class.ilLMMenuObjectSelector.php");
3352  $exp = new ilLMMenuObjectSelector($this->ctrl->getLinkTarget($this,'test'),$this);
3353 
3354  $exp->setExpand($_GET["lm_menu_expand"] ? $_GET["lm_menu_expand"] : $this->tree->readRootId());
3355  $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showEntrySelector'));
3356  $exp->setTargetGet("ref_id");
3357  $exp->setRefId($this->cur_ref_id);
3358 
3359  $sel_types = array('mcst', 'mep', 'cat', 'lm','dbk','glo','frm','exc','tst','svy', 'chat', 'wiki', 'sahs',
3360  "crs", "grp", "book", "tst", "file");
3361  $exp->setSelectableTypes($sel_types);
3362 
3363  //$exp->setTargetGet("obj_id");
3364 
3365  // build html-output
3366  $exp->setOutput(0);
3367  $output = $exp->getOutput();
3368 
3369  // get page ids
3370  foreach ($exp->format_options as $node)
3371  {
3372  if (!$node["container"])
3373  {
3374  $pages[] = $node["child"];
3375  }
3376  }
3377 
3378  //$this->tpl->setCurrentBlock("content");
3379  //var_dump($this->object->getPublicAccessMode());
3380  // access mode selector
3381  $this->tpl->setVariable("TXT_SET_PUBLIC_MODE", $this->lng->txt("set_public_mode"));
3382  $this->tpl->setVariable("TXT_CHOOSE_PUBLIC_MODE", $this->lng->txt("choose_public_mode"));
3383  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
3384  $select_public_mode = ilUtil::formSelect ($this->object->getPublicAccessMode(),"lm_public_mode",$modes, false, true);
3385  $this->tpl->setVariable("SELECT_PUBLIC_MODE", $select_public_mode);
3386 
3387  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("choose_public_pages"));
3388  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
3389  $this->tpl->setVariable("EXPLORER",$output);
3390  $this->tpl->setVariable("ONCLICK",$js_pages);
3391  $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
3392  $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
3393  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3394  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
3395  //$this->tpl->parseCurrentBlock();
3396  }
3397 
3401  function selectHeader()
3402  {
3403  if(!isset($_POST["id"]))
3404  {
3405  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3406  }
3407  if(count($_POST["id"]) > 1)
3408  {
3409  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3410  }
3411  if ($_POST["id"][0] != $this->object->getHeaderPage())
3412  {
3413  $this->object->setHeaderPage($_POST["id"][0]);
3414  }
3415  else
3416  {
3417  $this->object->setHeaderPage(0);
3418  }
3419  $this->object->updateProperties();
3420  $this->ctrl->redirect($this, "pages");
3421  }
3422 
3426  function selectFooter()
3427  {
3428  if(!isset($_POST["id"]))
3429  {
3430  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3431  }
3432  if(count($_POST["id"]) > 1)
3433  {
3434  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3435  }
3436  if ($_POST["id"][0] != $this->object->getFooterPage())
3437  {
3438  $this->object->setFooterPage($_POST["id"][0]);
3439  }
3440  else
3441  {
3442  $this->object->setFooterPage(0);
3443  }
3444  $this->object->updateProperties();
3445  $this->ctrl->redirect($this, "pages");
3446  }
3447 
3451  function saveAllTitles()
3452  {
3453  global $ilCtrl;
3454 
3455  ilLMObject::saveTitles($this->object, ilUtil::stripSlashesArray($_POST["title"]));
3456 
3457  $ilCtrl->redirect($this, "chapters");
3458  }
3459 
3463  function insertChapter()
3464  {
3465  global $ilCtrl, $lng;
3466 
3467  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
3468 
3471 
3472  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
3473  {
3474  $parent_id = $this->lm_tree->getParentId($node_id);
3475  $target = $node_id;
3476  }
3477  else // insert as first child
3478  {
3479  $parent_id = $node_id;
3480  $target = IL_FIRST_NODE;
3481  }
3482 
3483  for ($i = 1; $i <= $num; $i++)
3484  {
3485  $chap = new ilStructureObject($this->object);
3486  $chap->setType("st");
3487  $chap->setTitle($lng->txt("cont_new_chap"));
3488  $chap->setLMId($this->object->getId());
3489  $chap->create();
3490  ilLMObject::putInTree($chap, $parent_id, $target);
3491  }
3492 
3493  $ilCtrl->redirect($this, "chapters");
3494  }
3495 
3500  {
3501  global $ilUser, $ilCtrl, $ilLog;
3502 
3503  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
3504 
3505  if ($ilUser->getPref("lm_js_chapter_editing") != "disable")
3506  {
3507  //$num = ilChapterHierarchyFormGUI::getPostMulti();
3510  }
3511  else
3512  {
3513  if (!isset($_POST["id"]) || $_POST["id"][0] == -1)
3514  {
3515  $node_id = $this->lm_tree->getRootId();
3516  $first_child = true;
3517  }
3518  else
3519  {
3520  $node_id = $_POST["id"][0];
3521  $first_child = false;
3522  }
3523  }
3524 
3525  $ilLog->write("InsertChapterClip, num: $num, node_id: $node_id, ".
3526  " getPostFirstChild ".ilChapterHierarchyFormGUI::getPostFirstChild());
3527 
3528  if (!$first_child) // insert after node id
3529  {
3530  $parent_id = $this->lm_tree->getParentId($node_id);
3531  $target = $node_id;
3532  }
3533  else // insert as first child
3534  {
3535  $parent_id = $node_id;
3536  $target = IL_FIRST_NODE;
3537  }
3538 
3539  // copy and paste
3540  $chapters = $ilUser->getClipboardObjects("st", true);
3541  $copied_nodes = array();
3542  foreach ($chapters as $chap)
3543  {
3544  $ilLog->write("Call pasteTree, Target LM: ".$this->object->getId().", Chapter ID: ".$chap["id"]
3545  .", Parent ID: ".$parent_id.", Target: ".$target);
3546  $cid = ilLMObject::pasteTree($this->object, $chap["id"], $parent_id,
3547  $target, $chap["insert_time"], $copied_nodes,
3548  (ilEditClipboard::getAction() == "copy"));
3549  $target = $cid;
3550  }
3551  ilLMObject::updateInternalLinks($copied_nodes);
3552 
3553  if (ilEditClipboard::getAction() == "cut")
3554  {
3555  $ilUser->clipboardDeleteObjectsOfType("pg");
3556  $ilUser->clipboardDeleteObjectsOfType("st");
3558  }
3559 
3560  $this->object->checkTree();
3561  $ilCtrl->redirect($this, "chapters");
3562  }
3563 
3569  function _goto($a_target)
3570  {
3571  global $ilAccess, $ilErr, $lng;
3572 
3573  if ($ilAccess->checkAccess("read", "", $a_target))
3574  {
3575  $_GET["baseClass"] = "ilLMPresentationGUI";
3576  $_GET["ref_id"] = $a_target;
3577  include("ilias.php");
3578  exit;
3579  } else if ($ilAccess->checkAccess("visible", "", $a_target))
3580  {
3581  $_GET["baseClass"] = "ilLMPresentationGUI";
3582  $_GET["ref_id"] = $a_target;
3583  $_GET["cmd"] = "infoScreen";
3584  include("ilias.php");
3585  exit;
3586  }
3587  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
3588  {
3589  $_GET["cmd"] = "frameset";
3590  $_GET["target"] = "";
3591  $_GET["ref_id"] = ROOT_FOLDER_ID;
3592  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
3593  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
3594  include("repository.php");
3595  exit;
3596  }
3597 
3598 
3599  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
3600  }
3601 
3605  function cutItems($a_return = "chapters")
3606  {
3607  global $ilCtrl, $lng;
3608 
3609  $items = ilUtil::stripSlashesArray($_POST["id"]);
3610  if (!is_array($items))
3611  {
3612  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3613  $ilCtrl->redirect($this, $a_return);
3614  }
3615 
3616  $todel = array(); // delete IDs < 0 (needed for non-js editing)
3617  foreach($items as $k => $item)
3618  {
3619  if ($item < 0)
3620  {
3621  $todel[] = $k;
3622  }
3623  }
3624  foreach($todel as $k)
3625  {
3626  unset($items[$k]);
3627  }
3628  ilLMObject::clipboardCut($this->object->getId(), $items);
3630  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
3631 
3632  $ilCtrl->redirect($this, $a_return);
3633  }
3634 
3638  function copyItems()
3639  {
3640  global $ilCtrl, $lng;
3641 
3642  $items = ilUtil::stripSlashesArray($_POST["id"]);
3643  if (!is_array($items))
3644  {
3645  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3646  $ilCtrl->redirect($this, "chapters");
3647  }
3648 
3649  $todel = array(); // delete IDs < 0 (needed for non-js editing)
3650  foreach($items as $k => $item)
3651  {
3652  if ($item < 0)
3653  {
3654  $todel[] = $k;
3655  }
3656  }
3657  foreach($todel as $k)
3658  {
3659  unset($items[$k]);
3660  }
3661  ilLMObject::clipboardCopy($this->object->getId(), $items);
3663  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
3664  $ilCtrl->redirect($this, "chapters");
3665  }
3666 
3670  function cutChapter()
3671  {
3672  $this->cutItems("chapters");
3673  }
3674 
3675 } // END class.ilObjContentObjectGUI
3676 ?>