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