function preview() { global $ilias; $export = new ilScorm2004Export($this->object, 'SCORM 2004 3rd'); $zipfile = $export->buildExportFile(); $zipPathinfo = pathinfo($zipfile); $file_path = $this->object->getDataDirectory() . "/" . $zipPathinfo["basename"]; copy($zipfile, $file_path); unlink($zipfile); ilUtil::unzip($file_path, true); ilUtil::renameExecutables($this->object->getDataDirectory()); unlink($file_path); include_once "./Modules/Scorm2004/classes/ilSCORM13Package.php"; $rte_pkg = new ilSCORM13Package(); $rte_pkg->il_import($this->object->getDataDirectory(), $this->object->getId(), $ilias, false, true); //increase module version is it necessary? //$this->object->setModuleVersion($module_version+1); //$this->object->update(); //redirect to view player ilUtil::redirect("ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=" . $this->object->getRefID() . "&envEditor=1"); }
/** * read manifest file * @access public */ function readObject() { global $ilias, $lng, $ilDB; //check for MYSQL 4.1 and json_encode,json_decode if (!function_exists('json_encode') || !function_exists('json_decode') || $ilDB->getDBType() == 'mysql' && !$ilDB->isMysql4_1OrHigher()) { $ilias->raiseError($lng->txt('scplayer_phpmysqlcheck'), $ilias->error_obj->WARNING); } $needs_convert = false; // convert imsmanifest.xml file in iso to utf8 if needed $manifest_file = $this->getDataDirectory() . "/imsmanifest.xml"; // check if manifestfile exists and space left on device... $check_for_manifest_file = is_file($manifest_file); // if no manifestfile if (!$check_for_manifest_file) { $this->ilias->raiseError($this->lng->txt("Manifestfile {$manifest_file} not found!"), $this->ilias->error_obj->MESSAGE); return; } if ($check_for_manifest_file) { $manifest_file_array = file($manifest_file); foreach ($manifest_file_array as $mfa) { // if (seems_not_utf8($mfa)) if (@iconv('UTF-8', 'UTF-8', $mfa) != $mfa) { $needs_convert = true; break; } } // to copy the file we need some extraspace, counted in bytes *2 ... we need 2 copies.... $estimated_manifest_filesize = filesize($manifest_file) * 2; // i deactivated this, because it seems to fail on some windows systems (see bug #1795) //$check_disc_free = disk_free_space($this->getDataDirectory()) - $estimated_manifest_filesize; $check_disc_free = 2; } // if $manifest_file needs to be converted to UTF8 if ($needs_convert) { // if file exists and enough space left on device if ($check_for_manifest_file && $check_disc_free > 1) { // create backup from original if (!copy($manifest_file, $manifest_file . ".old")) { echo "Failed to copy {$manifest_file}...<br>\n"; } // read backupfile, convert each line to utf8, write line to new file // php < 4.3 style $f_write_handler = fopen($manifest_file . ".new", "w"); $f_read_handler = fopen($manifest_file . ".old", "r"); while (!feof($f_read_handler)) { $zeile = fgets($f_read_handler); //echo mb_detect_encoding($zeile); fputs($f_write_handler, utf8_encode($zeile)); } fclose($f_read_handler); fclose($f_write_handler); // copy new utf8-file to imsmanifest.xml if (!copy($manifest_file . ".new", $manifest_file)) { echo "Failed to copy {$manifest_file}...<br>\n"; } if (!@is_file($manifest_file)) { $this->ilias->raiseError($this->lng->txt("cont_no_manifest"), $this->ilias->error_obj->WARNING); } } else { // gives out the specific error if (!($check_disc_free > 1)) { $this->ilias->raiseError($this->lng->txt("Not enough space left on device!"), $this->ilias->error_obj->MESSAGE); } return; } } else { // check whether file starts with BOM (that confuses some sax parsers, see bug #1795) $hmani = fopen($manifest_file, "r"); $start = fread($hmani, 3); if (strtolower(bin2hex($start)) == "efbbbf") { $f_write_handler = fopen($manifest_file . ".new", "w"); while (!feof($hmani)) { $n = fread($hmani, 900); fputs($f_write_handler, $n); } fclose($f_write_handler); fclose($hmani); // copy new utf8-file to imsmanifest.xml if (!copy($manifest_file . ".new", $manifest_file)) { echo "Failed to copy {$manifest_file}...<br>\n"; } } else { fclose($hmani); } } //validate the XML-Files in the SCORM-Package if ($_POST["validate"] == "y") { if (!$this->validate($this->getDataDirectory())) { $this->ilias->raiseError("<b>Validation Error(s):</b><br>" . $this->getValidationSummary(), $this->ilias->error_obj->WARNING); } } //check for SCORM 1.2 $this->convert_1_2_to_2004($manifest_file); // start SCORM 2004 package parser/importer include_once "./Modules/Scorm2004/classes/ilSCORM13Package.php"; $newPack = new ilSCORM13Package(); if ($this->getEditable()) { return $newPack->il_importLM($this, $this->getDataDirectory(), $this->getImportSequencing()); } else { return $newPack->il_import($this->getDataDirectory(), $this->getId(), $this->ilias, $_POST["validate"]); } }