00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00037 require_once "classes/class.ilObject.php";
00038 require_once "classes/class.ilMetaData.php";
00039 require_once("classes/class.ilNestedSetXML.php");
00040
00041
00042 class ilObjContentObject extends ilObject
00043 {
00044 var $lm_tree;
00045 var $meta_data;
00046 var $layout;
00047 var $style_id;
00048 var $pg_header;
00049 var $online;
00050
00057 function ilObjContentObject($a_id = 0,$a_call_by_reference = true)
00058 {
00059
00060 $this->ilObject($a_id,$a_call_by_reference);
00061
00062 $this->mob_ids = array();
00063 $this->file_ids = array();
00064 }
00065
00069 function create($a_upload = false)
00070 {
00071 global $ilUser;
00072
00073 parent::create();
00074
00075
00076
00077 if (!$a_upload)
00078 {
00079 $this->createMetaData();
00080 }
00081
00082 $this->createProperties();
00083 if (!$a_upload)
00084 {
00085 if (is_object($ilUser))
00086 {
00087
00088 }
00089 }
00090 }
00091
00098 function initDefaultRoles()
00099 {
00100 return array();
00101
00102 global $rbacadmin, $rbacreview;
00103
00104
00105 $rfoldObj = $this->createRoleFolder("Local roles","Role Folder of content object ".$this->getId());
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 unset($rfoldObj);
00123
00124
00125 return $roles ? $roles : array();
00126 }
00127
00128
00132 function read()
00133 {
00134 parent::read();
00135 # echo "Content<br>\n";
00136
00137 $this->lm_tree = new ilTree($this->getId());
00138 $this->lm_tree->setTableNames('lm_tree','lm_data');
00139 $this->lm_tree->setTreeTablePK("lm_id");
00140
00141 $this->readProperties();
00142
00143 }
00144
00150 function getTitle()
00151 {
00152 return parent::getTitle();
00153 }
00154
00158 function setTitle($a_title)
00159 {
00160 parent::setTitle($a_title);
00161
00162 }
00163
00169 function getDescription()
00170 {
00171 return parent::getDescription();
00172 }
00173
00177 function setDescription($a_description)
00178 {
00179 parent::setDescription($a_description);
00180
00181 }
00182
00183
00184 function getImportId()
00185 {
00186 return $this->import_id;
00187 }
00188
00189 function setImportId($a_id)
00190 {
00191 $this->import_id = $a_id;
00192 }
00193
00194 function &getTree()
00195 {
00196 return $this->lm_tree;
00197 }
00198
00202 function update()
00203 {
00204 $this->updateMetaData();
00205 parent::update();
00206 $this->updateProperties();
00207 }
00208
00209
00213 function import()
00214 {
00215
00216 return;
00217 }
00218
00219
00224 function putInTree($a_parent)
00225 {
00226 global $tree;
00227
00228
00229 parent::putInTree($a_parent);
00230
00231
00232
00233 }
00234
00235
00241 function createLMTree()
00242 {
00243 $this->lm_tree =& new ilTree($this->getId());
00244 $this->lm_tree->setTreeTablePK("lm_id");
00245 $this->lm_tree->setTableNames('lm_tree','lm_data');
00246 $this->lm_tree->addTree($this->getId(), 1);
00247 }
00248
00249
00253 function &getLMTree()
00254 {
00255 return $this->lm_tree;
00256 }
00257
00258
00264 function createImportDirectory()
00265 {
00266 $lm_data_dir = ilUtil::getDataDir()."/lm_data";
00267 if(!is_writable($lm_data_dir))
00268 {
00269 $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir
00270 .") not writeable.",$this->ilias->error_obj->FATAL);
00271 }
00272
00273
00274 $lm_dir = $lm_data_dir."/lm_".$this->getId();
00275 ilUtil::makeDir($lm_dir);
00276 if(!@is_dir($lm_dir))
00277 {
00278 $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
00279 }
00280
00281
00282 $import_dir = $lm_dir."/import";
00283 ilUtil::makeDir($import_dir);
00284 if(!@is_dir($import_dir))
00285 {
00286 $this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
00287 }
00288 }
00289
00293 function getDataDirectory()
00294 {
00295 return ilUtil::getDataDir()."/lm_data".
00296 "/lm_".$this->getId();
00297 }
00298
00302 function getImportDirectory()
00303 {
00304 $import_dir = ilUtil::getDataDir()."/lm_data".
00305 "/lm_".$this->getId()."/import";
00306 if(@is_dir($import_dir))
00307 {
00308 return $import_dir;
00309 }
00310 else
00311 {
00312 return false;
00313 }
00314 }
00315
00316
00322 function createExportDirectory($a_type = "xml")
00323 {
00324 $lm_data_dir = ilUtil::getDataDir()."/lm_data";
00325 if(!is_writable($lm_data_dir))
00326 {
00327 $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir
00328 .") not writeable.",$this->ilias->error_obj->FATAL);
00329 }
00330
00331 $lm_dir = $lm_data_dir."/lm_".$this->getId();
00332 ilUtil::makeDir($lm_dir);
00333 if(!@is_dir($lm_dir))
00334 {
00335 $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
00336 }
00337
00338 switch ($a_type)
00339 {
00340
00341 case "html":
00342 $export_dir = $lm_dir."/export_html";
00343 break;
00344
00345
00346 case "scorm":
00347 $export_dir = $lm_dir."/export_scorm";
00348 break;
00349
00350 default:
00351 $export_dir = $lm_dir."/export";
00352 break;
00353 }
00354 ilUtil::makeDir($export_dir);
00355
00356 if(!@is_dir($export_dir))
00357 {
00358 $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
00359 }
00360 }
00361
00365 function getExportDirectory($a_type = "xml")
00366 {
00367 switch ($a_type)
00368 {
00369 case "html":
00370 $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export_html";
00371 break;
00372
00373 case "scorm":
00374 $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export_scorm";
00375 break;
00376
00377 default:
00378 $export_dir = ilUtil::getDataDir()."/lm_data"."/lm_".$this->getId()."/export";
00379 break;
00380 }
00381 return $export_dir;
00382 }
00383
00390 function ilClone($a_parent_ref)
00391 {
00392 global $rbacadmin;
00393
00394
00395 $new_ref_id = parent::ilClone($a_parent_ref);
00396
00397
00398
00399
00400 return $new_ref_id;
00401 }
00402
00413 function delete()
00414 {
00415 global $ilDB;
00416
00417 global $ilBench;
00418
00419
00420 if (!parent::delete())
00421 {
00422 return false;
00423 }
00424
00425
00426 include_once("content/classes/class.ilLMObject.php");
00427 ilLMObject::_deleteAllObjectData($this);
00428
00429
00430 $this->deleteMetaData();
00431
00432
00433 $nested = new ilNestedSetXML();
00434 $nested->init($this->getId(), "bib");
00435 $nested->deleteAllDBData();
00436
00437
00438
00439 $this->lm_tree->removeTree($this->lm_tree->getTreeId());
00440
00441
00442 ilUtil::delDir($this->getDataDirectory());
00443
00444
00445 $q = "DELETE FROM content_object WHERE id = ".$ilDB->quote($this->getId());
00446 $this->ilias->db->query($q);
00447
00448
00449 $q = "DELETE FROM lm_menu WHERE lm_id = ".$ilDB->quote($this->getId());
00450 $this->ilias->db->query($q);
00451
00452 return true;
00453 }
00454
00455
00461 function getLayout()
00462 {
00463 return $this->layout;
00464 }
00465
00471 function setLayout($a_layout)
00472 {
00473 $this->layout = $a_layout;
00474 }
00475
00479 function getStyleSheetId()
00480 {
00481 return $this->style_id;
00482 }
00483
00487 function setStyleSheetId($a_style_id)
00488 {
00489 $this->style_id = $a_style_id;
00490 }
00491
00495 function writeStyleSheetId($a_style_id)
00496 {
00497 global $ilDB;
00498
00499 $q = "UPDATE content_object SET ".
00500 " stylesheet = ".$ilDB->quote($a_style_id).
00501 " WHERE id = '".$this->getId()."'";
00502 $ilDB->query($q);
00503
00504 $this->style_id = $a_style_id;
00505 }
00506
00510 function _lookupStyleSheetId($a_cont_obj_id)
00511 {
00512 global $ilDB;
00513
00514 $q = "SELECT stylesheet FROM content_object ".
00515 " WHERE id = '".$a_cont_obj_id."'";
00516 $res = $ilDB->query($q);
00517 $sheet = $res->fetchRow(DB_FETCHMODE_ASSOC);
00518
00519 return $sheet["stylesheet"];
00520 }
00521
00522
00528 function _deleteStyleAssignments($a_style_id)
00529 {
00530 global $ilDB;
00531
00532 $q = "UPDATE content_object SET ".
00533 " stylesheet = ".$ilDB->quote("0").
00534 " WHERE stylesheet = ".$this->getId($a_style_id);
00535
00536 $ilDB->query($q);
00537 }
00538
00542 function getPageHeader()
00543 {
00544 return $this->pg_header;
00545 }
00546
00552 function setPageHeader($a_pg_header = IL_CHAPTER_TITLE)
00553 {
00554 $this->pg_header = $a_pg_header;
00555 }
00556
00560 function getTOCMode()
00561 {
00562 return $this->toc_mode;
00563 }
00564
00568 function getPublicAccessMode()
00569 {
00570 return $this->public_access_mode;
00571 }
00572
00578 function setTOCMode($a_toc_mode = "chapters")
00579 {
00580 $this->toc_mode = $a_toc_mode;
00581 }
00582
00583 function setOnline($a_online)
00584 {
00585 $this->online = $a_online;
00586 }
00587
00588 function getOnline()
00589 {
00590 return $this->online;
00591 }
00592
00593 function setActiveLMMenu($a_act_lm_menu)
00594 {
00595 $this->lm_menu_active = $a_act_lm_menu;
00596 }
00597
00598 function isActiveLMMenu()
00599 {
00600 return $this->lm_menu_active;
00601 }
00602
00603 function setActiveTOC($a_toc)
00604 {
00605 $this->toc_active = $a_toc;
00606 }
00607
00608 function isActiveTOC()
00609 {
00610 return $this->toc_active;
00611 }
00612
00613 function setActiveNumbering($a_num)
00614 {
00615 $this->numbering = $a_num;
00616 }
00617
00618 function isActiveNumbering()
00619 {
00620 return $this->numbering;
00621 }
00622
00623 function setActivePrintView($a_print)
00624 {
00625 $this->print_view_active = $a_print;
00626 }
00627
00628 function isActivePrintView()
00629 {
00630 return $this->print_view_active;
00631 }
00632
00633 function setActiveDownloads($a_down)
00634 {
00635 $this->downloads_active = $a_down;
00636 }
00637
00638 function isActiveDownloads()
00639 {
00640 return $this->downloads_active;
00641 }
00642
00643 function setCleanFrames($a_clean)
00644 {
00645 $this->clean_frames = $a_clean;
00646 }
00647
00648 function cleanFrames()
00649 {
00650 return $this->clean_frames;
00651 }
00652
00653 function setHistoryUserComments($a_comm)
00654 {
00655 $this->user_comments = $a_comm;
00656 }
00657
00658 function setPublicAccessMode($a_mode)
00659 {
00660 $this->public_access_mode = $a_mode;
00661 }
00662
00663 function isActiveHistoryUserComments()
00664 {
00665 return $this->user_comments;
00666 }
00667
00671 function readProperties()
00672 {
00673 $q = "SELECT * FROM content_object WHERE id = '".$this->getId()."'";
00674 $lm_set = $this->ilias->db->query($q);
00675 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00676 $this->setLayout($lm_rec["default_layout"]);
00677 $this->setStyleSheetId($lm_rec["stylesheet"]);
00678 $this->setPageHeader($lm_rec["page_header"]);
00679 $this->setTOCMode($lm_rec["toc_mode"]);
00680 $this->setOnline(ilUtil::yn2tf($lm_rec["online"]));
00681 $this->setActiveTOC(ilUtil::yn2tf($lm_rec["toc_active"]));
00682 $this->setActiveNumbering(ilUtil::yn2tf($lm_rec["numbering"]));
00683 $this->setActivePrintView(ilUtil::yn2tf($lm_rec["print_view_active"]));
00684 $this->setActiveDownloads(ilUtil::yn2tf($lm_rec["downloads_active"]));
00685 $this->setActiveLMMenu(ilUtil::yn2tf($lm_rec["lm_menu_active"]));
00686 $this->setCleanFrames(ilUtil::yn2tf($lm_rec["clean_frames"]));
00687 $this->setHistoryUserComments(ilUtil::yn2tf($lm_rec["hist_user_comments"]));
00688 $this->setPublicAccessMode($lm_rec["public_access_mode"]);
00689 $this->setPublicExportFile("xml", $lm_rec["public_xml_file"]);
00690 $this->setPublicExportFile("html", $lm_rec["public_html_file"]);
00691 }
00692
00696 function updateProperties()
00697 {
00698 $q = "UPDATE content_object SET ".
00699 " default_layout = '".$this->getLayout()."', ".
00700 " stylesheet = '".$this->getStyleSheetId()."',".
00701 " page_header = '".$this->getPageHeader()."',".
00702 " toc_mode = '".$this->getTOCMode()."',".
00703 " online = '".ilUtil::tf2yn($this->getOnline())."',".
00704 " toc_active = '".ilUtil::tf2yn($this->isActiveTOC())."',".
00705 " numbering = '".ilUtil::tf2yn($this->isActiveNumbering())."',".
00706 " print_view_active = '".ilUtil::tf2yn($this->isActivePrintView())."',".
00707 " downloads_active = '".ilUtil::tf2yn($this->isActiveDownloads())."',".
00708 " clean_frames = '".ilUtil::tf2yn($this->cleanFrames())."',".
00709 " hist_user_comments = '".ilUtil::tf2yn($this->isActiveHistoryUserComments())."',".
00710 " public_access_mode = '".$this->getPublicAccessMode()."',".
00711 " public_xml_file = '".$this->getPublicExportFile("xml")."',".
00712 " public_html_file = '".$this->getPublicExportFile("html")."',".
00713 " lm_menu_active = '".ilUtil::tf2yn($this->isActiveLMMenu())."'".
00714 " WHERE id = '".$this->getId()."'";
00715 $this->ilias->db->query($q);
00716 }
00717
00721 function createProperties()
00722 {
00723 $q = "INSERT INTO content_object (id) VALUES ('".$this->getId()."')";
00724 $this->ilias->db->query($q);
00725 $this->readProperties();
00726 }
00727
00731 function _lookupOnline($a_id)
00732 {
00733
00734
00735 $q = "SELECT * FROM content_object WHERE id = '".$a_id."'";
00736 $lm_set = $this->ilias->db->query($q);
00737 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00738
00739 return ilUtil::yn2tf($lm_rec["online"]);
00740 }
00741
00747 function getAvailableLayouts()
00748 {
00749
00750 $dir = opendir("./layouts/lm");
00751
00752 $layouts = array();
00753
00754 while($file = readdir($dir))
00755 {
00756 if ($file != "." && $file != ".." && $file != "CVS")
00757 {
00758
00759 if (@is_dir("./layouts/lm/".$file))
00760 {
00761 $layouts[$file] = $file;
00762 }
00763 }
00764 }
00765 asort($layouts);
00766 return $layouts;
00767 }
00768
00772 function _checkPreconditionsOfPage($cont_obj_id, $page_id)
00773 {
00774 global $ilias,$ilUser,$ilErr;
00775
00776 $lm_tree = new ilTree($cont_obj_id);
00777 $lm_tree->setTableNames('lm_tree','lm_data');
00778 $lm_tree->setTreeTablePK("lm_id");
00779
00780 if ($lm_tree->isInTree($page_id))
00781 {
00782 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
00783 foreach ($path as $node)
00784 {
00785 if ($node["type"] == "st")
00786 {
00787 if (!ilConditionHandler::_checkAllConditionsOfTarget($node["child"], "st"))
00788 {
00789 return false;
00790 }
00791 }
00792 }
00793 }
00794
00795 return true;
00796 }
00797
00801 function _getMissingPreconditionsOfPage($cont_obj_id, $page_id)
00802 {
00803 $lm_tree = new ilTree($cont_obj_id);
00804 $lm_tree->setTableNames('lm_tree','lm_data');
00805 $lm_tree->setTreeTablePK("lm_id");
00806
00807 $conds = array();
00808 if ($lm_tree->isInTree($page_id))
00809 {
00810
00811 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
00812 foreach ($path as $node)
00813 {
00814 if ($node["type"] == "st")
00815 {
00816
00817 $tconds = ilConditionHandler::_getConditionsOfTarget($node["child"], "st");
00818 foreach ($tconds as $tcond)
00819 {
00820
00821 if (!ilConditionHandler::_checkCondition($tcond["id"]))
00822 {
00823 $conds[] = $tcond;
00824 }
00825 }
00826 }
00827 }
00828 }
00829
00830 return $conds;
00831 }
00832
00836 function _getMissingPreconditionsTopChapter($cont_obj_id, $page_id)
00837 {
00838 $lm_tree = new ilTree($cont_obj_id);
00839 $lm_tree->setTableNames('lm_tree','lm_data');
00840 $lm_tree->setTreeTablePK("lm_id");
00841
00842 $conds = array();
00843 if ($lm_tree->isInTree($page_id))
00844 {
00845
00846 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
00847 foreach ($path as $node)
00848 {
00849 if ($node["type"] == "st")
00850 {
00851
00852 $tconds = ilConditionHandler::_getConditionsOfTarget($node["child"], "st");
00853 foreach ($tconds as $tcond)
00854 {
00855
00856 if (!ilConditionHandler::_checkCondition($tcond["id"]))
00857 {
00858 return $node["child"];
00859 }
00860 }
00861 }
00862 }
00863 }
00864
00865 return "";
00866 }
00867
00878 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00879 {
00880 global $tree;
00881
00882 switch ($a_event)
00883 {
00884 case "link":
00885
00886
00887
00888
00889 break;
00890
00891 case "cut":
00892
00893
00894
00895 break;
00896
00897 case "copy":
00898
00899
00900
00901
00902 break;
00903
00904 case "paste":
00905
00906
00907
00908 break;
00909
00910 case "new":
00911
00912
00913
00914 break;
00915 }
00916
00917
00918 if ($a_node_id==$_GET["ref_id"])
00919 {
00920 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00921 $parent_type = $parent_obj->getType();
00922 if($parent_type == $this->getType())
00923 {
00924 $a_node_id = (int) $tree->getParentId($a_node_id);
00925 }
00926 }
00927
00928 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00929 }
00930
00938 function _search(&$search_obj,$a_search_in)
00939 {
00940 global $ilBench;
00941
00942 switch($a_search_in)
00943 {
00944 case 'meta':
00945
00946 $in = $search_obj->getInStatement("r.ref_id");
00947 $where = $search_obj->getWhereCondition("fulltext",array("xv.tag_value"));
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959 $query1 = "SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
00960 "xmlnestedset AS xm,xmlvalue AS xv ".
00961 $where.
00962 $in.
00963 "AND r.obj_id=o.obj_id AND ( ".
00964 "(o.obj_id=xm.ns_book_fk AND xm.ns_type IN ('lm','bib'))) ".
00965 "AND xm.ns_tag_fk=xv.tag_fk ".
00966 "AND o.type= 'lm'";
00967
00968
00969 $query1 = "SELECT DISTINCT(r.ref_id) as ref_id FROM xmlvalue AS xv ".
00970 "LEFT JOIN xmlnestedset AS xm ON xm.ns_tag_fk=xv.tag_fk ".
00971 "LEFT JOIN object_data AS o ON o.obj_id = xm.ns_book_fk ".
00972 "LEFT JOIN object_reference AS r ON o.obj_id = r.obj_id ".
00973 $where.
00974 $in.
00975 " AND o.type = 'lm' AND xm.ns_type IN ('lm','bib')";
00976
00977 $query2 = "SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
00978 "lm_data AS l,xmlnestedset AS xm,xmlvalue AS xv ".
00979 $where.
00980 $in.
00981 "AND r.obj_id=o.obj_id AND ((o.obj_id=l.lm_id AND xm.ns_book_fk=l.obj_id)".
00982 ") ".
00983 "AND xm.ns_tag_fk=xv.tag_fk ".
00984 "AND o.type= 'lm'";
00985
00986 $query2 = "SELECT DISTINCT(r.ref_id) as ref_id FROM xmlvalue AS xv ".
00987 "LEFT JOIN xmlnestedset AS xm ON xm.ns_tag_fk = xv.tag_fk ".
00988 "LEFT JOIN lm_data AS l ON l.obj_id = xm.ns_book_fk ".
00989 "LEFT JOIN object_data AS o ON o.obj_id = l.lm_id ".
00990 "LEFT JOIN object_reference AS r ON r.obj_id = o.obj_id ".
00991 $where.
00992 $in.
00993 "AND o.type = 'lm'";
00994
00995 $ilBench->start("Search", "ilObjContentObject_search_meta");
00996 $res1 = $search_obj->ilias->db->query($query1);
00997 $res2 = $search_obj->ilias->db->query($query2);
00998 $ilBench->stop("Search", "ilObjContentObject_search_meta");
00999
01000 $counter = 0;
01001 $ids = array();
01002 while($row = $res1->fetchRow(DB_FETCHMODE_OBJECT))
01003 {
01004 $ids[] = $row->ref_id;
01005 $result[$counter]["id"] = $row->ref_id;
01006 ++$counter;
01007 }
01008 while($row = $res2->fetchRow(DB_FETCHMODE_OBJECT))
01009 {
01010 if(in_array($row->ref_id,$ids))
01011 {
01012 continue;
01013 }
01014 $result[$counter]["id"] = $row->ref_id;
01015 ++$counter;
01016 }
01017 break;
01018
01019 case 'content':
01020 $in = $search_obj->getInStatement("r.ref_id");
01021 $where = $search_obj->getWhereCondition("fulltext",array("pg.content"));
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031 $query = "SELECT DISTINCT(r.ref_id) AS ref_id ,pg.page_id AS page_id FROM page_object AS pg ".
01032 ", object_reference AS r ".
01033 $where.
01034 " AND pg.parent_id = r.obj_id ".
01035 $in.
01036 " AND pg.parent_type = 'lm' ";
01037
01038 $query = "SELECT DISTINCT(r.ref_id) AS ref_id ,pg.page_id AS page_id FROM page_object AS pg ".
01039 "LEFT JOIN object_data AS o ON o.obj_id = pg.parent_id ".
01040 "LEFT JOIN object_reference AS r ON o.obj_id = r.obj_id ".
01041 $where.
01042 $in.
01043 " AND pg.parent_type = 'lm'";
01044
01045 $ilBench->start("Search", "ilObjContentObject_search_content");
01046 $res = $search_obj->ilias->db->query($query);
01047 $ilBench->stop("Search", "ilObjContentObject_search_content");
01048
01049 $counter = 0;
01050 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
01051 {
01052 $result[$counter]["id"] = $row->ref_id;
01053 $result[$counter]["page_id"] = $row->page_id;
01054
01055
01056
01057
01058 ++$counter;
01059 }
01060 break;
01061 }
01062 return $result ? $result : array();
01063 }
01064
01075 function _getLinkToObject($a_ref_id,$a_type,$a_obj_id = 0)
01076 {
01077 switch($a_type)
01078 {
01079 case "content":
01080 return array("content/lm_presentation.php?ref_id=".$a_ref_id."&obj_id=".$a_obj_id,"_blank");
01081
01082 case "meta":
01083 return array("content/lm_presentation.php?ref_id=".$a_ref_id,"_blank");
01084 }
01085 }
01086
01092 function _goto($a_target)
01093 {
01094 global $rbacsystem, $ilErr, $lng;
01095
01096 include_once 'classes/class.ilSearch.php';
01097
01098
01099
01100 if ($rbacsystem->checkAccess("read", $a_target) and ilSearch::_checkParentConditions($a_target))
01101 {
01102 ilUtil::redirect("content/lm_presentation.php?ref_id=$a_target");
01103 }
01104 else
01105 {
01106 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
01107 }
01108 }
01109
01113 function hasSuccessorPage($a_cont_obj_id, $a_page_id)
01114 {
01115 $tree = new ilTree($a_cont_obj_id);
01116 $tree->setTableNames('lm_tree','lm_data');
01117 $tree->setTreeTablePK("lm_id");
01118 if ($tree->isInTree($a_page_id))
01119 {
01120 $succ = $tree->fetchSuccessorNode($a_page_id, "pg");
01121 if ($succ > 0)
01122 {
01123 return true;
01124 }
01125 }
01126 return false;
01127 }
01128
01129
01130 function checkTree()
01131 {
01132 $tree = new ilTree($this->getId());
01133 $tree->setTableNames('lm_tree','lm_data');
01134 $tree->setTreeTablePK("lm_id");
01135 $tree->checkTree();
01136 $tree->checkTreeChilds();
01137
01138 }
01139
01143 function fixTree()
01144 {
01145 global $ilDB;
01146
01147 $tree =& $this->getLMTree();
01148
01149
01150 $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
01151 foreach ($nodes as $node)
01152 {
01153 $q = "SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($node["child"]);
01154 $obj_set = $ilDB->query($q);
01155 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
01156 if (!$obj_rec)
01157 {
01158 $node_data = $tree->getNodeData($node["child"]);
01159 $tree->deleteTree($node_data);
01160 }
01161 }
01162
01163
01164 $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
01165 foreach ($nodes as $node)
01166 {
01167 $q = "SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($node["parent"]);
01168 $obj_set = $ilDB->query($q);
01169 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
01170 if ($obj_rec["type"] == "pg")
01171 {
01172 $node_data = $tree->getNodeData($node["child"]);
01173 if ($tree->isInTree($node["child"]))
01174 {
01175 $tree->deleteTree($node_data);
01176 }
01177 }
01178 }
01179
01180 }
01181
01182
01189 function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
01190 {
01191 global $ilBench;
01192
01193 $attrs = array();
01194 switch($this->getType())
01195 {
01196 case "lm":
01197 $attrs["Type"] = "LearningModule";
01198 break;
01199
01200 case "dbk":
01201 $attrs["Type"] = "LibObject";
01202 break;
01203 }
01204 $a_xml_writer->xmlStartTag("ContentObject", $attrs);
01205
01206
01207 $this->exportXMLMetaData($a_xml_writer);
01208
01209
01210
01211 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Structure Objects");
01212 $ilBench->start("ContentObjectExport", "exportStructureObjects");
01213 $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
01214 $ilBench->stop("ContentObjectExport", "exportStructureObjects");
01215 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Structure Objects");
01216
01217
01218 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Page Objects");
01219 $ilBench->start("ContentObjectExport", "exportPageObjects");
01220 $this->exportXMLPageObjects($a_xml_writer, $a_inst, $expLog);
01221 $ilBench->stop("ContentObjectExport", "exportPageObjects");
01222 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Page Objects");
01223
01224
01225 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
01226 $ilBench->start("ContentObjectExport", "exportMediaObjects");
01227 $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
01228 $ilBench->stop("ContentObjectExport", "exportMediaObjects");
01229 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");
01230
01231
01232 $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
01233 $ilBench->start("ContentObjectExport", "exportFileItems");
01234 $this->exportFileItems($a_target_dir, $expLog);
01235 $ilBench->stop("ContentObjectExport", "exportFileItems");
01236 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");
01237
01238
01239
01240 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Properties");
01241 $this->exportXMLProperties($a_xml_writer, $expLog);
01242 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Properties");
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253 $a_xml_writer->xmlEndTag("ContentObject");
01254 }
01255
01262 function exportXMLMetaData(&$a_xml_writer)
01263 {
01264 include_once("Services/MetaData/classes/class.ilMD2XML.php");
01265 $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
01266 $md2xml->setExportMode(true);
01267 $md2xml->startExport();
01268 $a_xml_writer->appendXML($md2xml->getXML());
01269 }
01270
01277 function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
01278 {
01279 include_once './content/classes/class.ilStructureObject.php';
01280
01281 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
01282 foreach ($childs as $child)
01283 {
01284 if($child["type"] != "st")
01285 {
01286 continue;
01287 }
01288
01289 $structure_obj = new ilStructureObject($this, $child["obj_id"]);
01290 $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
01291 unset($structure_obj);
01292 }
01293 }
01294
01295
01302 function exportXMLPageObjects(&$a_xml_writer, $a_inst, &$expLog)
01303 {
01304 global $ilBench;
01305
01306 include_once "./content/classes/class.ilLMPageObject.php";
01307
01308 $pages = ilLMPageObject::getPageList($this->getId());
01309 foreach ($pages as $page)
01310 {
01311 $ilBench->start("ContentObjectExport", "exportPageObject");
01312 $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$page["obj_id"]);
01313
01314
01315 $ilBench->start("ContentObjectExport", "exportPageObject_getLMPageObject");
01316 $page_obj = new ilLMPageObject($this, $page["obj_id"]);
01317 $ilBench->stop("ContentObjectExport", "exportPageObject_getLMPageObject");
01318 $ilBench->start("ContentObjectExport", "exportPageObject_XML");
01319 $page_obj->exportXML($a_xml_writer, "normal", $a_inst);
01320 $ilBench->stop("ContentObjectExport", "exportPageObject_XML");
01321
01322
01323 $ilBench->start("ContentObjectExport", "exportPageObject_CollectMedia");
01324 $mob_ids = $page_obj->getMediaObjectIDs();
01325 foreach($mob_ids as $mob_id)
01326 {
01327 $this->mob_ids[$mob_id] = $mob_id;
01328 }
01329 $ilBench->stop("ContentObjectExport", "exportPageObject_CollectMedia");
01330
01331
01332 $ilBench->start("ContentObjectExport", "exportPageObject_CollectFileItems");
01333 $file_ids = $page_obj->getFileItemIds();
01334 foreach($file_ids as $file_id)
01335 {
01336 $this->file_ids[$file_id] = $file_id;
01337 }
01338 $ilBench->stop("ContentObjectExport", "exportPageObject_CollectFileItems");
01339
01340 unset($page_obj);
01341
01342 $ilBench->stop("ContentObjectExport", "exportPageObject");
01343 }
01344 }
01345
01352 function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
01353 {
01354 include_once("content/classes/Media/class.ilObjMediaObject.php");
01355
01356 foreach ($this->mob_ids as $mob_id)
01357 {
01358 $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
01359 $media_obj = new ilObjMediaObject($mob_id);
01360 $media_obj->exportXML($a_xml_writer, $a_inst);
01361 $media_obj->exportFiles($a_target_dir);
01362 unset($media_obj);
01363 }
01364 }
01365
01370 function exportFileItems($a_target_dir, &$expLog)
01371 {
01372 include_once("classes/class.ilObjFile.php");
01373
01374 foreach ($this->file_ids as $file_id)
01375 {
01376 $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
01377 $file_obj = new ilObjFile($file_id, false);
01378 $file_obj->export($a_target_dir);
01379 unset($file_obj);
01380 }
01381 }
01382
01387 function exportXMLProperties($a_xml_writer, &$expLog)
01388 {
01389 $attrs = array();
01390 $a_xml_writer->xmlStartTag("Properties", $attrs);
01391
01392
01393 $attrs = array("Name" => "Layout", "Value" => $this->getLayout());
01394 $a_xml_writer->xmlElement("Property", $attrs);
01395
01396
01397 $attrs = array("Name" => "PageHeader", "Value" => $this->getPageHeader());
01398 $a_xml_writer->xmlElement("Property", $attrs);
01399
01400
01401 $attrs = array("Name" => "TOCMode", "Value" => $this->getTOCMode());
01402 $a_xml_writer->xmlElement("Property", $attrs);
01403
01404
01405 $attrs = array("Name" => "ActiveLMMenu", "Value" =>
01406 ilUtil::tf2yn($this->isActiveLMMenu()));
01407 $a_xml_writer->xmlElement("Property", $attrs);
01408
01409
01410 $attrs = array("Name" => "ActiveNumbering", "Value" =>
01411 ilUtil::tf2yn($this->isActiveNumbering()));
01412 $a_xml_writer->xmlElement("Property", $attrs);
01413
01414
01415 $attrs = array("Name" => "ActiveTOC", "Value" =>
01416 ilUtil::tf2yn($this->isActiveTOC()));
01417 $a_xml_writer->xmlElement("Property", $attrs);
01418
01419
01420 $attrs = array("Name" => "ActivePrintView", "Value" =>
01421 ilUtil::tf2yn($this->isActivePrintView()));
01422 $a_xml_writer->xmlElement("Property", $attrs);
01423
01424
01425
01426
01427
01428 $attrs = array("Name" => "CleanFrames", "Value" =>
01429 ilUtil::tf2yn($this->cleanFrames()));
01430 $a_xml_writer->xmlElement("Property", $attrs);
01431
01432
01433 $attrs = array("Name" => "HistoryUserComments", "Value" =>
01434 ilUtil::tf2yn($this->isActiveHistoryUserComments()));
01435 $a_xml_writer->xmlElement("Property", $attrs);
01436
01437 $a_xml_writer->xmlEndTag("Properties");
01438 }
01439
01443 function getExportFiles()
01444 {
01445 $file = array();
01446
01447 $types = array("xml", "html", "scorm");
01448
01449 foreach ($types as $type)
01450 {
01451 $dir = $this->getExportDirectory($type);
01452
01453 if (!@is_dir($dir) or
01454 !is_writeable($dir))
01455 {
01456 continue;
01457 }
01458
01459
01460 $cdir = dir($dir);
01461
01462
01463
01464
01465 while ($entry = $cdir->read())
01466 {
01467 if ($entry != "." and
01468 $entry != ".." and
01469 substr($entry, -4) == ".zip" and
01470 ereg("^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.zip\$", $entry))
01471 {
01472 $file[$entry.$type] = array("type" => $type, "file" => $entry,
01473 "size" => filesize($dir."/".$entry));
01474 }
01475 }
01476
01477
01478 $cdir->close();
01479 }
01480
01481
01482 ksort ($file);
01483 reset ($file);
01484 return $file;
01485 }
01486
01493 function setPublicExportFile($a_type, $a_file)
01494 {
01495 $this->public_export_file[$a_type] = $a_file;
01496 }
01497
01505 function getPublicExportFile($a_type)
01506 {
01507 return $this->public_export_file[$a_type];
01508 }
01509
01513 function getOfflineFiles($dir)
01514 {
01515
01516 if (!@is_dir($dir) or
01517 !is_writeable($dir))
01518 {
01519 return array();
01520 }
01521
01522
01523 $dir = dir($dir);
01524
01525
01526 $file = array();
01527
01528
01529 while ($entry = $dir->read())
01530 {
01531 if ($entry != "." and
01532 $entry != ".." and
01533 substr($entry, -4) == ".pdf" and
01534 ereg("^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.pdf\$", $entry))
01535 {
01536 $file[] = $entry;
01537 }
01538 }
01539
01540
01541 $dir->close();
01542
01543
01544 sort ($file);
01545 reset ($file);
01546
01547 return $file;
01548 }
01549
01553 function exportSCORM($a_target_dir, $log)
01554 {
01555 ilUtil::delDir($a_target_dir);
01556 ilUtil::makeDir($a_target_dir);
01557
01558
01559
01560 $this->exportHTML($a_target_dir."/res", $log, false, "scorm");
01561
01562
01563 include("content/classes/class.ilContObjectManifestBuilder.php");
01564 $man_builder = new ilContObjectManifestBuilder($this);
01565 $man_builder->buildManifest();
01566 $man_builder->dump($a_target_dir);
01567
01568
01569 copy("content/scorm_xsd/adlcp_rootv1p2.xsd", $a_target_dir."/adlcp_rootv1p2.xsd");
01570 copy("content/scorm_xsd/imscp_rootv1p1p2.xsd", $a_target_dir."/imscp_rootv1p1p2.xsd");
01571 copy("content/scorm_xsd/imsmd_rootv1p2p1.xsd", $a_target_dir."/imsmd_rootv1p2p1.xsd");
01572 copy("content/scorm_xsd/ims_xml.xsd", $a_target_dir."/ims_xml.xsd");
01573
01574
01575 $date = time();
01576 $zip_file = $a_target_dir."/".$date."__".IL_INST_ID."__".
01577 $this->getType()."_".$this->getId().".zip";
01578
01579 ilUtil::zip(array($a_target_dir."/res",
01580 $a_target_dir."/imsmanifest.xml",
01581 $a_target_dir."/adlcp_rootv1p2.xsd",
01582 $a_target_dir."/imscp_rootv1p1p2.xsd",
01583 $a_target_dir."/ims_xml.xsd",
01584 $a_target_dir."/imsmd_rootv1p2p1.xsd")
01585 , $zip_file);
01586
01587 $dest_file = $this->getExportDirectory("scorm")."/".$date."__".IL_INST_ID."__".
01588 $this->getType()."_".$this->getId().".zip";
01589
01590 rename($zip_file, $dest_file);
01591 ilUtil::delDir($a_target_dir);
01592
01593 }
01594
01595
01599 function exportHTML($a_target_dir, $log, $a_zip_file = true, $a_export_format = "html")
01600 {
01601 global $ilias, $tpl;
01602
01603
01604 ilUtil::delDir($a_target_dir);
01605 ilUtil::makeDir($a_target_dir);
01606 $mob_dir = $a_target_dir."/mobs";
01607 ilUtil::makeDir($mob_dir);
01608 $file_dir = $a_target_dir."/files";
01609 ilUtil::makeDir($file_dir);
01610
01611
01612 $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
01613 $style_name = $ilias->account->prefs["style"].".css";
01614 copy($location_stylesheet, $a_target_dir."/".$style_name);
01615 $location_stylesheet = ilUtil::getStyleSheetLocation();
01616
01617
01618 if ($this->getStyleSheetId() < 1)
01619 {
01620 $cont_stylesheet = "content/content.css";
01621 copy($cont_stylesheet, $a_target_dir."/content.css");
01622 }
01623 else
01624 {
01625 $style = new ilObjStyleSheet($this->getStyleSheetId());
01626 $style->writeCSSFile($a_target_dir."/content.css");
01627 }
01628
01629
01630 $syn_stylesheet = "content/syntaxhighlight.css";
01631 copy($syn_stylesheet, $a_target_dir."/syntaxhighlight.css");
01632
01633
01634 include_once("content/classes/class.ilLMPresentationGUI.php");
01635 $_GET["cmd"] = "nop";
01636 $lm_gui =& new ilLMPresentationGUI();
01637 $lm_gui->setOfflineMode(true);
01638 $lm_gui->setOfflineDirectory($a_target_dir);
01639 $lm_gui->setExportFormat($a_export_format);
01640
01641
01642 $this->exportHTMLPages($lm_gui, $a_target_dir);
01643
01644
01645 $this->exportHTMLGlossaryTerms($lm_gui, $a_target_dir);
01646
01647
01648 foreach ($this->offline_mobs as $mob)
01649 {
01650 $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_new");
01651 }
01652 $_GET["obj_type"] = "MediaObject";
01653 $_GET["obj_id"] = $a_mob_id;
01654 $_GET["cmd"] = "";
01655
01656
01657 foreach ($this->offline_files as $file)
01658 {
01659 $this->exportHTMLFile($a_target_dir, $file);
01660 }
01661
01662
01663 if ($this->isActiveTOC())
01664 {
01665 $tpl = new ilTemplate("tpl.main.html", true, true);
01666
01667 $content =& $lm_gui->showTableOfContents();
01668 $file = $a_target_dir."/table_of_contents.html";
01669
01670
01671 if (!($fp = @fopen($file,"w+")))
01672 {
01673 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01674 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01675 }
01676 chmod($file, 0770);
01677 fwrite($fp, $content);
01678 fclose($fp);
01679 }
01680
01681
01682 $image_dir = $a_target_dir."/images";
01683 ilUtil::makeDir($image_dir);
01684 ilUtil::makeDir($image_dir."/browser");
01685 copy(ilUtil::getImagePath("enlarge.gif", false, "filesystem"),
01686 $image_dir."/enlarge.gif");
01687 copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
01688 $image_dir."/browser/plus.gif");
01689 copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
01690 $image_dir."/browser/minus.gif");
01691 copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
01692 $image_dir."/browser/blank.gif");
01693 copy(ilUtil::getImagePath("icon_st.gif", false, "filesystem"),
01694 $image_dir."/icon_st.gif");
01695 copy(ilUtil::getImagePath("icon_pg.gif", false, "filesystem"),
01696 $image_dir."/icon_pg.gif");
01697 copy(ilUtil::getImagePath("nav_arr_L.gif", false, "filesystem"),
01698 $image_dir."/nav_arr_L.gif");
01699 copy(ilUtil::getImagePath("nav_arr_R.gif", false, "filesystem"),
01700 $image_dir."/nav_arr_R.gif");
01701
01702 copy(ilUtil::getImagePath("download.gif", false, "filesystem"),
01703 $image_dir."/download.gif");
01704
01705
01706 $tpl = new ilTemplate("tpl.main.html", true, true);
01707 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
01708 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01709
01710
01711 if ($a_zip_file)
01712 {
01713
01714 $date = time();
01715 $zip_file = $this->getExportDirectory("html")."/".$date."__".IL_INST_ID."__".
01716 $this->getType()."_".$this->getId().".zip";
01717
01718 ilUtil::zip($a_target_dir, $zip_file);
01719 ilUtil::delDir($a_target_dir);
01720 }
01721 }
01722
01726 function exportHTMLFile($a_target_dir, $a_file_id)
01727 {
01728 $file_dir = $a_target_dir."/files/file_".$a_file_id;
01729 ilUtil::makeDir($file_dir);
01730 include_once("classes/class.ilObjFile.php");
01731 $file_obj = new ilObjFile($a_file_id, false);
01732 $source_file = $file_obj->getDirectory($file_obj->getVersion())."/".$file_obj->getFileName();
01733 if (!is_file($source_file))
01734 {
01735 $source_file = $file_obj->getDirectory()."/".$file_obj->getFileName();
01736 }
01737 copy($source_file, $file_dir."/".$file_obj->getFileName());
01738 }
01739
01743 function exportHTMLMOB($a_target_dir, &$a_lm_gui, $a_mob_id, $a_frame = "")
01744 {
01745 global $tpl;
01746
01747 $mob_dir = $a_target_dir."/mobs";
01748
01749 $source_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
01750 if (@is_dir($source_dir))
01751 {
01752 ilUtil::makeDir($mob_dir."/mm_".$a_mob_id);
01753 ilUtil::rCopy($source_dir, $mob_dir."/mm_".$a_mob_id);
01754 }
01755
01756 $tpl = new ilTemplate("tpl.main.html", true, true);
01757 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01758 $_GET["obj_type"] = "MediaObject";
01759 $_GET["mob_id"] = $a_mob_id;
01760 $_GET["frame"] = $a_frame;
01761 $_GET["cmd"] = "";
01762 $content =& $a_lm_gui->media();
01763 $file = $a_target_dir."/media_".$a_mob_id.".html";
01764
01765
01766 if (!($fp = @fopen($file,"w+")))
01767 {
01768 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01769 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01770 }
01771 chmod($file, 0770);
01772 fwrite($fp, $content);
01773 fclose($fp);
01774
01775
01776 include_once("content/classes/Media/class.ilObjMediaObject.php");
01777 $mob_obj = new ilObjMediaObject($a_mob_id);
01778 if ($mob_obj->hasFullscreenItem())
01779 {
01780 $tpl = new ilTemplate("tpl.main.html", true, true);
01781 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01782 $_GET["obj_type"] = "";
01783 $_GET["frame"] = "";
01784 $_GET["mob_id"] = $a_mob_id;
01785 $_GET["cmd"] = "fullscreen";
01786 $content =& $a_lm_gui->fullscreen();
01787 $file = $a_target_dir."/fullscreen_".$a_mob_id.".html";
01788
01789
01790 if (!($fp = @fopen($file,"w+")))
01791 {
01792 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01793 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01794 }
01795 chmod($file, 0770);
01796 fwrite($fp, $content);
01797 fclose($fp);
01798 }
01799 }
01800
01804 function exportHTMLGlossaryTerms(&$a_lm_gui, $a_target_dir)
01805 {
01806 foreach($this->offline_int_links as $int_link)
01807 {
01808 if ($int_link["type"] == "git")
01809 {
01810 $tpl = new ilTemplate("tpl.main.html", true, true);
01811 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01812
01813 $_GET["obj_id"] = $int_link["id"];
01814 $_GET["frame"] = "_new";
01815 $content =& $a_lm_gui->glossary();
01816 $file = $a_target_dir."/term_".$int_link["id"].".html";
01817
01818
01819 if (!($fp = @fopen($file,"w+")))
01820 {
01821 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01822 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01823 }
01824 chmod($file, 0770);
01825 fwrite($fp, $content);
01826 fclose($fp);
01827
01828
01829 include_once("content/classes/class.ilGlossaryDefinition.php");
01830 $defs = ilGlossaryDefinition::getDefinitionList($int_link["id"]);
01831 foreach($defs as $def)
01832 {
01833 $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
01834 foreach($def_mobs as $def_mob)
01835 {
01836 $this->offline_mobs[$def_mob] = $def_mob;
01837 }
01838
01839
01840 $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $page["obj_id"]);
01841 $this->offline_files = array_merge($this->offline_files, $def_files);
01842
01843 }
01844
01845 }
01846 }
01847 }
01848
01852 function exportHTMLPages(&$a_lm_gui, $a_target_dir)
01853 {
01854 global $tpl;
01855
01856 $pages = ilLMPageObject::getPageList($this->getId());
01857
01858 $lm_tree =& $this->getLMTree();
01859 $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg");
01860 $this->first_page_id = $first_page["child"];
01861
01862
01863 $mobs = array();
01864 $int_links = array();
01865 $this->offline_files = array();
01866
01867 foreach ($pages as $page)
01868 {
01869 $this->exportPageHTML($a_lm_gui, $a_target_dir, $page["obj_id"]);
01870
01871
01872 include_once("content/classes/Media/class.ilObjMediaObject.php");
01873 $pg_mobs = ilObjMediaObject::_getMobsOfObject($this->getType().":pg", $page["obj_id"]);
01874 foreach($pg_mobs as $pg_mob)
01875 {
01876 $mobs[$pg_mob] = $pg_mob;
01877 }
01878
01879
01880 $pg_links = ilInternalLink::_getTargetsOfSource($this->getType().":pg", $page["obj_id"]);
01881 $int_links = array_merge($int_links, $pg_links);
01882
01883
01884 include_once("classes/class.ilObjFile.php");
01885 $pg_files = ilObjFile::_getFilesOfObject($this->getType().":pg", $page["obj_id"]);
01886 $this->offline_files = array_merge($this->offline_files, $pg_files);
01887
01888
01889 }
01890 $this->offline_mobs = $mobs;
01891 $this->offline_int_links = $int_links;
01892
01893
01894 }
01895
01899 function exportPageHTML(&$a_lm_gui, $a_target_dir, $a_lm_page_id, $a_frame = "")
01900 {
01901 global $ilias, $tpl;
01902
01903
01904 $tpl = new ilTemplate("tpl.main.html", true, true);
01905 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01906
01907 $_GET["obj_id"] = $a_lm_page_id;
01908 $_GET["frame"] = $a_frame;
01909
01910 if ($a_frame == "")
01911 {
01912 $file = $a_target_dir."/lm_pg_".$a_lm_page_id.".html";
01913 }
01914 else
01915 {
01916 if ($a_frame != "toc")
01917 {
01918 $file = $a_target_dir."/frame_".$a_lm_page_id."_".$a_frame.".html";
01919 }
01920 else
01921 {
01922 $file = $a_target_dir."/frame_".$a_frame.".html";
01923 }
01924 }
01925
01926
01927 if (@is_file($file))
01928 {
01929 return;
01930 }
01931
01932 $content =& $a_lm_gui->layout("main.xml", false);
01933
01934
01935 if (!($fp = @fopen($file,"w+")))
01936 {
01937 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01938 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01939 }
01940
01941
01942 chmod($file, 0770);
01943
01944
01945 fwrite($fp, $content);
01946
01947
01948 fclose($fp);
01949
01950 if ($this->first_page_id == $a_lm_page_id && $a_frame == "")
01951 {
01952 copy($file, $a_target_dir."/index.html");
01953 }
01954
01955
01956 $frameset = $a_lm_gui->getCurrentFrameSet();
01957 foreach ($frameset as $frame)
01958 {
01959 $this->exportPageHTML($a_lm_gui, $a_target_dir, $a_lm_page_id, $frame);
01960 }
01961
01962 }
01963
01970 function exportFO(&$a_xml_writer, $a_target_dir)
01971 {
01972 global $ilBench;
01973
01974
01975 $attrs = array();
01976 $attrs["xmlns:fo"] = "http://www.w3.org/1999/XSL/Format";
01977 $a_xml_writer->xmlStartTag("fo:root", $attrs);
01978
01979
01980 $attrs = array();
01981 $a_xml_writer->xmlStartTag("fo:layout-master-set", $attrs);
01982
01983
01984 $attrs = array();
01985 $attrs["master-name"] = "DinA4";
01986 $attrs["page-height"] = "29.7cm";
01987 $attrs["page-width"] = "21cm";
01988 $attrs["margin-top"] = "4cm";
01989 $attrs["margin-bottom"] = "1cm";
01990 $attrs["margin-left"] = "2.8cm";
01991 $attrs["margin-right"] = "7.3cm";
01992 $a_xml_writer->xmlStartTag("fo:simple-page-master", $attrs);
01993
01994
01995 $attrs = array();
01996 $attrs["margin-top"] = "0cm";
01997 $attrs["margin-bottom"] = "1.25cm";
01998 $a_xml_writer->xmlElement("fo:region-body", $attrs);
01999
02000
02001 $attrs = array();
02002 $attrs["extent"] = "1cm";
02003 $a_xml_writer->xmlElement("fo:region-before", $attrs);
02004
02005
02006 $attrs = array();
02007 $attrs["extent"] = "1cm";
02008 $a_xml_writer->xmlElement("fo:region-after", $attrs);
02009
02010
02011 $a_xml_writer->xmlEndTag("fo:simple-page-master");
02012
02013
02014 $a_xml_writer->xmlEndTag("fo:layout-master-set");
02015
02016
02017 $attrs = array();
02018 $attrs["master-reference"] = "DinA4";
02019 $a_xml_writer->xmlStartTag("fo:page-sequence", $attrs);
02020
02021
02022 $attrs = array();
02023 $attrs["flow-name"] = "xsl-region-body";
02024 $a_xml_writer->xmlStartTag("fo:flow", $attrs);
02025
02026
02027
02028
02029 $ilBench->start("ContentObjectExport", "exportFOStructureObjects");
02030 $this->exportFOStructureObjects($a_xml_writer, $expLog);
02031 $ilBench->stop("ContentObjectExport", "exportFOStructureObjects");
02032
02033
02034
02035 $a_xml_writer->xmlEndTag("fo:flow");
02036
02037
02038 $a_xml_writer->xmlEndTag("fo:page-sequence");
02039
02040
02041 $a_xml_writer->xmlEndTag("fo:root");
02042 }
02043
02050 function exportFOStructureObjects(&$a_xml_writer)
02051 {
02052 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
02053 foreach ($childs as $child)
02054 {
02055 if($child["type"] != "st")
02056 {
02057 continue;
02058 }
02059
02060 $structure_obj = new ilStructureObject($this, $child["obj_id"]);
02061 $structure_obj->exportFO($a_xml_writer, $expLog);
02062 unset($structure_obj);
02063 }
02064 }
02065
02066 function getXMLZip()
02067 {
02068 include_once("./content/classes/class.ilContObjectExport.php");
02069
02070 $cont_exp = new ilContObjectExport($this,'xml');
02071
02072 $export_file = $cont_exp->buildExportFile();
02073 return $export_file;
02074 }
02075
02076
02077 }
02078 ?>