ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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{
29 protected $rating;
30 protected $rating_pages;
31 var $auto_glossaries = array();
32
33 private $import_dir = '';
37 protected $log;
38
45 function __construct($a_id = 0,$a_call_by_reference = true)
46 {
47 // this also calls read() method! (if $a_id is set)
48 parent::__construct($a_id,$a_call_by_reference);
49
50 $this->log = ilLoggerFactory::getLogger('lm');
51
52 $this->mob_ids = array();
53 $this->file_ids = array();
54 $this->q_ids = array();
55 }
56
60 function create($a_no_meta_data = false)
61 {
62 global $ilUser;
63
64 parent::create();
65
66 // meta data will be created by
67 // import parser
68 if (!$a_no_meta_data)
69 {
70 $this->createMetaData();
71 }
72
73 $this->createProperties();
74 $this->updateAutoGlossaries();
75 }
76
77
78
82 function read()
83 {
84 global $ilDB;
85
86 parent::read();
87# echo "Content<br>\n";
88
89 $this->lm_tree = new ilTree($this->getId());
90 $this->lm_tree->setTableNames('lm_tree','lm_data');
91 $this->lm_tree->setTreeTablePK("lm_id");
92
93 $this->readProperties();
94
95 // read auto glossaries
96 $set = $ilDB->query("SELECT * FROM lm_glossaries ".
97 " WHERE lm_id = ".$ilDB->quote($this->getId(), "integer")
98 );
99 $glos = array();
100 while ($rec = $ilDB->fetchAssoc($set))
101 {
102 $glos[] = $rec["glo_id"];
103 }
104 $this->setAutoGlossaries($glos);
105
106 //parent::read();
107 }
108
114 function getTitle()
115 {
116 return parent::getTitle();
117 }
118
122 function setTitle($a_title)
123 {
124 parent::setTitle($a_title);
125// $this->meta_data->setTitle($a_title);
126 }
127
133 function getDescription()
134 {
135 return parent::getDescription();
136 }
137
141 function setDescription($a_description)
142 {
143 parent::setDescription($a_description);
144// $this->meta_data->setDescription($a_description);
145 }
146
147
148 function getImportId()
149 {
150 return $this->import_id;
151 }
152
153 function setImportId($a_id)
154 {
155 $this->import_id = $a_id;
156 }
157
163 function setLayoutPerPage($a_val)
164 {
165 $this->layout_per_page = $a_val;
166 }
167
174 {
175 return $this->layout_per_page;
176 }
177
184 {
185 $this->disable_def_feedback = $a_val;
186 }
187
194 {
195 return $this->disable_def_feedback;
196 }
197
203 function setProgressIcons($a_val)
204 {
205 $this->progr_icons = $a_val;
206 }
207
214 {
215 return $this->progr_icons;
216 }
217
223 function setStoreTries($a_val)
224 {
225 $this->store_tries = $a_val;
226 }
227
233 function getStoreTries()
234 {
235 return $this->store_tries;
236 }
237
244 {
245 $this->restrict_forw_nav = $a_val;
246 }
247
254 {
255 return $this->restrict_forw_nav;
256 }
257
258
259 function &getTree()
260 {
261 return $this->lm_tree;
262 }
263
267 function update()
268 {
269 $this->updateMetaData();
270 parent::update();
271 $this->updateProperties();
272 $this->updateAutoGlossaries();
273 }
274
282 {
283 global $ilDB;
284
285 // update auto glossaries
286 $ilDB->manipulate("DELETE FROM lm_glossaries WHERE ".
287 " lm_id = ".$ilDB->quote($this->getId(), "integer")
288 );
289 foreach ($this->getAutoGlossaries() as $glo_id)
290 {
291 $ilDB->manipulate("INSERT INTO lm_glossaries ".
292 "(lm_id, glo_id) VALUES (".
293 $ilDB->quote($this->getId(), "integer").",".
294 $ilDB->quote($glo_id, "integer").
295 ")");
296 }
297 }
298
299
303 function import()
304 {
305 // nothing to do. just display the dialogue in Out
306 return;
307 }
308
309
314 function putInTree($a_parent)
315 {
316 global $tree;
317
318 // put this object in tree under $a_parent
319 parent::putInTree($a_parent);
320
321 // make new tree for this object
322 //$tree->addTree($this->getId());
323 }
324
325
331 function createLMTree()
332 {
333 $this->lm_tree = new ilTree($this->getId());
334 $this->lm_tree->setTreeTablePK("lm_id");
335 $this->lm_tree->setTableNames('lm_tree','lm_data');
336 $this->lm_tree->addTree($this->getId(), 1);
337 }
338
344 function setAutoGlossaries($a_val)
345 {
346 $this->auto_glossaries = array();
347 if (is_array($a_val))
348 {
349 foreach ($a_val as $v)
350 {
351 $v = (int) $v;
352 if ($v > 0 && ilObject::_lookupType($v) == "glo" &&
353 !in_array($v, $this->auto_glossaries))
354 {
355 $this->auto_glossaries[] = $v;
356 }
357 }
358 }
359 }
360
367 {
369 }
370
377 function removeAutoGlossary($a_glo_id)
378 {
379 $glo_ids = array();
380 foreach($this->getAutoGlossaries() as $g)
381 {
382 if ($g != $a_glo_id)
383 {
384 $glo_ids[] = $g;
385 }
386 }
387 $this->setAutoGlossaries($glo_ids);
388 }
389
390
395 {
396 global $lng;
397
398 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
399 include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
400 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
401
402 $root_id = $this->lm_tree->getRootId();
403
404 // chapter
405 $chap = new ilStructureObject($this);
406 $chap->setType("st");
407 $chap->setTitle($lng->txt("cont_new_chap"));
408 $chap->setLMId($this->getId());
409 $chap->create();
410 ilLMObject::putInTree($chap, $root_id, IL_FIRST_NODE);
411
412 // page
413 $page = new ilLMPageObject($this);
414 $page->setType("pg");
415 $page->setTitle($lng->txt("cont_new_page"));
416 $page->setLMId($this->getId());
417 $page->create();
418 ilLMObject::putInTree($page, $chap->getId(), IL_FIRST_NODE);
419 }
420
426 function setForTranslation($a_val)
427 {
428 $this->for_translation = $a_val;
429 }
430
437 {
439 }
440
444 function &getLMTree()
445 {
446 return $this->lm_tree;
447 }
448
449
456 {
457 $lm_data_dir = ilUtil::getDataDir()."/lm_data";
458 if(!is_writable($lm_data_dir))
459 {
460 $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir
461 .") not writeable.",$this->ilias->error_obj->FATAL);
462 }
463
464 // create learning module directory (data_dir/lm_data/lm_<id>)
465 $lm_dir = $lm_data_dir."/lm_".$this->getId();
466 ilUtil::makeDir($lm_dir);
467 if(!@is_dir($lm_dir))
468 {
469 $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
470 }
471
472 // create import subdirectory (data_dir/lm_data/lm_<id>/import)
473 $import_dir = $lm_dir."/import";
475 if(!@is_dir($import_dir))
476 {
477 $this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
478 }
479 }
480
485 {
486 return ilUtil::getDataDir()."/lm_data".
487 "/lm_".$this->getId();
488 }
489
494 {
495 if(strlen($this->import_dir))
496 {
497 return $this->import_dir;
498 }
499
500 $import_dir = ilUtil::getDataDir()."/lm_data".
501 "/lm_".$this->getId()."/import";
502 if(@is_dir($import_dir))
503 {
504 return $import_dir;
505 }
506 else
507 {
508 return false;
509 }
510 }
511
518 public function setImportDirectory($a_import_dir)
519 {
520 $this->import_dir = $a_import_dir;
521 }
522
523
530 {
531 $lm_data_dir = ilUtil::getDataDir()."/lm_data";
532 if(!is_writable($lm_data_dir))
533 {
534 $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir
535 .") not writeable.",$this->ilias->error_obj->FATAL);
536 }
537 // create learning module directory (data_dir/lm_data/lm_<id>)
538 $lm_dir = $lm_data_dir."/lm_".$this->getId();
539 ilUtil::makeDir($lm_dir);
540 if(!@is_dir($lm_dir))
541 {
542 $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
543 }
544 // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
545 switch ($a_type)
546 {
547 // scorm
548 case "scorm":
549 $export_dir = $lm_dir."/export_scorm";
550 break;
551
552 default: // = xml
553 if (substr($a_type, 0, 4) == "html")
554 {
555 $export_dir = $lm_dir."/export_".$a_type;
556 }
557 else
558 {
559 $export_dir = $lm_dir."/export";
560 }
561 break;
562 }
563 ilUtil::makeDir($export_dir);
564
565 if(!@is_dir($export_dir))
566 {
567 $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
568 }
569 }
570
574 function getExportDirectory($a_type = "xml")
575 {
576 switch ($a_type)
577 {
578 case "scorm":
579 $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export_scorm";
580 break;
581
582 default: // = xml
583 if (substr($a_type, 0, 4) == "html")
584 {
585 $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export_".$a_type;
586 }
587 else
588 {
589 $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export";
590 }
591 break;
592 }
593 return $export_dir;
594 }
595
596
607 function delete()
608 {
609 global $ilDB;
610
611 global $ilBench;
612
613 // always call parent delete function first!!
614 if (!parent::delete())
615 {
616 return false;
617 }
618
619 // delete lm object data
620 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
622
623 // delete meta data of content object
624 $this->deleteMetaData();
625
626
627 // delete learning module tree
628 $this->lm_tree->removeTree($this->lm_tree->getTreeId());
629
630 // delete data directory
632
633 // delete content object record
634 $q = "DELETE FROM content_object WHERE id = ".
635 $ilDB->quote($this->getId(), "integer");
636 $ilDB->manipulate($q);
637
638 // delete lm menu entries
639 $q = "DELETE FROM lm_menu WHERE lm_id = ".
640 $ilDB->quote($this->getId(), "integer");
641 $ilDB->manipulate($q);
642
643 // remove auto glossary entries
644 $ilDB->manipulate("DELETE FROM lm_glossaries WHERE ".
645 " lm_id = ".$ilDB->quote($this->getId(), "integer")
646 );
647
648
649 return true;
650 }
651
652
658 function getLayout()
659 {
660 return $this->layout;
661 }
662
668 function setLayout($a_layout)
669 {
670 $this->layout = $a_layout;
671 }
672
677 {
678 return $this->style_id;
679 }
680
684 function setStyleSheetId($a_style_id)
685 {
686 $this->style_id = $a_style_id;
687 }
688
692 function writeStyleSheetId($a_style_id)
693 {
694 global $ilDB;
695
696 $q = "UPDATE content_object SET ".
697 " stylesheet = ".$ilDB->quote((int) $a_style_id, "integer").
698 " WHERE id = ".$ilDB->quote($this->getId(), "integer");
699 $ilDB->manipulate($q);
700
701 $this->style_id = $a_style_id;
702 }
703
710 static function writeHeaderPage($a_lm_id, $a_page_id)
711 {
712 global $ilDB;
713
714 $ilDB->manipulate("UPDATE content_object SET ".
715 " header_page = ".$ilDB->quote($a_page_id, "integer").
716 " WHERE id = ".$ilDB->quote($a_lm_id, "integer")
717 );
718 }
719
726 static function writeFooterPage($a_lm_id, $a_page_id)
727 {
728 global $ilDB;
729
730 $ilDB->manipulate("UPDATE content_object SET ".
731 " footer_page = ".$ilDB->quote($a_page_id, "integer").
732 " WHERE id = ".$ilDB->quote($a_lm_id, "integer")
733 );
734 }
735
736
740 static function _moveLMStyles($a_from_style, $a_to_style)
741 {
742 global $ilDB, $ilias;
743
744 if ($a_from_style < 0) // change / delete all individual styles
745 {
746 $q = "SELECT stylesheet FROM content_object, style_data ".
747 " WHERE content_object.stylesheet = style_data.id ".
748 " AND style_data.standard = ".$ilDB->quote(0, "integer").
749 " AND content_object.stylesheet > ".$ilDB->quote(0, "integer");
750 $style_set = $ilDB->query($q);
751 while($style_rec = $ilDB->fetchAssoc($style_set))
752 {
753 // assign learning modules to new style
754 $q = "UPDATE content_object SET ".
755 " stylesheet = ".$ilDB->quote((int) $a_to_style, "integer").
756 " WHERE stylesheet = ".$ilDB->quote($style_rec["stylesheet"], "integer");
757 $ilDB->manipulate($q);
758
759 // delete style
760 $style_obj = $ilias->obj_factory->getInstanceByObjId($style_rec["stylesheet"]);
761 $style_obj->delete();
762 }
763 }
764 else
765 {
766 $q = "UPDATE content_object SET ".
767 " stylesheet = ".$ilDB->quote((int) $a_to_style, "integer").
768 " WHERE stylesheet = ".$ilDB->quote($a_from_style, "integer");
769 $ilDB->manipulate($q);
770 }
771 }
772
780 static protected function _lookup($a_obj_id, $a_field)
781 {
782 global $ilDB, $ilLog;
783
784 $q = "SELECT ".$a_field." FROM content_object ".
785 " WHERE id = ".$ilDB->quote($a_obj_id, "integer");
786
787 $res = $ilDB->query($q);
788 $rec = $ilDB->fetchAssoc($res);
789
790 return $rec[$a_field];
791 }
792
799 static function _lookupRestrictForwardNavigation($a_obj_id)
800 {
801 return self::_lookup($a_obj_id, "restrict_forw_nav");
802 }
803
807 static function _lookupStyleSheetId($a_cont_obj_id)
808 {
809 global $ilDB;
810
811 $q = "SELECT stylesheet FROM content_object ".
812 " WHERE id = ".$ilDB->quote($a_cont_obj_id, "integer");
813 $res = $ilDB->query($q);
814 $sheet = $ilDB->fetchAssoc($res);
815
816 return $sheet["stylesheet"];
817 }
818
822 static function _lookupContObjIdByStyleId($a_style_id)
823 {
824 global $ilDB;
825
826 $q = "SELECT id FROM content_object ".
827 " WHERE stylesheet = ".$ilDB->quote($a_style_id, "integer");
828 $res = $ilDB->query($q);
829 $obj_ids = array();
830 while($cont = $ilDB->fetchAssoc($res))
831 {
832 $obj_ids[] = $cont["id"];
833 }
834 return $obj_ids;
835 }
836
840 static function _lookupDisableDefaultFeedback($a_id)
841 {
842 global $ilDB;
843
844 $q = "SELECT disable_def_feedback FROM content_object ".
845 " WHERE id = ".$ilDB->quote($a_id, "integer");
846 $res = $ilDB->query($q);
847 $rec = $ilDB->fetchAssoc($res);
848
849 return $rec["disable_def_feedback"];
850 }
851
855 static function _lookupStoreTries($a_id)
856 {
857 global $ilDB;
858
859 $q = "SELECT store_tries FROM content_object ".
860 " WHERE id = ".$ilDB->quote($a_id, "integer");
861 $res = $ilDB->query($q);
862 $rec = $ilDB->fetchAssoc($res);
863
864 return $rec["store_tries"];
865 }
866
867
873 static function _getNrOfAssignedLMs($a_style_id)
874 {
875 global $ilDB;
876
877 $q = "SELECT count(*) as cnt FROM content_object ".
878 " WHERE stylesheet = ".$ilDB->quote($a_style_id, "integer");
879 $cset = $ilDB->query($q);
880 $crow = $ilDB->fetchAssoc($cset);
881
882 return (int) $crow["cnt"];
883 }
884
885
890 {
891 global $ilDB;
892
893 // joining with style table (not perfectly nice)
894 $q = "SELECT count(*) as cnt FROM content_object, style_data ".
895 " WHERE stylesheet = style_data.id ".
896 " AND standard = ".$ilDB->quote(0, "integer");
897 $cset = $ilDB->query($q);
898 $crow = $ilDB->fetchAssoc($cset);
899
900 return (int) $crow["cnt"];
901 }
902
906 static function _getNrLMsNoStyle()
907 {
908 global $ilDB;
909
910 $q = "SELECT count(*) as cnt FROM content_object ".
911 " WHERE stylesheet = ".$ilDB->quote(0, "integer");
912 $cset = $ilDB->query($q);
913 $crow = $ilDB->fetchAssoc($cset);
914
915 return (int) $crow["cnt"];
916 }
917
923 static function _deleteStyleAssignments($a_style_id)
924 {
925 global $ilDB;
926
927 $q = "UPDATE content_object SET ".
928 " stylesheet = ".$ilDB->quote(0, "integer").
929 " WHERE stylesheet = ".$ilDB->quote((int) $a_style_id, "integer");
930
931 $ilDB->manipulate($q);
932 }
933
937 function getPageHeader()
938 {
939 return $this->pg_header;
940 }
941
947 function setPageHeader($a_pg_header = IL_CHAPTER_TITLE)
948 {
949 $this->pg_header = $a_pg_header;
950 }
951
955 function getTOCMode()
956 {
957 return $this->toc_mode;
958 }
959
964 {
965 return $this->public_access_mode;
966 }
967
973 function setTOCMode($a_toc_mode = "chapters")
974 {
975 $this->toc_mode = $a_toc_mode;
976 }
977
978 function setOnline($a_online)
979 {
980 $this->online = $a_online;
981 }
982
983 function getOnline()
984 {
985 return $this->online;
986 }
987
988 function setActiveLMMenu($a_act_lm_menu)
989 {
990 $this->lm_menu_active = $a_act_lm_menu;
991 }
992
993 function isActiveLMMenu()
994 {
995 return $this->lm_menu_active;
996 }
997
998 function setActiveTOC($a_toc)
999 {
1000 $this->toc_active = $a_toc;
1001 }
1002
1003 function isActiveTOC()
1004 {
1005 return $this->toc_active;
1006 }
1007
1008 function setActiveNumbering($a_num)
1009 {
1010 $this->numbering = $a_num;
1011 }
1012
1014 {
1015 return $this->numbering;
1016 }
1017
1018 function setActivePrintView($a_print)
1019 {
1020 $this->print_view_active = $a_print;
1021 }
1022
1024 {
1025 return $this->print_view_active;
1026 }
1027
1029 {
1030 $this->prevent_glossary_appendix_active = $a_print;
1031 }
1032
1034 {
1035 return $this->prevent_glossary_appendix_active;
1036 }
1037
1044 {
1045 $this->hide_header_footer_print = $a_val;
1046 }
1047
1054 {
1055 return $this->hide_header_footer_print;
1056 }
1057
1058 function setActiveDownloads($a_down)
1059 {
1060 $this->downloads_active = $a_down;
1061 }
1062
1064 {
1065 return $this->downloads_active;
1066 }
1067
1069 {
1070 $this->downloads_public_active = $a_down;
1071 }
1072
1074 {
1075 return $this->downloads_public_active;
1076 }
1077
1078 function setPublicNotes($a_pub_notes)
1079 {
1080 $this->pub_notes = $a_pub_notes;
1081 }
1082
1083 function publicNotes()
1084 {
1085 return $this->pub_notes;
1086 }
1087
1088 function setCleanFrames($a_clean)
1089 {
1090 $this->clean_frames = $a_clean;
1091 }
1092
1093 function cleanFrames()
1094 {
1095 return $this->clean_frames;
1096 }
1097
1098 function setHistoryUserComments($a_comm)
1099 {
1100 $this->user_comments = $a_comm;
1101 }
1102
1103 function setPublicAccessMode($a_mode)
1104 {
1105 $this->public_access_mode = $a_mode;
1106 }
1107
1109 {
1110 return $this->user_comments;
1111 }
1112
1113 function setHeaderPage($a_pg)
1114 {
1115 $this->header_page = $a_pg;
1116 }
1117
1118 function getHeaderPage()
1119 {
1120 return $this->header_page;
1121 }
1122
1123 function setFooterPage($a_pg)
1124 {
1125 $this->footer_page = $a_pg;
1126 }
1127
1128 function getFooterPage()
1129 {
1130 return $this->footer_page;
1131 }
1132
1137 {
1138 global $ilDB;
1139
1140 $q = "SELECT * FROM content_object WHERE id = ".
1141 $ilDB->quote($this->getId(), "integer");
1142 $lm_set = $ilDB->query($q);
1143 $lm_rec = $ilDB->fetchAssoc($lm_set);
1144 $this->setLayout($lm_rec["default_layout"]);
1145 $this->setStyleSheetId((int) $lm_rec["stylesheet"]);
1146 $this->setPageHeader($lm_rec["page_header"]);
1147 $this->setTOCMode($lm_rec["toc_mode"]);
1148 $this->setOnline(ilUtil::yn2tf($lm_rec["is_online"]));
1149 $this->setActiveTOC(ilUtil::yn2tf($lm_rec["toc_active"]));
1150 $this->setActiveNumbering(ilUtil::yn2tf($lm_rec["numbering"]));
1151 $this->setActivePrintView(ilUtil::yn2tf($lm_rec["print_view_active"]));
1152 $this->setActivePreventGlossaryAppendix(ilUtil::yn2tf($lm_rec["no_glo_appendix"]));
1153 $this->setHideHeaderFooterPrint($lm_rec["hide_head_foot_print"]);
1154 $this->setActiveDownloads(ilUtil::yn2tf($lm_rec["downloads_active"]));
1155 $this->setActiveDownloadsPublic(ilUtil::yn2tf($lm_rec["downloads_public_active"]));
1156 $this->setActiveLMMenu(ilUtil::yn2tf($lm_rec["lm_menu_active"]));
1157 $this->setCleanFrames(ilUtil::yn2tf($lm_rec["clean_frames"]));
1158 $this->setHeaderPage((int) $lm_rec["header_page"]);
1159 $this->setFooterPage((int) $lm_rec["footer_page"]);
1160 $this->setHistoryUserComments(ilUtil::yn2tf($lm_rec["hist_user_comments"]));
1161 $this->setPublicAccessMode($lm_rec["public_access_mode"]);
1162 $this->setPublicExportFile("xml", $lm_rec["public_xml_file"]);
1163 $this->setPublicExportFile("html", $lm_rec["public_html_file"]);
1164 $this->setPublicExportFile("scorm", $lm_rec["public_scorm_file"]);
1165 $this->setLayoutPerPage($lm_rec["layout_per_page"]);
1166 $this->setRating($lm_rec["rating"]);
1167 $this->setRatingPages($lm_rec["rating_pages"]);
1168 $this->setDisableDefaultFeedback($lm_rec["disable_def_feedback"]);
1169 $this->setProgressIcons($lm_rec["progr_icons"]);
1170 $this->setStoreTries($lm_rec["store_tries"]);
1171 $this->setRestrictForwardNavigation($lm_rec["restrict_forw_nav"]);
1172
1173 // #14661
1174 include_once("./Services/Notes/classes/class.ilNote.php");
1175 $this->setPublicNotes(ilNote::commentsActivated($this->getId(), 0, $this->getType()));
1176
1177 $this->setForTranslation($lm_rec["for_translation"]);
1178 }
1179
1184 {
1185 global $ilDB;
1186
1187 // force clean_frames to be set, if layout per page is activated
1188 if ($this->getLayoutPerPage())
1189 {
1190 $this->setCleanFrames(true);
1191 }
1192
1193 $q = "UPDATE content_object SET ".
1194 " default_layout = ".$ilDB->quote($this->getLayout(), "text").", ".
1195 " stylesheet = ".$ilDB->quote($this->getStyleSheetId(), "integer").",".
1196 " page_header = ".$ilDB->quote($this->getPageHeader(), "text").",".
1197 " toc_mode = ".$ilDB->quote($this->getTOCMode(), "text").",".
1198 " is_online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline()), "text").",".
1199 " toc_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveTOC()), "text").",".
1200 " numbering = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveNumbering()), "text").",".
1201 " print_view_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActivePrintView()), "text").",".
1202 " no_glo_appendix = ".$ilDB->quote(ilUtil::tf2yn($this->isActivePreventGlossaryAppendix()), "text").",".
1203 " hide_head_foot_print = ".$ilDB->quote($this->getHideHeaderFooterPrint(), "integer").",".
1204 " downloads_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveDownloads()), "text").",".
1205 " downloads_public_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveDownloadsPublic()), "text").",".
1206 " clean_frames = ".$ilDB->quote(ilUtil::tf2yn($this->cleanFrames()), "text").",".
1207 " hist_user_comments = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveHistoryUserComments()), "text").",".
1208 " public_access_mode = ".$ilDB->quote($this->getPublicAccessMode(), "text").",".
1209 " public_xml_file = ".$ilDB->quote($this->getPublicExportFile("xml"), "text").",".
1210 " public_html_file = ".$ilDB->quote($this->getPublicExportFile("html"), "text").",".
1211 " public_scorm_file = ".$ilDB->quote($this->getPublicExportFile("scorm"), "text").",".
1212 " header_page = ".$ilDB->quote($this->getHeaderPage(), "integer").",".
1213 " footer_page = ".$ilDB->quote($this->getFooterPage(), "integer").",".
1214 " lm_menu_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveLMMenu()), "text").", ".
1215 " layout_per_page = ".$ilDB->quote($this->getLayoutPerPage(), "integer").", ".
1216 " rating = ".$ilDB->quote($this->hasRating(), "integer").", ".
1217 " rating_pages = ".$ilDB->quote($this->hasRatingPages(), "integer").", ".
1218 " disable_def_feedback = ".$ilDB->quote($this->getDisableDefaultFeedback(), "integer").", ".
1219 " progr_icons = ".$ilDB->quote($this->getProgressIcons(), "integer").", ".
1220 " store_tries = ".$ilDB->quote($this->getStoreTries(), "integer").", ".
1221 " restrict_forw_nav = ".$ilDB->quote($this->getRestrictForwardNavigation(), "integer").", ".
1222 " for_translation = ".$ilDB->quote((int) $this->getForTranslation(), "integer")." ".
1223 " WHERE id = ".$ilDB->quote($this->getId(), "integer");
1224 $ilDB->manipulate($q);
1225 // #14661
1226 include_once("./Services/Notes/classes/class.ilNote.php");
1227 ilNote::activateComments($this->getId(), 0, $this->getType(), $this->publicNotes());
1228 }
1229
1234 {
1235 global $ilDB;
1236
1237 $q = "INSERT INTO content_object (id) VALUES (".$ilDB->quote($this->getId(), "integer").")";
1238 $ilDB->manipulate($q);
1239
1240 // #14661
1241 include_once("./Services/Notes/classes/class.ilNote.php");
1242 ilNote::activateComments($this->getId(), 0, $this->getType(), true);
1243
1244 $this->readProperties(); // to get db default values
1245 }
1246
1250 static function _lookupOnline($a_id)
1251 {
1252 global $ilDB;
1253
1254//echo "class ilObjContentObject::_lookupOnline($a_id) called. Use Access class instead.";
1255
1256 $q = "SELECT is_online FROM content_object WHERE id = ".$ilDB->quote($a_id, "integer");
1257 $lm_set = $ilDB->query($q);
1258 $lm_rec = $ilDB->fetchAssoc($lm_set);
1259
1260 return ilUtil::yn2tf($lm_rec["is_online"]);
1261 }
1262
1266 static function getAvailableLayouts()
1267 {
1268 $dir = opendir("./Modules/LearningModule/layouts/lm");
1269
1270 $layouts = array();
1271
1272 while($file = readdir($dir))
1273 {
1274 if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn")
1275 {
1276 // directories
1277 if (@is_dir("./Modules/LearningModule/layouts/lm/".$file))
1278 {
1279 $layouts[$file] = $file;
1280 }
1281 }
1282 }
1283 asort($layouts);
1284
1285 // workaround: fix ordering
1286 $ret = array(
1287 'toc2win' => 'toc2win',
1288 'toc2windyn' => 'toc2windyn',
1289 '1window' => '1window',
1290 '2window' => '2window',
1291 '3window' => '3window',
1292 'presentation' => 'presentation',
1293 'fullscreen' => 'fullscreen'
1294 );
1295
1296 foreach ($layouts as $l)
1297 {
1298 if (!in_array($l, $ret))
1299 {
1300 $ret[$l] = $l;
1301 }
1302 }
1303
1304 return $ret;
1305 }
1306
1310 static function _checkPreconditionsOfPage($cont_ref_id,$cont_obj_id, $page_id)
1311 {
1312 global $ilUser,$ilErr;
1313
1314 $lm_tree = new ilTree($cont_obj_id);
1315 $lm_tree->setTableNames('lm_tree','lm_data');
1316 $lm_tree->setTreeTablePK("lm_id");
1317
1318 if ($lm_tree->isInTree($page_id))
1319 {
1320 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
1321 foreach ($path as $node)
1322 {
1323 if ($node["type"] == "st")
1324 {
1325 if (!ilConditionHandler::_checkAllConditionsOfTarget($cont_ref_id,$node["child"], "st"))
1326 {
1327 return false;
1328 }
1329 }
1330 }
1331 }
1332
1333 return true;
1334 }
1335
1339 static function _getMissingPreconditionsOfPage($cont_ref_id,$cont_obj_id, $page_id)
1340 {
1341 $lm_tree = new ilTree($cont_obj_id);
1342 $lm_tree->setTableNames('lm_tree','lm_data');
1343 $lm_tree->setTreeTablePK("lm_id");
1344
1345 $conds = array();
1346 if ($lm_tree->isInTree($page_id))
1347 {
1348 // get full path of page
1349 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
1350 foreach ($path as $node)
1351 {
1352 if ($node["type"] == "st")
1353 {
1354 // get all preconditions of upper chapters
1355 $tconds = ilConditionHandler::_getConditionsOfTarget($cont_ref_id,$node["child"], "st");
1356 foreach ($tconds as $tcond)
1357 {
1358 // store all missing preconditions
1359 if (!ilConditionHandler::_checkCondition($tcond["id"]))
1360 {
1361 $conds[] = $tcond;
1362 }
1363 }
1364 }
1365 }
1366 }
1367
1368 return $conds;
1369 }
1370
1374 static function _getMissingPreconditionsTopChapter($cont_obj_ref_id,$cont_obj_id, $page_id)
1375 {
1376 $lm_tree = new ilTree($cont_obj_id);
1377 $lm_tree->setTableNames('lm_tree','lm_data');
1378 $lm_tree->setTreeTablePK("lm_id");
1379
1380 $conds = array();
1381 if ($lm_tree->isInTree($page_id))
1382 {
1383 // get full path of page
1384 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
1385 foreach ($path as $node)
1386 {
1387 if ($node["type"] == "st")
1388 {
1389 // get all preconditions of upper chapters
1390 $tconds = ilConditionHandler::_getConditionsOfTarget($cont_obj_ref_id,$node["child"], "st");
1391 foreach ($tconds as $tcond)
1392 {
1393 // look for missing precondition
1394 if (!ilConditionHandler::_checkCondition($tcond["id"]))
1395 {
1396 return $node["child"];
1397 }
1398 }
1399 }
1400 }
1401 }
1402
1403 return "";
1404 }
1405
1409 static function hasSuccessorPage($a_cont_obj_id, $a_page_id)
1410 {
1411 $tree = new ilTree($a_cont_obj_id);
1412 $tree->setTableNames('lm_tree','lm_data');
1413 $tree->setTreeTablePK("lm_id");
1414 if ($tree->isInTree($a_page_id))
1415 {
1416 $succ = $tree->fetchSuccessorNode($a_page_id, "pg");
1417 if ($succ > 0)
1418 {
1419 return true;
1420 }
1421 }
1422 return false;
1423 }
1424
1425
1426 function checkTree()
1427 {
1428 $tree = new ilTree($this->getId());
1429 $tree->setTableNames('lm_tree','lm_data');
1430 $tree->setTreeTablePK("lm_id");
1431 $tree->checkTree();
1432 $tree->checkTreeChilds();
1433//echo "checked";
1434 }
1435
1439 function fixTree()
1440 {
1441 global $ilDB;
1442
1443 $tree = $this->getLMTree();
1444
1445 // check numbering, if errors, renumber
1446 // it is very important to keep this step before deleting subtrees
1447 // in the following steps
1448 $set = $ilDB->query("SELECT DISTINCT l1.lm_id".
1449 " FROM lm_tree l1".
1450 " JOIN lm_tree l2 ON ( l1.child = l2.parent".
1451 " AND l1.lm_id = l2.lm_id )".
1452 " JOIN lm_data ON ( l1.child = lm_data.obj_id )".
1453 " WHERE (l2.lft < l1.lft".
1454 " OR l2.rgt > l1.rgt OR l2.lft > l1.rgt OR l2.rgt < l1.lft)".
1455 " AND l1.lm_id = ".$ilDB->quote($this->getId(), "integer").
1456 " ORDER BY lm_data.create_date DESC"
1457 );
1458 if ($rec = $ilDB->fetchAssoc($set))
1459 {
1460 $tree->renumber();
1461 }
1462
1463 // delete subtrees that have no lm_data records (changed due to #20637)
1464 $set = $ilDB->query("SELECT * FROM lm_tree WHERE lm_tree.lm_id = ".$ilDB->quote($this->getId(), "integer"));
1465 while ($node = $ilDB->fetchAssoc($set))
1466 {
1467 $q = "SELECT * FROM lm_data WHERE obj_id = ".
1468 $ilDB->quote($node["child"], "integer");
1469 $obj_set = $ilDB->query($q);
1470 $obj_rec = $ilDB->fetchAssoc($obj_set);
1471 if (!$obj_rec)
1472 {
1473 $node_data = $tree->getNodeData($node["child"]);
1474 $node_data["child"] = $node["child"];
1475 $tree->deleteTree($node_data);
1476 }
1477 }
1478
1479 // delete subtrees that have pages as parent
1480 $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
1481 foreach ($nodes as $node)
1482 {
1483 $q = "SELECT * FROM lm_data WHERE obj_id = ".
1484 $ilDB->quote($node["parent"], "integer");
1485 $obj_set = $ilDB->query($q);
1486 $obj_rec = $ilDB->fetchAssoc($obj_set);
1487 if ($obj_rec["type"] == "pg")
1488 {
1489 $node_data = $tree->getNodeData($node["child"]);
1490 if ($tree->isInTree($node["child"]))
1491 {
1492 $tree->deleteTree($node_data);
1493 }
1494 }
1495 }
1496
1497 // check for multi-references pages or chapters
1498 // if errors -> create copies of them here
1499 $set = $ilDB->query("SELECT DISTINCT l1.lm_id".
1500 " FROM lm_tree l1".
1501 " JOIN lm_tree l2 ON ( l1.child = l2.child AND l1.lm_id <> l2.lm_id )".
1502 " JOIN lm_data ON (l1.child = lm_data.obj_id)".
1503 " WHERE l1.child <> 1".
1504 " AND l1.lm_id <> lm_data.lm_id".
1505 " AND l1.lm_id = ".$ilDB->quote($this->getId(), "integer"));
1506 if ($rec = $ilDB->fetchAssoc($set))
1507 {
1508 $set = $ilDB->query("SELECT DISTINCT l1.child ".
1509 " FROM lm_tree l1".
1510 " JOIN lm_tree l2 ON ( l1.child = l2.child AND l1.lm_id <> l2.lm_id )".
1511 " JOIN lm_data ON (l1.child = lm_data.obj_id)".
1512 " WHERE l1.child <> 1".
1513 " AND l1.lm_id <> lm_data.lm_id".
1514 " AND l1.lm_id = ".$ilDB->quote($this->getId(), "integer"));
1515 include_once("./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
1516 while ($rec = $ilDB->fetchAssoc($set))
1517 {
1518 $cobj = ilLMObjectFactory::getInstance($this, $rec["child"]);
1519
1520 if (is_object($cobj))
1521 {
1522 if ($cobj->getType() == "pg")
1523 {
1524 // make a copy of it
1525 $pg_copy = $cobj->copy($this);
1526
1527 // replace the child in the tree with the copy (id)
1528 $ilDB->manipulate("UPDATE lm_tree SET ".
1529 " child = ".$ilDB->quote($pg_copy->getId(), "integer").
1530 " WHERE child = ".$ilDB->quote($cobj->getId(), "integer").
1531 " AND lm_id = ".$ilDB->quote($this->getId(), "integer")
1532 );
1533 }
1534 else if ($cobj->getType() == "st")
1535 {
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("UPDATE lm_tree SET ".
1541 " child = ".$ilDB->quote($st_copy->getId(), "integer").
1542 " WHERE child = ".$ilDB->quote($cobj->getId(), "integer").
1543 " AND lm_id = ".$ilDB->quote($this->getId(), "integer")
1544 );
1545
1546 // make all childs refer to the copy now
1547 $ilDB->manipulate("UPDATE lm_tree SET ".
1548 " parent = ".$ilDB->quote($st_copy->getId(), "integer").
1549 " WHERE parent = ".$ilDB->quote($cobj->getId(), "integer").
1550 " AND lm_id = ".$ilDB->quote($this->getId(), "integer")
1551 );
1552 }
1553 }
1554 }
1555 }
1556 }
1557
1558
1565 function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
1566 {
1567 global $ilBench;
1568
1569 $attrs = array();
1570 switch($this->getType())
1571 {
1572 case "lm":
1573 $attrs["Type"] = "LearningModule";
1574 break;
1575 }
1576 $a_xml_writer->xmlStartTag("ContentObject", $attrs);
1577
1578 // MetaData
1579 $this->exportXMLMetaData($a_xml_writer);
1580
1581 // StructureObjects
1582//echo "ContObj:".$a_inst.":<br>";
1583 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Structure Objects");
1584 $ilBench->start("ContentObjectExport", "exportStructureObjects");
1585 $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
1586 $ilBench->stop("ContentObjectExport", "exportStructureObjects");
1587 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Structure Objects");
1588
1589 // PageObjects
1590 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Page Objects");
1591 $ilBench->start("ContentObjectExport", "exportPageObjects");
1592 $this->exportXMLPageObjects($a_xml_writer, $a_inst, $expLog);
1593 $ilBench->stop("ContentObjectExport", "exportPageObjects");
1594 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Page Objects");
1595
1596 // MediaObjects
1597 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
1598 $ilBench->start("ContentObjectExport", "exportMediaObjects");
1599 $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
1600 $ilBench->stop("ContentObjectExport", "exportMediaObjects");
1601 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");
1602
1603 // FileItems
1604 $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
1605 $ilBench->start("ContentObjectExport", "exportFileItems");
1606 $this->exportFileItems($a_target_dir, $expLog);
1607 $ilBench->stop("ContentObjectExport", "exportFileItems");
1608 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");
1609
1610 // Questions
1611 if (count($this->q_ids) > 0)
1612 {
1613 $qti_file = fopen($a_target_dir."/qti.xml", "w");
1614 include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
1615 $pool = new ilObjQuestionPool();
1616 fwrite($qti_file, $pool->questionsToXML($this->q_ids));
1617 fclose($qti_file);
1618 }
1619
1620 // To do: implement version selection/detection
1621 // Properties
1622 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Properties");
1623 $this->exportXMLProperties($a_xml_writer, $expLog);
1624 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Properties");
1625
1626 $a_xml_writer->xmlEndTag("ContentObject");
1627 }
1628
1635 function exportXMLMetaData(&$a_xml_writer)
1636 {
1637 include_once("Services/MetaData/classes/class.ilMD2XML.php");
1638 $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
1639 $md2xml->setExportMode(true);
1640 $md2xml->startExport();
1641 $a_xml_writer->appendXML($md2xml->getXML());
1642 }
1643
1650 function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
1651 {
1652 include_once './Modules/LearningModule/classes/class.ilStructureObject.php';
1653
1654 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
1655 foreach ($childs as $child)
1656 {
1657 if($child["type"] != "st")
1658 {
1659 continue;
1660 }
1661
1662 $structure_obj = new ilStructureObject($this, $child["obj_id"]);
1663 $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
1664 unset($structure_obj);
1665 }
1666 }
1667
1668
1675 function exportXMLPageObjects(&$a_xml_writer, $a_inst, &$expLog)
1676 {
1677 global $ilBench;
1678
1679 include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
1680 include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
1681
1682 $pages = ilLMPageObject::getPageList($this->getId());
1683 foreach ($pages as $page)
1684 {
1685 if (ilLMPage::_exists($this->getType(), $page["obj_id"]))
1686 {
1687 $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$page["obj_id"]);
1688
1689 // export xml to writer object
1690 $page_obj = new ilLMPageObject($this, $page["obj_id"]);
1691 $page_obj->exportXML($a_xml_writer, "normal", $a_inst);
1692
1693 // collect media objects
1694 $mob_ids = $page_obj->getMediaObjectIDs();
1695 foreach($mob_ids as $mob_id)
1696 {
1697 $this->mob_ids[$mob_id] = $mob_id;
1698 }
1699
1700 // collect all file items
1701 $file_ids = $page_obj->getFileItemIds();
1702 foreach($file_ids as $file_id)
1703 {
1704 $this->file_ids[$file_id] = $file_id;
1705 }
1706
1707 // collect all questions
1708 $q_ids = $page_obj->getQuestionIds();
1709 foreach($q_ids as $q_id)
1710 {
1711 $this->q_ids[$q_id] = $q_id;
1712 }
1713
1714 unset($page_obj);
1715 }
1716 }
1717 }
1718
1725 function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
1726 {
1727 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1728
1729 $linked_mobs = array();
1730
1731 // mobs directly embedded into pages
1732 foreach ($this->mob_ids as $mob_id)
1733 {
1734 if ($mob_id > 0 && ilObject::_lookupType($mob_id) == "mob")
1735 {
1736 $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
1737 $media_obj = new ilObjMediaObject($mob_id);
1738 $media_obj->exportXML($a_xml_writer, $a_inst);
1739 $media_obj->exportFiles($a_target_dir);
1740
1741 $lmobs = $media_obj->getLinkedMediaObjects($this->mob_ids);
1742 $linked_mobs = array_merge($linked_mobs, $lmobs);
1743
1744 unset($media_obj);
1745 }
1746 }
1747
1748 // linked mobs (in map areas)
1749 foreach ($linked_mobs as $mob_id)
1750 {
1751 if ($mob_id > 0)
1752 {
1753 $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
1754 $media_obj = new ilObjMediaObject($mob_id);
1755 $media_obj->exportXML($a_xml_writer, $a_inst);
1756 $media_obj->exportFiles($a_target_dir);
1757 unset($media_obj);
1758 }
1759 }
1760
1761 }
1762
1767 function exportFileItems($a_target_dir, &$expLog)
1768 {
1769 include_once("./Modules/File/classes/class.ilObjFile.php");
1770
1771 foreach ($this->file_ids as $file_id)
1772 {
1773 $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
1774 $file_obj = new ilObjFile($file_id, false);
1775 $file_obj->export($a_target_dir);
1776 unset($file_obj);
1777 }
1778 }
1779
1784 function exportXMLProperties($a_xml_writer, &$expLog)
1785 {
1786 $attrs = array();
1787 $a_xml_writer->xmlStartTag("Properties", $attrs);
1788
1789 // Layout
1790 $attrs = array("Name" => "Layout", "Value" => $this->getLayout());
1791 $a_xml_writer->xmlElement("Property", $attrs);
1792
1793 // Page Header
1794 $attrs = array("Name" => "PageHeader", "Value" => $this->getPageHeader());
1795 $a_xml_writer->xmlElement("Property", $attrs);
1796
1797 // TOC Mode
1798 $attrs = array("Name" => "TOCMode", "Value" => $this->getTOCMode());
1799 $a_xml_writer->xmlElement("Property", $attrs);
1800
1801 // LM Menu Activation
1802 $attrs = array("Name" => "ActiveLMMenu", "Value" =>
1803 ilUtil::tf2yn($this->isActiveLMMenu()));
1804 $a_xml_writer->xmlElement("Property", $attrs);
1805
1806 // Numbering Activation
1807 $attrs = array("Name" => "ActiveNumbering", "Value" =>
1809 $a_xml_writer->xmlElement("Property", $attrs);
1810
1811 // Table of contents button activation
1812 $attrs = array("Name" => "ActiveTOC", "Value" =>
1813 ilUtil::tf2yn($this->isActiveTOC()));
1814 $a_xml_writer->xmlElement("Property", $attrs);
1815
1816 // Print view button activation
1817 $attrs = array("Name" => "ActivePrintView", "Value" =>
1819 $a_xml_writer->xmlElement("Property", $attrs);
1820
1821 // Note that download button is not saved, because
1822 // download files do not exist after import
1823
1824 // Clean frames
1825 $attrs = array("Name" => "CleanFrames", "Value" =>
1826 ilUtil::tf2yn($this->cleanFrames()));
1827 $a_xml_writer->xmlElement("Property", $attrs);
1828
1829 // Public notes activation
1830 $attrs = array("Name" => "PublicNotes", "Value" =>
1831 ilUtil::tf2yn($this->publicNotes()));
1832 $a_xml_writer->xmlElement("Property", $attrs);
1833
1834 // History comments for authors activation
1835 $attrs = array("Name" => "HistoryUserComments", "Value" =>
1837 $a_xml_writer->xmlElement("Property", $attrs);
1838
1839 // Rating
1840 $attrs = array("Name" => "Rating", "Value" =>
1841 ilUtil::tf2yn($this->hasRating()));
1842 $a_xml_writer->xmlElement("Property", $attrs);
1843 $attrs = array("Name" => "RatingPages", "Value" =>
1844 ilUtil::tf2yn($this->hasRatingPages()));
1845 $a_xml_writer->xmlElement("Property", $attrs);
1846
1847 // Header Page
1848 if ($this->getHeaderPage() > 0)
1849 {
1850 $attrs = array("Name" => "HeaderPage", "Value" =>
1851 "il_".IL_INST_ID."_pg_".$this->getHeaderPage());
1852 $a_xml_writer->xmlElement("Property", $attrs);
1853 }
1854
1855 // Footer Page
1856 if ($this->getFooterPage() > 0)
1857 {
1858 $attrs = array("Name" => "FooterPage", "Value" =>
1859 "il_".IL_INST_ID."_pg_".$this->getFooterPage());
1860 $a_xml_writer->xmlElement("Property", $attrs);
1861 }
1862
1863 // layout per page
1864 $attrs = array("Name" => "LayoutPerPage", "Value" =>
1865 $this->getLayoutPerPage());
1866 $a_xml_writer->xmlElement("Property", $attrs);
1867
1868 // progress icons
1869 $attrs = array("Name" => "ProgressIcons", "Value" =>
1870 $this->getProgressIcons());
1871 $a_xml_writer->xmlElement("Property", $attrs);
1872
1873 // store tries
1874 $attrs = array("Name" => "StoreTries", "Value" =>
1875 $this->getStoreTries());
1876 $a_xml_writer->xmlElement("Property", $attrs);
1877
1878 // restrict forward navigation
1879 $attrs = array("Name" => "RestrictForwardNavigation", "Value" =>
1881 $a_xml_writer->xmlElement("Property", $attrs);
1882
1883 // disable default feedback
1884 $attrs = array("Name" => "DisableDefaultFeedback", "Value" =>
1885 $this->getDisableDefaultFeedback());
1886 $a_xml_writer->xmlElement("Property", $attrs);
1887
1888 $a_xml_writer->xmlEndTag("Properties");
1889 }
1890
1895 {
1896 $file = array();
1897
1898 $types = array("xml", "html", "scorm");
1899
1900 foreach ($types as $type)
1901 {
1902 $dir = $this->getExportDirectory($type);
1903 // quit if import dir not available
1904 if (!@is_dir($dir) or
1905 !is_writeable($dir))
1906 {
1907 continue;
1908 }
1909
1910 // open directory
1911 $cdir = dir($dir);
1912
1913 // initialize array
1914
1915 // get files and save the in the array
1916 while ($entry = $cdir->read())
1917 {
1918 if ($entry != "." and
1919 $entry != ".." and
1920 substr($entry, -4) == ".zip" and
1921 preg_match("~^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.zip\$~", $entry))
1922 {
1923 $file[$entry.$type] = array("type" => $type, "file" => $entry,
1924 "size" => filesize($dir."/".$entry));
1925 }
1926 }
1927
1928 // close import directory
1929 $cdir->close();
1930 }
1931
1932 // sort files
1933 ksort ($file);
1934 reset ($file);
1935 return $file;
1936 }
1937
1944 function setPublicExportFile($a_type, $a_file)
1945 {
1946 $this->public_export_file[$a_type] = $a_file;
1947 }
1948
1957 {
1958 return $this->public_export_file[$a_type];
1959 }
1960
1964 function getOfflineFiles($dir)
1965 {
1966 // quit if offline dir not available
1967 if (!@is_dir($dir) or
1968 !is_writeable($dir))
1969 {
1970 return array();
1971 }
1972
1973 // open directory
1974 $dir = dir($dir);
1975
1976 // initialize array
1977 $file = array();
1978
1979 // get files and save the in the array
1980 while ($entry = $dir->read())
1981 {
1982 if ($entry != "." and
1983 $entry != ".." and
1984 substr($entry, -4) == ".pdf" and
1985 preg_match("~^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.pdf\$~", $entry))
1986 {
1987 $file[] = $entry;
1988 }
1989 }
1990
1991 // close import directory
1992 $dir->close();
1993
1994 // sort files
1995 sort ($file);
1996 reset ($file);
1997
1998 return $file;
1999 }
2000
2004 function exportSCORM($a_target_dir, $log)
2005 {
2006 ilUtil::delDir($a_target_dir);
2007 ilUtil::makeDir($a_target_dir);
2008 //ilUtil::makeDir($a_target_dir."/res");
2009
2010 // export everything to html
2011 $this->exportHTML($a_target_dir."/res", $log, false, "scorm");
2012
2013 // build manifest file
2014 include("./Modules/LearningModule/classes/class.ilContObjectManifestBuilder.php");
2015 $man_builder = new ilContObjectManifestBuilder($this);
2016 $man_builder->buildManifest();
2017 $man_builder->dump($a_target_dir);
2018
2019 // copy scorm 1.2 schema definitions
2020 copy("Modules/LearningModule/scorm_xsd/adlcp_rootv1p2.xsd", $a_target_dir."/adlcp_rootv1p2.xsd");
2021 copy("Modules/LearningModule/scorm_xsd/imscp_rootv1p1p2.xsd", $a_target_dir."/imscp_rootv1p1p2.xsd");
2022 copy("Modules/LearningModule/scorm_xsd/imsmd_rootv1p2p1.xsd", $a_target_dir."/imsmd_rootv1p2p1.xsd");
2023 copy("Modules/LearningModule/scorm_xsd/ims_xml.xsd", $a_target_dir."/ims_xml.xsd");
2024
2025 // zip it all
2026 $date = time();
2027 $zip_file = $a_target_dir."/".$date."__".IL_INST_ID."__".
2028 $this->getType()."_".$this->getId().".zip";
2029 //echo "zip-".$a_target_dir."-to-".$zip_file;
2030 ilUtil::zip(array($a_target_dir."/res",
2031 $a_target_dir."/imsmanifest.xml",
2032 $a_target_dir."/adlcp_rootv1p2.xsd",
2033 $a_target_dir."/imscp_rootv1p1p2.xsd",
2034 $a_target_dir."/ims_xml.xsd",
2035 $a_target_dir."/imsmd_rootv1p2p1.xsd")
2036 , $zip_file);
2037
2038 $dest_file = $this->getExportDirectory("scorm")."/".$date."__".IL_INST_ID."__".
2039 $this->getType()."_".$this->getId().".zip";
2040
2041 rename($zip_file, $dest_file);
2042 ilUtil::delDir($a_target_dir);
2043
2044 }
2045
2046
2050 function exportHTML($a_target_dir, $log, $a_zip_file = true, $a_export_format = "html", $a_lang = "")
2051 {
2052 global $tpl, $ilBench, $ilLocator, $ilUser, $ilObjDataCache, $ilias;
2053
2054 $user_lang = $ilUser->getLanguage();
2055
2056 // initialize temporary target directory
2057 ilUtil::delDir($a_target_dir);
2058 ilUtil::makeDir($a_target_dir);
2059 $mob_dir = $a_target_dir."/mobs";
2060 ilUtil::makeDir($mob_dir);
2061 $file_dir = $a_target_dir."/files";
2062 ilUtil::makeDir($file_dir);
2063 $teximg_dir = $a_target_dir."/teximg";
2064 ilUtil::makeDir($teximg_dir);
2065 $style_dir = $a_target_dir."/style";
2066 ilUtil::makeDir($style_dir);
2067 $style_img_dir = $a_target_dir."/style/images";
2068 ilUtil::makeDir($style_img_dir);
2069 $content_style_dir = $a_target_dir."/content_style";
2070 ilUtil::makeDir($content_style_dir);
2071 $content_style_img_dir = $a_target_dir."/content_style/images";
2072 ilUtil::makeDir($content_style_img_dir);
2073 $GLOBALS["teximgcnt"] = 0;
2074
2075 // init the mathjax rendering for HTML export
2076 include_once './Services/MathJax/classes/class.ilMathJax.php';
2078
2079 // export system style sheet
2080 $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
2081 $style_name = $ilUser->prefs["style"].".css";
2082 copy($location_stylesheet, $style_dir."/".$style_name);
2083 $fh = fopen($location_stylesheet, "r");
2084 $css = fread($fh, filesize($location_stylesheet));
2085 preg_match_all("/url\‍(([^\‍)]*)\‍)/",$css,$files);
2086 foreach (array_unique($files[1]) as $fileref)
2087 {
2088 $css_fileref = str_replace(array("'", '"'), "", $fileref);
2089 $fileref = dirname($location_stylesheet)."/".$css_fileref;
2090 if (is_file($fileref))
2091 {
2092//echo "<br>make dir: ".dirname($style_dir."/".$css_fileref);
2093 ilUtil::makeDirParents(dirname($style_dir."/".$css_fileref));
2094//echo "<br>copy: ".$fileref." TO ".$style_dir."/".$css_fileref;
2095 copy($fileref, $style_dir."/".$css_fileref);
2096 }
2097 }
2098 fclose($fh);
2099 $location_stylesheet = ilUtil::getStyleSheetLocation();
2100
2101 // export content style sheet
2102 $ilBench->start("ExportHTML", "exportContentStyle");
2103 if ($this->getStyleSheetId() < 1)
2104 {
2105 $cont_stylesheet = "./Services/COPage/css/content.css";
2106
2107 $css = fread(fopen($cont_stylesheet,'r'),filesize($cont_stylesheet));
2108 preg_match_all("/url\‍(([^\‍)]*)\‍)/",$css,$files);
2109 foreach (array_unique($files[1]) as $fileref)
2110 {
2111 if (is_file(str_replace("..", ".", $fileref)))
2112 {
2113 copy(str_replace("..", ".", $fileref), $content_style_img_dir."/".basename($fileref));
2114 }
2115 $css = str_replace($fileref, "images/".basename($fileref),$css);
2116 }
2117 fwrite(fopen($content_style_dir."/content.css",'w'),$css);
2118 }
2119 else
2120 {
2121 $style = new ilObjStyleSheet($this->getStyleSheetId());
2122 $style->writeCSSFile($content_style_dir."/content.css", "images");
2123 $style->copyImagesToDir($content_style_img_dir);
2124 }
2125 $ilBench->stop("ExportHTML", "exportContentStyle");
2126
2127 // export syntax highlighting style
2128 $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
2129 copy($syn_stylesheet, $a_target_dir."/syntaxhighlight.css");
2130
2131 // get learning module presentation gui class
2132 include_once("./Modules/LearningModule/classes/class.ilLMPresentationGUI.php");
2133 $_GET["cmd"] = "nop";
2134 $get_transl = $_GET["transl"];
2135 $_GET["transl"] = "";
2136 $lm_gui = new ilLMPresentationGUI();
2137 $lm_gui->setOfflineMode(true, ($a_lang == "all"));
2138 $lm_gui->setOfflineDirectory($a_target_dir);
2139 $lm_gui->setExportFormat($a_export_format);
2140
2142 $langs = array();
2143 if ($a_lang != "all")
2144 {
2145 $langs = array($a_lang);
2146 }
2147 else
2148 {
2149 $ot_langs = $ot->getLanguages();
2150 foreach ($ot_langs as $otl)
2151 {
2152 $langs[] = $otl["lang_code"];
2153 }
2154 }
2155
2156 // init collector arrays
2157 $this->offline_mobs = array();
2158 $this->offline_int_links = array();
2159 $this->offline_files = array();
2160
2161 // iterate all languages
2162 foreach ($langs as $lang)
2163 {
2164
2165 if ($lang != "")
2166 {
2167 $ilUser->setLanguage($lang);
2168 $ilUser->setCurrentLanguage($lang);
2169 }
2170 else
2171 {
2172 $ilUser->setLanguage($user_lang);
2173 $ilUser->setCurrentLanguage($user_lang);
2174 }
2175
2176 if ($lang != "")
2177 {
2178 if ($lang == $ot->getMasterLanguage())
2179 {
2180 $lm_gui->lang = "";
2181 }
2182 else
2183 {
2184 $lm_gui->lang = $lang;
2185 }
2186 }
2187
2188 // export pages
2189 $ilBench->start("ExportHTML", "exportHTMLPages");
2190 // now: forward ("all" info to export files and links)
2191 $this->exportHTMLPages($lm_gui, $a_target_dir, $lm_gui->lang, ($a_lang == "all"));
2192 $ilBench->stop("ExportHTML", "exportHTMLPages");
2193
2194 // export table of contents
2195 $ilLocator->clearItems();
2196 if ($this->isActiveTOC())
2197 {
2198 $tpl = new ilTemplate("tpl.main.html", true, true);
2199
2200 $GLOBALS["tpl"] = $tpl;
2201
2202 $lm_gui->tpl = $tpl;
2203 $content = $lm_gui->showTableOfContents();
2204 //var_dump($content); exit;
2205 if ($a_lang == "all")
2206 {
2207 $file = $a_target_dir . "/table_of_contents_".$lang.".html";
2208 }
2209 else
2210 {
2211 $file = $a_target_dir . "/table_of_contents.html";
2212 }
2213
2214 // open file
2215 if (!($fp = @fopen($file,"w+")))
2216 {
2217 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
2218 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
2219 }
2220 chmod($file, 0770);
2221 fwrite($fp, $content);
2222 fclose($fp);
2223 }
2224 }
2225
2226 // export glossary terms
2227 $ilBench->start("ExportHTML", "exportHTMLGlossaryTerms");
2228 $this->exportHTMLGlossaryTerms($lm_gui, $a_target_dir);
2229 $ilBench->stop("ExportHTML", "exportHTMLGlossaryTerms");
2230
2231 // export all media objects
2232 $ilBench->start("ExportHTML", "exportHTMLMediaObjects");
2233 $linked_mobs = array();
2234 foreach ($this->offline_mobs as $mob)
2235 {
2236 if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob")
2237 {
2238 $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs);
2239 }
2240 }
2241 $linked_mobs2 = array(); // mobs linked in link areas
2242 foreach ($linked_mobs as $mob)
2243 {
2244 if (ilObject::_exists($mob))
2245 {
2246 $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs2);
2247 }
2248 }
2249 $_GET["obj_type"] = "MediaObject";
2250 $_GET["obj_id"] = $a_mob_id;
2251 $_GET["cmd"] = "";
2252 $ilBench->stop("ExportHTML", "exportHTMLMediaObjects");
2253
2254 // export all file objects
2255 $ilBench->start("ExportHTML", "exportHTMLFileObjects");
2256 foreach ($this->offline_files as $file)
2257 {
2258 $this->exportHTMLFile($a_target_dir, $file);
2259 }
2260 $ilBench->stop("ExportHTML", "exportHTMLFileObjects");
2261
2262 // export questions (images)
2263 if (count($this->q_ids) > 0)
2264 {
2265 foreach ($this->q_ids as $q_id)
2266 {
2267 ilUtil::makeDirParents($a_target_dir."/assessment/0/".$q_id."/images");
2268 ilUtil::rCopy(ilUtil::getWebspaceDir()."/assessment/0/".$q_id."/images",
2269 $a_target_dir."/assessment/0/".$q_id."/images");
2270 }
2271 }
2272
2273 // export images
2274 $ilBench->start("ExportHTML", "exportHTMLImages");
2275 $image_dir = $a_target_dir."/images";
2276 ilUtil::makeDir($image_dir);
2277 ilUtil::makeDir($image_dir."/browser");
2278 copy(ilUtil::getImagePath("enlarge.svg", false, "filesystem"),
2279 $image_dir."/enlarge.svg");
2280 copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
2281 $image_dir."/browser/plus.png");
2282 copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
2283 $image_dir."/browser/minus.png");
2284 copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
2285 $image_dir."/browser/blank.png");
2286 copy(ilUtil::getImagePath("spacer.png", false, "filesystem"),
2287 $image_dir."/spacer.png");
2288 copy(ilUtil::getImagePath("icon_st.svg", false, "filesystem"),
2289 $image_dir."/icon_st.svg");
2290 copy(ilUtil::getImagePath("icon_pg.svg", false, "filesystem"),
2291 $image_dir."/icon_pg.svg");
2292 copy(ilUtil::getImagePath("icon_lm.svg", false, "filesystem"),
2293 $image_dir."/icon_lm.svg");
2294 copy(ilUtil::getImagePath("nav_arr_L.png", false, "filesystem"),
2295 $image_dir."/nav_arr_L.png");
2296 copy(ilUtil::getImagePath("nav_arr_R.png", false, "filesystem"),
2297 $image_dir."/nav_arr_R.png");
2298
2299 $ilBench->stop("ExportHTML", "exportHTMLImages");
2300
2301 // export flv/mp3 player
2302 $services_dir = $a_target_dir."/Services";
2303 ilUtil::makeDir($services_dir);
2304 $media_service_dir = $services_dir."/MediaObjects";
2305 ilUtil::makeDir($media_service_dir);
2306 include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
2307 $flv_dir = $a_target_dir."/".ilPlayerUtil::getFlashVideoPlayerDirectory();
2308 ilUtil::makeDir($flv_dir);
2309 $mp3_dir = $media_service_dir."/flash_mp3_player";
2310 ilUtil::makeDir($mp3_dir);
2311// copy(ilPlayerUtil::getFlashVideoPlayerFilename(true),
2312// $flv_dir."/".ilPlayerUtil::getFlashVideoPlayerFilename());
2314 include_once("./Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php");
2317
2318 // js files
2319 ilUtil::makeDir($a_target_dir.'/js');
2320 ilUtil::makeDir($a_target_dir.'/js/yahoo');
2321 ilUtil::makeDir($a_target_dir.'/css');
2322 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
2323 foreach (self::getSupplyingExportFiles($a_target_dir) as $f)
2324 {
2325 if ($f["source"] != "")
2326 {
2327 copy($f["source"], $f["target"]);
2328 }
2329 }
2330
2331 // template workaround: reset of template
2332 $tpl = new ilTemplate("tpl.main.html", true, true);
2333 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
2334 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2335
2336 if ($a_lang != "")
2337 {
2338 $ilUser->setLanguage($user_lang);
2339 $ilUser->setCurrentLanguage($user_lang);
2340 }
2341
2342 // zip everything
2343 if ($a_zip_file)
2344 {
2345 if ($a_lang == "")
2346 {
2347 $zip_target_dir = $this->getExportDirectory("html");
2348 }
2349 else
2350 {
2351 $zip_target_dir = $this->getExportDirectory("html_".$a_lang);
2352 ilUtil::makeDir($zip_target_dir);
2353 }
2354
2355 // zip it all
2356 $date = time();
2357 $zip_file = $zip_target_dir."/".$date."__".IL_INST_ID."__".
2358 $this->getType()."_".$this->getId().".zip";
2359//echo "-".$a_target_dir."-".$zip_file."-"; exit;
2360 ilUtil::zip($a_target_dir, $zip_file);
2361 ilUtil::delDir($a_target_dir);
2362 }
2363 }
2364
2371 static function getSupplyingExportFiles($a_target_dir = ".")
2372 {
2373 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
2374 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
2375 include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
2376 include_once("./Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php");
2377 $scripts = array(
2378 array("source" => ilYuiUtil::getLocalPath('yahoo/yahoo-min.js'),
2379 "target" => $a_target_dir.'/js/yahoo/yahoo-min.js',
2380 "type" => "js"),
2381 array("source" => ilYuiUtil::getLocalPath('yahoo-dom-event/yahoo-dom-event.js'),
2382 "target" => $a_target_dir.'/js/yahoo/yahoo-dom-event.js',
2383 "type" => "js"),
2384 array("source" => ilYuiUtil::getLocalPath('animation/animation-min.js'),
2385 "target" => $a_target_dir.'/js/yahoo/animation-min.js',
2386 "type" => "js"),
2387 array("source" => './Services/JavaScript/js/Basic.js',
2388 "target" => $a_target_dir.'/js/Basic.js',
2389 "type" => "js"),
2390 array("source" => './Services/Accordion/js/accordion.js',
2391 "target" => $a_target_dir.'/js/accordion.js',
2392 "type" => "js"),
2393 array("source" => './Services/Accordion/css/accordion.css',
2394 "target" => $a_target_dir.'/css/accordion.css',
2395 "type" => "css"),
2396 array("source" => iljQueryUtil::getLocaljQueryPath(),
2397 "target" => $a_target_dir.'/js/jquery.js',
2398 "type" => "js"),
2399 array("source" => iljQueryUtil::getLocalMaphilightPath(),
2400 "target" => $a_target_dir.'/js/maphilight.js',
2401 "type" => "js"),
2402 array("source" => iljQueryUtil::getLocaljQueryUIPath(),
2403 "target" => $a_target_dir.'/js/jquery-ui-min.js',
2404 "type" => "js"),
2405 array("source" => './Services/COPage/js/ilCOPagePres.js',
2406 "target" => $a_target_dir.'/js/ilCOPagePres.js',
2407 "type" => "js"),
2408 array("source" => './Modules/Scorm2004/scripts/questions/pure.js',
2409 "target" => $a_target_dir.'/js/pure.js',
2410 "type" => "js"),
2411 array("source" => './Modules/Scorm2004/scripts/questions/question_handling.js',
2412 "target" => $a_target_dir.'/js/question_handling.js',
2413 "type" => "js"),
2414 array("source" => './Modules/TestQuestionPool/js/ilMatchingQuestion.js',
2415 "target" => $a_target_dir.'/js/ilMatchingQuestion.js',
2416 "type" => "js"),
2417 array("source" => './Modules/Scorm2004/templates/default/question_handling.css',
2418 "target" => $a_target_dir.'/css/question_handling.css',
2419 "type" => "css"),
2420 array("source" => './Modules/TestQuestionPool/templates/default/test_javascript.css',
2421 "target" => $a_target_dir.'/css/test_javascript.css',
2422 "type" => "css"),
2423 array("source" => ilPlayerUtil::getLocalMediaElementJsPath(),
2424 "target" => $a_target_dir."/".ilPlayerUtil::getLocalMediaElementJsPath(),
2425 "type" => "js"),
2427 "target" => $a_target_dir."/".ilPlayerUtil::getLocalMediaElementCssPath(),
2428 "type" => "css"),
2430 "target" => $a_target_dir."/".ilExplorerBaseGUI::getLocalExplorerJsPath(),
2431 "type" => "js"),
2432 array("source" => ilExplorerBaseGUI::getLocalJsTreeJsPath(),
2433 "target" => $a_target_dir."/".ilExplorerBaseGUI::getLocalJsTreeJsPath(),
2434 "type" => "js"),
2435 array("source" => './Modules/LearningModule/js/LearningModule.js',
2436 "target" => $a_target_dir.'/js/LearningModule.js',
2437 "type" => "js")
2438 );
2439
2440 $mathJaxSetting = new ilSetting("MathJax");
2441 $use_mathjax = $mathJaxSetting->get("enable");
2442 if ($use_mathjax)
2443 {
2444 $scripts[] = array("source" => "",
2445 "target" => $mathJaxSetting->get("path_to_mathjax"),
2446 "type" => "js");
2447 }
2448
2449 // auto linking js
2450 include_once("./Services/Link/classes/class.ilLinkifyUtil.php");
2451 foreach (ilLinkifyUtil::getLocalJsPaths() as $p)
2452 {
2453 if (is_int(strpos($p, "ExtLink")))
2454 {
2455 $scripts[] = array("source" => $p,
2456 "target" => $a_target_dir.'/js/ilExtLink.js',
2457 "type" => "js");
2458 }
2459 if (is_int(strpos($p, "linkify")))
2460 {
2461 $scripts[] = array("source" => $p,
2462 "target" => $a_target_dir.'/js/linkify.js',
2463 "type" => "js");
2464 }
2465 }
2466
2467 return $scripts;
2468
2469 }
2470
2474 function exportHTMLFile($a_target_dir, $a_file_id)
2475 {
2476 $file_dir = $a_target_dir."/files/file_".$a_file_id;
2477 ilUtil::makeDir($file_dir);
2478 include_once("./Modules/File/classes/class.ilObjFile.php");
2479 $file_obj = new ilObjFile($a_file_id, false);
2480 $source_file = $file_obj->getDirectory($file_obj->getVersion())."/".$file_obj->getFileName();
2481 if (!is_file($source_file))
2482 {
2483 $source_file = $file_obj->getDirectory()."/".$file_obj->getFileName();
2484 }
2485 if (is_file($source_file))
2486 {
2487 copy($source_file, $file_dir."/".$file_obj->getFileName());
2488 }
2489 }
2490
2494 function exportHTMLMOB($a_target_dir, &$a_lm_gui, $a_mob_id, $a_frame, &$a_linked_mobs)
2495 {
2496 global $tpl;
2497
2498 $mob_dir = $a_target_dir."/mobs";
2499
2500 $source_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
2501 if (@is_dir($source_dir))
2502 {
2503 ilUtil::makeDir($mob_dir."/mm_".$a_mob_id);
2504 ilUtil::rCopy($source_dir, $mob_dir."/mm_".$a_mob_id);
2505 }
2506
2507 $tpl = new ilTemplate("tpl.main.html", true, true);
2508 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2509 $_GET["obj_type"] = "MediaObject";
2510 $_GET["mob_id"] = $a_mob_id;
2511 $_GET["frame"] = $a_frame;
2512 $_GET["cmd"] = "";
2513 $content = $a_lm_gui->media();
2514 $file = $a_target_dir."/media_".$a_mob_id.".html";
2515
2516 // open file
2517 if (!($fp = @fopen($file,"w+")))
2518 {
2519 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
2520 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
2521 }
2522 chmod($file, 0770);
2523 fwrite($fp, $content);
2524 fclose($fp);
2525
2526 // fullscreen
2527 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2528 $mob_obj = new ilObjMediaObject($a_mob_id);
2529 if ($mob_obj->hasFullscreenItem())
2530 {
2531 $tpl = new ilTemplate("tpl.main.html", true, true);
2532 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2533 $_GET["obj_type"] = "";
2534 $_GET["frame"] = "";
2535 $_GET["mob_id"] = $a_mob_id;
2536 $_GET["cmd"] = "fullscreen";
2537 $content = $a_lm_gui->fullscreen();
2538 $file = $a_target_dir."/fullscreen_".$a_mob_id.".html";
2539
2540 // open file
2541 if (!($fp = @fopen($file,"w+")))
2542 {
2543 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
2544 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
2545 }
2546 chmod($file, 0770);
2547 fwrite($fp, $content);
2548 fclose($fp);
2549 }
2550 $linked_mobs = $mob_obj->getLinkedMediaObjects();
2551 foreach ($linked_mobs as $id)
2552 {
2553 $this->log->debug("HTML Export: Add media object $id (".ilObject::_lookupTitle($id).") ".
2554 " due to media object ".$a_mob_id." (".ilObject::_lookupTitle($a_mob_id).").");
2555 }
2556 $a_linked_mobs = array_merge($a_linked_mobs, $linked_mobs);
2557 }
2558
2562 function exportHTMLGlossaryTerms(&$a_lm_gui, $a_target_dir)
2563 {
2564 global $ilLocator;
2565
2566 foreach($this->offline_int_links as $int_link)
2567 {
2568 $ilLocator->clearItems();
2569 if ($int_link["type"] == "git")
2570 {
2571 $tpl = new ilTemplate("tpl.main.html", true, true);
2572 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2573
2574 $_GET["obj_id"] = $int_link["id"];
2575 $_GET["frame"] = "_blank";
2576 $content = $a_lm_gui->glossary();
2577 $file = $a_target_dir."/term_".$int_link["id"].".html";
2578
2579 // open file
2580 if (!($fp = @fopen($file,"w+")))
2581 {
2582 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
2583 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
2584 }
2585 chmod($file, 0770);
2586 fwrite($fp, $content);
2587 fclose($fp);
2588
2589 // store linked/embedded media objects of glosssary term
2590 include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
2591 $defs = ilGlossaryDefinition::getDefinitionList($int_link["id"]);
2592 foreach($defs as $def)
2593 {
2594 $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
2595 foreach($def_mobs as $def_mob)
2596 {
2597 $this->offline_mobs[$def_mob] = $def_mob;
2598 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
2599 $this->log->debug("HTML Export: Add media object $def_mob (".ilObject::_lookupTitle($def_mob).") ".
2600 " due to glossary entry ".$int_link["id"]." (".ilGlossaryTerm::_lookGlossaryTerm($int_link["id"]).").");
2601 }
2602
2603 // get all files of page
2604 $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $page["obj_id"]);
2605 $this->offline_files = array_merge($this->offline_files, $def_files);
2606
2607 }
2608
2609 }
2610 }
2611 }
2612
2616 function exportHTMLPages(&$a_lm_gui, $a_target_dir, $a_lang = "", $a_all_languages = false)
2617 {
2618 global $tpl, $ilBench, $ilLocator;
2619
2620 $pages = ilLMPageObject::getPageList($this->getId());
2621
2622 $lm_tree = $this->getLMTree();
2623 $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg");
2624 $this->first_page_id = $first_page["child"];
2625
2626 // iterate all learning module pages
2627 $mobs = array();
2628 $int_links = array();
2629 $this->offline_files = array();
2630
2631 include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
2632 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2633
2634 // get html export id mapping
2635 $lm_set = new ilSetting("lm");
2636 $exp_id_map = array();
2637
2638 if ($lm_set->get("html_export_ids"))
2639 {
2640 foreach ($pages as $page)
2641 {
2642 $exp_id = ilLMPageObject::getExportId($this->getId(), $page["obj_id"]);
2643 if (trim($exp_id) != "")
2644 {
2645 $exp_id_map[$page["obj_id"]] = trim($exp_id);
2646 }
2647 }
2648 }
2649//exit;
2650 if ($a_lang == "")
2651 {
2652 $a_lang = "-";
2653 }
2654
2655 reset($pages);
2656 foreach ($pages as $page)
2657 {
2658 if (ilLMPage::_exists($this->getType(), $page["obj_id"]))
2659 {
2660 $ilLocator->clearItems();
2661 $ilBench->start("ExportHTML", "exportHTMLPage");
2662 $ilBench->start("ExportHTML", "exportPageHTML");
2663 $this->exportPageHTML($a_lm_gui, $a_target_dir, $page["obj_id"],
2664 "", $exp_id_map, $a_lang, $a_all_languages);
2665 $ilBench->stop("ExportHTML", "exportPageHTML");
2666
2667 // get all snippets of page
2668 $pcs = ilPageContentUsage::getUsagesOfPage($page["obj_id"], $this->getType().":pg", 0, false, $a_lang);
2669 foreach ($pcs as $pc)
2670 {
2671 if ($pc["type"] == "incl")
2672 {
2673 $incl_mobs = ilObjMediaObject::_getMobsOfObject("mep:pg", $pc["id"]);
2674 foreach($incl_mobs as $incl_mob)
2675 {
2676 $mobs[$incl_mob] = $incl_mob;
2677 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
2678 $this->log->debug("HTML Export: Add media object $incl_mob (".ilObject::_lookupTitle($incl_mob).") ".
2679 " due to snippet ".$pc["id"]." in page ".$page["obj_id"]." (".ilLMObject::_lookupTitle($page["obj_id"]).").");
2680 }
2681 }
2682 }
2683
2684 // get all media objects of page
2685 $pg_mobs = ilObjMediaObject::_getMobsOfObject($this->getType().":pg", $page["obj_id"], 0, $a_lang);
2686 foreach($pg_mobs as $pg_mob)
2687 {
2688 $mobs[$pg_mob] = $pg_mob;
2689 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
2690 $this->log->debug("HTML Export: Add media object $pg_mob (".ilObject::_lookupTitle($pg_mob).") ".
2691 " due to page ".$page["obj_id"]." (".ilLMObject::_lookupTitle($page["obj_id"]).").");
2692 }
2693
2694 // get all internal links of page
2695 $pg_links = ilInternalLink::_getTargetsOfSource($this->getType().":pg", $page["obj_id"], $a_lang);
2696 $int_links = array_merge($int_links, $pg_links);
2697
2698 // get all files of page
2699 include_once("./Modules/File/classes/class.ilObjFile.php");
2700 $pg_files = ilObjFile::_getFilesOfObject($this->getType().":pg", $page["obj_id"], 0, $a_lang);
2701 $this->offline_files = array_merge($this->offline_files, $pg_files);
2702
2703 // collect all questions
2704 include_once("./Services/COPage/classes/class.ilPCQuestion.php");
2705 $q_ids = ilPCQuestion::_getQuestionIdsForPage($this->getType(), $page["obj_id"], $a_lang);
2706 foreach($q_ids as $q_id)
2707 {
2708 $this->q_ids[$q_id] = $q_id;
2709 }
2710
2711 $ilBench->stop("ExportHTML", "exportHTMLPage");
2712 }
2713 }
2714 foreach ($mobs as $m)
2715 {
2716 $this->offline_mobs[$m] = $m;
2717 }
2718 foreach ($int_links as $k => $v)
2719 {
2720 $this->offline_int_links[$k] = $v;
2721 }
2722 }
2723
2724
2725
2729 function exportPageHTML(&$a_lm_gui, $a_target_dir, $a_lm_page_id, $a_frame = "",
2730 $a_exp_id_map = array(), $a_lang = "-", $a_all_languages = false)
2731 {
2732 global $tpl, $ilBench;
2733
2734 $lang_suffix = "";
2735 if ($a_lang != "-" && $a_lang != "" && $a_all_languages)
2736 {
2737 $lang_suffix = "_".$a_lang;
2738 }
2739
2740//echo "<br>B: export Page HTML ($a_lm_page_id)"; flush();
2741 // template workaround: reset of template
2742 $tpl = new ilTemplate("tpl.main.html", true, true);
2743 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2744
2745 include_once("./Services/COPage/classes/class.ilPCQuestion.php");
2747
2748 $_GET["obj_id"] = $a_lm_page_id;
2749 $_GET["frame"] = $a_frame;
2750
2751 if ($a_frame == "")
2752 {
2753 //if ($nid = ilLMObject::_lookupNID($a_lm_gui->lm->getId(), $a_lm_page_id, "pg"))
2754 if (is_array($a_exp_id_map) && isset($a_exp_id_map[$a_lm_page_id]))
2755 {
2756 $file = $a_target_dir."/lm_pg_".$a_exp_id_map[$a_lm_page_id].$lang_suffix.".html";
2757 }
2758 else
2759 {
2760 $file = $a_target_dir."/lm_pg_".$a_lm_page_id.$lang_suffix.".html";
2761 }
2762 }
2763 else
2764 {
2765 if ($a_frame != "toc")
2766 {
2767 $file = $a_target_dir."/frame_".$a_lm_page_id."_".$a_frame.$lang_suffix.".html";
2768 }
2769 else
2770 {
2771 $file = $a_target_dir."/frame_".$a_frame.$lang_suffix.".html";
2772 }
2773 }
2774
2775 // return if file is already existing
2776 if (@is_file($file))
2777 {
2778 return;
2779 }
2780
2781 $content = $a_lm_gui->layout("main.xml", false);
2782
2783 // open file
2784 if (!($fp = @fopen($file,"w+")))
2785 {
2786 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
2787 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
2788 }
2789
2790 // set file permissions
2791 chmod($file, 0770);
2792
2793 // write xml data into the file
2794 fwrite($fp, $content);
2795
2796 // close file
2797 fclose($fp);
2798
2799 if ($this->first_page_id == $a_lm_page_id && $a_frame == "")
2800 {
2801 copy($file, $a_target_dir."/index".$lang_suffix.".html");
2802 }
2803
2804 // write frames of frameset
2805 $frameset = $a_lm_gui->getCurrentFrameSet();
2806
2807 foreach ($frameset as $frame)
2808 {
2809 $this->exportPageHTML($a_lm_gui, $a_target_dir, $a_lm_page_id, $frame);
2810 }
2811
2812 }
2813
2820 function exportFO(&$a_xml_writer, $a_target_dir)
2821 {
2822 global $ilBench;
2823
2824 // fo:root (start)
2825 $attrs = array();
2826 $attrs["xmlns:fo"] = "http://www.w3.org/1999/XSL/Format";
2827 $a_xml_writer->xmlStartTag("fo:root", $attrs);
2828
2829 // fo:layout-master-set (start)
2830 $attrs = array();
2831 $a_xml_writer->xmlStartTag("fo:layout-master-set", $attrs);
2832
2833 // fo:simple-page-master (start)
2834 $attrs = array();
2835 $attrs["master-name"] = "DinA4";
2836 $attrs["page-height"] = "29.7cm";
2837 $attrs["page-width"] = "21cm";
2838 $attrs["margin-top"] = "4cm";
2839 $attrs["margin-bottom"] = "1cm";
2840 $attrs["margin-left"] = "2.8cm";
2841 $attrs["margin-right"] = "7.3cm";
2842 $a_xml_writer->xmlStartTag("fo:simple-page-master", $attrs);
2843
2844 // fo:region-body (complete)
2845 $attrs = array();
2846 $attrs["margin-top"] = "0cm";
2847 $attrs["margin-bottom"] = "1.25cm";
2848 $a_xml_writer->xmlElement("fo:region-body", $attrs);
2849
2850 // fo:region-before (complete)
2851 $attrs = array();
2852 $attrs["extent"] = "1cm";
2853 $a_xml_writer->xmlElement("fo:region-before", $attrs);
2854
2855 // fo:region-after (complete)
2856 $attrs = array();
2857 $attrs["extent"] = "1cm";
2858 $a_xml_writer->xmlElement("fo:region-after", $attrs);
2859
2860 // fo:simple-page-master (end)
2861 $a_xml_writer->xmlEndTag("fo:simple-page-master");
2862
2863 // fo:layout-master-set (end)
2864 $a_xml_writer->xmlEndTag("fo:layout-master-set");
2865
2866 // fo:page-sequence (start)
2867 $attrs = array();
2868 $attrs["master-reference"] = "DinA4";
2869 $a_xml_writer->xmlStartTag("fo:page-sequence", $attrs);
2870
2871 // fo:flow (start)
2872 $attrs = array();
2873 $attrs["flow-name"] = "xsl-region-body";
2874 $a_xml_writer->xmlStartTag("fo:flow", $attrs);
2875
2876
2877 // StructureObjects
2878 //$expLog->write(date("[y-m-d H:i:s] ")."Start Export Structure Objects");
2879 $ilBench->start("ContentObjectExport", "exportFOStructureObjects");
2880 $this->exportFOStructureObjects($a_xml_writer, $expLog);
2881 $ilBench->stop("ContentObjectExport", "exportFOStructureObjects");
2882 //$expLog->write(date("[y-m-d H:i:s] ")."Finished Export Structure Objects");*/
2883
2884 // fo:flow (end)
2885 $a_xml_writer->xmlEndTag("fo:flow");
2886
2887 // fo:page-sequence (end)
2888 $a_xml_writer->xmlEndTag("fo:page-sequence");
2889
2890 // fo:root (end)
2891 $a_xml_writer->xmlEndTag("fo:root");
2892 }
2893
2900 function exportFOStructureObjects(&$a_xml_writer)
2901 {
2902 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
2903 foreach ($childs as $child)
2904 {
2905 if($child["type"] != "st")
2906 {
2907 continue;
2908 }
2909
2910 $structure_obj = new ilStructureObject($this, $child["obj_id"]);
2911 $structure_obj->exportFO($a_xml_writer, $expLog);
2912 unset($structure_obj);
2913 }
2914 }
2915
2916 function getXMLZip()
2917 {
2918 include_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2919
2920 $cont_exp = new ilContObjectExport($this,'xml');
2921
2922 $export_file = $cont_exp->buildExportFile();
2923 return $export_file;
2924 }
2925
2934 function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
2935 {
2936 $lmtree = new ilTree($this->getId());
2937 $lmtree->setTableNames('lm_tree','lm_data');
2938 $lmtree->setTreeTablePK("lm_id");
2939//echo "-".$source_id."-".$target_id."-".$first_child."-".$as_subitem."-";
2940 $source_obj = ilLMObjectFactory::getInstance($this, $source_id, true);
2941 $source_obj->setLMId($this->getId());
2942
2943 if (!$first_child)
2944 {
2945 $target_obj = ilLMObjectFactory::getInstance($this, $target_id, true);
2946 $target_obj->setLMId($this->getId());
2947 $target_parent = $lmtree->getParentId($target_id);
2948 }
2949
2950 // handle pages
2951 if ($source_obj->getType() == "pg")
2952 {
2953//echo "1";
2954 if ($lmtree->isInTree($source_obj->getId()))
2955 {
2956 $node_data = $lmtree->getNodeData($source_obj->getId());
2957
2958 // cut on move
2959 if ($movecopy == "move")
2960 {
2961 $parent_id = $lmtree->getParentId($source_obj->getId());
2962 $lmtree->deleteTree($node_data);
2963
2964 // write history entry
2965 require_once("./Services/History/classes/class.ilHistory.php");
2966 ilHistory::_createEntry($source_obj->getId(), "cut",
2967 array(ilLMObject::_lookupTitle($parent_id), $parent_id),
2968 $this->getType().":pg");
2969 ilHistory::_createEntry($parent_id, "cut_page",
2970 array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()),
2971 $this->getType().":st");
2972 }
2973 else
2974 {
2975 // copy page
2976 $new_page = $source_obj->copy();
2977 $source_id = $new_page->getId();
2978 $source_obj = $new_page;
2979 }
2980
2981 // paste page
2982 if(!$lmtree->isInTree($source_obj->getId()))
2983 {
2984 if ($first_child) // as first child
2985 {
2986 $target_pos = IL_FIRST_NODE;
2987 $parent = $target_id;
2988 }
2989 else if ($as_subitem) // as last child
2990 {
2991 $parent = $target_id;
2992 $target_pos = IL_FIRST_NODE;
2993 $pg_childs = $lmtree->getChildsByType($parent, "pg");
2994 if (count($pg_childs) != 0)
2995 {
2996 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
2997 }
2998 }
2999 else // at position
3000 {
3001 $target_pos = $target_id;
3002 $parent = $target_parent;
3003 }
3004
3005 // insert page into tree
3006 $lmtree->insertNode($source_obj->getId(),
3007 $parent, $target_pos);
3008
3009 // write history entry
3010 if ($movecopy == "move")
3011 {
3012 // write history comments
3013 include_once("./Services/History/classes/class.ilHistory.php");
3014 ilHistory::_createEntry($source_obj->getId(), "paste",
3015 array(ilLMObject::_lookupTitle($parent), $parent),
3016 $this->getType().":pg");
3017 ilHistory::_createEntry($parent, "paste_page",
3018 array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()),
3019 $this->getType().":st");
3020 }
3021
3022 }
3023 }
3024 }
3025
3026 // handle chapters
3027 if ($source_obj->getType() == "st")
3028 {
3029//echo "2";
3030 $source_node = $lmtree->getNodeData($source_id);
3031 $subnodes = $lmtree->getSubtree($source_node);
3032
3033 // check, if target is within subtree
3034 foreach ($subnodes as $subnode)
3035 {
3036 if($subnode["obj_id"] == $target_id)
3037 {
3038 return;
3039 }
3040 }
3041
3042 $target_pos = $target_id;
3043
3044 if ($first_child) // as first subchapter
3045 {
3046 $target_pos = IL_FIRST_NODE;
3047 $target_parent = $target_id;
3048
3049 $pg_childs = $lmtree->getChildsByType($target_parent, "pg");
3050 if (count($pg_childs) != 0)
3051 {
3052 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
3053 }
3054 }
3055 else if ($as_subitem) // as last subchapter
3056 {
3057 $target_parent = $target_id;
3058 $target_pos = IL_FIRST_NODE;
3059 $childs = $lmtree->getChilds($target_parent);
3060 if (count($childs) != 0)
3061 {
3062 $target_pos = $childs[count($childs) - 1]["obj_id"];
3063 }
3064 }
3065
3066 // insert into
3067/*
3068 if ($position == "into")
3069 {
3070 $target_parent = $target_id;
3071 $target_pos = IL_FIRST_NODE;
3072
3073 // if target_pos is still first node we must skip all pages
3074 if ($target_pos == IL_FIRST_NODE)
3075 {
3076 $pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
3077 if (count($pg_childs) != 0)
3078 {
3079 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
3080 }
3081 }
3082 }
3083*/
3084
3085
3086 // delete source tree
3087 if ($movecopy == "move")
3088 {
3089 $lmtree->deleteTree($source_node);
3090 }
3091 else
3092 {
3093 // copy chapter (incl. subcontents)
3094 $new_chapter = $source_obj->copy($lmtree, $target_parent, $target_pos);
3095 }
3096
3097 if (!$lmtree->isInTree($source_id))
3098 {
3099 $lmtree->insertNode($source_id, $target_parent, $target_pos);
3100
3101 // insert moved tree
3102 if ($movecopy == "move")
3103 {
3104 foreach ($subnodes as $node)
3105 {
3106 if($node["obj_id"] != $source_id)
3107 {
3108 $lmtree->insertNode($node["obj_id"], $node["parent"]);
3109 }
3110 }
3111 }
3112 }
3113
3114 // check the tree
3115 $this->checkTree();
3116 }
3117
3118 $this->checkTree();
3119 }
3120
3124 function validatePages()
3125 {
3126 include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
3127 include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
3128
3129 $mess = "";
3130
3131 $pages = ilLMPageObject::getPageList($this->getId());
3132 foreach ($pages as $page)
3133 {
3134 if (ilLMPage::_exists($this->getType(), $page["obj_id"]))
3135 {
3136 $cpage = new ilLMPage($page["obj_id"]);
3137 $cpage->buildDom();
3138 $error = @$cpage->validateDom();
3139
3140 if ($error != "")
3141 {
3142 $this->lng->loadLanguageModule("content");
3143 ilUtil::sendInfo($this->lng->txt("cont_import_validation_errors"));
3144 $title = ilLMObject::_lookupTitle($page["obj_id"]);
3145 $page_obj = new ilLMPageObject($this, $page["obj_id"]);
3146 $mess.= $this->lng->txt("obj_pg").": ".$title;
3147 $mess.= '<div class="small">';
3148 foreach ($error as $e)
3149 {
3150 $err_mess = implode($e, " - ");
3151 if (!is_int(strpos($err_mess, ":0:")))
3152 {
3153 $mess.= htmlentities($err_mess)."<br />";
3154 }
3155 }
3156 $mess.= '</div>';
3157 $mess.= "<br />";
3158 }
3159 }
3160 }
3161
3162 return $mess;
3163 }
3164
3171 function importFromZipFile($a_tmp_file, $a_filename, $a_validate = true,
3172 $a_import_into_help_module = 0)
3173 {
3174 global $lng;
3175
3176 // create import directory
3177 $this->createImportDirectory();
3178
3179 // copy uploaded file to import directory
3180 $file = pathinfo($a_filename);
3181 $full_path = $this->getImportDirectory()."/".$a_filename;
3182
3183 ilUtil::moveUploadedFile($a_tmp_file,
3184 $a_filename, $full_path);
3185
3186 // unzip file
3187 ilUtil::unzip($full_path);
3188
3189 $subdir = basename($file["basename"],".".$file["extension"]);
3190
3191 $mess = $this->importFromDirectory(
3192 $this->getImportDirectory()."/".$subdir, $a_validate);
3193
3194
3195 // delete import directory
3197
3198 return $mess;
3199 }
3200
3201
3208 // begin-patch optes_lok_export
3209 function importFromDirectory($a_directory, $a_validate = true, $a_mapping = null)
3210 // end-patch optes_lok_export
3211 {
3212 global $lng;
3213
3214 $this->log->debug("import from directory ".$a_directory);
3215
3216 // determine filename of xml file
3217 $subdir = basename($a_directory);
3218 $xml_file = $a_directory."/".$subdir.".xml";
3219
3220 // check directory exists within zip file
3221 if (!is_dir($a_directory))
3222 {
3223 $this->log->error(sprintf($lng->txt("cont_no_subdir_in_zip"), $subdir));
3224 return sprintf($lng->txt("cont_no_subdir_in_zip"), $subdir);
3225 }
3226
3227 // check whether xml file exists within zip file
3228 if (!is_file($xml_file))
3229 {
3230 $this->log->error(sprintf($lng->txt("cont_zip_file_invalid"), $subdir."/".$subdir.".xml"));
3231 return sprintf($lng->txt("cont_zip_file_invalid"), $subdir."/".$subdir.".xml");
3232 }
3233
3234 // import questions
3235 $this->log->debug("import qti");
3236 $qti_file = $a_directory."/qti.xml";
3237 $qtis = array();
3238 if (is_file($qti_file))
3239 {
3240 include_once "./Services/QTI/classes/class.ilQTIParser.php";
3241 include_once("./Modules/Test/classes/class.ilObjTest.php");
3242 $qtiParser = new ilQTIParser ($qti_file,
3243 IL_MO_VERIFY_QTI, 0, "");
3244 $result = $qtiParser->startParsing ();
3245 $founditems = & $qtiParser->getFoundItems ();
3246 $testObj = new ilObjTest(0, true);
3247 if (count($founditems) > 0)
3248 {
3249 $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, 0, "");
3250 $qtiParser->setTestObject($testObj);
3251 $result = $qtiParser->startParsing();
3252 $qtis = array_merge($qtis, $qtiParser->getImportMapping());
3253 }
3254 }
3255
3256 $this->log->debug("get ilContObjParser");
3257 include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
3258 $subdir = ".";
3259 $contParser = new ilContObjParser($this, $xml_file, $subdir, $a_directory);
3260 // smeyer: added \ilImportMapping lok im/export
3261 $contParser->setImportMapping($a_mapping);
3262 $contParser->setQuestionMapping($qtis);
3263 $contParser->startParsing();
3264 ilObject::_writeImportId($this->getId(), $this->getImportId());
3265 $this->MDUpdateListener('General');
3266
3267 // import style
3268 $style_file = $a_directory."/style.xml";
3269 $style_zip_file = $a_directory."/style.zip";
3270 if (is_file($style_zip_file)) // try to import style.zip first
3271 {
3272 require_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3273 $style = new ilObjStyleSheet();
3274 $style->import($style_zip_file);
3275 $this->writeStyleSheetId($style->getId());
3276 }
3277 else if (is_file($style_file)) // try to import style.xml
3278 {
3279 require_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3280 $style = new ilObjStyleSheet();
3281 $style->import($style_file);
3282 $this->writeStyleSheetId($style->getId());
3283 }
3284
3285// // validate
3286 if ($a_validate)
3287 {
3288 $mess = $this->validatePages();
3289 }
3290
3291 if ($mess == "")
3292 {
3293 // handle internal links to this learning module
3294 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
3296 $this->getType(), $this->getRefId());
3297 }
3298
3299 return $mess;
3300 }
3301
3310 public function cloneObject($a_target_id,$a_copy_id = 0, $a_omit_tree = false)
3311 {
3312 global $ilDB, $ilUser, $ilias;
3313
3314 $new_obj = parent::cloneObject($a_target_id,$a_copy_id, $a_omit_tree);
3315 $this->cloneMetaData($new_obj);
3316 //$new_obj->createProperties();
3317
3318 //copy online status if object is not the root copy object
3319 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
3320
3321 if(!$cp_options->isRootNode($this->getRefId()))
3322 {
3323 $new_obj->setOnline($this->getOnline());
3324 }
3325
3326// $new_obj->setTitle($this->getTitle());
3327 $new_obj->setDescription($this->getDescription());
3328 $new_obj->setLayoutPerPage($this->getLayoutPerPage());
3329 $new_obj->setLayout($this->getLayout());
3330 $new_obj->setTOCMode($this->getTOCMode());
3331 $new_obj->setActiveLMMenu($this->isActiveLMMenu());
3332 $new_obj->setActiveTOC($this->isActiveTOC());
3333 $new_obj->setActiveNumbering($this->isActiveNumbering());
3334 $new_obj->setActivePrintView($this->isActivePrintView());
3335 $new_obj->setActivePreventGlossaryAppendix($this->isActivePreventGlossaryAppendix());
3336 $new_obj->setActiveDownloads($this->isActiveDownloads());
3337 $new_obj->setActiveDownloadsPublic($this->isActiveDownloadsPublic());
3338 $new_obj->setPublicNotes($this->publicNotes());
3339 $new_obj->setCleanFrames($this->cleanFrames());
3340 $new_obj->setHistoryUserComments($this->isActiveHistoryUserComments());
3341 $new_obj->setPublicAccessMode($this->getPublicAccessMode());
3342 $new_obj->setPageHeader($this->getPageHeader());
3343 $new_obj->setRating($this->hasRating());
3344 $new_obj->setRatingPages($this->hasRatingPages());
3345 $new_obj->setDisableDefaultFeedback($this->getDisableDefaultFeedback());
3346 $new_obj->setProgressIcons($this->getProgressIcons());
3347 $new_obj->setStoreTries($this->getStoreTries());
3348 $new_obj->setRestrictForwardNavigation($this->getRestrictForwardNavigation());
3349 $new_obj->setAutoGlossaries($this->getAutoGlossaries());
3350
3351 $new_obj->update();
3352
3353 $new_obj->createLMTree();
3354
3355 // copy style
3356 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3357 $style_id = $this->getStyleSheetId();
3358 if ($style_id > 0 &&
3360 {
3361 $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
3362 $new_id = $style_obj->ilClone();
3363 $new_obj->setStyleSheetId($new_id);
3364 }
3365 else // or just set the same standard style
3366 {
3367 $new_obj->setStyleSheetId($style_id);
3368 }
3369 $new_obj->update();
3370
3371 // copy content
3372 $copied_nodes = $this->copyAllPagesAndChapters($new_obj, $a_copy_id);
3373
3374 // page header and footer
3375 if ($this->getHeaderPage() > 0 && ($new_page_header = $copied_nodes[$this->getHeaderPage()]) > 0)
3376 {
3377 $new_obj->setHeaderPage($new_page_header);
3378 }
3379 if ($this->getFooterPage() > 0 && ($new_page_footer = $copied_nodes[$this->getFooterPage()]) > 0)
3380 {
3381 $new_obj->setFooterPage($new_page_footer);
3382 }
3383 $new_obj->update();
3384
3385 // Copy learning progress settings
3386 include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
3387 $obj_settings = new ilLPObjSettings($this->getId());
3388 $obj_settings->cloneSettings($new_obj->getId());
3389 unset($obj_settings);
3390
3391 // copy (page) multilang settings
3392 include_once("./Services/Object/classes/class.ilObjectTranslation.php");
3394 $ot->copy($new_obj->getId());
3395
3396 // copy lm menu
3397 include_once './Modules/LearningModule/classes/class.ilLMMenuEditor.php';
3398 $menu = new ilLMMenuEditor();
3399 $menu->setObjId($this->getId());
3400 $new_menu = new ilLMMenuEditor();
3401 $new_menu->setObjId($new_obj->getId());
3402 foreach ($menu->getMenuEntries() as $entry)
3403 {
3404 /*'id' => $row->id,
3405 'title' => $row->title,
3406 'link' => $row->target,
3407 'type' => $row->link_type,
3408 'ref_id' => $row->link_ref_id,
3409 'active'*/
3410
3411 $new_menu->setTarget($entry["link"]);
3412 $new_menu->setTitle($entry["title"]);
3413 $new_menu->setLinkType($entry["type"]);
3414 $new_menu->setLinkRefId($entry["ref_id"]);
3415 $new_menu->create();
3416 ilLMMenuEditor::writeActive($new_menu->getEntryId(), $entry["active"] == "y" ? true : false);
3417 }
3418
3419
3420 return $new_obj;
3421 }
3422
3428 function copyAllPagesAndChapters($a_target_obj, $a_copy_id = 0)
3429 {
3430 $parent_id = $a_target_obj->lm_tree->readRootId();
3431
3432 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
3433 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
3434
3435 // get all chapters of root lm
3436 $chapters = $this->lm_tree->getChildsByType($this->lm_tree->readRootId(), "st");
3437 $copied_nodes = array();
3438 //$time = time();
3439 foreach ($chapters as $chap)
3440 {
3441 $cid = ilLMObject::pasteTree($a_target_obj, $chap["child"], $parent_id,
3442 IL_LAST_NODE, $time, $copied_nodes, true, $this);
3443 $target = $cid;
3444 }
3445
3446 // copy free pages
3447 $pages = ilLMPageObject::getPageList($this->getId());
3448 foreach ($pages as $p)
3449 {
3450 if (!$this->lm_tree->isInTree($p["obj_id"]))
3451 {
3452 $item = new ilLMPageObject($this, $p["obj_id"]);
3453 $target_item = $item->copy($a_target_obj);
3454 $copied_nodes[$item->getId()] = $target_item->getId();
3455 }
3456 }
3457
3458 // Add mapping for pages and chapters
3459 include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
3461 foreach($copied_nodes as $old_id => $new_id)
3462 {
3463 $options->appendMapping(
3464 $this->getRefId().'_'.$old_id,
3465 $a_target_obj->getRefId().'_'.$new_id
3466 );
3467 }
3468
3469 ilLMObject::updateInternalLinks($copied_nodes);
3470
3471 $a_target_obj->checkTree();
3472
3473 return $copied_nodes;
3474 }
3475
3476
3483 static function lookupAutoGlossaries($a_lm_id)
3484 {
3485 global $ilDB;
3486
3487 // read auto glossaries
3488 $set = $ilDB->query("SELECT * FROM lm_glossaries ".
3489 " WHERE lm_id = ".$ilDB->quote($a_lm_id, "integer")
3490 );
3491 $glos = array();
3492 while ($rec = $ilDB->fetchAssoc($set))
3493 {
3494 $glos[] = $rec["glo_id"];
3495 }
3496 return $glos;
3497 }
3498
3505 function autoLinkGlossaryTerms($a_glo_id)
3506 {
3507 // get terms
3508 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
3509 $terms = ilGlossaryTerm::getTermList($a_glo_id);
3510
3511 // each get page: get content
3512 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
3513 $pages = ilLMPage::getAllPages($this->getType(), $this->getId());
3514
3515 // determine terms that occur in the page
3516 $found_pages = array();
3517 foreach ($pages as $p)
3518 {
3519 $pg = new ilLMPage($p["id"]);
3520 $c = $pg->getXMLContent();
3521 foreach ($terms as $t)
3522 {
3523 if (is_int(stripos($c, $t["term"])))
3524 {
3525 $found_pages[$p["id"]]["terms"][] = $t;
3526 if (!is_object($found_pages[$p["id"]]["page"]))
3527 {
3528 $found_pages[$p["id"]]["page"] = $pg;
3529 }
3530 }
3531 }
3532 reset($terms);
3533 }
3534
3535 // ilPCParagraph autoLinkGlossariesPage with page and terms
3536 include_once("./Services/COPage/classes/class.ilPCParagraph.php");
3537 foreach ($found_pages as $id => $fp)
3538 {
3539 ilPCParagraph::autoLinkGlossariesPage($fp["page"], $fp["terms"]);
3540 }
3541
3542
3543 }
3544
3545
3549
3555 static function isOnlineHelpModule($a_id, $a_as_obj_id = false)
3556 {
3557 if (!$a_as_obj_id && $a_id > 0 && $a_id == OH_REF_ID)
3558 {
3559 return true;
3560 }
3561 if ($a_as_obj_id && $a_id > 0 && $a_id == ilObject::_lookupObjId(OH_REF_ID))
3562 {
3563 return true;
3564 }
3565 return false;
3566 }
3567
3568 public function setRating($a_value)
3569 {
3570 $this->rating = (bool)$a_value;
3571 }
3572
3573 public function hasRating()
3574 {
3575 return $this->rating;
3576 }
3577
3578 public function setRatingPages($a_value)
3579 {
3580 $this->rating_pages = (bool)$a_value;
3581 }
3582
3583 public function hasRatingPages()
3584 {
3585 return $this->rating_pages;
3586 }
3587
3588
3589 public function MDUpdateListener($a_element)
3590 {
3591 parent::MDUpdateListener($a_element);
3592
3593 include_once 'Services/MetaData/classes/class.ilMD.php';
3594
3595 switch($a_element)
3596 {
3597 case 'Educational':
3598 include_once("./Services/Object/classes/class.ilObjectLP.php");
3599 $obj_lp = ilObjectLP::getInstance($this->getId());
3600 if(in_array($obj_lp->getCurrentMode(),
3602 {
3603 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
3605 }
3606 break;
3607
3608 case 'General':
3609
3610 // Update Title and description
3611 $md = new ilMD($this->getId(),0, $this->getType());
3612 if(!is_object($md_gen = $md->getGeneral()))
3613 {
3614 return false;
3615 }
3616
3617 include_once("./Services/Object/classes/class.ilObjectTranslation.php");
3619 if ($ot->getContentActivated())
3620 {
3621 $ot->setDefaultTitle($md_gen->getTitle());
3622
3623 foreach($md_gen->getDescriptionIds() as $id)
3624 {
3625 $md_des = $md_gen->getDescription($id);
3626 $ot->setDefaultDescription($md_des->getDescription());
3627 break;
3628 }
3629 $ot->save();
3630 }
3631 break;
3632
3633 }
3634 return true;
3635 }
3636
3643 {
3644 $dirs = array("xml", "scorm");
3645 $export_files = array();
3646
3647 include_once("./Services/Object/classes/class.ilObjectTranslation.php");
3649 if ($ot->getContentActivated())
3650 {
3651 $langs = $ot->getLanguages();
3652 foreach ($langs as $l => $ldata)
3653 {
3654 $dirs[] = "html_".$l;
3655 }
3656 $dirs[] = "html_all";
3657 }
3658 else
3659 {
3660 $dirs[] = "html";
3661 }
3662
3663 foreach($dirs as $dir)
3664 {
3665 $type = explode("_", $dir);
3666 $type = $type[0];
3667 if ($this->getPublicExportFile($type) != "")
3668 {
3669 if (is_file($this->getExportDirectory($dir)."/".
3670 $this->getPublicExportFile($type)))
3671 {
3672 $size = filesize($this->getExportDirectory($dir)."/".
3673 $this->getPublicExportFile($type));
3674 $export_files[] = array("type" => $type,
3675 "dir_type" => $dir,
3676 "file" => $this->getPublicExportFile($type),
3677 "size" => $size);
3678 }
3679 }
3680 }
3681
3682 return $export_files;
3683 }
3684
3685
3686}
3687?>
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$result
$error
Definition: Error.php:17
$size
Definition: RandomTest.php:79
global $tpl
Definition: ilias.php:8
if(strpos( $jquery_path, './')===0) else if(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:36
$files
Definition: add-vimline.php:18
global $l
Definition: afr.php:30
$path
Definition: aliased.php:25
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
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.
Content Object (ILIAS native learning module / digilib book) Manifest export class.
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_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.
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 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.
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)
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
importFromZipFile($a_tmp_file, $a_filename, $a_validate=true, $a_import_into_help_module=0)
Import lm from zip file.
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.
createLMTree()
create content object tree (that stores structure object hierarchie)
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.
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
autoLinkGlossaryTerms($a_glo_id)
Auto link glossary terms.
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 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 moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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)
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()
Get local path of jQuery UI file.
static getLocaljQueryPath()
Get local path of jQuery file.
static getLocalMaphilightPath()
Get local path of maphilight file.
$style
Definition: example_012.php:70
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$target_id
Definition: goto.php:51
global $ilBench
Definition: ilias.php:18
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
redirection script todo: (a better solution should control the processing via a xml file)
$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 $ilDB
$lm_set
if(!is_array($argv)) $options
$mobs
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:93