ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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;
29 
30  private $import_dir = '';
31 
38  function ilObjContentObject($a_id = 0,$a_call_by_reference = true)
39  {
40  // this also calls read() method! (if $a_id is set)
41  $this->ilObject($a_id,$a_call_by_reference);
42 
43  $this->mob_ids = array();
44  $this->file_ids = array();
45  $this->q_ids = array();
46  }
47 
51  function create($a_no_meta_data = false)
52  {
53  global $ilUser;
54 
56 
57  // meta data will be created by
58  // import parser
59  if (!$a_no_meta_data)
60  {
61  $this->createMetaData();
62  }
63 
64  $this->createProperties();
65  }
66 
73  function initDefaultRoles()
74  {
75  return array();
76 
77  global $rbacadmin, $rbacreview;
78 
79  // create a local role folder
80  $rfoldObj = $this->createRoleFolder("Local roles","Role Folder of content object ".$this->getId());
81 
82  // note: we don't need any roles here, local "author" roles must
83  // be created manually. subscription roles have been abandoned.
84  /*
85  // create author role and assign role to rolefolder...
86  $roleObj = $rfoldObj->createRole("author object ".$this->getRefId(),"author of content object ref id ".$this->getRefId());
87  $roles[] = $roleObj->getId();
88 
89  // copy permissions from author template to new role
90  $rbacadmin->copyRolePermissions($this->getAuthorRoleTemplateId(), 8, $rfoldObj->getRefId(), $roleObj->getId());
91 
92  // grant all allowed operations of role to current learning module
93  $rbacadmin->grantPermission($roleObj->getId(),
94  $rbacreview->getOperationsOfRole($roleObj->getId(), "lm", $rfoldObj->getRefId()),
95  $this->getRefId());*/
96 
97  unset($rfoldObj);
98  //unset($roleObj);
99 
100  return $roles ? $roles : array();
101  }
102 
103 
107  function read()
108  {
109  parent::read();
110 # echo "Content<br>\n";
111 
112  $this->lm_tree = new ilTree($this->getId());
113  $this->lm_tree->setTableNames('lm_tree','lm_data');
114  $this->lm_tree->setTreeTablePK("lm_id");
115 
116  $this->readProperties();
117  //parent::read();
118  }
119 
125  function getTitle()
126  {
127  return parent::getTitle();
128  }
129 
133  function setTitle($a_title)
134  {
135  parent::setTitle($a_title);
136 // $this->meta_data->setTitle($a_title);
137  }
138 
144  function getDescription()
145  {
146  return parent::getDescription();
147  }
148 
152  function setDescription($a_description)
153  {
154  parent::setDescription($a_description);
155 // $this->meta_data->setDescription($a_description);
156  }
157 
158 
159  function getImportId()
160  {
161  return $this->import_id;
162  }
163 
164  function setImportId($a_id)
165  {
166  $this->import_id = $a_id;
167  }
168 
174  function setLayoutPerPage($a_val)
175  {
176  $this->layout_per_page = $a_val;
177  }
178 
184  function getLayoutPerPage()
185  {
186  return $this->layout_per_page;
187  }
188 
189  function &getTree()
190  {
191  return $this->lm_tree;
192  }
193 
197  function update()
198  {
199  $this->updateMetaData();
200  parent::update();
201  $this->updateProperties();
202  }
203 
204 
208  function import()
209  {
210  // nothing to do. just display the dialogue in Out
211  return;
212  }
213 
214 
219  function putInTree($a_parent)
220  {
221  global $tree;
222 
223  // put this object in tree under $a_parent
224  parent::putInTree($a_parent);
225 
226  // make new tree for this object
227  //$tree->addTree($this->getId());
228  }
229 
230 
236  function createLMTree()
237  {
238  $this->lm_tree =& new ilTree($this->getId());
239  $this->lm_tree->setTreeTablePK("lm_id");
240  $this->lm_tree->setTableNames('lm_tree','lm_data');
241  $this->lm_tree->addTree($this->getId(), 1);
242  }
243 
248  {
249  global $lng;
250 
251  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
252  include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
253  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
254 
255  $root_id = $this->lm_tree->getRootId();
256 
257  // chapter
258  $chap = new ilStructureObject($this);
259  $chap->setType("st");
260  $chap->setTitle($lng->txt("cont_new_chap"));
261  $chap->setLMId($this->getId());
262  $chap->create();
263  ilLMObject::putInTree($chap, $root_id, IL_FIRST_NODE);
264 
265  // page
266  $page = new ilLMPageObject($this);
267  $page->setType("pg");
268  $page->setTitle($lng->txt("cont_new_page"));
269  $page->setLMId($this->getId());
270  $page->create();
271  ilLMObject::putInTree($page, $chap->getId(), IL_FIRST_NODE);
272  }
273 
274 
278  function &getLMTree()
279  {
280  return $this->lm_tree;
281  }
282 
283 
290  {
291  $lm_data_dir = ilUtil::getDataDir()."/lm_data";
292  if(!is_writable($lm_data_dir))
293  {
294  $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir
295  .") not writeable.",$this->ilias->error_obj->FATAL);
296  }
297 
298  // create learning module directory (data_dir/lm_data/lm_<id>)
299  $lm_dir = $lm_data_dir."/lm_".$this->getId();
300  ilUtil::makeDir($lm_dir);
301  if(!@is_dir($lm_dir))
302  {
303  $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
304  }
305 
306  // create import subdirectory (data_dir/lm_data/lm_<id>/import)
307  $import_dir = $lm_dir."/import";
309  if(!@is_dir($import_dir))
310  {
311  $this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
312  }
313  }
314 
318  function getDataDirectory()
319  {
320  return ilUtil::getDataDir()."/lm_data".
321  "/lm_".$this->getId();
322  }
323 
328  {
329  if(strlen($this->import_dir))
330  {
331  return $this->import_dir;
332  }
333 
334  $import_dir = ilUtil::getDataDir()."/lm_data".
335  "/lm_".$this->getId()."/import";
336  if(@is_dir($import_dir))
337  {
338  return $import_dir;
339  }
340  else
341  {
342  return false;
343  }
344  }
345 
352  public function setImportDirectory($a_import_dir)
353  {
354  $this->import_dir = $a_import_dir;
355  }
356 
357 
363  function createExportDirectory($a_type = "xml")
364  {
365  $lm_data_dir = ilUtil::getDataDir()."/lm_data";
366  if(!is_writable($lm_data_dir))
367  {
368  $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir
369  .") not writeable.",$this->ilias->error_obj->FATAL);
370  }
371  // create learning module directory (data_dir/lm_data/lm_<id>)
372  $lm_dir = $lm_data_dir."/lm_".$this->getId();
373  ilUtil::makeDir($lm_dir);
374  if(!@is_dir($lm_dir))
375  {
376  $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
377  }
378  // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
379  switch ($a_type)
380  {
381  // html
382  case "html":
383  $export_dir = $lm_dir."/export_html";
384  break;
385 
386  // scorm
387  case "scorm":
388  $export_dir = $lm_dir."/export_scorm";
389  break;
390 
391  default: // = xml
392  $export_dir = $lm_dir."/export";
393  break;
394  }
395  ilUtil::makeDir($export_dir);
396 
397  if(!@is_dir($export_dir))
398  {
399  $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
400  }
401  }
402 
406  function getExportDirectory($a_type = "xml")
407  {
408  switch ($a_type)
409  {
410  case "html":
411  $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export_html";
412  break;
413 
414  case "scorm":
415  $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export_scorm";
416  break;
417 
418  default: // = xml
419  $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export";
420  break;
421  }
422  return $export_dir;
423  }
424 
425 
436  function delete()
437  {
438  global $ilDB;
439 
440  global $ilBench;
441 
442  // always call parent delete function first!!
443  if (!parent::delete())
444  {
445  return false;
446  }
447 
448  // delete lm object data
449  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
451 
452  // delete meta data of content object
453  $this->deleteMetaData();
454 
455  // delete bibitem data
456  $nested = new ilNestedSetXML();
457  $nested->init($this->getId(), "bib");
458  $nested->deleteAllDBData();
459 
460 
461  // delete learning module tree
462  $this->lm_tree->removeTree($this->lm_tree->getTreeId());
463 
464  // delete data directory
466 
467  // delete content object record
468  $q = "DELETE FROM content_object WHERE id = ".
469  $ilDB->quote($this->getId(), "integer");
470  $ilDB->manipulate($q);
471 
472  // delete lm menu entries
473  $q = "DELETE FROM lm_menu WHERE lm_id = ".
474  $ilDB->quote($this->getId(), "integer");
475  $ilDB->manipulate($q);
476 
477  return true;
478  }
479 
480 
486  function getLayout()
487  {
488  return $this->layout;
489  }
490 
496  function setLayout($a_layout)
497  {
498  $this->layout = $a_layout;
499  }
500 
504  function getStyleSheetId()
505  {
506  return $this->style_id;
507  }
508 
512  function setStyleSheetId($a_style_id)
513  {
514  $this->style_id = $a_style_id;
515  }
516 
520  function writeStyleSheetId($a_style_id)
521  {
522  global $ilDB;
523 
524  $q = "UPDATE content_object SET ".
525  " stylesheet = ".$ilDB->quote((int) $a_style_id, "integer").
526  " WHERE id = ".$ilDB->quote($this->getId(), "integer");
527  $ilDB->manipulate($q);
528 
529  $this->style_id = $a_style_id;
530  }
531 
535  function _moveLMStyles($a_from_style, $a_to_style)
536  {
537  global $ilDB, $ilias;
538 
539  if ($a_from_style < 0) // change / delete all individual styles
540  {
541  $q = "SELECT stylesheet FROM content_object, style_data ".
542  " WHERE content_object.stylesheet = style_data.id ".
543  " AND style_data.standard = ".$ilDB->quote(0, "integer").
544  " AND content_object.stylesheet > ".$ilDB->quote(0, "integer");
545  $style_set = $ilDB->query($q);
546  while($style_rec = $ilDB->fetchAssoc($style_set))
547  {
548  // assign learning modules to new style
549  $q = "UPDATE content_object SET ".
550  " stylesheet = ".$ilDB->quote((int) $a_to_style, "integer").
551  " WHERE stylesheet = ".$ilDB->quote($style_rec["stylesheet"], "integer");
552  $ilDB->manipulate($q);
553 
554  // delete style
555  $style_obj =& $ilias->obj_factory->getInstanceByObjId($style_rec["stylesheet"]);
556  $style_obj->delete();
557  }
558  }
559  else
560  {
561  $q = "UPDATE content_object SET ".
562  " stylesheet = ".$ilDB->quote((int) $a_to_style, "integer").
563  " WHERE stylesheet = ".$ilDB->quote($a_from_style, "integer");
564  $ilDB->manipulate($q);
565  }
566  }
567 
571  function _lookupStyleSheetId($a_cont_obj_id)
572  {
573  global $ilDB;
574 
575  $q = "SELECT stylesheet FROM content_object ".
576  " WHERE id = ".$ilDB->quote($a_cont_obj_id, "integer");
577  $res = $ilDB->query($q);
578  $sheet = $ilDB->fetchAssoc($res);
579 
580  return $sheet["stylesheet"];
581  }
582 
586  function _lookupContObjIdByStyleId($a_style_id)
587  {
588  global $ilDB;
589 
590  $q = "SELECT id FROM content_object ".
591  " WHERE stylesheet = ".$ilDB->quote($a_style_id, "integer");
592  $res = $ilDB->query($q);
593  $obj_ids = array();
594  while($cont = $ilDB->fetchAssoc($res))
595  {
596  $obj_ids[] = $cont["id"];
597  }
598  return $obj_ids;
599  }
600 
606  function _getNrOfAssignedLMs($a_style_id)
607  {
608  global $ilDB;
609 
610  $q = "SELECT count(*) as cnt FROM content_object ".
611  " WHERE stylesheet = ".$ilDB->quote($a_style_id, "integer");
612  $cset = $ilDB->query($q);
613  $crow = $ilDB->fetchAssoc($cset);
614 
615  return (int) $crow["cnt"];
616  }
617 
618 
623  {
624  global $ilDB;
625 
626  // joining with style table (not perfectly nice)
627  $q = "SELECT count(*) as cnt FROM content_object, style_data ".
628  " WHERE stylesheet = style_data.id ".
629  " AND standard = ".$ilDB->quote(0, "integer");
630  $cset = $ilDB->query($q);
631  $crow = $ilDB->fetchAssoc($cset);
632 
633  return (int) $crow["cnt"];
634  }
635 
639  function _getNrLMsNoStyle()
640  {
641  global $ilDB;
642 
643  $q = "SELECT count(*) as cnt FROM content_object ".
644  " WHERE stylesheet = ".$ilDB->quote(0, "integer");
645  $cset = $ilDB->query($q);
646  $crow = $ilDB->fetchAssoc($cset);
647 
648  return (int) $crow["cnt"];
649  }
650 
656  function _deleteStyleAssignments($a_style_id)
657  {
658  global $ilDB;
659 
660  $q = "UPDATE content_object SET ".
661  " stylesheet = ".$ilDB->quote(0, "integer").
662  " WHERE stylesheet = ".$ilDB->quote((int) $this->getId($a_style_id), "integer");
663 
664  $ilDB->manipulate($q);
665  }
666 
670  function getPageHeader()
671  {
672  return $this->pg_header;
673  }
674 
680  function setPageHeader($a_pg_header = IL_CHAPTER_TITLE)
681  {
682  $this->pg_header = $a_pg_header;
683  }
684 
688  function getTOCMode()
689  {
690  return $this->toc_mode;
691  }
692 
697  {
698  return $this->public_access_mode;
699  }
700 
706  function setTOCMode($a_toc_mode = "chapters")
707  {
708  $this->toc_mode = $a_toc_mode;
709  }
710 
711  function setOnline($a_online)
712  {
713  $this->online = $a_online;
714  }
715 
716  function getOnline()
717  {
718  return $this->online;
719  }
720 
721  function setActiveLMMenu($a_act_lm_menu)
722  {
723  $this->lm_menu_active = $a_act_lm_menu;
724  }
725 
726  function isActiveLMMenu()
727  {
728  return $this->lm_menu_active;
729  }
730 
731  function setActiveTOC($a_toc)
732  {
733  $this->toc_active = $a_toc;
734  }
735 
736  function isActiveTOC()
737  {
738  return $this->toc_active;
739  }
740 
741  function setActiveNumbering($a_num)
742  {
743  $this->numbering = $a_num;
744  }
745 
746  function isActiveNumbering()
747  {
748  return $this->numbering;
749  }
750 
751  function setActivePrintView($a_print)
752  {
753  $this->print_view_active = $a_print;
754  }
755 
756  function isActivePrintView()
757  {
758  return $this->print_view_active;
759  }
760 
762  {
763  $this->prevent_glossary_appendix_active = $a_print;
764  }
765 
767  {
768  return $this->prevent_glossary_appendix_active;
769  }
770 
771  function setActiveDownloads($a_down)
772  {
773  $this->downloads_active = $a_down;
774  }
775 
776  function isActiveDownloads()
777  {
778  return $this->downloads_active;
779  }
780 
781  function setActiveDownloadsPublic($a_down)
782  {
783  $this->downloads_public_active = $a_down;
784  }
785 
787  {
788  return $this->downloads_public_active;
789  }
790 
791  function setPublicNotes($a_pub_notes)
792  {
793  $this->pub_notes = $a_pub_notes;
794  }
795 
796  function publicNotes()
797  {
798  return $this->pub_notes;
799  }
800 
801  function setCleanFrames($a_clean)
802  {
803  $this->clean_frames = $a_clean;
804  }
805 
806  function cleanFrames()
807  {
808  return $this->clean_frames;
809  }
810 
811  function setHistoryUserComments($a_comm)
812  {
813  $this->user_comments = $a_comm;
814  }
815 
816  function setPublicAccessMode($a_mode)
817  {
818  $this->public_access_mode = $a_mode;
819  }
820 
822  {
823  return $this->user_comments;
824  }
825 
826  function setHeaderPage($a_pg)
827  {
828  $this->header_page = $a_pg;
829  }
830 
831  function getHeaderPage()
832  {
833  return $this->header_page;
834  }
835 
836  function setFooterPage($a_pg)
837  {
838  $this->footer_page = $a_pg;
839  }
840 
841  function getFooterPage()
842  {
843  return $this->footer_page;
844  }
845 
849  function readProperties()
850  {
851  global $ilDB;
852 
853  $q = "SELECT * FROM content_object WHERE id = ".
854  $ilDB->quote($this->getId(), "integer");
855  $lm_set = $ilDB->query($q);
856  $lm_rec = $ilDB->fetchAssoc($lm_set);
857  $this->setLayout($lm_rec["default_layout"]);
858  $this->setStyleSheetId((int) $lm_rec["stylesheet"]);
859  $this->setPageHeader($lm_rec["page_header"]);
860  $this->setTOCMode($lm_rec["toc_mode"]);
861  $this->setOnline(ilUtil::yn2tf($lm_rec["is_online"]));
862  $this->setActiveTOC(ilUtil::yn2tf($lm_rec["toc_active"]));
863  $this->setActiveNumbering(ilUtil::yn2tf($lm_rec["numbering"]));
864  $this->setActivePrintView(ilUtil::yn2tf($lm_rec["print_view_active"]));
865  $this->setActivePreventGlossaryAppendix(ilUtil::yn2tf($lm_rec["no_glo_appendix"]));
866  $this->setActiveDownloads(ilUtil::yn2tf($lm_rec["downloads_active"]));
867  $this->setActiveDownloadsPublic(ilUtil::yn2tf($lm_rec["downloads_public_active"]));
868  $this->setActiveLMMenu(ilUtil::yn2tf($lm_rec["lm_menu_active"]));
869  $this->setCleanFrames(ilUtil::yn2tf($lm_rec["clean_frames"]));
870  $this->setPublicNotes(ilUtil::yn2tf($lm_rec["pub_notes"]));
871  $this->setHeaderPage((int) $lm_rec["header_page"]);
872  $this->setFooterPage((int) $lm_rec["footer_page"]);
873  $this->setHistoryUserComments(ilUtil::yn2tf($lm_rec["hist_user_comments"]));
874  $this->setPublicAccessMode($lm_rec["public_access_mode"]);
875  $this->setPublicExportFile("xml", $lm_rec["public_xml_file"]);
876  $this->setPublicExportFile("html", $lm_rec["public_html_file"]);
877  $this->setPublicExportFile("scorm", $lm_rec["public_scorm_file"]);
878  $this->setLayoutPerPage($lm_rec["layout_per_page"]);
879  }
880 
884  function updateProperties()
885  {
886  global $ilDB;
887 
888  // force clean_frames to be set, if layout per page is activated
889  if ($this->getLayoutPerPage())
890  {
891  $this->setCleanFrames(true);
892  }
893 
894  $q = "UPDATE content_object SET ".
895  " default_layout = ".$ilDB->quote($this->getLayout(), "text").", ".
896  " stylesheet = ".$ilDB->quote($this->getStyleSheetId(), "integer").",".
897  " page_header = ".$ilDB->quote($this->getPageHeader(), "text").",".
898  " toc_mode = ".$ilDB->quote($this->getTOCMode(), "text").",".
899  " is_online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline()), "text").",".
900  " toc_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveTOC()), "text").",".
901  " numbering = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveNumbering()), "text").",".
902  " print_view_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActivePrintView()), "text").",".
903  " no_glo_appendix = ".$ilDB->quote(ilUtil::tf2yn($this->isActivePreventGlossaryAppendix()), "text").",".
904  " downloads_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveDownloads()), "text").",".
905  " downloads_public_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveDownloadsPublic()), "text").",".
906  " clean_frames = ".$ilDB->quote(ilUtil::tf2yn($this->cleanFrames()), "text").",".
907  " pub_notes = ".$ilDB->quote(ilUtil::tf2yn($this->publicNotes()), "text").",".
908  " hist_user_comments = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveHistoryUserComments()), "text").",".
909  " public_access_mode = ".$ilDB->quote($this->getPublicAccessMode(), "text").",".
910  " public_xml_file = ".$ilDB->quote($this->getPublicExportFile("xml"), "text").",".
911  " public_html_file = ".$ilDB->quote($this->getPublicExportFile("html"), "text").",".
912  " public_scorm_file = ".$ilDB->quote($this->getPublicExportFile("scorm"), "text").",".
913  " header_page = ".$ilDB->quote($this->getHeaderPage(), "integer").",".
914  " footer_page = ".$ilDB->quote($this->getFooterPage(), "integer").",".
915  " lm_menu_active = ".$ilDB->quote(ilUtil::tf2yn($this->isActiveLMMenu()), "text").", ".
916  " layout_per_page = ".$ilDB->quote($this->getLayoutPerPage(), "integer")." ".
917  " WHERE id = ".$ilDB->quote($this->getId(), "integer");
918  $ilDB->manipulate($q);
919  }
920 
924  function createProperties()
925  {
926  global $ilDB;
927 
928  $q = "INSERT INTO content_object (id) VALUES (".$ilDB->quote($this->getId(), "integer").")";
929  $ilDB->manipulate($q);
930  $this->readProperties(); // to get db default values
931  }
932 
936  function _lookupOnline($a_id)
937  {
938  global $ilDB;
939 
940 //echo "class ilObjContentObject::_lookupOnline($a_id) called. Use Access class instead.";
941 
942  $q = "SELECT is_online FROM content_object WHERE id = ".$ilDB->quote($a_id, "integer");
943  $lm_set = $ilDB->query($q);
944  $lm_rec = $ilDB->fetchAssoc($lm_set);
945 
946  return ilUtil::yn2tf($lm_rec["is_online"]);
947  }
948 
955  {
956  $dir = opendir("./Modules/LearningModule/layouts/lm");
957 
958  $layouts = array();
959 
960  while($file = readdir($dir))
961  {
962  if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn")
963  {
964  // directories
965  if (@is_dir("./Modules/LearningModule/layouts/lm/".$file))
966  {
967  $layouts[$file] = $file;
968  }
969  }
970  }
971  asort($layouts);
972 
973  // workaround: fix ordering
974  $ret = array(
975  'toc2win' => 'toc2win',
976  'toc2windyn' => 'toc2windyn',
977  '1window' => '1window',
978  '2window' => '2window',
979  '3window' => '3window',
980  'presentation' => 'presentation',
981  'fullscreen' => 'fullscreen'
982  );
983 
984  foreach ($layouts as $l)
985  {
986  if (!in_array($l, $ret))
987  {
988  $ret[$l] = $l;
989  }
990  }
991 
992  return $ret;
993  }
994 
998  function _checkPreconditionsOfPage($cont_ref_id,$cont_obj_id, $page_id)
999  {
1000  global $ilUser,$ilErr;
1001 
1002  $lm_tree = new ilTree($cont_obj_id);
1003  $lm_tree->setTableNames('lm_tree','lm_data');
1004  $lm_tree->setTreeTablePK("lm_id");
1005 
1006  if ($lm_tree->isInTree($page_id))
1007  {
1008  $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
1009  foreach ($path as $node)
1010  {
1011  if ($node["type"] == "st")
1012  {
1013  if (!ilConditionHandler::_checkAllConditionsOfTarget($cont_ref_id,$node["child"], "st"))
1014  {
1015  return false;
1016  }
1017  }
1018  }
1019  }
1020 
1021  return true;
1022  }
1023 
1027  function _getMissingPreconditionsOfPage($cont_ref_id,$cont_obj_id, $page_id)
1028  {
1029  $lm_tree = new ilTree($cont_obj_id);
1030  $lm_tree->setTableNames('lm_tree','lm_data');
1031  $lm_tree->setTreeTablePK("lm_id");
1032 
1033  $conds = array();
1034  if ($lm_tree->isInTree($page_id))
1035  {
1036  // get full path of page
1037  $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
1038  foreach ($path as $node)
1039  {
1040  if ($node["type"] == "st")
1041  {
1042  // get all preconditions of upper chapters
1043  $tconds = ilConditionHandler::_getConditionsOfTarget($cont_ref_id,$node["child"], "st");
1044  foreach ($tconds as $tcond)
1045  {
1046  // store all missing preconditions
1047  if (!ilConditionHandler::_checkCondition($tcond["id"]))
1048  {
1049  $conds[] = $tcond;
1050  }
1051  }
1052  }
1053  }
1054  }
1055 
1056  return $conds;
1057  }
1058 
1062  function _getMissingPreconditionsTopChapter($cont_obj_ref_id,$cont_obj_id, $page_id)
1063  {
1064  $lm_tree = new ilTree($cont_obj_id);
1065  $lm_tree->setTableNames('lm_tree','lm_data');
1066  $lm_tree->setTreeTablePK("lm_id");
1067 
1068  $conds = array();
1069  if ($lm_tree->isInTree($page_id))
1070  {
1071  // get full path of page
1072  $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
1073  foreach ($path as $node)
1074  {
1075  if ($node["type"] == "st")
1076  {
1077  // get all preconditions of upper chapters
1078  $tconds = ilConditionHandler::_getConditionsOfTarget($cont_obj_ref_id,$node["child"], "st");
1079  foreach ($tconds as $tcond)
1080  {
1081  // look for missing precondition
1082  if (!ilConditionHandler::_checkCondition($tcond["id"]))
1083  {
1084  return $node["child"];
1085  }
1086  }
1087  }
1088  }
1089  }
1090 
1091  return "";
1092  }
1093 
1104  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1105  {
1106  global $tree;
1107 
1108  switch ($a_event)
1109  {
1110  case "link":
1111 
1112  //var_dump("<pre>",$a_params,"</pre>");
1113  //echo "Content Object ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
1114  //exit;
1115  break;
1116 
1117  case "cut":
1118 
1119  //echo "Content Object ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
1120  //exit;
1121  break;
1122 
1123  case "copy":
1124 
1125  //var_dump("<pre>",$a_params,"</pre>");
1126  //echo "Content Object ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
1127  //exit;
1128  break;
1129 
1130  case "paste":
1131 
1132  //echo "Content Object ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
1133  //exit;
1134  break;
1135 
1136  case "new":
1137 
1138  //echo "Content Object ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
1139  //exit;
1140  break;
1141  }
1142 
1143  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
1144  if ($a_node_id==$_GET["ref_id"])
1145  {
1146  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1147  $parent_type = $parent_obj->getType();
1148  if($parent_type == $this->getType())
1149  {
1150  $a_node_id = (int) $tree->getParentId($a_node_id);
1151  }
1152  }
1153 
1154  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
1155  }
1156 
1157 
1161  function hasSuccessorPage($a_cont_obj_id, $a_page_id)
1162  {
1163  $tree = new ilTree($a_cont_obj_id);
1164  $tree->setTableNames('lm_tree','lm_data');
1165  $tree->setTreeTablePK("lm_id");
1166  if ($tree->isInTree($a_page_id))
1167  {
1168  $succ = $tree->fetchSuccessorNode($a_page_id, "pg");
1169  if ($succ > 0)
1170  {
1171  return true;
1172  }
1173  }
1174  return false;
1175  }
1176 
1177 
1178  function checkTree()
1179  {
1180  $tree = new ilTree($this->getId());
1181  $tree->setTableNames('lm_tree','lm_data');
1182  $tree->setTreeTablePK("lm_id");
1183  $tree->checkTree();
1184  $tree->checkTreeChilds();
1185 //echo "checked";
1186  }
1187 
1191  function fixTree()
1192  {
1193  global $ilDB;
1194 
1195  $tree =& $this->getLMTree();
1196 
1197  // check numbering, if errors, renumber
1198  // it is very important to keep this step before deleting subtrees
1199  // in the following steps
1200  $set = $ilDB->query("SELECT DISTINCT l1.lm_id".
1201  " FROM lm_tree l1".
1202  " JOIN lm_tree l2 ON ( l1.child = l2.parent".
1203  " AND l1.lm_id = l2.lm_id )".
1204  " JOIN lm_data ON ( l1.child = lm_data.obj_id )".
1205  " WHERE (l2.lft < l1.lft".
1206  " OR l2.rgt > l1.rgt OR l2.lft > l1.rgt OR l2.rgt < l1.lft)".
1207  " AND l1.lm_id = ".$ilDB->quote($this->getId(), "integer").
1208  " ORDER BY lm_data.create_date DESC"
1209  );
1210  if ($rec = $ilDB->fetchAssoc($set))
1211  {
1212  $tree->renumber();
1213  }
1214 
1215  // delete subtrees that have no lm_data records
1216  $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
1217  foreach ($nodes as $node)
1218  {
1219  $q = "SELECT * FROM lm_data WHERE obj_id = ".
1220  $ilDB->quote($node["child"], "integer");
1221  $obj_set = $ilDB->query($q);
1222  $obj_rec = $ilDB->fetchAssoc($obj_set);
1223  if (!$obj_rec)
1224  {
1225  $node_data = $tree->getNodeData($node["child"]);
1226  $tree->deleteTree($node_data);
1227  }
1228  }
1229 
1230  // delete subtrees that have pages as parent
1231  $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
1232  foreach ($nodes as $node)
1233  {
1234  $q = "SELECT * FROM lm_data WHERE obj_id = ".
1235  $ilDB->quote($node["parent"], "integer");
1236  $obj_set = $ilDB->query($q);
1237  $obj_rec = $ilDB->fetchAssoc($obj_set);
1238  if ($obj_rec["type"] == "pg")
1239  {
1240  $node_data = $tree->getNodeData($node["child"]);
1241  if ($tree->isInTree($node["child"]))
1242  {
1243  $tree->deleteTree($node_data);
1244  }
1245  }
1246  }
1247 
1248  // check for multi-references pages or chapters
1249  // if errors -> create copies of them here
1250  $set = $ilDB->query("SELECT DISTINCT l1.lm_id".
1251  " FROM lm_tree l1".
1252  " JOIN lm_tree l2 ON ( l1.child = l2.child AND l1.lm_id <> l2.lm_id )".
1253  " JOIN lm_data ON (l1.child = lm_data.obj_id)".
1254  " WHERE l1.child <> 1".
1255  " AND l1.lm_id <> lm_data.lm_id".
1256  " AND l1.lm_id = ".$ilDB->quote($this->getId(), "integer"));
1257  if ($rec = $ilDB->fetchAssoc($set))
1258  {
1259  $set = $ilDB->query("SELECT DISTINCT l1.child ".
1260  " FROM lm_tree l1".
1261  " JOIN lm_tree l2 ON ( l1.child = l2.child AND l1.lm_id <> l2.lm_id )".
1262  " JOIN lm_data ON (l1.child = lm_data.obj_id)".
1263  " WHERE l1.child <> 1".
1264  " AND l1.lm_id <> lm_data.lm_id".
1265  " AND l1.lm_id = ".$ilDB->quote($this->getId(), "integer"));
1266  include_once("./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
1267  while ($rec = $ilDB->fetchAssoc($set))
1268  {
1269  $cobj = ilLMObjectFactory::getInstance($this, $rec["child"]);
1270 
1271  if (is_object($cobj))
1272  {
1273  if ($cobj->getType() == "pg")
1274  {
1275  // make a copy of it
1276  $pg_copy = $cobj->copy($this);
1277 
1278  // replace the child in the tree with the copy (id)
1279  $ilDB->manipulate("UPDATE lm_tree SET ".
1280  " child = ".$ilDB->quote($pg_copy->getId(), "integer").
1281  " WHERE child = ".$ilDB->quote($cobj->getId(), "integer").
1282  " AND lm_id = ".$ilDB->quote($this->getId(), "integer")
1283  );
1284  }
1285  else if ($cobj->getType() == "st")
1286  {
1287  // make a copy of it
1288  $st_copy = $cobj->copy($this);
1289 
1290  // replace the child in the tree with the copy (id)
1291  $ilDB->manipulate("UPDATE lm_tree SET ".
1292  " child = ".$ilDB->quote($st_copy->getId(), "integer").
1293  " WHERE child = ".$ilDB->quote($cobj->getId(), "integer").
1294  " AND lm_id = ".$ilDB->quote($this->getId(), "integer")
1295  );
1296 
1297  // make all childs refer to the copy now
1298  $ilDB->manipulate("UPDATE lm_tree SET ".
1299  " parent = ".$ilDB->quote($st_copy->getId(), "integer").
1300  " WHERE parent = ".$ilDB->quote($cobj->getId(), "integer").
1301  " AND lm_id = ".$ilDB->quote($this->getId(), "integer")
1302  );
1303  }
1304  }
1305  }
1306  }
1307  }
1308 
1309 
1316  function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
1317  {
1318  global $ilBench;
1319 
1320  $attrs = array();
1321  switch($this->getType())
1322  {
1323  case "lm":
1324  $attrs["Type"] = "LearningModule";
1325  break;
1326 
1327  case "dbk":
1328  $attrs["Type"] = "LibObject";
1329  break;
1330  }
1331  $a_xml_writer->xmlStartTag("ContentObject", $attrs);
1332 
1333  // MetaData
1334  $this->exportXMLMetaData($a_xml_writer);
1335 
1336  // StructureObjects
1337 //echo "ContObj:".$a_inst.":<br>";
1338  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Structure Objects");
1339  $ilBench->start("ContentObjectExport", "exportStructureObjects");
1340  $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
1341  $ilBench->stop("ContentObjectExport", "exportStructureObjects");
1342  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Structure Objects");
1343 
1344  // PageObjects
1345  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Page Objects");
1346  $ilBench->start("ContentObjectExport", "exportPageObjects");
1347  $this->exportXMLPageObjects($a_xml_writer, $a_inst, $expLog);
1348  $ilBench->stop("ContentObjectExport", "exportPageObjects");
1349  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Page Objects");
1350 
1351  // MediaObjects
1352  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
1353  $ilBench->start("ContentObjectExport", "exportMediaObjects");
1354  $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
1355  $ilBench->stop("ContentObjectExport", "exportMediaObjects");
1356  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");
1357 
1358  // FileItems
1359  $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
1360  $ilBench->start("ContentObjectExport", "exportFileItems");
1361  $this->exportFileItems($a_target_dir, $expLog);
1362  $ilBench->stop("ContentObjectExport", "exportFileItems");
1363  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");
1364 
1365  // Questions
1366  if (count($this->q_ids) > 0)
1367  {
1368  $qti_file = fopen($a_target_dir."/qti.xml", "w");
1369  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
1370  $pool = new ilObjQuestionPool();
1371  fwrite($qti_file, $pool->toXML($this->q_ids));
1372  fclose($qti_file);
1373  }
1374 
1375  // To do: implement version selection/detection
1376  // Properties
1377  $expLog->write(date("[y-m-d H:i:s] ")."Start Export Properties");
1378  $this->exportXMLProperties($a_xml_writer, $expLog);
1379  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Properties");
1380 
1381  $a_xml_writer->xmlEndTag("ContentObject");
1382  }
1383 
1390  function exportXMLMetaData(&$a_xml_writer)
1391  {
1392  include_once("Services/MetaData/classes/class.ilMD2XML.php");
1393  $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
1394  $md2xml->setExportMode(true);
1395  $md2xml->startExport();
1396  $a_xml_writer->appendXML($md2xml->getXML());
1397  }
1398 
1405  function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
1406  {
1407  include_once './Modules/LearningModule/classes/class.ilStructureObject.php';
1408 
1409  $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
1410  foreach ($childs as $child)
1411  {
1412  if($child["type"] != "st")
1413  {
1414  continue;
1415  }
1416 
1417  $structure_obj = new ilStructureObject($this, $child["obj_id"]);
1418  $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
1419  unset($structure_obj);
1420  }
1421  }
1422 
1423 
1430  function exportXMLPageObjects(&$a_xml_writer, $a_inst, &$expLog)
1431  {
1432  global $ilBench;
1433 
1434  include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
1435 
1436  $pages = ilLMPageObject::getPageList($this->getId());
1437  foreach ($pages as $page)
1438  {
1439  if (ilPageObject::_exists($this->getType(), $page["obj_id"]))
1440  {
1441  $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$page["obj_id"]);
1442 
1443  // export xml to writer object
1444  $page_obj = new ilLMPageObject($this, $page["obj_id"]);
1445  $page_obj->exportXML($a_xml_writer, "normal", $a_inst);
1446 
1447  // collect media objects
1448  $mob_ids = $page_obj->getMediaObjectIDs();
1449  foreach($mob_ids as $mob_id)
1450  {
1451  $this->mob_ids[$mob_id] = $mob_id;
1452  }
1453 
1454  // collect all file items
1455  $file_ids = $page_obj->getFileItemIds();
1456  foreach($file_ids as $file_id)
1457  {
1458  $this->file_ids[$file_id] = $file_id;
1459  }
1460 
1461  // collect all questions
1462  $q_ids = $page_obj->getQuestionIds();
1463  foreach($q_ids as $q_id)
1464  {
1465  $this->q_ids[$q_id] = $q_id;
1466  }
1467 
1468  unset($page_obj);
1469  }
1470  }
1471  }
1472 
1479  function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
1480  {
1481  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1482 
1483  $linked_mobs = array();
1484 
1485  // mobs directly embedded into pages
1486  foreach ($this->mob_ids as $mob_id)
1487  {
1488  if ($mob_id > 0 && ilObject::_lookupType($mob_id) == "mob")
1489  {
1490  $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
1491  $media_obj = new ilObjMediaObject($mob_id);
1492  $media_obj->exportXML($a_xml_writer, $a_inst);
1493  $media_obj->exportFiles($a_target_dir);
1494 
1495  $lmobs = $media_obj->getLinkedMediaObjects($this->mob_ids);
1496  $linked_mobs = array_merge($linked_mobs, $lmobs);
1497 
1498  unset($media_obj);
1499  }
1500  }
1501 
1502  // linked mobs (in map areas)
1503  foreach ($linked_mobs as $mob_id)
1504  {
1505  if ($mob_id > 0)
1506  {
1507  $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
1508  $media_obj = new ilObjMediaObject($mob_id);
1509  $media_obj->exportXML($a_xml_writer, $a_inst);
1510  $media_obj->exportFiles($a_target_dir);
1511  unset($media_obj);
1512  }
1513  }
1514 
1515  }
1516 
1521  function exportFileItems($a_target_dir, &$expLog)
1522  {
1523  include_once("./Modules/File/classes/class.ilObjFile.php");
1524 
1525  foreach ($this->file_ids as $file_id)
1526  {
1527  $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
1528  $file_obj = new ilObjFile($file_id, false);
1529  $file_obj->export($a_target_dir);
1530  unset($file_obj);
1531  }
1532  }
1533 
1538  function exportXMLProperties($a_xml_writer, &$expLog)
1539  {
1540  $attrs = array();
1541  $a_xml_writer->xmlStartTag("Properties", $attrs);
1542 
1543  // Layout
1544  $attrs = array("Name" => "Layout", "Value" => $this->getLayout());
1545  $a_xml_writer->xmlElement("Property", $attrs);
1546 
1547  // Page Header
1548  $attrs = array("Name" => "PageHeader", "Value" => $this->getPageHeader());
1549  $a_xml_writer->xmlElement("Property", $attrs);
1550 
1551  // TOC Mode
1552  $attrs = array("Name" => "TOCMode", "Value" => $this->getTOCMode());
1553  $a_xml_writer->xmlElement("Property", $attrs);
1554 
1555  // LM Menu Activation
1556  $attrs = array("Name" => "ActiveLMMenu", "Value" =>
1557  ilUtil::tf2yn($this->isActiveLMMenu()));
1558  $a_xml_writer->xmlElement("Property", $attrs);
1559 
1560  // Numbering Activation
1561  $attrs = array("Name" => "ActiveNumbering", "Value" =>
1562  ilUtil::tf2yn($this->isActiveNumbering()));
1563  $a_xml_writer->xmlElement("Property", $attrs);
1564 
1565  // Table of contents button activation
1566  $attrs = array("Name" => "ActiveTOC", "Value" =>
1567  ilUtil::tf2yn($this->isActiveTOC()));
1568  $a_xml_writer->xmlElement("Property", $attrs);
1569 
1570  // Print view button activation
1571  $attrs = array("Name" => "ActivePrintView", "Value" =>
1572  ilUtil::tf2yn($this->isActivePrintView()));
1573  $a_xml_writer->xmlElement("Property", $attrs);
1574 
1575  // Note that download button is not saved, because
1576  // download files do not exist after import
1577 
1578  // Clean frames
1579  $attrs = array("Name" => "CleanFrames", "Value" =>
1580  ilUtil::tf2yn($this->cleanFrames()));
1581  $a_xml_writer->xmlElement("Property", $attrs);
1582 
1583  // Public notes activation
1584  $attrs = array("Name" => "PublicNotes", "Value" =>
1585  ilUtil::tf2yn($this->publicNotes()));
1586  $a_xml_writer->xmlElement("Property", $attrs);
1587 
1588  // History comments for authors activation
1589  $attrs = array("Name" => "HistoryUserComments", "Value" =>
1591  $a_xml_writer->xmlElement("Property", $attrs);
1592 
1593  // Header Page
1594  if ($this->getHeaderPage() > 0)
1595  {
1596  $attrs = array("Name" => "HeaderPage", "Value" =>
1597  "il_".IL_INST_ID."_pg_".$this->getHeaderPage());
1598  $a_xml_writer->xmlElement("Property", $attrs);
1599  }
1600 
1601  // Footer Page
1602  if ($this->getFooterPage() > 0)
1603  {
1604  $attrs = array("Name" => "FooterPage", "Value" =>
1605  "il_".IL_INST_ID."_pg_".$this->getFooterPage());
1606  $a_xml_writer->xmlElement("Property", $attrs);
1607  }
1608 
1609  $a_xml_writer->xmlEndTag("Properties");
1610  }
1611 
1615  function getExportFiles()
1616  {
1617  $file = array();
1618 
1619  $types = array("xml", "html", "scorm");
1620 
1621  foreach ($types as $type)
1622  {
1623  $dir = $this->getExportDirectory($type);
1624  // quit if import dir not available
1625  if (!@is_dir($dir) or
1626  !is_writeable($dir))
1627  {
1628  continue;
1629  }
1630 
1631  // open directory
1632  $cdir = dir($dir);
1633 
1634  // initialize array
1635 
1636  // get files and save the in the array
1637  while ($entry = $cdir->read())
1638  {
1639  if ($entry != "." and
1640  $entry != ".." and
1641  substr($entry, -4) == ".zip" and
1642  ereg("^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.zip\$", $entry))
1643  {
1644  $file[$entry.$type] = array("type" => $type, "file" => $entry,
1645  "size" => filesize($dir."/".$entry));
1646  }
1647  }
1648 
1649  // close import directory
1650  $cdir->close();
1651  }
1652 
1653  // sort files
1654  ksort ($file);
1655  reset ($file);
1656  return $file;
1657  }
1658 
1665  function setPublicExportFile($a_type, $a_file)
1666  {
1667  $this->public_export_file[$a_type] = $a_file;
1668  }
1669 
1677  function getPublicExportFile($a_type)
1678  {
1679  return $this->public_export_file[$a_type];
1680  }
1681 
1685  function getOfflineFiles($dir)
1686  {
1687  // quit if offline dir not available
1688  if (!@is_dir($dir) or
1689  !is_writeable($dir))
1690  {
1691  return array();
1692  }
1693 
1694  // open directory
1695  $dir = dir($dir);
1696 
1697  // initialize array
1698  $file = array();
1699 
1700  // get files and save the in the array
1701  while ($entry = $dir->read())
1702  {
1703  if ($entry != "." and
1704  $entry != ".." and
1705  substr($entry, -4) == ".pdf" and
1706  ereg("^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.pdf\$", $entry))
1707  {
1708  $file[] = $entry;
1709  }
1710  }
1711 
1712  // close import directory
1713  $dir->close();
1714 
1715  // sort files
1716  sort ($file);
1717  reset ($file);
1718 
1719  return $file;
1720  }
1721 
1725  function exportSCORM($a_target_dir, $log)
1726  {
1727  ilUtil::delDir($a_target_dir);
1728  ilUtil::makeDir($a_target_dir);
1729  //ilUtil::makeDir($a_target_dir."/res");
1730 
1731  // export everything to html
1732  $this->exportHTML($a_target_dir."/res", $log, false, "scorm");
1733 
1734  // build manifest file
1735  include("./Modules/LearningModule/classes/class.ilContObjectManifestBuilder.php");
1736  $man_builder = new ilContObjectManifestBuilder($this);
1737  $man_builder->buildManifest();
1738  $man_builder->dump($a_target_dir);
1739 
1740  // copy scorm 1.2 schema definitions
1741  copy("Modules/LearningModule/scorm_xsd/adlcp_rootv1p2.xsd", $a_target_dir."/adlcp_rootv1p2.xsd");
1742  copy("Modules/LearningModule/scorm_xsd/imscp_rootv1p1p2.xsd", $a_target_dir."/imscp_rootv1p1p2.xsd");
1743  copy("Modules/LearningModule/scorm_xsd/imsmd_rootv1p2p1.xsd", $a_target_dir."/imsmd_rootv1p2p1.xsd");
1744  copy("Modules/LearningModule/scorm_xsd/ims_xml.xsd", $a_target_dir."/ims_xml.xsd");
1745 
1746  // zip it all
1747  $date = time();
1748  $zip_file = $a_target_dir."/".$date."__".IL_INST_ID."__".
1749  $this->getType()."_".$this->getId().".zip";
1750  //echo "zip-".$a_target_dir."-to-".$zip_file;
1751  ilUtil::zip(array($a_target_dir."/res",
1752  $a_target_dir."/imsmanifest.xml",
1753  $a_target_dir."/adlcp_rootv1p2.xsd",
1754  $a_target_dir."/imscp_rootv1p1p2.xsd",
1755  $a_target_dir."/ims_xml.xsd",
1756  $a_target_dir."/imsmd_rootv1p2p1.xsd")
1757  , $zip_file);
1758 
1759  $dest_file = $this->getExportDirectory("scorm")."/".$date."__".IL_INST_ID."__".
1760  $this->getType()."_".$this->getId().".zip";
1761 
1762  rename($zip_file, $dest_file);
1763  ilUtil::delDir($a_target_dir);
1764 
1765  }
1766 
1767 
1771  function exportHTML($a_target_dir, $log, $a_zip_file = true, $a_export_format = "html")
1772  {
1773  global $tpl, $ilBench, $ilLocator, $ilUser;
1774 
1775  // initialize temporary target directory
1776  ilUtil::delDir($a_target_dir);
1777  ilUtil::makeDir($a_target_dir);
1778  $mob_dir = $a_target_dir."/mobs";
1779  ilUtil::makeDir($mob_dir);
1780  $file_dir = $a_target_dir."/files";
1781  ilUtil::makeDir($file_dir);
1782  $teximg_dir = $a_target_dir."/teximg";
1783  ilUtil::makeDir($teximg_dir);
1784  $style_dir = $a_target_dir."/style";
1785  ilUtil::makeDir($style_dir);
1786  $style_img_dir = $a_target_dir."/style/images";
1787  ilUtil::makeDir($style_img_dir);
1788  $content_style_dir = $a_target_dir."/content_style";
1789  ilUtil::makeDir($content_style_dir);
1790  $content_style_img_dir = $a_target_dir."/content_style/images";
1791  ilUtil::makeDir($content_style_img_dir);
1792  $GLOBALS["teximgcnt"] = 0;
1793 
1794  // export system style sheet
1795  $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
1796  $style_name = $ilUser->prefs["style"].".css";
1797  copy($location_stylesheet, $style_dir."/".$style_name);
1798  $fh = fopen($location_stylesheet, "r");
1799  $css = fread($fh, filesize($location_stylesheet));
1800  preg_match_all("/url\(([^\)]*)\)/",$css,$files);
1801  foreach (array_unique($files[1]) as $fileref)
1802  {
1803  $fileref = dirname($location_stylesheet)."/".$fileref;
1804  if (is_file($fileref))
1805  {
1806  copy($fileref, $style_img_dir."/".basename($fileref));
1807  }
1808  }
1809  fclose($fh);
1810  $location_stylesheet = ilUtil::getStyleSheetLocation();
1811 
1812  // export content style sheet
1813  $ilBench->start("ExportHTML", "exportContentStyle");
1814  if ($this->getStyleSheetId() < 1)
1815  {
1816  $cont_stylesheet = "./Services/COPage/css/content.css";
1817 
1818  $css = fread(fopen($cont_stylesheet,'r'),filesize($cont_stylesheet));
1819  preg_match_all("/url\(([^\)]*)\)/",$css,$files);
1820  foreach (array_unique($files[1]) as $fileref)
1821  {
1822  if (is_file(str_replace("..", ".", $fileref)))
1823  {
1824  copy(str_replace("..", ".", $fileref), $content_style_img_dir."/".basename($fileref));
1825  }
1826  $css = str_replace($fileref, "images/".basename($fileref),$css);
1827  }
1828  fwrite(fopen($content_style_dir."/content.css",'w'),$css);
1829  }
1830  else
1831  {
1832  $style = new ilObjStyleSheet($this->getStyleSheetId());
1833  $style->writeCSSFile($content_style_dir."/content.css", "images");
1834  $style->copyImagesToDir($content_style_img_dir);
1835  }
1836  $ilBench->stop("ExportHTML", "exportContentStyle");
1837 
1838  // export syntax highlighting style
1839  $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
1840  copy($syn_stylesheet, $a_target_dir."/syntaxhighlight.css");
1841 
1842  // get learning module presentation gui class
1843  include_once("./Modules/LearningModule/classes/class.ilLMPresentationGUI.php");
1844  $_GET["cmd"] = "nop";
1845  $lm_gui =& new ilLMPresentationGUI();
1846  $lm_gui->setOfflineMode(true);
1847  $lm_gui->setOfflineDirectory($a_target_dir);
1848  $lm_gui->setExportFormat($a_export_format);
1849 
1850  // export pages
1851  $ilBench->start("ExportHTML", "exportHTMLPages");
1852  $this->exportHTMLPages($lm_gui, $a_target_dir);
1853  $ilBench->stop("ExportHTML", "exportHTMLPages");
1854 
1855  // export glossary terms
1856  $ilBench->start("ExportHTML", "exportHTMLGlossaryTerms");
1857  $this->exportHTMLGlossaryTerms($lm_gui, $a_target_dir);
1858  $ilBench->stop("ExportHTML", "exportHTMLGlossaryTerms");
1859 
1860  // export all media objects
1861  $ilBench->start("ExportHTML", "exportHTMLMediaObjects");
1862  $linked_mobs = array();
1863  foreach ($this->offline_mobs as $mob)
1864  {
1865  if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob")
1866  {
1867  $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs);
1868  }
1869  }
1870  $linked_mobs2 = array(); // mobs linked in link areas
1871  foreach ($linked_mobs as $mob)
1872  {
1873  if (ilObject::_exists($mob))
1874  {
1875  $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs2);
1876  }
1877  }
1878  $_GET["obj_type"] = "MediaObject";
1879  $_GET["obj_id"] = $a_mob_id;
1880  $_GET["cmd"] = "";
1881  $ilBench->stop("ExportHTML", "exportHTMLMediaObjects");
1882 
1883  // export all file objects
1884  $ilBench->start("ExportHTML", "exportHTMLFileObjects");
1885  foreach ($this->offline_files as $file)
1886  {
1887  $this->exportHTMLFile($a_target_dir, $file);
1888  }
1889  $ilBench->stop("ExportHTML", "exportHTMLFileObjects");
1890 
1891  // export table of contents
1892  $ilBench->start("ExportHTML", "exportHTMLTOC");
1893  $ilLocator->clearItems();
1894  if ($this->isActiveTOC())
1895  {
1896  $tpl = new ilTemplate("tpl.main.html", true, true);
1897  //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
1898  $content =& $lm_gui->showTableOfContents();
1899  $file = $a_target_dir."/table_of_contents.html";
1900 
1901  // open file
1902  if (!($fp = @fopen($file,"w+")))
1903  {
1904  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
1905  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
1906  }
1907  chmod($file, 0770);
1908  fwrite($fp, $content);
1909  fclose($fp);
1910  }
1911  $ilBench->stop("ExportHTML", "exportHTMLTOC");
1912 
1913  // export images
1914  $ilBench->start("ExportHTML", "exportHTMLImages");
1915  $image_dir = $a_target_dir."/images";
1916  ilUtil::makeDir($image_dir);
1917  ilUtil::makeDir($image_dir."/browser");
1918  copy(ilUtil::getImagePath("enlarge.png", false, "filesystem"),
1919  $image_dir."/enlarge.png");
1920  copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
1921  $image_dir."/browser/plus.png");
1922  copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
1923  $image_dir."/browser/minus.png");
1924  copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"),
1925  $image_dir."/browser/blank.png");
1926  copy(ilUtil::getImagePath("spacer.png", false, "filesystem"),
1927  $image_dir."/spacer.png");
1928  copy(ilUtil::getImagePath("icon_st.png", false, "filesystem"),
1929  $image_dir."/icon_st.png");
1930  copy(ilUtil::getImagePath("icon_pg.png", false, "filesystem"),
1931  $image_dir."/icon_pg.png");
1932  copy(ilUtil::getImagePath("icon_st_s.png", false, "filesystem"),
1933  $image_dir."/icon_st_s.png");
1934  copy(ilUtil::getImagePath("icon_pg_s.png", false, "filesystem"),
1935  $image_dir."/icon_pg_s.png");
1936  copy(ilUtil::getImagePath("icon_lm.png", false, "filesystem"),
1937  $image_dir."/icon_lm.png");
1938  copy(ilUtil::getImagePath("icon_lm_s.png", false, "filesystem"),
1939  $image_dir."/icon_lm_s.png");
1940  copy(ilUtil::getImagePath("nav_arr_L.png", false, "filesystem"),
1941  $image_dir."/nav_arr_L.png");
1942  copy(ilUtil::getImagePath("nav_arr_R.png", false, "filesystem"),
1943  $image_dir."/nav_arr_R.png");
1944  copy(ilUtil::getImagePath("browser/forceexp.png", false, "filesystem"),
1945  $image_dir."/browser/forceexp.png");
1946 
1947  copy(ilUtil::getImagePath("download.png", false, "filesystem"),
1948  $image_dir."/download.png");
1949  $ilBench->stop("ExportHTML", "exportHTMLImages");
1950 
1951  // export flv/mp3 player
1952  $services_dir = $a_target_dir."/Services";
1953  ilUtil::makeDir($services_dir);
1954  $media_service_dir = $services_dir."/MediaObjects";
1955  ilUtil::makeDir($media_service_dir);
1956  include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1957  $flv_dir = $a_target_dir."/".ilPlayerUtil::getFlashVideoPlayerDirectory();
1958  ilUtil::makeDir($flv_dir);
1959  $mp3_dir = $media_service_dir."/flash_mp3_player";
1960  ilUtil::makeDir($mp3_dir);
1961 // copy(ilPlayerUtil::getFlashVideoPlayerFilename(true),
1962 // $flv_dir."/".ilPlayerUtil::getFlashVideoPlayerFilename());
1964  copy("./Services/MediaObjects/flash_mp3_player/mp3player.swf",
1965  $mp3_dir."/mp3player.swf");
1966 
1967  // js files
1968  ilUtil::makeDir($a_target_dir.'/js');
1969  ilUtil::makeDir($a_target_dir.'/js/yahoo');
1970  ilUtil::makeDir($a_target_dir.'/css');
1971  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1972  foreach (self::getSupplyingExportFiles($a_target_dir) as $f)
1973  {
1974  if ($f["source"] != "")
1975  {
1976  copy($f["source"], $f["target"]);
1977  }
1978  }
1979 
1980  // template workaround: reset of template
1981  $tpl = new ilTemplate("tpl.main.html", true, true);
1982  $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
1983  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
1984 
1985  // zip everything
1986  $ilBench->start("ExportHTML", "zip");
1987  if (true)
1988  {
1989  if ($a_zip_file)
1990  {
1991  // zip it all
1992  $date = time();
1993  $zip_file = $this->getExportDirectory("html")."/".$date."__".IL_INST_ID."__".
1994  $this->getType()."_".$this->getId().".zip";
1995  ilUtil::zip($a_target_dir, $zip_file);
1996  ilUtil::delDir($a_target_dir);
1997  }
1998  }
1999  $ilBench->stop("ExportHTML", "zip");
2000 
2001  }
2002 
2009  static function getSupplyingExportFiles($a_target_dir = ".")
2010  {
2011  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
2012  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
2013  include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
2014  $scripts = array(
2015  array("source" => ilYuiUtil::getLocalPath('yahoo/yahoo-min.js'),
2016  "target" => $a_target_dir.'/js/yahoo/yahoo-min.js',
2017  "type" => "js"),
2018  array("source" => ilYuiUtil::getLocalPath('yahoo-dom-event/yahoo-dom-event.js'),
2019  "target" => $a_target_dir.'/js/yahoo/yahoo-dom-event.js',
2020  "type" => "js"),
2021  array("source" => ilYuiUtil::getLocalPath('animation/animation-min.js'),
2022  "target" => $a_target_dir.'/js/yahoo/animation-min.js',
2023  "type" => "js"),
2024  array("source" => './Services/JavaScript/js/Basic.js',
2025  "target" => $a_target_dir.'/js/Basic.js',
2026  "type" => "js"),
2027  array("source" => './Services/Accordion/js/accordion.js',
2028  "target" => $a_target_dir.'/js/accordion.js',
2029  "type" => "js"),
2030  array("source" => './Services/Accordion/css/accordion.css',
2031  "target" => $a_target_dir.'/css/accordion.css',
2032  "type" => "css"),
2033  array("source" => iljQueryUtil::getLocaljQueryPath(),
2034  "target" => $a_target_dir.'/js/jquery.js',
2035  "type" => "js"),
2036  array("source" => iljQueryUtil::getLocalMaphilightPath(),
2037  "target" => $a_target_dir.'/js/maphilight.js',
2038  "type" => "js"),
2039  array("source" => iljQueryUtil::getLocaljQueryUIPath(),
2040  "target" => $a_target_dir.'/js/jquery-ui-min.js',
2041  "type" => "js"),
2042  array("source" => './Services/COPage/js/ilCOPagePres.js',
2043  "target" => $a_target_dir.'/js/ilCOPagePres.js',
2044  "type" => "js"),
2045  array("source" => './Modules/Scorm2004/scripts/questions/pure.js',
2046  "target" => $a_target_dir.'/js/pure.js',
2047  "type" => "js"),
2048  array("source" => './Modules/Scorm2004/scripts/questions/question_handling.js',
2049  "target" => $a_target_dir.'/js/question_handling.js',
2050  "type" => "js"),
2051  array("source" => './Modules/Scorm2004/templates/default/question_handling.css',
2052  "target" => $a_target_dir.'/css/question_handling.css',
2053  "type" => "css"),
2054  array("source" => ilPlayerUtil::getLocalMediaElementJsPath(),
2055  "target" => $a_target_dir."/".ilPlayerUtil::getLocalMediaElementJsPath(),
2056  "type" => "js"),
2057  array("source" => ilPlayerUtil::getLocalMediaElementCssPath(),
2058  "target" => $a_target_dir."/".ilPlayerUtil::getLocalMediaElementCssPath(),
2059  "type" => "css")
2060  );
2061 
2062  $mathJaxSetting = new ilSetting("MathJax");
2063  $use_mathjax = $mathJaxSetting->get("enable");
2064  if ($use_mathjax)
2065  {
2066  $scripts[] = array("source" => "",
2067  "target" => $mathJaxSetting->get("path_to_mathjax"),
2068  "type" => "js");
2069  }
2070 
2071  return $scripts;
2072 
2073  }
2074 
2078  function exportHTMLFile($a_target_dir, $a_file_id)
2079  {
2080  $file_dir = $a_target_dir."/files/file_".$a_file_id;
2081  ilUtil::makeDir($file_dir);
2082  include_once("./Modules/File/classes/class.ilObjFile.php");
2083  $file_obj = new ilObjFile($a_file_id, false);
2084  $source_file = $file_obj->getDirectory($file_obj->getVersion())."/".$file_obj->getFileName();
2085  if (!is_file($source_file))
2086  {
2087  $source_file = $file_obj->getDirectory()."/".$file_obj->getFileName();
2088  }
2089  if (is_file($source_file))
2090  {
2091  copy($source_file, $file_dir."/".$file_obj->getFileName());
2092  }
2093  }
2094 
2098  function exportHTMLMOB($a_target_dir, &$a_lm_gui, $a_mob_id, $a_frame, &$a_linked_mobs)
2099  {
2100  global $tpl;
2101 
2102  $mob_dir = $a_target_dir."/mobs";
2103 
2104  $source_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
2105  if (@is_dir($source_dir))
2106  {
2107  ilUtil::makeDir($mob_dir."/mm_".$a_mob_id);
2108  ilUtil::rCopy($source_dir, $mob_dir."/mm_".$a_mob_id);
2109  }
2110 
2111  $tpl = new ilTemplate("tpl.main.html", true, true);
2112  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2113  $_GET["obj_type"] = "MediaObject";
2114  $_GET["mob_id"] = $a_mob_id;
2115  $_GET["frame"] = $a_frame;
2116  $_GET["cmd"] = "";
2117  $content =& $a_lm_gui->media();
2118  $file = $a_target_dir."/media_".$a_mob_id.".html";
2119 
2120  // open file
2121  if (!($fp = @fopen($file,"w+")))
2122  {
2123  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
2124  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
2125  }
2126  chmod($file, 0770);
2127  fwrite($fp, $content);
2128  fclose($fp);
2129 
2130  // fullscreen
2131  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2132  $mob_obj = new ilObjMediaObject($a_mob_id);
2133  if ($mob_obj->hasFullscreenItem())
2134  {
2135  $tpl = new ilTemplate("tpl.main.html", true, true);
2136  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2137  $_GET["obj_type"] = "";
2138  $_GET["frame"] = "";
2139  $_GET["mob_id"] = $a_mob_id;
2140  $_GET["cmd"] = "fullscreen";
2141  $content =& $a_lm_gui->fullscreen();
2142  $file = $a_target_dir."/fullscreen_".$a_mob_id.".html";
2143 
2144  // open file
2145  if (!($fp = @fopen($file,"w+")))
2146  {
2147  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
2148  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
2149  }
2150  chmod($file, 0770);
2151  fwrite($fp, $content);
2152  fclose($fp);
2153  }
2154  $linked_mobs = $mob_obj->getLinkedMediaObjects();
2155  $a_linked_mobs = array_merge($a_linked_mobs, $linked_mobs);
2156  }
2157 
2161  function exportHTMLGlossaryTerms(&$a_lm_gui, $a_target_dir)
2162  {
2163  global $ilLocator;
2164 
2165  foreach($this->offline_int_links as $int_link)
2166  {
2167  $ilLocator->clearItems();
2168  if ($int_link["type"] == "git")
2169  {
2170  $tpl = new ilTemplate("tpl.main.html", true, true);
2171  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2172 
2173  $_GET["obj_id"] = $int_link["id"];
2174  $_GET["frame"] = "_blank";
2175  $content =& $a_lm_gui->glossary();
2176  $file = $a_target_dir."/term_".$int_link["id"].".html";
2177 
2178  // open file
2179  if (!($fp = @fopen($file,"w+")))
2180  {
2181  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
2182  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
2183  }
2184  chmod($file, 0770);
2185  fwrite($fp, $content);
2186  fclose($fp);
2187 
2188  // store linked/embedded media objects of glosssary term
2189  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
2190  $defs = ilGlossaryDefinition::getDefinitionList($int_link["id"]);
2191  foreach($defs as $def)
2192  {
2193  $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
2194  foreach($def_mobs as $def_mob)
2195  {
2196  $this->offline_mobs[$def_mob] = $def_mob;
2197  }
2198 
2199  // get all files of page
2200  $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $page["obj_id"]);
2201  $this->offline_files = array_merge($this->offline_files, $def_files);
2202 
2203  }
2204 
2205  }
2206  }
2207  }
2208 
2212  function exportHTMLPages(&$a_lm_gui, $a_target_dir)
2213  {
2214  global $tpl, $ilBench, $ilLocator;
2215 
2216  $pages = ilLMPageObject::getPageList($this->getId());
2217 
2218  $lm_tree =& $this->getLMTree();
2219  $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg");
2220  $this->first_page_id = $first_page["child"];
2221 
2222  // iterate all learning module pages
2223  $mobs = array();
2224  $int_links = array();
2225  $this->offline_files = array();
2226 
2227  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
2228  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2229 
2230  // get html export id mapping
2231  $lm_set = new ilSetting("lm");
2232  $exp_id_map = array();
2233 
2234  if ($lm_set->get("html_export_ids"))
2235  {
2236  foreach ($pages as $page)
2237  {
2238  $exp_id = ilLMPageObject::getExportId($this->getId(), $page["obj_id"]);
2239  if (trim($exp_id) != "")
2240  {
2241  $exp_id_map[$page["obj_id"]] = trim($exp_id);
2242  }
2243  }
2244  }
2245 //exit;
2246  reset($pages);
2247  foreach ($pages as $page)
2248  {
2249  if (ilPageObject::_exists($this->getType(), $page["obj_id"]))
2250  {
2251  $ilLocator->clearItems();
2252  $ilBench->start("ExportHTML", "exportHTMLPage");
2253  $ilBench->start("ExportHTML", "exportPageHTML");
2254  $this->exportPageHTML($a_lm_gui, $a_target_dir, $page["obj_id"],
2255  "", $exp_id_map);
2256  $ilBench->stop("ExportHTML", "exportPageHTML");
2257 
2258  // get all snippets of page
2259  $pcs = ilPageContentUsage::getUsagesOfPage($page["obj_id"], $this->getType().":pg");
2260  foreach ($pcs as $pc)
2261  {
2262  if ($pc["type"] == "incl")
2263  {
2264  $incl_mobs = ilObjMediaObject::_getMobsOfObject("mep:pg", $pc["id"]);
2265  foreach($incl_mobs as $incl_mob)
2266  {
2267  $mobs[$incl_mob] = $incl_mob;
2268  }
2269  }
2270  }
2271 
2272  // get all media objects of page
2273  $pg_mobs = ilObjMediaObject::_getMobsOfObject($this->getType().":pg", $page["obj_id"]);
2274  foreach($pg_mobs as $pg_mob)
2275  {
2276  $mobs[$pg_mob] = $pg_mob;
2277  }
2278 
2279  // get all internal links of page
2280  $pg_links = ilInternalLink::_getTargetsOfSource($this->getType().":pg", $page["obj_id"]);
2281  $int_links = array_merge($int_links, $pg_links);
2282 
2283  // get all files of page
2284  include_once("./Modules/File/classes/class.ilObjFile.php");
2285  $pg_files = ilObjFile::_getFilesOfObject($this->getType().":pg", $page["obj_id"]);
2286  $this->offline_files = array_merge($this->offline_files, $pg_files);
2287 
2288  $ilBench->stop("ExportHTML", "exportHTMLPage");
2289  }
2290  }
2291  $this->offline_mobs = $mobs;
2292  $this->offline_int_links = $int_links;
2293 
2294 
2295  }
2296 
2297 
2298 
2302  function exportPageHTML(&$a_lm_gui, $a_target_dir, $a_lm_page_id, $a_frame = "",
2303  $a_exp_id_map = array())
2304  {
2305  global $tpl, $ilBench;
2306 
2307 //echo "<br>B: export Page HTML ($a_lm_page_id)"; flush();
2308  // template workaround: reset of template
2309  $tpl = new ilTemplate("tpl.main.html", true, true);
2310  $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
2311 
2312  $_GET["obj_id"] = $a_lm_page_id;
2313  $_GET["frame"] = $a_frame;
2314 
2315  if ($a_frame == "")
2316  {
2317  //if ($nid = ilLMObject::_lookupNID($a_lm_gui->lm->getId(), $a_lm_page_id, "pg"))
2318  if (is_array($a_exp_id_map) && isset($a_exp_id_map[$a_lm_page_id]))
2319  {
2320  $file = $a_target_dir."/lm_pg_".$a_exp_id_map[$a_lm_page_id].".html";
2321  }
2322  else
2323  {
2324  $file = $a_target_dir."/lm_pg_".$a_lm_page_id.".html";
2325  }
2326  }
2327  else
2328  {
2329  if ($a_frame != "toc")
2330  {
2331  $file = $a_target_dir."/frame_".$a_lm_page_id."_".$a_frame.".html";
2332  }
2333  else
2334  {
2335  $file = $a_target_dir."/frame_".$a_frame.".html";
2336  }
2337  }
2338 
2339  // return if file is already existing
2340  if (@is_file($file))
2341  {
2342  return;
2343  }
2344 
2345  $ilBench->start("ExportHTML", "layout");
2346  $ilBench->start("ExportHTML", "layout_".$a_frame);
2347  $content =& $a_lm_gui->layout("main.xml", false);
2348  $ilBench->stop("ExportHTML", "layout_".$a_frame);
2349  $ilBench->stop("ExportHTML", "layout");
2350 
2351  // open file
2352  if (!($fp = @fopen($file,"w+")))
2353  {
2354  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
2355  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
2356  }
2357 
2358  // set file permissions
2359  chmod($file, 0770);
2360 
2361  // write xml data into the file
2362  fwrite($fp, $content);
2363 
2364  // close file
2365  fclose($fp);
2366 
2367  if ($this->first_page_id == $a_lm_page_id && $a_frame == "")
2368  {
2369  copy($file, $a_target_dir."/index.html");
2370  }
2371 
2372  // write frames of frameset
2373  $ilBench->start("ExportHTML", "getCurrentFrameSet");
2374  $frameset = $a_lm_gui->getCurrentFrameSet();
2375  $ilBench->stop("ExportHTML", "getCurrentFrameSet");
2376 
2377  foreach ($frameset as $frame)
2378  {
2379  $this->exportPageHTML($a_lm_gui, $a_target_dir, $a_lm_page_id, $frame);
2380  }
2381 
2382  }
2383 
2390  function exportFO(&$a_xml_writer, $a_target_dir)
2391  {
2392  global $ilBench;
2393 
2394  // fo:root (start)
2395  $attrs = array();
2396  $attrs["xmlns:fo"] = "http://www.w3.org/1999/XSL/Format";
2397  $a_xml_writer->xmlStartTag("fo:root", $attrs);
2398 
2399  // fo:layout-master-set (start)
2400  $attrs = array();
2401  $a_xml_writer->xmlStartTag("fo:layout-master-set", $attrs);
2402 
2403  // fo:simple-page-master (start)
2404  $attrs = array();
2405  $attrs["master-name"] = "DinA4";
2406  $attrs["page-height"] = "29.7cm";
2407  $attrs["page-width"] = "21cm";
2408  $attrs["margin-top"] = "4cm";
2409  $attrs["margin-bottom"] = "1cm";
2410  $attrs["margin-left"] = "2.8cm";
2411  $attrs["margin-right"] = "7.3cm";
2412  $a_xml_writer->xmlStartTag("fo:simple-page-master", $attrs);
2413 
2414  // fo:region-body (complete)
2415  $attrs = array();
2416  $attrs["margin-top"] = "0cm";
2417  $attrs["margin-bottom"] = "1.25cm";
2418  $a_xml_writer->xmlElement("fo:region-body", $attrs);
2419 
2420  // fo:region-before (complete)
2421  $attrs = array();
2422  $attrs["extent"] = "1cm";
2423  $a_xml_writer->xmlElement("fo:region-before", $attrs);
2424 
2425  // fo:region-after (complete)
2426  $attrs = array();
2427  $attrs["extent"] = "1cm";
2428  $a_xml_writer->xmlElement("fo:region-after", $attrs);
2429 
2430  // fo:simple-page-master (end)
2431  $a_xml_writer->xmlEndTag("fo:simple-page-master");
2432 
2433  // fo:layout-master-set (end)
2434  $a_xml_writer->xmlEndTag("fo:layout-master-set");
2435 
2436  // fo:page-sequence (start)
2437  $attrs = array();
2438  $attrs["master-reference"] = "DinA4";
2439  $a_xml_writer->xmlStartTag("fo:page-sequence", $attrs);
2440 
2441  // fo:flow (start)
2442  $attrs = array();
2443  $attrs["flow-name"] = "xsl-region-body";
2444  $a_xml_writer->xmlStartTag("fo:flow", $attrs);
2445 
2446 
2447  // StructureObjects
2448  //$expLog->write(date("[y-m-d H:i:s] ")."Start Export Structure Objects");
2449  $ilBench->start("ContentObjectExport", "exportFOStructureObjects");
2450  $this->exportFOStructureObjects($a_xml_writer, $expLog);
2451  $ilBench->stop("ContentObjectExport", "exportFOStructureObjects");
2452  //$expLog->write(date("[y-m-d H:i:s] ")."Finished Export Structure Objects");*/
2453 
2454  // fo:flow (end)
2455  $a_xml_writer->xmlEndTag("fo:flow");
2456 
2457  // fo:page-sequence (end)
2458  $a_xml_writer->xmlEndTag("fo:page-sequence");
2459 
2460  // fo:root (end)
2461  $a_xml_writer->xmlEndTag("fo:root");
2462  }
2463 
2470  function exportFOStructureObjects(&$a_xml_writer)
2471  {
2472  $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
2473  foreach ($childs as $child)
2474  {
2475  if($child["type"] != "st")
2476  {
2477  continue;
2478  }
2479 
2480  $structure_obj = new ilStructureObject($this, $child["obj_id"]);
2481  $structure_obj->exportFO($a_xml_writer, $expLog);
2482  unset($structure_obj);
2483  }
2484  }
2485 
2486  function getXMLZip()
2487  {
2488  include_once("./Modules/LearningModule/classes/class.ilContObjectExport.php");
2489 
2490  $cont_exp = new ilContObjectExport($this,'xml');
2491 
2492  $export_file = $cont_exp->buildExportFile();
2493  return $export_file;
2494  }
2495 
2504  function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
2505  {
2506  $lmtree = new ilTree($this->getId());
2507  $lmtree->setTableNames('lm_tree','lm_data');
2508  $lmtree->setTreeTablePK("lm_id");
2509 //echo "-".$source_id."-".$target_id."-".$first_child."-".$as_subitem."-";
2510  $source_obj = ilLMObjectFactory::getInstance($this, $source_id, true);
2511  $source_obj->setLMId($this->getId());
2512 
2513  if (!$first_child)
2514  {
2515  $target_obj = ilLMObjectFactory::getInstance($this, $target_id, true);
2516  $target_obj->setLMId($this->getId());
2517  $target_parent = $lmtree->getParentId($target_id);
2518  }
2519 
2520  // handle pages
2521  if ($source_obj->getType() == "pg")
2522  {
2523 //echo "1";
2524  if ($lmtree->isInTree($source_obj->getId()))
2525  {
2526  $node_data = $lmtree->getNodeData($source_obj->getId());
2527 
2528  // cut on move
2529  if ($movecopy == "move")
2530  {
2531  $parent_id = $lmtree->getParentId($source_obj->getId());
2532  $lmtree->deleteTree($node_data);
2533 
2534  // write history entry
2535  require_once("./Services/History/classes/class.ilHistory.php");
2536  ilHistory::_createEntry($source_obj->getId(), "cut",
2537  array(ilLMObject::_lookupTitle($parent_id), $parent_id),
2538  $this->getType().":pg");
2539  ilHistory::_createEntry($parent_id, "cut_page",
2540  array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()),
2541  $this->getType().":st");
2542  }
2543  else
2544  {
2545  // copy page
2546  $new_page =& $source_obj->copy();
2547  $source_id = $new_page->getId();
2548  $source_obj =& $new_page;
2549  }
2550 
2551  // paste page
2552  if(!$lmtree->isInTree($source_obj->getId()))
2553  {
2554  if ($first_child) // as first child
2555  {
2556  $target_pos = IL_FIRST_NODE;
2557  $parent = $target_id;
2558  }
2559  else if ($as_subitem) // as last child
2560  {
2561  $parent = $target_id;
2562  $target_pos = IL_FIRST_NODE;
2563  $pg_childs =& $lmtree->getChildsByType($parent, "pg");
2564  if (count($pg_childs) != 0)
2565  {
2566  $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
2567  }
2568  }
2569  else // at position
2570  {
2571  $target_pos = $target_id;
2572  $parent = $target_parent;
2573  }
2574 
2575  // insert page into tree
2576  $lmtree->insertNode($source_obj->getId(),
2577  $parent, $target_pos);
2578 
2579  // write history entry
2580  if ($movecopy == "move")
2581  {
2582  // write history comments
2583  include_once("./Services/History/classes/class.ilHistory.php");
2584  ilHistory::_createEntry($source_obj->getId(), "paste",
2585  array(ilLMObject::_lookupTitle($parent), $parent),
2586  $this->getType().":pg");
2587  ilHistory::_createEntry($parent, "paste_page",
2588  array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()),
2589  $this->getType().":st");
2590  }
2591 
2592  }
2593  }
2594  }
2595 
2596  // handle chapters
2597  if ($source_obj->getType() == "st")
2598  {
2599 //echo "2";
2600  $source_node = $lmtree->getNodeData($source_id);
2601  $subnodes = $lmtree->getSubtree($source_node);
2602 
2603  // check, if target is within subtree
2604  foreach ($subnodes as $subnode)
2605  {
2606  if($subnode["obj_id"] == $target_id)
2607  {
2608  return;
2609  }
2610  }
2611 
2612  $target_pos = $target_id;
2613 
2614  if ($first_child) // as first subchapter
2615  {
2616  $target_pos = IL_FIRST_NODE;
2617  $target_parent = $target_id;
2618 
2619  $pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
2620  if (count($pg_childs) != 0)
2621  {
2622  $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
2623  }
2624  }
2625  else if ($as_subitem) // as last subchapter
2626  {
2627  $target_parent = $target_id;
2628  $target_pos = IL_FIRST_NODE;
2629  $childs =& $lmtree->getChilds($target_parent);
2630  if (count($childs) != 0)
2631  {
2632  $target_pos = $childs[count($childs) - 1]["obj_id"];
2633  }
2634  }
2635 
2636  // insert into
2637 /*
2638  if ($position == "into")
2639  {
2640  $target_parent = $target_id;
2641  $target_pos = IL_FIRST_NODE;
2642 
2643  // if target_pos is still first node we must skip all pages
2644  if ($target_pos == IL_FIRST_NODE)
2645  {
2646  $pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
2647  if (count($pg_childs) != 0)
2648  {
2649  $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
2650  }
2651  }
2652  }
2653 */
2654 
2655 
2656  // delete source tree
2657  if ($movecopy == "move")
2658  {
2659  $lmtree->deleteTree($source_node);
2660  }
2661  else
2662  {
2663  // copy chapter (incl. subcontents)
2664  $new_chapter =& $source_obj->copy($lmtree, $target_parent, $target_pos);
2665  }
2666 
2667  if (!$lmtree->isInTree($source_id))
2668  {
2669  $lmtree->insertNode($source_id, $target_parent, $target_pos);
2670 
2671  // insert moved tree
2672  if ($movecopy == "move")
2673  {
2674  foreach ($subnodes as $node)
2675  {
2676  if($node["obj_id"] != $source_id)
2677  {
2678  $lmtree->insertNode($node["obj_id"], $node["parent"]);
2679  }
2680  }
2681  }
2682  }
2683 
2684  // check the tree
2685  $this->checkTree();
2686  }
2687 
2688  $this->checkTree();
2689  }
2690 
2694  function validatePages()
2695  {
2696  include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
2697  include_once "./Services/COPage/classes/class.ilPageObject.php";
2698 
2699  $mess = "";
2700 
2701  $pages = ilLMPageObject::getPageList($this->getId());
2702  foreach ($pages as $page)
2703  {
2704  if (ilPageObject::_exists($this->getType(), $page["obj_id"]))
2705  {
2706  $cpage = new ilPageObject($this->getType(), $page["obj_id"]);
2707  $cpage->buildDom();
2708  $error = @$cpage->validateDom();
2709 
2710  if ($error != "")
2711  {
2712  $this->lng->loadLanguageModule("content");
2713  ilUtil::sendInfo($this->lng->txt("cont_import_validation_errors"));
2714  $title = ilLMObject::_lookupTitle($page["obj_id"]);
2715  $page_obj = new ilLMPageObject($this, $page["obj_id"]);
2716  $mess.= $this->lng->txt("obj_pg").": ".$title;
2717  $mess.= '<div class="small">';
2718  foreach ($error as $e)
2719  {
2720  $err_mess = implode($e, " - ");
2721  if (!is_int(strpos($err_mess, ":0:")))
2722  {
2723  $mess.= htmlentities($err_mess)."<br />";
2724  }
2725  }
2726  $mess.= '</div>';
2727  $mess.= "<br />";
2728  }
2729  }
2730  }
2731 
2732  return $mess;
2733  }
2734 
2741  function importFromZipFile($a_tmp_file, $a_filename, $a_validate = true,
2742  $a_import_into_help_module = 0)
2743  {
2744  global $lng;
2745 
2746  // create import directory
2747  $this->createImportDirectory();
2748 
2749  // copy uploaded file to import directory
2750  $file = pathinfo($a_filename);
2751  $full_path = $this->getImportDirectory()."/".$a_filename;
2752 
2753  ilUtil::moveUploadedFile($a_tmp_file,
2754  $a_filename, $full_path);
2755 
2756  // unzip file
2757  ilUtil::unzip($full_path);
2758 
2759  $subdir = basename($file["basename"],".".$file["extension"]);
2760 
2761  $mess = $this->importFromDirectory(
2762  $this->getImportDirectory()."/".$subdir, $a_validate);
2763 
2764  // this should only be true for help modules
2765  if ($a_import_into_help_module > 0)
2766  {
2767  // search the zip file
2768  $dir = $this->getImportDirectory()."/".$subdir;
2769  $files = ilUtil::getDir($dir);
2770  foreach ($files as $file)
2771  {
2772  if (is_int(strpos($file["entry"], "__help_")) &&
2773  is_int(strpos($file["entry"], ".zip")))
2774  {
2775  include_once("./Services/Export/classes/class.ilImport.php");
2776  $imp = new ilImport();
2777  $imp->getMapping()->addMapping('Services/Help', 'help_module', 0, $a_import_into_help_module);
2778  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
2779  $chaps = ilLMObject::getObjectList($this->getId(), "st");
2780  foreach ($chaps as $chap)
2781  {
2782  $chap_arr = explode("_", $chap["import_id"]);
2783  $imp->getMapping()->addMapping('Services/Help', 'help_chap',
2784  $chap_arr[count($chap_arr) - 1], $chap["obj_id"]);
2785  }
2786  $imp->importEntity($dir."/".$file["entry"], $file["entry"],
2787  "help", "Services/Help", true);
2788  }
2789  }
2790  }
2791 
2792  // delete import directory
2794 
2795  return $mess;
2796  }
2797 
2798 
2805  function importFromDirectory($a_directory, $a_validate = true)
2806  {
2807  global $lng;
2808 
2809  // determine filename of xml file
2810  $subdir = basename($a_directory);
2811  $xml_file = $a_directory."/".$subdir.".xml";
2812 
2813  // check directory exists within zip file
2814  if (!is_dir($a_directory))
2815  {
2816  return sprintf($lng->txt("cont_no_subdir_in_zip"), $subdir);
2817  }
2818 
2819  // check whether xml file exists within zip file
2820  if (!is_file($xml_file))
2821  {
2822  return sprintf($lng->txt("cont_zip_file_invalid"), $subdir."/".$subdir.".xml");
2823  }
2824 
2825  // import questions
2826  $qti_file = $a_directory."/qti.xml";
2827  $qtis = array();
2828  if (is_file($qti_file))
2829  {
2830  include_once "./Services/QTI/classes/class.ilQTIParser.php";
2831  include_once("./Modules/Test/classes/class.ilObjTest.php");
2832  $qtiParser = new ilQTIParser ($qti_file,
2833  IL_MO_VERIFY_QTI, 0, "");
2834  $result = $qtiParser->startParsing ();
2835  $founditems = & $qtiParser->getFoundItems ();
2836  $testObj = new ilObjTest(0, true);
2837  if (count($founditems) > 0)
2838  {
2839  $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, 0, "");
2840  $qtiParser->setTestObject($testObj);
2841  $result = $qtiParser->startParsing();
2842  $qtis = array_merge($qtis, $qtiParser->getImportMapping());
2843  }
2844  }
2845 
2846  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
2847  $contParser = new ilContObjParser($this, $xml_file, $subdir, $qmapping);
2848  $contParser->setQuestionMapping($qtis);
2849  $contParser->startParsing();
2850  ilObject::_writeImportId($this->getId(), $this->getImportId());
2851  $this->MDUpdateListener('General');
2852 
2853  // import style
2854  $style_file = $a_directory."/style.xml";
2855  $style_zip_file = $a_directory."/style.zip";
2856  if (is_file($style_zip_file)) // try to import style.zip first
2857  {
2858  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
2859  $style = new ilObjStyleSheet();
2860  $style->import($style_zip_file);
2861  $this->writeStyleSheetId($style->getId());
2862  }
2863  else if (is_file($style_file)) // try to import style.xml
2864  {
2865  require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
2866  $style = new ilObjStyleSheet();
2867  $style->import($style_file);
2868  $this->writeStyleSheetId($style->getId());
2869  }
2870 
2871 // // validate
2872  if ($a_validate)
2873  {
2874  $mess = $this->validatePages();
2875  }
2876 
2877  if ($mess == "")
2878  {
2879  // handle internal links to this learning module
2880  include_once("./Services/COPage/classes/class.ilPageObject.php");
2882  $this->getType(), $this->getRefId());
2883  }
2884 
2885  return $mess;
2886  }
2887 
2896  public function cloneObject($a_target_id,$a_copy_id = 0)
2897  {
2898  global $ilDB, $ilUser, $ilias;
2899 
2900  $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
2901  $this->cloneMetaData($new_obj);
2902  //$new_obj->createProperties();
2903 
2904  $new_obj->setTitle($this->getTitle());
2905  $new_obj->setDescription($this->getDescription());
2906  $new_obj->setLayoutPerPage($this->getLayoutPerPage());
2907  $new_obj->setLayout($this->getLayout());
2908  $new_obj->setTOCMode($this->getTOCMode());
2909  $new_obj->setActiveLMMenu($this->isActiveLMMenu());
2910  $new_obj->setActiveTOC($this->isActiveTOC());
2911  $new_obj->setActiveNumbering($this->isActiveNumbering());
2912  $new_obj->setActivePrintView($this->isActivePrintView());
2913  $new_obj->setActivePreventGlossaryAppendix($this->isActivePreventGlossaryAppendix());
2914  $new_obj->setActiveDownloads($this->isActiveDownloads());
2915  $new_obj->setActiveDownloadsPublic($this->isActiveDownloadsPublic());
2916  $new_obj->setPublicNotes($this->publicNotes());
2917  $new_obj->setCleanFrames($this->cleanFrames());
2918  $new_obj->setHistoryUserComments($this->isActiveHistoryUserComments());
2919  $new_obj->setPublicAccessMode($this->getPublicAccessMode());
2920  $new_obj->setPageHeader($this->getPageHeader());
2921 
2922  $new_obj->update();
2923 
2924  $new_obj->createLMTree();
2925 
2926  // copy style
2927  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
2928  $style_id = $this->getStyleSheetId();
2929  if ($style_id > 0 &&
2931  {
2932  $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
2933  $new_id = $style_obj->ilClone();
2934  $new_obj->setStyleSheetId($new_id);
2935  $new_obj->update();
2936  }
2937 
2938  // copy content
2939  $this->copyAllPagesAndChapters($new_obj);
2940 
2941  // Copy learning progress settings
2942  include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
2943  $obj_settings = new ilLPObjSettings($this->getId());
2944  $obj_settings->cloneSettings($new_obj->getId());
2945  unset($obj_settings);
2946 
2947 
2948  return $new_obj;
2949  }
2950 
2956  function copyAllPagesAndChapters($a_target_obj)
2957  {
2958  $parent_id = $a_target_obj->lm_tree->readRootId();
2959 
2960  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
2961  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
2962 
2963  // get all chapters of root lm
2964  $chapters = $this->lm_tree->getChildsByType($this->lm_tree->readRootId(), "st");
2965  $copied_nodes = array();
2966  //$time = time();
2967  foreach ($chapters as $chap)
2968  {
2969  $cid = ilLMObject::pasteTree($a_target_obj, $chap["child"], $parent_id,
2970  IL_LAST_NODE, $time, $copied_nodes, true, $this);
2971  $target = $cid;
2972  }
2973 
2974  // copy free pages
2975  $pages = ilLMPageObject::getPageList($this->getId());
2976  foreach ($pages as $p)
2977  {
2978  if (!$this->lm_tree->isInTree($p["obj_id"]))
2979  {
2980  $item = new ilLMPageObject($this, $p["obj_id"]);
2981  $target_item = $item->copy($a_target_obj);
2982  $copied_nodes[$item->getId()] = $target_item->getId();
2983  }
2984  }
2985 
2986  ilLMObject::updateInternalLinks($copied_nodes);
2987 
2988  $a_target_obj->checkTree();
2989 
2990  }
2991 
2995 
3001  static function isOnlineHelpModule($a_ref_id)
3002  {
3003  if ($a_ref_id > 0 && $a_ref_id == OH_REF_ID)
3004  {
3005  return true;
3006  }
3007  return false;
3008  }
3009 
3010 }
3011 ?>