/**
  * Create resource entries for the learning module "PKG" and all SCOS and Assets
  */
 function writeResources()
 {
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php";
     $tree = new ilSCORM2004Tree($this->cont_obj->getId());
     //$tree = new ilTree($this->cont_obj->getId());
     //$tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     //$tree->setTreeTablePK("slm_id");
     foreach ($tree->getSubTree($tree->getNodeData($tree->root_id), true, array('sco', 'ass')) as $obj) {
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . "_ref";
         $attrs["type"] = "webcontent";
         if ($obj['type'] == "sco") {
             $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "sco";
         } else {
             $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         }
         $attrs["href"] = "./" . $obj['obj_id'] . "/index.html";
         $this->writer->xmlStartTag("resource", $attrs, "");
         $this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'ITSELF'), "");
         $this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'OBJECTS'), "");
         $this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'RESOURCES'), "");
         $this->writer->xmlElement("dependency", array("identifierref" => "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'FLAVOUR'), "");
         $this->writer->xmlEndTag("resource");
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'ITSELF';
         $attrs["type"] = "webcontent";
         $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         $this->writer->xmlStartTag("resource", $attrs, "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/index.xml"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/ilias_co_3_7.dtd"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/index.html"), "");
         $this->writer->xmlEndTag("resource");
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'RESOURCES';
         $attrs["type"] = "webcontent";
         $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         $this->writer->xmlStartTag("resource", $attrs, "");
         $this->writer->xmlEndTag("resource");
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'FLAVOUR';
         $attrs["type"] = "webcontent";
         $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         $this->writer->xmlStartTag("resource", $attrs, "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/index.xml"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/sco.xsl"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/css/system.css"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/css/style.css"), "");
         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/js/scorm.js"), "");
         $this->writer->xmlEndTag("resource");
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'] . 'OBJECTS';
         $attrs["type"] = "webcontent";
         $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         $this->writer->xmlStartTag("resource", $attrs, "");
         include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
         $active_css = ilObjStyleSheet::getContentStylePath($this->cont_obj->getStyleSheetId());
         $active_css = split(@'\\?', $active_css, 2);
         $css = fread(fopen($active_css[0], 'r'), filesize($active_css[0]));
         preg_match_all("/url\\(([^\\)]*)\\)/", $css, $css_files);
         $css_files = array_unique($css_files[1]);
         $currdir = getcwd();
         chdir(dirname($active_css[0]));
         foreach ($css_files as $fileref) {
             if (file_exists($fileref)) {
                 $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/images/" . basename($fileref)), "");
             }
         }
         chdir($currdir);
         include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php";
         $pagetree = new ilSCORM2004Tree($this->cont_obj->getId());
         //$pagetree = new ilTree($this->cont_obj->getId());
         //$pagetree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
         //$pagetree->setTreeTablePK("slm_id");
         foreach ($pagetree->getSubTree($pagetree->getNodeData($obj['obj_id']), false, 'page') as $page) {
             $page_obj = new ilSCORM2004Page($page);
             $page_obj->buildDom();
             $mob_ids = $page_obj->collectMediaObjects(false);
             foreach ($mob_ids as $mob_id) {
                 if ($mob_id > 0 && ilObject::_exists($mob_id)) {
                     $media_obj = new ilObjMediaObject($mob_id);
                     $media_obj = $media_obj->getMediaItem("Standard");
                     if ($media_obj != null && $media_obj->getLocationType() == "LocalFile") {
                         $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/objects/il_" . IL_INST_ID . "_mob_" . $mob_id . "/" . rawurlencode($media_obj->getLocation())), "");
                     }
                 }
             }
             $file_ids = $page_obj->collectFileItems();
             foreach ($file_ids as $file_id) {
                 if (ilObject::_lookupType($file_id) == "file") {
                     $file_obj = new ilObjFile($file_id, false);
                     $this->writer->xmlElement("file", array("href" => "./" . $obj['obj_id'] . "/objects/il_" . IL_INST_ID . "_file_" . $file_id . "/" . rawurlencode($file_obj->filename)), "");
                 }
             }
             unset($page_obj);
         }
         $this->writer->xmlEndTag("resource");
     }
     if ($this->version == "2004") {
         $attrs = array();
         $attrs["identifier"] = "PKG";
         $attrs["type"] = "webcontent";
         $attrs[$this->version == "2004" ? "adlcp:scormType" : "adlcp:scormtype"] = "asset";
         $this->writer->xmlStartTag("resource", $attrs, "");
         $xsd_files = array('adlcp_v1p3.xsd', 'adlseq_v1p3.xsd', 'imsss_v1p0.xsd', 'adlnav_v1p3.xsd', 'adlnav_v1p3.xsd', 'imscp_v1p1.xsd', 'imsmanifest.xml', 'imsss_v1p0auxresource.xsd', 'imsss_v1p0control.xsd', 'imsss_v1p0delivery.xsd', 'imsss_v1p0limit.xsd', 'imsss_v1p0objective.xsd', 'imsss_v1p0random.xsd', 'imsss_v1p0rollup.xsd', 'imsss_v1p0seqrule.xsd', 'imsss_v1p0util.xsd', 'xml.xsd', 'index.html');
         foreach ($xsd_files as $xsd_file) {
             $attrs = array();
             $attrs["href"] = $xsd_file;
             $this->writer->xmlElement("file", $attrs, "");
         }
         $this->writer->xmlEndTag("resource");
     }
 }
Пример #2
0
 function getExportResources()
 {
     $export_files = array();
     require_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     include_once "./Modules/File/classes/class.ilObjFile.php";
     $tree = new ilTree($this->slm_object->getId());
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
         $page_obj = new ilSCORM2004Page($page["obj_id"]);
         $page_obj->buildDom();
         $mob_ids = $page_obj->collectMediaObjects(false);
         foreach ($mob_ids as $mob_id) {
             if ($mob_id > 0 && ilObject::_exists($mob_id)) {
                 $path = ilObjMediaObject::_lookupStandardItemPath($mob_id, false, false);
                 $media_obj = new ilObjMediaObject($mob_id);
                 $export_files[$i]["date"] = $media_obj->getCreateDate();
                 $export_files[$i]["size"] = @filesize($path);
                 // could be remote, e.g. youtube video
                 $export_files[$i]["file"] = $media_obj->getTitle();
                 $export_files[$i]["type"] = $media_obj->getDescription();
                 $export_files[$i]["path"] = $path;
                 $this->ctrl->setParameter($this, "resource", rawurlencode(ilObjMediaObject::_lookupStandardItemPath($mob_id, false, false)));
                 $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this, "downloadResource");
                 $i++;
             }
         }
         include_once "./Services/COPage/classes/class.ilPCFileList.php";
         $file_ids = ilPCFileList::collectFileItems($page_obj, $page_obj->getDomDoc());
         foreach ($file_ids as $file_id) {
             $file_obj = new ilObjFile($file_id, false);
             $export_files[$i]["date"] = $file_obj->getCreateDate();
             $export_files[$i]["size"] = $file_obj->getFileSize();
             $export_files[$i]["file"] = $file_obj->getFileName();
             $export_files[$i]["type"] = $file_obj->getFileType();
             $export_files[$i]["file_id"] = $file_id;
             $this->ctrl->setParameter($this, "file_id", $file_id);
             $export_files[$i]["link"] = $this->ctrl->getLinkTarget($this, "downloadFile", "");
             $i++;
         }
         unset($page_obj);
     }
     return $export_files;
 }