function exportHTMLScoObjects($a_inst, $a_target_dir, &$expLog, $a_one_file = "") { global $ilBench; $tree = new ilTree($this->getId()); $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $tree->setTreeTablePK("slm_id"); // copy all necessary files now if ($a_one_file != "") { $this->prepareHTMLExporter($a_target_dir); // put header into file $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004"); include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php"; $sco_tpl = ilCOPageHTMLExport::getPreparedMainTemplate($sco_tpl); $sco_tpl->setCurrentBlock("js_file"); $sco_tpl->setVariable("JS_FILE", "./js/pure.js"); $sco_tpl->parseCurrentBlock(); $sco_tpl->setCurrentBlock("js_file"); $sco_tpl->setVariable("JS_FILE", "./js/question_handling.js"); $sco_tpl->parseCurrentBlock(); $sco_tpl->setCurrentBlock("head"); $sco_tpl->parseCurrentBlock(); fputs($a_one_file, $sco_tpl->get("head")); // toc include_once "./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php"; $manifestBuilder = new ilContObjectManifestBuilder($this); $manifestBuilder->buildManifest('12'); $xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/module.xsl"); $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem()); $args = array('/_xml' => $xml->organizations->organization->asXml(), '/_xsl' => $xsl); $xh = xslt_create(); $params = array("one_page" => "y"); $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params); xslt_free($xh); fputs($a_one_file, $output); } foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId()), true, 'sco') as $sco) { include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php"; $sco_folder = $a_target_dir . "/" . $sco['obj_id']; ilUtil::makeDir($sco_folder); $node = new ilSCORM2004Sco($this, $sco['obj_id']); if ($a_one_file == "") { $node->exportHTML($a_inst, $sco_folder, $expLog, $a_one_file); } else { $node->exportHTMLPageObjects($a_inst, $a_target_dir, $expLog, 'full', "sco", $a_one_file, $sco_tpl); } if ($this->getAssignedGlossary() != 0) { include_once "./Modules/Glossary/classes/class.ilObjGlossary.php"; $glos = new ilObjGlossary($this->getAssignedGlossary(), false); //$glos->exportHTML($sco_folder."/glossary", $expLog); } } // copy all necessary files now if ($a_one_file != "") { // put tail into file fputs($a_one_file, $sco_tpl->get("tail")); } }
/** * Export HTML pages of SCO */ function exportHTMLPageObjects($a_inst, $a_target_dir, &$expLog, $mode, $a_asset_type = "sco", $a_one_file = "", $a_sco_tpl = null) { global $tpl, $ilCtrl, $ilBench, $ilLog, $lng; include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php"; include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModuleGUI.php"; include_once "./Services/MetaData/classes/class.ilMD.php"; $output = ""; $tree = new ilTree($this->slm_id); $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $tree->setTreeTablePK("slm_id"); // @todo // Why is that much HTML code in an application class? // Please extract all this HTML to a tpl.<t_name>.html file and use // placeholders and the template engine to insert data. // // There copy/paste code residenting in ilSCORM2004ScoGUI. This // should be merged. // // alex, 4 Apr 09 // // if ($a_one_file == "") // { $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004"); // } // else // { // $sco_tpl = $a_sco_tpl; // } if ($mode != 'pdf' && $a_one_file == "") { include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php"; $pg_exp = new ilCOPageHTMLExport($a_target_dir); $pg_exp->getPreparedMainTemplate($sco_tpl); // init and question lang vars $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->slm_id); $sco_tpl->setCurrentBlock("init"); include_once "./Services/COPage/classes/class.ilPCQuestion.php"; $sco_tpl->setVariable("TXT_INIT_CODE", ilPCQuestion::getJSTextInitCode($lk)); $sco_tpl->parseCurrentBlock(); // (additional) style sheets needed $styles = array("./css/yahoo/container.css", "./css/question_handling.css"); foreach ($styles as $style) { $sco_tpl->setCurrentBlock("css_file"); $sco_tpl->setVariable("CSS_FILE", $style); $sco_tpl->parseCurrentBlock(); } // (additional) scripts needed $scripts = array("./js/scorm.js", "./js/pager.js", "./js/pure.js", "./js/questions_" . $this->getId() . ".js"); foreach ($scripts as $script) { $sco_tpl->setCurrentBlock("js_file"); $sco_tpl->setVariable("JS_FILE", $script); $sco_tpl->parseCurrentBlock(); } if ($a_asset_type != "entry_asset" && $a_asset_type != "final_asset") { self::renderNavigation($sco_tpl, "./images/spacer.png", $lk); } $sco_tpl->touchBlock("finish"); } // render head $sco_tpl->setCurrentBlock("head"); $sco_tpl->setVariable("SCO_TITLE", $this->getTitle()); $sco_tpl->parseCurrentBlock(); $sco_tpl->touchBlock("tail"); // meta page (meta info at SCO beginning) self::renderMetaPage($sco_tpl, $this, $a_asset_type, $mode); if ($a_one_file != "") { fputs($a_one_file, "<a name='sco" . $this->getId() . "'></a>"); fputs($a_one_file, $sco_tpl->get("meta_page")); } //notify Question Exporter of new SCO require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php'; ilQuestionExporter::indicateNewSco(); // init export (this initialises glossary template) ilSCORM2004PageGUI::initExport(); $terms = array(); $terms = $this->getGlossaryTermIds(); include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ScoGUI.php"; $pages = $tree->getSubTree($tree->getNodeData($this->getId()), true, 'page'); $sco_q_ids = array(); foreach ($pages as $page) { //echo(print_r($page)); $page_obj = new ilSCORM2004PageGUI($this->getType(), $page["obj_id"], 0, $this->slm_object->getId()); $page_obj->setPresentationTitle($page["title"]); $page_obj->setOutputMode(IL_PAGE_OFFLINE); $page_obj->setStyleId($this->slm_object->getStyleSheetId()); if (count($terms) > 1) { $page_obj->setGlossaryOverviewInfo(ilSCORM2004ScoGUI::getGlossaryOverviewId(), $this); } $page_output = $page_obj->showPage("export"); // collect media objects $mob_ids = $page_obj->getSCORM2004Page()->collectMediaObjects(false); foreach ($mob_ids as $mob_id) { $this->mob_ids[$mob_id] = $mob_id; $media_obj = new ilObjMediaObject($mob_id); if ($media_obj->hasFullscreenItem()) { $media_obj->exportMediaFullscreen($a_target_dir, $page_obj->getPageObject()); } } // collect glossary items $int_links = $page_obj->getPageObject()->getInternalLinks(true); include_once "./Services/Link/classes/class.ilInternalLink.php"; include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; if (is_array($int_links)) { foreach ($int_links as $k => $e) { // glossary link if ($e["Type"] == "GlossaryItem") { $karr = explode(":", $k); $tid = ilInternalLink::_extractObjIdOfTarget($karr[0]); $dids = ilGlossaryDefinition::getDefinitionList($tid); foreach ($dids as $did) { include_once "./Modules/Glossary/classes/class.ilGlossaryDefPage.php"; $def_pg = new ilGlossaryDefPage($did["id"]); $def_pg->buildDom(); $mob_ids = $def_pg->collectMediaObjects(false); foreach ($mob_ids as $mob_id) { $this->mob_ids[$mob_id] = $mob_id; //echo "<br>-$mob_id-"; $media_obj = new ilObjMediaObject($mob_id); if ($media_obj->hasFullscreenItem()) { $media_obj->exportMediaFullscreen($a_target_dir, $def_pg); } } include_once "./Services/COPage/classes/class.ilPCFileList.php"; $file_ids = ilPCFileList::collectFileItems($def_pg, $def_pg->getDomDoc()); foreach ($file_ids as $file_id) { $this->file_ids[$file_id] = $file_id; } } } } } //exit; // collect all file items include_once "./Services/COPage/classes/class.ilPCFileList.php"; $file_ids = ilPCFileList::collectFileItems($page_obj->getSCORM2004Page(), $page_obj->getSCORM2004Page()->getDomDoc()); foreach ($file_ids as $file_id) { $this->file_ids[$file_id] = $file_id; } if ($mode == 'pdf') { include_once "./Services/COPage/classes/class.ilPCQuestion.php"; $q_ids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]); foreach ($q_ids as $q_id) { include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php"; $q_gui =& assQuestionGUI::_getQuestionGUI("", $q_id); $q_gui->outAdditionalOutput(); $html = $q_gui->getPreview(TRUE); $page_output = preg_replace("/{{{{{Question;il__qst_" . $q_id . "}}}}}/i", $html, $page_output); } $sco_tpl->touchBlock("pdf_pg_break"); } $sco_tpl->setCurrentBlock("page"); $sco_tpl->setVariable("PAGE", $page_output); $sco_tpl->parseCurrentBlock(); // get all question ids of the sco if ($a_one_file != "") { include_once "./Services/COPage/classes/class.ilPCQuestion.php"; $q_ids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]); foreach ($q_ids as $i) { if (!in_array($i, $sco_q_ids)) { $sco_q_ids[] = $i; } } } } // glossary if ($mode != 'pdf') { $sco_tpl->setVariable("GLOSSARY_HTML", ilSCORM2004PageGUI::getGlossaryHTML($this)); } if ($a_one_file == "") { $output = $sco_tpl->get(); } else { $output = $sco_tpl->get("page"); } if ($mode == 'pdf') { $output = preg_replace("/<div class=\"ilc_page_title_PageTitle\">(.*?)<\\/div>/i", "<h2>\$1</h2>", $output); } //$output = preg_replace("/\.\/mobs\/mm_(\d+)\/([^\"]+)/i","./objects/il_".IL_INST_ID."_mob_$1/$2",$output); $output = preg_replace("/mobs\\/mm_(\\d+)\\/([^\"]+)/i", "./objects/il_" . IL_INST_ID . "_mob_\$1/\$2", $output); $output = preg_replace("/\\.\\/files\\/file_(\\d+)\\/([^\"]+)/i", "./objects/il_" . IL_INST_ID . "_file_\$1/\$2", $output); $output = preg_replace("/\\.\\/Services\\/MediaObjects\\/flash_mp3_player/i", "./players", $output); // $output = preg_replace("/\.\/".str_replace("/", "\/", ilPlayerUtil::getFlashVideoPlayerDirectory())."/i","./players",$output); $output = preg_replace("/file=..\\/..\\/..\\/.\\//i", "file=../", $output); if ($mode != 'pdf') { $output = preg_replace_callback("/href=\"&mob_id=(\\d+)&pg_id=(\\d+)\"/", array(get_class($this), 'fixFullscreeenLink'), $output); // this one is for fullscreen in glossary entries $output = preg_replace_callback("/href=\"fullscreen_(\\d+)\\.html\"/", array(get_class($this), 'fixFullscreeenLink'), $output); $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/", array(get_class($this), 'insertQuestion'), $output); // $output = preg_replace("/{/","",$output); // $output = preg_replace("/}/","",$output); $q_handling = file_get_contents('./Modules/Scorm2004/scripts/questions/question_handling.js'); fputs(fopen($a_target_dir . '/js/questions_' . $this->getId() . '.js', 'w+'), ilQuestionExporter::questionsJS() . $q_handling); copy("./Modules/Scorm2004/templates/default/question_handling.css", $a_target_dir . '/css/question_handling.css'); // hack to get the question js into the file and to display the correct answers if ($a_one_file != "") { $output = '<script type="text/javascript">' . ilQuestionExporter::questionsJS() . '</script>' . $output; if (count($sco_q_ids) > 0) { $output .= '<script type="text/javascript">'; foreach ($sco_q_ids as $i) { if ($i > 0) { $output .= "ilias.questions.showCorrectAnswers(" . $i . "); \n"; } } $output .= '</script>'; } } foreach (ilQuestionExporter::getMobs() as $mob_id) { $this->mob_ids[$mob_id] = $mob_id; } } $this->q_media = ilQuestionExporter::getFiles(); //questions export end if ($a_one_file != "") { fputs($a_one_file, $output); } else { fputs(fopen($a_target_dir . '/index.html', 'w+'), $output); } $this->exportFileItems($a_target_dir, $expLog); }
/** * 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); } } }