/**
  * export scorm package
  */
 function exportSCORM($a_target_dir, $log)
 {
     ilUtil::delDir($a_target_dir);
     ilUtil::makeDir($a_target_dir);
     //ilUtil::makeDir($a_target_dir."/res");
     // export everything to html
     $this->exportHTML($a_target_dir . "/res", $log, false, "scorm");
     // build manifest file
     include "./Modules/LearningModule/classes/class.ilContObjectManifestBuilder.php";
     $man_builder = new ilContObjectManifestBuilder($this);
     $man_builder->buildManifest();
     $man_builder->dump($a_target_dir);
     // copy scorm 1.2 schema definitions
     copy("Modules/LearningModule/scorm_xsd/adlcp_rootv1p2.xsd", $a_target_dir . "/adlcp_rootv1p2.xsd");
     copy("Modules/LearningModule/scorm_xsd/imscp_rootv1p1p2.xsd", $a_target_dir . "/imscp_rootv1p1p2.xsd");
     copy("Modules/LearningModule/scorm_xsd/imsmd_rootv1p2p1.xsd", $a_target_dir . "/imsmd_rootv1p2p1.xsd");
     copy("Modules/LearningModule/scorm_xsd/ims_xml.xsd", $a_target_dir . "/ims_xml.xsd");
     // zip it all
     $date = time();
     $zip_file = $a_target_dir . "/" . $date . "__" . IL_INST_ID . "__" . $this->getType() . "_" . $this->getId() . ".zip";
     //echo "zip-".$a_target_dir."-to-".$zip_file;
     ilUtil::zip(array($a_target_dir . "/res", $a_target_dir . "/imsmanifest.xml", $a_target_dir . "/adlcp_rootv1p2.xsd", $a_target_dir . "/imscp_rootv1p1p2.xsd", $a_target_dir . "/ims_xml.xsd", $a_target_dir . "/imsmd_rootv1p2p1.xsd"), $zip_file);
     $dest_file = $this->getExportDirectory("scorm") . "/" . $date . "__" . IL_INST_ID . "__" . $this->getType() . "_" . $this->getId() . ".zip";
     rename($zip_file, $dest_file);
     ilUtil::delDir($a_target_dir);
 }
 /**
  * Export (authoring) scorm package
  */
 function exportScorm($a_inst, $a_target_dir, $ver, &$expLog)
 {
     $a_xml_writer = new ilXmlWriter();
     // export metadata
     $this->exportXMLMetaData($a_xml_writer);
     $metadata_xml = $a_xml_writer->xmlDumpMem(false);
     $a_xml_writer->_XmlWriter;
     $xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/metadata.xsl");
     $args = array('/_xml' => $metadata_xml, '/_xsl' => $xsl);
     $xh = xslt_create();
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
     xslt_free($xh);
     file_put_contents($a_target_dir . '/indexMD.xml', $output);
     // export glossary
     if ($this->getAssignedGlossary() != 0) {
         ilUtil::makeDir($a_target_dir . "/glossary");
         include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
         include_once "./Modules/Glossary/classes/class.ilGlossaryExport.php";
         $glo_xml_writer = new ilXmlWriter();
         $glo_xml_writer->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
         // set xml header
         $glo_xml_writer->xmlHeader();
         $glos = new ilObjGlossary($this->getAssignedGlossary(), false);
         //$glos->exportHTML($a_target_dir."/glossary", $expLog);
         $glos_export = new ilGlossaryExport($glos, "xml");
         $glos->exportXML($glo_xml_writer, $glos_export->getInstId(), $a_target_dir . "/glossary", $expLog);
         $glo_xml_writer->xmlDumpFile($a_target_dir . "/glossary/glossary.xml");
         $glo_xml_writer->_XmlWriter;
     }
     $a_xml_writer = new ilXmlWriter();
     // set dtd definition
     $a_xml_writer->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
     // set generated comment
     $a_xml_writer->xmlSetGenCmt("Export of ILIAS Content Module " . $this->getId() . " of installation " . $a_inst . ".");
     // set xml header
     $a_xml_writer->xmlHeader();
     global $ilBench;
     $a_xml_writer->xmlStartTag("ContentObject", array("Type" => "SCORM2004LearningModule"));
     // MetaData
     $this->exportXMLMetaData($a_xml_writer);
     $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
     // SCO Objects
     $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Sco Objects");
     $this->exportXMLScoObjects($a_inst, $a_target_dir, $ver, $expLog);
     $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Sco Objects");
     $a_xml_writer->xmlEndTag("ContentObject");
     $a_xml_writer->xmlDumpFile($a_target_dir . '/index.xml', false);
     if ($ver == "2004 4th") {
         $revision = "4th";
         $ver = "2004";
     }
     if ($ver == "2004 3rd") {
         $revision = "3rd";
         $ver = "2004";
     }
     // add content css (note: this is also done per item)
     $css_dir = $a_target_dir . "/ilias_css_4_2";
     ilUtil::makeDir($css_dir);
     include_once "./Modules/Scorm2004/classes/class.ilScormExportUtil.php";
     ilScormExportUtil::exportContentCSS($this, $css_dir);
     // add manifest
     include_once "./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php";
     $manifestBuilder = new ilContObjectManifestBuilder($this);
     $manifestBuilder->buildManifest($ver, $revision);
     $manifestBuilder->dump($a_target_dir);
     $xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/module.xsl");
     $args = array('/_xml' => file_get_contents($a_target_dir . "/imsmanifest.xml"), '/_xsl' => $xsl);
     $xh = xslt_create();
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
     xslt_free($xh);
     fputs(fopen($a_target_dir . '/index.html', 'w+'), $output);
     // copy xsd files to target
     switch ($ver) {
         case "2004":
             if ($revision == "3rd") {
                 ilUtil::rCopy('./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004', $a_target_dir, false);
             }
             if ($revision == "4th") {
                 ilUtil::rCopy('./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004_4th', $a_target_dir, false);
             }
             break;
         case "12":
             ilUtil::rCopy('./Modules/Scorm2004/templates/xsd/adlcp_120_export_12', $a_target_dir, false);
             break;
     }
     $a_xml_writer->_XmlWriter;
 }