/** * Get head dependencies * * @param string entity * @param string target release * @param array ids * @return array array of array with keys "component", entity", "ids" */ function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids) { if ($a_entity == "pg") { // get all media objects and files of the page include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; include_once "./Modules/File/classes/class.ilObjFile.php"; $mob_ids = array(); $file_ids = array(); foreach ($a_ids as $pg_id) { $pg_id = explode(":", $pg_id); // get media objects $mids = ilObjMediaObject::_getMobsOfObject($pg_id[0] . ":pg", $pg_id[1]); foreach ($mids as $mid) { if (ilObject::_lookupType($mid) == "mob") { $mob_ids[] = $mid; } } // get files $files = ilObjFile::_getFilesOfObject($pg_id[0] . ":pg", $pg_id[1]); foreach ($files as $file) { if (ilObject::_lookupType($file) == "file") { $file_ids[] = $file; } } } return array(array("component" => "Services/MediaObjects", "entity" => "mob", "ids" => $mob_ids), array("component" => "Modules/File", "entity" => "file", "ids" => $file_ids)); } return array(); }
function getLastUpdateOfIncludedElements() { include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; include_once "./Modules/File/classes/class.ilObjFile.php"; $mobs = ilObjMediaObject::_getMobsOfObject($this->getParentType() . ":pg", $this->getId()); $files = ilObjFile::_getFilesOfObject($this->getParentType() . ":pg", $this->getId()); $objs = array_merge($mobs, $files); return ilObject::_getLastUpdateOfObjects($objs); }
/** * After page has been updated (or created) * * @param object $a_page page object * @param DOMDocument $a_domdoc dom document * @param string $a_xml xml * @param bool $a_creation true on creation, otherwise false */ static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation) { // pc filelist include_once "./Modules/File/classes/class.ilObjFile.php"; $file_ids = ilObjFile::_getFilesOfObject($a_page->getParentType() . ":pg", $a_page->getId(), 0, $a_page->getLanguage()); self::saveFileUsage($a_page, $a_domdoc); foreach ($file_ids as $file) { if (ilObject::_exists($file)) { $file_obj = new ilObjFile($file, false); $usages = $file_obj->getUsages(); if (count($usages) == 0) { if ($file_obj->getMode() == "filelist") { $file_obj->delete(); } } } } }
/** * Collect page elements (that need to be exported separately) * * @param string $a_pg_type page type * @param int $a_pg_id page id */ function collectPageElements($a_type, $a_id) { // collect media objects $pg_mobs = ilObjMediaObject::_getMobsOfObject($a_type, $a_id); foreach ($pg_mobs as $pg_mob) { $this->mobs[$pg_mob] = $pg_mob; } // collect all files include_once "./Modules/File/classes/class.ilObjFile.php"; $files = ilObjFile::_getFilesOfObject($a_type, $a_id); foreach ($files as $f) { $this->files[$f] = $f; } $skill_tree = $ws_tree = null; $pcs = ilPageContentUsage::getUsagesOfPage($a_id, $a_type); foreach ($pcs as $pc) { // skils if ($pc["type"] == "skmg") { $skill_id = $pc["id"]; // get user id from portfolio page include_once "Services/Portfolio/classes/class.ilPortfolioPage.php"; $page = new ilPortfolioPage(0, $a_id); $user_id = $page->create_user; // we only need 1 instance each if (!$skill_tree) { include_once "Services/Skill/classes/class.ilSkillTree.php"; $skill_tree = new ilSkillTree(); include_once "Services/Skill/classes/class.ilPersonalSkill.php"; include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php"; $ws_tree = new ilWorkspaceTree($user_id); } // walk skill tree $b_skills = ilSkillTreeNode::getSkillTreeNodes($skill_id, true); foreach ($b_skills as $bs) { $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]); $level_data = $skill->getLevelData(); foreach ($level_data as $k => $v) { // get assigned materials from personal skill $mat = ilPersonalSkill::getAssignedMaterial($user_id, $bs["tref"], $v["id"]); if (sizeof($mat)) { foreach ($mat as $item) { $wsp_id = $item["wsp_id"]; $obj_id = $ws_tree->lookupObjectId($wsp_id); // all possible material types for now switch (ilObject::_lookupType($obj_id)) { case "file": $this->files[$obj_id] = $obj_id; break; case "tstv": include_once "Modules/Test/classes/class.ilObjTestVerification.php"; $obj = new ilObjTestVerification($obj_id, false); $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename()); break; case "excv": include_once "Modules/Exercise/classes/class.ilObjExerciseVerification.php"; $obj = new ilObjExerciseVerification($obj_id, false); $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename()); break; } } } } } } } }
/** * export all pages of learning module to html file */ function exportHTMLPages(&$a_lm_gui, $a_target_dir) { global $tpl, $ilBench, $ilLocator; $pages = ilLMPageObject::getPageList($this->getId()); $lm_tree =& $this->getLMTree(); $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg"); $this->first_page_id = $first_page["child"]; // iterate all learning module pages $mobs = array(); $int_links = array(); $this->offline_files = array(); include_once "./Services/COPage/classes/class.ilPageContentUsage.php"; include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; // get html export id mapping $lm_set = new ilSetting("lm"); $exp_id_map = array(); if ($lm_set->get("html_export_ids")) { foreach ($pages as $page) { $exp_id = ilLMPageObject::getExportId($this->getId(), $page["obj_id"]); if (trim($exp_id) != "") { $exp_id_map[$page["obj_id"]] = trim($exp_id); } } } //exit; reset($pages); foreach ($pages as $page) { if (ilLMPage::_exists($this->getType(), $page["obj_id"])) { $ilLocator->clearItems(); $ilBench->start("ExportHTML", "exportHTMLPage"); $ilBench->start("ExportHTML", "exportPageHTML"); $this->exportPageHTML($a_lm_gui, $a_target_dir, $page["obj_id"], "", $exp_id_map); $ilBench->stop("ExportHTML", "exportPageHTML"); // get all snippets of page $pcs = ilPageContentUsage::getUsagesOfPage($page["obj_id"], $this->getType() . ":pg"); foreach ($pcs as $pc) { if ($pc["type"] == "incl") { $incl_mobs = ilObjMediaObject::_getMobsOfObject("mep:pg", $pc["id"]); foreach ($incl_mobs as $incl_mob) { $mobs[$incl_mob] = $incl_mob; } } } // get all media objects of page $pg_mobs = ilObjMediaObject::_getMobsOfObject($this->getType() . ":pg", $page["obj_id"]); foreach ($pg_mobs as $pg_mob) { $mobs[$pg_mob] = $pg_mob; } // get all internal links of page $pg_links = ilInternalLink::_getTargetsOfSource($this->getType() . ":pg", $page["obj_id"]); $int_links = array_merge($int_links, $pg_links); // get all files of page include_once "./Modules/File/classes/class.ilObjFile.php"; $pg_files = ilObjFile::_getFilesOfObject($this->getType() . ":pg", $page["obj_id"]); $this->offline_files = array_merge($this->offline_files, $pg_files); $ilBench->stop("ExportHTML", "exportHTMLPage"); } } $this->offline_mobs = $mobs; $this->offline_int_links = $int_links; }
/** * export glossary terms */ function exportHTMLGlossaryTerms(&$a_glo_gui, $a_target_dir) { global $ilUser; include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php"; $copage_export = new ilCOPageHTMLExport($a_target_dir); $copage_export->exportSupportScripts(); // index.html file $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true); $style_name = $ilUser->prefs["style"] . ".css"; $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET", "./" . $style_name); $a_glo_gui->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html"); $a_glo_gui->tpl->setTitle($this->getTitle()); $content = $a_glo_gui->listTerms(); $file = $a_target_dir . "/index.html"; // open file if (!($fp = @fopen($file, "w+"))) { die("<b>Error</b>: Could not open \"" . $file . "\" for writing" . " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />"); } chmod($file, 0770); fwrite($fp, $content); fclose($fp); $terms = $this->getTermList(); $this->offline_mobs = array(); $this->offline_files = array(); foreach ($terms as $term) { $a_glo_gui->tpl = new ilTemplate("tpl.main.html", true, true); $a_glo_gui->tpl = $copage_export->getPreparedMainTemplate(); //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html"); // set style $style_name = $ilUser->prefs["style"] . ".css"; $a_glo_gui->tpl->setVariable("LOCATION_STYLESHEET", "./" . $style_name); $_GET["term_id"] = $term["id"]; $_GET["frame"] = "_blank"; $content =& $a_glo_gui->listDefinitions($_GET["ref_id"], $term["id"], false); $file = $a_target_dir . "/term_" . $term["id"] . ".html"; // open file if (!($fp = @fopen($file, "w+"))) { die("<b>Error</b>: Could not open \"" . $file . "\" for writing" . " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />"); } chmod($file, 0770); fwrite($fp, $content); fclose($fp); // store linked/embedded media objects of glosssary term include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; $defs = ilGlossaryDefinition::getDefinitionList($term["id"]); foreach ($defs as $def) { $def_mobs = ilObjMediaObject::_getMobsOfObject("gdf:pg", $def["id"]); foreach ($def_mobs as $def_mob) { $this->offline_mobs[$def_mob] = $def_mob; } // get all files of page include_once "./Modules/File/classes/class.ilObjFile.php"; $def_files = ilObjFile::_getFilesOfObject("gdf:pg", $def["id"]); $this->offline_files = array_merge($this->offline_files, $def_files); } } }