ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjContentObject.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once "./Services/Object/classes/class.ilObject.php";
5require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
6
21{
25 protected $user;
26
30 protected $tpl;
31
35 protected $locator;
36
37 public $lm_tree;
38 public $meta_data;
39 public $layout;
40 public $style_id;
41 public $pg_header;
42 public $online;
43 public $for_translation = 0;
44 protected $rating;
45 protected $rating_pages;
46 public $auto_glossaries = array();
47
48 private $import_dir = '';
52 protected $log;
53
60 public function __construct($a_id = 0, $a_call_by_reference = true)
61 {
62 global $DIC;
63
64 $this->user = $DIC->user();
65 $this->db = $DIC->database();
66 $this->tree = $DIC->repositoryTree();
67 $this->lng = $DIC->language();
68 $this->error = $DIC["ilErr"];
69 if (isset($DIC["tpl"])) {
70 $this->tpl = $DIC["tpl"];
71 }
72 if (isset($DIC["ilLocator"])) {
73 $this->locator = $DIC["ilLocator"];
74 }
75
76 // this also calls read() method! (if $a_id is set)
77 parent::__construct($a_id, $a_call_by_reference);
78
79 $this->log = ilLoggerFactory::getLogger('lm');
80
81 $this->mob_ids = array();
82 $this->file_ids = array();
83 $this->q_ids = array();
84 }
85
89 public function create($a_no_meta_data = false)
90 {
91 $this->setOfflineStatus(true);
92 parent::create();
93
94 // meta data will be created by
95 // import parser
96 if (!$a_no_meta_data) {
97 $this->createMetaData();
98 }
99
100 $this->createProperties();
101 $this->updateAutoGlossaries();
102 }
103
104
105
109 public function read()
110 {
112
113 parent::read();
114 # echo "Content<br>\n";
115
116 $this->lm_tree = new ilTree($this->getId());
117 $this->lm_tree->setTableNames('lm_tree', 'lm_data');
118 $this->lm_tree->setTreeTablePK("lm_id");
119
120 $this->readProperties();
121
122 // read auto glossaries
123 $set = $ilDB->query(
124 "SELECT * FROM lm_glossaries " .
125 " WHERE lm_id = " . $ilDB->quote($this->getId(), "integer")
126 );
127 $glos = array();
128 while ($rec = $ilDB->fetchAssoc($set)) {
129 $glos[] = $rec["glo_id"];
130 }
131 $this->setAutoGlossaries($glos);
132
133 //parent::read();
134 }
135
141 public function getTitle()
142 {
143 return parent::getTitle();
144 }
145
149 public function setTitle($a_title)
150 {
151 parent::setTitle($a_title);
152 // $this->meta_data->setTitle($a_title);
153 }
154
160 public function getDescription()
161 {
162 return parent::getDescription();
163 }
164
168 public function setDescription($a_description)
169 {
170 parent::setDescription($a_description);
171 // $this->meta_data->setDescription($a_description);
172 }
173
174
175 public function getImportId()
176 {
177 return $this->import_id;
178 }
179
180 public function setImportId($a_id)
181 {
182 $this->import_id = $a_id;
183 }
184
190 public function setLayoutPerPage($a_val)
191 {
192 $this->layout_per_page = $a_val;
193 }
194
200 public function getLayoutPerPage()
201 {
202 return $this->layout_per_page;
203 }
204
210 public function setDisableDefaultFeedback($a_val)
211 {
212 $this->disable_def_feedback = $a_val;
213 }
214
221 {
222 return $this->disable_def_feedback;
223 }
224
230 public function setProgressIcons($a_val)
231 {
232 $this->progr_icons = $a_val;
233 }
234
240 public function getProgressIcons()
241 {
242 return $this->progr_icons;
243 }
244
250 public function setStoreTries($a_val)
251 {
252 $this->store_tries = $a_val;
253 }
254
260 public function getStoreTries()
261 {
262 return $this->store_tries;
263 }
264
270 public function setRestrictForwardNavigation($a_val)
271 {
272 $this->restrict_forw_nav = $a_val;
273 }
274
281 {
282 return $this->restrict_forw_nav;
283 }
284
285
286 public function &getTree()
287 {
288 return $this->lm_tree;
289 }
290
294 public function update()
295 {
296 $this->updateMetaData();
298 $this->updateProperties();
299 $this->updateAutoGlossaries();
300 }
301
308 public function updateAutoGlossaries()
309 {
311
312 // update auto glossaries
313 $ilDB->manipulate(
314 "DELETE FROM lm_glossaries WHERE " .
315 " lm_id = " . $ilDB->quote($this->getId(), "integer")
316 );
317 foreach ($this->getAutoGlossaries() as $glo_id) {
318 $ilDB->manipulate("INSERT INTO lm_glossaries " .
319 "(lm_id, glo_id) VALUES (" .
320 $ilDB->quote($this->getId(), "integer") . "," .
321 $ilDB->quote($glo_id, "integer") .
322 ")");
323 }
324 }
325
326
330 public function import()
331 {
332 // nothing to do. just display the dialogue in Out
333 return;
334 }
335
336
341 public function putInTree($a_parent)
342 {
344
345 // put this object in tree under $a_parent
346 parent::putInTree($a_parent);
347
348 // make new tree for this object
349 //$tree->addTree($this->getId());
350 }
351
352
358 public function createLMTree()
359 {
360 $this->lm_tree = new ilTree($this->getId());
361 $this->lm_tree->setTreeTablePK("lm_id");
362 $this->lm_tree->setTableNames('lm_tree', 'lm_data');
363 $this->lm_tree->addTree($this->getId(), 1);
364 }
365
371 public function setAutoGlossaries($a_val)
372 {
373 $this->auto_glossaries = array();
374 if (is_array($a_val)) {
375 foreach ($a_val as $v) {
376 $v = (int) $v;
377 if ($v > 0 && ilObject::_lookupType($v) == "glo" &&
378 !in_array($v, $this->auto_glossaries)) {
379 $this->auto_glossaries[] = $v;
380 }
381 }
382 }
383 }
384
390 public function getAutoGlossaries()
391 {
393 }
394
401 public function removeAutoGlossary($a_glo_id)
402 {
403 $glo_ids = array();
404 foreach ($this->getAutoGlossaries() as $g) {
405 if ($g != $a_glo_id) {
406 $glo_ids[] = $g;
407 }
408 }
409 $this->setAutoGlossaries($glo_ids);
410 }
411
412
416 public function addFirstChapterAndPage()
417 {
419
420 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
421 include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
422 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
423
424 $root_id = $this->lm_tree->getRootId();
425
426 // chapter
427 $chap = new ilStructureObject($this);
428 $chap->setType("st");
429 $chap->setTitle($lng->txt("cont_new_chap"));
430 $chap->setLMId($this->getId());
431 $chap->create();
432 ilLMObject::putInTree($chap, $root_id, IL_FIRST_NODE);
433
434 // page
435 $page = new ilLMPageObject($this);
436 $page->setType("pg");
437 $page->setTitle($lng->txt("cont_new_page"));
438 $page->setLMId($this->getId());
439 $page->create();
440 ilLMObject::putInTree($page, $chap->getId(), IL_FIRST_NODE);
441 }
442
448 public function setForTranslation($a_val)
449 {
450 $this->for_translation = $a_val;
451 }
452
458 public function getForTranslation()
459 {
461 }
462
466 public function &getLMTree()
467 {
468 return $this->lm_tree;
469 }
470
471
477 public function createImportDirectory()
478 {
480
481 $lm_data_dir = ilUtil::getDataDir() . "/lm_data";
482 if (!is_writable($lm_data_dir)) {
483 $ilErr->raiseError("Content object Data Directory (" . $lm_data_dir
484 . ") not writeable.", $ilErr->FATAL);
485 }
486
487 // create learning module directory (data_dir/lm_data/lm_<id>)
488 $lm_dir = $lm_data_dir . "/lm_" . $this->getId();
489 ilUtil::makeDir($lm_dir);
490 if (!@is_dir($lm_dir)) {
491 $ilErr->raiseError("Creation of Learning Module Directory failed.", $ilErr->FATAL);
492 }
493
494 // create import subdirectory (data_dir/lm_data/lm_<id>/import)
495 $import_dir = $lm_dir . "/import";
497 if (!@is_dir($import_dir)) {
498 $ilErr->raiseError("Creation of Import Directory failed.", $ilErr->FATAL);
499 }
500 }
501
505 public function getDataDirectory()
506 {
507 return ilUtil::getDataDir() . "/lm_data" .
508 "/lm_" . $this->getId();
509 }
510
514 public function getImportDirectory()
515 {
516 if (strlen($this->import_dir)) {
517 return $this->import_dir;
518 }
519
520 $import_dir = ilUtil::getDataDir() . "/lm_data" .
521 "/lm_" . $this->getId() . "/import";
522 if (@is_dir($import_dir)) {
523 return $import_dir;
524 } else {
525 return false;
526 }
527 }
528
535 public function setImportDirectory($a_import_dir)
536 {
537 $this->import_dir = $a_import_dir;
538 }
539
540
546 public function createExportDirectory($a_type = "xml")
547 {
549
550 $lm_data_dir = ilUtil::getDataDir() . "/lm_data";
551 if (!is_writable($lm_data_dir)) {
552 $ilErr->raiseError("Content object Data Directory (" . $lm_data_dir
553 . ") not writeable.", $ilErr->FATAL);
554 }
555 // create learning module directory (data_dir/lm_data/lm_<id>)
556 $lm_dir = $lm_data_dir . "/lm_" . $this->getId();
557 ilUtil::makeDir($lm_dir);
558 if (!@is_dir($lm_dir)) {
559 $ilErr->raiseError("Creation of Learning Module Directory failed.", $ilErr->FATAL);
560 }
561 // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
562 switch ($a_type) {
563 // scorm
564 case "scorm":
565 $export_dir = $lm_dir . "/export_scorm";
566 break;
567
568 default: // = xml
569 if (substr($a_type, 0, 4) == "html") {
570 $export_dir = $lm_dir . "/export_" . $a_type;
571 } else {
572 $export_dir = $lm_dir . "/export";
573 }
574 break;
575 }
576 ilUtil::makeDir($export_dir);
577
578 if (!@is_dir($export_dir)) {
579 $ilErr->raiseError("Creation of Export Directory failed.", $ilErr->FATAL);
580 }
581 }
582
586 public function getExportDirectory($a_type = "xml")
587 {
588 switch ($a_type) {
589 case "scorm":
590 $export_dir = ilUtil::getDataDir() . "/lm_data" . "/lm_" . $this->getId() . "/export_scorm";
591 break;
592
593 default: // = xml
594 if (substr($a_type, 0, 4) == "html") {
595 $export_dir = ilUtil::getDataDir() . "/lm_data" . "/lm_" . $this->getId() . "/export_" . $a_type;
596 } else {
597 $export_dir = ilUtil::getDataDir() . "/lm_data" . "/lm_" . $this->getId() . "/export";
598 }
599 break;
600 }
601 return $export_dir;
602 }
603
604
615 public function delete()
616 {
618
619 // always call parent delete function first!!
620 if (!parent::delete()) {
621 return false;
622 }
623
624 // delete lm object data
625 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
627
628 // delete meta data of content object
629 $this->deleteMetaData();
630
631
632 // delete learning module tree
633 $this->lm_tree->removeTree($this->lm_tree->getTreeId());
634
635 // delete data directory
637
638 // delete content object record
639 $q = "DELETE FROM content_object WHERE id = " .
640 $ilDB->quote($this->getId(), "integer");
641 $ilDB->manipulate($q);
642
643 // delete lm menu entries
644 $q = "DELETE FROM lm_menu WHERE lm_id = " .
645 $ilDB->quote($this->getId(), "integer");
646 $ilDB->manipulate($q);
647
648 // remove auto glossary entries
649 $ilDB->manipulate(
650 "DELETE FROM lm_glossaries WHERE " .
651 " lm_id = " . $ilDB->quote($this->getId(), "integer")
652 );
653
654
655 return true;
656 }
657
658
664 public function getLayout()
665 {
666 return $this->layout;
667 }
668
674 public function setLayout($a_layout)
675 {
676 $this->layout = $a_layout;
677 }
678
682 public function getStyleSheetId()
683 {
684 return $this->style_id;
685 }
686
690 public function setStyleSheetId($a_style_id)
691 {
692 $this->style_id = $a_style_id;
693 }
694
698 public function writeStyleSheetId($a_style_id)
699 {
701
702 $q = "UPDATE content_object SET " .
703 " stylesheet = " . $ilDB->quote((int) $a_style_id, "integer") .
704 " WHERE id = " . $ilDB->quote($this->getId(), "integer");
705 $ilDB->manipulate($q);
706
707 $this->style_id = $a_style_id;
708 }
709
716 public static function writeHeaderPage($a_lm_id, $a_page_id)
717 {
718 global $DIC;
719
720 $ilDB = $DIC->database();
721
722 $ilDB->manipulate(
723 "UPDATE content_object SET " .
724 " header_page = " . $ilDB->quote($a_page_id, "integer") .
725 " WHERE id = " . $ilDB->quote($a_lm_id, "integer")
726 );
727 }
728
735 public static function writeFooterPage($a_lm_id, $a_page_id)
736 {
737 global $DIC;
738
739 $ilDB = $DIC->database();
740
741 $ilDB->manipulate(
742 "UPDATE content_object SET " .
743 " footer_page = " . $ilDB->quote($a_page_id, "integer") .
744 " WHERE id = " . $ilDB->quote($a_lm_id, "integer")
745 );
746 }
747
748
752 public static function _moveLMStyles($a_from_style, $a_to_style)
753 {
754 global $DIC;
755
756 $ilDB = $DIC->database();
757
758 if ($a_from_style < 0) { // change / delete all individual styles
759 $q = "SELECT stylesheet FROM content_object, style_data " .
760 " WHERE content_object.stylesheet = style_data.id " .
761 " AND style_data.standard = " . $ilDB->quote(0, "integer") .
762 " AND content_object.stylesheet > " . $ilDB->quote(0, "integer");
763 $style_set = $ilDB->query($q);
764 while ($style_rec = $ilDB->fetchAssoc($style_set)) {
765 // assign learning modules to new style
766 $q = "UPDATE content_object SET " .
767 " stylesheet = " . $ilDB->quote((int) $a_to_style, "integer") .
768 " WHERE stylesheet = " . $ilDB->quote($style_rec["stylesheet"], "integer");
769 $ilDB->manipulate($q);
770
771 // delete style
772 $style_obj = ilObjectFactory::getInstanceByObjId($style_rec["stylesheet"]);
773 $style_obj->delete();
774 }
775 } else {
776 $q = "UPDATE content_object SET " .
777 " stylesheet = " . $ilDB->quote((int) $a_to_style, "integer") .
778 " WHERE stylesheet = " . $ilDB->quote($a_from_style, "integer");
779 $ilDB->manipulate($q);
780 }
781 }
782
790 protected static function _lookup($a_obj_id, $a_field)
791 {
792 global $DIC;
793
794 $ilDB = $DIC->database();
795 $ilLog = $DIC["ilLog"];
796
797 $q = "SELECT " . $a_field . " FROM content_object " .
798 " WHERE id = " . $ilDB->quote($a_obj_id, "integer");
799
800 $res = $ilDB->query($q);
801 $rec = $ilDB->fetchAssoc($res);
802
803 return $rec[$a_field];
804 }
805
812 public static function _lookupRestrictForwardNavigation($a_obj_id)
813 {
814 return self::_lookup($a_obj_id, "restrict_forw_nav");
815 }
816
820 public static function _lookupStyleSheetId($a_cont_obj_id)
821 {
822 global $DIC;
823
824 $ilDB = $DIC->database();
825
826 $q = "SELECT stylesheet FROM content_object " .
827 " WHERE id = " . $ilDB->quote($a_cont_obj_id, "integer");
828 $res = $ilDB->query($q);
829 $sheet = $ilDB->fetchAssoc($res);
830
831 return $sheet["stylesheet"];
832 }
833
837 public static function _lookupContObjIdByStyleId($a_style_id)
838 {
839 global $DIC;
840
841 $ilDB = $DIC->database();
842
843 $q = "SELECT id FROM content_object " .
844 " WHERE stylesheet = " . $ilDB->quote($a_style_id, "integer");
845 $res = $ilDB->query($q);
846 $obj_ids = array();
847 while ($cont = $ilDB->fetchAssoc($res)) {
848 $obj_ids[] = $cont["id"];
849 }
850 return $obj_ids;
851 }
852
856 public static function _lookupDisableDefaultFeedback($a_id)
857 {
858 global $DIC;
859
860 $ilDB = $DIC->database();
861
862 $q = "SELECT disable_def_feedback FROM content_object " .
863 " WHERE id = " . $ilDB->quote($a_id, "integer");
864 $res = $ilDB->query($q);
865 $rec = $ilDB->fetchAssoc($res);
866
867 return $rec["disable_def_feedback"];
868 }
869
873 public static function _lookupStoreTries($a_id)
874 {
875 global $DIC;
876
877 $ilDB = $DIC->database();
878
879 $q = "SELECT store_tries FROM content_object " .
880 " WHERE id = " . $ilDB->quote($a_id, "integer");
881 $res = $ilDB->query($q);
882 $rec = $ilDB->fetchAssoc($res);
883
884 return $rec["store_tries"];
885 }
886
887
893 public static function _getNrOfAssignedLMs($a_style_id)
894 {
895 global $DIC;
896
897 $ilDB = $DIC->database();
898
899 $q = "SELECT count(*) as cnt FROM content_object " .
900 " WHERE stylesheet = " . $ilDB->quote($a_style_id, "integer");
901 $cset = $ilDB->query($q);
902 $crow = $ilDB->fetchAssoc($cset);
903
904 return (int) $crow["cnt"];
905 }
906
907
911 public static function _getNrLMsIndividualStyles()
912 {
913 global $DIC;
914
915 $ilDB = $DIC->database();
916
917 // joining with style table (not perfectly nice)
918 $q = "SELECT count(*) as cnt FROM content_object, style_data " .
919 " WHERE stylesheet = style_data.id " .
920 " AND standard = " . $ilDB->quote(0, "integer");
921 $cset = $ilDB->query($q);
922 $crow = $ilDB->fetchAssoc($cset);
923
924 return (int) $crow["cnt"];
925 }
926
930 public static function _getNrLMsNoStyle()
931 {
932 global $DIC;
933
934 $ilDB = $DIC->database();
935
936 $q = "SELECT count(*) as cnt FROM content_object " .
937 " WHERE stylesheet = " . $ilDB->quote(0, "integer");
938 $cset = $ilDB->query($q);
939 $crow = $ilDB->fetchAssoc($cset);
940
941 return (int) $crow["cnt"];
942 }
943
949 public static function _deleteStyleAssignments($a_style_id)
950 {
951 global $DIC;
952
953 $ilDB = $DIC->database();
954
955 $q = "UPDATE content_object SET " .
956 " stylesheet = " . $ilDB->quote(0, "integer") .
957 " WHERE stylesheet = " . $ilDB->quote((int) $a_style_id, "integer");
958
959 $ilDB->manipulate($q);
960 }
961
965 public function getPageHeader()
966 {
967 return $this->pg_header;
968 }
969
975 public function setPageHeader($a_pg_header = IL_CHAPTER_TITLE)
976 {
977 $this->pg_header = $a_pg_header;
978 }
979
983 public function getTOCMode()
984 {
985 return $this->toc_mode;
986 }
987
991 public function getPublicAccessMode()
992 {
993 return $this->public_access_mode;
994 }
995
1001 public function setTOCMode($a_toc_mode = "chapters")
1002 {
1003 $this->toc_mode = $a_toc_mode;
1004 }
1005
1006 public function setActiveLMMenu($a_act_lm_menu)
1007 {
1008 $this->lm_menu_active = $a_act_lm_menu;
1009 }
1010
1011 public function isActiveLMMenu()
1012 {
1013 return $this->lm_menu_active;
1014 }
1015
1016 public function setActiveTOC($a_toc)
1017 {
1018 $this->toc_active = $a_toc;
1019 }
1020
1021 public function isActiveTOC()
1022 {
1023 return $this->toc_active;
1024 }
1025
1026 public function setActiveNumbering($a_num)
1027 {
1028 $this->numbering = $a_num;
1029 }
1030
1031 public function isActiveNumbering()
1032 {
1033 return $this->numbering;
1034 }
1035
1036 public function setActivePrintView($a_print)
1037 {
1038 $this->print_view_active = $a_print;
1039 }
1040
1041 public function isActivePrintView()
1042 {
1043 return $this->print_view_active;
1044 }
1045
1046 public function setActivePreventGlossaryAppendix($a_print)
1047 {
1048 $this->prevent_glossary_appendix_active = $a_print;
1049 }
1050
1052 {
1053 return $this->prevent_glossary_appendix_active;
1054 }
1055
1061 public function setHideHeaderFooterPrint($a_val)
1062 {
1063 $this->hide_header_footer_print = $a_val;
1064 }
1065
1072 {
1073 return $this->hide_header_footer_print;
1074 }
1075
1076 public function setActiveDownloads($a_down)
1077 {
1078 $this->downloads_active = $a_down;
1079 }
1080
1081 public function isActiveDownloads()
1082 {
1083 return $this->downloads_active;
1084 }
1085
1086 public function setActiveDownloadsPublic($a_down)
1087 {
1088 $this->downloads_public_active = $a_down;
1089 }
1090
1091 public function isActiveDownloadsPublic()
1092 {
1093 return $this->downloads_public_active;
1094 }
1095
1096 public function setPublicNotes($a_pub_notes)
1097 {
1098 $this->pub_notes = $a_pub_notes;
1099 }
1100
1101 public function publicNotes()
1102 {
1103 return $this->pub_notes;
1104 }
1105
1106 public function setCleanFrames($a_clean)
1107 {
1108 $this->clean_frames = $a_clean;
1109 }
1110
1111 public function cleanFrames()
1112 {
1113 return $this->clean_frames;
1114 }
1115
1116 public function setHistoryUserComments($a_comm)
1117 {
1118 $this->user_comments = $a_comm;
1119 }
1120
1121 public function setPublicAccessMode($a_mode)
1122 {
1123 $this->public_access_mode = $a_mode;
1124 }
1125
1127 {
1128 return $this->user_comments;
1129 }
1130
1131 public function setHeaderPage($a_pg)
1132 {
1133 $this->header_page = $a_pg;
1134 }
1135
1136 public function getHeaderPage()
1137 {
1138 return $this->header_page;
1139 }
1140
1141 public function setFooterPage($a_pg)
1142 {
1143 $this->footer_page = $a_pg;
1144 }
1145
1146 public function getFooterPage()
1147 {
1148 return $this->footer_page;
1149 }
1150
1154 public function readProperties()
1155 {
1156 $ilDB = $this->db;
1157
1158 $q = "SELECT * FROM content_object WHERE id = " .
1159 $ilDB->quote($this->getId(), "integer");
1160 $lm_set = $ilDB->query($q);
1161 $lm_rec = $ilDB->fetchAssoc($lm_set);
1162 $this->setLayout($lm_rec["default_layout"]);
1163 $this->setStyleSheetId((int) $lm_rec["stylesheet"]);
1164 $this->setPageHeader($lm_rec["page_header"]);
1165 $this->setTOCMode($lm_rec["toc_mode"]);
1166 $this->setActiveTOC(ilUtil::yn2tf($lm_rec["toc_active"]));
1167 $this->setActiveNumbering(ilUtil::yn2tf($lm_rec["numbering"]));
1168 $this->setActivePrintView(ilUtil::yn2tf($lm_rec["print_view_active"]));
1169 $this->setActivePreventGlossaryAppendix(ilUtil::yn2tf($lm_rec["no_glo_appendix"]));
1170 $this->setHideHeaderFooterPrint($lm_rec["hide_head_foot_print"]);
1171 $this->setActiveDownloads(ilUtil::yn2tf($lm_rec["downloads_active"]));
1172 $this->setActiveDownloadsPublic(ilUtil::yn2tf($lm_rec["downloads_public_active"]));
1173 $this->setActiveLMMenu(ilUtil::yn2tf($lm_rec["lm_menu_active"]));
1174 $this->setCleanFrames(ilUtil::yn2tf($lm_rec["clean_frames"]));
1175 $this->setHeaderPage((int) $lm_rec["header_page"]);
1176 $this->setFooterPage((int) $lm_rec["footer_page"]);
1177 $this->setHistoryUserComments(ilUtil::yn2tf($lm_rec["hist_user_comments"]));
1178 $this->setPublicAccessMode($lm_rec["public_access_mode"]);
1179 $this->setPublicExportFile("xml", $lm_rec["public_xml_file"]);
1180 $this->setPublicExportFile("html", $lm_rec["public_html_file"]);
1181 $this->setPublicExportFile("scorm", $lm_rec["public_scorm_file"]);
1182 $this->setLayoutPerPage($lm_rec["layout_per_page"]);
1183 $this->setRating($lm_rec["rating"]);
1184 $this->setRatingPages($lm_rec["rating_pages"]);
1185 $this->setDisableDefaultFeedback($lm_rec["disable_def_feedback"]);
1186 $this->setProgressIcons($lm_rec["progr_icons"]);
1187 $this->setStoreTries($lm_rec["store_tries"]);
1188 $this->setRestrictForwardNavigation($lm_rec["restrict_forw_nav"]);
1189
1190 // #14661
1191 include_once("./Services/Notes/classes/class.ilNote.php");
1192 $this->setPublicNotes(ilNote::commentsActivated($this->getId(), 0, $this->getType()));
1193
1194 $this->setForTranslation($lm_rec["for_translation"]);
1195 }
1196
1200 public function updateProperties()
1201 {
1202 $ilDB = $this->db;
1203
1204 // force clean_frames to be set, if layout per page is activated
1205 if ($this->getLayoutPerPage()) {
1206 $this->setCleanFrames(true);
1207 }
1208
1209 $q = "UPDATE content_object SET " .
1210 " default_layout = " . $ilDB->quote($this->getLayout(), "text") . ", " .
1211 " stylesheet = " . $ilDB->quote($this->getStyleSheetId(), "integer") . "," .
1212 " page_header = " . $ilDB->quote($this->getPageHeader(), "text") . "," .
1213 " toc_mode = " . $ilDB->quote($this->getTOCMode(), "text") . "," .
1214 " toc_active = " . $ilDB->quote(ilUtil::tf2yn($this->isActiveTOC()), "text") . "," .
1215 " numbering = " . $ilDB->quote(ilUtil::tf2yn($this->isActiveNumbering()), "text") . "," .
1216 " print_view_active = " . $ilDB->quote(ilUtil::tf2yn($this->isActivePrintView()), "text") . "," .
1217 " no_glo_appendix = " . $ilDB->quote(ilUtil::tf2yn($this->isActivePreventGlossaryAppendix()), "text") . "," .
1218 " hide_head_foot_print = " . $ilDB->quote($this->getHideHeaderFooterPrint(), "integer") . "," .
1219 " downloads_active = " . $ilDB->quote(ilUtil::tf2yn($this->isActiveDownloads()), "text") . "," .
1220 " downloads_public_active = " . $ilDB->quote(ilUtil::tf2yn($this->isActiveDownloadsPublic()), "text") . "," .
1221 " clean_frames = " . $ilDB->quote(ilUtil::tf2yn($this->cleanFrames()), "text") . "," .
1222 " hist_user_comments = " . $ilDB->quote(ilUtil::tf2yn($this->isActiveHistoryUserComments()), "text") . "," .
1223 " public_access_mode = " . $ilDB->quote($this->getPublicAccessMode(), "text") . "," .
1224 " public_xml_file = " . $ilDB->quote($this->getPublicExportFile("xml"), "text") . "," .
1225 " public_html_file = " . $ilDB->quote($this->getPublicExportFile("html"), "text") . "," .
1226 " public_scorm_file = " . $ilDB->quote($this->getPublicExportFile("scorm"), "text") . "," .
1227 " header_page = " . $ilDB->quote($this->getHeaderPage(), "integer") . "," .
1228 " footer_page = " . $ilDB->quote($this->getFooterPage(), "integer") . "," .
1229 " lm_menu_active = " . $ilDB->quote(ilUtil::tf2yn($this->isActiveLMMenu()), "text") . ", " .
1230 " layout_per_page = " . $ilDB->quote($this->getLayoutPerPage(), "integer") . ", " .
1231 " rating = " . $ilDB->quote($this->hasRating(), "integer") . ", " .
1232 " rating_pages = " . $ilDB->quote($this->hasRatingPages(), "integer") . ", " .
1233 " disable_def_feedback = " . $ilDB->quote($this->getDisableDefaultFeedback(), "integer") . ", " .
1234 " progr_icons = " . $ilDB->quote($this->getProgressIcons(), "integer") . ", " .
1235 " store_tries = " . $ilDB->quote($this->getStoreTries(), "integer") . ", " .
1236 " restrict_forw_nav = " . $ilDB->quote($this->getRestrictForwardNavigation(), "integer") . ", " .
1237 " for_translation = " . $ilDB->quote((int) $this->getForTranslation(), "integer") . " " .
1238 " WHERE id = " . $ilDB->quote($this->getId(), "integer");
1239 $ilDB->manipulate($q);
1240 // #14661
1241 include_once("./Services/Notes/classes/class.ilNote.php");
1242 ilNote::activateComments($this->getId(), 0, $this->getType(), $this->publicNotes());
1243 }
1244
1248 public function createProperties()
1249 {
1250 $ilDB = $this->db;
1251
1252 $q = "INSERT INTO content_object (id) VALUES (" . $ilDB->quote($this->getId(), "integer") . ")";
1253 $ilDB->manipulate($q);
1254
1255 // #14661
1256 include_once("./Services/Notes/classes/class.ilNote.php");
1257 ilNote::activateComments($this->getId(), 0, $this->getType(), true);
1258
1259 $this->readProperties(); // to get db default values
1260 }
1261
1262
1266 public static function getAvailableLayouts()
1267 {
1268 $dir = opendir("./Modules/LearningModule/layouts/lm");
1269
1270 $layouts = array();
1271
1272 while ($file = readdir($dir)) {
1273 if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
1274 // directories
1275 if (@is_dir("./Modules/LearningModule/layouts/lm/" . $file)) {
1276 $layouts[$file] = $file;
1277 }
1278 }
1279 }
1280 asort($layouts);
1281
1282 // workaround: fix ordering
1283 $ret = array(
1284 'toc2win' => 'toc2win',
1285 'toc2windyn' => 'toc2windyn',
1286 '1window' => '1window',
1287 '2window' => '2window',
1288 '3window' => '3window',
1289 'presentation' => 'presentation',
1290 'fullscreen' => 'fullscreen'
1291 );
1292
1293 foreach ($layouts as $l) {
1294 if (!in_array($l, $ret)) {
1295 $ret[$l] = $l;
1296 }
1297 }
1298
1299 return $ret;
1300 }
1301
1305 public static function _checkPreconditionsOfPage($cont_ref_id, $cont_obj_id, $page_id)
1306 {
1307 global $DIC;
1308
1309 $ilUser = $DIC->user();
1310 $ilErr = $DIC["ilErr"];
1311
1312 $lm_tree = new ilTree($cont_obj_id);
1313 $lm_tree->setTableNames('lm_tree', 'lm_data');
1314 $lm_tree->setTreeTablePK("lm_id");
1315
1316 if ($lm_tree->isInTree($page_id)) {
1317 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
1318 foreach ($path as $node) {
1319 if ($node["type"] == "st") {
1320 if (!ilConditionHandler::_checkAllConditionsOfTarget($cont_ref_id, $node["child"], "st")) {
1321 return false;
1322 }
1323 }
1324 }
1325 }
1326
1327 return true;
1328 }
1329
1333 public static function _getMissingPreconditionsOfPage($cont_ref_id, $cont_obj_id, $page_id)
1334 {
1335 $lm_tree = new ilTree($cont_obj_id);
1336 $lm_tree->setTableNames('lm_tree', 'lm_data');
1337 $lm_tree->setTreeTablePK("lm_id");
1338
1339 $conds = array();
1340 if ($lm_tree->isInTree($page_id)) {
1341 // get full path of page
1342 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
1343 foreach ($path as $node) {
1344 if ($node["type"] == "st") {
1345 // get all preconditions of upper chapters
1346 $tconds = ilConditionHandler::_getPersistedConditionsOfTarget($cont_ref_id, $node["child"], "st");
1347 foreach ($tconds as $tcond) {
1348 // store all missing preconditions
1350 $conds[] = $tcond;
1351 }
1352 }
1353 }
1354 }
1355 }
1356
1357 return $conds;
1358 }
1359
1363 public static function _getMissingPreconditionsTopChapter($cont_obj_ref_id, $cont_obj_id, $page_id)
1364 {
1365 $lm_tree = new ilTree($cont_obj_id);
1366 $lm_tree->setTableNames('lm_tree', 'lm_data');
1367 $lm_tree->setTreeTablePK("lm_id");
1368
1369 $conds = array();
1370 if ($lm_tree->isInTree($page_id)) {
1371 // get full path of page
1372 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
1373 foreach ($path as $node) {
1374 if ($node["type"] == "st") {
1375 // get all preconditions of upper chapters
1376 $tconds = ilConditionHandler::_getPersistedConditionsOfTarget($cont_obj_ref_id, $node["child"], "st");
1377 foreach ($tconds as $tcond) {
1378 // look for missing precondition
1380 return $node["child"];
1381 }
1382 }
1383 }
1384 }
1385 }
1386
1387 return "";
1388 }
1389
1393 public static function hasSuccessorPage($a_cont_obj_id, $a_page_id)
1394 {
1395 $tree = new ilTree($a_cont_obj_id);
1396 $tree->setTableNames('lm_tree', 'lm_data');
1397 $tree->setTreeTablePK("lm_id");
1398 if ($tree->isInTree($a_page_id)) {
1399 $succ = $tree->fetchSuccessorNode($a_page_id, "pg");
1400 if ($succ > 0) {
1401 return true;
1402 }
1403 }
1404 return false;
1405 }
1406
1407
1408 public function checkTree()
1409 {
1410 $tree = new ilTree($this->getId());
1411 $tree->setTableNames('lm_tree', 'lm_data');
1412 $tree->setTreeTablePK("lm_id");
1413 $tree->checkTree();
1414 $tree->checkTreeChilds();
1415 //echo "checked";
1416 }
1417
1421 public function fixTree()
1422 {
1423 $ilDB = $this->db;
1424
1425 $tree = $this->getLMTree();
1426
1427 // check numbering, if errors, renumber
1428 // it is very important to keep this step before deleting subtrees
1429 // in the following steps
1430 $set = $ilDB->query(
1431 "SELECT DISTINCT l1.lm_id" .
1432 " FROM lm_tree l1" .
1433 " JOIN lm_tree l2 ON ( l1.child = l2.parent" .
1434 " AND l1.lm_id = l2.lm_id )" .
1435 " JOIN lm_data ON ( l1.child = lm_data.obj_id )" .
1436 " WHERE (l2.lft < l1.lft" .
1437 " OR l2.rgt > l1.rgt OR l2.lft > l1.rgt OR l2.rgt < l1.lft)" .
1438 " AND l1.lm_id = " . $ilDB->quote($this->getId(), "integer") .
1439 " ORDER BY lm_data.create_date DESC"
1440 );
1441 if ($rec = $ilDB->fetchAssoc($set)) {
1442 $tree->renumber();
1443 }
1444
1445 // delete subtrees that have no lm_data records (changed due to #20637)
1446 $set = $ilDB->query("SELECT * FROM lm_tree WHERE lm_tree.lm_id = " . $ilDB->quote($this->getId(), "integer"));
1447 while ($node = $ilDB->fetchAssoc($set)) {
1448 $q = "SELECT * FROM lm_data WHERE obj_id = " .
1449 $ilDB->quote($node["child"], "integer");
1450 $obj_set = $ilDB->query($q);
1451 $obj_rec = $ilDB->fetchAssoc($obj_set);
1452 if (!$obj_rec) {
1453 $node_data = $tree->getNodeData($node["child"]);
1454 $node_data["child"] = $node["child"];
1455 $tree->deleteTree($node_data);
1456 }
1457 }
1458
1459 // delete subtrees that have pages as parent
1460 $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
1461 foreach ($nodes as $node) {
1462 $q = "SELECT * FROM lm_data WHERE obj_id = " .
1463 $ilDB->quote($node["parent"], "integer");
1464 $obj_set = $ilDB->query($q);
1465 $obj_rec = $ilDB->fetchAssoc($obj_set);
1466 if ($obj_rec["type"] == "pg") {
1467 $node_data = $tree->getNodeData($node["child"]);
1468 if ($tree->isInTree($node["child"])) {
1469 $tree->deleteTree($node_data);
1470 }
1471 }
1472 }
1473
1474 // check for multi-references pages or chapters
1475 // if errors -> create copies of them here
1476 $set = $ilDB->query("SELECT DISTINCT l1.lm_id" .
1477 " FROM lm_tree l1" .
1478 " JOIN lm_tree l2 ON ( l1.child = l2.child AND l1.lm_id <> l2.lm_id )" .
1479 " JOIN lm_data ON (l1.child = lm_data.obj_id)" .
1480 " WHERE l1.child <> 1" .
1481 " AND l1.lm_id <> lm_data.lm_id" .
1482 " AND l1.lm_id = " . $ilDB->quote($this->getId(), "integer"));
1483 if ($rec = $ilDB->fetchAssoc($set)) {
1484 $set = $ilDB->query("SELECT DISTINCT l1.child " .
1485 " FROM lm_tree l1" .
1486 " JOIN lm_tree l2 ON ( l1.child = l2.child AND l1.lm_id <> l2.lm_id )" .
1487 " JOIN lm_data ON (l1.child = lm_data.obj_id)" .
1488 " WHERE l1.child <> 1" .
1489 " AND l1.lm_id <> lm_data.lm_id" .
1490 " AND l1.lm_id = " . $ilDB->quote($this->getId(), "integer"));
1491 include_once("./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
1492 while ($rec = $ilDB->fetchAssoc($set)) {
1493 $cobj = ilLMObjectFactory::getInstance($this, $rec["child"]);
1494
1495 if (is_object($cobj)) {
1496 if ($cobj->getType() == "pg") {
1497 // make a copy of it
1498 $pg_copy = $cobj->copy($this);
1499
1500 // replace the child in the tree with the copy (id)
1501 $ilDB->manipulate(
1502 "UPDATE lm_tree SET " .
1503 " child = " . $ilDB->quote($pg_copy->getId(), "integer") .
1504 " WHERE child = " . $ilDB->quote($cobj->getId(), "integer") .
1505 " AND lm_id = " . $ilDB->quote($this->getId(), "integer")
1506 );
1507 } elseif ($cobj->getType() == "st") {
1508 // make a copy of it
1509 $st_copy = $cobj->copy($this);
1510
1511 // replace the child in the tree with the copy (id)
1512 $ilDB->manipulate(
1513 "UPDATE lm_tree SET " .
1514 " child = " . $ilDB->quote($st_copy->getId(), "integer") .
1515 " WHERE child = " . $ilDB->quote($cobj->getId(), "integer") .
1516 " AND lm_id = " . $ilDB->quote($this->getId(), "integer")
1517 );
1518
1519 // make all childs refer to the copy now
1520 $ilDB->manipulate(
1521 "UPDATE lm_tree SET " .
1522 " parent = " . $ilDB->quote($st_copy->getId(), "integer") .
1523 " WHERE parent = " . $ilDB->quote($cobj->getId(), "integer") .
1524 " AND lm_id = " . $ilDB->quote($this->getId(), "integer")
1525 );
1526 }
1527 }
1528 }
1529 }
1530
1531 // missing copage entries
1532 $set = $ilDB->queryF(
1533 "SELECT * FROM lm_data " .
1534 " WHERE lm_id = %s AND type = %s",
1535 array("integer", "text"),
1536 array($this->getId(), "pg")
1537 );
1538 while ($rec = $ilDB->fetchAssoc($set)) {
1539 if (!ilPageObject::_exists("lm", $rec["obj_id"], "-")) {
1540 $lm_page = new ilLMPage();
1541 $lm_page->setId($rec["obj_id"]);
1542 $lm_page->setParentId($this->getId());
1543 $lm_page->create();
1544 }
1545 }
1546 }
1547
1551 public function checkStructure()
1552 {
1553 $issues = [];
1554 $ilDB = $this->db;
1555
1556 $tree = $this->getLMTree();
1557
1558 // check numbering, if errors, renumber
1559 // it is very important to keep this step before deleting subtrees
1560 // in the following steps
1561 $set = $ilDB->query(
1562 "SELECT l1.child, l1.lft l1lft, l1.rgt l1rgt, l2.parent, l2.lft l2lft, l2.rgt l2rgt" .
1563 " FROM lm_tree l1" .
1564 " JOIN lm_tree l2 ON ( l1.child = l2.parent" .
1565 " AND l1.lm_id = l2.lm_id )" .
1566 " JOIN lm_data ON ( l1.child = lm_data.obj_id )" .
1567 " WHERE (l2.lft < l1.lft" .
1568 " OR l2.rgt > l1.rgt OR l2.lft > l1.rgt OR l2.rgt < l1.lft)" .
1569 " AND l1.lm_id = " . $ilDB->quote($this->getId(), "integer") .
1570 " ORDER BY lm_data.create_date DESC"
1571 );
1572 while ($rec = $ilDB->fetchAssoc($set)) {
1573 $issues[] = "Tree numbering: " . print_r($rec, true);
1574 }
1575
1576 // delete subtrees that have no lm_data records (changed due to #20637)
1577 $set = $ilDB->query("SELECT * FROM lm_tree WHERE lm_tree.lm_id = " . $ilDB->quote($this->getId(), "integer"));
1578 while ($node = $ilDB->fetchAssoc($set)) {
1579 $q = "SELECT * FROM lm_data WHERE obj_id = " .
1580 $ilDB->quote($node["child"], "integer");
1581 $obj_set = $ilDB->query($q);
1582 $obj_rec = $ilDB->fetchAssoc($obj_set);
1583 if (!$obj_rec) {
1584 $issues[] = "Tree entry without data entry: " . print_r($node, true);
1585 }
1586 }
1587
1588 // delete subtrees that have pages as parent
1589 $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
1590 foreach ($nodes as $node) {
1591 $q = "SELECT * FROM lm_data WHERE obj_id = " .
1592 $ilDB->quote($node["parent"], "integer");
1593 $obj_set = $ilDB->query($q);
1594 $obj_rec = $ilDB->fetchAssoc($obj_set);
1595 if ($obj_rec["type"] == "pg") {
1596 $node_data = $tree->getNodeData($node["child"]);
1597 if ($tree->isInTree($node["child"])) {
1598 $issues[] = "Subtree with page parent: " . print_r($node_data, true);
1599 }
1600 }
1601 }
1602
1603 // check for multi-references pages or chapters
1604 // if errors -> create copies of them here
1605 $set = $ilDB->query("SELECT DISTINCT l1.lm_id" .
1606 " FROM lm_tree l1" .
1607 " JOIN lm_tree l2 ON ( l1.child = l2.child AND l1.lm_id <> l2.lm_id )" .
1608 " JOIN lm_data ON (l1.child = lm_data.obj_id)" .
1609 " WHERE l1.child <> 1" .
1610 " AND l1.lm_id <> lm_data.lm_id" .
1611 " AND l1.lm_id = " . $ilDB->quote($this->getId(), "integer"));
1612 if ($rec = $ilDB->fetchAssoc($set)) {
1613 $set = $ilDB->query("SELECT DISTINCT l1.child " .
1614 " FROM lm_tree l1" .
1615 " JOIN lm_tree l2 ON ( l1.child = l2.child AND l1.lm_id <> l2.lm_id )" .
1616 " JOIN lm_data ON (l1.child = lm_data.obj_id)" .
1617 " WHERE l1.child <> 1" .
1618 " AND l1.lm_id <> lm_data.lm_id" .
1619 " AND l1.lm_id = " . $ilDB->quote($this->getId(), "integer"));
1620 include_once("./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
1621 while ($rec = $ilDB->fetchAssoc($set)) {
1622 $set3 = $ilDB->queryF(
1623 "SELECT * FROM lm_tree " .
1624 " WHERE child = %s ",
1625 array("integer"),
1626 array($rec["child"])
1627 );
1628 while ($rec3 = $ilDB->fetchAssoc($set3)) {
1629 $issues[] = "Multi-reference item: " . print_r($rec3, true);
1630 }
1631 }
1632 }
1633
1634 // missing copage entries
1635 $set = $ilDB->queryF(
1636 "SELECT * FROM lm_data " .
1637 " WHERE lm_id = %s AND type = %s",
1638 array("integer", "text"),
1639 array($this->getId(), "pg")
1640 );
1641 while ($rec = $ilDB->fetchAssoc($set)) {
1642 if (!ilPageObject::_exists("lm", $rec["obj_id"], "-")) {
1643 $issues[] = "Missing COPage: " . print_r($rec, true);
1644 }
1645 }
1646
1647
1648 return $issues;
1649 }
1650
1657 public function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
1658 {
1659 $attrs = array();
1660 switch ($this->getType()) {
1661 case "lm":
1662 $attrs["Type"] = "LearningModule";
1663 break;
1664 }
1665 $a_xml_writer->xmlStartTag("ContentObject", $attrs);
1666
1667 // MetaData
1668 $this->exportXMLMetaData($a_xml_writer);
1669
1670 // StructureObjects
1671 //echo "ContObj:".$a_inst.":<br>";
1672 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Structure Objects");
1673 $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
1674 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Structure Objects");
1675
1676 // PageObjects
1677 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Page Objects");
1678 $this->exportXMLPageObjects($a_xml_writer, $a_inst, $expLog);
1679 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Page Objects");
1680
1681 // MediaObjects
1682 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Media Objects");
1683 $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
1684 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Media Objects");
1685
1686 // FileItems
1687 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export File Items");
1688 $this->exportFileItems($a_target_dir, $expLog);
1689 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export File Items");
1690
1691 // Questions
1692 if (count($this->q_ids) > 0) {
1693 $qti_file = fopen($a_target_dir . "/qti.xml", "w");
1694 include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
1695 $pool = new ilObjQuestionPool();
1696 fwrite($qti_file, $pool->questionsToXML($this->q_ids));
1697 fclose($qti_file);
1698 }
1699
1700 // To do: implement version selection/detection
1701 // Properties
1702 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Properties");
1703 $this->exportXMLProperties($a_xml_writer, $expLog);
1704 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Properties");
1705
1706 $a_xml_writer->xmlEndTag("ContentObject");
1707 }
1708
1715 public function exportXMLMetaData(&$a_xml_writer)
1716 {
1717 include_once("Services/MetaData/classes/class.ilMD2XML.php");
1718 $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
1719 $md2xml->setExportMode(true);
1720 $md2xml->startExport();
1721 $a_xml_writer->appendXML($md2xml->getXML());
1722 }
1723
1730 public function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
1731 {
1732 include_once './Modules/LearningModule/classes/class.ilStructureObject.php';
1733
1734 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
1735 foreach ($childs as $child) {
1736 if ($child["type"] != "st") {
1737 continue;
1738 }
1739
1740 $structure_obj = new ilStructureObject($this, $child["obj_id"]);
1741 $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
1742 unset($structure_obj);
1743 }
1744 }
1745
1746
1753 public function exportXMLPageObjects(&$a_xml_writer, $a_inst, &$expLog)
1754 {
1755 include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
1756 include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
1757
1758 $pages = ilLMPageObject::getPageList($this->getId());
1759 foreach ($pages as $page) {
1760 if (ilLMPage::_exists($this->getType(), $page["obj_id"])) {
1761 $expLog->write(date("[y-m-d H:i:s] ") . "Page Object " . $page["obj_id"]);
1762
1763 // export xml to writer object
1764 $page_obj = new ilLMPageObject($this, $page["obj_id"]);
1765 $page_obj->exportXML($a_xml_writer, "normal", $a_inst);
1766
1767 // collect media objects
1768 $mob_ids = $page_obj->getMediaObjectIDs();
1769 foreach ($mob_ids as $mob_id) {
1770 $this->mob_ids[$mob_id] = $mob_id;
1771 }
1772
1773 // collect all file items
1774 $file_ids = $page_obj->getFileItemIds();
1775 foreach ($file_ids as $file_id) {
1776 $this->file_ids[$file_id] = $file_id;
1777 }
1778
1779 // collect all questions
1780 $q_ids = $page_obj->getQuestionIds();
1781 foreach ($q_ids as $q_id) {
1782 $this->q_ids[$q_id] = $q_id;
1783 }
1784
1785 unset($page_obj);
1786 }
1787 }
1788 }
1789
1796 public function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
1797 {
1798 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1799
1800 $linked_mobs = array();
1801
1802 // mobs directly embedded into pages
1803 foreach ($this->mob_ids as $mob_id) {
1804 if ($mob_id > 0 && ilObject::_lookupType($mob_id) == "mob") {
1805 $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id);
1806 $media_obj = new ilObjMediaObject($mob_id);
1807 $media_obj->exportXML($a_xml_writer, $a_inst);
1808 $media_obj->exportFiles($a_target_dir);
1809
1810 $lmobs = $media_obj->getLinkedMediaObjects($this->mob_ids);
1811 $linked_mobs = array_merge($linked_mobs, $lmobs);
1812
1813 unset($media_obj);
1814 }
1815 }
1816
1817 // linked mobs (in map areas)
1818 foreach ($linked_mobs as $mob_id) {
1819 if ($mob_id > 0) {
1820 $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id);
1821 $media_obj = new ilObjMediaObject($mob_id);
1822 $media_obj->exportXML($a_xml_writer, $a_inst);
1823 $media_obj->exportFiles($a_target_dir);
1824 unset($media_obj);
1825 }
1826 }
1827 }
1828
1833 public function exportFileItems($a_target_dir, &$expLog)
1834 {
1835 include_once("./Modules/File/classes/class.ilObjFile.php");
1836
1837 foreach ($this->file_ids as $file_id) {
1838 $expLog->write(date("[y-m-d H:i:s] ") . "File Item " . $file_id);
1839 $file_obj = new ilObjFile($file_id, false);
1840 $file_obj->export($a_target_dir);
1841 unset($file_obj);
1842 }
1843 }
1844
1849 public function exportXMLProperties($a_xml_writer, &$expLog)
1850 {
1851 $attrs = array();
1852 $a_xml_writer->xmlStartTag("Properties", $attrs);
1853
1854 // Layout
1855 $attrs = array("Name" => "Layout", "Value" => $this->getLayout());
1856 $a_xml_writer->xmlElement("Property", $attrs);
1857
1858 // Page Header
1859 $attrs = array("Name" => "PageHeader", "Value" => $this->getPageHeader());
1860 $a_xml_writer->xmlElement("Property", $attrs);
1861
1862 // TOC Mode
1863 $attrs = array("Name" => "TOCMode", "Value" => $this->getTOCMode());
1864 $a_xml_writer->xmlElement("Property", $attrs);
1865
1866 // LM Menu Activation
1867 $attrs = array("Name" => "ActiveLMMenu", "Value" =>
1868 ilUtil::tf2yn($this->isActiveLMMenu()));
1869 $a_xml_writer->xmlElement("Property", $attrs);
1870
1871 // Numbering Activation
1872 $attrs = array("Name" => "ActiveNumbering", "Value" =>
1874 $a_xml_writer->xmlElement("Property", $attrs);
1875
1876 // Table of contents button activation
1877 $attrs = array("Name" => "ActiveTOC", "Value" =>
1878 ilUtil::tf2yn($this->isActiveTOC()));
1879 $a_xml_writer->xmlElement("Property", $attrs);
1880
1881 // Print view button activation
1882 $attrs = array("Name" => "ActivePrintView", "Value" =>
1884 $a_xml_writer->xmlElement("Property", $attrs);
1885
1886 // Note that download button is not saved, because
1887 // download files do not exist after import
1888
1889 // Clean frames
1890 $attrs = array("Name" => "CleanFrames", "Value" =>
1891 ilUtil::tf2yn($this->cleanFrames()));
1892 $a_xml_writer->xmlElement("Property", $attrs);
1893
1894 // Public notes activation
1895 $attrs = array("Name" => "PublicNotes", "Value" =>
1896 ilUtil::tf2yn($this->publicNotes()));
1897 $a_xml_writer->xmlElement("Property", $attrs);
1898
1899 // History comments for authors activation
1900 $attrs = array("Name" => "HistoryUserComments", "Value" =>
1902 $a_xml_writer->xmlElement("Property", $attrs);
1903
1904 // Rating
1905 $attrs = array("Name" => "Rating", "Value" =>
1906 ilUtil::tf2yn($this->hasRating()));
1907 $a_xml_writer->xmlElement("Property", $attrs);
1908 $attrs = array("Name" => "RatingPages", "Value" =>
1909 ilUtil::tf2yn($this->hasRatingPages()));
1910 $a_xml_writer->xmlElement("Property", $attrs);
1911
1912 // Header Page
1913 if ($this->getHeaderPage() > 0) {
1914 $attrs = array("Name" => "HeaderPage", "Value" =>
1915 "il_" . IL_INST_ID . "_pg_" . $this->getHeaderPage());
1916 $a_xml_writer->xmlElement("Property", $attrs);
1917 }
1918
1919 // Footer Page
1920 if ($this->getFooterPage() > 0) {
1921 $attrs = array("Name" => "FooterPage", "Value" =>
1922 "il_" . IL_INST_ID . "_pg_" . $this->getFooterPage());
1923 $a_xml_writer->xmlElement("Property", $attrs);
1924 }
1925
1926 // layout per page
1927 $attrs = array("Name" => "LayoutPerPage", "Value" =>
1928 $this->getLayoutPerPage());
1929 $a_xml_writer->xmlElement("Property", $attrs);
1930
1931 // progress icons
1932 $attrs = array("Name" => "ProgressIcons", "Value" =>
1933 $this->getProgressIcons());
1934 $a_xml_writer->xmlElement("Property", $attrs);
1935
1936 // store tries
1937 $attrs = array("Name" => "StoreTries", "Value" =>
1938 $this->getStoreTries());
1939 $a_xml_writer->xmlElement("Property", $attrs);
1940
1941 // restrict forward navigation
1942 $attrs = array("Name" => "RestrictForwardNavigation", "Value" =>
1944 $a_xml_writer->xmlElement("Property", $attrs);
1945
1946 // disable default feedback
1947 $attrs = array("Name" => "DisableDefaultFeedback", "Value" =>
1948 $this->getDisableDefaultFeedback());
1949 $a_xml_writer->xmlElement("Property", $attrs);
1950
1951 $a_xml_writer->xmlEndTag("Properties");
1952 }
1953
1957 public function getExportFiles()
1958 {
1959 $file = array();
1960
1961 $types = array("xml", "html", "scorm");
1962
1963 foreach ($types as $type) {
1964 $dir = $this->getExportDirectory($type);
1965 // quit if import dir not available
1966 if (!@is_dir($dir) or
1967 !is_writeable($dir)) {
1968 continue;
1969 }
1970
1971 // open directory
1972 $cdir = dir($dir);
1973
1974 // initialize array
1975
1976 // get files and save the in the array
1977 while ($entry = $cdir->read()) {
1978 if ($entry != "." and
1979 $entry != ".." and
1980 substr($entry, -4) == ".zip" and
1981 preg_match("~^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.zip\$~", $entry)) {
1982 $file[$entry . $type] = array("type" => $type, "file" => $entry,
1983 "size" => filesize($dir . "/" . $entry));
1984 }
1985 }
1986
1987 // close import directory
1988 $cdir->close();
1989 }
1990
1991 // sort files
1992 ksort($file);
1993 reset($file);
1994 return $file;
1995 }
1996
2003 public function setPublicExportFile($a_type, $a_file)
2004 {
2005 $this->public_export_file[$a_type] = $a_file;
2006 }
2007
2016 {
2017 return $this->public_export_file[$a_type];
2018 }
2019
2023 public function getOfflineFiles($dir)
2024 {
2025 // quit if offline dir not available
2026 if (!@is_dir($dir) or
2027 !is_writeable($dir)) {
2028 return array();
2029 }
2030
2031 // open directory
2032 $dir = dir($dir);
2033
2034 // initialize array
2035 $file = array();
2036
2037 // get files and save the in the array
2038 while ($entry = $dir->read()) {
2039 if ($entry != "." and
2040 $entry != ".." and
2041 substr($entry, -4) == ".pdf" and
2042 preg_match("~^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.pdf\$~", $entry)) {
2043 $file[] = $entry;
2044 }
2045 }
2046
2047 // close import directory
2048 $dir->close();
2049
2050 // sort files
2051 sort($file);
2052 reset($file);
2053
2054 return $file;
2055 }
2056
2060 public function exportSCORM($a_target_dir, $log)
2061 {
2062 ilUtil::delDir($a_target_dir);
2063 ilUtil::makeDir($a_target_dir);
2064 //ilUtil::makeDir($a_target_dir."/res");
2065
2066 // export everything to html
2067 $this->exportHTML($a_target_dir . "/res", $log, false, "scorm");
2068
2069 // build manifest file
2070 include("./Modules/LearningModule/classes/class.ilLMContObjectManifestBuilder.php");
2071 $man_builder = new ilLMContObjectManifestBuilder($this);
2072 $man_builder->buildManifest();
2073 $man_builder->dump($a_target_dir);
2074
2075 // copy scorm 1.2 schema definitions
2076 copy("Modules/LearningModule/scorm_xsd/adlcp_rootv1p2.xsd", $a_target_dir . "/adlcp_rootv1p2.xsd");
2077 copy("Modules/LearningModule/scorm_xsd/imscp_rootv1p1p2.xsd", $a_target_dir . "/imscp_rootv1p1p2.xsd");
2078 copy("Modules/LearningModule/scorm_xsd/imsmd_rootv1p2p1.xsd", $a_target_dir . "/imsmd_rootv1p2p1.xsd");
2079 copy("Modules/LearningModule/scorm_xsd/ims_xml.xsd", $a_target_dir . "/ims_xml.xsd");
2080
2081 // zip it all
2082 $date = time();
2083 $zip_file = $a_target_dir . "/" . $date . "__" . IL_INST_ID . "__" .
2084 $this->getType() . "_" . $this->getId() . ".zip";
2085 //echo "zip-".$a_target_dir."-to-".$zip_file;
2086 ilUtil::zip(array($a_target_dir . "/res",
2087 $a_target_dir . "/imsmanifest.xml",
2088 $a_target_dir . "/adlcp_rootv1p2.xsd",
2089 $a_target_dir . "/imscp_rootv1p1p2.xsd",
2090 $a_target_dir . "/ims_xml.xsd",
2091 $a_target_dir . "/imsmd_rootv1p2p1.xsd"), $zip_file);
2092
2093 $dest_file = $this->getExportDirectory("scorm") . "/" . $date . "__" . IL_INST_ID . "__" .
2094 $this->getType() . "_" . $this->getId() . ".zip";
2095
2096 rename($zip_file, $dest_file);
2097 ilUtil::delDir($a_target_dir);
2098 }
2099
2100
2104 public function exportHTML($a_target_dir, $log, $a_zip_file = true, $a_export_format = "html", $a_lang = "")
2105 {
2106 $tpl = $this->tpl;
2107 $ilLocator = $this->locator;
2109
2110 $user_lang = $ilUser->getLanguage();
2111
2112 // initialize temporary target directory
2113 ilUtil::delDir($a_target_dir);
2114 ilUtil::makeDir($a_target_dir);
2115 $mob_dir = $a_target_dir . "/mobs";
2116 ilUtil::makeDir($mob_dir);
2117 $file_dir = $a_target_dir . "/files";
2118 ilUtil::makeDir($file_dir);
2119 $teximg_dir = $a_target_dir . "/teximg";
2120 ilUtil::makeDir($teximg_dir);
2121 $style_dir = $a_target_dir . "/style";
2122 ilUtil::makeDir($style_dir);
2123 $style_img_dir = $a_target_dir . "/style/images";
2124 ilUtil::makeDir($style_img_dir);
2125 $content_style_dir = $a_target_dir . "/content_style";
2126 ilUtil::makeDir($content_style_dir);
2127 $content_style_img_dir = $a_target_dir . "/content_style/images";
2128 ilUtil::makeDir($content_style_img_dir);
2129
2130 // init the mathjax rendering for HTML export
2131 include_once './Services/MathJax/classes/class.ilMathJax.php';
2133
2134 // export system style sheet
2135 $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
2136 $style_name = $ilUser->prefs["style"] . ".css";
2137 copy($location_stylesheet, $style_dir . "/" . $style_name);
2138 $fh = fopen($location_stylesheet, "r");
2139 $css = fread($fh, filesize($location_stylesheet));
2140 preg_match_all("/url\‍(([^\‍)]*)\‍)/", $css, $files);
2141 foreach (array_unique($files[1]) as $fileref) {
2142 $css_fileref = str_replace(array("'", '"'), "", $fileref);
2143 $fileref = dirname($location_stylesheet) . "/" . $css_fileref;
2144 if (is_file($fileref)) {
2145 //echo "<br>make dir: ".dirname($style_dir."/".$css_fileref);
2146 ilUtil::makeDirParents(dirname($style_dir . "/" . $css_fileref));
2147 //echo "<br>copy: ".$fileref." TO ".$style_dir."/".$css_fileref;
2148 copy($fileref, $style_dir . "/" . $css_fileref);
2149 }
2150 }
2151 fclose($fh);
2152 $location_stylesheet = ilUtil::getStyleSheetLocation();
2153
2154 // export content style sheet
2155 if ($this->getStyleSheetId() < 1) {
2156 $cont_stylesheet = "./Services/COPage/css/content.css";
2157
2158 $css = fread(fopen($cont_stylesheet, 'r'), filesize($cont_stylesheet));
2159 preg_match_all("/url\‍(([^\‍)]*)\‍)/", $css, $files);
2160 foreach (array_unique($files[1]) as $fileref) {
2161 $target_fileref = str_replace("..", ".", $fileref);
2162 $target_fileref = str_replace('"', "", $target_fileref);
2163 if (is_file($target_fileref)) {
2164 copy($target_fileref, $content_style_img_dir . "/" . basename($target_fileref));
2165 }
2166 $css = str_replace($fileref, "images/" . basename($target_fileref), $css);
2167 }
2168 fwrite(fopen($content_style_dir . "/content.css", 'w'), $css);
2169 } else {
2170 $style = new ilObjStyleSheet($this->getStyleSheetId());
2171 $style->writeCSSFile($content_style_dir . "/content.css", "images");
2172 $style->copyImagesToDir($content_style_img_dir);
2173 }
2174
2175 // export syntax highlighting style
2176 $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
2177 copy($syn_stylesheet, $a_target_dir . "/syntaxhighlight.css");
2178
2179 // get learning module presentation gui class
2180 include_once("./Modules/LearningModule/classes/class.ilLMPresentationGUI.php");
2181 $_GET["cmd"] = "nop";
2182 $get_transl = $_GET["transl"];
2183 $_GET["transl"] = "";
2184 $lm_gui = new ilLMPresentationGUI();
2185 $lm_gui->setOfflineMode(true, ($a_lang == "all"));
2186 $lm_gui->setOfflineDirectory($a_target_dir);
2187 $lm_gui->setExportFormat($a_export_format);
2188
2190 $langs = array();
2191 if ($a_lang != "all") {
2192 $langs = array($a_lang);
2193 } else {
2194 $ot_langs = $ot->getLanguages();
2195 foreach ($ot_langs as $otl) {
2196 $langs[] = $otl["lang_code"];
2197 }
2198 }
2199
2200 // init collector arrays
2201 $this->offline_mobs = array();
2202 $this->offline_int_links = array();
2203 $this->offline_files = array();
2204
2205 // iterate all languages
2206 foreach ($langs as $lang) {
2207 if ($lang != "") {
2208 $ilUser->setLanguage($lang);
2209 $ilUser->setCurrentLanguage($lang);
2210 } else {
2211 $ilUser->setLanguage($user_lang);
2212 $ilUser->setCurrentLanguage($user_lang);
2213 }
2214
2215 if ($lang != "") {
2216 if ($lang == $ot->getMasterLanguage()) {
2217 $lm_gui->lang = "";
2218 } else {
2219 $lm_gui->lang = $lang;
2220 }
2221 }
2222
2223 // export pages
2224 // now: forward ("all" info to export files and links)
2225 $this->exportHTMLPages($lm_gui, $a_target_dir, $lm_gui->lang, ($a_lang == "all"));
2226
2227 // export table of contents
2228 $ilLocator->clearItems();
2229 if ($this->isActiveTOC()) {
2230 $tpl = new ilTemplate("tpl.main.html", true, true);
2231
2232 $GLOBALS["tpl"] = $tpl;
2233
2234 $lm_gui->tpl = $tpl;
2235 $content = $lm_gui->showTableOfContents();
2236 //var_dump($content); exit;
2237 if ($a_lang == "all") {
2238 $file = $a_target_dir . "/table_of_contents_" . $lang . ".html";
2239 } else {
2240 $file = $a_target_dir . "/table_of_contents.html";
2241 }
2242
2243 // open file
2244 if (!($fp = @fopen($file, "w+"))) {
2245 die("<b>Error</b>: Could not open \"" . $file . "\" for writing" .
2246 " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />");
2247 }
2248 chmod($file, 0770);
2249 fwrite($fp, $content);
2250 fclose($fp);
2251 }
2252 }
2253
2254 // export glossary terms
2255 $this->exportHTMLGlossaryTerms($lm_gui, $a_target_dir);
2256
2257 // export all media objects
2258 $linked_mobs = array();
2259 foreach ($this->offline_mobs as $mob) {
2260 if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
2261 $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs);
2262 }
2263 }
2264 $linked_mobs2 = array(); // mobs linked in link areas
2265 foreach ($linked_mobs as $mob) {
2266 if (ilObject::_exists($mob)) {
2267 $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs2);
2268 }
2269 }
2270 $_GET["obj_type"] = "MediaObject";
2271 $_GET["obj_id"] = $a_mob_id;
2272 $_GET["cmd"] = "";
2273
2274 // export all file objects
2275 foreach ($this->offline_files as $file) {
2276 $this->exportHTMLFile($a_target_dir, $file);
2277 }
2278
2279 // export questions (images)
2280 if (count($this->q_ids) > 0) {
2281 foreach ($this->q_ids as $q_id) {
2282 ilUtil::makeDirParents($a_target_dir . "/assessment/0/" . $q_id . "/images");
2284 ilUtil::getWebspaceDir() . "/assessment/0/" . $q_id . "/images",
2285 $a_target_dir . "/assessment/0/" . $q_id . "/images"
2286 );
2287 }
2288 }
2289
2290 // export images
2291 $image_dir = $a_target_dir . "/images";
2292 ilUtil::makeDir($image_dir);
2293 ilUtil::makeDir($image_dir . "/browser");
2294 copy(
2295 ilUtil::getImagePath("enlarge.svg", false, "filesystem"),
2296 $image_dir . "/enlarge.svg"
2297 );
2298 copy(
2299 ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
2300 $image_dir . "/browser/plus.png"
2301 );
2302 copy(
2303 ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
2304 $image_dir . "/browser/minus.png"
2305 );
2306 copy(
2307 ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
2308 $image_dir . "/browser/blank.png"
2309 );
2310 copy(
2311 ilUtil::getImagePath("spacer.png", false, "filesystem"),
2312 $image_dir . "/spacer.png"
2313 );
2314 copy(
2315 ilUtil::getImagePath("icon_st.svg", false, "filesystem"),
2316 $image_dir . "/icon_st.svg"
2317 );
2318 copy(
2319 ilUtil::getImagePath("icon_pg.svg", false, "filesystem"),
2320 $image_dir . "/icon_pg.svg"
2321 );
2322 copy(
2323 ilUtil::getImagePath("icon_lm.svg", false, "filesystem"),
2324 $image_dir . "/icon_lm.svg"
2325 );
2326 copy(
2327 ilUtil::getImagePath("nav_arr_L.png", false, "filesystem"),
2328 $image_dir . "/nav_arr_L.png"
2329 );
2330 copy(
2331 ilUtil::getImagePath("nav_arr_R.png", false, "filesystem"),
2332 $image_dir . "/nav_arr_R.png"
2333 );
2334
2335 // export flv/mp3 player
2336 $services_dir = $a_target_dir . "/Services";
2337 ilUtil::makeDir($services_dir);
2338 $media_service_dir = $services_dir . "/MediaObjects";
2339 ilUtil::makeDir($media_service_dir);
2340 include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
2341 $flv_dir = $a_target_dir . "/" . ilPlayerUtil::getFlashVideoPlayerDirectory();
2342 ilUtil::makeDirParents($flv_dir);
2343 $mp3_dir = $media_service_dir . "/flash_mp3_player";
2344 ilUtil::makeDir($mp3_dir);
2345 // copy(ilPlayerUtil::getFlashVideoPlayerFilename(true),
2346 // $flv_dir."/".ilPlayerUtil::getFlashVideoPlayerFilename());
2348 include_once("./Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php");
2351
2352 // js files
2353 ilUtil::makeDir($a_target_dir . '/js');
2354 ilUtil::makeDir($a_target_dir . '/js/yahoo');
2355 ilUtil::makeDir($a_target_dir . '/css');
2356 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
2357 foreach (self::getSupplyingExportFiles($a_target_dir) as $f) {
2358 if ($f["source"] != "") {
2359 ilUtil::makeDirParents(dirname($f["target"]));
2360 copy($f["source"], $f["target"]);
2361 }
2362 }
2363 // template workaround: reset of template
2364 $tpl = new ilTemplate("tpl.main.html", true, true);
2365 $tpl->setVariable("LOCATION_STYLESHEET", $location_stylesheet);
2366 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2367
2368 if ($a_lang != "") {
2369 $ilUser->setLanguage($user_lang);
2370 $ilUser->setCurrentLanguage($user_lang);
2371 }
2372
2373 // zip everything
2374 if ($a_zip_file) {
2375 if ($a_lang == "") {
2376 $zip_target_dir = $this->getExportDirectory("html");
2377 } else {
2378 $zip_target_dir = $this->getExportDirectory("html_" . $a_lang);
2379 ilUtil::makeDir($zip_target_dir);
2380 }
2381
2382 // zip it all
2383 $date = time();
2384 $zip_file = $zip_target_dir . "/" . $date . "__" . IL_INST_ID . "__" .
2385 $this->getType() . "_" . $this->getId() . ".zip";
2386 //echo "-".$a_target_dir."-".$zip_file."-"; exit;
2387 ilUtil::zip($a_target_dir, $zip_file);
2388 ilUtil::delDir($a_target_dir);
2389 }
2390 }
2391
2398 public static function getSupplyingExportFiles($a_target_dir = ".")
2399 {
2400 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
2401 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
2402 include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
2403 include_once("./Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php");
2404 $scripts = array(
2405 array("source" => ilYuiUtil::getLocalPath('yahoo/yahoo-min.js'),
2406 "target" => $a_target_dir . '/js/yahoo/yahoo-min.js',
2407 "type" => "js"),
2408 array("source" => ilYuiUtil::getLocalPath('yahoo-dom-event/yahoo-dom-event.js'),
2409 "target" => $a_target_dir . '/js/yahoo/yahoo-dom-event.js',
2410 "type" => "js"),
2411 array("source" => ilYuiUtil::getLocalPath('animation/animation-min.js'),
2412 "target" => $a_target_dir . '/js/yahoo/animation-min.js',
2413 "type" => "js"),
2414 array("source" => './Services/JavaScript/js/Basic.js',
2415 "target" => $a_target_dir . '/js/Basic.js',
2416 "type" => "js"),
2417 array("source" => './Services/Accordion/js/accordion.js',
2418 "target" => $a_target_dir . '/js/accordion.js',
2419 "type" => "js"),
2420 array("source" => './Services/Accordion/css/accordion.css',
2421 "target" => $a_target_dir . '/css/accordion.css',
2422 "type" => "css"),
2423 array("source" => iljQueryUtil::getLocaljQueryPath(),
2424 "target" => $a_target_dir . '/js/jquery.js',
2425 "type" => "js"),
2426 array("source" => iljQueryUtil::getLocalMaphilightPath(),
2427 "target" => $a_target_dir . '/js/maphilight.js',
2428 "type" => "js"),
2429 array("source" => iljQueryUtil::getLocaljQueryUIPath(),
2430 "target" => $a_target_dir . '/js/jquery-ui-min.js',
2431 "type" => "js"),
2432 array("source" => './Services/COPage/js/ilCOPagePres.js',
2433 "target" => $a_target_dir . '/js/ilCOPagePres.js',
2434 "type" => "js"),
2435 array("source" => './Modules/Scorm2004/scripts/questions/pure.js',
2436 "target" => $a_target_dir . '/js/pure.js',
2437 "type" => "js"),
2438 array("source" => './Modules/Scorm2004/scripts/questions/question_handling.js',
2439 "target" => $a_target_dir . '/js/question_handling.js',
2440 "type" => "js"),
2441 array("source" => './Modules/TestQuestionPool/js/ilMatchingQuestion.js',
2442 "target" => $a_target_dir . '/js/ilMatchingQuestion.js',
2443 "type" => "js"),
2444 array("source" => './Modules/Scorm2004/templates/default/question_handling.css',
2445 "target" => $a_target_dir . '/css/question_handling.css',
2446 "type" => "css"),
2447 array("source" => './Modules/TestQuestionPool/templates/default/test_javascript.css',
2448 "target" => $a_target_dir . '/css/test_javascript.css',
2449 "type" => "css"),
2450 array("source" => './Modules/TestQuestionPool/js/ilAssMultipleChoice.js',
2451 "target" => $a_target_dir . '/js/ilAssMultipleChoice.js',
2452 "type" => "js"),
2453 array("source" => ilPlayerUtil::getLocalMediaElementJsPath(),
2454 "target" => $a_target_dir . "/" . ilPlayerUtil::getLocalMediaElementJsPath(),
2455 "type" => "js"),
2457 "target" => $a_target_dir . "/" . ilPlayerUtil::getLocalMediaElementCssPath(),
2458 "type" => "css"),
2460 "target" => $a_target_dir . "/" . ilExplorerBaseGUI::getLocalExplorerJsPath(),
2461 "type" => "js"),
2462 array("source" => ilExplorerBaseGUI::getLocalJsTreeJsPath(),
2463 "target" => $a_target_dir . "/" . ilExplorerBaseGUI::getLocalJsTreeJsPath(),
2464 "type" => "js"),
2465 array("source" => ilExplorerBaseGUI::getLocalJsTreeCssPath(),
2466 "target" => $a_target_dir . "/" . ilExplorerBaseGUI::getLocalJsTreeCssPath(),
2467 "type" => "css"),
2468 array("source" => './Modules/LearningModule/js/LearningModule.js',
2469 "target" => $a_target_dir . '/js/LearningModule.js',
2470 "type" => "js")
2471 );
2472
2473 $mathJaxSetting = new ilSetting("MathJax");
2474 $use_mathjax = $mathJaxSetting->get("enable");
2475 if ($use_mathjax) {
2476 $scripts[] = array("source" => "",
2477 "target" => $mathJaxSetting->get("path_to_mathjax"),
2478 "type" => "js");
2479 }
2480
2481 // auto linking js
2482 include_once("./Services/Link/classes/class.ilLinkifyUtil.php");
2483 foreach (ilLinkifyUtil::getLocalJsPaths() as $p) {
2484 if (is_int(strpos($p, "ExtLink"))) {
2485 $scripts[] = array("source" => $p,
2486 "target" => $a_target_dir . '/js/ilExtLink.js',
2487 "type" => "js");
2488 }
2489 if (is_int(strpos($p, "linkify.min.js"))) {
2490 $scripts[] = array("source" => $p,
2491 "target" => $a_target_dir . '/js/linkify.min.js',
2492 "type" => "js");
2493 }
2494 if (is_int(strpos($p, "linkify-jquery.min.js"))) {
2495 $scripts[] = array("source" => $p,
2496 "target" => $a_target_dir . '/js/linkify-jquery.min.js',
2497 "type" => "js");
2498 }
2499 }
2500
2501 return $scripts;
2502 }
2503
2507 public function exportHTMLFile($a_target_dir, $a_file_id)
2508 {
2509 $file_dir = $a_target_dir . "/files/file_" . $a_file_id;
2510 ilUtil::makeDir($file_dir);
2511 include_once("./Modules/File/classes/class.ilObjFile.php");
2512 $file_obj = new ilObjFile($a_file_id, false);
2513 $source_file = $file_obj->getDirectory($file_obj->getVersion()) . "/" . $file_obj->getFileName();
2514 if (!is_file($source_file)) {
2515 $source_file = $file_obj->getDirectory() . "/" . $file_obj->getFileName();
2516 }
2517 if (is_file($source_file)) {
2518 copy($source_file, $file_dir . "/" . $file_obj->getFileName());
2519 }
2520 }
2521
2525 public function exportHTMLMOB($a_target_dir, &$a_lm_gui, $a_mob_id, $a_frame, &$a_linked_mobs)
2526 {
2527 $tpl = $this->tpl;
2528
2529 $mob_dir = $a_target_dir . "/mobs";
2530
2531 $source_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $a_mob_id;
2532 if (@is_dir($source_dir)) {
2533 ilUtil::makeDir($mob_dir . "/mm_" . $a_mob_id);
2534 ilUtil::rCopy($source_dir, $mob_dir . "/mm_" . $a_mob_id);
2535 }
2536
2537 $tpl = new ilTemplate("tpl.main.html", true, true);
2538 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2539 $_GET["obj_type"] = "MediaObject";
2540 $_GET["mob_id"] = $a_mob_id;
2541 $_GET["frame"] = $a_frame;
2542 $_GET["cmd"] = "";
2543 $content = $a_lm_gui->media();
2544 $file = $a_target_dir . "/media_" . $a_mob_id . ".html";
2545
2546 // open file
2547 if (!($fp = @fopen($file, "w+"))) {
2548 die("<b>Error</b>: Could not open \"" . $file . "\" for writing" .
2549 " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />");
2550 }
2551 chmod($file, 0770);
2552 fwrite($fp, $content);
2553 fclose($fp);
2554
2555 // fullscreen
2556 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2557 $mob_obj = new ilObjMediaObject($a_mob_id);
2558 if ($mob_obj->hasFullscreenItem()) {
2559 $tpl = new ilTemplate("tpl.main.html", true, true);
2560 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2561 $_GET["obj_type"] = "";
2562 $_GET["frame"] = "";
2563 $_GET["mob_id"] = $a_mob_id;
2564 $_GET["cmd"] = "fullscreen";
2565 $content = $a_lm_gui->fullscreen();
2566 $file = $a_target_dir . "/fullscreen_" . $a_mob_id . ".html";
2567
2568 // open file
2569 if (!($fp = @fopen($file, "w+"))) {
2570 die("<b>Error</b>: Could not open \"" . $file . "\" for writing" .
2571 " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />");
2572 }
2573 chmod($file, 0770);
2574 fwrite($fp, $content);
2575 fclose($fp);
2576 }
2577 $linked_mobs = $mob_obj->getLinkedMediaObjects();
2578 foreach ($linked_mobs as $id) {
2579 $this->log->debug("HTML Export: Add media object $id (" . ilObject::_lookupTitle($id) . ") " .
2580 " due to media object " . $a_mob_id . " (" . ilObject::_lookupTitle($a_mob_id) . ").");
2581 }
2582 $a_linked_mobs = array_merge($a_linked_mobs, $linked_mobs);
2583 }
2584
2588 public function exportHTMLGlossaryTerms(&$a_lm_gui, $a_target_dir)
2589 {
2590 $ilLocator = $this->locator;
2591
2592 foreach ($this->offline_int_links as $int_link) {
2593 $ilLocator->clearItems();
2594 if ($int_link["type"] == "git") {
2595 $tpl = new ilTemplate("tpl.main.html", true, true);
2596 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2597
2598 $_GET["obj_id"] = $int_link["id"];
2599 $_GET["frame"] = "_blank";
2600 $content = $a_lm_gui->glossary();
2601 $file = $a_target_dir . "/term_" . $int_link["id"] . ".html";
2602
2603 // open file
2604 if (!($fp = @fopen($file, "w+"))) {
2605 die("<b>Error</b>: Could not open \"" . $file . "\" for writing" .
2606 " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />");
2607 }
2608 chmod($file, 0770);
2609 fwrite($fp, $content);
2610 fclose($fp);
2611
2612 // store linked/embedded media objects of glosssary term
2613 include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
2614 $defs = ilGlossaryDefinition::getDefinitionList($int_link["id"]);
2615 foreach ($defs as $def) {
2616 $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
2617 foreach ($def_mobs as $def_mob) {
2618 $this->offline_mobs[$def_mob] = $def_mob;
2619 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
2620 $this->log->debug("HTML Export: Add media object $def_mob (" . ilObject::_lookupTitle($def_mob) . ") " .
2621 " due to glossary entry " . $int_link["id"] . " (" . ilGlossaryTerm::_lookGlossaryTerm($int_link["id"]) . ").");
2622 }
2623
2624 // get all files of page
2625 $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $page["obj_id"]);
2626 $this->offline_files = array_merge($this->offline_files, $def_files);
2627 }
2628 }
2629 }
2630 }
2631
2635 public function exportHTMLPages(&$a_lm_gui, $a_target_dir, $a_lang = "", $a_all_languages = false)
2636 {
2637 $ilLocator = $this->locator;
2638
2639 $pages = ilLMPageObject::getPageList($this->getId());
2640
2641 $lm_tree = $this->getLMTree();
2642 $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg");
2643 $this->first_page_id = $first_page["child"];
2644
2645 // iterate all learning module pages
2646 $mobs = array();
2647 $int_links = array();
2648 $this->offline_files = array();
2649
2650 include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
2651 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2652
2653 // get html export id mapping
2654 $lm_set = new ilSetting("lm");
2655 $exp_id_map = array();
2656
2657 if ($lm_set->get("html_export_ids")) {
2658 foreach ($pages as $page) {
2659 $exp_id = ilLMPageObject::getExportId($this->getId(), $page["obj_id"]);
2660 if (trim($exp_id) != "") {
2661 $exp_id_map[$page["obj_id"]] = trim($exp_id);
2662 }
2663 }
2664 }
2665 //exit;
2666 if ($a_lang == "") {
2667 $a_lang = "-";
2668 }
2669
2670 reset($pages);
2671 foreach ($pages as $page) {
2672 if (ilLMPage::_exists($this->getType(), $page["obj_id"])) {
2673 $ilLocator->clearItems();
2674 $this->exportPageHTML(
2675 $a_lm_gui,
2676 $a_target_dir,
2677 $page["obj_id"],
2678 "",
2679 $exp_id_map,
2680 $a_lang,
2681 $a_all_languages
2682 );
2683
2684 // get all snippets of page
2685 $pcs = ilPageContentUsage::getUsagesOfPage($page["obj_id"], $this->getType() . ":pg", 0, false, $a_lang);
2686 foreach ($pcs as $pc) {
2687 if ($pc["type"] == "incl") {
2688 $incl_mobs = ilObjMediaObject::_getMobsOfObject("mep:pg", $pc["id"]);
2689 foreach ($incl_mobs as $incl_mob) {
2690 $mobs[$incl_mob] = $incl_mob;
2691 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
2692 $this->log->debug("HTML Export: Add media object $incl_mob (" . ilObject::_lookupTitle($incl_mob) . ") " .
2693 " due to snippet " . $pc["id"] . " in page " . $page["obj_id"] . " (" . ilLMObject::_lookupTitle($page["obj_id"]) . ").");
2694 }
2695 }
2696 }
2697
2698 // get all media objects of page
2699 $pg_mobs = ilObjMediaObject::_getMobsOfObject($this->getType() . ":pg", $page["obj_id"], 0, $a_lang);
2700 foreach ($pg_mobs as $pg_mob) {
2701 $mobs[$pg_mob] = $pg_mob;
2702 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
2703 $this->log->debug("HTML Export: Add media object $pg_mob (" . ilObject::_lookupTitle($pg_mob) . ") " .
2704 " due to page " . $page["obj_id"] . " (" . ilLMObject::_lookupTitle($page["obj_id"]) . ").");
2705 }
2706
2707 // get all internal links of page
2708 $pg_links = ilInternalLink::_getTargetsOfSource($this->getType() . ":pg", $page["obj_id"], $a_lang);
2709 $int_links = array_merge($int_links, $pg_links);
2710
2711 // get all files of page
2712 include_once("./Modules/File/classes/class.ilObjFile.php");
2713 $pg_files = ilObjFile::_getFilesOfObject($this->getType() . ":pg", $page["obj_id"], 0, $a_lang);
2714 $this->offline_files = array_merge($this->offline_files, $pg_files);
2715
2716 // collect all questions
2717 include_once("./Services/COPage/classes/class.ilPCQuestion.php");
2718 $q_ids = ilPCQuestion::_getQuestionIdsForPage($this->getType(), $page["obj_id"], $a_lang);
2719 foreach ($q_ids as $q_id) {
2720 $this->q_ids[$q_id] = $q_id;
2721 }
2722 }
2723 }
2724 foreach ($mobs as $m) {
2725 $this->offline_mobs[$m] = $m;
2726 }
2727 foreach ($int_links as $k => $v) {
2728 $this->offline_int_links[$k] = $v;
2729 }
2730 }
2731
2732
2733
2737 public function exportPageHTML(
2738 &$a_lm_gui,
2739 $a_target_dir,
2740 $a_lm_page_id,
2741 $a_frame = "",
2742 $a_exp_id_map = array(),
2743 $a_lang = "-",
2744 $a_all_languages = false
2745 ) {
2746 $tpl = $this->tpl;
2747
2748 $lang_suffix = "";
2749 if ($a_lang != "-" && $a_lang != "" && $a_all_languages) {
2750 $lang_suffix = "_" . $a_lang;
2751 }
2752
2753 //echo "<br>B: export Page HTML ($a_lm_page_id)"; flush();
2754 // template workaround: reset of template
2755 $tpl = new ilTemplate("tpl.main.html", true, true);
2756 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2757
2758 include_once("./Services/COPage/classes/class.ilPCQuestion.php");
2760
2761 $_GET["obj_id"] = $a_lm_page_id;
2762 $_GET["frame"] = $a_frame;
2763
2764 if ($a_frame == "") {
2765 //if ($nid = ilLMObject::_lookupNID($a_lm_gui->lm->getId(), $a_lm_page_id, "pg"))
2766 if (is_array($a_exp_id_map) && isset($a_exp_id_map[$a_lm_page_id])) {
2767 $file = $a_target_dir . "/lm_pg_" . $a_exp_id_map[$a_lm_page_id] . $lang_suffix . ".html";
2768 } else {
2769 $file = $a_target_dir . "/lm_pg_" . $a_lm_page_id . $lang_suffix . ".html";
2770 }
2771 } else {
2772 if ($a_frame != "toc") {
2773 $file = $a_target_dir . "/frame_" . $a_lm_page_id . "_" . $a_frame . $lang_suffix . ".html";
2774 } else {
2775 $file = $a_target_dir . "/frame_" . $a_frame . $lang_suffix . ".html";
2776 }
2777 }
2778
2779 // return if file is already existing
2780 if (@is_file($file)) {
2781 return;
2782 }
2783
2784 $content = $a_lm_gui->layout("main.xml", false);
2785
2786 // open file
2787 if (!($fp = @fopen($file, "w+"))) {
2788 die("<b>Error</b>: Could not open \"" . $file . "\" for writing" .
2789 " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />");
2790 }
2791
2792 // set file permissions
2793 chmod($file, 0770);
2794
2795 // write xml data into the file
2796 fwrite($fp, $content);
2797
2798 // close file
2799 fclose($fp);
2800
2801 if ($this->first_page_id == $a_lm_page_id && $a_frame == "") {
2802 copy($file, $a_target_dir . "/index" . $lang_suffix . ".html");
2803 }
2804
2805 // write frames of frameset
2806 $frameset = $a_lm_gui->getCurrentFrameSet();
2807
2808 foreach ($frameset as $frame) {
2809 $this->exportPageHTML($a_lm_gui, $a_target_dir, $a_lm_page_id, $frame);
2810 }
2811 }
2812
2819 public function exportFO(&$a_xml_writer, $a_target_dir)
2820 {
2821 // fo:root (start)
2822 $attrs = array();
2823 $attrs["xmlns:fo"] = "http://www.w3.org/1999/XSL/Format";
2824 $a_xml_writer->xmlStartTag("fo:root", $attrs);
2825
2826 // fo:layout-master-set (start)
2827 $attrs = array();
2828 $a_xml_writer->xmlStartTag("fo:layout-master-set", $attrs);
2829
2830 // fo:simple-page-master (start)
2831 $attrs = array();
2832 $attrs["master-name"] = "DinA4";
2833 $attrs["page-height"] = "29.7cm";
2834 $attrs["page-width"] = "21cm";
2835 $attrs["margin-top"] = "4cm";
2836 $attrs["margin-bottom"] = "1cm";
2837 $attrs["margin-left"] = "2.8cm";
2838 $attrs["margin-right"] = "7.3cm";
2839 $a_xml_writer->xmlStartTag("fo:simple-page-master", $attrs);
2840
2841 // fo:region-body (complete)
2842 $attrs = array();
2843 $attrs["margin-top"] = "0cm";
2844 $attrs["margin-bottom"] = "1.25cm";
2845 $a_xml_writer->xmlElement("fo:region-body", $attrs);
2846
2847 // fo:region-before (complete)
2848 $attrs = array();
2849 $attrs["extent"] = "1cm";
2850 $a_xml_writer->xmlElement("fo:region-before", $attrs);
2851
2852 // fo:region-after (complete)
2853 $attrs = array();
2854 $attrs["extent"] = "1cm";
2855 $a_xml_writer->xmlElement("fo:region-after", $attrs);
2856
2857 // fo:simple-page-master (end)
2858 $a_xml_writer->xmlEndTag("fo:simple-page-master");
2859
2860 // fo:layout-master-set (end)
2861 $a_xml_writer->xmlEndTag("fo:layout-master-set");
2862
2863 // fo:page-sequence (start)
2864 $attrs = array();
2865 $attrs["master-reference"] = "DinA4";
2866 $a_xml_writer->xmlStartTag("fo:page-sequence", $attrs);
2867
2868 // fo:flow (start)
2869 $attrs = array();
2870 $attrs["flow-name"] = "xsl-region-body";
2871 $a_xml_writer->xmlStartTag("fo:flow", $attrs);
2872
2873
2874 // StructureObjects
2875 $this->exportFOStructureObjects($a_xml_writer, $expLog);
2876
2877 // fo:flow (end)
2878 $a_xml_writer->xmlEndTag("fo:flow");
2879
2880 // fo:page-sequence (end)
2881 $a_xml_writer->xmlEndTag("fo:page-sequence");
2882
2883 // fo:root (end)
2884 $a_xml_writer->xmlEndTag("fo:root");
2885 }
2886
2893 public function exportFOStructureObjects(&$a_xml_writer)
2894 {
2895 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
2896 foreach ($childs as $child) {
2897 if ($child["type"] != "st") {
2898 continue;
2899 }
2900
2901 $structure_obj = new ilStructureObject($this, $child["obj_id"]);
2902 $structure_obj->exportFO($a_xml_writer, $expLog);
2903 unset($structure_obj);
2904 }
2905 }
2906
2907 public function getXMLZip()
2908 {
2909 include_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2910
2911 $cont_exp = new ilContObjectExport($this, 'xml');
2912
2913 $export_file = $cont_exp->buildExportFile();
2914 return $export_file;
2915 }
2916
2925 public function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
2926 {
2927 $lmtree = new ilTree($this->getId());
2928 $lmtree->setTableNames('lm_tree', 'lm_data');
2929 $lmtree->setTreeTablePK("lm_id");
2930 //echo "-".$source_id."-".$target_id."-".$first_child."-".$as_subitem."-";
2931 $source_obj = ilLMObjectFactory::getInstance($this, $source_id, true);
2932 $source_obj->setLMId($this->getId());
2933
2934 if (!$first_child) {
2935 $target_obj = ilLMObjectFactory::getInstance($this, $target_id, true);
2936 $target_obj->setLMId($this->getId());
2937 $target_parent = $lmtree->getParentId($target_id);
2938 }
2939
2940 // handle pages
2941 if ($source_obj->getType() == "pg") {
2942 //echo "1";
2943 if ($lmtree->isInTree($source_obj->getId())) {
2944 $node_data = $lmtree->getNodeData($source_obj->getId());
2945
2946 // cut on move
2947 if ($movecopy == "move") {
2948 $parent_id = $lmtree->getParentId($source_obj->getId());
2949 $lmtree->deleteTree($node_data);
2950
2951 // write history entry
2952 require_once("./Services/History/classes/class.ilHistory.php");
2954 $source_obj->getId(),
2955 "cut",
2956 array(ilLMObject::_lookupTitle($parent_id), $parent_id),
2957 $this->getType() . ":pg"
2958 );
2960 $parent_id,
2961 "cut_page",
2962 array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()),
2963 $this->getType() . ":st"
2964 );
2965 } else {
2966 // copy page
2967 $new_page = $source_obj->copy();
2968 $source_id = $new_page->getId();
2969 $source_obj = $new_page;
2970 }
2971
2972 // paste page
2973 if (!$lmtree->isInTree($source_obj->getId())) {
2974 if ($first_child) { // as first child
2975 $target_pos = IL_FIRST_NODE;
2976 $parent = $target_id;
2977 } elseif ($as_subitem) { // as last child
2978 $parent = $target_id;
2979 $target_pos = IL_FIRST_NODE;
2980 $pg_childs = $lmtree->getChildsByType($parent, "pg");
2981 if (count($pg_childs) != 0) {
2982 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
2983 }
2984 } else { // at position
2985 $target_pos = $target_id;
2986 $parent = $target_parent;
2987 }
2988
2989 // insert page into tree
2990 $lmtree->insertNode(
2991 $source_obj->getId(),
2992 $parent,
2993 $target_pos
2994 );
2995
2996 // write history entry
2997 if ($movecopy == "move") {
2998 // write history comments
2999 include_once("./Services/History/classes/class.ilHistory.php");
3001 $source_obj->getId(),
3002 "paste",
3003 array(ilLMObject::_lookupTitle($parent), $parent),
3004 $this->getType() . ":pg"
3005 );
3007 $parent,
3008 "paste_page",
3009 array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()),
3010 $this->getType() . ":st"
3011 );
3012 }
3013 }
3014 }
3015 }
3016
3017 // handle chapters
3018 if ($source_obj->getType() == "st") {
3019 //echo "2";
3020 $source_node = $lmtree->getNodeData($source_id);
3021 $subnodes = $lmtree->getSubtree($source_node);
3022
3023 // check, if target is within subtree
3024 foreach ($subnodes as $subnode) {
3025 if ($subnode["obj_id"] == $target_id) {
3026 return;
3027 }
3028 }
3029
3030 $target_pos = $target_id;
3031
3032 if ($first_child) { // as first subchapter
3033 $target_pos = IL_FIRST_NODE;
3034 $target_parent = $target_id;
3035
3036 $pg_childs = $lmtree->getChildsByType($target_parent, "pg");
3037 if (count($pg_childs) != 0) {
3038 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
3039 }
3040 } elseif ($as_subitem) { // as last subchapter
3041 $target_parent = $target_id;
3042 $target_pos = IL_FIRST_NODE;
3043 $childs = $lmtree->getChilds($target_parent);
3044 if (count($childs) != 0) {
3045 $target_pos = $childs[count($childs) - 1]["obj_id"];
3046 }
3047 }
3048
3049 // insert into
3050 /*
3051 if ($position == "into")
3052 {
3053 $target_parent = $target_id;
3054 $target_pos = IL_FIRST_NODE;
3055
3056 // if target_pos is still first node we must skip all pages
3057 if ($target_pos == IL_FIRST_NODE)
3058 {
3059 $pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
3060 if (count($pg_childs) != 0)
3061 {
3062 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
3063 }
3064 }
3065 }
3066 */
3067
3068
3069 // delete source tree
3070 if ($movecopy == "move") {
3071 $lmtree->deleteTree($source_node);
3072 } else {
3073 // copy chapter (incl. subcontents)
3074 $new_chapter = $source_obj->copy($lmtree, $target_parent, $target_pos);
3075 }
3076
3077 if (!$lmtree->isInTree($source_id)) {
3078 $lmtree->insertNode($source_id, $target_parent, $target_pos);
3079
3080 // insert moved tree
3081 if ($movecopy == "move") {
3082 foreach ($subnodes as $node) {
3083 if ($node["obj_id"] != $source_id) {
3084 $lmtree->insertNode($node["obj_id"], $node["parent"]);
3085 }
3086 }
3087 }
3088 }
3089
3090 // check the tree
3091 $this->checkTree();
3092 }
3093
3094 $this->checkTree();
3095 }
3096
3100 public function validatePages()
3101 {
3102 include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
3103 include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
3104
3105 $mess = "";
3106
3107 $pages = ilLMPageObject::getPageList($this->getId());
3108 foreach ($pages as $page) {
3109 if (ilLMPage::_exists($this->getType(), $page["obj_id"])) {
3110 $cpage = new ilLMPage($page["obj_id"]);
3111 $cpage->buildDom();
3112 $error = @$cpage->validateDom();
3113
3114 if ($error != "") {
3115 $this->lng->loadLanguageModule("content");
3116 ilUtil::sendInfo($this->lng->txt("cont_import_validation_errors"));
3117 $title = ilLMObject::_lookupTitle($page["obj_id"]);
3118 $page_obj = new ilLMPageObject($this, $page["obj_id"]);
3119 $mess .= $this->lng->txt("obj_pg") . ": " . $title;
3120 $mess .= '<div class="small">';
3121 foreach ($error as $e) {
3122 $err_mess = implode($e, " - ");
3123 if (!is_int(strpos($err_mess, ":0:"))) {
3124 $mess .= htmlentities($err_mess) . "<br />";
3125 }
3126 }
3127 $mess .= '</div>';
3128 $mess .= "<br />";
3129 }
3130 }
3131 }
3132
3133 return $mess;
3134 }
3135
3142 public function importFromZipFile(
3143 $a_tmp_file,
3144 $a_filename,
3145 $a_validate = true,
3146 $a_import_into_help_module = 0
3147 ) {
3148 $lng = $this->lng;
3149
3150 // create import directory
3151 $this->createImportDirectory();
3152
3153 // copy uploaded file to import directory
3154 $file = pathinfo($a_filename);
3155 $full_path = $this->getImportDirectory() . "/" . $a_filename;
3156
3157 ilUtil::moveUploadedFile(
3158 $a_tmp_file,
3159 $a_filename,
3160 $full_path
3161 );
3162
3163 // unzip file
3164 ilUtil::unzip($full_path);
3165
3166 $subdir = basename($file["basename"], "." . $file["extension"]);
3167
3168 $mess = $this->importFromDirectory(
3169 $this->getImportDirectory() . "/" . $subdir,
3170 $a_validate
3171 );
3172
3173
3174 // delete import directory
3176
3177 return $mess;
3178 }
3179
3180
3187 // begin-patch optes_lok_export
3188 public function importFromDirectory($a_directory, $a_validate = true, $a_mapping = null)
3189 // end-patch optes_lok_export
3190 {
3191 $lng = $this->lng;
3192
3193 $this->log->debug("import from directory " . $a_directory);
3194
3195 // determine filename of xml file
3196 $subdir = basename($a_directory);
3197 $xml_file = $a_directory . "/" . $subdir . ".xml";
3198
3199 // check directory exists within zip file
3200 if (!is_dir($a_directory)) {
3201 $this->log->error(sprintf($lng->txt("cont_no_subdir_in_zip"), $subdir));
3202 return sprintf($lng->txt("cont_no_subdir_in_zip"), $subdir);
3203 }
3204
3205 // check whether xml file exists within zip file
3206 if (!is_file($xml_file)) {
3207 $this->log->error(sprintf($lng->txt("cont_zip_file_invalid"), $subdir . "/" . $subdir . ".xml"));
3208 return sprintf($lng->txt("cont_zip_file_invalid"), $subdir . "/" . $subdir . ".xml");
3209 }
3210
3211 // import questions
3212 $this->log->debug("import qti");
3213 $qti_file = $a_directory . "/qti.xml";
3214 $qtis = array();
3215 if (is_file($qti_file)) {
3216 include_once "./Services/QTI/classes/class.ilQTIParser.php";
3217 include_once("./Modules/Test/classes/class.ilObjTest.php");
3218 $qtiParser = new ilQTIParser(
3219 $qti_file,
3221 0,
3222 ""
3223 );
3224 $result = $qtiParser->startParsing();
3225 $founditems = &$qtiParser->getFoundItems();
3226 $testObj = new ilObjTest(0, true);
3227 if (count($founditems) > 0) {
3228 $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, 0, "");
3229 $qtiParser->setTestObject($testObj);
3230 $result = $qtiParser->startParsing();
3231 $qtis = array_merge($qtis, $qtiParser->getImportMapping());
3232 }
3233 }
3234
3235 $this->log->debug("get ilContObjParser");
3236 include_once("./Modules/LearningModule/classes/class.ilContObjParser.php");
3237 $subdir = ".";
3238 $contParser = new ilContObjParser($this, $xml_file, $subdir, $a_directory);
3239 // smeyer: added \ilImportMapping lok im/export
3240 $contParser->setImportMapping($a_mapping);
3241 $contParser->setQuestionMapping($qtis);
3242 $contParser->startParsing();
3243 ilObject::_writeImportId($this->getId(), $this->getImportId());
3244 $this->MDUpdateListener('General');
3245
3246 // import style
3247 $style_file = $a_directory . "/style.xml";
3248 $style_zip_file = $a_directory . "/style.zip";
3249 if (is_file($style_zip_file)) { // try to import style.zip first
3250 require_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3251 $style = new ilObjStyleSheet();
3252 $style->import($style_zip_file);
3253 $this->writeStyleSheetId($style->getId());
3254 } elseif (is_file($style_file)) { // try to import style.xml
3255 require_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3256 $style = new ilObjStyleSheet();
3257 $style->import($style_file);
3258 $this->writeStyleSheetId($style->getId());
3259 }
3260
3261 // // validate
3262 if ($a_validate) {
3263 $mess = $this->validatePages();
3264 }
3265
3266 if ($mess == "") {
3267 // handle internal links to this learning module
3268 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
3270 $this->getImportId(),
3271 $this->getType(),
3272 $this->getRefId()
3273 );
3274 }
3275
3276 return $mess;
3277 }
3278
3287 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
3288 {
3289 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
3290 $this->cloneMetaData($new_obj);
3291 //$new_obj->createProperties();
3292
3293 //copy online status if object is not the root copy object
3294 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
3295
3296 if (!$cp_options->isRootNode($this->getRefId())) {
3297 $new_obj->setOfflineStatus($this->getOfflineStatus());
3298 }
3299
3300 // $new_obj->setTitle($this->getTitle());
3301 $new_obj->setDescription($this->getDescription());
3302 $new_obj->setLayoutPerPage($this->getLayoutPerPage());
3303 $new_obj->setLayout($this->getLayout());
3304 $new_obj->setTOCMode($this->getTOCMode());
3305 $new_obj->setActiveLMMenu($this->isActiveLMMenu());
3306 $new_obj->setActiveTOC($this->isActiveTOC());
3307 $new_obj->setActiveNumbering($this->isActiveNumbering());
3308 $new_obj->setActivePrintView($this->isActivePrintView());
3309 $new_obj->setActivePreventGlossaryAppendix($this->isActivePreventGlossaryAppendix());
3310 $new_obj->setActiveDownloads($this->isActiveDownloads());
3311 $new_obj->setActiveDownloadsPublic($this->isActiveDownloadsPublic());
3312 $new_obj->setPublicNotes($this->publicNotes());
3313 $new_obj->setCleanFrames($this->cleanFrames());
3314 $new_obj->setHistoryUserComments($this->isActiveHistoryUserComments());
3315 $new_obj->setPublicAccessMode($this->getPublicAccessMode());
3316 $new_obj->setPageHeader($this->getPageHeader());
3317 $new_obj->setRating($this->hasRating());
3318 $new_obj->setRatingPages($this->hasRatingPages());
3319 $new_obj->setDisableDefaultFeedback($this->getDisableDefaultFeedback());
3320 $new_obj->setProgressIcons($this->getProgressIcons());
3321 $new_obj->setStoreTries($this->getStoreTries());
3322 $new_obj->setRestrictForwardNavigation($this->getRestrictForwardNavigation());
3323 $new_obj->setAutoGlossaries($this->getAutoGlossaries());
3324
3325 $new_obj->update();
3326
3327 $new_obj->createLMTree();
3328
3329 // copy style
3330 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3331 $style_id = $this->getStyleSheetId();
3332 if ($style_id > 0 &&
3335 $new_id = $style_obj->ilClone();
3336 $new_obj->setStyleSheetId($new_id);
3337 } else { // or just set the same standard style
3338 $new_obj->setStyleSheetId($style_id);
3339 }
3340 $new_obj->update();
3341
3342 // copy content
3343 $copied_nodes = $this->copyAllPagesAndChapters($new_obj, $a_copy_id);
3344
3345 // page header and footer
3346 if ($this->getHeaderPage() > 0 && ($new_page_header = $copied_nodes[$this->getHeaderPage()]) > 0) {
3347 $new_obj->setHeaderPage($new_page_header);
3348 }
3349 if ($this->getFooterPage() > 0 && ($new_page_footer = $copied_nodes[$this->getFooterPage()]) > 0) {
3350 $new_obj->setFooterPage($new_page_footer);
3351 }
3352 $new_obj->update();
3353
3354 // Copy learning progress settings
3355 include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
3356 $obj_settings = new ilLPObjSettings($this->getId());
3357 $obj_settings->cloneSettings($new_obj->getId());
3358 unset($obj_settings);
3359
3360 // copy (page) multilang settings
3361 include_once("./Services/Object/classes/class.ilObjectTranslation.php");
3363 $ot->copy($new_obj->getId());
3364
3365 // copy lm menu
3366 include_once './Modules/LearningModule/classes/class.ilLMMenuEditor.php';
3367 $menu = new ilLMMenuEditor();
3368 $menu->setObjId($this->getId());
3369 $new_menu = new ilLMMenuEditor();
3370 $new_menu->setObjId($new_obj->getId());
3371 foreach ($menu->getMenuEntries() as $entry) {
3372 /*'id' => $row->id,
3373 'title' => $row->title,
3374 'link' => $row->target,
3375 'type' => $row->link_type,
3376 'ref_id' => $row->link_ref_id,
3377 'active'*/
3378
3379 $new_menu->setTarget($entry["link"]);
3380 $new_menu->setTitle($entry["title"]);
3381 $new_menu->setLinkType($entry["type"]);
3382 $new_menu->setLinkRefId($entry["ref_id"]);
3383 $new_menu->create();
3384 ilLMMenuEditor::writeActive($new_menu->getEntryId(), $entry["active"] == "y" ? true : false);
3385 }
3386
3387
3388 return $new_obj;
3389 }
3390
3396 public function copyAllPagesAndChapters($a_target_obj, $a_copy_id = 0)
3397 {
3398 $parent_id = $a_target_obj->lm_tree->readRootId();
3399
3400 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
3401 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
3402
3403 // get all chapters of root lm
3404 $chapters = $this->lm_tree->getChildsByType($this->lm_tree->readRootId(), "st");
3405 $copied_nodes = array();
3406 //$time = time();
3407 foreach ($chapters as $chap) {
3408 $cid = ilLMObject::pasteTree(
3409 $a_target_obj,
3410 $chap["child"],
3411 $parent_id,
3413 $time,
3414 $copied_nodes,
3415 true,
3416 $this
3417 );
3418 $target = $cid;
3419 }
3420
3421 // copy free pages
3422 $pages = ilLMPageObject::getPageList($this->getId());
3423 foreach ($pages as $p) {
3424 if (!$this->lm_tree->isInTree($p["obj_id"])) {
3425 $item = new ilLMPageObject($this, $p["obj_id"]);
3426 $target_item = $item->copy($a_target_obj);
3427 $copied_nodes[$item->getId()] = $target_item->getId();
3428 }
3429 }
3430
3431 // Add mapping for pages and chapters
3432 include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
3434 foreach ($copied_nodes as $old_id => $new_id) {
3435 $options->appendMapping(
3436 $this->getRefId() . '_' . $old_id,
3437 $a_target_obj->getRefId() . '_' . $new_id
3438 );
3439 }
3440
3441 ilLMObject::updateInternalLinks($copied_nodes);
3442
3443 $a_target_obj->checkTree();
3444
3445 return $copied_nodes;
3446 }
3447
3448
3455 public static function lookupAutoGlossaries($a_lm_id)
3456 {
3457 global $DIC;
3458
3459 $ilDB = $DIC->database();
3460
3461 // read auto glossaries
3462 $set = $ilDB->query(
3463 "SELECT * FROM lm_glossaries " .
3464 " WHERE lm_id = " . $ilDB->quote($a_lm_id, "integer")
3465 );
3466 $glos = array();
3467 while ($rec = $ilDB->fetchAssoc($set)) {
3468 $glos[] = $rec["glo_id"];
3469 }
3470 return $glos;
3471 }
3472
3479 public function autoLinkGlossaryTerms($a_glo_ref_id)
3480 {
3481 // get terms
3482 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
3483 $terms = ilGlossaryTerm::getTermList($a_glo_ref_id);
3484
3485 // each get page: get content
3486 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
3487 $pages = ilLMPage::getAllPages($this->getType(), $this->getId());
3488
3489 // determine terms that occur in the page
3490 $found_pages = array();
3491 foreach ($pages as $p) {
3492 $pg = new ilLMPage($p["id"]);
3493 $c = $pg->getXMLContent();
3494 foreach ($terms as $t) {
3495 if (is_int(stripos($c, $t["term"]))) {
3496 $found_pages[$p["id"]]["terms"][] = $t;
3497 if (!is_object($found_pages[$p["id"]]["page"])) {
3498 $found_pages[$p["id"]]["page"] = $pg;
3499 }
3500 }
3501 }
3502 reset($terms);
3503 }
3504
3505 // ilPCParagraph autoLinkGlossariesPage with page and terms
3506 include_once("./Services/COPage/classes/class.ilPCParagraph.php");
3507 foreach ($found_pages as $id => $fp) {
3508 ilPCParagraph::autoLinkGlossariesPage($fp["page"], $fp["terms"]);
3509 }
3510 }
3511
3512
3516
3522 public static function isOnlineHelpModule($a_id, $a_as_obj_id = false)
3523 {
3524 if (!$a_as_obj_id && $a_id > 0 && $a_id == OH_REF_ID) {
3525 return true;
3526 }
3527 if ($a_as_obj_id && $a_id > 0 && $a_id == ilObject::_lookupObjId(OH_REF_ID)) {
3528 return true;
3529 }
3530 return false;
3531 }
3532
3533 public function setRating($a_value)
3534 {
3535 $this->rating = (bool) $a_value;
3536 }
3537
3538 public function hasRating()
3539 {
3540 return $this->rating;
3541 }
3542
3543 public function setRatingPages($a_value)
3544 {
3545 $this->rating_pages = (bool) $a_value;
3546 }
3547
3548 public function hasRatingPages()
3549 {
3550 return $this->rating_pages;
3551 }
3552
3553
3554 public function MDUpdateListener($a_element)
3555 {
3556 parent::MDUpdateListener($a_element);
3557
3558 include_once 'Services/MetaData/classes/class.ilMD.php';
3559
3560 switch ($a_element) {
3561 case 'Educational':
3562 include_once("./Services/Object/classes/class.ilObjectLP.php");
3563 $obj_lp = ilObjectLP::getInstance($this->getId());
3564 if (in_array(
3565 $obj_lp->getCurrentMode(),
3567 )) {
3568 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
3570 }
3571 break;
3572
3573 case 'General':
3574
3575 // Update Title and description
3576 $md = new ilMD($this->getId(), 0, $this->getType());
3577 if (!is_object($md_gen = $md->getGeneral())) {
3578 return false;
3579 }
3580
3581 include_once("./Services/Object/classes/class.ilObjectTranslation.php");
3583 if ($ot->getContentActivated()) {
3584 $ot->setDefaultTitle($md_gen->getTitle());
3585
3586 foreach ($md_gen->getDescriptionIds() as $id) {
3587 $md_des = $md_gen->getDescription($id);
3588 $ot->setDefaultDescription($md_des->getDescription());
3589 break;
3590 }
3591 $ot->save();
3592 }
3593 break;
3594
3595 }
3596 return true;
3597 }
3598
3604 public function getPublicExportFiles()
3605 {
3606 $dirs = array("xml", "scorm");
3607 $export_files = array();
3608
3609 include_once("./Services/Object/classes/class.ilObjectTranslation.php");
3611 if ($ot->getContentActivated()) {
3612 $langs = $ot->getLanguages();
3613 foreach ($langs as $l => $ldata) {
3614 $dirs[] = "html_" . $l;
3615 }
3616 $dirs[] = "html_all";
3617 } else {
3618 $dirs[] = "html";
3619 }
3620
3621 foreach ($dirs as $dir) {
3622 $type = explode("_", $dir);
3623 $type = $type[0];
3624 if ($this->getPublicExportFile($type) != "") {
3625 if (is_file($this->getExportDirectory($dir) . "/" .
3626 $this->getPublicExportFile($type))) {
3627 $size = filesize($this->getExportDirectory($dir) . "/" .
3628 $this->getPublicExportFile($type));
3629 $export_files[] = array("type" => $type,
3630 "dir_type" => $dir,
3631 "file" => $this->getPublicExportFile($type),
3632 "size" => $size);
3633 }
3634 }
3635 }
3636
3637 return $export_files;
3638 }
3639}
$result
user()
Definition: user.php:4
$size
Definition: RandomTest.php:84
if(strpos( $jquery_path, './')===0) elseif(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:32
global $l
Definition: afr.php:30
$path
Definition: aliased.php:25
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
const IL_CHAPTER_TITLE
const IL_MO_VERIFY_QTI
const IL_MO_PARSE_QTI
const IL_LAST_NODE
Definition: class.ilTree.php:4
const IL_FIRST_NODE
Definition: class.ilTree.php:5
static _checkCondition($condition, $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
static _checkAllConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type="", $a_usr_id=0)
checks wether all conditions of a target object are fulfilled
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
Content Object Parser.
Export class for content objects.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static getLocalJsTreeCssPath()
Get local path of jsTree js.
static getLocalExplorerJsPath()
Get local path of explorer js.
static getLocalJsTreeJsPath()
Get local path of jsTree js.
static createHTMLExportDirs($a_target_dir)
Create html export directories.
static getDefinitionList($a_term_id)
static
static getTermList( $a_glo_ref_id, $searchterm="", $a_first_letter="", $a_def="", $a_tax_node=0, $a_add_amet_fields=false, array $a_amet_filter=null, $a_include_references=false)
Get all terms for given set of glossary ids.
static _lookGlossaryTerm($term_id)
get glossary term
static _createEntry( $a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.
Content Object (ILIAS native learning module / digilib book) Manifest export class.
class for editing lm menu
static writeActive($entry_id, $active)
Write status for entry id.
static getInstance(&$a_content_obj, $a_id=0, $a_halt=true)
static getExportId($a_lm_id, $a_lmobj_id, $a_type="pg")
Get export ID.
static updateInternalLinks($a_copied_nodes, $a_parent_type="lm")
Update internal links, after multiple pages have been copied.
static _lookupTitle($a_obj_id)
Lookup title.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
static _deleteAllObjectData(&$a_cobj)
delete all objects of content object (digi book / learning module)
static pasteTree( $a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_source_lm=null)
Paste item (tree) from clipboard to current lm.
Class ilLMPageObject.
static getPageList($lm_id)
static
Extension of ilPageObject for learning modules.
Class ilLMPresentationGUI.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static getLocalJsPaths()
Get paths of necessary js files.
static getLogger($a_component_id)
Get component logger.
static getInstance()
Singleton: get instance.
const PURPOSE_EXPORT
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_news_id=0)
Are comments activated for object?
static activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
Activate notes feature.
Class ilObjContentObject.
exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
export media objects to xml (see ilias_co.dtd)
exportFO(&$a_xml_writer, $a_target_dir)
export object to fo
exportHTML($a_target_dir, $log, $a_zip_file=true, $a_export_format="html", $a_lang="")
export html package
exportHTMLGlossaryTerms(&$a_lm_gui, $a_target_dir)
export glossary terms
static lookupAutoGlossaries($a_lm_id)
Lookup auto glossaries.
putInTree($a_parent)
put content object in main tree
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
updateProperties()
Update content object properties.
setAutoGlossaries($a_val)
Set auto glossaries.
setTitle($a_title)
set title of content object
exportFileItems($a_target_dir, &$expLog)
export files of file itmes
exportHTMLPages(&$a_lm_gui, $a_target_dir, $a_lang="", $a_all_languages=false)
export all pages of learning module to html file
getLayoutPerPage()
Get layout per page.
createProperties()
create new properties record
& getLMTree()
get content object tree
static _getNrLMsIndividualStyles()
get number of learning modules with individual styles
setForTranslation($a_val)
Set for translation.
static getAvailableLayouts()
get all available lm layouts
exportSCORM($a_target_dir, $log)
export scorm package
getRestrictForwardNavigation()
Get restrict forward navigation.
getDataDirectory()
get data directory
getHideHeaderFooterPrint()
Get hide header footer in print mode.
exportHTMLFile($a_target_dir, $a_file_id)
export file object
copyAllPagesAndChapters($a_target_obj, $a_copy_id=0)
Copy all pages and chapters.
update()
update complete object (meta data and properties)
getTOCMode()
get toc mode ("chapters" | "pages")
exportXMLPageObjects(&$a_xml_writer, $a_inst, &$expLog)
export page objects to xml (see ilias_co.dtd)
getExportDirectory($a_type="xml")
get export directory of lm
exportXMLMetaData(&$a_xml_writer)
export content objects meta data to xml (see ilias_co.dtd)
static _lookupRestrictForwardNavigation($a_obj_id)
Lookup forward restriction navigation.
static writeHeaderPage($a_lm_id, $a_page_id)
Write header page.
setImportDirectory($a_import_dir)
Set import directory for further use in ilContObjParser.
getForTranslation()
Get for translation.
importFromDirectory($a_directory, $a_validate=true, $a_mapping=null)
Import lm from directory.
getTitle()
get title of content object
static _lookupStoreTries($a_id)
Lookup disable default feedback.
createImportDirectory()
creates data directory for import files (data_dir/lm_data/lm_<id>/import, depending on data directory...
create($a_no_meta_data=false)
create content object
getAutoGlossaries()
Get auto glossaries.
static getSupplyingExportFiles($a_target_dir=".")
Get supplying export files.
static _lookupStyleSheetId($a_cont_obj_id)
lookup style sheet ID
static _getNrLMsNoStyle()
get number of learning modules assigned no style
static writeFooterPage($a_lm_id, $a_page_id)
Write footer page.
static _getMissingPreconditionsTopChapter($cont_obj_ref_id, $cont_obj_id, $page_id)
get top chapter of page for that any precondition is missing
writeStyleSheetId($a_style_id)
write ID of assigned style sheet object to db
setPageHeader($a_pg_header=IL_CHAPTER_TITLE)
set page header mode
removeAutoGlossary($a_glo_id)
Remove auto glossary.
setProgressIcons($a_val)
Set progress icons.
setLayoutPerPage($a_val)
Set layout per page.
autoLinkGlossaryTerms($a_glo_ref_id)
Auto link glossary terms.
createLMTree()
create content object tree (that stores structure object hierarchie)
importFromZipFile( $a_tmp_file, $a_filename, $a_validate=true, $a_import_into_help_module=0)
Import lm from zip file.
getExportFiles()
get export files
getLayout()
get default page layout of content object (see directory layouts/)
getDescription()
get description of content object
exportHTMLMOB($a_target_dir, &$a_lm_gui, $a_mob_id, $a_frame, &$a_linked_mobs)
export media object to html
getPageHeader()
get page header mode (IL_CHAPTER_TITLE | IL_PAGE_TITLE | IL_NO_HEADER)
exportXMLProperties($a_xml_writer, &$expLog)
export properties of content object
static _lookup($a_obj_id, $a_field)
Lookup property.
getPublicAccessMode()
get public access mode ("complete" | "selected")
setRestrictForwardNavigation($a_val)
Set restrict forward navigation.
getImportDirectory()
get import directory of lm
setDisableDefaultFeedback($a_val)
Set disable default feedback for questions.
checkStructure()
Check tree (this has been copied from fixTree due to a bug fixing, should be reorganised)
addFirstChapterAndPage()
Add first chapter and page.
setImportId($a_id)
set import id
readProperties()
read content object properties
getStyleSheetId()
get ID of assigned style sheet object
setHideHeaderFooterPrint($a_val)
Set hide header footer in print mode.
exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
export structure objects to xml (see ilias_co.dtd)
MDUpdateListener($a_element)
Meta data update listener.
static hasSuccessorPage($a_cont_obj_id, $a_page_id)
checks if page has a successor page
static _checkPreconditionsOfPage($cont_ref_id, $cont_obj_id, $page_id)
checks wether the preconditions of a page are fulfilled or not
setDescription($a_description)
set description of content object
exportPageHTML(&$a_lm_gui, $a_target_dir, $a_lm_page_id, $a_frame="", $a_exp_id_map=array(), $a_lang="-", $a_all_languages=false)
export page html
executeDragDrop($source_id, $target_id, $first_child, $as_subitem=false, $movecopy="move")
Execute Drag Drop Action.
setPublicExportFile($a_type, $a_file)
specify public export file for type
validatePages()
Validate all pages.
static _lookupContObjIdByStyleId($a_style_id)
lookup style sheet ID
getStoreTries()
Get store tries.
read()
read data of content object
exportFOStructureObjects(&$a_xml_writer)
export structure objects to fo
updateAutoGlossaries()
Update auto glossaries.
createExportDirectory($a_type="xml")
creates data directory for export files (data_dir/lm_data/lm_<id>/export, depending on data directory...
setStoreTries($a_val)
Set store tries.
setTOCMode($a_toc_mode="chapters")
set toc mode
getProgressIcons()
Get progress icons.
static _getMissingPreconditionsOfPage($cont_ref_id, $cont_obj_id, $page_id)
gets all missing preconditions of page
setStyleSheetId($a_style_id)
set ID of assigned style sheet object
static isOnlineHelpModule($a_id, $a_as_obj_id=false)
Is module an online module.
static _getNrOfAssignedLMs($a_style_id)
gets the number of learning modules assigned to a content style
static _lookupDisableDefaultFeedback($a_id)
Lookup disable default feedback.
static _deleteStyleAssignments($a_style_id)
delete all style references to style
exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
export object to xml (see ilias_co.dtd)
getPublicExportFiles()
Get public export files.
setLayout($a_layout)
set default page layout
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone learning module.
static _moveLMStyles($a_from_style, $a_to_style)
move learning modules from one style to another
getOfflineFiles($dir)
get offline files
getDisableDefaultFeedback()
Get disable default feedback for questions.
getPublicExportFile($a_type)
get public export file
Class ilObjFile.
static _getFilesOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_usage_lang="-")
get all files of an object
Class ilObjMediaObject.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
Class ilObjStyleSheet.
static _lookupStandard($a_id)
Lookup standard flag.
static getSyntaxStylePath()
get syntax style path
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstance($a_obj_id)
static getInstance($a_obj_id)
Get instance.
Class ilObject Basic functions for all objects.
static _writeImportId($a_obj_id, $a_import_id)
write import id to db (static)
getType()
get object type @access public
static _lookupObjId($a_id)
setOfflineStatus($a_status)
Set offline status.
static _lookupTitle($a_id)
lookup object title
deleteMetaData()
delete meta data entry
updateMetaData()
update meta data entry
getOfflineStatus()
Get offline status.
createMetaData()
create meta data entry
getRefId()
get reference id @access public
cloneMetaData($target_obj)
Copy meta data.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
getId()
get object id @access public
static _lookupType($a_id, $a_reference=false)
lookup object type
static autoLinkGlossariesPage($a_page, $a_terms)
Auto link glossary of whole page.
static resetInitialState()
Reset initial state (for exports)
static _getQuestionIdsForPage($a_parent_type, $a_page_id, $a_lang="-")
Get all questions of a page.
static getUsagesOfPage($a_usage_id, $a_usage_type, $a_hist_nr=0, $a_all_hist_nrs=false, $a_lang="-")
Get page content usages for page.
static _handleImportRepositoryLinks($a_rep_import_id, $a_rep_type, $a_rep_ref_id)
Change targest of repository links.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static getAllPages($a_parent_type, $a_parent_id, $a_lang="-")
Get all pages for parent object.
static getLocalMediaElementJsPath()
Get local path of jQuery file.
static getFlashVideoPlayerDirectory()
Get flash video player directory.
static getLocalMediaElementCssPath()
Get local path of jQuery file.
static copyPlayerFilesToTargetDirectory($a_target_dir)
Copy css files to target dir.
ILIAS Setting Class.
Class ilStructreObject.
special template class to simplify handling of ITX/PEAR
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static getDataDir()
get data directory (outside webspace)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static tf2yn($a_tf)
convert true/false to "y"/"n"
static getWebspaceDir($mode="filesystem")
get webspace directory
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static yn2tf($a_yn)
convert "y"/"n" to true/false
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getLocalPath($a_name="")
Get local path of a YUI js file.
static getLocaljQueryUIPath()
static getLocaljQueryPath()
static getLocalMaphilightPath()
Get local path of maphilight file.
$def
Definition: croninfo.php:21
$style
Definition: example_012.php:70
$target_id
Definition: goto.php:49
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
$time
Definition: cron.php:21
$target
Definition: test.php:19
$files
Definition: metarefresh.php:49
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
static getDescription()
Definition: Php.php:51
update($pash, $contents, Config $config)
$ret
Definition: parser.php:6
$ilErr
Definition: raiseError.php:18
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB
$lm_set
$mobs
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92