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 * * @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); } }
/** * Get export files */ function getExportFiles() { $types = array(); foreach ($this->parent_obj->getFormats() as $f) { $types[] = $f["key"]; } include_once "./Services/Export/classes/class.ilExport.php"; $files = ilExport::_getExportFiles($this->obj->getId(), $types, $this->obj->getType()); return $files; }
/** * 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; }
function ilSubItemSelectionTableGUI($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_cmd = "createExportFile", $a_cmd_txt = "") { global $ilCtrl, $lng; parent::__construct($a_parent_obj, $a_parent_cmd); $lng->loadLanguageModule("export"); if ($a_cmd_txt == "") { $a_cmd_txt = $lng->txt("export_create_export_file"); } $this->addColumn($lng->txt("export_resource")); $this->addColumn($lng->txt("export_last_export")); $this->addColumn($lng->txt("export_last_export_file"), "", "20%"); $this->addColumn($lng->txt("export_create_new_file"), "", "20%"); $this->addColumn($lng->txt("export_omit_resource"), "", "20%"); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); $this->addCommandButton($a_cmd, $a_cmd_txt); $this->setRowTemplate("tpl.sub_item_selection_row.html", "Services/Export"); $this->setTitle($lng->txt("export_select_resources")); include_once "./Services/Export/classes/class.ilExport.php"; $this->setData(ilExport::_getValidExportSubItems($a_ref_id)); $this->setLimit(99999); }
/** * Save selection of subitems * @return */ protected function saveItemSelection() { global $tree, $objDefinition, $ilAccess, $ilCtrl, $lng; include_once './Services/Export/classes/class.ilExportOptions.php'; $eo = ilExportOptions::newInstance(ilExportOptions::allocateExportId()); $eo->addOption(ilExportOptions::KEY_ROOT, 0, 0, $this->obj->getId()); $items_selected = false; foreach ($tree->getSubTree($root = $tree->getNodeData($this->getParentGUI()->object->getRefId())) as $node) { if ($node['type'] == 'rolf') { continue; } if ($node['ref_id'] == $this->getParentGUI()->object->getRefId()) { $eo->addOption(ilExportOptions::KEY_ITEM_MODE, $node['ref_id'], $node['obj_id'], ilExportOptions::EXPORT_BUILD); continue; } // no export available or no access if (!$objDefinition->allowExport($node['type']) or !$ilAccess->checkAccess('write', '', $node['ref_id'])) { $eo->addOption(ilExportOptions::KEY_ITEM_MODE, $node['ref_id'], $node['obj_id'], ilExportOptions::EXPORT_OMIT); continue; } $mode = isset($_POST['cp_options'][$node['ref_id']]['type']) ? $_POST['cp_options'][$node['ref_id']]['type'] : ilExportOptions::EXPORT_OMIT; $eo->addOption(ilExportOptions::KEY_ITEM_MODE, $node['ref_id'], $node['obj_id'], $mode); if ($mode != ilExportOptions::EXPORT_OMIT) { $items_selected = true; } } include_once "./Services/Export/classes/class.ilExport.php"; if ($items_selected) { // TODO: move this to background soap $eo->read(); $exp = new ilExport(); foreach ($eo->getSubitemsForCreation($this->obj->getRefId()) as $ref_id) { $obj_id = ilObject::_lookupObjId($ref_id); $type = ilObject::_lookupType($obj_id); $exp->exportObject($type, $obj_id, '4.1.0'); } // Fixme: there is a naming conflict between the container settings xml and the container subitem xml. sleep(1); // Export container include_once './Services/Export/classes/class.ilExportContainer.php'; $cexp = new ilExportContainer($eo); $cexp->exportObject($this->obj->getType(), $this->obj->getId(), '4.1.0'); } else { $exp = new ilExport(); $exp->exportObject($this->obj->getType(), $this->obj->getId(), "4.1.0"); } // Delete export options $eo->delete(); ilUtil::sendSuccess($lng->txt('export_created'), true); $ilCtrl->redirect($this, "listExportFiles"); }
/** * Export page layout template object */ function exportLayoutObject() { include_once "./Services/Export/classes/class.ilExport.php"; $exp = new ilExport(); $tmpdir = ilUtil::ilTempnam(); ilUtil::makeDir($tmpdir); $succ = $exp->exportEntity("pgtp", (int) $_GET["layout_id"], "4.2.0", "Services/COPage", "Title", $tmpdir); if ($succ["success"]) { ilUtil::deliverFile($succ["directory"] . "/" . $succ["file"], $succ["file"], "", false, false, false); } if (is_file($succ["directory"] . "/" . $succ["file"])) { unlink($succ["directory"] . "/" . $succ["file"]); } if (is_dir($succ["directory"])) { unlink($succ["directory"]); } }
/** * 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); }
/** * Send personal data file * * @param * @return */ function sendPersonalDataFile() { include_once "./Services/Export/classes/class.ilExport.php"; $file = ilExport::_getExportDirectory($this->getId(), "xml", "usr", "personal_data") . "/" . $this->getPersonalDataExportFile(); if (is_file($file)) { ilUtil::deliverFile($file, $this->getPersonalDataExportFile()); } }
/** * Get export files */ function getExportFiles() { include_once "./Services/Export/classes/class.ilExport.php"; return ilExport::_getExportFiles($this->getId(), array("xml", "html"), $this->getType()); }
/** * 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"; }
/** * Add zip files to folder * * @param array selection array: key is ref_id, value is "last_file", "omit" or "create" */ function __addZipFiles($a_parent_id, $a_selection = "") { $this->course_obj->initCourseItemObject(); $this->course_obj->items_obj->setParentId($a_parent_id); foreach ($this->course_obj->items_obj->getAllItems() as $item) { if (!($tmp_obj =& ilObjectFactory::getInstanceByRefId($item['child'], false))) { continue; } $action = $a_selection[$item['child']]; if ($a_selection == "") { $action = "create"; } if ($action == "omit") { continue; } if ($action == "create") { $abs_file_name = $tmp_obj->getXMLZip(); } else { include_once "./Services/Export/classes/class.ilExport.php"; $info = ilExport::_getLastExportFileInformation($item['obj_id'], "xml", $item['type']); $abs_file_name = ilExport::_getExportDirectory($item['obj_id'], "xml", $item['type']) . "/" . $info["file"]; if (!@is_file($abs_file_name)) { $abs_file_name = ""; } } // must return absolute path to zip file if ($abs_file_name != "") { //$new_name = 'il_'.$this->ilias->getSetting('inst_id').'_'.$tmp_obj->getType().'_'.$item['obj_id'].'.zip'; $new_name = basename($abs_file_name); $this->course_files_obj->copyFile($abs_file_name, $this->course_files_obj->getArchiveDirectory() . '/' . $this->getName() . '/' . $new_name); if (is_file($this->course_files_obj->getArchiveDirectory() . '/' . $this->getName() . '/' . $new_name)) { $this->copied_files[] = array("title" => $item['title'], "file" => $new_name, "type" => $item['type']); } } $this->__addZipFiles($item['child']); unset($tmp_obj); } return true; }
/** * 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; }
/** * Add subitems * @param object $a_id * @param object $a_type * @return */ protected function addSubitems($a_id, $a_type, $a_target_release) { $GLOBALS['ilLog']->write(__METHOD__); $set_number = 1; foreach ($this->eo->getSubitemsForExport() as $ref_id) { // get last export file $obj_id = ilObject::_lookupObjId($ref_id); $expi = ilExportFileInfo::lookupLastExport($obj_id, 'xml', $a_target_release); if (!$expi instanceof ilExportFileInfo) { $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find export file for refId ' . $ref_id . ', type ' . ilObject::_lookupType($a_id)); continue; } $exp_dir = ilExport::_getExportDirectory($obj_id, 'xml', ilObject::_lookupType($obj_id)); $exp_full = $exp_dir . DIRECTORY_SEPARATOR . $expi->getFilename(); $GLOBALS['ilLog']->write(__METHOD__ . ': zip path ' . $exp_full); // Unzip ilUtil::unzip($exp_full, true, false); // create set directory ilUtil::makeDirParents($this->cont_export_dir . DIRECTORY_SEPARATOR . 'set_' . $set_number); // cut .zip $new_path_rel = 'set_' . $set_number . DIRECTORY_SEPARATOR . $expi->getBasename(); $new_path_abs = $this->cont_export_dir . DIRECTORY_SEPARATOR . $new_path_rel; $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $new_path_rel . ' ' . $new_path_abs); // Move export rename($exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename(), $new_path_abs); $GLOBALS['ilLog']->write($exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename() . ' -> ' . $new_path_abs); // Delete latest container xml of source if ($a_id == $obj_id) { $expi->delete(); if (file_exists($exp_full)) { $GLOBALS['ilLog']->write(__METHOD__ . ': Deleting' . $exp_full); unlink($exp_full); } } $this->cont_manifest_writer->xmlElement('ExportSet', array('Path' => $new_path_rel, 'Type' => ilObject::_lookupType($obj_id))); ++$set_number; } }
/** * Export an ILIAS object (the object type must be known by objDefinition) * * @param string $a_type repository object type * @param int $a_id id of object or entity that shoudl be exported * @param string $a_target_release target release * * @return array success and info array */ function exportObject($a_type, $a_id, $a_target_release) { global $objDefinition, $tpl; $comp = $objDefinition->getComponentForType($a_type); $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_type, "Title" => ilObject::_lookupTitle($a_id), "TargetRelease" => $a_target_release, "InstallationId" => IL_INST_ID, "InstallationUrl" => ILIAS_HTTP_PATH)); // get export class ilExport::_createExportDirectory($a_id, "xml", $a_type); $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type); $ts = time(); // Workaround for test assessment $sub_dir = $ts . '__' . IL_INST_ID . '__' . $a_type . '_' . $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_type, $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); // Store info about export if ($success) { include_once './Services/Export/classes/class.ilExportFileInfo.php'; $exp = new ilExportFileInfo($a_id); $exp->setVersion($a_target_release); $exp->setCreationDate(new ilDateTime($ts, IL_CAL_UNIX)); $exp->setExportType('xml'); $exp->setFilename($new_file); $exp->create(); } return array("success" => $success, "file" => $new_file, "directory" => $export_dir); }