/** * Build export file * * @param * @return */ function buildExportFile() { global $ilias; // create export file include_once "./Services/Export/classes/class.ilExport.php"; ilExport::_createExportDirectory($this->wiki->getId(), "html", "wiki"); $exp_dir = ilExport::_getExportDirectory($this->wiki->getId(), "html", "wiki"); $this->subdir = $this->wiki->getType() . "_" . $this->wiki->getId(); $this->export_dir = $exp_dir . "/" . $this->subdir; // initialize temporary target directory ilUtil::delDir($this->export_dir); ilUtil::makeDir($this->export_dir); // system style html exporter include_once "./Services/Style/classes/class.ilSystemStyleHTMLExport.php"; $this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir); $this->sys_style_html_export->addImage("icon_wiki.svg"); $this->sys_style_html_export->export(); // init co page html exporter include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php"; $this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir); $this->co_page_html_export->setContentStyleId($this->wiki->getStyleSheetId()); $this->co_page_html_export->createDirectories(); $this->co_page_html_export->exportStyles(); $this->co_page_html_export->exportSupportScripts(); // export pages $this->exportHTMLPages(); // zip everything if (true) { // zip it all $date = time(); $zip_file = ilExport::_getExportDirectory($this->wiki->getId(), "html", "wiki") . "/" . $date . "__" . IL_INST_ID . "__" . $this->wiki->getType() . "_" . $this->wiki->getId() . ".zip"; ilUtil::zip($this->export_dir, $zip_file); ilUtil::delDir($this->export_dir); } }
/** * Build export file * * @param * @return */ function buildExportFile() { global $ilias; // create export file include_once "./Services/Export/classes/class.ilExport.php"; ilExport::_createExportDirectory($this->object->getId(), "html", "prtf"); $exp_dir = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf"); $this->subdir = $this->object->getType() . "_" . $this->object->getId(); $this->export_dir = $exp_dir . "/" . $this->subdir; // initialize temporary target directory ilUtil::delDir($this->export_dir); ilUtil::makeDir($this->export_dir); // system style html exporter include_once "./Services/Style/classes/class.ilSystemStyleHTMLExport.php"; $this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir); // $this->sys_style_html_export->addImage("icon_prtf_b.png"); $this->sys_style_html_export->export(); // init co page html exporter include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php"; $this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir); /* $this->co_page_html_export->setContentStyleId( $this->object->getStyleSheetId()); */ $this->co_page_html_export->createDirectories(); $this->co_page_html_export->exportStyles(); $this->co_page_html_export->exportSupportScripts(); // banner / profile picture $prfa_set = new ilSetting("prfa"); if ($prfa_set->get("banner")) { $banner = $this->object->getImageFullPath(); copy($banner, $this->export_dir . "/" . basename($banner)); } $ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "big"); if ($ppic) { $ppic = array_shift(explode("?", $ppic)); copy($ppic, $this->export_dir . "/" . basename($ppic)); } // export pages $this->exportHTMLPages(); // zip everything if (true) { // zip it all $date = time(); $zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf") . "/" . $date . "__" . IL_INST_ID . "__" . $this->object->getType() . "_" . $this->object->getId() . ".zip"; ilUtil::zip($this->export_dir, $zip_file); ilUtil::delDir($this->export_dir); } return $zip_file; }
/** * Export a container * * @param object $a_type * @param object $a_obj_id * @param object $a_target_release * @return */ public function exportObject($a_type, $a_id, $a_target_release) { // Create base export directory ilExport::_createExportDirectory($a_id, "xml", $a_type); $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type); $ts = time(); $sub_dir = $ts . "__" . IL_INST_ID . "__" . $a_type . "_" . $a_id; $this->cont_export_dir = $export_dir . DIRECTORY_SEPARATOR . $sub_dir; ilUtil::makeDirParents($this->cont_export_dir); $GLOBALS['ilLog']->write(__METHOD__ . ' using base directory: ' . $this->export_run_dir); $this->manifestWriterBegin($a_type, $a_id, $a_target_release); $this->addContainer(); $this->addSubitems($a_id, $a_type, $a_target_release); $this->manifestWriterEnd($a_type, $a_id, $a_target_release); ilUtil::zip($this->cont_export_dir, $this->cont_export_dir . '.zip'); ilUtil::delDir($this->cont_export_dir); }
/** * Export an ILIAS entity * * @param string $a_entity entity type, e.g. "sty" * @param mixed $a_id entity id * @param string $a_target_release target release * @param string $a_component component that exports (e.g. "Services/Style") * * @return array success and info array */ function exportEntity($a_entity, $a_id, $a_target_release, $a_component, $a_title, $a_export_dir, $a_type_for_file = "") { global $objDefinition, $tpl; if ($a_type_for_file == "") { $a_type_for_file = $a_entity; } $comp = $a_component; $c = explode("/", $comp); $class = "il" . $c[1] . "Exporter"; // manifest writer include_once "./Services/Xml/classes/class.ilXmlWriter.php"; $this->manifest_writer = new ilXmlWriter(); $this->manifest_writer->xmlHeader(); $this->manifest_writer->xmlStartTag('Manifest', array("MainEntity" => $a_entity, "Title" => $a_title, "TargetRelease" => $a_target_release, "InstallationId" => IL_INST_ID, "InstallationUrl" => ILIAS_HTTP_PATH)); $export_dir = $a_export_dir; $ts = time(); // determine file name and subdirectory $sub_dir = $ts . '__' . IL_INST_ID . '__' . $a_type_for_file . '_' . $a_id; $new_file = $sub_dir . '.zip'; $this->export_run_dir = $export_dir . "/" . $sub_dir; ilUtil::makeDirParents($this->export_run_dir); $this->cnt = array(); $success = $this->processExporter($comp, $class, $a_entity, $a_target_release, $a_id); $this->manifest_writer->xmlEndTag('Manifest'); $this->manifest_writer->xmlDumpFile($this->export_run_dir . "/manifest.xml", false); // zip the file ilUtil::zip($this->export_run_dir, $export_dir . "/" . $new_file); ilUtil::delDir($this->export_run_dir); return array("success" => $success, "file" => $new_file, "directory" => $export_dir); }
/** * build xml export file */ function buildExportFileXML() { global $ilBench; $ilBench->start("SurveyExport", "buildExportFile"); // create directories $this->survey_obj->createExportDirectory(); include_once "./Services/Utilities/classes/class.ilUtil.php"; ilUtil::makeDir($this->export_dir . "/" . $this->subdir); ilUtil::makeDir($this->export_dir . "/" . $this->subdir . "/objects"); // get Log File $expDir = $this->survey_obj->getExportDirectory(); include_once "./Services/Logging/classes/class.ilLog.php"; $expLog = new ilLog($expDir, "export.log"); $expLog->delete(); $expLog->setLogFormat(""); $expLog->write(date("[y-m-d H:i:s] ") . "Start Export"); // write xml file $xmlFile = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->filename, "w"); fwrite($xmlFile, $this->survey_obj->toXML()); fclose($xmlFile); // add media objects which were added with tiny mce $this->exportXHTMLMediaObjects($this->export_dir . "/" . $this->subdir); // zip the file $ilBench->start("SurveyExport", "buildExportFileXML_zipFile"); ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip"); $ilBench->stop("SurveyExport", "buildExportFileXML_zipFile"); if (@file_exists($this->export_dir . "/" . $this->subdir . ".zip")) { // remove export directory and contents if (@is_dir($this->export_dir . "/" . $this->subdir)) { ilUtil::delDir($this->export_dir . "/" . $this->subdir); } } $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export"); $ilBench->stop("SurveyExport", "buildExportFile"); return $this->export_dir . "/" . $this->subdir . ".zip"; }
/** * Create member status record for a new assignment for all participants */ function sendMultiFeedbackStructureFile() { global $ilDB; // send and delete the zip file $deliverFilename = trim(str_replace(" ", "_", $this->getTitle() . "_" . $this->getId())); $deliverFilename = ilUtil::getASCIIFilename($deliverFilename); $deliverFilename = "multi_feedback_" . $deliverFilename; $exc = new ilObjExercise($this->getExerciseId(), false); $cdir = getcwd(); // create temporary directoy $tmpdir = ilUtil::ilTempnam(); ilUtil::makeDir($tmpdir); $mfdir = $tmpdir . "/" . $deliverFilename; ilUtil::makeDir($mfdir); // create subfolders <lastname>_<firstname>_<id> for each participant include_once "./Modules/Exercise/classes/class.ilExerciseMembers.php"; $exmem = new ilExerciseMembers($exc); $mems = $exmem->getMembers(); foreach ($mems as $mem) { $name = ilObjUser::_lookupName($mem); $subdir = $name["lastname"] . "_" . $name["firstname"] . "_" . $name["login"] . "_" . $name["user_id"]; $subdir = ilUtil::getASCIIFilename($subdir); ilUtil::makeDir($mfdir . "/" . $subdir); } // create the zip file chdir($tmpdir); $tmpzipfile = $tmpdir . "/multi_feedback.zip"; ilUtil::zip($tmpdir, $tmpzipfile, true); chdir($cdir); ilUtil::deliverFile($tmpzipfile, $deliverFilename . ".zip", "", false, true); }
function zipFile($a_rel_name, $a_zip_name) { ilUtil::zip($this->getGroupPath() . '/grp_' . $this->group_obj->getId() . '/' . $a_rel_name, $this->getGroupPath() . '/grp_' . $this->group_obj->getId() . '/' . $a_zip_name); return true; }
public function sendAndCreateSimpleExportFile() { $orgu_id = ilObjOrgUnit::getRootOrgId(); $orgu_ref_id = ilObjOrgUnit::getRootOrgRefId(); ilExport::_createExportDirectory($orgu_id, "xml", "orgu"); $export_dir = ilExport::_getExportDirectory($orgu_id, "xml", "orgu"); $ts = time(); // Workaround for test assessment $sub_dir = $ts . '__' . IL_INST_ID . '__' . "orgu" . '_' . $orgu_id . ""; $new_file = $sub_dir . '.zip'; $export_run_dir = $export_dir . "/" . $sub_dir; ilUtil::makeDirParents($export_run_dir); $writer = $this->simpleExport($orgu_ref_id); $writer->xmlDumpFile($export_run_dir . "/manifest.xml", false); // zip the file ilUtil::zip($export_run_dir, $export_dir . "/" . $new_file); ilUtil::delDir($export_run_dir); // Store info about export include_once './Services/Export/classes/class.ilExportFileInfo.php'; $exp = new ilExportFileInfo($orgu_id); $exp->setVersion(ILIAS_VERSION_NUMERIC); $exp->setCreationDate(new ilDateTime($ts, IL_CAL_UNIX)); $exp->setExportType('xml'); $exp->setFilename($new_file); $exp->create(); ilUtil::deliverFile($export_dir . "/" . $new_file, $new_file); return array("success" => true, "file" => $new_file, "directory" => $export_dir); }
/** * build export file (complete zip file) */ function buildExportFileXML() { global $ilBench; $ilBench->start("GlossaryExport", "buildExportFile"); require_once "./Services/Xml/classes/class.ilXmlWriter.php"; $this->xml = new ilXmlWriter(); // set dtd definition $this->xml->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co_3_7.dtd\">"); // set generated comment $this->xml->xmlSetGenCmt("Export of ILIAS Glossary " . $this->glo_obj->getId() . " of installation " . $this->inst . "."); // set xml header $this->xml->xmlHeader(); // create directories $this->glo_obj->createExportDirectory(); ilUtil::makeDir($this->export_dir . "/" . $this->subdir); ilUtil::makeDir($this->export_dir . "/" . $this->subdir . "/objects"); // get Log File $expDir = $this->glo_obj->getExportDirectory(); $expLog = new ilLog($expDir, "export.log"); $expLog->delete(); $expLog->setLogFormat(""); $expLog->write(date("[y-m-d H:i:s] ") . "Start Export"); // get xml content //echo "ContObjExport:".$this->inst_id.":<br>"; $ilBench->start("GlossaryExport", "buildExportFile_getXML"); $this->glo_obj->exportXML($this->xml, $this->inst_id, $this->export_dir . "/" . $this->subdir, $expLog); $ilBench->stop("GlossaryExport", "buildExportFile_getXML"); // dump xml document to screen (only for debugging reasons) /* echo "<PRE>"; echo htmlentities($this->xml->xmlDumpMem($format)); echo "</PRE>"; */ // dump xml document to file $ilBench->start("GlossaryExport", "buildExportFile_dumpToFile"); $this->xml->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->filename, false); $ilBench->stop("GlossaryExport", "buildExportFile_dumpToFile"); // zip the file $ilBench->start("GlossaryExport", "buildExportFile_zipFile"); ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip"); $ilBench->stop("GlossaryExport", "buildExportFile_zipFile"); // destroy writer object $this->xml->_XmlWriter; $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export"); $ilBench->stop("GlossaryExport", "buildExportFile"); return $this->export_dir . "/" . $this->subdir . ".zip"; }
/** * export html package */ function exportHTML($a_target_dir, $log) { global $ilias, $tpl; // initialize temporary target directory ilUtil::delDir($a_target_dir); ilUtil::makeDir($a_target_dir); include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php"; $this->co_page_html_export = new ilCOPageHTMLExport($a_target_dir); $this->co_page_html_export->createDirectories(); // export system style sheet $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem"); $style_name = $ilias->account->prefs["style"] . ".css"; copy($location_stylesheet, $a_target_dir . "/" . $style_name); $location_stylesheet = ilUtil::getStyleSheetLocation(); if ($this->getStyleSheetId() < 1) { $cont_stylesheet = "Services/COPage/css/content.css"; copy($cont_stylesheet, $a_target_dir . "/content.css"); } else { $content_style_img_dir = $a_target_dir . "/images"; ilUtil::makeDir($content_style_img_dir); $style = new ilObjStyleSheet($this->getStyleSheetId()); $style->writeCSSFile($a_target_dir . "/content.css", "images"); $style->copyImagesToDir($content_style_img_dir); } // export syntax highlighting style $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath(); copy($syn_stylesheet, $a_target_dir . "/syntaxhighlight.css"); // get glossary presentation gui class include_once "./Modules/Glossary/classes/class.ilGlossaryPresentationGUI.php"; $_GET["cmd"] = "nop"; $glo_gui =& new ilGlossaryPresentationGUI(); $glo_gui->setOfflineMode(true); $glo_gui->setOfflineDirectory($a_target_dir); // could be implemented in the future if other export // formats are supported (e.g. scorm) //$glo_gui->setExportFormat($a_export_format); // export terms $this->exportHTMLGlossaryTerms($glo_gui, $a_target_dir); // export all media objects foreach ($this->offline_mobs as $mob) { $this->exportHTMLMOB($a_target_dir, $glo_gui, $mob, "_blank"); } $_GET["obj_type"] = "MediaObject"; $_GET["obj_id"] = $a_mob_id; $_GET["cmd"] = ""; // export all file objects foreach ($this->offline_files as $file) { $this->exportHTMLFile($a_target_dir, $file); } // export images $image_dir = $a_target_dir . "/images"; ilUtil::makeDir($image_dir); ilUtil::makeDir($image_dir . "/browser"); copy(ilUtil::getImagePath("enlarge.svg", false, "filesystem"), $image_dir . "/enlarge.svg"); copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"), $image_dir . "/browser/plus.png"); copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"), $image_dir . "/browser/minus.png"); copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"), $image_dir . "/browser/blank.png"); copy(ilUtil::getImagePath("icon_st.svg", false, "filesystem"), $image_dir . "/icon_st.svg"); copy(ilUtil::getImagePath("icon_pg.svg", false, "filesystem"), $image_dir . "/icon_pg.svg"); copy(ilUtil::getImagePath("nav_arr_L.png", false, "filesystem"), $image_dir . "/nav_arr_L.png"); copy(ilUtil::getImagePath("nav_arr_R.png", false, "filesystem"), $image_dir . "/nav_arr_R.png"); // template workaround: reset of template $tpl = new ilTemplate("tpl.main.html", true, true); $tpl->setVariable("LOCATION_STYLESHEET", $location_stylesheet); $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html"); // zip everything if (true) { // zip it all $date = time(); $zip_file = $this->getExportDirectory("html") . "/" . $date . "__" . IL_INST_ID . "__" . $this->getType() . "_" . $this->getId() . ".zip"; //echo "zip-".$a_target_dir."-to-".$zip_file; ilUtil::zip($a_target_dir, $zip_file); ilUtil::delDir($a_target_dir); } }
/** * build xml export file */ function buildExportFileXML() { global $ilBench; $ilBench->start("ContentObjectExport", "buildExportFile"); require_once "./Services/Xml/classes/class.ilXmlWriter.php"; $this->xml = new ilXmlWriter(); // set dtd definition $this->xml->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">"); // set generated comment $this->xml->xmlSetGenCmt("Export of ILIAS Content Module " . $this->cont_obj->getId() . " of installation " . $this->inst . "."); // set xml header $this->xml->xmlHeader(); // create directories $this->cont_obj->createExportDirectory(); ilUtil::makeDir($this->export_dir . "/" . $this->subdir); ilUtil::makeDir($this->export_dir . "/" . $this->subdir . "/objects"); // get Log File $expDir = $this->cont_obj->getExportDirectory(); $expLog = new ilLog($expDir, "export.log"); $expLog->delete(); $expLog->setLogFormat(""); $expLog->write(date("[y-m-d H:i:s] ") . "Start Export"); // get xml content //echo "ContObjExport:".$this->inst_id.":<br>"; $ilBench->start("ContentObjectExport", "buildExportFile_getXML"); $this->cont_obj->exportXML($this->xml, $this->inst_id, $this->export_dir . "/" . $this->subdir, $expLog); $ilBench->stop("ContentObjectExport", "buildExportFile_getXML"); // export style if ($this->cont_obj->getStyleSheetId() > 0) { include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $style_obj = new ilObjStyleSheet($this->cont_obj->getStyleSheetId(), false); //$style_obj->exportXML($this->export_dir."/".$this->subdir); $style_obj->setExportSubDir("style"); $style_file = $style_obj->export(); if (is_file($style_file)) { copy($style_file, $this->export_dir . "/" . $this->subdir . "/style.zip"); } } // dump xml document to screen (only for debugging reasons) /* echo "<PRE>"; echo htmlentities($this->xml->xmlDumpMem($format)); echo "</PRE>"; */ // dump xml document to file $this->xml->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->filename, false); // help export (workaround to use ref id here) if (ilObjContentObject::isOnlineHelpModule((int) $_GET["ref_id"])) { include_once "./Services/Export/classes/class.ilExport.php"; $exp = new ilExport(); $exp->exportEntity("help", $this->cont_obj->getId(), "4.3.0", "Services/Help", "OnlineHelp", $this->export_dir . "/" . $this->subdir); } // zip the file ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip"); // destroy writer object $this->xml->_XmlWriter; $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export"); $ilBench->stop("ContentObjectExport", "buildExportFile"); return $this->export_dir . "/" . $this->subdir . ".zip"; }
/** * the different export types are processed here * * @param * @access public * @return */ function offlineexport() { global $ilDB; if ($_POST["cmd"]["cancel"] != "") { $this->ctrl->setParameter($this, "frame", "maincontent"); $this->ctrl->redirect($this, "layout"); } switch ($this->lm->getType()) { case "dbk": //$this->lm_gui->offlineexport(); $_GET["frame"] = "maincontent"; $objRow["obj_id"] = ilObject::_lookupObjId($_GET["ref_id"]); $_GET["obj_id"] = $objRow["obj_id"]; $query = "SELECT * FROM lm_data WHERE lm_id = " . $ilDB->quote($objRow["obj_id"], "integer") . " AND type='pg' "; $result = $ilDB->query($query); $page = 0; $showpage = 0; while (is_array($row = $ilDB->fetchAssoc($result))) { $page++; if ($_POST["pages"] == "all" || $_POST["pages"] == "fromto" && $page >= $_POST["pagefrom"] && $page <= $_POST["pageto"]) { if ($showpage > 0) { if ($_POST["type"] == "pdf") { $output .= "<hr BREAK >\n"; } if ($_POST["type"] == "print") { $output .= "<p style=\"page-break-after:always\" />"; } if ($_POST["type"] == "html") { $output .= "<br><br><br><br>"; } } $showpage++; $_GET["obj_id"] = $row["obj_id"]; $o = $this->layout("main.xml", false); $output .= "<div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" class=\"ilc_PageTitle\">" . $this->lm->title . "</div><p>"; $output .= $o; $output .= "\n<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td valign=top align=center>- " . $page . " -</td></tr></table>\n"; } } $printTpl = new ilTemplate("tpl.print.html", true, true, "Modules/LearningModule"); if ($_POST["type"] == "print") { $printTpl->touchBlock("printreq"); $css1 = ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()); $css2 = ilUtil::getStyleSheetLocation(); } else { $css1 = "./css/delos.css"; $css2 = "./css/content.css"; } $printTpl->setVariable("LOCATION_CONTENT_STYLESHEET", $css1); $printTpl->setVariable("LOCATION_STYLESHEET", $css2); $printTpl->setVariable("CONTENT", $output); // syntax style $printTpl->setCurrentBlock("SyntaxStyle"); $printTpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath()); $printTpl->parseCurrentBlock(); $html = $printTpl->get(); /** * Check if export-directory exists */ $this->lm->createExportDirectory(); $export_dir = $this->lm->getExportDirectory(); /** * create html-offline-directory */ $fileName = "offline"; $fileName = str_replace(" ", "_", $fileName); if (!file_exists($export_dir . "/" . $fileName)) { @mkdir($export_dir . "/" . $fileName); @chmod($export_dir . "/" . $fileName, 0755); @mkdir($export_dir . "/" . $fileName . "/css"); @chmod($export_dir . "/" . $fileName . "/css", 0755); } if ($_POST["type"] == "xml") { //vd($_GET["ref_id"]); $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($_GET["ref_id"]); if ($tmp_obj->getType() == "dbk") { require_once "./Modules/LearningModule/classes/class.ilObjDlBook.php"; $dbk =& new ilObjDlBook($_GET["ref_id"]); $dbk->export(); } } else { if ($_POST["type"] == "print") { echo $html; } else { if ($_POST["type"] == "html") { /** * copy data into dir * zip all end deliver zip-file for download */ $css1 = file("./templates/default/delos.css"); $css1 = implode($css1, ""); $fp = fopen($export_dir . "/" . $fileName . "/css/delos.css", "wb"); fwrite($fp, $css1); fclose($fp); $fp = fopen($export_dir . "/" . $fileName . "/" . $fileName . ".html", "wb"); fwrite($fp, $html); fclose($fp); ilUtil::zip($export_dir . "/" . $fileName, $export_dir . "/" . $fileName . ".zip"); ilUtil::deliverFile($export_dir . "/" . $fileName . ".zip", $fileName . ".zip"); } else { if ($_POST["type"] == "pdf") { ilUtil::html2pdf($html, $export_dir . "/" . $fileName . ".pdf"); ilUtil::deliverFile($export_dir . "/" . $fileName . ".pdf", $fileName . ".pdf"); } } } } exit; } }
/** * Build export file * * @param * @return */ function buildExportFile() { global $ilias; // create export file include_once "./Services/Export/classes/class.ilExport.php"; ilExport::_createExportDirectory($this->object->getId(), "html", "prtf"); $exp_dir = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf"); $this->subdir = $this->object->getType() . "_" . $this->object->getId(); $this->export_dir = $exp_dir . "/" . $this->subdir; // initialize temporary target directory ilUtil::delDir($this->export_dir); ilUtil::makeDir($this->export_dir); // system style html exporter include_once "./Services/Style/classes/class.ilSystemStyleHTMLExport.php"; $this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir); // $this->sys_style_html_export->addImage("icon_prtf.svg"); $this->sys_style_html_export->export(); // init co page html exporter include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php"; $this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir); $this->co_page_html_export->setContentStyleId($this->object->getStyleSheetId()); $this->co_page_html_export->createDirectories(); $this->co_page_html_export->exportStyles(); $this->co_page_html_export->exportSupportScripts(); // banner $prfa_set = new ilSetting("prfa"); if ($prfa_set->get("banner")) { $banner = $this->object->getImageFullPath(); if ($banner) { copy($banner, $this->export_dir . "/" . basename($banner)); } } // page element: profile picture $ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "big", true, true); if ($ppic) { $ppic = array_shift(explode("?", $ppic)); copy($ppic, $this->export_dir . "/" . basename($ppic)); } // header image: profile picture $ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "xsmall", true, true); if ($ppic) { $ppic = array_shift(explode("?", $ppic)); copy($ppic, $this->export_dir . "/" . basename($ppic)); } // export pages $this->exportHTMLPages(); // add js/images/file to zip $images = $files = $js_files = array(); foreach ($this->export_material as $items) { $images = array_merge($images, $items["images"]); $files = array_merge($files, $items["files"]); $js_files = array_merge($js_files, $items["js"]); } foreach (array_unique($images) as $image) { if (is_file($image)) { copy($image, $this->export_dir . "/images/" . basename($image)); } } foreach (array_unique($js_files) as $js_file) { if (is_file($js_file)) { copy($js_file, $this->export_dir . "/js/" . basename($js_file)); } } foreach (array_unique($files) as $file) { if (is_file($file)) { copy($file, $this->export_dir . "/files/" . basename($file)); } } // zip everything if (true) { // zip it all $date = time(); $zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf") . "/" . $date . "__" . IL_INST_ID . "__" . $this->object->getType() . "_" . $this->object->getId() . ".zip"; ilUtil::zip($this->export_dir, $zip_file); ilUtil::delDir($this->export_dir); } return $zip_file; }
function zipFile($a_rel_name, $a_zip_name) { ilUtil::zip($this->getCoursePath() . '/' . $a_rel_name, $this->getCoursePath() . '/' . $a_zip_name); // RETURN filesize return filesize($this->getCoursePath() . '/' . $a_zip_name); }
/** * build xml export file */ function buildExportFileXML($questions = null) { global $ilBench; $ilBench->start("SurveyQuestionpoolExport", "buildExportFile"); // create directories $this->spl_obj->createExportDirectory(); include_once "./Services/Utilities/classes/class.ilUtil.php"; ilUtil::makeDir($this->export_dir . "/" . $this->subdir); // get Log File include_once "./Services/Logging/classes/class.ilLog.php"; $expLog = new ilLog($this->spl_obj->getExportDirectory(), "export.log"); $expLog->delete(); $expLog->setLogFormat(""); $expLog->write(date("[y-m-d H:i:s] ") . "Start Export"); // write qti file $qti_file = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->filename, "w"); fwrite($qti_file, $this->spl_obj->toXML($questions)); fclose($qti_file); // destroy writer object $this->xml->_XmlWriter; ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip"); $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export"); $ilBench->stop("SurveyQuestionpoolExport", "buildExportFile"); return $this->export_dir . "/" . $this->subdir . ".zip"; }
/** * Zip archive directory * * @access public * @param string relative name of directory to zip * @param string zip archive name * @return int filesize of zip archive * */ public function zipArchive($a_rel_name, $a_zip_name) { ilUtil::zip($this->getArchiveDirectory() . '/' . $a_rel_name, $this->getArchiveDirectory() . '/' . $a_zip_name); return filesize($this->getArchiveDirectory() . '/' . $a_zip_name); }
/** * build xml export file */ function buildExportFileXLS() { global $ilBench; $ilBench->start("QuestionpoolExport", "buildExportFile"); include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php"; $adapter = new ilExcelWriterAdapter($this->export_dir . "/" . $this->filename, FALSE); $workbook = $adapter->getWorkbook(); $workbook->setVersion(8); // Use Excel97/2000 Format $format_bold =& $workbook->addFormat(); $format_bold->setBold(); $format_percent =& $workbook->addFormat(); $format_percent->setNumFormat("0.00%"); $format_datetime =& $workbook->addFormat(); $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss"); $format_title =& $workbook->addFormat(); $format_title->setBold(); $format_title->setColor('black'); $format_title->setPattern(1); $format_title->setFgColor('silver'); $worksheet =& $workbook->addWorksheet(); $row = 0; $col = 0; // title row include_once "./Services/Excel/classes/class.ilExcelUtils.php"; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("title"), "latin1"), $format_title); $col++; $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("description"), "latin1"), $format_title); $col++; $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("question_type"), "latin1"), $format_title); $col++; $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("author"), "latin1"), $format_title); $col++; $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("create_date"), "latin1"), $format_title); $col++; $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("last_update"), "latin1"), $format_title); $col = 0; $row++; $questions = $this->qpl_obj->getQuestionList(); foreach ($questions as $question) { $worksheet->write($row, $col, ilExcelUtils::_convert_text($question["title"], "latin1")); $col++; $worksheet->write($row, $col, ilExcelUtils::_convert_text($question["description"], "latin1")); $col++; $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt($question["type_tag"]), "latin1")); $col++; $worksheet->write($row, $col, ilExcelUtils::_convert_text($question["author"], "latin1")); $col++; // ilDatePresentation::formatDate(new ilDateTime($question["created"],IL_CAL_UNIX)) $worksheet->write($row, $col, ilExcelUtils::_convert_text(ilFormat::formatDate(ilFormat::ftimestamp2dateDB($question["created"]), "date"), "latin1")); $col++; $worksheet->write($row, $col, ilExcelUtils::_convert_text(ilFormat::formatDate(ilFormat::ftimestamp2dateDB($question["tstamp"]), "date"), "latin1")); $col = 0; $row++; } $workbook->close(); ilUtil::zip($this->export_dir . "/" . $this->filename, $this->export_dir . "/" . $this->zipfilename); if (@file_exists($this->export_dir . "/" . $this->filename)) { @unlink($this->export_dir . "/" . $this->filename); } }
/** * 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" ); */ }
/** * build xml export file */ function buildExportFileHTMLOne() { require_once "./Services/Xml/classes/class.ilXmlWriter.php"; // create directories $this->createExportDirectory(); ilUtil::makeDir($this->export_dir . "/" . $this->subdir); // get Log File $expDir = $this->export_dir; $expLog = new ilLog($expDir, "export.log"); $expLog->delete(); $expLog->setLogFormat(""); $expLog->write(date("[y-m-d H:i:s] ") . "Start Export"); // get xml content $this->cont_obj->exportHTMLOne($this->inst_id, $this->export_dir . "/" . $this->subdir, $expLog); // zip the file ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip", true); ilUtil::delDir($this->export_dir . "/" . $this->subdir); $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export"); return $this->export_dir . "/" . $this->subdir . ".zip"; }
/** * Create a ZIP file from a directory with certificates * * @param string $dir Directory containing the certificates * @param boolean $deliver TRUE to deliver the ZIP file, FALSE to return the filename only * @return string The created ZIP archive path */ public function zipCertificatesInArchiveDirectory($dir, $deliver = TRUE) { $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificates.zip"; ilUtil::zip($dir, $this->getAdapter()->getCertificatePath() . $zipfile); ilUtil::delDir($dir); if ($deliver) { ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip"); } return $this->getAdapter()->getCertificatePath() . $zipfile; }
/** * 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); }
private function downloadMultipleObjects($a_ref_ids) { global $lng, $rbacsystem, $ilAccess; include_once "./Services/Utilities/classes/class.ilUtil.php"; include_once 'Modules/Folder/classes/class.ilObjFolder.php'; include_once 'Modules/File/classes/class.ilObjFile.php'; include_once 'Modules/File/classes/class.ilFileException.php'; // create temporary file to download $zip = PATH_TO_ZIP; $tmpdir = ilUtil::ilTempnam(); ilUtil::makeDir($tmpdir); try { // copy each selected object foreach ($a_ref_ids as $ref_id) { if (!$ilAccess->checkAccess("read", "", $ref_id)) { continue; } if (ilObject::_isInTrash($ref_id)) { continue; } // get object $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id); $obj_type = $object->getType(); if ($obj_type == "fold") { // copy folder to temp directory self::recurseFolder($ref_id, $object->getTitle(), $tmpdir); } else { if ($obj_type == "file") { // copy file to temp directory self::copyFile($object->getId(), $object->getTitle(), $tmpdir); } } } // compress the folder $deliverFilename = ilUtil::getAsciiFilename($this->object->getTitle()) . ".zip"; $tmpzipfile = ilUtil::ilTempnam() . ".zip"; ilUtil::zip($tmpdir, $tmpzipfile, true); ilUtil::delDir($tmpdir); ilUtil::deliverFile($tmpzipfile, $deliverFilename, '', false, true, true); } catch (ilFileException $e) { ilUtil::sendInfo($e->getMessage(), true); } }
/** * Create export file * * @return string local file name of export file */ function export() { $this->cleanExportDirectory(); $ex_dir = $this->createExportDirectory(); $this->createExportSubDirectory(); $this->exportXML($ex_dir . "/" . $this->getExportSubDir()); //echo "-".$this->getImagesDirectory()."-".$ex_dir."/".$this->getExportSubDir()."/images"."-"; ilUtil::rCopy($this->getImagesDirectory(), $ex_dir . "/" . $this->getExportSubDir() . "/images"); if (is_file($ex_dir . "/" . $this->getExportSubDir() . ".zip")) { unlink($ex_dir . "/" . $this->getExportSubDir() . ".zip"); } ilUtil::zip($ex_dir . "/" . $this->getExportSubDir(), $ex_dir . "/" . $this->getExportSubDir() . ".zip"); return $ex_dir . "/" . $this->getExportSubDir() . ".zip"; }
/** * Generates a ZIP file containing all file uploads for a given test and the original id of the question * * @param int $test_id */ public function getFileUploadZIPFile($test_id) { /** @var ilDB $ilDB */ global $ilDB; $query = "\n\t\tSELECT \n\t\t\ttst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi, \n\t\t\ttst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp \n\t\tFROM tst_solutions, tst_active, qpl_questions \n\t\tWHERE tst_solutions.active_fi = tst_active.active_id \n\t\tAND tst_solutions.question_fi = qpl_questions.question_id \n\t\tAND tst_solutions.question_fi = %s \n\t\tAND tst_active.test_fi = %s \n\t\tORDER BY tst_solutions.active_fi, tst_solutions.tstamp"; $result = $ilDB->queryF($query, array("integer", "integer"), array($this->getId(), $test_id)); $zipfile = ilUtil::ilTempnam() . ".zip"; $tempdir = ilUtil::ilTempnam(); if ($result->numRows()) { $userdata = array(); $data .= "<html><head>"; $data .= '<meta http-equiv="content-type" content="text/html; charset=UTF-8" />'; $data .= '<style> table { border: 1px #333 solid; border-collapse:collapse;} td, th { border: 1px #333 solid; padding: 0.25em;} th { color: #fff; background-color: #666;} </style> '; $data .= "<title>" . $this->getTitle() . "</title></head><body>\n"; $data .= "<h1>" . $this->getTitle() . "</h1>\n"; $data .= "<table><thead>\n"; $data .= "<tr><th>" . $this->lng->txt("name") . "</th><th>" . $this->lng->txt("filename") . "</th><th>" . $this->lng->txt("pass") . "</th><th>" . $this->lng->txt("location") . "</th><th>" . $this->lng->txt("date") . "</th></tr></thead><tbody>\n"; while ($row = $ilDB->fetchAssoc($result)) { ilUtil::makeDirParents($tempdir . "/" . $row["active_fi"] . "/" . $row["question_fi"]); @copy($this->getFileUploadPath($test_id, $row["active_fi"], $row["question_fi"]) . $row["value1"], $tempdir . "/" . $row["active_fi"] . "/" . $row["question_fi"] . "/" . $row["value1"]); if (!array_key_exists($row["active_fi"], $userdata)) { include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; $userdata[$row["active_fi"]] = ilObjTestAccess::_getParticipantData($row["active_fi"]); } $data .= "<tr><td>" . $userdata[$row["active_fi"]] . "</td><td><a href=\"" . $row["active_fi"] . "/" . $row["question_fi"] . "/" . $row["value1"] . "\" target=\"_blank\">" . $row["value2"] . "</a></td><td>" . $row["pass"] . "</td><td>" . $row["active_fi"] . "/" . $row["question_fi"] . "/" . $row["value1"] . "</td>"; $data .= "<td>" . ilFormat::fmtDateTime(ilFormat::unixtimestamp2datetime($row["tstamp"]), $this->lng->txt("lang_dateformat"), $this->lng->txt("lang_timeformat"), "datetime", FALSE) . "</td>"; $data .= "</tr>\n"; } $data .= "</tbody></table>\n"; $data .= "</body></html>\n"; $indexfile = $tempdir . "/index.html"; $fh = fopen($indexfile, 'w'); fwrite($fh, $data); fclose($fh); } ilUtil::zip($tempdir, $zipfile); ilUtil::delDir($tempdir); ilUtil::deliverFile($zipfile, ilUtil::getASCIIFilename($this->getTitle() . ".zip"), "application/zip", false, true); }
public function downloadFolder() { global $lng, $rbacsystem, $ilAccess; include_once "./Services/Utilities/classes/class.ilUtil.php"; include_once 'Modules/File/classes/class.ilObjFile.php'; include_once 'Modules/File/classes/class.ilFileException.php'; if (!$ilAccess->checkAccess("read", "", $this->getRefId())) { $this->ilErr->raiseError(get_class($this) . "::downloadFolder(): missing read permission!", $this->ilErr->WARNING); } if (ilObject::_isInTrash($this->getRefId())) { $this->ilErr->raiseError(get_class($this) . "::downloadFolder(): object is trashed!", $this->ilErr->WARNING); } $zip = PATH_TO_ZIP; $tmpdir = ilUtil::ilTempnam(); ilUtil::makeDir($tmpdir); $basename = ilUtil::getAsciiFilename($this->getTitle()); $deliverFilename = $basename . ".zip"; $zipbasedir = $tmpdir . DIRECTORY_SEPARATOR . $basename; $tmpzipfile = $tmpdir . DIRECTORY_SEPARATOR . $deliverFilename; try { ilObjFolder::recurseFolder($this->getRefId(), $this->getTitle(), $tmpdir); ilUtil::zip($zipbasedir, $tmpzipfile); rename($tmpzipfile, $zipfile = ilUtil::ilTempnam()); ilUtil::delDir($tmpdir); ilUtil::deliverFile($zipfile, $deliverFilename, '', false, true); } catch (ilFileException $e) { ilUtil::sendInfo($e->getMessage(), true); } }
/** * export html package */ function exportHTML($a_target_dir, $log, $a_zip_file = true, $a_export_format = "html") { global $tpl, $ilBench, $ilLocator, $ilUser; // initialize temporary target directory ilUtil::delDir($a_target_dir); ilUtil::makeDir($a_target_dir); $mob_dir = $a_target_dir . "/mobs"; ilUtil::makeDir($mob_dir); $file_dir = $a_target_dir . "/files"; ilUtil::makeDir($file_dir); $teximg_dir = $a_target_dir . "/teximg"; ilUtil::makeDir($teximg_dir); $style_dir = $a_target_dir . "/style"; ilUtil::makeDir($style_dir); $style_img_dir = $a_target_dir . "/style/images"; ilUtil::makeDir($style_img_dir); $content_style_dir = $a_target_dir . "/content_style"; ilUtil::makeDir($content_style_dir); $content_style_img_dir = $a_target_dir . "/content_style/images"; ilUtil::makeDir($content_style_img_dir); $GLOBALS["teximgcnt"] = 0; // export system style sheet $location_stylesheet = ilUtil::getStyleSheetLocation("filesystem"); $style_name = $ilUser->prefs["style"] . ".css"; copy($location_stylesheet, $style_dir . "/" . $style_name); $fh = fopen($location_stylesheet, "r"); $css = fread($fh, filesize($location_stylesheet)); preg_match_all("/url\\(([^\\)]*)\\)/", $css, $files); foreach (array_unique($files[1]) as $fileref) { $fileref = dirname($location_stylesheet) . "/" . $fileref; if (is_file($fileref)) { copy($fileref, $style_img_dir . "/" . basename($fileref)); } } fclose($fh); $location_stylesheet = ilUtil::getStyleSheetLocation(); // export content style sheet $ilBench->start("ExportHTML", "exportContentStyle"); if ($this->getStyleSheetId() < 1) { $cont_stylesheet = "./Services/COPage/css/content.css"; $css = fread(fopen($cont_stylesheet, 'r'), filesize($cont_stylesheet)); preg_match_all("/url\\(([^\\)]*)\\)/", $css, $files); foreach (array_unique($files[1]) as $fileref) { if (is_file(str_replace("..", ".", $fileref))) { copy(str_replace("..", ".", $fileref), $content_style_img_dir . "/" . basename($fileref)); } $css = str_replace($fileref, "images/" . basename($fileref), $css); } fwrite(fopen($content_style_dir . "/content.css", 'w'), $css); } else { $style = new ilObjStyleSheet($this->getStyleSheetId()); $style->writeCSSFile($content_style_dir . "/content.css", "images"); $style->copyImagesToDir($content_style_img_dir); } $ilBench->stop("ExportHTML", "exportContentStyle"); // export syntax highlighting style $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath(); copy($syn_stylesheet, $a_target_dir . "/syntaxhighlight.css"); // get learning module presentation gui class include_once "./Modules/LearningModule/classes/class.ilLMPresentationGUI.php"; $_GET["cmd"] = "nop"; $lm_gui =& new ilLMPresentationGUI(); $lm_gui->setOfflineMode(true); $lm_gui->setOfflineDirectory($a_target_dir); $lm_gui->setExportFormat($a_export_format); // export pages $ilBench->start("ExportHTML", "exportHTMLPages"); $this->exportHTMLPages($lm_gui, $a_target_dir); $ilBench->stop("ExportHTML", "exportHTMLPages"); // export glossary terms $ilBench->start("ExportHTML", "exportHTMLGlossaryTerms"); $this->exportHTMLGlossaryTerms($lm_gui, $a_target_dir); $ilBench->stop("ExportHTML", "exportHTMLGlossaryTerms"); // export all media objects $ilBench->start("ExportHTML", "exportHTMLMediaObjects"); $linked_mobs = array(); foreach ($this->offline_mobs as $mob) { if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") { $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs); } } $linked_mobs2 = array(); // mobs linked in link areas foreach ($linked_mobs as $mob) { if (ilObject::_exists($mob)) { $this->exportHTMLMOB($a_target_dir, $lm_gui, $mob, "_blank", $linked_mobs2); } } $_GET["obj_type"] = "MediaObject"; $_GET["obj_id"] = $a_mob_id; $_GET["cmd"] = ""; $ilBench->stop("ExportHTML", "exportHTMLMediaObjects"); // export all file objects $ilBench->start("ExportHTML", "exportHTMLFileObjects"); foreach ($this->offline_files as $file) { $this->exportHTMLFile($a_target_dir, $file); } $ilBench->stop("ExportHTML", "exportHTMLFileObjects"); // export table of contents $ilBench->start("ExportHTML", "exportHTMLTOC"); $ilLocator->clearItems(); if ($this->isActiveTOC()) { $tpl = new ilTemplate("tpl.main.html", true, true); //$tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html"); $content =& $lm_gui->showTableOfContents(); $file = $a_target_dir . "/table_of_contents.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); } $ilBench->stop("ExportHTML", "exportHTMLTOC"); // export images $ilBench->start("ExportHTML", "exportHTMLImages"); $image_dir = $a_target_dir . "/images"; ilUtil::makeDir($image_dir); ilUtil::makeDir($image_dir . "/browser"); copy(ilUtil::getImagePath("enlarge.png", false, "filesystem"), $image_dir . "/enlarge.png"); copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"), $image_dir . "/browser/plus.png"); copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"), $image_dir . "/browser/minus.png"); copy(ilUtil::getImagePath("browser/blank.png", false, "filesystem"), $image_dir . "/browser/blank.png"); copy(ilUtil::getImagePath("spacer.png", false, "filesystem"), $image_dir . "/spacer.png"); copy(ilUtil::getImagePath("icon_st.png", false, "filesystem"), $image_dir . "/icon_st.png"); copy(ilUtil::getImagePath("icon_pg.png", false, "filesystem"), $image_dir . "/icon_pg.png"); copy(ilUtil::getImagePath("icon_st_s.png", false, "filesystem"), $image_dir . "/icon_st_s.png"); copy(ilUtil::getImagePath("icon_pg_s.png", false, "filesystem"), $image_dir . "/icon_pg_s.png"); copy(ilUtil::getImagePath("icon_lm.png", false, "filesystem"), $image_dir . "/icon_lm.png"); copy(ilUtil::getImagePath("icon_lm_s.png", false, "filesystem"), $image_dir . "/icon_lm_s.png"); copy(ilUtil::getImagePath("nav_arr_L.png", false, "filesystem"), $image_dir . "/nav_arr_L.png"); copy(ilUtil::getImagePath("nav_arr_R.png", false, "filesystem"), $image_dir . "/nav_arr_R.png"); copy(ilUtil::getImagePath("browser/forceexp.png", false, "filesystem"), $image_dir . "/browser/forceexp.png"); copy(ilUtil::getImagePath("download.png", false, "filesystem"), $image_dir . "/download.png"); $ilBench->stop("ExportHTML", "exportHTMLImages"); // export flv/mp3 player $services_dir = $a_target_dir . "/Services"; ilUtil::makeDir($services_dir); $media_service_dir = $services_dir . "/MediaObjects"; ilUtil::makeDir($media_service_dir); include_once "./Services/MediaObjects/classes/class.ilPlayerUtil.php"; $flv_dir = $a_target_dir . "/" . ilPlayerUtil::getFlashVideoPlayerDirectory(); ilUtil::makeDir($flv_dir); $mp3_dir = $media_service_dir . "/flash_mp3_player"; ilUtil::makeDir($mp3_dir); // copy(ilPlayerUtil::getFlashVideoPlayerFilename(true), // $flv_dir."/".ilPlayerUtil::getFlashVideoPlayerFilename()); ilPlayerUtil::copyPlayerFilesToTargetDirectory($flv_dir); // js files ilUtil::makeDir($a_target_dir . '/js'); ilUtil::makeDir($a_target_dir . '/js/yahoo'); ilUtil::makeDir($a_target_dir . '/css'); include_once "./Services/YUI/classes/class.ilYuiUtil.php"; foreach (self::getSupplyingExportFiles($a_target_dir) as $f) { if ($f["source"] != "") { copy($f["source"], $f["target"]); } } // template workaround: reset of template $tpl = new ilTemplate("tpl.main.html", true, true); $tpl->setVariable("LOCATION_STYLESHEET", $location_stylesheet); $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html"); // zip everything $ilBench->start("ExportHTML", "zip"); if (true) { if ($a_zip_file) { // zip it all $date = time(); $zip_file = $this->getExportDirectory("html") . "/" . $date . "__" . IL_INST_ID . "__" . $this->getType() . "_" . $this->getId() . ".zip"; ilUtil::zip($a_target_dir, $zip_file); ilUtil::delDir($a_target_dir); } } $ilBench->stop("ExportHTML", "zip"); }
/** * Generate the test archive for download. * * @return void */ public function compressTestArchive() { $this->updateTestArchive(); $this->ensureZipExportDirectoryExists(); $zip_output_path = $this->getZipExportDirectory(); $zip_output_filename = 'test_archive_obj_' . $this->test_obj_id . '_' . time() . '_.zip'; ilUtil::zip($this->getTestArchive(), $zip_output_path . self::DIR_SEP . $zip_output_filename, true); return; }
public function zipLmForOfflineMode() { $lmDir = ilUtil::getWebspaceDir("filesystem") . "/lm_data/lm_" . $this->getId(); $zipFile = ilUtil::getDataDir() . "/lm_data/lm_" . $this->getId(); return ilUtil::zip($lmDir, $zipFile, true); }
/** * build xml export file */ function buildExportFileXML() { global $ilBench; $ilBench->start("TestExport", "buildExportFile"); include_once "./Services/Xml/classes/class.ilXmlWriter.php"; $this->xml = new ilXmlWriter(); // set dtd definition $this->xml->xmlSetDtdDef("<!DOCTYPE Test SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co.dtd\">"); // set generated comment $this->xml->xmlSetGenCmt("Export of ILIAS Test " . $this->test_obj->getId() . " of installation " . $this->inst . "."); // set xml header $this->xml->xmlHeader(); // create directories $this->test_obj->createExportDirectory(); include_once "./Services/Utilities/classes/class.ilUtil.php"; ilUtil::makeDir($this->export_dir . "/" . $this->subdir); ilUtil::makeDir($this->export_dir . "/" . $this->subdir . "/objects"); // get Log File $expDir = $this->test_obj->getExportDirectory(); include_once "./Services/Logging/classes/class.ilLog.php"; $expLog = new ilLog($expDir, "export.log"); $expLog->delete(); $expLog->setLogFormat(""); $expLog->write(date("[y-m-d H:i:s] ") . "Start Export"); // write qti file $qti_file = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->qti_filename, "w"); fwrite($qti_file, $this->test_obj->toXML()); fclose($qti_file); // get xml content $ilBench->start("TestExport", "buildExportFile_getXML"); $this->test_obj->exportPagesXML($this->xml, $this->inst_id, $this->export_dir . "/" . $this->subdir, $expLog); $ilBench->stop("TestExport", "buildExportFile_getXML"); // dump xml document to screen (only for debugging reasons) /* echo "<PRE>"; echo htmlentities($this->xml->xmlDumpMem($format)); echo "</PRE>"; */ // dump xml document to file $ilBench->start("TestExport", "buildExportFile_dumpToFile"); $this->xml->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->filename, false); $ilBench->stop("TestExport", "buildExportFile_dumpToFile"); if (@file_exists("./Modules/Test/classes/class.ilTestResultsToXML.php")) { // dump results xml document to file include_once "./Modules/Test/classes/class.ilTestResultsToXML.php"; $resultwriter = new ilTestResultsToXML($this->test_obj->getTestId(), $this->test_obj->getAnonymity()); $ilBench->start("TestExport", "buildExportFile_results"); $resultwriter->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->resultsfile, false); $ilBench->stop("TestExport", "buildExportFile_results"); } // add media objects which were added with tiny mce $ilBench->start("QuestionpoolExport", "buildExportFile_saveAdditionalMobs"); $this->exportXHTMLMediaObjects($this->export_dir . "/" . $this->subdir); $ilBench->stop("QuestionpoolExport", "buildExportFile_saveAdditionalMobs"); // zip the file $ilBench->start("TestExport", "buildExportFile_zipFile"); ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip"); $ilBench->stop("TestExport", "buildExportFile_zipFile"); // destroy writer object $this->xml->_XmlWriter; $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export"); $ilBench->stop("TestExport", "buildExportFile"); return $this->export_dir . "/" . $this->subdir . ".zip"; }
/** * Download the given IDs of certificates as ZIP-File. * Note: No permission checking, this must be done by the controller calling this method * * @param array $cert_ids * @param string $filename Filename of zip, appended to the current date */ public static function downloadAsZip(array $cert_ids = array(), $filename = 'certificates') { if (count($cert_ids)) { $zip_filename = date('d-m-Y') . '-' . $filename; // Make a random temp dir in ilias data directory $tmp_dir = ilUtil::ilTempnam(); ilUtil::makeDir($tmp_dir); $zip_base_dir = $tmp_dir . DIRECTORY_SEPARATOR . $zip_filename; ilUtil::makeDir($zip_base_dir); // Copy all PDFs in folder foreach ($cert_ids as $cert_id) { /** @var srCertificate $cert */ $cert = srCertificate::find((int) $cert_id); if (!is_null($cert) && $cert->getStatus() == srCertificate::STATUS_PROCESSED) { copy($cert->getFilePath(), $zip_base_dir . DIRECTORY_SEPARATOR . $cert->getFilename(true)); } } $tmp_zip_file = $tmp_dir . DIRECTORY_SEPARATOR . $zip_filename . '.zip'; try { ilUtil::zip($zip_base_dir, $tmp_zip_file); rename($tmp_zip_file, $zip_file = ilUtil::ilTempnam()); ilUtil::delDir($tmp_dir); ilUtil::deliverFile($zip_file, $zip_filename . '.zip', '', false, true); } catch (ilFileException $e) { ilUtil::sendInfo($e->getMessage()); } } }