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