/**
  * Export content style
  *
  * @param
  * @return
  */
 function exportStyles()
 {
     include_once "Services/Style/classes/class.ilObjStyleSheet.php";
     // export content style sheet
     if ($this->getContentStyleId() < 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), $this->content_style_img_dir . "/" . basename($fileref));
             }
             $css = str_replace($fileref, "images/" . basename($fileref), $css);
         }
         fwrite(fopen($this->content_style_dir . "/content.css", 'w'), $css);
     } else {
         $style = new ilObjStyleSheet($this->getContentStyleId());
         $style->writeCSSFile($this->content_style_dir . "/content.css", "images");
         $style->copyImagesToDir($this->content_style_img_dir);
     }
     // export syntax highlighting style
     $syn_stylesheet = ilObjStyleSheet::getSyntaxStylePath();
     copy($syn_stylesheet, $this->exp_dir . "/syntaxhighlight.css");
 }
 /**
  * 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");
 }
 /**
  * get content style path
  *
  * static (to avoid full reading)
  */
 function getContentStylePath($a_style_id)
 {
     global $ilias;
     $rand = rand(1, 999999);
     // check global fixed content style
     $fixed_style = $ilias->getSetting("fixed_content_style_id");
     if ($fixed_style > 0) {
         $a_style_id = $fixed_style;
     }
     // check global default style
     if ($a_style_id <= 0) {
         $a_style_id = $ilias->getSetting("default_content_style_id");
     }
     if ($a_style_id > 0 && ilObject::_exists($a_style_id)) {
         // check whether file is up to date
         if (!ilObjStyleSheet::_lookupUpToDate($a_style_id)) {
             $style = new ilObjStyleSheet($a_style_id);
             $style->writeCSSFile();
         }
         return ilUtil::getWebspaceDir("output") . "/css/style_" . $a_style_id . ".css?dummy={$rand}";
     } else {
         return "./Services/COPage/css/content.css";
     }
 }
Esempio n. 4
0
 /**
  * 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);
     }
 }