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