ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjContentObjectGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 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 
21 {
22  var $ctrl;
23 
29  function ilObjContentObjectGUI($a_data,$a_id = 0,$a_call_by_reference = true, $a_prepare_output = false)
30  {
31  global $lng, $ilCtrl;
32 //echo "<br>ilobjcontobjgui-constructor-id-$a_id";
33  $this->ctrl =& $ilCtrl;
34  $lng->loadLanguageModule("content");
35  parent::ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
36  }
37 
41  function &executeCommand()
42  {
43  global $ilAccess;
44 
45  if ($this->ctrl->getRedirectSource() == "ilinternallinkgui")
46  {
47  $this->explorer();
48  return;
49  }
50 
51  if ($this->ctrl->getCmdClass() == "ilinternallinkgui")
52  {
53  $this->ctrl->setReturn($this, "explorer");
54  }
55 
56  // get next class that processes or forwards current command
57  $next_class = $this->ctrl->getNextClass($this);
58 
59  // get current command
60  $cmd = $this->ctrl->getCmd("", array("downloadExportFile"));
61 //echo "-$cmd-";
62  switch($next_class)
63  {
64  case "illearningprogressgui":
65  $this->addLocations();
66  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
67  $this->setTabs();
68 
69  $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,$this->object->getRefId());
70  $new_gui->activateStatistics();
71  $this->ctrl->forwardCommand($new_gui);
72 
73  break;
74 
75  case 'ilmdeditorgui':
76  $this->addLocations();
77  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
78  $this->setTabs();
79  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
80  $md_gui->addObserver($this->object,'MDUpdateListener','General');
81 
82  $this->ctrl->forwardCommand($md_gui);
83  break;
84 
85  case "ilobjstylesheetgui":
86  $this->addLocations();
87  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
88  $this->ctrl->setReturn($this, "editStyleProperties");
89  $style_gui =& new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
90  $style_gui->omitLocator();
91  if ($cmd == "create" || $_GET["new_type"]=="sty")
92  {
93  $style_gui->setCreationMode(true);
94  }
95  $ret =& $this->ctrl->forwardCommand($style_gui);
96  //$ret =& $style_gui->executeCommand();
97 
98  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
99  {
100  $style_id = $ret;
101  $this->object->setStyleSheetId($style_id);
102  $this->object->update();
103  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
104  }
105  break;
106 
107  case "illmpageobjectgui":
108  $this->ctrl->saveParameter($this, array("obj_id"));
109  $this->addLocations();
110  $this->ctrl->setReturn($this, "chapters");
111 //echo "!";
112  //$this->lm_obj =& $this->ilias->obj_factory->getInstanceByRefId($this->ref_id);
113 
114  $pg_gui =& new ilLMPageObjectGUI($this->object);
115  if ($_GET["obj_id"] != "")
116  {
117  $obj =& ilLMObjectFactory::getInstance($this->object, $_GET["obj_id"]);
118  $pg_gui->setLMPageObject($obj);
119  }
120  //$ret =& $pg_gui->executeCommand();
121  $ret =& $this->ctrl->forwardCommand($pg_gui);
122  if ($cmd == "save" || $cmd == "cancel")
123  {
124  $this->ctrl->redirect($this, "pages");
125  }
126  break;
127 
128  case "ilstructureobjectgui":
129  $this->ctrl->saveParameter($this, array("obj_id"));
130  $this->addLocations();
131  $this->ctrl->setReturn($this, "chapters");
132  $st_gui =& new ilStructureObjectGUI($this->object, $this->object->lm_tree);
133  if ($_GET["obj_id"] != "")
134  {
135  $obj =& ilLMObjectFactory::getInstance($this->object, $_GET["obj_id"]);
136  $st_gui->setStructureObject($obj);
137  }
138  //$ret =& $st_gui->executeCommand();
139  $ret =& $this->ctrl->forwardCommand($st_gui);
140  if ($cmd == "save" || $cmd == "cancel")
141  {
142  if ($_GET["obj_id"] == "")
143  {
144  $this->ctrl->redirect($this, "chapters");
145  }
146  else
147  {
148  $this->ctrl->setCmd("subchap");
149  $this->executeCommand();
150  }
151  }
152  break;
153 
154  case 'ilpermissiongui':
155  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
156  {
157  $this->prepareOutput();
158  }
159  else
160  {
161  $this->addLocations(true);
162  $this->setTabs();
163  }
164  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
165  $perm_gui =& new ilPermissionGUI($this);
166  $ret =& $this->ctrl->forwardCommand($perm_gui);
167  break;
168 
169  // infoscreen
170  case 'ilinfoscreengui':
171  $this->addLocations(true);
172  $this->setTabs();
173  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
174  $info = new ilInfoScreenGUI($this);
175  $info->enablePrivateNotes();
176  $info->enableLearningProgress();
177 
178  $info->enableNews();
179  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
180  {
181  $info->enableNewsEditing();
182  $info->setBlockProperty("news", "settings", true);
183  }
184 
185  // show standard meta data section
186  $info->addMetaDataSections($this->object->getId(), 0,
187  $this->object->getType());
188 
189  $ret =& $this->ctrl->forwardCommand($info);
190  break;
191 
192  default:
193  $new_type = $_POST["new_type"]
194  ? $_POST["new_type"]
195  : $_GET["new_type"];
196 
197 
198  if ($cmd == "create" &&
199  !in_array($new_type, array("dbk", "lm")))
200  {
201  //$this->addLocations();
202  switch ($new_type)
203  {
204  case "pg":
205  $this->setTabs();
206  $this->ctrl->setCmdClass("ilLMPageObjectGUI");
207  $ret =& $this->executeCommand();
208  break;
209 
210  case "st":
211  $this->setTabs();
212  $this->ctrl->setCmdClass("ilStructureObjectGUI");
213  $ret =& $this->executeCommand();
214  break;
215  }
216  }
217  else
218  {
219  // creation of new dbk/lm in repository
220  if ($this->getCreationMode() == true &&
221  in_array($new_type, array("dbk", "lm")))
222  {
223  $this->prepareOutput();
224  if ($cmd == "") // this may be due to too big upload files
225  {
226  $cmd = "create";
227  }
228  $cmd .= "Object";
229  $ret =& $this->$cmd();
230  }
231  else
232  {
233  $this->addLocations();
234  $ret =& $this->$cmd();
235  }
236  }
237  break;
238  }
239  return $ret;
240  }
241 
242  function _forwards()
243  {
244  return array("ilLMPageObjectGUI", "ilStructureObjectGUI","ilObjStyleSheetGUI");
245  }
246 
250  function properties()
251  {
252  global $lng;
253 
254  $lng->loadLanguageModule("style");
255  $this->setTabs();
256  $this->setSubTabs("cont_general_properties");
257 
258  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
259  $showViewInFrameset = true;
260 
261  if ($showViewInFrameset)
262  {
263  $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
264  }
265  else
266  {
267  $buttonTarget = "ilContObj".$this->object->getID();
268  }
269 
270  //add template for view button
271  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
272 
273  // view button
274  $this->tpl->setCurrentBlock("btn_cell");
275  $this->tpl->setVariable("BTN_LINK", "ilias.php?baseClass=ilLMPresentationGUI&ref_id=".$this->object->getRefID());
276  $this->tpl->setVariable("BTN_TARGET"," target=\"".$buttonTarget."\" ");
277  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
278  $this->tpl->parseCurrentBlock();
279 
280  $this->tpl->setCurrentBlock("btn_cell");
281  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "fixTreeConfirm"));
282  //$this->tpl->setVariable("BTN_TARGET"," target=\"_top\" ");
283  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_fix_tree"));
284  $this->tpl->parseCurrentBlock();
285 
286  //$this->tpl->touchBlock("btn_row");
287 
288  // lm properties
289  $this->initPropertiesForm();
290  $this->getPropertiesFormValues();
291  $this->tpl->setContent($this->form->getHTML());
292  }
293 
298  {
299  global $ilCtrl, $lng;
300 
301  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
302  $this->form = new ilPropertyFormGUI();
303 
304  // online
305  $online = new ilCheckboxInputGUI($lng->txt("cont_online"), "cobj_online");
306  $this->form->addItem($online);
307 
308  // default layout
309  $layout = new ilRadioMatrixInputGUI($lng->txt("cont_def_layout"), "lm_layout");
310  $option = array();
312  {
313  $im_tag = "";
314  if (is_file($im = ilUtil::getImagePath("layout_".$l.".gif")))
315  {
316  $im_tag = ilUtil::img($im, $l);
317  }
318  $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>";
319  }
320  $layout->setOptions($option);
321  $this->form->addItem($layout);
322 
323  // page header
324  $page_header = new ilSelectInputGUI($lng->txt("cont_page_header"), "lm_pg_header");
325  $option = array ("st_title" => $this->lng->txt("cont_st_title"),
326  "pg_title" => $this->lng->txt("cont_pg_title"),
327  "none" => $this->lng->txt("cont_none"));
328  $page_header->setOptions($option);
329  $this->form->addItem($page_header);
330 
331  // chapter numeration
332  $chap_num = new ilCheckboxInputGUI($lng->txt("cont_act_number"), "cobj_act_number");
333  $this->form->addItem($chap_num);
334 
335  // toc mode
336  $toc_mode = new ilSelectInputGUI($lng->txt("cont_toc_mode"), "toc_mode");
337  $option = array ("chapters" => $this->lng->txt("cont_chapters_only"),
338  "pages" => $this->lng->txt("cont_chapters_and_pages"));
339  $toc_mode->setOptions($option);
340  $this->form->addItem($toc_mode);
341 
342  // public notes
343  if (!$this->ilias->getSetting('disable_notes'))
344  {
345  $pub_nodes = new ilCheckboxInputGUI($lng->txt("cont_public_notes"), "cobj_pub_notes");
346  $pub_nodes->setInfo($this->lng->txt("cont_public_notes_desc"));
347  $this->form->addItem($pub_nodes);
348  }
349 
350  // layout per page
351  $lpp = new ilCheckboxInputGUI($lng->txt("cont_layout_per_page"), "layout_per_page");
352  $lpp->setInfo($this->lng->txt("cont_layout_per_page_info"));
353  $this->form->addItem($lpp);
354 
355  // synchronize frames
356  $synch = new ilCheckboxInputGUI($lng->txt("cont_synchronize_frames"), "cobj_clean_frames");
357  $synch->setInfo($this->lng->txt("cont_synchronize_frames_desc"));
358  $this->form->addItem($synch);
359 
360  // history user comments
361  $com = new ilCheckboxInputGUI($lng->txt("enable_hist_user_comments"), "cobj_user_comments");
362  $com->setInfo($this->lng->txt("enable_hist_user_comments_desc"));
363  $this->form->addItem($com);
364 
365  $this->form->setTitle($lng->txt("cont_general_properties"));
366  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
367  $this->form->setFormAction($ilCtrl->getFormAction($this));
368  }
369 
374  {
375  $values = array();
376  if ($this->object->getOnline())
377  {
378  $values["cobj_online"] = true;
379  }
380  $values["lm_layout"] = $this->object->getLayout();
381  $values["lm_pg_header"] = $this->object->getPageHeader();
382  if ($this->object->isActiveNumbering())
383  {
384  $values["cobj_act_number"] = true;
385  }
386  $values["toc_mode"] = $this->object->getTOCMode();
387  if ($this->object->publicNotes())
388  {
389  $values["cobj_pub_notes"] = true;
390  }
391  if ($this->object->cleanFrames())
392  {
393  $values["cobj_clean_frames"] = true;
394  }
395  if ($this->object->isActiveHistoryUserComments())
396  {
397  $values["cobj_user_comments"] = true;
398  }
399  $values["layout_per_page"] = $this->object->getLayoutPerPage();
400 
401  $this->form->setValuesByArray($values);
402  }
403 
407  function saveProperties()
408  {
409  global $ilias;
410 
411  $this->initPropertiesForm();
412  if ($this->form->checkInput())
413  {
414  $this->object->setLayout($_POST["lm_layout"]);
415  $this->object->setPageHeader($_POST["lm_pg_header"]);
416  $this->object->setTOCMode($_POST["toc_mode"]);
417  $this->object->setOnline($_POST["cobj_online"]);
418  $this->object->setActiveNumbering($_POST["cobj_act_number"]);
419  $this->object->setCleanFrames($_POST["cobj_clean_frames"]);
420  $this->object->setPublicNotes($_POST["cobj_pub_notes"]);
421  $this->object->setHistoryUserComments($_POST["cobj_user_comments"]);
422  $this->object->setLayoutPerPage($_POST["layout_per_page"]);
423  $this->object->updateProperties();
424  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
425  $this->ctrl->redirect($this, "properties");
426  }
427  else
428  {
429  $this->form->setValuesByPost();
430  $tpl->setContent($this->form->getHTML());
431  }
432  }
433 
438  {
439  global $tpl;
440 
441  $this->initStylePropertiesForm();
442  $tpl->setContent($this->form->getHTML());
443  }
444 
449  {
450  global $ilCtrl, $lng, $ilTabs, $ilSetting;
451 
452  $lng->loadLanguageModule("style");
453  $this->setTabs();
454  $ilTabs->setTabActive("properties");
455  $this->setSubTabs("cont_style");
456 
457  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
458  $this->form = new ilPropertyFormGUI();
459 
460  $fixed_style = $ilSetting->get("fixed_content_style_id");
461  $style_id = $this->object->getStyleSheetId();
462 
463  if ($fixed_style > 0)
464  {
465  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
466  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
467  $this->lng->txt("global_fixed").")");
468  $this->form->addItem($st);
469  }
470  else
471  {
472  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
473  $_GET["ref_id"]);
474 
475  $st_styles[0] = $this->lng->txt("default");
476  ksort($st_styles);
477 
478  if ($style_id > 0)
479  {
480  // individual style
481  if (!ilObjStyleSheet::_lookupStandard($style_id))
482  {
483  $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
484  $st->setValue(ilObject::_lookupTitle($style_id));
485  $this->form->addItem($st);
486 
487 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
488 
489  // delete command
490  $this->form->addCommandButton("editStyle",
491  $lng->txt("cont_edit_style"));
492  $this->form->addCommandButton("deleteStyle",
493  $lng->txt("cont_delete_style"));
494 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
495  }
496  }
497 
498  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
499  {
500  $style_sel = ilUtil::formSelect ($style_id, "style_id",
501  $st_styles, false, true);
502  $style_sel = new ilSelectInputGUI($lng->txt("cont_current_style"), "style_id");
503  $style_sel->setOptions($st_styles);
504  $style_sel->setValue($style_id);
505  $this->form->addItem($style_sel);
506 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
507  $this->form->addCommandButton("saveStyleSettings",
508  $lng->txt("save"));
509  $this->form->addCommandButton("createStyle",
510  $lng->txt("sty_create_ind_style"));
511  }
512  }
513  $this->form->setTitle($lng->txt("cont_style"));
514  $this->form->setFormAction($ilCtrl->getFormAction($this));
515  }
516 
520  function createStyle()
521  {
522  global $ilCtrl;
523 
524  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
525  }
526 
530  function editStyle()
531  {
532  global $ilCtrl;
533 
534  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
535  }
536 
540  function deleteStyle()
541  {
542  global $ilCtrl;
543 
544  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
545  }
546 
550  function saveStyleSettings()
551  {
552  global $ilSetting;
553 
554  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
555  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
556  || $this->object->getStyleSheetId() == 0))
557  {
558  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
559  $this->object->update();
560  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
561  }
562  $this->ctrl->redirect($this, "editStyleProperties");
563  }
564 
569  {
570  global $lng, $ilTabs;
571 
572  $lng->loadLanguageModule("style");
573  $this->setTabs();
574  $ilTabs->setTabActive("properties");
575  $this->setSubTabs("cont_lm_menu");
576 
577  // lm menu properties
578  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_properties.html", "Modules/LearningModule");
579  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
580 
581  $this->tpl->setVariable("TXT_LM_MENU", $this->lng->txt("cont_lm_menu"));
582  $this->tpl->setVariable("TXT_ACT_MENU", $this->lng->txt("cont_active"));
583  $this->tpl->setVariable("CBOX_LM_MENU", "cobj_act_lm_menu");
584  $this->tpl->setVariable("VAL_LM_MENU", "y");
585  if ($this->object->isActiveLMMenu())
586  {
587  $this->tpl->setVariable("CHK_LM_MENU", "checked");
588  }
589 
590  // toc
591  $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
592  $this->tpl->setVariable("CBOX_TOC", "cobj_act_toc");
593  $this->tpl->setVariable("VAL_TOC", "y");
594  if ($this->object->isActiveTOC())
595  {
596  $this->tpl->setVariable("CHK_TOC", "checked");
597  }
598 
599  // print view
600  $this->tpl->setVariable("TXT_PRINT", $this->lng->txt("cont_print_view"));
601  $this->tpl->setVariable("CBOX_PRINT", "cobj_act_print");
602  $this->tpl->setVariable("VAL_PRINT", "y");
603  if ($this->object->isActivePrintView())
604  {
605  $this->tpl->setVariable("CHK_PRINT", "checked");
606  }
607 
608  // prevent glossary appendix
609  $this->tpl->setVariable("TXT_PRINT_PREV_GLO", $this->lng->txt("cont_print_view_pre_glo"));
610  $this->tpl->setVariable("CBOX_PRINT_PREV_GLO", "cobj_act_print_prev_glo");
611  $this->tpl->setVariable("VAL_PRINT_PREV_GLO", "y");
612  if ($this->object->isActivePreventGlossaryAppendix())
613  {
614  $this->tpl->setVariable("CHK_PRINT_PREV_GLO", "checked");
615  }
616 
617  // downloads
618  $this->tpl->setVariable("TXT_DOWNLOADS", $this->lng->txt("cont_downloads"));
619  $this->tpl->setVariable("TXT_DOWNLOADS_DESC", $this->lng->txt("cont_downloads_desc"));
620  $this->tpl->setVariable("CBOX_DOWNLOADS", "cobj_act_downloads");
621  $this->tpl->setVariable("VAL_DOWNLOADS", "y");
622 
623  if ($this->object->isActiveDownloads())
624  {
625  $this->tpl->setVariable("CHK_DOWNLOADS", "checked=\"checked\"");
626  }
627 
628  $this->tpl->setVariable("TXT_DOWNLOADS_PUBLIC_DESC", $this->lng->txt("cont_downloads_public_desc"));
629  $this->tpl->setVariable("CBOX_DOWNLOADS_PUBLIC", "cobj_act_downloads_public");
630  $this->tpl->setVariable("VAL_DOWNLOADS_PUBLIC", "y");
631 
632  if ($this->object->isActiveDownloadsPublic())
633  {
634  $this->tpl->setVariable("CHK_DOWNLOADS_PUBLIC", "checked=\"checked\"");
635  }
636 
637  if (!$this->object->isActiveDownloads())
638  {
639  $this->tpl->setVariable("CHK2_DOWNLOADS_PUBLIC", "disabled=\"disabled\"");
640  }
641 
642  // get user defined menu entries
643  $this->__initLMMenuEditor();
644  $entries = $this->lmme_obj->getMenuEntries();
645 
646  if (count($entries) > 0)
647  {
648  foreach ($entries as $entry)
649  {
650  $this->ctrl->setParameter($this, "menu_entry", $entry["id"]);
651 
652  $this->tpl->setCurrentBlock("menu_entries");
653 
654  if ($entry["type"] == "intern")
655  {
656  $entry["link"] = ILIAS_HTTP_PATH."/goto.php?target=".$entry["link"];
657  }
658 
659  // add http:// prefix if not exist
660  if (!strstr($entry["link"],'://') && !strstr($entry["link"],'mailto:'))
661  {
662  $entry["link"] = "http://".$entry["link"];
663  }
664 
665  $this->tpl->setVariable("ENTRY_LINK", $entry["link"]);
666  $this->tpl->setVariable("ENTRY_TITLE", $entry["title"]);
667 
668  $this->tpl->setVariable("CBOX_ENTRY", "menu_entries[]");
669  $this->tpl->setVariable("VAL_ENTRY", $entry["id"]);
670 
671  if (ilUtil::yn2tf($entry["active"]))
672  {
673  $this->tpl->setVariable("CHK_ENTRY", "checked=\"checked\"");
674  }
675 
676 
677  $this->tpl->setVariable("LINK_EDIT", $this->ctrl->getLinkTarget($this,"editMenuEntry"));
678  $this->tpl->setVariable("TARGET_EDIT", "content");
679  $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
680  $this->tpl->setVariable("IMG_EDIT", ilUtil::getImagePath("icon_pencil.gif"));
681 
682  $this->tpl->setVariable("LINK_DROP", $this->ctrl->getLinkTarget($this,"deleteMenuEntry"));
683  $this->tpl->setVariable("TARGET_DROP", "content");
684  $this->tpl->setVariable("TXT_DROP", $this->lng->txt("drop"));
685  $this->tpl->setVariable("IMG_DROP", ilUtil::getImagePath("delete.gif"));
686 
687  $this->tpl->parseCurrentBlock();
688  }
689  }
690 
691  // add entry link
692 
693 
694  $this->tpl->setCurrentBlock("commands");
695  $this->tpl->setVariable("BTN_NAME", "saveMenuProperties");
696  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
697  $this->tpl->setVariable("BTN_NAME2", "addMenuEntry");
698  $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("add_menu_entry"));
699  $this->tpl->parseCurrentBlock();
700  }
701 
706  {
707  global $ilias;
708 
709  $this->object->setActiveLMMenu(ilUtil::yn2tf($_POST["cobj_act_lm_menu"]));
710  $this->object->setActiveTOC(ilUtil::yn2tf($_POST["cobj_act_toc"]));
711  $this->object->setActivePrintView(ilUtil::yn2tf($_POST["cobj_act_print"]));
712  $this->object->setActivePreventGlossaryAppendix(ilUtil::yn2tf($_POST["cobj_act_print_prev_glo"]));
713  $this->object->setActiveDownloads(ilUtil::yn2tf($_POST["cobj_act_downloads"]));
714  $this->object->setActiveDownloadsPublic(ilUtil::yn2tf($_POST["cobj_act_downloads_public"]));
715  $this->object->updateProperties();
716 
717  $this->__initLMMenuEditor();
718 //var_dump($_POST["menu_entries"]); exit;
719  $this->lmme_obj->updateActiveStatus($_POST["menu_entries"]);
720 
721  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
722  $this->ctrl->redirect($this, "editMenuProperties");
723  }
724 
728  function explorer()
729  {
730  global $ilUser, $ilias, $ilCtrl;
731 
732  switch ($this->object->getType())
733  {
734  case "lm":
735  $gui_class = "ilobjlearningmodulegui";
736  break;
737 
738  case "dlb":
739  $gui_class = "ilobjdlbookgui";
740  break;
741  }
742 
743  $ilCtrl->setParameterByClass($gui_class, "active_node", $_GET["active_node"]);
744 
745  $this->tpl = new ilTemplate("tpl.main.html", true, true);
746  // get learning module object
747  //$this->lm_obj =& new ilObjLearningModule($this->ref_id, true);
748 
749  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
750 
751  //$this->tpl = new ilTemplate("tpl.explorer.html", false, false);
752  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
753  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
754 
755  require_once ("./Modules/LearningModule/classes/class.ilLMEditorExplorer.php");
756  $exp = new ilLMEditorExplorer($this->ctrl->getLinkTarget($this, "view"),
757  $this->object, $gui_class);
758 
759  $exp->setTargetGet("obj_id");
760  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, "explorer"));
761 
762  if ($_GET["lmmovecopy"] == "1")
763  {
764  $this->proceedDragDrop();
765  }
766 
767 
768  if ($_GET["lmexpand"] == "")
769  {
770  $mtree = new ilTree($this->object->getId());
771  $mtree->setTableNames('lm_tree','lm_data');
772  $mtree->setTreeTablePK("lm_id");
773  $expanded = $mtree->readRootId();
774  }
775  else
776  {
777  $expanded = $_GET["lmexpand"];
778  }
779  if ($_GET["active_node"] != "")
780  {
781  $path = $this->lm_tree->getPathId($_GET["active_node"]);
782  $exp->setForceOpenPath($path);
783 
784  $exp->highlightNode($_GET["active_node"]);
785  }
786  $exp->setExpand($expanded);
787 
788  // build html-output
789  $exp->setOutput(0);
790  $output = $exp->getOutput();
791 
792  // asynchronous output
793  if ($ilCtrl->isAsynch())
794  {
795  echo $output; exit;
796  }
797 
798  include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
799 
800  /*if (ilPageEditorGUI::_doJSEditing())
801  {
802  //$this->tpl->touchBlock("includejavascript");
803 
804  $IDS = "";
805  for ($i=0;$i<count($exp->iconList);$i++)
806  {
807  if ($i>0) $IDS .= ",";
808  $IDS .= "'".$exp->iconList[$i]."'";
809  }
810  $this->tpl->setVariable("ICONIDS",$IDS);
811  //$this->ctrl->setParameter($this, "lmovecopy", 1);
812  $this->tpl->setVariable("TESTPFAD",$this->ctrl->getLinkTarget($this, "explorer")."&lmmovecopy=1");
813  //$this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode");
814  $this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode");
815  }*/
816 
817  $this->tpl->setCurrentBlock("content");
818  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_chap_and_pages"));
819  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
820  $this->tpl->setVariable("EXPLORER",$output);
821  $this->ctrl->setParameter($this, "lmexpand", $_GET["lmexpand"]);
822  $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, "explorer"));
823  $this->tpl->parseCurrentBlock();
824  $this->tpl->show(false);
825  exit;
826  }
827 
831  function popup()
832  {
833  include_once "./Services/COPage/classes/class.ilWysiwygUtil.php";
834  $popup = new ilWysiwygUtil();
835  $popup->show($_GET["ptype"]);
836  exit;
837  }
838 
842  function proceedDragDrop()
843  {
844  global $ilCtrl;
845 
846  $this->object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
847  $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
848  $ilCtrl->redirect($this, "chapters");
849  }
850 
854  function createObject()
855  {
856  global $rbacsystem, $tpl;
857 
858  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
859 
860  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
861  {
862  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
863  }
864  else
865  {
866  $this->initCreationForm();
867  $f1 = $this->form->getHTML();
868  $this->initImportForm();
869  $f2 = $this->form->getHTML();
870  $this->tpl->setContent($f1."<br />".$f2);
871 
872 
873 
874 return;
875  // fill in saved values in case of error
876  $data = array();
877  $data["fields"] = array();
878  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
879  $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
880 
881  $this->getTemplateFile("create", $new_type);
882 
883  $this->tpl->setVariable("TYPE_IMG",
884  ilUtil::getImagePath("icon_".$new_type.".gif"));
885  $this->tpl->setVariable("ALT_IMG",
886  $this->lng->txt("obj_".$new_type));
887 
888  foreach ($data["fields"] as $key => $val)
889  {
890  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
891  $this->tpl->setVariable(strtoupper($key), $val);
892 
893  if ($this->prepare_output)
894  {
895  $this->tpl->parseCurrentBlock();
896  }
897  }
898 
899 
900  //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save",
901  // "adm_object.php?cmd=gateway&ref_id=".
902  // $_GET["ref_id"]."&new_type=".$new_type));
903  $this->ctrl->setParameter($this, "new_type", $new_type);
904  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "save"));
905 
906 
907  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
908  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
909  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
910  $this->tpl->setVariable("CMD_SUBMIT", "save");
911  $this->tpl->setVariable("TARGET", ' target="'.
912  ilFrameTargetInfo::_getFrame("MainContent").'" ');
913  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
914 
915  $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_".$new_type));
916  $this->tpl->setVariable("TXT_LM_FILE", $this->lng->txt("file"));
917  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
918 
919  // get the value for the maximal uploadable filesize from the php.ini (if available)
920  $umf=get_cfg_var("upload_max_filesize");
921  // get the value for the maximal post data from the php.ini (if available)
922  $pms=get_cfg_var("post_max_size");
923 
924  // use the smaller one as limit
925  $max_filesize = ((int) $umf < (int) $pms)
926  ? $umf
927  : $pms;
928  if ((int) $pms == 0) $max_filesize = $umf;
929 
930  if (!$max_filesize) $max_filesize=max($umf, $pms);
931 
932  // gives out the limit as a littel notice :)
933  $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." $max_filesize.");
934 
935  }
936  }
937 
943  public function initCreationForm($a_mode = "create")
944  {
945  global $lng, $ilCtrl;
946 
947  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
948  $this->form = new ilPropertyFormGUI();
949 
950  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
951  $this->ctrl->setParameter($this, "new_type", $new_type);
952 
953  $this->form->setTarget(ilFrameTargetInfo::_getFrame("MainContent"));
954  $this->form->setTableWidth("600px");
955 
956  // title
957  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
958  $ti->setMaxLength(128);
959  $ti->setRequired(true);
960  //$ti->setSize();
961  $this->form->addItem($ti);
962 
963  // text area
964  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
965  //$ta->setCols();
966  //$ta->setRows();
967  $this->form->addItem($ta);
968 
969  $this->form->addCommandButton("save", $this->lng->txt($new_type."_add"));
970  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
971  $this->form->setTitle($this->lng->txt($new_type."_new"));
972  $this->form->setFormAction($this->ctrl->getFormAction($this, "save"));
973  }
974 
978  public function initImportForm()
979  {
980  global $lng, $ilCtrl;
981 
982  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
983  $this->form = new ilPropertyFormGUI();
984 
985  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
986  $this->ctrl->setParameter($this, "new_type", $new_type);
987 
988  $this->form->setTarget(ilFrameTargetInfo::_getFrame("MainContent"));
989  $this->form->setTableWidth("600px");
990 
991  // import file
992  $fi = new ilFileInputGUI($this->lng->txt("file"), "xmldoc");
993  $fi->setSuffixes(array("zip"));
994  $fi->setRequired(true);
995  $fi->setSize(30);
996  $this->form->addItem($fi);
997 
998  // validation
999  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_validate_file"), "validate");
1000  $cb->setInfo($this->lng->txt(""));
1001  $this->form->addItem($cb);
1002 
1003  $this->form->addCommandButton("importFile", $lng->txt("import"));
1004  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
1005 
1006  $this->form->setTitle($this->lng->txt("import_".$new_type));
1007  $this->form->setFormAction($ilCtrl->getFormAction($this));
1008 
1009  }
1010 
1014  function saveObject()
1015  {
1016  global $rbacadmin, $rbacsystem, $tpl;
1017 
1018  // always call parent method first to create an object_data entry & a reference
1019  //$newObj = parent::saveObject();
1020  // TODO: fix MetaDataGUI implementation to make it compatible to use parent call
1021  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
1022  {
1023  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
1024  return;
1025  }
1026 
1027  $this->initCreationForm();
1028  if ($this->form->checkInput())
1029  {
1030  // create and insert object in objecttree
1031  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
1032  $newObj = new ilObjContentObject();
1033  $newObj->setType($this->type);
1034  $newObj->setTitle($_POST["title"]);#"content object ".$newObj->getId()); // set by meta_gui->save
1035  $newObj->setDescription($_POST["desc"]); // set by meta_gui->save
1036  $newObj->create();
1037  $newObj->createReference();
1038  $newObj->putInTree($_GET["ref_id"]);
1039  $newObj->setPermissions($_GET["ref_id"]);
1040  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
1041  $newObj->setCleanFrames(true);
1042  $newObj->update();
1043 
1044  // setup rolefolder & default local roles (moderator)
1045  //$roles = $newObj->initDefaultRoles();
1046  // assign author role to creator of forum object
1047  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n");
1048  // create content object tree
1049  $newObj->createLMTree();
1050 
1051  // always send a message
1052  ilUtil::sendSuccess($this->lng->txt($this->type."_added"), true);
1053  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1054  "&baseClass=ilLMEditorGUI");
1055 
1056  }
1057  else
1058  {
1059  $this->form->setValuesByPost();
1060  $tpl->setContent($this->form->getHtml());
1061  }
1062  }
1063 
1067  function addBibItemObject($a_target = "")
1068  {
1069  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1070  $bib_gui =& new ilBibItemGUI();
1071  $bib_gui->setObject($this->object);
1072  $bibItemName = $_POST["bibItemName"] ? $_POST["bibItemName"] : $_GET["bibItemName"];
1073  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1074  if ($bibItemIndex == "")
1075  $bibItemIndex = 0;
1076  $bibItemPath = $_POST["bibItemPath"] ? $_POST["bibItemPath"] : $_GET["bibItemPath"];
1077  if ($bibItemName != "")
1078  {
1079  $bib_gui->bib_obj->add($bibItemName, $bibItemPath, $bibItemIndex);
1080  $data = $bib_gui->bib_obj->getElement("BibItem");
1081  $bibItemIndex = (count($data) - 1);
1082  }
1083  else
1084  {
1085  ilUtil::sendInfo($this->lng->txt("bibitem_choose_element"), true);
1086  }
1087  if ($a_target == "")
1088  {
1089  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1090  }
1091 
1092  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1093  }
1094 
1098  function addBibItem()
1099  {
1100  $this->setTabs();
1101 
1102  // questionable workaround to make this old stuff work
1103  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1104 
1105  $this->addBibItemObject($this->ctrl->getLinkTarget($this));
1106  }
1107 
1111  function deleteBibItemObject($a_target = "")
1112  {
1113  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1114  $bib_gui =& new ilBibItemGUI();
1115  $bib_gui->setObject($this->object);
1116  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1117  $bib_gui->bib_obj->delete($_GET["bibItemName"], $_GET["bibItemPath"], $bibItemIndex);
1118  if (strpos($bibItemIndex, ",") > 0)
1119  {
1120  $bibItemIndex = substr($bibItemIndex, 0, strpos($bibItemIndex, ","));
1121  }
1122  if ($a_target == "")
1123  {
1124  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1125  }
1126 
1127  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1128  }
1129 
1133  function deleteBibItem()
1134  {
1135  $this->setTabs();
1136 
1137  // questionable workaround to make this old stuff work
1138  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1139 
1140  $this->deleteBibItemObject($this->ctrl->getLinkTarget($this));
1141  }
1142 
1143 
1147  function editBibItemObject($a_target = "")
1148  {
1149  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1150  $bib_gui =& new ilBibItemGUI();
1151  $bib_gui->setObject($this->object);
1152  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1153  $bibItemIndex *= 1;
1154  if ($bibItemIndex < 0)
1155  {
1156  $bibItemIndex = 0;
1157  }
1158  if ($a_target == "")
1159  {
1160  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1161  }
1162 
1163  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1164  }
1165 
1169  function editBibItem()
1170  {
1171  $this->setTabs();
1172 
1173  // questionable workaround to make this old stuff work
1174  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1175 
1176  $this->editBibItemObject($this->ctrl->getLinkTarget($this));
1177  }
1178 
1182  function saveBibItemObject($a_target = "")
1183  {
1184  include_once "./Modules/LearningModule/classes/class.ilBibItemGUI.php";
1185  $bib_gui =& new ilBibItemGUI();
1186  $bib_gui->setObject($this->object);
1187  $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
1188  $bibItemIndex *= 1;
1189  if ($bibItemIndex < 0)
1190  {
1191  $bibItemIndex = 0;
1192  }
1193  $bibItemIndex = $bib_gui->save($bibItemIndex);
1194 
1195  if ($a_target == "")
1196  {
1197  $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
1198  }
1199 
1200  $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
1201  }
1202 
1206  function saveBibItem()
1207  {
1208  $this->setTabs();
1209 
1210  // questionable workaround to make this old stuff work
1211  $this->ctrl->setParameter($this, ilCtrl::IL_RTOKEN_NAME, $this->ctrl->getRequestToken());
1212 
1213  $this->saveBibItemObject($this->ctrl->getLinkTarget($this));
1214  }
1215 
1221  function exportObject()
1222  {
1223  return;
1224  }
1225 
1231  function importObject()
1232  {
1233  $this->createObject();
1234  return;
1235  }
1236 
1237 
1244  function importFileObject()
1245  {
1246  global $_FILES, $rbacsystem, $ilDB, $tpl;
1247 
1248  include_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
1249 
1250  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
1251  {
1252  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
1253  return;
1254  }
1255 
1256  $this->initImportForm();
1257  if ($this->form->checkInput())
1258  {
1259  // create and insert object in objecttree
1260  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
1261  $newObj = new ilObjContentObject();
1262  $newObj->setType($_GET["new_type"]);
1263  $newObj->setTitle($_FILES["xmldoc"]["name"]);
1264  $newObj->setDescription("");
1265  $newObj->create(true);
1266  $newObj->createReference();
1267  $newObj->putInTree($_GET["ref_id"]);
1268  $newObj->setPermissions($_GET["ref_id"]);
1269  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
1270 
1271  // create learning module tree
1272  $newObj->createLMTree();
1273 
1274  // create import directory
1275  $newObj->createImportDirectory();
1276 
1277  // copy uploaded file to import directory
1278  $file = pathinfo($_FILES["xmldoc"]["name"]);
1279  $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
1280 
1281  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"],
1282  $_FILES["xmldoc"]["name"], $full_path);
1283 
1284  //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
1285 
1286  // unzip file
1287  ilUtil::unzip($full_path);
1288 
1289  // determine filename of xml file
1290  $subdir = basename($file["basename"],".".$file["extension"]);
1291  $xml_file = $newObj->getImportDirectory()."/".$subdir."/".$subdir.".xml";
1292 
1293  // check whether subdirectory exists within zip file
1294  if (!is_dir($newObj->getImportDirectory()."/".$subdir))
1295  {
1296  $this->ilias->raiseError(sprintf($this->lng->txt("cont_no_subdir_in_zip"), $subdir),
1297  $this->ilias->error_obj->MESSAGE);
1298  }
1299 
1300  // check whether xml file exists within zip file
1301  if (!is_file($xml_file))
1302  {
1303  $this->ilias->raiseError(sprintf($this->lng->txt("cont_zip_file_invalid"), $subdir."/".$subdir.".xml"),
1304  $this->ilias->error_obj->MESSAGE);
1305  }
1306 
1307  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
1308  $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
1309  $contParser->startParsing();
1310  ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
1311  $newObj->MDUpdateListener('General');
1312 
1313  // import style
1314  $style_file = $newObj->getImportDirectory()."/".$subdir."/style.xml";
1315  $style_zip_file = $newObj->getImportDirectory()."/".$subdir."/style.zip";
1316  if (is_file($style_zip_file)) // try to import style.zip first
1317  {
1318  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1319  $style = new ilObjStyleSheet();
1320  $style->import($style_zip_file);
1321  $newObj->writeStyleSheetId($style->getId());
1322  }
1323  else if (is_file($style_file)) // try to import style.xml
1324  {
1325  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1326  $style = new ilObjStyleSheet();
1327  $style->import($style_file);
1328  $newObj->writeStyleSheetId($style->getId());
1329  }
1330 
1331  // delete import directory
1332  ilUtil::delDir($newObj->getImportDirectory());
1333 
1334  // validate
1335  if ($_POST["validate"])
1336  {
1337  $mess = $newObj->validatePages();
1338  }
1339 
1340  if ($mess == "")
1341  {
1342  ilUtil::sendSuccess($this->lng->txt($this->type."_added"),true);
1343 
1344  // handle internal links to this learning module
1345  include_once("./Services/COPage/classes/class.ilPageObject.php");
1346  ilPageObject::_handleImportRepositoryLinks($newObj->getImportId(),
1347  $newObj->getType(), $newObj->getRefId());
1348  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1349  "&baseClass=ilLMEditorGUI");
1350  }
1351  else
1352  {
1353  $link = '<a href="'."ilias.php?ref_id=".$newObj->getRefId().
1354  "&baseClass=ilLMEditorGUI".'" target="_top">'.$this->lng->txt("btn_next").'</a>';
1355  $tpl->setContent("<br />".$link."<br /><br />".$mess.$link);
1356  }
1357  }
1358  else
1359  {
1360  $this->form->setValuesByPost();
1361  $tpl->setContent($this->form->getHtml());
1362  }
1363  }
1364 
1368  function chapters()
1369  {
1370  global $tree, $lng, $ilCtrl, $ilUser;
1371 
1372  $this->setTabs();
1373 
1374  if ($ilUser->getPref("lm_js_chapter_editing") != "disable")
1375  {
1376  $ilCtrl->setParameter($this, "backcmd", "chapters");
1377 
1378  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
1379  $form_gui = new ilChapterHierarchyFormGUI($this->object->getType());
1380  $form_gui->setFormAction($ilCtrl->getFormAction($this));
1381  $form_gui->setTitle($this->object->getTitle());
1382  $form_gui->setIcon(ilUtil::getImagePath("icon_lm.gif"));
1383  $form_gui->setTree($this->lm_tree);
1384  $form_gui->setMaxDepth(0);
1385  $form_gui->setCurrentTopNodeId($this->tree->getRootId());
1386  $form_gui->addMultiCommand($lng->txt("delete"), "delete");
1387  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
1388  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
1389  $form_gui->setDragIcon(ilUtil::getImagePath("icon_st_s.gif"));
1390  $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
1391  $up_gui = ($this->object->getType() == "dbk")
1392  ? "ilobjdlbookgui"
1393  : "ilobjlearningmodulegui";
1394  $form_gui->setExplorerUpdater("tree", "tree_div",
1395  $ilCtrl->getLinkTargetByClass($up_gui, "explorer", "", true));
1396 
1397  $ctpl = new ilTemplate("tpl.chap_and_pages.html", true, true, "Modules/LearningModule");
1398  $ctpl->setVariable("HIERARCHY_FORM", $form_gui->getHTML());
1399  $ilCtrl->setParameter($this, "obj_id", "");
1400  $ctpl->setVariable("HREF_NO_JS_EDIT",
1401  $ilCtrl->getLinkTarget($this, "deactivateJSChapterEditing"));
1402  $ctpl->setVariable("TXT_NO_JS_EDIT",
1403  $lng->txt("cont_not_js_chap_editing"));
1404 
1405  $this->tpl->setContent($ctpl->get());
1406  }
1407  else
1408  {
1409  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", "Modules/LearningModule");
1410  $num = 0;
1411 
1412  $this->ctrl->setParameter($this, "backcmd", "chapters");
1413  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1414  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_chapters"));
1415  $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
1416 
1417  $cnt = 0;
1418  $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
1419  foreach ($childs as $child)
1420  {
1421  if($child["type"] != "st")
1422  {
1423  continue;
1424  }
1425 
1426  $this->tpl->setCurrentBlock("table_row");
1427  // color changing
1428  $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
1429 
1430  // checkbox
1431  $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
1432  $this->tpl->setVariable("CSS_ROW", $css_row);
1433  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.gif"));
1434 
1435  // link
1436  $this->ctrl->setParameter($this, "backcmd", "");
1437  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
1438  $this->tpl->setVariable("LINK_TARGET",
1439  $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view"));
1440 
1441  // title
1442  $this->tpl->setVariable("TEXT_CONTENT",
1444  $this->object->isActiveNumbering()));
1445 
1446  $this->tpl->parseCurrentBlock();
1447  }
1448 
1449  $paste_active = false;
1450  if ($ilUser->clipboardHasObjectsOfType("st"))
1451  {
1452  $paste_active = true;
1453  }
1454 
1455  if($cnt == 0 && !$paste_active)
1456  {
1457  $this->tpl->setCurrentBlock("notfound");
1458  $this->tpl->setVariable("NUM_COLS", 3);
1459  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1460  $this->tpl->parseCurrentBlock();
1461  }
1462  else
1463  {
1464  // SHOW VALID ACTIONS
1465  $this->tpl->setVariable("NUM_COLS", 3);
1466  if ($cnt > 0)
1467  {
1468  $acts = array("delete" => "delete", "cutChapter" => "cut",
1469  "copyChapter" => "copyChapter");
1470  }
1471  if ($paste_active)
1472  {
1473  $acts["pasteChapter"] = "pasteChapter";
1474  }
1475  $this->showActions($acts);
1476  }
1477 
1478  // SHOW POSSIBLE SUB OBJECTS
1479  $this->tpl->setVariable("NUM_COLS", 3);
1480  $subobj = array("st");
1481  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1482  $this->tpl->setCurrentBlock("add_object");
1483  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1484  $this->tpl->setVariable("BTN_NAME", "create");
1485  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
1486  $this->tpl->parseCurrentBlock();
1487 
1488  $this->tpl->setCurrentBlock("form");
1489  $this->tpl->parseCurrentBlock();
1490 
1491  $this->tpl->setVariable("HREF_JS_EDIT",
1492  $ilCtrl->getLinkTarget($this, "activateJSChapterEditing"));
1493  $this->tpl->setVariable("TXT_JS_EDIT",
1494  $lng->txt("cont_js_chap_editing"));
1495  }
1496  }
1497 
1498 
1499  /*
1500  * list all pages of learning module
1501  */
1502  function pages()
1503  {
1504  global $tree;
1505 
1506  $this->setTabs();
1507 
1508  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.all_pages.html", "Modules/LearningModule");
1509  $num = 0;
1510 
1511  $this->tpl->setCurrentBlock("form");
1512  $this->ctrl->setParameter($this, "backcmd", "pages");
1513  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1514  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_pages"));
1515  $this->tpl->setVariable("CONTEXT", $this->lng->txt("cont_usage"));
1516  $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
1517 
1518  $cnt = 0;
1519  $pages = ilLMPageObject::getPageList($this->object->getId());
1520  foreach ($pages as $page)
1521  {
1522  $this->tpl->setCurrentBlock("table_row");
1523 
1524  // check activation
1525  include_once("./Services/COPage/classes/class.ilPageObject.php");
1526  $lm_set = new ilSetting("lm");
1527  $active = ilPageObject::_lookupActive($page["obj_id"], $this->object->getType(),
1528  $lm_set->get("time_scheduled_page_activation"));
1529 
1530  // is page scheduled?
1531  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
1532  ilPageObject::_isScheduledActivation($page["obj_id"], $this->object->getType()))
1533  ? "_sc"
1534  : "";
1535 
1536  if (!$active)
1537  {
1538  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg_d".$img_sc.".gif"));
1539  $this->tpl->setVariable("IMG_ALT",
1540  $this->lng->txt("cont_page_deactivated"));
1541  }
1542  else
1543  {
1545  $this->object->getType()))
1546  {
1547  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg_del".$img_sc.".gif"));
1548  $this->tpl->setVariable("IMG_ALT",
1549  $this->lng->txt("cont_page_deactivated_elements"));
1550  }
1551  else
1552  {
1553  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg".$img_sc.".gif"));
1554  $this->tpl->setVariable("IMG_ALT",
1555  $this->lng->txt("pg"));
1556  }
1557  }
1558 
1559  // color changing
1560  $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
1561 
1562  // checkbox
1563  $this->tpl->setVariable("CHECKBOX_ID", $page["obj_id"]);
1564  $this->tpl->setVariable("CSS_ROW", $css_row);
1565 
1566  // link
1567  $this->ctrl->setParameter($this, "backcmd", "");
1568  $this->ctrl->setParameterByClass("ilLMPageObjectGUI", "obj_id", $page["obj_id"]);
1569 //echo "<br>:".$this->ctrl->getLinkTargetByClass("ilLMPageObjectGUI", "view").":";
1570  $this->tpl->setVariable("LINK_TARGET",
1571  $this->ctrl->getLinkTargetByClass("ilLMPageObjectGUI", "edit"));
1572 
1573  // title
1574  $this->tpl->setVariable("TEXT_CONTENT", $page["title"]);
1575 
1576  // context
1577  if ($this->lm_tree->isInTree($page["obj_id"]))
1578  {
1579  $path_str = $this->getContextPath($page["obj_id"]);
1580  }
1581  else
1582  {
1583  $path_str = "---";
1584  }
1585 
1586  // check whether page is header or footer
1587  $add_str = "";
1588  if ($page["obj_id"] == $this->object->getHeaderPage())
1589  {
1590  $add_str = " <b>(".$this->lng->txt("cont_header").")</b>";
1591  }
1592  if ($page["obj_id"] == $this->object->getFooterPage())
1593  {
1594  $add_str = " <b>(".$this->lng->txt("cont_footer").")</b>";
1595  }
1596 
1597  $this->tpl->setVariable("TEXT_CONTEXT", $path_str.$add_str);
1598 
1599 
1600  $this->tpl->parseCurrentBlock();
1601  }
1602  if($cnt == 0)
1603  {
1604  $this->tpl->setCurrentBlock("notfound");
1605  $this->tpl->setVariable("NUM_COLS", 4);
1606  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1607  $this->tpl->parseCurrentBlock();
1608  }
1609  else
1610  {
1611  $acts = array("delete" => "delete", "movePage" => "movePage", "copyPage" => "copyPage",
1612  "selectHeader" => "selectHeader", "selectFooter" => "selectFooter",
1613  "activatePages" => "cont_de_activate");
1615  ilEditClipboard::getAction() == "copy")
1616  {
1617  $acts["pastePage"] = "pastePage";
1618  }
1619 
1620  /*
1621  if (ilEditClipboard::getContentObjectType() == "st")
1622  {
1623  $acts["pasteChapter"] = "pasteChapter";
1624  }*/
1625  $this->tpl->setVariable("NUM_COLS", 4);
1626  $this->showActions($acts);
1627 
1628  // SHOW VALID ACTIONS
1629  /*
1630  $this->tpl->setCurrentBlock("operation_btn");
1631  $this->tpl->setVariable("BTN_NAME", "delete");
1632  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1633  $this->tpl->parseCurrentBlock();*/
1634 
1635  }
1636 
1637  // SHOW POSSIBLE SUB OBJECTS
1638  $this->tpl->setVariable("NUM_COLS", 4);
1639  //$this->showPossibleSubObjects("st");
1640  $subobj = array("pg");
1641  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1642  $this->tpl->setCurrentBlock("add_object");
1643  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1644  $this->tpl->setVariable("BTN_NAME", "create");
1645  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("create"));
1646  $this->tpl->parseCurrentBlock();
1647 
1648 
1649  $this->tpl->setCurrentBlock("form");
1650  $this->tpl->parseCurrentBlock();
1651 
1652  }
1653 
1657  function listLinks()
1658  {
1659  global $tpl;
1660 
1661  $this->setTabs();
1662 
1663  include_once("./Modules/LearningModule/classes/class.ilLinksTableGUI.php");
1664  $table_gui = new ilLinksTableGUI($this, "listLinks",
1665  $this->object->getId(), $this->object->getType());
1666 
1667  $tpl->setContent($table_gui->getHTML());
1668  }
1669 
1670 
1674  function activatePages()
1675  {
1676  if (is_array($_POST["id"]))
1677  {
1678  foreach($_POST["id"] as $id)
1679  {
1680  include_once("./Services/COPage/classes/class.ilPageObject.php");
1681  $act = ilPageObject::_lookupActive($id, $this->object->getType());
1682  ilPageObject::_writeActive($id, $this->object->getType(), !$act);
1683  }
1684  }
1685 
1686  $this->ctrl->redirect($this, "pages");
1687  }
1688 
1693  {
1694  global $ilCtrl, $ilUser;
1695 
1696  $ilUser->writePref("lm_js_chapter_editing", "disable");
1697  $ilCtrl->redirect($this, "chapters");
1698  }
1699 
1704  {
1705  global $ilCtrl, $ilUser;
1706 
1707  $ilUser->writePref("lm_js_chapter_editing", "enable");
1708  $ilCtrl->redirect($this, "chapters");
1709  }
1710 
1714  function pastePage()
1715  {
1717  {
1718  $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
1719  }
1720 
1721  // paste selected object
1723 
1724  // copy page, if action is copy
1725  if (ilEditClipboard::getAction() == "copy")
1726  {
1727  // check wether page belongs to lm
1729  == $this->object->getID())
1730  {
1731  $lm_page = new ilLMPageObject($this->object, $id);
1732  $new_page =& $lm_page->copy();
1733  $id = $new_page->getId();
1734  }
1735  else
1736  {
1737  // get page from other content object into current content object
1739  $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
1740  $lm_page = new ilLMPageObject($lm_obj, $id);
1741  $copied_nodes = array();
1742  $new_page =& $lm_page->copyToOtherContObject($this->object, $copied_nodes);
1743  $id = $new_page->getId();
1744  ilLMObject::updateInternalLinks($copied_nodes);
1745  }
1746  }
1747 
1748  // cut is not be possible in "all pages" form yet
1749  if (ilEditClipboard::getAction() == "cut")
1750  {
1751  // check wether page belongs not to lm
1753  != $this->object->getID())
1754  {
1756  $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
1757  $lm_page = new ilLMPageObject($lm_obj, $id);
1758  $lm_page->setLMId($this->object->getID());
1759  $lm_page->update();
1760  $page =& $lm_page->getPageObject();
1761  $page->buildDom();
1762  $page->setParentId($this->object->getID());
1763  $page->update();
1764  }
1765  }
1766 
1767 
1769  $this->ctrl->redirect($this, "pages");
1770  }
1771 
1775  function copyPage()
1776  {
1777  if(!isset($_POST["id"]))
1778  {
1779  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1780  }
1781 
1782  $items = ilUtil::stripSlashesArray($_POST["id"]);
1783  ilLMObject::clipboardCopy($this->object->getId(), $items);
1785 
1786  ilUtil::sendInfo($this->lng->txt("msg_copy_clipboard"), true);
1787 
1788  $this->ctrl->redirect($this, "pages");
1789  }
1790 
1798  function delete($a_parent_subobj_id = 0)
1799  {
1800  if(!isset($_POST["id"]))
1801  {
1802  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1803  }
1804 
1805  if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
1806  {
1807  $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
1808  }
1809 
1810  if ($a_parent_subobj_id == 0)
1811  {
1812  $this->setTabs();
1813  }
1814 
1815  // SAVE POST VALUES
1816  $_SESSION["saved_post"] = $_POST["id"];
1817 
1818  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/LearningModule");
1819 
1820  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1821 
1822  if ($a_parent_subobj_id != 0)
1823  {
1824  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "backcmd", $_GET["backcmd"]);
1825  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $a_parent_subobj_id);
1826  $this->tpl->setVariable("FORMACTION",
1827  $this->ctrl->getFormActionByClass("ilStructureObjectGUI"));
1828  }
1829  else
1830  {
1831  $this->ctrl->setParameter($this, "backcmd", $_GET["backcmd"]);
1832  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1833  }
1834  // BEGIN TABLE HEADER
1835  $this->tpl->setCurrentBlock("table_header");
1836  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
1837  $this->tpl->parseCurrentBlock();
1838 
1839  // END TABLE HEADER
1840 
1841  // BEGIN TABLE DATA
1842  $counter = 0;
1843 //var_dump($_POST);
1844  foreach($_POST["id"] as $id)
1845  {
1846  if ($id != IL_FIRST_NODE)
1847  {
1848  $obj =& new ilLMObject($this->object, $id);
1849  switch($obj->getType()) // ok that's not so nice, could be done better
1850  {
1851  case "pg":
1852  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg.gif"));
1853  break;
1854  case "st":
1855  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.gif"));
1856  break;
1857  }
1858  $this->tpl->setCurrentBlock("table_row");
1859  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow2","tblrow1"));
1860  $this->tpl->setVariable("TEXT_CONTENT", $obj->getTitle());
1861  $this->tpl->parseCurrentBlock();
1862  }
1863  }
1864 
1865  // cancel/confirm button
1866  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
1867  $buttons = array( "cancelDelete" => $this->lng->txt("cancel"),
1868  "confirmedDelete" => $this->lng->txt("confirm"));
1869  foreach ($buttons as $name => $value)
1870  {
1871  $this->tpl->setCurrentBlock("operation_btn");
1872  $this->tpl->setVariable("BTN_NAME",$name);
1873  $this->tpl->setVariable("BTN_VALUE",$value);
1874  $this->tpl->parseCurrentBlock();
1875  }
1876  }
1877 
1881  function cancelDelete()
1882  {
1883  session_unregister("saved_post");
1884 
1885  $this->ctrl->redirect($this, $_GET["backcmd"]);
1886 
1887  }
1888 
1896  function confirmedDelete($a_parent_subobj_id = 0)
1897  {
1898  $tree = new ilTree($this->object->getId());
1899  $tree->setTableNames('lm_tree','lm_data');
1900  $tree->setTreeTablePK("lm_id");
1901 
1902  // check number of objects
1903  if (!isset($_SESSION["saved_post"]))
1904  {
1905  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1906  }
1907 
1908  // delete all selected objects
1909  foreach ($_SESSION["saved_post"] as $id)
1910  {
1911  if ($id != IL_FIRST_NODE)
1912  {
1913  $obj =& ilLMObjectFactory::getInstance($this->object, $id, false);
1914  $node_data = $tree->getNodeData($id);
1915  if (is_object($obj))
1916  {
1917  $obj->setLMId($this->object->getId());
1918 
1919  include_once("classes/class.ilHistory.php");
1920  ilHistory::_createEntry($this->object->getId(), "delete_".$obj->getType(),
1921  array(ilLMObject::_lookupTitle($id), $id),
1922  $this->object->getType());
1923 
1924  $obj->delete();
1925  }
1926  if($tree->isInTree($id))
1927  {
1928  $tree->deleteTree($node_data);
1929  }
1930  }
1931  }
1932 
1933  // check the tree
1934  $this->object->checkTree();
1935 
1936  // feedback
1937  ilUtil::sendSuccess($this->lng->txt("info_deleted"),true);
1938 
1939  if ($a_parent_subobj_id == 0)
1940  {
1941  $this->ctrl->redirect($this, $_GET["backcmd"]);
1942  }
1943  }
1944 
1945 
1946 
1953  function getContextPath($a_endnode_id, $a_startnode_id = 1)
1954  {
1955  $path = "";
1956 
1957  $tmpPath = $this->lm_tree->getPathFull($a_endnode_id, $a_startnode_id);
1958 
1959  // count -1, to exclude the learning module itself
1960  for ($i = 1; $i < (count($tmpPath) - 1); $i++)
1961  {
1962  if ($path != "")
1963  {
1964  $path .= " > ";
1965  }
1966 
1967  $path .= $tmpPath[$i]["title"];
1968  }
1969 
1970  return $path;
1971  }
1972 
1973 
1974 
1980  function showActions($a_actions)
1981  {
1982  foreach ($a_actions as $name => $lng)
1983  {
1984  $d[$name] = array("name" => $name, "lng" => $lng);
1985  }
1986 
1987  $notoperations = array();
1988 
1989  $operations = array();
1990 
1991  if (is_array($d))
1992  {
1993  foreach ($d as $row)
1994  {
1995  if (!in_array($row["name"], $notoperations))
1996  {
1997  $operations[] = $row;
1998  }
1999  }
2000  }
2001 
2002  if (count($operations)>0)
2003  {
2004  foreach ($operations as $val)
2005  {
2006  $this->tpl->setCurrentBlock("operation_btn");
2007  $this->tpl->setVariable("BTN_NAME", $val["name"]);
2008  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
2009  $this->tpl->parseCurrentBlock();
2010  }
2011 
2012  $this->tpl->setCurrentBlock("operation");
2013  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
2014  $this->tpl->parseCurrentBlock();
2015  }
2016  }
2017 
2021  function perm()
2022  {
2023  $this->setTabs();
2024 
2025  $this->setFormAction("addRole", $this->ctrl->getLinkTarget($this, "addRole"));
2026  $this->setFormAction("permSave", $this->ctrl->getLinkTarget($this, "permSave"));
2027  $this->permObject();
2028  }
2029 
2030 
2034  function permSave()
2035  {
2036  $this->setReturnLocation("permSave", $this->ctrl->getLinkTarget($this, "perm"));
2037  $this->permSaveObject();
2038  }
2039 
2043  function info()
2044  {
2045  $this->setTabs();
2046  $this->infoObject();
2047  }
2048 
2049 
2053  function addRole()
2054  {
2055  $this->setReturnLocation("addRole", $this->ctrl->getLinkTarget($this, "perm"));
2056  $this->addRoleObject();
2057  }
2058 
2059 
2063  function owner()
2064  {
2065  $this->setTabs();
2066  $this->ownerObject();
2067  }
2068 
2069 
2073  function view()
2074  {
2075  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
2076  {
2077  $this->prepareOutput();
2079  }
2080  else
2081  {
2082  $this->viewObject();
2083  }
2084  }
2085 
2086 
2090  function moveChapter($a_parent_subobj_id = 0)
2091  {
2092  if(!isset($_POST["id"]))
2093  {
2094  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2095  }
2096 //echo "Hallo::"; exit;
2097  if(count($_POST["id"]) > 1)
2098  {
2099  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2100  }
2101 
2102  if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
2103  {
2104  $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
2105  }
2106 
2107  // SAVE POST VALUES
2108  ilEditClipboard::storeContentObject("st", $_POST["id"][0], "move");
2109 
2110  ilUtil::sendInfo($this->lng->txt("cont_chap_select_target_now"), true);
2111 
2112  if ($a_parent_subobj_id == 0)
2113  {
2114  $this->ctrl->redirect($this, "chapters");
2115  }
2116  }
2117 
2118 
2122  function copyChapter($a_parent_subobj_id = 0)
2123  {
2124  $this->copyItems();
2125  return;
2126 
2127  if(!isset($_POST["id"]))
2128  {
2129  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2130  }
2131 
2132  if(count($_POST["id"]) > 1)
2133  {
2134  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2135  }
2136 
2137  if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
2138  {
2139  $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
2140  }
2141 
2142  // SAVE POST VALUES
2143  ilEditClipboard::storeContentObject("st", $_POST["id"][0], "copy");
2144 
2145  ilUtil::sendInfo($this->lng->txt("cont_chap_copy_select_target_now"), true);
2146 
2147  if ($a_parent_subobj_id == 0)
2148  {
2149  $this->ctrl->redirect($this, "chapters");
2150  }
2151  }
2152 
2156  function pasteChapter($a_parent_subobj_id = 0)
2157  {
2158  return $this->insertChapterClip(false);
2159  return;
2160 
2162  {
2163  $this->ilias->raiseError($this->lng->txt("no_chapter_in_clipboard"),$this->ilias->error_obj->MESSAGE);
2164  }
2165 
2166  $target_tree = new ilTree($this->object->getId());
2167  $target_tree->setTableNames('lm_tree','lm_data');
2168  $target_tree->setTreeTablePK("lm_id");
2169 
2170  // check wether page belongs to lm
2172  != $this->object->getID())
2173  {
2175  $source_tree->setTableNames('lm_tree','lm_data');
2176  $source_tree->setTreeTablePK("lm_id");
2177  }
2178  else
2179  {
2180  $source_tree =& $target_tree;
2181  }
2182 
2183  // check, if target is within subtree
2185  $node = $source_tree->getNodeData($id);
2186  $subnodes = $source_tree->getSubtree($node);
2187  foreach ($subnodes as $subnode)
2188  {
2189  if($subnode["obj_id"] == $a_parent_subobj_id)
2190  {
2191  $this->ilias->raiseError($this->lng->txt("cont_target_within_source"),$this->ilias->error_obj->MESSAGE);
2192  }
2193  }
2194  if($_POST["id"][0] == $id)
2195  {
2197  $this->ctrl->redirect($this, "chapters");
2198  }
2199 
2200  // determin parent
2201  $parent = ($a_parent_subobj_id == 0)
2202  ? $target_tree->getRootId()
2203  : $a_parent_subobj_id;
2204 
2205  // determine target position
2206  if(!isset($_POST["id"]))
2207  {
2208  $target = IL_LAST_NODE;
2209  }
2210  else
2211  {
2212  $target = $_POST["id"][0];
2213  }
2214  if($target == IL_FIRST_NODE) // do not move a chapter in front of a page
2215  {
2216  $childs =& $target_tree->getChildsByType($parent, "pg");
2217  if (count($childs) != 0)
2218  {
2219  $target = $childs[count($childs) - 1]["obj_id"];
2220  }
2221  }
2222 
2223  //echo ":".$id.":";
2224  // delete old tree entries
2225 //echo "-".ilEditClipboard::getAction()."-";
2226  if (ilEditClipboard::getAction() == "move")
2227  {
2229  != $this->object->getID())
2230  {
2231  // we should never reach these lines, moving chapters from on
2232  // lm to another is not supported
2234  if ($a_parent_subobj_id == 0)
2235  {
2236  $this->ctrl->redirect($this, "chapters");
2237  }
2238  return;
2239  }
2240 
2241  $target_tree->deleteTree($node);
2242 
2243  if (!$target_tree->isInTree($id))
2244  {
2245  $target_tree->insertNode($id, $parent, $target);
2246 
2247  foreach ($subnodes as $node)
2248  {
2249  //$obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
2250  //$obj_data->putInTree($node["parent"]);
2251  if($node["obj_id"] != $id)
2252  {
2253  $target_tree->insertNode($node["obj_id"], $node["parent"]);
2254  }
2255  }
2256  }
2257  }
2258  else // copy
2259  {
2261 
2262  $copied_nodes = array();
2264  == $this->object->getID())
2265  {
2266  $source_obj = ilLMObjectFactory::getInstance($this->object, $id, true);
2267  $source_obj->setLMId($this->object->getId());
2268  $source_obj->copy($target_tree, $parent, $target, $copied_nodes);
2269  }
2270  else
2271  {
2272  $lm_id = ilLMObject::_lookupContObjID($id);
2273 
2274  $source_lm =& ilObjectFactory::getInstanceByObjId($lm_id);
2275  $source_obj = ilLMObjectFactory::getInstance($source_lm, $id, true);
2276  $source_obj->setLMId($lm_id);
2277  $source_obj->copy($target_tree, $parent, $target, $copied_nodes);
2278  }
2279  }
2280 
2281  ilLMObject::updateInternalLinks($copied_nodes);
2282 
2284 
2285  // check the tree
2286  $this->object->checkTree();
2287 
2288  if ($a_parent_subobj_id == 0)
2289  {
2290  $this->ctrl->redirect($this, "chapters");
2291  }
2292  }
2293 
2297  function movePage()
2298  {
2299  if(!isset($_POST["id"]))
2300  {
2301  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2302  }
2303 
2304  $items = ilUtil::stripSlashesArray($_POST["id"]);
2305  ilLMObject::clipboardCut($this->object->getId(), $items);
2307 
2308  $this->ctrl->redirect($this, "pages");
2309  }
2310 
2314  function cancel()
2315  {
2316  if ($_GET["new_type"] == "pg")
2317  {
2318  $this->ctrl->redirect($this, "pages");
2319  }
2320  else
2321  {
2322  $this->ctrl->redirect($this, "chapters");
2323  }
2324  }
2325 
2326 
2330  function export()
2331  {
2332  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2333  $cont_exp = new ilContObjectExport($this->object);
2334  $cont_exp->buildExportFile();
2335  $this->ctrl->redirect($this, "exportList");
2336  }
2337 
2341  function exportMenu()
2342  {
2343  // create xml export file button
2344  $this->tpl->setCurrentBlock("btn_cell");
2345  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "export"));
2346  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_xml"));
2347  $this->tpl->parseCurrentBlock();
2348 
2349  // create html export file button
2350  $this->tpl->setCurrentBlock("btn_cell");
2351  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportHTML"));
2352  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_html"));
2353  $this->tpl->parseCurrentBlock();
2354 
2355  // create scorm export file button
2356  $this->tpl->setCurrentBlock("btn_cell");
2357  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportSCORM"));
2358  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_scorm"));
2359  $this->tpl->parseCurrentBlock();
2360 
2361  // view last export log button
2362  if (is_file($this->object->getExportDirectory()."/export.log"))
2363  {
2364  $this->tpl->setCurrentBlock("btn_cell");
2365  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
2366  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
2367  $this->tpl->parseCurrentBlock();
2368  }
2369 
2370  }
2371 
2372  /*
2373  * list all export files
2374  */
2375  function exportList()
2376  {
2377  global $tree;
2378 
2379  $this->setTabs();
2380 
2381  //add template for view button
2382  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
2383 
2384  $this->exportMenu();
2385 
2386  $export_files = $this->object->getExportFiles();
2387 
2388  // create table
2389  require_once("./Services/Table/classes/class.ilTableGUI.php");
2390  $tbl = new ilTableGUI();
2391 
2392  // load files templates
2393  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
2394 
2395  // load template for table content data
2396  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", "Modules/LearningModule");
2397 
2398  $num = 0;
2399 
2400  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2401 
2402  $tbl->setTitle($this->lng->txt("cont_export_files"));
2403 
2404  $tbl->setHeaderNames(array("", $this->lng->txt("type"),
2405  $this->lng->txt("cont_file"),
2406  $this->lng->txt("cont_size"), $this->lng->txt("date") ));
2407 
2408  $cols = array("", "type", "file", "size", "date");
2409  $header_params = array("ref_id" => $_GET["ref_id"], "baseClass" => $_GET["baseClass"],
2410  "cmd" => "exportList", "cmdClass" => strtolower(get_class($this)));
2411  $tbl->setHeaderVars($cols, $header_params);
2412  $tbl->setColumnWidth(array("1%", "9%", "40%", "25%", "25%"));
2413 
2414  // control
2415  $tbl->setOrderColumn($_GET["sort_by"]);
2416  $tbl->setOrderDirection($_GET["sort_order"]);
2417  $tbl->setLimit($_GET["limit"]);
2418  $tbl->setOffset($_GET["offset"]);
2419  $tbl->setMaxCount($this->maxcount); // ???
2420  $tbl->disable("sort");
2421 
2422 
2423  $this->tpl->setVariable("COLUMN_COUNTS", 5);
2424 
2425  // delete button
2426  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
2427  $this->tpl->setCurrentBlock("tbl_action_btn");
2428  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
2429  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
2430  $this->tpl->parseCurrentBlock();
2431 
2432  $this->tpl->setCurrentBlock("tbl_action_btn");
2433  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
2434  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
2435  $this->tpl->parseCurrentBlock();
2436 
2437  $this->tpl->setCurrentBlock("tbl_action_btn");
2438  $this->tpl->setVariable("BTN_NAME", "publishExportFile");
2439  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_public_access"));
2440  $this->tpl->parseCurrentBlock();
2441 
2442  // footer
2443  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
2444  //$tbl->disable("footer");
2445 
2446  $tbl->setMaxCount(count($export_files));
2447  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
2448  $tbl->render();
2449  if(count($export_files) > 0)
2450  {
2451  $i=0;
2452  foreach($export_files as $exp_file)
2453  {
2454  $this->tpl->setCurrentBlock("tbl_content");
2455  $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
2456 
2457  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
2458  $this->tpl->setVariable("CSS_ROW", $css_row);
2459 
2460  $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
2461  $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
2462  ? " <b>(".$this->lng->txt("public").")<b>"
2463  : "";
2464  $this->tpl->setVariable("TXT_TYPE", $exp_file["type"].$public_str);
2465  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
2466 
2467  $file_arr = explode("__", $exp_file["file"]);
2468  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
2469 
2470  $this->tpl->parseCurrentBlock();
2471  }
2472  } //if is_array
2473  else
2474  {
2475  $this->tpl->setCurrentBlock("notfound");
2476  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
2477  $this->tpl->setVariable("NUM_COLS", 4);
2478  $this->tpl->parseCurrentBlock();
2479  }
2480 
2481  $this->tpl->parseCurrentBlock();
2482  }
2483 
2484  /*
2485  * view last export log
2486  */
2487  function viewExportLog()
2488  {
2489  global $tree;
2490 
2491  $this->setTabs();
2492 
2493  //add template for view button
2494  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
2495 
2496  $this->exportMenu();
2497 
2498  // load files templates
2499  $this->tpl->setVariable("ADM_CONTENT",
2500  nl2br(file_get_contents($this->object->getExportDirectory()."/export.log")));
2501 
2502  $this->tpl->parseCurrentBlock();
2503  }
2504 
2509  {
2510  if(!isset($_POST["file"]))
2511  {
2512  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2513  }
2514 
2515  if (count($_POST["file"]) > 1)
2516  {
2517  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2518  }
2519 
2520  $file = explode(":", $_POST["file"][0]);
2521  $export_dir = $this->object->getExportDirectory($file[0]);
2522  ilUtil::deliverFile($export_dir."/".$file[1],
2523  $file[1]);
2524  }
2525 
2530  {
2531  if(!isset($_POST["file"]))
2532  {
2533  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2534  }
2535  if (count($_POST["file"]) > 1)
2536  {
2537  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2538  }
2539 
2540  $file = explode(":", $_POST["file"][0]);
2541  $export_dir = $this->object->getExportDirectory($file[0]);
2542 
2543  if ($this->object->getPublicExportFile($file[0]) ==
2544  $file[1])
2545  {
2546  $this->object->setPublicExportFile($file[0], "");
2547  }
2548  else
2549  {
2550  $this->object->setPublicExportFile($file[0], $file[1]);
2551  }
2552  $this->object->update();
2553  $this->ctrl->redirect($this, "exportList");
2554  }
2555 
2559  function downloadPDFFile()
2560  {
2561  if(!isset($_POST["file"]))
2562  {
2563  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2564  }
2565 
2566  if (count($_POST["file"]) > 1)
2567  {
2568  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
2569  }
2570 
2571 
2572  $export_dir = $this->object->getOfflineDirectory();
2573  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
2574  $_POST["file"][0]);
2575  }
2576 
2581  {
2582  if(!isset($_POST["file"]))
2583  {
2584  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
2585  }
2586 
2587  $this->setTabs();
2588 
2589  // SAVE POST VALUES
2590  $_SESSION["ilExportFiles"] = $_POST["file"];
2591 
2592  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/LearningModule");
2593 
2594  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
2595 
2596  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2597 
2598  // BEGIN TABLE HEADER
2599  $this->tpl->setCurrentBlock("table_header");
2600  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
2601  $this->tpl->parseCurrentBlock();
2602 
2603  // BEGIN TABLE DATA
2604  $counter = 0;
2605  foreach($_POST["file"] as $file)
2606  {
2607  $file = explode(":", $file);
2608  $this->tpl->setCurrentBlock("table_row");
2609  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
2610  $this->tpl->setVariable("TEXT_CONTENT", $file[1]." (".$file[0].")");
2611  $this->tpl->parseCurrentBlock();
2612  }
2613 
2614  // cancel/confirm button
2615  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
2616  $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
2617  "deleteExportFile" => $this->lng->txt("confirm"));
2618  foreach ($buttons as $name => $value)
2619  {
2620  $this->tpl->setCurrentBlock("operation_btn");
2621  $this->tpl->setVariable("BTN_NAME",$name);
2622  $this->tpl->setVariable("BTN_VALUE",$value);
2623  $this->tpl->parseCurrentBlock();
2624  }
2625  }
2626 
2627 
2632  {
2633  session_unregister("ilExportFiles");
2634  $this->ctrl->redirect($this, "exportList");
2635  }
2636 
2637 
2641  function deleteExportFile()
2642  {
2643  foreach($_SESSION["ilExportFiles"] as $file)
2644  {
2645  $file = explode(":", $file);
2646  $export_dir = $this->object->getExportDirectory($file[0]);
2647 
2648  $exp_file = $export_dir."/".$file[1];
2649  $exp_dir = $export_dir."/".substr($file[1], 0, strlen($file[1]) - 4);
2650  if (@is_file($exp_file))
2651  {
2652  unlink($exp_file);
2653  }
2654  if (@is_dir($exp_dir))
2655  {
2656  ilUtil::delDir($exp_dir);
2657  }
2658  }
2659  $this->ctrl->redirect($this, "exportList");
2660  }
2661 
2666  function fixTreeConfirm()
2667  {
2668  $this->setTabs();
2669 
2670  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm.html");
2671 
2672  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2673 
2674  //
2675  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirmation"));
2676  $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("cont_fix_tree_confirm"));
2677  $this->tpl->setVariable("CMD_CANCEL", "cancelFixTree");
2678  $this->tpl->setVariable("CMD_OK", "fixTree");
2679  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2680  $this->tpl->setVariable("TXT_OK", $this->lng->txt("cont_fix_tree"));
2681  }
2682 
2688  function cancelObject($in_rep = false)
2689  {
2690  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
2691  //$this->ctrl->redirectByClass("ilrepositorygui", "frameset");
2692  }
2693 
2697  function cancelFixTree()
2698  {
2699  $this->ctrl->redirect($this, "properties");
2700  }
2701 
2705  function fixTree()
2706  {
2707  $this->object->fixTree();
2708  ilUtil::sendSuccess($this->lng->txt("cont_tree_fixed"), true);
2709  $this->ctrl->redirect($this, "properties");
2710  }
2711 
2715  function setilLMMenu($a_offline = false, $a_export_format = "",
2716  $a_active = "content", $a_use_global_tabs = false, $a_as_subtabs = false)
2717  {
2718  global $ilCtrl,$ilUser, $ilAccess, $ilTabs;
2719 
2720  if ($a_as_subtabs)
2721  {
2722  $addcmd = "addSubTabTarget";
2723  $getcmd = "getSubTabHTML";
2724  }
2725  else
2726  {
2727  $addcmd = "addTarget";
2728  $getcmd = "getHTML";
2729  }
2730 
2731  $active[$a_active] = true;
2732 
2733  if (!$this->object->isActiveLMMenu())
2734  {
2735  return "";
2736  }
2737 
2738  if ($a_use_global_tabs)
2739  {
2740  $tabs_gui = $ilTabs;
2741  }
2742  else
2743  {
2744  $tabs_gui = new ilTabsGUI();
2745  }
2746 
2747  // Determine whether the view of a learning resource should
2748  // be shown in the frameset of ilias, or in a separate window.
2749  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
2750  $showViewInFrameset = true;
2751 
2752  if ($showViewInFrameset && !$a_offline)
2753  {
2754  $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
2755  }
2756  else
2757  {
2758  $buttonTarget = "_top";
2759  }
2760 
2761  if ($a_export_format == "scorm")
2762  {
2763  $buttonTarget = "";
2764  }
2765 
2766  $requires_purchase_to_access = ilPaymentObject::_requiresPurchaseToAccess((int)$_GET['ref_id']);
2767 
2768  // info button
2769  if ($a_export_format != "scorm" && !$a_offline)
2770  {
2771  if (!$a_offline)
2772  {
2773  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2774  $link = $this->ctrl->getLinkTargetByClass(
2775  array("illmpresentationgui", "ilinfoscreengui"), "showSummary");
2776  }
2777  else
2778  {
2779  $link = "./info.html";
2780  }
2781 
2782  $tabs_gui->$addcmd(($requires_purchase_to_access ? 'buy' : 'info_short'), $link,
2783  "", "", $buttonTarget, $active["info"]);
2784  }
2785 
2786  // content
2787  if (!$a_offline && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2788  {
2789  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2790  $tabs_gui->$addcmd("content",
2791  $ilCtrl->getLinkTargetByClass("illmpresentationgui", "layout"),
2792  "", "", $buttonTarget, $active["content"]);
2793  }
2794 
2795  // table of contents
2796  if (!$requires_purchase_to_access && $this->object->isActiveTOC() && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2797  {
2798  if (!$a_offline)
2799  {
2800  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2801  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showTableOfContents");
2802  }
2803  else
2804  {
2805  $link = "./table_of_contents.html";
2806  }
2807 
2808  $tabs_gui->$addcmd("cont_toc", $link,
2809  "", "", $buttonTarget, $active["toc"]);
2810  }
2811 
2812  // print view
2813  if (!$requires_purchase_to_access && $this->object->isActivePrintView() && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2814  {
2815  if (!$a_offline) // has to be implemented for offline mode
2816  {
2817  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2818  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showPrintViewSelection");
2819  $tabs_gui->$addcmd("cont_print_view", $link,
2820  "", "", $buttonTarget, $active["print"]);
2821  }
2822  }
2823 
2824  // download
2825  if (!$requires_purchase_to_access && $ilUser->getId() == ANONYMOUS_USER_ID)
2826  {
2827  $is_public = $this->object->isActiveDownloadsPublic();
2828  }
2829  else if(!$requires_purchase_to_access)
2830  {
2831  $is_public = true;
2832  }
2833 
2834  if (!$requires_purchase_to_access && $this->object->isActiveDownloads() && !$a_offline && $is_public &&
2835  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2836  {
2837  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2838  $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showDownloadList");
2839  $tabs_gui->$addcmd("download", $link,
2840  "", "", $buttonTarget, $active["download"]);
2841  }
2842 
2843  if(!$requires_purchase_to_access)
2844  {
2845  // get user defined menu entries
2846  $this->__initLMMenuEditor();
2847  $entries = $this->lmme_obj->getMenuEntries(true);
2848 
2849  if (count($entries) > 0 && $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2850  {
2851  foreach ($entries as $entry)
2852  {
2853  // build goto-link for internal resources
2854  if ($entry["type"] == "intern")
2855  {
2856  $entry["link"] = ILIAS_HTTP_PATH."/goto.php?target=".$entry["link"];
2857  }
2858 
2859  // add http:// prefix if not exist
2860  if (!strstr($entry["link"],'://') && !strstr($entry["link"],'mailto:'))
2861  {
2862  $entry["link"] = "http://".$entry["link"];
2863  }
2864 
2865  if (!strstr($entry["link"],'mailto:'))
2866  {
2867  $entry["link"] = ilUtil::appendUrlParameterString($entry["link"], "ref_id=".$this->ref_id."&structure_id=".$this->obj_id);
2868  }
2869  $tabs_gui->$addcmd($entry["title"],
2870  $entry["link"],
2871  "", "", "_blank", "", true);
2872  }
2873  }
2874  }
2875 
2876  return $tabs_gui->$getcmd();
2877  }
2878 
2882  function createPDF()
2883  {
2884  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2885  $cont_exp = new ilContObjectExport($this->object, "pdf");
2886  $cont_exp->buildExportFile();
2887  $this->offlineList();
2888  }
2889 
2893  function exportHTML()
2894  {
2895  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2896  $cont_exp = new ilContObjectExport($this->object, "html");
2897  $cont_exp->buildExportFile();
2898 //echo $this->tpl->get();
2899  $this->ctrl->redirect($this, "exportList");
2900  }
2901 
2905  function exportSCORM()
2906  {
2907  require_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2908  $cont_exp = new ilContObjectExport($this->object, "scorm");
2909  $cont_exp->buildExportFile();
2910 //echo $this->tpl->get();
2911  $this->ctrl->redirect($this, "exportList");
2912  }
2913 
2919  function addLocations($a_omit_obj_id = false)
2920  {
2921  global $lng, $tree, $ilLocator;
2922 
2923  //$ilLocator->clearItems();
2924 
2925  $this->ctrl->addLocation(
2926  "...",
2927  "");
2928 
2929  $par_id = $tree->getParentId($_GET["ref_id"]);
2930  $this->ctrl->addLocation(
2932  "repository.php?cmd=frameset&amp;ref_id=".$par_id,
2933  ilFrameTargetInfo::_getFrame("MainContent"), $par_id);
2934  if (!$a_omit_obj_id)
2935  {
2936  $obj_id = $_GET["obj_id"];
2937  }
2938  $lmtree =& $this->object->getTree();
2939 
2940  if (($obj_id != 0) && $lmtree->isInTree($obj_id))
2941  {
2942  $path = $lmtree->getPathFull($obj_id);
2943  }
2944  else
2945  {
2946  $path = $lmtree->getPathFull($lmtree->getRootId());
2947  if ($obj_id != 0)
2948  {
2949  $path[] = array("type" => "pg", "child" => $this->obj_id,
2950  "title" => ilLMPageObject::_getPresentationTitle($this->obj_id));
2951  }
2952  }
2953 
2954  $modifier = 1;
2955 
2956  foreach ($path as $key => $row)
2957  {
2958  if ($row["child"] == 1)
2959  {
2960  $this->ctrl->setParameter($this, "obj_id", "");
2961  $this->ctrl->addLocation(
2962  $this->object->getTitle(),
2963  $this->ctrl->getLinkTarget($this, "chapters"), "", $_GET["ref_id"]);
2964  }
2965  else
2966  {
2967  $title = $row["title"];
2968  switch($row["type"])
2969  {
2970  case "st":
2971  $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $row["child"]);
2972  $this->ctrl->addLocation(
2973  $title,
2974  $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view"));
2975  break;
2976 
2977  case "pg":
2978  $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $row["child"]);
2979  $this->ctrl->addLocation(
2980  $title,
2981  $this->ctrl->getLinkTargetByClass("illmpageobjectgui", "edit"));
2982  break;
2983  }
2984  }
2985  }
2986  if (!$a_omit_obj_id)
2987  {
2988  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
2989  }
2990  }
2991 
2992 
2996  function setTabs()
2997  {
2998  // catch feedback message
2999  #include_once("classes/class.ilTabsGUI.php");
3000  #$tabs_gui =& new ilTabsGUI();
3001  $this->getTabs($this->tabs_gui);
3002  $this->tpl->setCurrentBlock("header_image");
3003  $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm_b.gif"));
3004  $this->tpl->parseCurrentBlock();
3005  $this->tpl->setCurrentBlock("content");
3006  #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
3007  $this->tpl->setVariable("HEADER", $this->object->getTitle());
3008  }
3009 
3015  function getTabs(&$tabs_gui)
3016  {
3017  global $rbacsystem,$ilUser;
3018 
3019  // back to upper context
3020  //$tabs_gui->getTargetsByObjectType($this, $this->object->getType());
3021 
3022  // info
3023  $tabs_gui->addTarget("info_short",
3024  $this->ctrl->getLinkTargetByClass("ilinfoscreengui",'showSummary'),
3025  "", "ilinfoscreengui");
3026 
3027  // chapters
3028  $tabs_gui->addTarget("cont_chapters",
3029  $this->ctrl->getLinkTarget($this, "chapters"),
3030  "chapters", get_class($this));
3031 
3032  // pages
3033  $tabs_gui->addTarget("cont_all_pages",
3034  $this->ctrl->getLinkTarget($this, "pages"),
3035  "pages", get_class($this));
3036 
3037  // properties
3038  $tabs_gui->addTarget("properties",
3039  $this->ctrl->getLinkTarget($this,'properties'),
3040  "properties", get_class($this));
3041 
3042  // meta data
3043  $tabs_gui->addTarget("meta_data",
3044  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
3045  "", "ilmdeditorgui");
3046 
3047  // links
3048  $tabs_gui->addTarget("cont_links",
3049  $this->ctrl->getLinkTarget($this,'listLinks'),
3050  "listLinks", get_class($this));
3051 
3052  if ($this->object->getType() == "lm")
3053  {
3054  // export
3055  $tabs_gui->addTarget("export",
3056  $this->ctrl->getLinkTarget($this, "exportList"),
3057  array("exportList", "viewExportLog"), get_class($this));
3058 
3059 
3060  if(@include_once('HTTP/Request.php'))
3061  {
3062  // link checker
3063  $tabs_gui->addTarget("link_check",
3064  $this->ctrl->getLinkTarget($this, "linkChecker"),
3065  array("linkChecker", "refreshLinkCheck"), get_class($this));
3066  }
3067  }
3068  else
3069  {
3070  // bibliographical data
3071  $tabs_gui->addTarget("bib_data",
3072  $this->ctrl->getLinkTarget($this, "editBibItem"),
3073  "editBibItem", get_class($this));
3074  }
3075  // learning progress
3076  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
3077  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()) and ($this->object->getType() == 'lm' or $this->object->getType() == 'dbk'))
3078  {
3079  $tabs_gui->addTarget('learning_progress',
3080  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
3081  '',
3082  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui','illmstatisticsgui'));
3083  }
3084 
3085  $tabs_gui->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
3086  , "history", get_class($this));
3087 
3088 
3089  // permissions
3090  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
3091  {
3092  $tabs_gui->addTarget("perm_settings",
3093  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
3094  }
3095  }
3096 
3100  function setSubTabs($a_active)
3101  {
3102  global $ilTabs, $ilSetting;
3103 
3104  if (in_array($a_active,
3105  array("cont_general_properties", "cont_style", "cont_lm_menu", "public_section")))
3106  {
3107  // general properties
3108  $ilTabs->addSubTabTarget("cont_general_properties",
3109  $this->ctrl->getLinkTarget($this, 'properties'),
3110  "", "");
3111 
3112  // style properties
3113  $ilTabs->addSubTabTarget("cont_style",
3114  $this->ctrl->getLinkTarget($this, 'editStyleProperties'),
3115  "", "");
3116 
3117  // menu properties
3118  $ilTabs->addSubTabTarget("cont_lm_menu",
3119  $this->ctrl->getLinkTarget($this, 'editMenuProperties'),
3120  "", "");
3121 
3122  if ($ilSetting->get("pub_section"))
3123  {
3124  if ($this->object->getType() != "dbk")
3125  {
3126  // public section
3127  $ilTabs->addSubTabTarget("public_section",
3128  $this->ctrl->getLinkTarget($this, 'editPublicSection'),
3129  "", "");
3130  }
3131  }
3132 
3133  $ilTabs->setSubTabActive($a_active);
3134  }
3135  }
3136 
3138  {
3139  global $ilTabs;
3140 
3141  $this->setTabs();
3142  $this->setSubTabs("public_section");
3143  $ilTabs->setTabActive("properties");
3144 
3145  switch ($this->object->getType())
3146  {
3147  case "lm":
3148  $gui_class = "ilobjlearningmodulegui";
3149  break;
3150 
3151  case "dlb":
3152  $gui_class = "ilobjdlbookgui";
3153  break;
3154  }
3155 
3156  // get learning module object
3157  $this->lm_obj =& new ilObjLearningModule($this->ref_id, true);
3158 
3159  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_public_selector.html");
3160  //$this->tpl->setVariable("ADM_CONTENT", "adm_content", "bla");
3161 
3162  require_once ("./Modules/LearningModule/classes/class.ilPublicSectionSelector.php");
3163  $exp = new ilPublicSectionSelector($this->ctrl->getLinkTarget($this, "view"),
3164  $this->object, $gui_class);
3165 
3166  $exp->setTargetGet("obj_id");
3167 
3168  // build html-output
3169  $exp->setOutput(0);
3170  $output = $exp->getOutput();
3171 
3172  // get page ids
3173  foreach ($exp->format_options as $node)
3174  {
3175  if (!$node["container"])
3176  {
3177  $pages[] = $node["child"];
3178  }
3179  }
3180 
3181  $js_pages = ilUtil::array_php2js($pages);
3182 
3183  //$this->tpl->setCurrentBlock("content");
3184  //var_dump($this->object->getPublicAccessMode());
3185  // access mode selector
3186  $this->tpl->setVariable("TXT_SET_PUBLIC_MODE", $this->lng->txt("set_public_mode"));
3187  $this->tpl->setVariable("TXT_CHOOSE_PUBLIC_MODE", $this->lng->txt("choose_public_mode"));
3188  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
3189  $select_public_mode = ilUtil::formSelect ($this->object->getPublicAccessMode(),"lm_public_mode",$modes, false, true);
3190  $this->tpl->setVariable("SELECT_PUBLIC_MODE", $select_public_mode);
3191 
3192  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("choose_public_pages"));
3193  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
3194  $this->tpl->setVariable("EXPLORER",$output);
3195  $this->tpl->setVariable("ONCLICK",$js_pages);
3196  $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
3197  $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
3198  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3199  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
3200  //$this->tpl->parseCurrentBlock();
3201 
3202  }
3203 
3205  {
3206  //var_dump($_POST["lm_public_mode"]);exit;
3207  $this->object->setPublicAccessMode($_POST["lm_public_mode"]);
3208  $this->object->updateProperties();
3209  ilLMObject::_writePublicAccessStatus($_POST["pages"],$this->object->getId());
3210  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3211  $this->ctrl->redirect($this, "editPublicSection");
3212  }
3213 
3219  function history()
3220  {
3221  $this->setTabs();
3222 
3223  require_once("classes/class.ilHistoryGUI.php");
3224  $hist_gui =& new ilHistoryGUI($this->object->getId() ,
3225  $this->object->getType());
3226  $hist_html = $hist_gui->getHistoryTable(
3227  $this->ctrl->getParameterArray($this, "history"),
3228  $this->object->isActiveHistoryUserComments()
3229  );
3230 
3231  $this->tpl->setVariable("ADM_CONTENT", $hist_html);
3232  }
3233 
3234 
3235  function linkChecker()
3236  {
3237  global $ilias,$ilUser;
3238 
3239  $this->__initLinkChecker();
3240 
3241  $invalid_links = $this->link_checker_obj->getInvalidLinksFromDB();
3242 
3243 
3244  $this->setTabs();
3245 
3246  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.link_check.html", "Modules/LearningModule");
3247 
3248  if($last_access = $this->link_checker_obj->getLastCheckTimestamp())
3249  {
3250  $this->tpl->setCurrentBlock("LAST_MODIFIED");
3251  $this->tpl->setVariable("AS_OF",$this->lng->txt('last_change').": ");
3252  $this->tpl->setVariable("LAST_CHECK",date('Y-m-d H:i:s',$last_access));
3253  $this->tpl->parseCurrentBlock();
3254  }
3255 
3256 
3257  $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
3258 
3259  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_lm.gif'));
3260  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('learning_module'));
3261  $this->tpl->setVariable("TITLE",$this->object->getTitle().' ('.$this->lng->txt('link_check').')');
3262  $this->tpl->setVariable("PAGE_TITLE",$this->lng->txt('cont_pg_title'));
3263  $this->tpl->setVariable("URL",$this->lng->txt('url'));
3264  $this->tpl->setVariable("OPTIONS",$this->lng->txt('edit'));
3265 
3266  if(!count($invalid_links))
3267  {
3268  $this->tpl->setCurrentBlock("no_invalid");
3269  $this->tpl->setVariable("TXT_NO_INVALID",$this->lng->txt('no_invalid_links'));
3270  $this->tpl->parseCurrentBlock();
3271  }
3272  else
3273  {
3274  $counter = 0;
3275  foreach($invalid_links as $invalid)
3276  {
3277  $this->tpl->setCurrentBlock("invalid_row");
3278  $this->tpl->setVariable("ROW_COLOR",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
3279  $this->tpl->setVariable("ROW_PAGE_TITLE",
3280  ilLMPageObject::_getPresentationTitle($invalid['page_id'],$this->object->getPageHeader()));
3281  $this->tpl->setVariable("ROW_URL",$invalid['url']);
3282 
3283 
3284  // EDIT IMAGE
3285  $this->ctrl->setParameterByClass('ilLMPageObjectGUI','obj_id',$invalid['page_id']);
3286  $this->tpl->setVariable("ROW_EDIT_LINK",$this->ctrl->getLinkTargetByClass('ilLMPageObjectGUI','edit'));
3287 
3288  $this->tpl->setVariable("ROW_IMG",ilUtil::getImagePath('edit.gif'));
3289  $this->tpl->setVariable("ROW_ALT_IMG",$this->lng->txt('edit'));
3290  $this->tpl->parseCurrentBlock();
3291  }
3292  }
3293  if((bool) $ilias->getSetting('cron_link_check'))
3294  {
3295  include_once './classes/class.ilLinkCheckNotify.php';
3296 
3297  // Show message block
3298  $this->tpl->setCurrentBlock("MESSAGE_BLOCK");
3299  $this->tpl->setVariable("INFO_MESSAGE",$this->lng->txt('link_check_message_a'));
3300  $this->tpl->setVariable("CHECK_MESSAGE",ilUtil::formCheckbox(
3301  ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(),$this->object->getId()),
3302  'link_check_message',
3303  1));
3304  $this->tpl->setVariable("INFO_MESSAGE_LONG",$this->lng->txt('link_check_message_b'));
3305  $this->tpl->parseCurrentBlock();
3306 
3307  // Show save button
3308  $this->tpl->setCurrentBlock("CRON_ENABLED");
3309  $this->tpl->setVariable("DOWNRIGHT_IMG",ilUtil::getImagePath('arrow_downright.gif'));
3310  $this->tpl->setVariable("BTN_SUBMIT_LINK_CHECK",$this->lng->txt('save'));
3311  $this->tpl->parseCurrentBlock();
3312  }
3313  $this->tpl->setVariable("BTN_REFRESH",$this->lng->txt('refresh'));
3314 
3315  return true;
3316 
3317  }
3318  function saveLinkCheck()
3319  {
3320  global $ilDB,$ilUser;
3321 
3322  include_once './classes/class.ilLinkCheckNotify.php';
3323 
3324  $link_check_notify =& new ilLinkCheckNotify($ilDB);
3325  $link_check_notify->setUserId($ilUser->getId());
3326  $link_check_notify->setObjId($this->object->getId());
3327 
3328  if($_POST['link_check_message'])
3329  {
3330  ilUtil::sendSuccess($this->lng->txt('link_check_message_enabled'));
3331  $link_check_notify->addNotifier();
3332  }
3333  else
3334  {
3335  ilUtil::sendSuccess($this->lng->txt('link_check_message_disabled'));
3336  $link_check_notify->deleteNotifier();
3337  }
3338  $this->linkChecker();
3339 
3340  return true;
3341  }
3342 
3343 
3344 
3345  function refreshLinkCheck()
3346  {
3347  $this->__initLinkChecker();
3348 
3349  if(!$this->link_checker_obj->checkPear())
3350  {
3351  ilUtil::sendFailure($this->lng->txt('missing_pear_library'));
3352  $this->linkChecker();
3353 
3354  return false;
3355  }
3356 
3357  $this->link_checker_obj->checkLinks();
3358  ilUtil::sendSuccess($this->lng->txt('link_checker_refreshed'));
3359 
3360  $this->linkChecker();
3361 
3362  return true;
3363  }
3364 
3366  {
3367  global $ilDB;
3368 
3369  include_once './classes/class.ilLinkChecker.php';
3370 
3371  $this->link_checker_obj =& new ilLinkChecker($ilDB,false);
3372  $this->link_checker_obj->setObjId($this->object->getId());
3373 
3374  return true;
3375  }
3376 
3378  {
3379  include_once './Modules/LearningModule/classes/class.ilLMMenuEditor.php';
3380 
3381  $this->lmme_obj =& new ilLMMenuEditor();
3382  $this->lmme_obj->setObjId($this->object->getId());
3383 
3384  return true;
3385  }
3386 
3390  function addMenuEntry()
3391  {
3392  $this->setTabs();
3393 
3394  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_entry_form.html","Modules/LearningModule");
3395 
3396  if (isset($_GET["link_ref_id"]))
3397  {
3398  $obj_type = ilObject::_lookupType($_GET["link_ref_id"],true);
3399  $obj_id = ilObject::_lookupObjectId($_GET["link_ref_id"]);
3401 
3402  $target_link = $obj_type."_".$_GET["link_ref_id"];
3403  $this->tpl->setVariable("TITLE", $title);
3404  $this->tpl->setVariable("TARGET", $target_link);
3405  $this->tpl->setVariable("LINK_REF_ID", $_GET["link_ref_id"]);
3406  }
3407 
3408 
3409  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "saveMenuEntry"));
3410  $this->tpl->setVariable("TXT_NEW_ENTRY", $this->lng->txt("lm_menu_new_entry"));
3411  $this->tpl->setVariable("TXT_TARGET", $this->lng->txt("lm_menu_entry_target"));
3412  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("lm_menu_entry_title"));
3413  $this->tpl->setVariable("BTN_NAME", "saveMenuEntry");
3414  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
3415  $this->tpl->setVariable("BTN_NAME2", "showEntrySelector");
3416  $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("lm_menu_select_internal_object"));
3417  //$this->tpl->parseCurrentBlock();
3418 
3419  }
3420 
3424  function saveMenuEntry()
3425  {
3426  global $ilCtrl;
3427 
3428  // check title and target
3429  if (empty($_POST["title"]))
3430  {
3431  //$this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
3432  ilUtil::sendFailure($this->lng->txt("please_enter_title") , true);
3433  $ilCtrl->redirect($this, "addMenuEntry");
3434  }
3435  if (empty($_POST["target"]))
3436  {
3437  //$this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
3438  ilUtil::sendFailure($this->lng->txt("please_enter_target"), true);
3439  $ilCtrl->redirect($this, "addMenuEntry");
3440  }
3441 
3442  $this->__initLMMenuEditor();
3443  $this->lmme_obj->setTitle($_POST["title"]);
3444  $this->lmme_obj->setTarget($_POST["target"]);
3445  $this->lmme_obj->setLinkRefId($_POST["link_ref_id"]);
3446 
3447  if ($_POST["link_ref_id"])
3448  {
3449  $this->lmme_obj->setLinkType("intern");
3450  }
3451 
3452  $this->lmme_obj->create();
3453 
3454  ilUtil::sendSuccess($this->lng->txt("msg_entry_added"), true);
3455  $this->ctrl->redirect($this, "editMenuProperties");
3456  }
3457 
3461  function deleteMenuEntry()
3462  {
3463  if (empty($_GET["menu_entry"]))
3464  {
3465  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3466  }
3467 
3468  $this->__initLMMenuEditor();
3469  $this->lmme_obj->delete($_GET["menu_entry"]);
3470 
3471  ilUtil::sendSuccess($this->lng->txt("msg_entry_removed"), true);
3472  $this->ctrl->redirect($this, "editMenuProperties");
3473  }
3474 
3478  function editMenuEntry()
3479  {
3480  if (empty($_GET["menu_entry"]))
3481  {
3482  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3483  }
3484 
3485  $this->__initLMMenuEditor();
3486  $this->lmme_obj->readEntry($_GET["menu_entry"]);
3487 
3488  $this->setTabs();
3489 
3490  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_entry_form.html","Modules/LearningModule");
3491 
3492  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
3493  $this->tpl->setVariable("TXT_NEW_ENTRY", $this->lng->txt("lm_menu_edit_entry"));
3494  $this->tpl->setVariable("TXT_TARGET", $this->lng->txt("lm_menu_entry_target"));
3495  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("lm_menu_entry_title"));
3496  $this->tpl->setVariable("TITLE", $this->lmme_obj->getTitle());
3497  $this->tpl->setVariable("TARGET", $this->lmme_obj->getTarget());
3498  $this->tpl->setVariable("ENTRY_ID", $this->lmme_obj->getEntryId());
3499  $this->tpl->setVariable("BTN_NAME", "updateMenuEntry");
3500  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
3501  $this->tpl->setVariable("BTN_NAME2", "showEntrySelector");
3502  $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("lm_menu_select_internal_object"));
3503  //$this->tpl->parseCurrentBlock();
3504  }
3505 
3509  function updateMenuEntry()
3510  {
3511  if (empty($_POST["menu_entry"]))
3512  {
3513  $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
3514  }
3515 
3516  // check title and target
3517  if (empty($_POST["title"]))
3518  {
3519  $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
3520  }
3521  if (empty($_POST["target"]))
3522  {
3523  $this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
3524  }
3525 
3526  $this->__initLMMenuEditor();
3527  $this->lmme_obj->readEntry($_POST["menu_entry"]);
3528  $this->lmme_obj->setTitle($_POST["title"]);
3529  $this->lmme_obj->setTarget($_POST["target"]);
3530  $this->lmme_obj->update();
3531 
3532  ilUtil::sendSuccess($this->lng->txt("msg_entry_updated"), true);
3533  $this->ctrl->redirect($this, "editMenuProperties");
3534  }
3535 
3537  {
3538  $this->setTabs();
3539 
3540  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_object_selector.html","Modules/LearningModule");
3541 
3542  ilUtil::sendInfo($this->lng->txt("lm_menu_select_object_to_add"));
3543 
3544  require_once ("./Modules/LearningModule/classes/class.ilLMMenuObjectSelector.php");
3545  $exp = new ilLMMenuObjectSelector($this->ctrl->getLinkTarget($this,'test'),$this);
3546 
3547  $exp->setExpand($_GET["lm_menu_expand"] ? $_GET["lm_menu_expand"] : $this->tree->readRootId());
3548  $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showEntrySelector'));
3549  $exp->setTargetGet("ref_id");
3550  $exp->setRefId($this->cur_ref_id);
3551 
3552  $sel_types = array('mcst', 'mep', 'cat', 'lm','dbk','glo','frm','exc','tst','svy', 'chat', 'wiki', 'sahs',
3553  "crs", "grp", "book", "tst", "file");
3554  $exp->setSelectableTypes($sel_types);
3555 
3556  //$exp->setTargetGet("obj_id");
3557 
3558  // build html-output
3559  $exp->setOutput(0);
3560  $output = $exp->getOutput();
3561 
3562  // get page ids
3563  foreach ($exp->format_options as $node)
3564  {
3565  if (!$node["container"])
3566  {
3567  $pages[] = $node["child"];
3568  }
3569  }
3570 
3571  //$this->tpl->setCurrentBlock("content");
3572  //var_dump($this->object->getPublicAccessMode());
3573  // access mode selector
3574  $this->tpl->setVariable("TXT_SET_PUBLIC_MODE", $this->lng->txt("set_public_mode"));
3575  $this->tpl->setVariable("TXT_CHOOSE_PUBLIC_MODE", $this->lng->txt("choose_public_mode"));
3576  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
3577  $select_public_mode = ilUtil::formSelect ($this->object->getPublicAccessMode(),"lm_public_mode",$modes, false, true);
3578  $this->tpl->setVariable("SELECT_PUBLIC_MODE", $select_public_mode);
3579 
3580  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("choose_public_pages"));
3581  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
3582  $this->tpl->setVariable("EXPLORER",$output);
3583  $this->tpl->setVariable("ONCLICK",$js_pages);
3584  $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
3585  $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
3586  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3587  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
3588  //$this->tpl->parseCurrentBlock();
3589  }
3590 
3594  function selectHeader()
3595  {
3596  if(!isset($_POST["id"]))
3597  {
3598  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3599  }
3600  if(count($_POST["id"]) > 1)
3601  {
3602  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3603  }
3604  if ($_POST["id"][0] != $this->object->getHeaderPage())
3605  {
3606  $this->object->setHeaderPage($_POST["id"][0]);
3607  }
3608  else
3609  {
3610  $this->object->setHeaderPage(0);
3611  }
3612  $this->object->updateProperties();
3613  $this->ctrl->redirect($this, "pages");
3614  }
3615 
3619  function selectFooter()
3620  {
3621  if(!isset($_POST["id"]))
3622  {
3623  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
3624  }
3625  if(count($_POST["id"]) > 1)
3626  {
3627  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
3628  }
3629  if ($_POST["id"][0] != $this->object->getFooterPage())
3630  {
3631  $this->object->setFooterPage($_POST["id"][0]);
3632  }
3633  else
3634  {
3635  $this->object->setFooterPage(0);
3636  }
3637  $this->object->updateProperties();
3638  $this->ctrl->redirect($this, "pages");
3639  }
3640 
3644  function saveAllTitles()
3645  {
3646  global $ilCtrl;
3647 
3648  ilLMObject::saveTitles($this->object, ilUtil::stripSlashesArray($_POST["title"]));
3649 
3650  $ilCtrl->redirect($this, "chapters");
3651  }
3652 
3656  function insertChapter()
3657  {
3658  global $ilCtrl;
3659 
3660  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
3661 
3664 
3665  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) // insert after node id
3666  {
3667  $parent_id = $this->lm_tree->getParentId($node_id);
3668  $target = $node_id;
3669  }
3670  else // insert as first child
3671  {
3672  $parent_id = $node_id;
3673  $target = IL_FIRST_NODE;
3674  }
3675 
3676  for ($i = 1; $i <= $num; $i++)
3677  {
3678  $chap = new ilStructureObject($this->object);
3679  $chap->setType("st");
3680  $chap->setTitle("");
3681  $chap->setLMId($this->object->getId());
3682  $chap->create();
3683  ilLMObject::putInTree($chap, $parent_id, $target);
3684  }
3685 
3686  $ilCtrl->redirect($this, "chapters");
3687  }
3688 
3693  {
3694  global $ilUser, $ilCtrl, $ilLog;
3695 
3696  include_once("./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php");
3697 
3698  if ($ilUser->getPref("lm_js_chapter_editing") != "disable")
3699  {
3700  //$num = ilChapterHierarchyFormGUI::getPostMulti();
3703  }
3704  else
3705  {
3706  if (!isset($_POST["id"]) || $_POST["id"][0] == -1)
3707  {
3708  $node_id = $this->lm_tree->getRootId();
3709  $first_child = true;
3710  }
3711  else
3712  {
3713  $node_id = $_POST["id"][0];
3714  $first_child = false;
3715  }
3716  }
3717 
3718  $ilLog->write("InsertChapterClip, num: $num, node_id: $node_id, ".
3719  " getPostFirstChild ".ilChapterHierarchyFormGUI::getPostFirstChild());
3720 
3721  if (!$first_child) // insert after node id
3722  {
3723  $parent_id = $this->lm_tree->getParentId($node_id);
3724  $target = $node_id;
3725  }
3726  else // insert as first child
3727  {
3728  $parent_id = $node_id;
3729  $target = IL_FIRST_NODE;
3730  }
3731 
3732  // copy and paste
3733  $chapters = $ilUser->getClipboardObjects("st", true);
3734  $copied_nodes = array();
3735  foreach ($chapters as $chap)
3736  {
3737  $ilLog->write("Call pasteTree, Target LM: ".$this->object->getId().", Chapter ID: ".$chap["id"]
3738  .", Parent ID: ".$parent_id.", Target: ".$target);
3739  $cid = ilLMObject::pasteTree($this->object, $chap["id"], $parent_id,
3740  $target, $chap["insert_time"], $copied_nodes,
3741  (ilEditClipboard::getAction() == "copy"));
3742  $target = $cid;
3743  }
3744  ilLMObject::updateInternalLinks($copied_nodes);
3745 
3746  if (ilEditClipboard::getAction() == "cut")
3747  {
3748  $ilUser->clipboardDeleteObjectsOfType("pg");
3749  $ilUser->clipboardDeleteObjectsOfType("st");
3751  }
3752 
3753  $this->object->checkTree();
3754  $ilCtrl->redirect($this, "chapters");
3755  }
3756 
3762  function _goto($a_target)
3763  {
3764  global $ilAccess, $ilErr, $lng;
3765 
3766  if ($ilAccess->checkAccess("read", "", $a_target))
3767  {
3768  $_GET["baseClass"] = "ilLMPresentationGUI";
3769  $_GET["ref_id"] = $a_target;
3770  include("ilias.php");
3771  exit;
3772  } else if ($ilAccess->checkAccess("visible", "", $a_target))
3773  {
3774  $_GET["baseClass"] = "ilLMPresentationGUI";
3775  $_GET["ref_id"] = $a_target;
3776  $_GET["cmd"] = "infoScreen";
3777  include("ilias.php");
3778  exit;
3779  }
3780  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
3781  {
3782  $_GET["cmd"] = "frameset";
3783  $_GET["target"] = "";
3784  $_GET["ref_id"] = ROOT_FOLDER_ID;
3785  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
3786  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
3787  include("repository.php");
3788  exit;
3789  }
3790 
3791 
3792  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
3793  }
3794 
3798  function cutItems($a_return = "chapters")
3799  {
3800  global $ilCtrl, $lng;
3801 
3802  $items = ilUtil::stripSlashesArray($_POST["id"]);
3803  if (!is_array($items))
3804  {
3805  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3806  $ilCtrl->redirect($this, $a_return);
3807  }
3808 
3809  $todel = array(); // delete IDs < 0 (needed for non-js editing)
3810  foreach($items as $k => $item)
3811  {
3812  if ($item < 0)
3813  {
3814  $todel[] = $k;
3815  }
3816  }
3817  foreach($todel as $k)
3818  {
3819  unset($items[$k]);
3820  }
3821  ilLMObject::clipboardCut($this->object->getId(), $items);
3823  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
3824 
3825  $ilCtrl->redirect($this, $a_return);
3826  }
3827 
3831  function copyItems()
3832  {
3833  global $ilCtrl, $lng;
3834 
3835  $items = ilUtil::stripSlashesArray($_POST["id"]);
3836  if (!is_array($items))
3837  {
3838  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
3839  $ilCtrl->redirect($this, "chapters");
3840  }
3841 
3842  $todel = array(); // delete IDs < 0 (needed for non-js editing)
3843  foreach($items as $k => $item)
3844  {
3845  if ($item < 0)
3846  {
3847  $todel[] = $k;
3848  }
3849  }
3850  foreach($todel as $k)
3851  {
3852  unset($items[$k]);
3853  }
3854  ilLMObject::clipboardCopy($this->object->getId(), $items);
3856  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
3857  $ilCtrl->redirect($this, "chapters");
3858  }
3859 
3863  function cutChapter()
3864  {
3865  $this->cutItems("chapters");
3866  }
3867 
3868 } // END class.ilObjContentObjectGUI
3869 ?>