Ejemplo n.º 1
0
 /**
  * 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);
     }
 }
 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->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;
 }
 /**
  * Download file
  */
 function download()
 {
     global $ilCtrl, $lng;
     if (!isset($_POST["file"])) {
         ilUtil::sendFailure($lng->txt("no_checkbox"), true);
         $ilCtrl->redirect($this, "listExportFiles");
     }
     if (count($_POST["file"]) > 1) {
         ilUtil::sendFailure($lng->txt("exp_select_max_one_item"), true);
         $ilCtrl->redirect($this, "listExportFiles");
     }
     $file = explode(":", $_POST["file"][0]);
     include_once "./Services/Export/classes/class.ilExport.php";
     $export_dir = ilExport::_getExportDirectory($this->obj->getId(), str_replace("..", "", $file[0]), $this->obj->getType());
     ilUtil::deliverFile($export_dir . "/" . $file[1], $file[1]);
 }
 /**
  * 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);
 }
Ejemplo n.º 6
0
 /**
  * Get export directory of glossary
  */
 function getExportDirectory($a_type = "xml")
 {
     include_once "./Services/Export/classes/class.ilExport.php";
     return ilExport::_getExportDirectory($this->getId(), $a_type, $this->getType());
 }
Ejemplo n.º 7
0
 /**
  * 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());
     }
 }
 /**
  * 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;
 }
Ejemplo n.º 10
0
 /**
  * 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;
     }
 }
Ejemplo n.º 11
0
 /**
  * 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);
 }
Ejemplo n.º 12
0
 /**
  * Download file
  */
 public function download()
 {
     global $ilCtrl, $lng;
     if (!isset($_GET["file"]) || is_array($_GET["file"])) {
         $ilCtrl->redirect($this, "listExportFiles");
     }
     $file = explode(":", trim($_GET["file"]));
     include_once "./Services/Export/classes/class.ilExport.php";
     $export_dir = ilExport::_getExportDirectory($this->obj->getId(), str_replace("..", "", $file[0]), $this->obj->getType());
     $file[1] = basename($file[1]);
     ilUtil::deliverFile($export_dir . "/" . $file[1], $file[1]);
 }