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 setActiveDownloadsPublic($a_down)
00644 {
00645 $this->downloads_public_active = $a_down;
00646 }
00647
00648 function isActiveDownloadsPublic()
00649 {
00650 return $this->downloads_public_active;
00651 }
00652
00653 function setPublicNotes($a_pub_notes)
00654 {
00655 $this->pub_notes = $a_pub_notes;
00656 }
00657
00658 function publicNotes()
00659 {
00660 return $this->pub_notes;
00661 }
00662
00663 function setCleanFrames($a_clean)
00664 {
00665 $this->clean_frames = $a_clean;
00666 }
00667
00668 function cleanFrames()
00669 {
00670 return $this->clean_frames;
00671 }
00672
00673 function setHistoryUserComments($a_comm)
00674 {
00675 $this->user_comments = $a_comm;
00676 }
00677
00678 function setPublicAccessMode($a_mode)
00679 {
00680 $this->public_access_mode = $a_mode;
00681 }
00682
00683 function isActiveHistoryUserComments()
00684 {
00685 return $this->user_comments;
00686 }
00687
00691 function readProperties()
00692 {
00693 $q = "SELECT * FROM content_object WHERE id = '".$this->getId()."'";
00694 $lm_set = $this->ilias->db->query($q);
00695 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00696 $this->setLayout($lm_rec["default_layout"]);
00697 $this->setStyleSheetId($lm_rec["stylesheet"]);
00698 $this->setPageHeader($lm_rec["page_header"]);
00699 $this->setTOCMode($lm_rec["toc_mode"]);
00700 $this->setOnline(ilUtil::yn2tf($lm_rec["online"]));
00701 $this->setActiveTOC(ilUtil::yn2tf($lm_rec["toc_active"]));
00702 $this->setActiveNumbering(ilUtil::yn2tf($lm_rec["numbering"]));
00703 $this->setActivePrintView(ilUtil::yn2tf($lm_rec["print_view_active"]));
00704 $this->setActiveDownloads(ilUtil::yn2tf($lm_rec["downloads_active"]));
00705 $this->setActiveDownloadsPublic(ilUtil::yn2tf($lm_rec["downloads_public_active"]));
00706 $this->setActiveLMMenu(ilUtil::yn2tf($lm_rec["lm_menu_active"]));
00707 $this->setCleanFrames(ilUtil::yn2tf($lm_rec["clean_frames"]));
00708 $this->setPublicNotes(ilUtil::yn2tf($lm_rec["pub_notes"]));
00709 $this->setHistoryUserComments(ilUtil::yn2tf($lm_rec["hist_user_comments"]));
00710 $this->setPublicAccessMode($lm_rec["public_access_mode"]);
00711 $this->setPublicExportFile("xml", $lm_rec["public_xml_file"]);
00712 $this->setPublicExportFile("html", $lm_rec["public_html_file"]);
00713 }
00714
00718 function updateProperties()
00719 {
00720 $q = "UPDATE content_object SET ".
00721 " default_layout = '".$this->getLayout()."', ".
00722 " stylesheet = '".$this->getStyleSheetId()."',".
00723 " page_header = '".$this->getPageHeader()."',".
00724 " toc_mode = '".$this->getTOCMode()."',".
00725 " online = '".ilUtil::tf2yn($this->getOnline())."',".
00726 " toc_active = '".ilUtil::tf2yn($this->isActiveTOC())."',".
00727 " numbering = '".ilUtil::tf2yn($this->isActiveNumbering())."',".
00728 " print_view_active = '".ilUtil::tf2yn($this->isActivePrintView())."',".
00729 " downloads_active = '".ilUtil::tf2yn($this->isActiveDownloads())."',".
00730 " downloads_public_active = '".ilUtil::tf2yn($this->isActiveDownloadsPublic())."',".
00731 " clean_frames = '".ilUtil::tf2yn($this->cleanFrames())."',".
00732 " pub_notes = '".ilUtil::tf2yn($this->publicNotes())."',".
00733 " hist_user_comments = '".ilUtil::tf2yn($this->isActiveHistoryUserComments())."',".
00734 " public_access_mode = '".$this->getPublicAccessMode()."',".
00735 " public_xml_file = '".$this->getPublicExportFile("xml")."',".
00736 " public_html_file = '".$this->getPublicExportFile("html")."',".
00737 " lm_menu_active = '".ilUtil::tf2yn($this->isActiveLMMenu())."'".
00738 " WHERE id = '".$this->getId()."'";
00739 $this->ilias->db->query($q);
00740 }
00741
00745 function createProperties()
00746 {
00747 $q = "INSERT INTO content_object (id) VALUES ('".$this->getId()."')";
00748 $this->ilias->db->query($q);
00749 $this->readProperties();
00750 }
00751
00755 function _lookupOnline($a_id)
00756 {
00757
00758
00759 $q = "SELECT * FROM content_object WHERE id = '".$a_id."'";
00760 $lm_set = $this->ilias->db->query($q);
00761 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00762
00763 return ilUtil::yn2tf($lm_rec["online"]);
00764 }
00765
00771 function getAvailableLayouts()
00772 {
00773
00774 $dir = opendir("./layouts/lm");
00775
00776 $layouts = array();
00777
00778 while($file = readdir($dir))
00779 {
00780 if ($file != "." && $file != ".." && $file != "CVS")
00781 {
00782
00783 if (@is_dir("./layouts/lm/".$file))
00784 {
00785 $layouts[$file] = $file;
00786 }
00787 }
00788 }
00789 asort($layouts);
00790 return $layouts;
00791 }
00792
00796 function _checkPreconditionsOfPage($cont_obj_id, $page_id)
00797 {
00798 global $ilias,$ilUser,$ilErr;
00799
00800 $lm_tree = new ilTree($cont_obj_id);
00801 $lm_tree->setTableNames('lm_tree','lm_data');
00802 $lm_tree->setTreeTablePK("lm_id");
00803
00804 if ($lm_tree->isInTree($page_id))
00805 {
00806 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
00807 foreach ($path as $node)
00808 {
00809 if ($node["type"] == "st")
00810 {
00811 if (!ilConditionHandler::_checkAllConditionsOfTarget($node["child"], "st"))
00812 {
00813 return false;
00814 }
00815 }
00816 }
00817 }
00818
00819 return true;
00820 }
00821
00825 function _getMissingPreconditionsOfPage($cont_obj_id, $page_id)
00826 {
00827 $lm_tree = new ilTree($cont_obj_id);
00828 $lm_tree->setTableNames('lm_tree','lm_data');
00829 $lm_tree->setTreeTablePK("lm_id");
00830
00831 $conds = array();
00832 if ($lm_tree->isInTree($page_id))
00833 {
00834
00835 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
00836 foreach ($path as $node)
00837 {
00838 if ($node["type"] == "st")
00839 {
00840
00841 $tconds = ilConditionHandler::_getConditionsOfTarget($node["child"], "st");
00842 foreach ($tconds as $tcond)
00843 {
00844
00845 if (!ilConditionHandler::_checkCondition($tcond["id"]))
00846 {
00847 $conds[] = $tcond;
00848 }
00849 }
00850 }
00851 }
00852 }
00853
00854 return $conds;
00855 }
00856
00860 function _getMissingPreconditionsTopChapter($cont_obj_id, $page_id)
00861 {
00862 $lm_tree = new ilTree($cont_obj_id);
00863 $lm_tree->setTableNames('lm_tree','lm_data');
00864 $lm_tree->setTreeTablePK("lm_id");
00865
00866 $conds = array();
00867 if ($lm_tree->isInTree($page_id))
00868 {
00869
00870 $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId());
00871 foreach ($path as $node)
00872 {
00873 if ($node["type"] == "st")
00874 {
00875
00876 $tconds = ilConditionHandler::_getConditionsOfTarget($node["child"], "st");
00877 foreach ($tconds as $tcond)
00878 {
00879
00880 if (!ilConditionHandler::_checkCondition($tcond["id"]))
00881 {
00882 return $node["child"];
00883 }
00884 }
00885 }
00886 }
00887 }
00888
00889 return "";
00890 }
00891
00902 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00903 {
00904 global $tree;
00905
00906 switch ($a_event)
00907 {
00908 case "link":
00909
00910
00911
00912
00913 break;
00914
00915 case "cut":
00916
00917
00918
00919 break;
00920
00921 case "copy":
00922
00923
00924
00925
00926 break;
00927
00928 case "paste":
00929
00930
00931
00932 break;
00933
00934 case "new":
00935
00936
00937
00938 break;
00939 }
00940
00941
00942 if ($a_node_id==$_GET["ref_id"])
00943 {
00944 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00945 $parent_type = $parent_obj->getType();
00946 if($parent_type == $this->getType())
00947 {
00948 $a_node_id = (int) $tree->getParentId($a_node_id);
00949 }
00950 }
00951
00952 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00953 }
00954
00962 function _search(&$search_obj,$a_search_in)
00963 {
00964 global $ilBench;
00965
00966 switch($a_search_in)
00967 {
00968 case 'meta':
00969
00970 $in = $search_obj->getInStatement("r.ref_id");
00971 $where = $search_obj->getWhereCondition("fulltext",array("xv.tag_value"));
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983 $query1 = "SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
00984 "xmlnestedset AS xm,xmlvalue AS xv ".
00985 $where.
00986 $in.
00987 "AND r.obj_id=o.obj_id AND ( ".
00988 "(o.obj_id=xm.ns_book_fk AND xm.ns_type IN ('lm','bib'))) ".
00989 "AND xm.ns_tag_fk=xv.tag_fk ".
00990 "AND o.type= 'lm'";
00991
00992
00993 $query1 = "SELECT DISTINCT(r.ref_id) as ref_id FROM xmlvalue AS xv ".
00994 "LEFT JOIN xmlnestedset AS xm ON xm.ns_tag_fk=xv.tag_fk ".
00995 "LEFT JOIN object_data AS o ON o.obj_id = xm.ns_book_fk ".
00996 "LEFT JOIN object_reference AS r ON o.obj_id = r.obj_id ".
00997 $where.
00998 $in.
00999 " AND o.type = 'lm' AND xm.ns_type IN ('lm','bib')";
01000
01001 $query2 = "SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
01002 "lm_data AS l,xmlnestedset AS xm,xmlvalue AS xv ".
01003 $where.
01004 $in.
01005 "AND r.obj_id=o.obj_id AND ((o.obj_id=l.lm_id AND xm.ns_book_fk=l.obj_id)".
01006 ") ".
01007 "AND xm.ns_tag_fk=xv.tag_fk ".
01008 "AND o.type= 'lm'";
01009
01010 $query2 = "SELECT DISTINCT(r.ref_id) as ref_id FROM xmlvalue AS xv ".
01011 "LEFT JOIN xmlnestedset AS xm ON xm.ns_tag_fk = xv.tag_fk ".
01012 "LEFT JOIN lm_data AS l ON l.obj_id = xm.ns_book_fk ".
01013 "LEFT JOIN object_data AS o ON o.obj_id = l.lm_id ".
01014 "LEFT JOIN object_reference AS r ON r.obj_id = o.obj_id ".
01015 $where.
01016 $in.
01017 "AND o.type = 'lm'";
01018
01019 $ilBench->start("Search", "ilObjContentObject_search_meta");
01020 $res1 = $search_obj->ilias->db->query($query1);
01021 $res2 = $search_obj->ilias->db->query($query2);
01022 $ilBench->stop("Search", "ilObjContentObject_search_meta");
01023
01024 $counter = 0;
01025 $ids = array();
01026 while($row = $res1->fetchRow(DB_FETCHMODE_OBJECT))
01027 {
01028 $ids[] = $row->ref_id;
01029 $result[$counter]["id"] = $row->ref_id;
01030 ++$counter;
01031 }
01032 while($row = $res2->fetchRow(DB_FETCHMODE_OBJECT))
01033 {
01034 if(in_array($row->ref_id,$ids))
01035 {
01036 continue;
01037 }
01038 $result[$counter]["id"] = $row->ref_id;
01039 ++$counter;
01040 }
01041 break;
01042
01043 case 'content':
01044 $in = $search_obj->getInStatement("r.ref_id");
01045 $where = $search_obj->getWhereCondition("fulltext",array("pg.content"));
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055 $query = "SELECT DISTINCT(r.ref_id) AS ref_id ,pg.page_id AS page_id FROM page_object AS pg ".
01056 ", object_reference AS r ".
01057 $where.
01058 " AND pg.parent_id = r.obj_id ".
01059 $in.
01060 " AND pg.parent_type = 'lm' ";
01061
01062 $query = "SELECT DISTINCT(r.ref_id) AS ref_id ,pg.page_id AS page_id FROM page_object AS pg ".
01063 "LEFT JOIN object_data AS o ON o.obj_id = pg.parent_id ".
01064 "LEFT JOIN object_reference AS r ON o.obj_id = r.obj_id ".
01065 $where.
01066 $in.
01067 " AND pg.parent_type = 'lm'";
01068
01069 $ilBench->start("Search", "ilObjContentObject_search_content");
01070 $res = $search_obj->ilias->db->query($query);
01071 $ilBench->stop("Search", "ilObjContentObject_search_content");
01072
01073 $counter = 0;
01074 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
01075 {
01076 $result[$counter]["id"] = $row->ref_id;
01077 $result[$counter]["page_id"] = $row->page_id;
01078
01079
01080
01081
01082 ++$counter;
01083 }
01084 break;
01085 }
01086 return $result ? $result : array();
01087 }
01088
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01118 function _goto($a_target)
01119 {
01120 global $rbacsystem, $ilErr, $lng;
01121
01122 include_once 'classes/class.ilSearch.php';
01123
01124
01125
01126 if ($rbacsystem->checkAccess("read", $a_target) and ilSearch::_checkParentConditions($a_target))
01127 {
01128 $_GET["baseClass"] = "ilLMPresentationGUI";
01129 $_GET["ref_id"] = $a_target;
01130
01131 }
01132 else
01133 {
01134 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
01135 }
01136 }
01137
01141 function hasSuccessorPage($a_cont_obj_id, $a_page_id)
01142 {
01143 $tree = new ilTree($a_cont_obj_id);
01144 $tree->setTableNames('lm_tree','lm_data');
01145 $tree->setTreeTablePK("lm_id");
01146 if ($tree->isInTree($a_page_id))
01147 {
01148 $succ = $tree->fetchSuccessorNode($a_page_id, "pg");
01149 if ($succ > 0)
01150 {
01151 return true;
01152 }
01153 }
01154 return false;
01155 }
01156
01157
01158 function checkTree()
01159 {
01160 $tree = new ilTree($this->getId());
01161 $tree->setTableNames('lm_tree','lm_data');
01162 $tree->setTreeTablePK("lm_id");
01163 $tree->checkTree();
01164 $tree->checkTreeChilds();
01165
01166 }
01167
01171 function fixTree()
01172 {
01173 global $ilDB;
01174
01175 $tree =& $this->getLMTree();
01176
01177
01178 $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
01179 foreach ($nodes as $node)
01180 {
01181 $q = "SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($node["child"]);
01182 $obj_set = $ilDB->query($q);
01183 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
01184 if (!$obj_rec)
01185 {
01186 $node_data = $tree->getNodeData($node["child"]);
01187 $tree->deleteTree($node_data);
01188 }
01189 }
01190
01191
01192 $nodes = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
01193 foreach ($nodes as $node)
01194 {
01195 $q = "SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($node["parent"]);
01196 $obj_set = $ilDB->query($q);
01197 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
01198 if ($obj_rec["type"] == "pg")
01199 {
01200 $node_data = $tree->getNodeData($node["child"]);
01201 if ($tree->isInTree($node["child"]))
01202 {
01203 $tree->deleteTree($node_data);
01204 }
01205 }
01206 }
01207
01208 }
01209
01210
01217 function exportXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
01218 {
01219 global $ilBench;
01220
01221 $attrs = array();
01222 switch($this->getType())
01223 {
01224 case "lm":
01225 $attrs["Type"] = "LearningModule";
01226 break;
01227
01228 case "dbk":
01229 $attrs["Type"] = "LibObject";
01230 break;
01231 }
01232 $a_xml_writer->xmlStartTag("ContentObject", $attrs);
01233
01234
01235 $this->exportXMLMetaData($a_xml_writer);
01236
01237
01238
01239 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Structure Objects");
01240 $ilBench->start("ContentObjectExport", "exportStructureObjects");
01241 $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
01242 $ilBench->stop("ContentObjectExport", "exportStructureObjects");
01243 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Structure Objects");
01244
01245
01246 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Page Objects");
01247 $ilBench->start("ContentObjectExport", "exportPageObjects");
01248 $this->exportXMLPageObjects($a_xml_writer, $a_inst, $expLog);
01249 $ilBench->stop("ContentObjectExport", "exportPageObjects");
01250 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Page Objects");
01251
01252
01253 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects");
01254 $ilBench->start("ContentObjectExport", "exportMediaObjects");
01255 $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
01256 $ilBench->stop("ContentObjectExport", "exportMediaObjects");
01257 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects");
01258
01259
01260 $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items");
01261 $ilBench->start("ContentObjectExport", "exportFileItems");
01262 $this->exportFileItems($a_target_dir, $expLog);
01263 $ilBench->stop("ContentObjectExport", "exportFileItems");
01264 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items");
01265
01266
01267
01268 $expLog->write(date("[y-m-d H:i:s] ")."Start Export Properties");
01269 $this->exportXMLProperties($a_xml_writer, $expLog);
01270 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Properties");
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281 $a_xml_writer->xmlEndTag("ContentObject");
01282 }
01283
01290 function exportXMLMetaData(&$a_xml_writer)
01291 {
01292 include_once("Services/MetaData/classes/class.ilMD2XML.php");
01293 $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
01294 $md2xml->setExportMode(true);
01295 $md2xml->startExport();
01296 $a_xml_writer->appendXML($md2xml->getXML());
01297 }
01298
01305 function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
01306 {
01307 include_once './content/classes/class.ilStructureObject.php';
01308
01309 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
01310 foreach ($childs as $child)
01311 {
01312 if($child["type"] != "st")
01313 {
01314 continue;
01315 }
01316
01317 $structure_obj = new ilStructureObject($this, $child["obj_id"]);
01318 $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
01319 unset($structure_obj);
01320 }
01321 }
01322
01323
01330 function exportXMLPageObjects(&$a_xml_writer, $a_inst, &$expLog)
01331 {
01332 global $ilBench;
01333
01334 include_once "./content/classes/class.ilLMPageObject.php";
01335
01336 $pages = ilLMPageObject::getPageList($this->getId());
01337 foreach ($pages as $page)
01338 {
01339 $ilBench->start("ContentObjectExport", "exportPageObject");
01340 $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$page["obj_id"]);
01341
01342
01343 $ilBench->start("ContentObjectExport", "exportPageObject_getLMPageObject");
01344 $page_obj = new ilLMPageObject($this, $page["obj_id"]);
01345 $ilBench->stop("ContentObjectExport", "exportPageObject_getLMPageObject");
01346 $ilBench->start("ContentObjectExport", "exportPageObject_XML");
01347 $page_obj->exportXML($a_xml_writer, "normal", $a_inst);
01348 $ilBench->stop("ContentObjectExport", "exportPageObject_XML");
01349
01350
01351 $ilBench->start("ContentObjectExport", "exportPageObject_CollectMedia");
01352 $mob_ids = $page_obj->getMediaObjectIDs();
01353 foreach($mob_ids as $mob_id)
01354 {
01355 $this->mob_ids[$mob_id] = $mob_id;
01356 }
01357 $ilBench->stop("ContentObjectExport", "exportPageObject_CollectMedia");
01358
01359
01360 $ilBench->start("ContentObjectExport", "exportPageObject_CollectFileItems");
01361 $file_ids = $page_obj->getFileItemIds();
01362 foreach($file_ids as $file_id)
01363 {
01364 $this->file_ids[$file_id] = $file_id;
01365 }
01366 $ilBench->stop("ContentObjectExport", "exportPageObject_CollectFileItems");
01367
01368 unset($page_obj);
01369
01370 $ilBench->stop("ContentObjectExport", "exportPageObject");
01371 }
01372 }
01373
01380 function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
01381 {
01382 include_once("content/classes/Media/class.ilObjMediaObject.php");
01383
01384 foreach ($this->mob_ids as $mob_id)
01385 {
01386 if ($mob_id > 0)
01387 {
01388 $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id);
01389 $media_obj = new ilObjMediaObject($mob_id);
01390 $media_obj->exportXML($a_xml_writer, $a_inst);
01391 $media_obj->exportFiles($a_target_dir);
01392 unset($media_obj);
01393 }
01394 }
01395 }
01396
01401 function exportFileItems($a_target_dir, &$expLog)
01402 {
01403 include_once("classes/class.ilObjFile.php");
01404
01405 foreach ($this->file_ids as $file_id)
01406 {
01407 $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id);
01408 $file_obj = new ilObjFile($file_id, false);
01409 $file_obj->export($a_target_dir);
01410 unset($file_obj);
01411 }
01412 }
01413
01418 function exportXMLProperties($a_xml_writer, &$expLog)
01419 {
01420 $attrs = array();
01421 $a_xml_writer->xmlStartTag("Properties", $attrs);
01422
01423
01424 $attrs = array("Name" => "Layout", "Value" => $this->getLayout());
01425 $a_xml_writer->xmlElement("Property", $attrs);
01426
01427
01428 $attrs = array("Name" => "PageHeader", "Value" => $this->getPageHeader());
01429 $a_xml_writer->xmlElement("Property", $attrs);
01430
01431
01432 $attrs = array("Name" => "TOCMode", "Value" => $this->getTOCMode());
01433 $a_xml_writer->xmlElement("Property", $attrs);
01434
01435
01436 $attrs = array("Name" => "ActiveLMMenu", "Value" =>
01437 ilUtil::tf2yn($this->isActiveLMMenu()));
01438 $a_xml_writer->xmlElement("Property", $attrs);
01439
01440
01441 $attrs = array("Name" => "ActiveNumbering", "Value" =>
01442 ilUtil::tf2yn($this->isActiveNumbering()));
01443 $a_xml_writer->xmlElement("Property", $attrs);
01444
01445
01446 $attrs = array("Name" => "ActiveTOC", "Value" =>
01447 ilUtil::tf2yn($this->isActiveTOC()));
01448 $a_xml_writer->xmlElement("Property", $attrs);
01449
01450
01451 $attrs = array("Name" => "ActivePrintView", "Value" =>
01452 ilUtil::tf2yn($this->isActivePrintView()));
01453 $a_xml_writer->xmlElement("Property", $attrs);
01454
01455
01456
01457
01458
01459 $attrs = array("Name" => "CleanFrames", "Value" =>
01460 ilUtil::tf2yn($this->cleanFrames()));
01461 $a_xml_writer->xmlElement("Property", $attrs);
01462
01463
01464 $attrs = array("Name" => "PublicNotes", "Value" =>
01465 ilUtil::tf2yn($this->publicNotes()));
01466 $a_xml_writer->xmlElement("Property", $attrs);
01467
01468
01469 $attrs = array("Name" => "HistoryUserComments", "Value" =>
01470 ilUtil::tf2yn($this->isActiveHistoryUserComments()));
01471 $a_xml_writer->xmlElement("Property", $attrs);
01472
01473 $a_xml_writer->xmlEndTag("Properties");
01474 }
01475
01479 function getExportFiles()
01480 {
01481 $file = array();
01482
01483 $types = array("xml", "html", "scorm");
01484
01485 foreach ($types as $type)
01486 {
01487 $dir = $this->getExportDirectory($type);
01488
01489 if (!@is_dir($dir) or
01490 !is_writeable($dir))
01491 {
01492 continue;
01493 }
01494
01495
01496 $cdir = dir($dir);
01497
01498
01499
01500
01501 while ($entry = $cdir->read())
01502 {
01503 if ($entry != "." and
01504 $entry != ".." and
01505 substr($entry, -4) == ".zip" and
01506 ereg("^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.zip\$", $entry))
01507 {
01508 $file[$entry.$type] = array("type" => $type, "file" => $entry,
01509 "size" => filesize($dir."/".$entry));
01510 }
01511 }
01512
01513
01514 $cdir->close();
01515 }
01516
01517
01518 ksort ($file);
01519 reset ($file);
01520 return $file;
01521 }
01522
01529 function setPublicExportFile($a_type, $a_file)
01530 {
01531 $this->public_export_file[$a_type] = $a_file;
01532 }
01533
01541 function getPublicExportFile($a_type)
01542 {
01543 return $this->public_export_file[$a_type];
01544 }
01545
01549 function getOfflineFiles($dir)
01550 {
01551
01552 if (!@is_dir($dir) or
01553 !is_writeable($dir))
01554 {
01555 return array();
01556 }
01557
01558
01559 $dir = dir($dir);
01560
01561
01562 $file = array();
01563
01564
01565 while ($entry = $dir->read())
01566 {
01567 if ($entry != "." and
01568 $entry != ".." and
01569 substr($entry, -4) == ".pdf" and
01570 ereg("^[0-9]{10}_{2}[0-9]+_{2}(lm_)*[0-9]+\.pdf\$", $entry))
01571 {
01572 $file[] = $entry;
01573 }
01574 }
01575
01576
01577 $dir->close();
01578
01579
01580 sort ($file);
01581 reset ($file);
01582
01583 return $file;
01584 }
01585
01589 function exportSCORM($a_target_dir, $log)
01590 {
01591 ilUtil::delDir($a_target_dir);
01592 ilUtil::makeDir($a_target_dir);
01593
01594
01595
01596 $this->exportHTML($a_target_dir."/res", $log, false, "scorm");
01597
01598
01599 include("content/classes/class.ilContObjectManifestBuilder.php");
01600 $man_builder = new ilContObjectManifestBuilder($this);
01601 $man_builder->buildManifest();
01602 $man_builder->dump($a_target_dir);
01603
01604
01605 copy("content/scorm_xsd/adlcp_rootv1p2.xsd", $a_target_dir."/adlcp_rootv1p2.xsd");
01606 copy("content/scorm_xsd/imscp_rootv1p1p2.xsd", $a_target_dir."/imscp_rootv1p1p2.xsd");
01607 copy("content/scorm_xsd/imsmd_rootv1p2p1.xsd", $a_target_dir."/imsmd_rootv1p2p1.xsd");
01608 copy("content/scorm_xsd/ims_xml.xsd", $a_target_dir."/ims_xml.xsd");
01609
01610
01611 $date = time();
01612 $zip_file = $a_target_dir."/".$date."__".IL_INST_ID."__".
01613 $this->getType()."_".$this->getId().".zip";
01614
01615 ilUtil::zip(array($a_target_dir."/res",
01616 $a_target_dir."/imsmanifest.xml",
01617 $a_target_dir."/adlcp_rootv1p2.xsd",
01618 $a_target_dir."/imscp_rootv1p1p2.xsd",
01619 $a_target_dir."/ims_xml.xsd",
01620 $a_target_dir."/imsmd_rootv1p2p1.xsd")
01621 , $zip_file);
01622
01623 $dest_file = $this->getExportDirectory("scorm")."/".$date."__".IL_INST_ID."__".
01624 $this->getType()."_".$this->getId().".zip";
01625
01626 rename($zip_file, $dest_file);
01627 ilUtil::delDir($a_target_dir);
01628
01629 }
01630
01631
01635 function exportHTML($a_target_dir, $log, $a_zip_file = true, $a_export_format = "html")
01636 {
01637 global $ilias, $tpl, $ilBench, $ilLocator;
01638
01639
01640 ilUtil::delDir($a_target_dir);
01641 ilUtil::makeDir($a_target_dir);
01642 $mob_dir = $a_target_dir."/mobs";
01643 ilUtil::makeDir($mob_dir);
01644 $file_dir = $a_target_dir."/files";
01645 ilUtil::makeDir($file_dir);
01646
01647
01648 $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem");
01649 $style_name = $ilias->account->prefs["style"].".css";
01650 copy($location_stylesheet, $a_target_dir."/".$style_name);
01651 $location_stylesheet = ilUtil::getStyleSheetLocation();
01652
01653
01654 $ilBench->start("ExportHTML", "exportContentStyle");
01655 if ($this->getStyleSheetId() < 1)
01656 {
01657 $cont_stylesheet = "content/content.css";
01658 copy($cont_stylesheet, $a_target_dir."/content.css");
01659 }
01660 else
01661 {
01662 $style = new ilObjStyleSheet($this->getStyleSheetId());
01663 $style->writeCSSFile($a_target_dir."/content.css");
01664 }
01665 $ilBench->stop("ExportHTML", "exportContentStyle");
01666
01667
01668 $syn_stylesheet = "content/syntaxhighlight.css";
01669 copy($syn_stylesheet, $a_target_dir."/syntaxhighlight.css");
01670
01671
01672 include_once("content/classes/class.ilLMPresentationGUI.php");
01673 $_GET["cmd"] = "nop";
01674 $lm_gui =& new ilLMPresentationGUI();
01675 $lm_gui->setOfflineMode(true);
01676 $lm_gui->setOfflineDirectory($a_target_dir);
01677 $lm_gui->setExportFormat($a_export_format);
01678
01679
01680 $ilBench->start("ExportHTML", "exportHTMLPages");
01681 $this->exportHTMLPages($lm_gui, $a_target_dir);
01682 $ilBench->stop("ExportHTML", "exportHTMLPages");
01683
01684
01685 $ilBench->start("ExportHTML", "exportHTMLGlossaryTerms");
01686 $this->exportHTMLGlossaryTerms($lm_gui, $a_target_dir);
01687 $ilBench->stop("ExportHTML", "exportHTMLGlossaryTerms");
01688
01689
01690 $ilBench->start("ExportHTML", "exportHTMLMediaObjects");
01691 foreach ($this->offline_mobs as $mob)
01692 {
01693 $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_new");
01694 }
01695 $_GET["obj_type"] = "MediaObject";
01696 $_GET["obj_id"] = $a_mob_id;
01697 $_GET["cmd"] = "";
01698 $ilBench->stop("ExportHTML", "exportHTMLMediaObjects");
01699
01700
01701 $ilBench->start("ExportHTML", "exportHTMLFileObjects");
01702 foreach ($this->offline_files as $file)
01703 {
01704 $this->exportHTMLFile($a_target_dir, $file);
01705 }
01706 $ilBench->stop("ExportHTML", "exportHTMLFileObjects");
01707
01708
01709 $ilBench->start("ExportHTML", "exportHTMLTOC");
01710 $ilLocator->clearItems();
01711 if ($this->isActiveTOC())
01712 {
01713 $tpl = new ilTemplate("tpl.main.html", true, true);
01714
01715 $content =& $lm_gui->showTableOfContents();
01716 $file = $a_target_dir."/table_of_contents.html";
01717
01718
01719 if (!($fp = @fopen($file,"w+")))
01720 {
01721 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01722 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01723 }
01724 chmod($file, 0770);
01725 fwrite($fp, $content);
01726 fclose($fp);
01727 }
01728 $ilBench->stop("ExportHTML", "exportHTMLTOC");
01729
01730
01731 $ilBench->start("ExportHTML", "exportHTMLImages");
01732 $image_dir = $a_target_dir."/images";
01733 ilUtil::makeDir($image_dir);
01734 ilUtil::makeDir($image_dir."/browser");
01735 copy(ilUtil::getImagePath("enlarge.gif", false, "filesystem"),
01736 $image_dir."/enlarge.gif");
01737 copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
01738 $image_dir."/browser/plus.gif");
01739 copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
01740 $image_dir."/browser/minus.gif");
01741 copy(ilUtil::getImagePath("browser/blank.gif", false, "filesystem"),
01742 $image_dir."/browser/blank.gif");
01743 copy(ilUtil::getImagePath("icon_st.gif", false, "filesystem"),
01744 $image_dir."/icon_st.gif");
01745 copy(ilUtil::getImagePath("icon_pg.gif", false, "filesystem"),
01746 $image_dir."/icon_pg.gif");
01747 copy(ilUtil::getImagePath("icon_lm.gif", false, "filesystem"),
01748 $image_dir."/icon_lm.gif");
01749 copy(ilUtil::getImagePath("nav_arr_L.gif", false, "filesystem"),
01750 $image_dir."/nav_arr_L.gif");
01751 copy(ilUtil::getImagePath("nav_arr_R.gif", false, "filesystem"),
01752 $image_dir."/nav_arr_R.gif");
01753
01754 copy(ilUtil::getImagePath("download.gif", false, "filesystem"),
01755 $image_dir."/download.gif");
01756 $ilBench->stop("ExportHTML", "exportHTMLImages");
01757
01758
01759 $tpl = new ilTemplate("tpl.main.html", true, true);
01760 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
01761 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01762
01763
01764 $ilBench->start("ExportHTML", "zip");
01765 if ($a_zip_file)
01766 {
01767
01768 $date = time();
01769 $zip_file = $this->getExportDirectory("html")."/".$date."__".IL_INST_ID."__".
01770 $this->getType()."_".$this->getId().".zip";
01771
01772 ilUtil::zip($a_target_dir, $zip_file);
01773 ilUtil::delDir($a_target_dir);
01774 }
01775 $ilBench->stop("ExportHTML", "zip");
01776
01777 }
01778
01782 function exportHTMLFile($a_target_dir, $a_file_id)
01783 {
01784 $file_dir = $a_target_dir."/files/file_".$a_file_id;
01785 ilUtil::makeDir($file_dir);
01786 include_once("classes/class.ilObjFile.php");
01787 $file_obj = new ilObjFile($a_file_id, false);
01788 $source_file = $file_obj->getDirectory($file_obj->getVersion())."/".$file_obj->getFileName();
01789 if (!is_file($source_file))
01790 {
01791 $source_file = $file_obj->getDirectory()."/".$file_obj->getFileName();
01792 }
01793 copy($source_file, $file_dir."/".$file_obj->getFileName());
01794 }
01795
01799 function exportHTMLMOB($a_target_dir, &$a_lm_gui, $a_mob_id, $a_frame = "")
01800 {
01801 global $tpl;
01802
01803 $mob_dir = $a_target_dir."/mobs";
01804
01805 $source_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob_id;
01806 if (@is_dir($source_dir))
01807 {
01808 ilUtil::makeDir($mob_dir."/mm_".$a_mob_id);
01809 ilUtil::rCopy($source_dir, $mob_dir."/mm_".$a_mob_id);
01810 }
01811
01812 $tpl = new ilTemplate("tpl.main.html", true, true);
01813 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01814 $_GET["obj_type"] = "MediaObject";
01815 $_GET["mob_id"] = $a_mob_id;
01816 $_GET["frame"] = $a_frame;
01817 $_GET["cmd"] = "";
01818 $content =& $a_lm_gui->media();
01819 $file = $a_target_dir."/media_".$a_mob_id.".html";
01820
01821
01822 if (!($fp = @fopen($file,"w+")))
01823 {
01824 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01825 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01826 }
01827 chmod($file, 0770);
01828 fwrite($fp, $content);
01829 fclose($fp);
01830
01831
01832 include_once("content/classes/Media/class.ilObjMediaObject.php");
01833 $mob_obj = new ilObjMediaObject($a_mob_id);
01834 if ($mob_obj->hasFullscreenItem())
01835 {
01836 $tpl = new ilTemplate("tpl.main.html", true, true);
01837 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01838 $_GET["obj_type"] = "";
01839 $_GET["frame"] = "";
01840 $_GET["mob_id"] = $a_mob_id;
01841 $_GET["cmd"] = "fullscreen";
01842 $content =& $a_lm_gui->fullscreen();
01843 $file = $a_target_dir."/fullscreen_".$a_mob_id.".html";
01844
01845
01846 if (!($fp = @fopen($file,"w+")))
01847 {
01848 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01849 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01850 }
01851 chmod($file, 0770);
01852 fwrite($fp, $content);
01853 fclose($fp);
01854 }
01855 }
01856
01860 function exportHTMLGlossaryTerms(&$a_lm_gui, $a_target_dir)
01861 {
01862 global $ilLocator;
01863
01864 foreach($this->offline_int_links as $int_link)
01865 {
01866 $ilLocator->clearItems();
01867 if ($int_link["type"] == "git")
01868 {
01869 $tpl = new ilTemplate("tpl.main.html", true, true);
01870 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01871
01872 $_GET["obj_id"] = $int_link["id"];
01873 $_GET["frame"] = "_new";
01874 $content =& $a_lm_gui->glossary();
01875 $file = $a_target_dir."/term_".$int_link["id"].".html";
01876
01877
01878 if (!($fp = @fopen($file,"w+")))
01879 {
01880 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
01881 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
01882 }
01883 chmod($file, 0770);
01884 fwrite($fp, $content);
01885 fclose($fp);
01886
01887
01888 include_once("content/classes/class.ilGlossaryDefinition.php");
01889 $defs = ilGlossaryDefinition::getDefinitionList($int_link["id"]);
01890 foreach($defs as $def)
01891 {
01892 $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]);
01893 foreach($def_mobs as $def_mob)
01894 {
01895 $this->offline_mobs[$def_mob] = $def_mob;
01896 }
01897
01898
01899 $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $page["obj_id"]);
01900 $this->offline_files = array_merge($this->offline_files, $def_files);
01901
01902 }
01903
01904 }
01905 }
01906 }
01907
01911 function exportHTMLPages(&$a_lm_gui, $a_target_dir)
01912 {
01913 global $tpl, $ilBench, $ilLocator;
01914
01915 $pages = ilLMPageObject::getPageList($this->getId());
01916
01917 $lm_tree =& $this->getLMTree();
01918 $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg");
01919 $this->first_page_id = $first_page["child"];
01920
01921
01922 $mobs = array();
01923 $int_links = array();
01924 $this->offline_files = array();
01925
01926 foreach ($pages as $page)
01927 {
01928 $ilLocator->clearItems();
01929 $ilBench->start("ExportHTML", "exportHTMLPage");
01930 $ilBench->start("ExportHTML", "exportPageHTML");
01931 $this->exportPageHTML($a_lm_gui, $a_target_dir, $page["obj_id"]);
01932 $ilBench->stop("ExportHTML", "exportPageHTML");
01933
01934
01935 include_once("content/classes/Media/class.ilObjMediaObject.php");
01936 $pg_mobs = ilObjMediaObject::_getMobsOfObject($this->getType().":pg", $page["obj_id"]);
01937 foreach($pg_mobs as $pg_mob)
01938 {
01939 $mobs[$pg_mob] = $pg_mob;
01940 }
01941
01942
01943 $pg_links = ilInternalLink::_getTargetsOfSource($this->getType().":pg", $page["obj_id"]);
01944 $int_links = array_merge($int_links, $pg_links);
01945
01946
01947 include_once("classes/class.ilObjFile.php");
01948 $pg_files = ilObjFile::_getFilesOfObject($this->getType().":pg", $page["obj_id"]);
01949 $this->offline_files = array_merge($this->offline_files, $pg_files);
01950
01951 $ilBench->stop("ExportHTML", "exportHTMLPage");
01952 }
01953 $this->offline_mobs = $mobs;
01954 $this->offline_int_links = $int_links;
01955
01956
01957 }
01958
01962 function exportPageHTML(&$a_lm_gui, $a_target_dir, $a_lm_page_id, $a_frame = "")
01963 {
01964 global $ilias, $tpl, $ilBench;
01965
01966
01967
01968 $tpl = new ilTemplate("tpl.main.html", true, true);
01969 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01970
01971 $_GET["obj_id"] = $a_lm_page_id;
01972 $_GET["frame"] = $a_frame;
01973
01974 if ($a_frame == "")
01975 {
01976 if ($nid = ilLMObject::_lookupNID($a_lm_gui->lm->getId(), $a_lm_page_id, "pg"))
01977 {
01978 $file = $a_target_dir."/lm_pg_".$nid.".html";
01979 }
01980 else
01981 {
01982 $file = $a_target_dir."/lm_pg_".$a_lm_page_id.".html";
01983 }
01984 }
01985 else
01986 {
01987 if ($a_frame != "toc")
01988 {
01989 $file = $a_target_dir."/frame_".$a_lm_page_id."_".$a_frame.".html";
01990 }
01991 else
01992 {
01993 $file = $a_target_dir."/frame_".$a_frame.".html";
01994 }
01995 }
01996
01997
01998 if (@is_file($file))
01999 {
02000 return;
02001 }
02002
02003 $ilBench->start("ExportHTML", "layout");
02004 $ilBench->start("ExportHTML", "layout_".$a_frame);
02005 $content =& $a_lm_gui->layout("main.xml", false);
02006 $ilBench->stop("ExportHTML", "layout_".$a_frame);
02007 $ilBench->stop("ExportHTML", "layout");
02008
02009
02010 if (!($fp = @fopen($file,"w+")))
02011 {
02012 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
02013 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
02014 }
02015
02016
02017 chmod($file, 0770);
02018
02019
02020 fwrite($fp, $content);
02021
02022
02023 fclose($fp);
02024
02025 if ($this->first_page_id == $a_lm_page_id && $a_frame == "")
02026 {
02027 copy($file, $a_target_dir."/index.html");
02028 }
02029
02030
02031 $ilBench->start("ExportHTML", "getCurrentFrameSet");
02032 $frameset = $a_lm_gui->getCurrentFrameSet();
02033 $ilBench->stop("ExportHTML", "getCurrentFrameSet");
02034
02035 foreach ($frameset as $frame)
02036 {
02037 $this->exportPageHTML($a_lm_gui, $a_target_dir, $a_lm_page_id, $frame);
02038 }
02039
02040 }
02041
02048 function exportFO(&$a_xml_writer, $a_target_dir)
02049 {
02050 global $ilBench;
02051
02052
02053 $attrs = array();
02054 $attrs["xmlns:fo"] = "http://www.w3.org/1999/XSL/Format";
02055 $a_xml_writer->xmlStartTag("fo:root", $attrs);
02056
02057
02058 $attrs = array();
02059 $a_xml_writer->xmlStartTag("fo:layout-master-set", $attrs);
02060
02061
02062 $attrs = array();
02063 $attrs["master-name"] = "DinA4";
02064 $attrs["page-height"] = "29.7cm";
02065 $attrs["page-width"] = "21cm";
02066 $attrs["margin-top"] = "4cm";
02067 $attrs["margin-bottom"] = "1cm";
02068 $attrs["margin-left"] = "2.8cm";
02069 $attrs["margin-right"] = "7.3cm";
02070 $a_xml_writer->xmlStartTag("fo:simple-page-master", $attrs);
02071
02072
02073 $attrs = array();
02074 $attrs["margin-top"] = "0cm";
02075 $attrs["margin-bottom"] = "1.25cm";
02076 $a_xml_writer->xmlElement("fo:region-body", $attrs);
02077
02078
02079 $attrs = array();
02080 $attrs["extent"] = "1cm";
02081 $a_xml_writer->xmlElement("fo:region-before", $attrs);
02082
02083
02084 $attrs = array();
02085 $attrs["extent"] = "1cm";
02086 $a_xml_writer->xmlElement("fo:region-after", $attrs);
02087
02088
02089 $a_xml_writer->xmlEndTag("fo:simple-page-master");
02090
02091
02092 $a_xml_writer->xmlEndTag("fo:layout-master-set");
02093
02094
02095 $attrs = array();
02096 $attrs["master-reference"] = "DinA4";
02097 $a_xml_writer->xmlStartTag("fo:page-sequence", $attrs);
02098
02099
02100 $attrs = array();
02101 $attrs["flow-name"] = "xsl-region-body";
02102 $a_xml_writer->xmlStartTag("fo:flow", $attrs);
02103
02104
02105
02106
02107 $ilBench->start("ContentObjectExport", "exportFOStructureObjects");
02108 $this->exportFOStructureObjects($a_xml_writer, $expLog);
02109 $ilBench->stop("ContentObjectExport", "exportFOStructureObjects");
02110
02111
02112
02113 $a_xml_writer->xmlEndTag("fo:flow");
02114
02115
02116 $a_xml_writer->xmlEndTag("fo:page-sequence");
02117
02118
02119 $a_xml_writer->xmlEndTag("fo:root");
02120 }
02121
02128 function exportFOStructureObjects(&$a_xml_writer)
02129 {
02130 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
02131 foreach ($childs as $child)
02132 {
02133 if($child["type"] != "st")
02134 {
02135 continue;
02136 }
02137
02138 $structure_obj = new ilStructureObject($this, $child["obj_id"]);
02139 $structure_obj->exportFO($a_xml_writer, $expLog);
02140 unset($structure_obj);
02141 }
02142 }
02143
02144 function getXMLZip()
02145 {
02146 include_once("./content/classes/class.ilContObjectExport.php");
02147
02148 $cont_exp = new ilContObjectExport($this,'xml');
02149
02150 $export_file = $cont_exp->buildExportFile();
02151 return $export_file;
02152 }
02153
02154
02155 }
02156 ?>