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