45 protected $mode = self::MODE_DEFAULT;
86 $this->db = $DIC->database();
87 $this->
user = $DIC->user();
88 $this->lng = $DIC->language();
89 $this->tabs = $DIC->tabs();
90 $this->wiki = $a_wiki;
92 $this->global_screen = $DIC->globalScreen();
93 $this->main_tpl = $DIC->ui()->mainTemplate();
103 $this->mode = $a_val;
129 $this->log->debug(
"buildExportFile...");
131 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
134 if ($this->
getMode() == self::MODE_USER) {
135 include_once(
"./Modules/Wiki/classes/class.ilWikiUserHTMLExport.php");
136 $this->user_html_exp = new \ilWikiUserHTMLExport($this->wiki,
$ilDB,
$ilUser);
142 include_once(
"./Services/Export/classes/class.ilExport.php");
147 if ($this->
getMode() == self::MODE_USER) {
151 if ($this->
getMode() == self::MODE_USER) {
152 $subdir = $ascii_name;
154 $subdir = $this->wiki->getType() .
"_" . $this->wiki->getId();
156 $this->export_dir = $exp_dir .
"/" . $subdir;
158 $this->export_util = new \ILIAS\Services\Export\HTML\Util($exp_dir, $subdir);
164 $this->log->debug(
"export directory: " . $this->export_dir);
167 $this->export_util->exportSystemStyle();
168 $this->export_util->exportCOPageFiles($this->wiki->getStyleSheetId(),
"wiki");
170 $this->co_page_html_export = new \ilCOPageHTMLExport($this->export_dir);
172 $this->wiki->getStyleSheetId(),
177 $this->log->debug(
"export pages");
181 $this->export_util->exportResourceFiles(
$global_screen, $this->export_dir);
184 $zip_file_name = ($this->
getMode() == self::MODE_USER)
185 ? $ascii_name .
".zip" 186 : $date .
"__" . IL_INST_ID .
"__" . $this->wiki->getType() .
"_" . $this->wiki->getId() .
".zip";
192 "/" . $zip_file_name;
193 $this->log->debug(
"zip: " . $zip_file);
213 foreach ($pages as $page) {
214 $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
215 $this->co_page_html_export->getPreparedMainTemplate(
$tpl);
216 $this->log->debug(
"page: " . $page[
"id"]);
218 $this->log->debug(
"export page");
220 $this->log->debug(
"collect page elements");
221 $this->co_page_html_export->collectPageElements(
"wpg:pg", $page[
"id"]);
224 if ($this->
getMode() == self::MODE_USER) {
226 $this->log->debug(
"update status: " . $cnt);
240 if ($this->
getMode() == self::MODE_USER) {
254 $this->log->debug(
"Export page:" . $a_page_id);
258 $ilTabs->clearTargets();
263 $file = $this->export_dir .
"/wpg_" . $a_page_id .
".html";
265 if (@is_file($file)) {
266 $this->log->debug(
"file already exists");
271 $this->log->debug(
"init page gui");
272 include_once(
"./Modules/Wiki/classes/class.ilWikiPageGUI.php");
273 $wpg_gui = new \ilWikiPageGUI($a_page_id);
274 $wpg_gui->setOutputMode(
"offline");
275 $page_content = $wpg_gui->showPage();
278 $this->log->debug(
"init page gui");
279 $ep_tpl = new \ilTemplate(
280 "tpl.export_page.html",
285 $ep_tpl->setVariable(
"PAGE_CONTENT", $page_content);
288 include_once(
"./Modules/Wiki/classes/class.ilWikiImportantPagesBlockGUI.php");
289 $bl = new \ilWikiImportantPagesBlockGUI();
293 $this->log->debug(
"set title");
294 $tpl->
setTitle($this->wiki->getTitle());
297 $lng->txt(
"obj_wiki")
304 $this->log->debug(
"write file: " . $file);
305 if (!($fp = @fopen($file,
"w+"))) {
306 $this->log->error(
"Could not open " . $file .
" for writing.");
307 include_once(
"./Modules/Wiki/exceptions/class.ilWikiExportException.php");
308 throw new \ilWikiExportException(
"Could not open \"" . $file .
"\" for writing.");
312 $this->log->debug(
"set permissions");
316 fwrite($fp, $content);
321 if ($this->wiki->getStartPage() == $wpg_gui->getPageObject()->getTitle()) {
322 copy($file, $this->export_dir .
"/index.html");
333 include_once(
"./Services/Export/classes/class.ilExport.php");
336 $this->log->debug(
"dir: " . $exp_dir);
338 $this->log->debug(
"file: " . $fileInfo->getFilename());
339 if (pathinfo($fileInfo->getFilename(), PATHINFO_EXTENSION) ==
"zip") {
340 $this->log->debug(
"return: " . $exp_dir .
"/" . $fileInfo->getFilename());
341 return $exp_dir .
"/" . $fileInfo->getFilename();
static _createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
buildExportFile()
Build export file.
setTitleIcon($a_icon_path, $a_icon_desc="")
setMode(string $a_val)
Set mode.
Wiki HTML exporter class.
__construct(\ilObjWiki $a_wiki)
Constructor.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
updateUserHTMLStatusForPageElements($a_total, $a_cnt)
Callback for updating the export status during elements export (media objects, files, ...)
Class ilGlobalPageTemplate.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
getUserExportFile()
Get user export file.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static getAllWikiPages($a_wiki_id)
Get all pages of wiki.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
setTitle($a_title, $hidden=false)
static getInstance()
Singleton: get instance.
exportPageHTML($a_page_id, \ilGlobalPageTemplate $tpl)
Export page html.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
static getLogger($a_component_id)
Get component logger.
const HTML_EXPORT_RENDERING
exportHTMLPages()
Export all pages.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively