function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping) { // see ilStyleExporter::getXmlRepresentation() if (preg_match("/<StyleSheetExport><ImagePath>(.+)<\\/ImagePath>/", $a_xml, $hits)) { $path = $hits[1]; $a_xml = str_replace($hits[0], "", $a_xml); $a_xml = str_replace("</StyleSheetExport>", "", $a_xml); } // temp xml-file $tmp_file = $this->getImportDirectory() . "/sty_" . $a_id . ".xml"; file_put_contents($tmp_file, $a_xml); include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $style = new ilObjStyleSheet(); $style->createFromXMLFile($tmp_file); $new_id = $style->getId(); unlink($tmp_file); // images if ($path) { $source = $this->getImportDirectory() . "/" . $path; if (is_dir($source)) { $target = $style->getImagesDirectory(); if (!is_dir($target)) { ilUtil::makeDirParents($target); } ilUtil::rCopy($source, $target); } } $a_mapping->addMapping("Services/Style", "sty", $a_id, $new_id); }
public function getXmlRepresentation($a_entity, $a_schema_version, $a_id) { include_once "Services/Style/classes/class.ilObjStyleSheet.php"; $style = new ilObjStyleSheet($a_id, false); // images $target = $this->getAbsoluteExportDirectory(); if ($target && !is_dir($target)) { ilUtil::makeDirParents($target); } ilUtil::rCopy($style->getImagesDirectory(), $target); return "<StyleSheetExport>" . "<ImagePath>" . $this->getRelativeExportDirectory() . "</ImagePath>" . $style->getXML() . "</StyleSheetExport>"; }
/** * 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; }
/** * export files of object to target directory * note: target directory must be the export target directory, * "/objects/il_<inst>_file_<file_id>/..." will be appended to this directory * * @param string $a_target_dir target directory */ function export($a_target_dir) { $subdir = "il_" . IL_INST_ID . "_file_" . $this->getId(); ilUtil::makeDir($a_target_dir . "/objects/" . $subdir); $filedir = $this->getDirectory($this->getVersion()); if (@(!is_dir($filedir))) { $filedir = $this->getDirectory(); } ilUtil::rCopy($filedir, $a_target_dir . "/objects/" . $subdir); }
/** * Copies content of a directory $a_sdir recursively to a directory $a_tdir * @param string $a_sdir source directory * @param string $a_tdir target directory * @param boolean $preserveTimeAttributes if true, ctime will be kept. * * @return boolean TRUE for sucess, FALSE otherwise * @access public * @static * */ public static function rCopy($a_sdir, $a_tdir, $preserveTimeAttributes = false) { // check if arguments are directories if (!@is_dir($a_sdir) or !@is_dir($a_tdir)) { return FALSE; } // read a_sdir, copy files and copy directories recursively $dir = opendir($a_sdir); while ($file = readdir($dir)) { if ($file != "." and $file != "..") { // directories if (@is_dir($a_sdir . "/" . $file)) { if (!@is_dir($a_tdir . "/" . $file)) { if (!ilUtil::makeDir($a_tdir . "/" . $file)) { return FALSE; } //chmod($a_tdir."/".$file, 0775); } if (!ilUtil::rCopy($a_sdir . "/" . $file, $a_tdir . "/" . $file)) { return FALSE; } } // files if (@is_file($a_sdir . "/" . $file)) { if (!copy($a_sdir . "/" . $file, $a_tdir . "/" . $file)) { return FALSE; } if ($preserveTimeAttributes) { touch($a_tdir . "/" . $file, filectime($a_sdir . "/" . $file)); } } } } return TRUE; }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { //echo $a_entity; //var_dump($a_rec); switch ($a_entity) { case "htlm": include_once "./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php"; if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) { $newObj = ilObjectFactory::getInstanceByObjId($new_id, false); } else { $newObj = new ilObjFileBasedLM(); $newObj->setType("htlm"); $newObj->create(true); } $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); $newObj->setStartFile($a_rec["StartFile"], true); $newObj->update(); $this->current_obj = $newObj; $dir = str_replace("..", "", $a_rec["Dir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = $newObj->getDataDirectory(); ilUtil::rCopy($source_dir, $target_dir); } $a_mapping->addMapping("Modules/HTMLLearningModule", "htlm", $a_rec["Id"], $newObj->getId()); $a_mapping->addMapping("Services/MetaData", "md", $a_rec["Id"] . ":0:htlm", $newObj->getId() . ":0:htlm"); break; } }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { //echo $a_entity; //var_dump($a_rec); switch ($a_entity) { case "mob": //var_dump($a_rec); include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $newObj = new ilObjMediaObject(); $newObj->setType("mob"); $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); $newObj->create(); $newObj->createDirectory(); ilObjMediaObject::_createThumbnailDirectory($newObj->getId()); $this->current_mob = $newObj; $dir = str_replace("..", "", $a_rec["Dir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = $dir = ilObjMediaObject::_getDirectory($newObj->getId()); ilUtil::rCopy($source_dir, $target_dir); } $a_mapping->addMapping("Services/MediaObjects", "mob", $a_rec["Id"], $newObj->getId()); //echo "<br>++add++"."0:".$a_rec["Id"].":mob+0:".$newObj->getId().":mob"."+"; $a_mapping->addMapping("Services/MetaData", "md", "0:" . $a_rec["Id"] . ":mob", "0:" . $newObj->getId() . ":mob"); break; case "mob_media_item": // determine parent mob include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]); if (is_object($this->current_mob) && $this->current_mob->getId() == $mob_id) { $mob = $this->current_mob; } else { $mob = new ilObjMediaObject($mob_id); } include_once "./Services/MediaObjects/classes/class.ilMediaItem.php"; $newObj = new ilMediaItem(); $newObj->setMobId($mob_id); $newObj->setWidth($a_rec["Width"]); $newObj->setHeight($a_rec["Height"]); $newObj->setCaption($a_rec["Caption"]); $newObj->setNr($a_rec["Nr"]); $newObj->setPurpose($a_rec["Purpose"]); $newObj->setLocation($a_rec["Location"]); $newObj->setLocationType($a_rec["LocationType"]); $newObj->setFormat($a_rec["Format"]); $newObj->setTextRepresentation($a_rec["TextRepresentation"]); $newObj->create(); $this->current_media_item = $newObj; $a_mapping->addMapping("Services/MediaObjects", "mob_media_item", $a_rec["Id"], $newObj->getId()); break; case "mob_mi_parameter": // get media item include_once "./Services/MediaObjects/classes/class.ilMediaItem.php"; $med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]); if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) { $med = $this->current_media_item; } else { $med = new ilMediaItem($med_id); } $med->writeParameter($a_rec["Name"], $a_rec["Value"]); break; case "mob_mi_map_area": // get media item include_once "./Services/MediaObjects/classes/class.ilMediaItem.php"; $med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]); if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) { $med = $this->current_media_item; } else { $med = new ilMediaItem($med_id); } include_once "./Services/MediaObjects/classes/class.ilMapArea.php"; $map_area = new ilMapArea(); $map_area->setItemId($med_id); $map_area->setNr($a_rec["Nr"]); $map_area->setShape($a_rec["Shape"]); $map_area->setCoords($a_rec["Coords"]); $map_area->setLinkType($a_rec["LinkType"]); $map_area->setTitle($a_rec["Title"]); $map_area->setHref($a_rec["Href"]); $map_area->setTarget($a_rec["Target"]); $map_area->setType($a_rec["Type"]); $map_area->setTargetFrame($a_rec["TargetFrame"]); $map_area->setHighlightMode($a_rec["HighlightMode"]); $map_area->setHighlightClass($a_rec["HighlightClass"]); $map_area->create(); break; } }
/** * Clone source client into current client * @param array form data * @return boolean */ function cloneFromSource($source_id) { // Getting source and targets $source = new ilClient($source_id, $this->db_connections); $source->init(); $target = $this->client; // ************************************************ // ** COPY FILES // Cleaning up datadir if (!ilUtil::delDir($target->getDataDir())) { $this->error = "Could not delete data dir {$target->getDataDir}()"; //return false; } // Create empty datadir if (!ilUtil::makeDir($target->getDataDir())) { $this->error = "could_not_create_base_data_dir :" . $target->getDataDir(); return false; } // Copying datadir if (!ilUtil::rCopy($source->getDataDir(), $target->getDataDir())) { $this->error = "clone_datadircopyfail"; $target->ini->write(); return false; } // Cleaning up Webspacedir if (!ilUtil::delDir($target->getWebspaceDir())) { $this->error = "Could not delete webspace dir {$target->getWebspaceDir}()"; //return false; } // Create empty Webspacedir if (!ilUtil::makeDir($target->getWebspaceDir())) { $this->error = "could_not_create_base_webspace_dir :" . $target->getWebspaceDir(); return false; } // Copying Webspacedir if (!ilUtil::rCopy($source->getWebspaceDir(), $target->getWebspaceDir())) { $this->error = "clone_websipacedircopyfail"; $target->ini->write(); return false; } // Restore ini file $target->ini->write(); // ************************************************ // ** COPY DATABASE $source->connect(); if (!$source->db) { $this->error = "Source database connection failed."; return false; } $target->connect(); if (!$target->db) { $this->error = "Target database connection failed."; return false; } $source->connect(); $srcTables = $source->db->query("SHOW TABLES"); $target->connect(); // drop all tables of the target db $tarTables = $target->db->query("SHOW TABLES"); foreach ($tarTables->fetchAll() as $cTable) { $target->db->query("DROP TABLE IF EXISTS " . $cTable[0]); } foreach ($srcTables->fetchAll() as $cTable) { $drop = $target->db->query("DROP TABLE IF EXISTS " . $cTable[0]); $create = $target->db->query("CREATE TABLE " . $cTable[0] . " LIKE " . $source->getDbName() . "." . $cTable[0]); if (!$create) { $error = true; } $insert = $target->db->query("INSERT INTO " . $cTable[0] . " SELECT * FROM " . $source->getDbName() . "." . $cTable[0]); } return true; }
/** * Clone assignments of exercise * * @param * @return */ function cloneAssignmentsOfExercise($a_old_exc_id, $a_new_exc_id) { $ass_data = ilExAssignment::getAssignmentDataOfExercise($a_old_exc_id); foreach ($ass_data as $d) { // clone assignment $new_ass = new ilExAssignment(); $new_ass->setExerciseId($a_new_exc_id); $new_ass->setTitle($d["title"]); $new_ass->setDeadline($d["deadline"]); $new_ass->setInstruction($d["instruction"]); $new_ass->setMandatory($d["mandatory"]); $new_ass->setOrderNr($d["order_val"]); $new_ass->setStartTime($d["start_time"]); $new_ass->setType($d["type"]); $new_ass->setPeerReview($d["peer"]); $new_ass->setPeerReviewMin($d["peer_min"]); $new_ass->setPeerReviewDeadline($d["peer_dl"]); $new_ass->setFeedbackFile($d["fb_file"]); $new_ass->setFeedbackCron($d["fb_cron"]); $new_ass->save(); // clone assignment files include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php"; $old_storage = new ilFSStorageExercise($a_old_exc_id, (int) $d["id"]); $new_storage = new ilFSStorageExercise($a_new_exc_id, (int) $new_ass->getId()); $new_storage->create(); if (is_dir($old_storage->getPath())) { ilUtil::rCopy($old_storage->getPath(), $new_storage->getPath()); } } }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { switch ($a_entity) { case "blog": include_once "./Modules/Blog/classes/class.ilObjBlog.php"; // container copy if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) { $newObj = ilObjectFactory::getInstanceByObjId($new_id, false); } else { $newObj = new ilObjBlog(); $newObj->create(); } $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); $newObj->setNotesStatus($a_rec["Notes"]); $newObj->setBackgroundColor($a_rec["BgColor"]); $newObj->setFontColor($a_rec["FontColor"]); $newObj->setProfilePicture($a_rec["Ppic"]); $newObj->setRSS($a_rec["RssActive"]); $newObj->setApproval($a_rec["Approval"]); $newObj->setImage($a_rec["Img"]); $newObj->setAbstractShorten($a_rec["AbsShorten"]); $newObj->setAbstractShortenLength($a_rec["AbsShortenLen"]); $newObj->setAbstractImage($a_rec["AbsImage"]); $newObj->setAbstractImageWidth($a_rec["AbsImgWidth"]); $newObj->setAbstractImageHeight($a_rec["AbsImgHeight"]); $newObj->setNavMode($a_rec["NavMode"]); $newObj->setNavModeListPostings($a_rec["NavListPost"]); $newObj->setNavModeListMonths($a_rec["NavListMon"]); $newObj->setKeywords($a_rec["Keywords"]); $newObj->setAuthors($a_rec["Authors"]); $newObj->setOrder(trim($a_rec["NavOrder"]) ? explode(";", $a_rec["NavOrder"]) : null); $newObj->setOverviewPostings($a_rec["OvPost"]); $newObj->update(); // handle image(s) if ($a_rec["Img"]) { $dir = str_replace("..", "", $a_rec["Dir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = ilObjBlog::initStorage($newObj->getId()); ilUtil::rCopy($source_dir, $target_dir); } } if ($a_rec["Style"]) { self::$style_map[$a_rec["Style"]][] = $newObj->getId(); } $a_mapping->addMapping("Modules/Blog", "blog", $a_rec["Id"], $newObj->getId()); break; case "blog_posting": $blog_id = (int) $a_mapping->getMapping("Modules/Blog", "blog", $a_rec["BlogId"]); if ($blog_id) { include_once "./Modules/Blog/classes/class.ilBlogPosting.php"; $newObj = new ilBlogPosting(); $newObj->setBlogId($blog_id); $newObj->setTitle($a_rec["Title"]); $newObj->setCreated(new ilDateTime($a_rec["Created"], IL_CAL_DATETIME)); $newObj->setApproved($a_rec["Approved"]); // parse export id into local id (if possible) $author = $this->parseObjectExportId($a_rec["Author"], -1); $newObj->setAuthor($author["id"]); $newObj->create(true); // keywords $keywords = array(); for ($loop = 0; $loop < 1000; $loop++) { if (isset($a_rec["Keyword" . $loop])) { $keyword = trim($a_rec["Keyword" . $loop]); if (strlen($keyword)) { $keywords[] = $keyword; } } } if (sizeof($keywords)) { $newObj->updateKeywords($keywords); } $a_mapping->addMapping("Services/COPage", "pg", "blp:" . $a_rec["Id"], "blp:" . $newObj->getId()); } break; } }
/** * copy files of file items */ function copyFileItems() { $imp_dir = $this->content_object->getImportDirectory(); foreach ($this->file_item_mapping as $origin_id => $file_id) { if (empty($origin_id)) { continue; } $obj_dir = $origin_id; $source_dir = $imp_dir . "/" . $this->subdir . "/objects/" . $obj_dir; include_once "./Modules/File/classes/class.ilObjFile.php"; $file_obj = new ilObjFile($file_id, false); //$target_dir = ilUtil::getDataDir()."/files/file_".$file_id; $target_dir = $file_obj->getDirectory(); if (@is_dir($source_dir)) { // make target directory ilUtil::makeDir($target_dir); //@mkdir($target_dir); //@chmod($target_dir, 0755); if (@is_dir($target_dir)) { ilUtil::rCopy($source_dir, $target_dir); } } $test = $file_obj->determineFilesize(); $file_obj->update(); } }
/** * Export media object to html */ function exportHTMLMOB($a_mob_id, &$a_linked_mobs) { global $tpl; $source_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $a_mob_id; if (@is_dir($source_dir)) { ilUtil::makeDir($this->mobs_dir . "/mm_" . $a_mob_id); ilUtil::rCopy($source_dir, $this->mobs_dir . "/mm_" . $a_mob_id); } // #12930 - fullscreen include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $mob_obj = new ilObjMediaObject($a_mob_id); if ($mob_obj->hasFullscreenItem()) { // render media object html $xh = xslt_create(); $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, array("/_xml" => "<dummy>" . $mob_obj->getXML(IL_MODE_ALIAS) . $mob_obj->getXML(IL_MODE_OUTPUT) . "</dummy>", "/_xsl" => file_get_contents("./Services/COPage/xsl/page.xsl")), array("mode" => "fullscreen")); xslt_free($xh); unset($xh); // render fullscreen html $tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage"); $tpl = $this->getPreparedMainTemplate($tpl); // adds js/css $tpl->setCurrentBlock("ilMedia"); $tpl->setVariable("MEDIA_CONTENT", $output); $output = $tpl->get(); unset($tpl); // write file $file = $this->exp_dir . "/fullscreen_" . $a_mob_id . ".html"; 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, $output); fclose($fp); unset($fp); unset($output); } $linked_mobs = $mob_obj->getLinkedMediaObjects(); $a_linked_mobs = array_merge($a_linked_mobs, $linked_mobs); }
/** * export media object to html */ function exportHTMLMOB($a_target_dir, &$a_glo_gui, $a_mob_id) { global $tpl; $mob_dir = $a_target_dir . "/mobs"; $source_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $a_mob_id; if (@is_dir($source_dir)) { ilUtil::makeDir($mob_dir . "/mm_" . $a_mob_id); ilUtil::rCopy($source_dir, $mob_dir . "/mm_" . $a_mob_id); } $tpl = new ilTemplate("tpl.main.html", true, true); $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html"); $_GET["obj_type"] = "MediaObject"; $_GET["mob_id"] = $a_mob_id; $_GET["cmd"] = ""; $content =& $a_glo_gui->media(); $file = $a_target_dir . "/media_" . $a_mob_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); // fullscreen include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $mob_obj = new ilObjMediaObject($a_mob_id); if ($mob_obj->hasFullscreenItem()) { $tpl = new ilTemplate("tpl.main.html", true, true); $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html"); $_GET["mob_id"] = $a_mob_id; $_GET["cmd"] = "fullscreen"; $content = $a_glo_gui->fullscreen(); $file = $a_target_dir . "/fullscreen_" . $a_mob_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); } }
/** * Add records xml * * @param * @return */ function addRecordsXml($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field = "") { $types = $this->getXmlTypes($a_entity, $a_schema_version); $this->readData($a_entity, $a_schema_version, $a_ids, $a_field); if (is_array($this->data)) { foreach ($this->data as $d) { $a_writer->xmlStartTag($this->getDSPrefixString() . "Rec", array("Entity" => $this->getXmlEntityName($a_entity, $a_schema_version))); // entity tag $a_writer->xmlStartTag($this->getXmlEntityTag($a_entity, $a_schema_version)); $rec = $this->getXmlRecord($a_entity, $a_schema_version, $d); foreach ($rec as $f => $c) { switch ($types[$f]) { case "directory": if ($this->absolute_export_dir != "" && $this->relative_export_dir != "") { ilUtil::makeDirParents($this->absolute_export_dir . "/dsDir_" . $this->dircnt); ilUtil::rCopy($c, $this->absolute_export_dir . "/dsDir_" . $this->dircnt); //echo "<br>copy-".$c."-".$this->absolute_export_dir."/dsDir_".$this->dircnt."-"; $c = $this->relative_export_dir . "/dsDir_" . $this->dircnt; $this->dircnt++; } break; } // this changes schema/dtd //$a_writer->xmlElement($a_prefixes[$a_entity].":".$f, // array(), $c); $a_writer->xmlElement($f, array(), $c); } $a_writer->xmlEndTag($this->getXmlEntityTag($a_entity, $a_schema_version)); $a_writer->xmlEndTag($this->getDSPrefixString() . "Rec"); $this->afterXmlRecordWriting($a_entity, $a_schema_version, $d); // foreach record records of dependent entities (no record) $deps = $this->getDependencies($a_entity, $a_schema_version, $rec, $a_ids); if (is_array($deps)) { foreach ($deps as $dp => $par) { $this->addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $par["ids"], $par["field"]); } } } } else { if ($this->data === false) { // false -> add records of dependent entities (no record) $deps = $this->getDependencies($a_entity, $a_schema_version, null, $a_ids); if (is_array($deps)) { foreach ($deps as $dp => $par) { $this->addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $par["ids"], $par["field"]); } } } } }
function createOnlineVersion($a_rel_name) { ilUtil::makeDir(CLIENT_WEB_DIR . '/courses/' . $a_rel_name); ilUtil::rCopy($this->getCoursePath() . '/' . $a_rel_name, CLIENT_WEB_DIR . '/courses/' . $a_rel_name); return true; }
public function dbImportSco($slm, $sco, $asset = false) { $qtis = array(); $d = ilUtil::getDir($this->packageFolder); foreach ($d as $f) { //continue; if ($f[type] == 'file' && substr($f[entry], 0, 4) == 'qti_') { include_once "./Services/QTI/classes/class.ilQTIParser.php"; include_once "./Modules/Test/classes/class.ilObjTest.php"; $qtiParser = new ilQTIParser($this->packageFolder . "/" . $f[entry], IL_MO_VERIFY_QTI, 0, ""); $result = $qtiParser->startParsing(); $founditems =& $qtiParser->getFoundItems(); // die(print_r($founditems)); foreach ($founditems as $qp) { $newObj = new ilObjTest(0, true); // This creates a lot of invalid repository objects for each question // question are not repository objects (see e.g. table object_data), alex 29 Sep 2009 // $newObj->setType ( $qp ['type'] ); // $newObj->setTitle ( $qp ['title'] ); // $newObj->create ( true ); // $newObj->createReference (); // $newObj->putInTree ($_GET ["ref_id"]); // $newObj->setPermissions ( $sco->getId ()); // $newObj->notify ("new", $_GET["ref_id"], $sco->getId (), $_GET["ref_id"], $newObj->getRefId () ); // $newObj->mark_schema->flush (); $qtiParser = new ilQTIParser($this->packageFolder . "/" . $f[entry], IL_MO_PARSE_QTI, 0, ""); $qtiParser->setTestObject($newObj); $result = $qtiParser->startParsing(); // $newObj->saveToDb (); $qtis = array_merge($qtis, $qtiParser->getImportMapping()); } } } //exit; include_once 'Modules/Scorm2004/classes/class.ilSCORM2004Page.php'; $doc = new SimpleXMLElement($this->imsmanifest->saveXml()); $l = $doc->xpath("/ContentObject/MetaData"); if ($l[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($l[0]->asXML(), $slm->getId(), $sco->getId(), $sco->getType()); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } $l = $doc->xpath("/ContentObject/PageObject"); foreach ($l as $page_xml) { $tnode = $page_xml->xpath('MetaData/General/Title'); $page = new ilSCORM2004PageNode($slm); $page->setTitle($tnode[0]); $page->setSLMId($slm->getId()); $page->create(true); ilSCORM2004Node::putInTree($page, $sco->getId(), $target); $pmd = $page_xml->xpath("MetaData"); if ($pmd[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($pmd[0]->asXML(), $slm->getId(), $page->getId(), $page->getType()); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } $tnode = $page_xml->xpath("//MediaObject/MediaAlias | //InteractiveImage/MediaAlias"); foreach ($tnode as $ttnode) { include_once './Services/MediaObjects/classes/class.ilObjMediaObject.php'; $OriginId = $ttnode[OriginId]; $medianodes = $doc->xpath("//MediaObject[MetaData/General/Identifier/@Entry='" . $OriginId . "']"); $medianode = $medianodes[0]; if ($medianode) { $media_object = new ilObjMediaObject(); $media_object->setTitle($medianode->MetaData->General->Title); $media_object->setDescription($medianode->MetaData->General->Description); $media_object->create(false); $mmd = $medianode->xpath("MetaData"); if ($mmd[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($mmd[0]->asXML(), 0, $media_object->getId(), $media_object->getType()); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } // determine and create mob directory, move uploaded file to directory $media_object->createDirectory(); $mob_dir = ilObjMediaObject::_getDirectory($media_object->getId()); foreach ($medianode->MediaItem as $xMediaItem) { $media_item =& new ilMediaItem(); $media_object->addMediaItem($media_item); $media_item->setPurpose($xMediaItem[Purpose]); $media_item->setFormat($xMediaItem->Format); $media_item->setLocation($xMediaItem->Location); $media_item->setLocationType($xMediaItem->Location[Type]); $media_item->setWidth($xMediaItem->Layout[Width]); $media_item->setHeight($xMediaItem->Layout[Height]); $media_item->setHAlign($xMediaItem->Layout[HorizontalAlign]); $media_item->setCaption($xMediaItem->Caption); $media_item->setTextRepresentation($xMediaItem->TextRepresentation); $nr = 0; // add map areas (external links only) foreach ($xMediaItem->MapArea as $n => $v) { if ($v->ExtLink[Href] != "") { include_once "./Services/MediaObjects/classes/class.ilMapArea.php"; $ma = new ilMapArea(); $map_area = new ilMapArea(); $map_area->setShape($v[Shape]); $map_area->setCoords($v[Coords]); $map_area->setLinkType(IL_EXT_LINK); $map_area->setTitle($v->ExtLink); $map_area->setHref($v->ExtLink[Href]); $media_item->addMapArea($map_area); } } if ($media_item->getLocationType() == "LocalFile") { // $tmp_name = $this->packageFolder."/objects/".$OriginId."/".$xMediaItem->Location; // copy($tmp_name, $mob_dir."/".$xMediaItem->Location); } } // copy whole directory ilUtil::rCopy($this->packageFolder . "/objects/" . $OriginId, $mob_dir); // alex: fixed media import: these lines have been // behind the next curly bracket which makes it fail // when no medianode is given. (id=0 -> fatal error) ilUtil::renameExecutables($mob_dir); $media_object->update(true); $ttnode[OriginId] = "il__mob_" . $media_object->getId(); } } include_once "./Modules/File/classes/class.ilObjFile.php"; include_once "./Services/Utilities/classes/class.ilFileUtils.php"; include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $intlinks = $page_xml->xpath("//IntLink"); foreach ($intlinks as $intlink) { if ($intlink[Type] != "File") { continue; } $path = $this->packageFolder . "/objects/" . str_replace('dfile', 'file', $intlink[Target]); if (!is_dir($path)) { continue; } $ffiles = array(); ilFileUtils::recursive_dirscan($path, $ffiles); $filename = $ffiles[file][0]; $fileObj = new ilObjFile(); $fileObj->setType("file"); $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); // better use this, mime_content_type is deprecated $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename)); $fileObj->setFileSize(filesize($path . "/" . $filename)); $fileObj->create(); $fileObj->createReference(); //$fileObj->putInTree($_GET["ref_id"]); //$fileObj->setPermissions($slm->getId ()); $fileObj->createDirectory(); $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); $intlink[Target] = "il__dfile_" . $fileObj->getId(); } $fileitems = $page_xml->xpath("//FileItem/Identifier"); foreach ($fileitems as $fileitem) { $path = $this->packageFolder . "/objects/" . $fileitem[Entry]; if (!is_dir($path)) { continue; } $ffiles = array(); ilFileUtils::recursive_dirscan($path, $ffiles); $filename = $ffiles[file][0]; $fileObj = new ilObjFile(); $fileObj->setType("file"); $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); // better use this, mime_content_type is deprecated $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename)); $fileObj->setFileSize(filesize($path . "/" . $filename)); $fileObj->create(); $fileObj->createReference(); //$fileObj->putInTree($_GET["ref_id"]); //$fileObj->setPermissions($slm->getId ()); $fileObj->createDirectory(); $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); $fileitem[Entry] = "il__file_" . $fileObj->getId(); } $pagex = new ilSCORM2004Page($page->getId()); $ddoc = new DOMDocument(); $ddoc->async = false; $ddoc->preserveWhiteSpace = false; $ddoc->formatOutput = false; $ddoc->loadXML($page_xml->asXML()); $xpath = new DOMXPath($ddoc); $tnode = $xpath->query('PageContent'); $t = "<PageObject>"; foreach ($tnode as $ttnode) { $t .= $ddoc->saveXML($ttnode); } $t .= "</PageObject>"; foreach ($qtis as $old => $q) { $t = str_replace($old, 'il__qst_' . $q['pool'], $t); } $pagex->setXMLContent($t); $pagex->updateFromXML(); } }
/** * Copy css files to target dir * * @param * @return */ function copyPlayerFilesToTargetDirectory($a_target_dir) { ilUtil::rCopy("./Services/MediaObjects/media_element_" . self::$mejs_ver, $a_target_dir); }
public function createArchiveOnlineVersion($a_rel_name) { ilUtil::makeDir(CLIENT_WEB_DIR . '/courses/' . $a_rel_name); ilUtil::rCopy($this->getArchiveDirectory() . '/' . $a_rel_name, CLIENT_WEB_DIR . '/courses/' . $a_rel_name); return true; }
public function doClone($a_pool_id, $a_schedule_map = null) { $new_obj = new self(); $new_obj->setPoolId($a_pool_id); $new_obj->setTitle($this->getTitle()); $new_obj->setDescription($this->getDescription()); $new_obj->setNrOfItems($this->getNrOfItems()); $new_obj->setFile($this->getFile()); $new_obj->setPostText($this->getPostText()); $new_obj->setPostFile($this->getPostFile()); if ($a_schedule_map) { $schedule_id = $this->getScheduleId(); if ($schedule_id) { $new_obj->setScheduleId($a_schedule_map[$schedule_id]); } } $new_obj->save(); // files $source = $this->initStorage($this->getId()); $target = $new_obj->initStorage($new_obj->getId()); ilUtil::rCopy($source, $target); }
/** * exports the digi-lib-object into a xml structure */ function export($a_deliver = true) { global $ilDB; include_once "./Services/Xml/classes/class.ilNestedSetXML.php"; // ------------------------------------------------------ // anhand der ref_id die obj_id ermitteln. // ------------------------------------------------------ $objRow["obj_id"] = ilOject::_lookupObjId(); $objRow["title"] = ilOject::_lookupTitle($objRow["obj_id"]); $obj_id = $objRow["obj_id"]; $this->mob_ids = array(); // ------------------------------------------------------ // start xml-String // ------------------------------------------------------ $xml = "<?xml version=\"1.0\"?>\n<!DOCTYPE ContentObject SYSTEM \"ilias_co.dtd\">\n<ContentObject Type=\"LibObject\">\n"; // ------------------------------------------------------ // get global meta-data // ------------------------------------------------------ $nested = new ilNestedSetXML(); $xml .= $nested->export($obj_id, "dbk") . "\n"; // ------------------------------------------------------ // get all book-xml-data recursiv // ------------------------------------------------------ $query = "SELECT *\n FROM lm_tree, lm_data\n WHERE lm_tree.lm_id = " . $ilDB->quote($obj_id, "integer") . "\n AND lm_tree.child = lm_data.obj_id\n AND ( lm_data.type = 'du' )\n AND lm_tree.depth = 1\n ORDER BY lm_tree.lft"; $result = $ilDB->query($query); $treeData = $ilDB->fetchAssoc($result); $xml .= $this->exportRekursiv($obj_id, 2, $treeData["lft"], $treeData["rgt"]); // ------------------------------------------------------ // get or create export-directory // ------------------------------------------------------ $this->createExportDirectory(); $export_dir = $this->getExportDirectory(); // ------------------------------------------------------ // get mediaobject-xml-data // ------------------------------------------------------ $mob_ids = $this->mob_ids; if (is_array($mob_ids) && count($mob_ids) > 0) { reset($mob_ids); while (list($key, $val) = each($mob_ids)) { $xml .= "<MediaObject>"; $query = "SELECT * FROM media_item WHERE mob_id= " . $ilDB->quote($key, "integer") . " "; //vd($query); $first = true; $result = $ilDB->query($query); while (is_array($row = $ilDB->fetchRow($result))) { if ($first) { //vd($row[purpose]); $nested = new ilNestedSetXML(); $metaxml = $nested->export($key, "mob"); $metaxml = preg_replace("/Entry=\"(.*?)\"/", "Entry=\"il__mob_" . $key . "\"", $metaxml); $metaxml2 = "<Technical>"; $metaxml2 .= "<Format>" . $row["format"] . "</Format>"; $metaxml2 .= "<Size>14559</Size>"; $metaxml2 .= "<Location Type=\"" . $row["location_type"] . "\">" . $row["location"] . "</Location>"; $metaxml2 .= "</Technical>"; $metaxml = str_replace("</MetaData>", $metaxml2 . "</MetaData>", $metaxml); $xml .= $metaxml; $first = false; } $xml .= "<MediaItem Purpose=\"" . $row["purpose"] . "\">"; $xml .= "<Location Type=\"" . $row["location_type"] . "\">" . $row["location"] . "</Location>"; $xml .= "<Format>" . $row["format"] . "</Format>"; $xml .= "<Layout Width=\"" . $row["width"] . "\" Height=\"" . $row["height"] . "\"/>"; $xml .= "</MediaItem>"; } $xml .= "</MediaObject>"; } } // ------------------------------------------------------ // get bib-xml-data // ------------------------------------------------------ $nested = new ilNestedSetXML(); $bib = $nested->export($obj_id, "bib"); $xml .= $bib . "\n"; // ------------------------------------------------------ // xml-ending // ------------------------------------------------------ $xml .= "</ContentObject>"; // ------------------------------------------------------ // filename and directory-creation // ------------------------------------------------------ $fileName = $objRow["title"]; $fileName = str_replace(" ", "_", $fileName); if (!file_exists($export_dir . "/" . $fileName)) { @mkdir($export_dir . "/" . $fileName); @chmod($export_dir . "/" . $fileName, 0755); } if (!file_exists($export_dir . "/" . $fileName . "/objects")) { @mkdir($export_dir . "/" . $fileName . "/objects"); @chmod($export_dir . "/" . $fileName . "/objects", 0755); } // ------------------------------------------------------ // copy mob-files // ------------------------------------------------------ $mob_ids = $this->mob_ids; if (is_array($mob_ids) && count($mob_ids) > 0) { reset($mob_ids); while (list($key, $val) = each($mob_ids)) { if (!file_exists($export_dir . "/" . $fileName . "/objects/mm" . $key)) { @mkdir($export_dir . "/" . $fileName . "/objects/mm" . $key); @chmod($export_dir . "/" . $fileName . "/objects/mm" . $key, 0755); } $mobdir = "./data/mobs/mm_" . $key; ilUtil::rCopy($mobdir, $export_dir . "/" . $fileName . "/objects/mm" . $key); } } // ------------------------------------------------------ // save xml-file // ------------------------------------------------------ $fp = fopen($export_dir . "/" . $fileName . "/" . $fileName . ".xml", "wb"); fwrite($fp, $xml); fclose($fp); // ------------------------------------------------------ // zip all files // ------------------------------------------------------ ilUtil::zip($export_dir . "/" . $fileName, $export_dir . "/" . $fileName . ".zip"); // ------------------------------------------------------ // deliver files // ------------------------------------------------------ if ($a_deliver) { ilUtil::deliverFile($export_dir . "/" . $fileName . ".zip", $fileName); } else { return $export_dir . "/" . $fileName . ".zip"; } /* header("Expires: Mon, 1 Jan 1990 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Content-type: application/octet-stream"); if (stristr(" ".$GLOBALS["HTTP_SERVER_VARS"]["HTTP_USER_AGENT"],"MSIE") ) { header ("Content-Disposition: attachment; filename=" . $fileName.".zip"); } else { header ("Content-Disposition: inline; filename=".$fileName.".zip" ); } header ("Content-length:".(string)( filesize($export_dir."/".$fileName.".zip")) ); readfile( $export_dir."/".$fileName.".zip" ); */ }
/** * create html package */ function exportHTML() { $inst_id = IL_INST_ID; include_once "./Services/Export/classes/class.ilExport.php"; ilExport::_createExportDirectory($this->object->getId(), "html", $this->object->getType()); $export_dir = ilExport::_getExportDirectory($this->object->getId(), "html", $this->object->getType()); $subdir = $this->object->getType() . "_" . $this->object->getId(); $filename = $this->subdir . ".zip"; $target_dir = $export_dir . "/" . $subdir; ilUtil::delDir($target_dir); ilUtil::makeDir($target_dir); $source_dir = $this->object->getDataDirectory(); ilUtil::rCopy($source_dir, $target_dir); // zip it all $date = time(); $zip_file = $export_dir . "/" . $date . "__" . IL_INST_ID . "__" . $this->object->getType() . "_" . $this->object->getId() . ".zip"; ilUtil::zip($target_dir, $zip_file); ilUtil::delDir($target_dir); }
/** * Import */ function import($a_file) { parent::create(); $im_dir = $this->createImportDirectory(); // handle uploaded files if (is_array($a_file)) { ilUtil::moveUploadedFile($a_file["tmp_name"], $a_file["name"], $im_dir . "/" . $a_file["name"]); $file_name = $a_file["name"]; } else { $pi = pathinfo($a_file); $file_name = $pi["basename"]; copy($a_file, $im_dir . "/" . $file_name); } $file = pathinfo($file_name); // unzip file if (strtolower($file["extension"] == "zip")) { ilUtil::unzip($im_dir . "/" . $file_name); $subdir = basename($file["basename"], "." . $file["extension"]); if (!is_dir($im_dir . "/" . $subdir)) { $subdir = "style"; // check style subdir } $xml_file = $im_dir . "/" . $subdir . "/style.xml"; } else { $xml_file = $im_dir . "/" . $file_name; } // load information from xml file //echo "-$xml_file-"; $this->createFromXMLFile($xml_file, true); // copy images $this->createImagesDirectory(); if (is_dir($im_dir . "/" . $subdir . "/images")) { ilUtil::rCopy($im_dir . "/" . $subdir . "/images", $this->getImagesDirectory()); } ilObjStyleSheet::_addMissingStyleClassesToStyle($this->getId()); $this->read(); $this->writeCSSFile(); }
/** * Duplicate media object, return new media object */ function duplicate() { $new_obj = new ilObjMediaObject(); $new_obj->setTitle($this->getTitle()); $new_obj->setDescription($this->getDescription()); // media items foreach ($this->getMediaItems() as $key => $val) { $new_obj->addMediaItem($val); } $new_obj->create(false, true); // files $new_obj->createDirectory(); self::_createThumbnailDirectory($new_obj->getId()); ilUtil::rCopy(ilObjMediaObject::_getDirectory($this->getId()), ilObjMediaObject::_getDirectory($new_obj->getId())); ilUtil::rCopy(ilObjMediaObject::_getThumbnailDirectory($this->getId()), ilObjMediaObject::_getThumbnailDirectory($new_obj->getId())); // meta data include_once "Services/MetaData/classes/class.ilMD.php"; $md = new ilMD(0, $this->getId(), "mob"); $new_md = $md->cloneMD(0, $new_obj->getId(), "mob"); return $new_obj; }
/** * Copies the preview images from one preview to a new preview object. * * @param int $a_src_id The id of the object to copy from. * @param int $a_dest_id The id of the object to copy to. */ public static function copyPreviews($a_src_id, $a_dest_id) { if (!ilPreviewSettings::isPreviewEnabled()) { return; } // get source preview $src = new ilPreview($a_src_id); $status = $src->getRenderStatus(); // created? copy the previews if ($status == self::RENDER_STATUS_CREATED) { // create destination preview and set it's properties $dest = new ilPreview($a_dest_id); $dest->setRenderDate($src->getRenderDate()); $dest->setRenderStatus($src->getRenderStatus()); // create path $dest->getStorage()->create(); // copy previews ilUtil::rCopy($src->getStoragePath(), $dest->getStoragePath()); // save copy $dest->doCreate(); } else { // all other status need no action // self::RENDER_STATUS_FAILED // self::RENDER_STATUS_NONE // self::RENDER_STATUS_PENDING } }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { //echo $a_entity; //var_dump($a_rec); switch ($a_entity) { case "exc": include_once "./Modules/Exercise/classes/class.ilObjExercise.php"; if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) { $newObj = ilObjectFactory::getInstanceByObjId($new_id, false); } else { $newObj = new ilObjExercise(); $newObj->setType("exc"); $newObj->create(true); } $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); $newObj->setPassMode($a_rec["PassMode"]); $newObj->setPassNr($a_rec["PassNr"]); $newObj->setShowSubmissions($a_rec["ShowSubmissions"]); $newObj->update(); $newObj->saveData(); //var_dump($a_rec); $this->current_exc = $newObj; $a_mapping->addMapping("Modules/Exercise", "exc", $a_rec["Id"], $newObj->getId()); //var_dump($a_mapping->mappings["Services/News"]["news_context"]); break; case "exc_assignment": $exc_id = $a_mapping->getMapping("Modules/Exercise", "exc", $a_rec["ExerciseId"]); if ($exc_id > 0) { if (is_object($this->current_exc) && $this->current_exc->getId() == $exc_id) { $exc = $this->current_exc; } else { include_once "./Modules/Exercise/classes/class.ilObjExercise.php"; $exc = new ilObjExercise($exc_id, false); } include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; $ass = new ilExAssignment(); $ass->setExerciseId($exc_id); if ($a_rec["StartTime"] != "") { $start = new ilDateTime($a_rec["StartTime"], IL_CAL_DATETIME, "UTC"); $ass->setStartTime($start->get(IL_CAL_UNIX)); } if ($a_rec["Deadline"] != "") { $deadline = new ilDateTime($a_rec["Deadline"], IL_CAL_DATETIME, "UTC"); $ass->setDeadline($deadline->get(IL_CAL_UNIX)); } //var_dump($a_rec); $ass->setInstruction($a_rec["Instruction"]); $ass->setTitle($a_rec["Title"]); $ass->setMandatory($a_rec["Mandatory"]); $ass->setOrderNr($a_rec["OrderNr"]); // 4.2 $ass->setType($a_rec["Type"]); // 4.4 $ass->setPeerReview($a_rec["Peer"]); $ass->setPeerReviewMin($a_rec["PeerMin"]); $ass->setPeerReviewDeadline($a_rec["PeerDeadline"]); $ass->setFeedbackFile($a_rec["FeedbackFile"]); $ass->setFeedbackCron($a_rec["FeedbackCron"]); $ass->setFeedbackDate($a_rec["FeedbackDate"]); // 5.0 $ass->setPeerReviewFileUpload($a_rec["PeerFile"]); $ass->setPeerReviewPersonalized($a_rec["PeerPersonal"]); $ass->save(); include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php"; $fstorage = new ilFSStorageExercise($exc_id, $ass->getId()); $fstorage->create(); // assignment files $dir = str_replace("..", "", $a_rec["Dir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = $fstorage->getPath(); ilUtil::rCopy($source_dir, $target_dir); } // (4.4) global feedback file $dir = str_replace("..", "", $a_rec["FeedbackDir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = $fstorage->getGlobalFeedbackPath(); ilUtil::rCopy($source_dir, $target_dir); } $a_mapping->addMapping("Modules/Exercise", "exc_assignment", $a_rec["Id"], $ass->getId()); } break; } }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { switch ($a_entity) { case "prtt": include_once "./Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php"; // container copy if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) { $newObj = ilObjectFactory::getInstanceByObjId($new_id, false); } else { $newObj = new ilObjPortfolioTemplate(); $newObj->create(); } $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); $newObj->setPublicComments($a_rec["Comments"]); $newObj->setBackgroundColor($a_rec["BgColor"]); $newObj->setFontColor($a_rec["FontColor"]); $newObj->setProfilePicture($a_rec["Ppic"]); $newObj->setImage($a_rec["Img"]); $newObj->update(); // handle image(s) if ($a_rec["Img"]) { $dir = str_replace("..", "", $a_rec["Dir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = ilObjPortfolioTemplate::initStorage($newObj->getId()); ilUtil::rCopy($source_dir, $target_dir); } } $a_mapping->addMapping("Modules/Portfolio", "prtt", $a_rec["Id"], $newObj->getId()); break; case "portfolio_page": $prtt_id = (int) $a_mapping->getMapping("Modules/Portfolio", "prtt", $a_rec["PortfolioId"]); if ($prtt_id) { include_once "./Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php"; $newObj = new ilPortfolioTemplatePage(); $newObj->setPortfolioId($prtt_id); $newObj->setTitle($a_rec["Title"]); $newObj->setType($a_rec["Type"]); $newObj->setOrderNr($a_rec["OrderNr"]); $newObj->create(true); $a_mapping->addMapping("Services/COPage", "pg", "prtt:" . $a_rec["Id"], "prtt:" . $newObj->getId()); } break; } }
/** * Populate by directory. Add a filename to do a special check for * ILIAS HTML export files. If the corresponding directory is found * within the passed directory path (i.e. "htlm_<id>") this * subdirectory is used instead. * * @param * @return */ function populateByDirectoy($a_dir, $a_filename = "") { preg_match("/.*htlm_([0-9]*)\\.zip/", $a_filename, $match); if (is_dir($a_dir . "/htlm_" . $match[1])) { $a_dir = $a_dir . "/htlm_" . $match[1]; } ilUtil::rCopy($a_dir, $this->getDataDirectory()); ilUtil::renameExecutables($this->getDataDirectory()); }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { switch ($a_entity) { case "poll": include_once "./Modules/Poll/classes/class.ilObjPoll.php"; $newObj = new ilObjPoll(); $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); $newObj->create(); $newObj->setQuestion($a_rec["Question"]); $newObj->setImage($a_rec["Image"]); $newObj->setViewResults($a_rec["ViewResults"]); $newObj->update(); // handle image(s) if ($a_rec["Image"]) { $dir = str_replace("..", "", $a_rec["Dir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = ilObjPoll::initStorage($newObj->getId()); ilUtil::rCopy($source_dir, $target_dir); } } $a_mapping->addMapping("Modules/Poll", "poll", $a_rec["Id"], $newObj->getId()); break; case "poll_answer": $poll_id = (int) $a_mapping->getMapping("Modules/Poll", "poll", $a_rec["PollId"]); if ($poll_id) { $poll = new ilObjPoll($poll_id, false); $poll->saveAnswer($a_rec["Answer"], $a_rec["pos"]); } break; } }
/** * Export media object to html */ function exportHTMLMOB($a_mob_id, &$a_linked_mobs) { global $tpl; $source_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $a_mob_id; if (@is_dir($source_dir)) { ilUtil::makeDir($this->mobs_dir . "/mm_" . $a_mob_id); ilUtil::rCopy($source_dir, $this->mobs_dir . "/mm_" . $a_mob_id); } // fullscreen include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $mob_obj = new ilObjMediaObject($a_mob_id); if ($mob_obj->hasFullscreenItem()) { $tpl = new ilTemplate("tpl.main.html", true, true); $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html"); $file = $this->exp_dir . "/fullscreen_" . $a_mob_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); } $linked_mobs = $mob_obj->getLinkedMediaObjects(); $a_linked_mobs = array_merge($a_linked_mobs, $linked_mobs); }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { switch ($a_entity) { case "poll": include_once "./Modules/Poll/classes/class.ilObjPoll.php"; // container copy if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) { $newObj = ilObjectFactory::getInstanceByObjId($new_id, false); } else { $newObj = new ilObjPoll(); $newObj->create(); } $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); if ((int) $a_rec["MaxAnswers"]) { $newObj->setMaxNumberOfAnswers($a_rec["MaxAnswers"]); } $newObj->setSortResultByVotes((bool) $a_rec["ResultSort"]); $newObj->setNonAnonymous((bool) $a_rec["NonAnon"]); if ((int) $a_rec["ShowResultsAs"]) { $newObj->setShowResultsAs($a_rec["ShowResultsAs"]); } $newObj->setShowComments($a_rec["ShowComments"]); $newObj->setQuestion($a_rec["Question"]); $newObj->setImage($a_rec["Image"]); $newObj->setViewResults($a_rec["ViewResults"]); $newObj->update(); // handle image(s) if ($a_rec["Image"]) { $dir = str_replace("..", "", $a_rec["Dir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = ilObjPoll::initStorage($newObj->getId()); ilUtil::rCopy($source_dir, $target_dir); } } $a_mapping->addMapping("Modules/Poll", "poll", $a_rec["Id"], $newObj->getId()); break; case "poll_answer": $poll_id = (int) $a_mapping->getMapping("Modules/Poll", "poll", $a_rec["PollId"]); if ($poll_id) { $poll = new ilObjPoll($poll_id, false); $poll->saveAnswer($a_rec["Answer"], $a_rec["pos"]); } break; } }