36 protected \ilDBInterface
$db;
38 protected \ilLanguage
$lng;
41 protected string $mode = self::MODE_DEFAULT;
57 $this->db = $DIC->database();
58 $this->
user = $DIC->user();
59 $this->
lng = $DIC->language();
60 $this->
tabs = $DIC->tabs();
61 $this->wiki = $a_wiki;
63 $this->global_screen = $DIC->globalScreen();
64 $this->main_tpl = $DIC->ui()->mainTemplate();
65 $this->content_style_domain = $DIC
68 ->styleForRefId($a_wiki->
getRefId());
93 $this->log->debug(
"buildExportFile...");
97 if (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
98 $this->user_html_exp = new \ilWikiUserHTMLExport($this->wiki,
$ilDB,
$ilUser, ($this->
getMode() === self::MODE_USER_COMMENTS));
108 if (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
112 if (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
113 $subdir = $ascii_name;
115 $subdir = $this->wiki->getType() .
"_" . $this->wiki->getId();
118 if ($print_version) {
122 $this->export_dir = $exp_dir .
"/" . $subdir;
124 $this->export_util = new \ILIAS\Services\Export\HTML\Util($exp_dir, $subdir);
130 $this->log->debug(
"export directory: " . $this->export_dir);
133 $this->export_util->exportSystemStyle();
134 $eff_style_id = $this->content_style_domain->getEffectiveStyleId();
135 $this->export_util->exportCOPageFiles($eff_style_id,
"wiki");
136 $this->co_page_html_export = new \ilCOPageHTMLExport($this->export_dir);
137 $this->co_page_html_export->setContentStyleId($eff_style_id);
140 $this->log->debug(
"export pages");
141 if (!self::$context_init) {
142 $global_screen->tool()->context()->current()->addAdditionalData(
146 self::$context_init =
true;
148 if ($print_version) {
155 $this->export_util->exportResourceFiles();
158 $zip_file_name = (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS]))
159 ? $ascii_name .
".zip" 160 : $date .
"__" .
IL_INST_ID .
"__" . $this->wiki->getType() .
"_" . $this->wiki->getId() .
".zip";
166 "/" . $zip_file_name;
167 $this->log->debug(
"zip: " . $zip_file);
170 $this->log->debug(
"zip, export dir: " . $this->export_dir);
171 $this->log->debug(
"zip, export file: " . $zip_file);
191 foreach ($pages as $page) {
192 $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
193 $this->co_page_html_export->getPreparedMainTemplate(
$tpl);
194 $this->log->debug(
"page: " . $page[
"id"]);
196 $this->log->debug(
"export page");
198 $this->log->debug(
"collect page elements");
199 $this->co_page_html_export->collectPageElements(
"wpg:pg", $page[
"id"]);
202 if (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
204 $this->log->debug(
"update status: " . $cnt);
208 $this->co_page_html_export->exportPageElements(
209 function (
int $total,
int $cnt):
void {
222 foreach ($pages as $page) {
224 $this->co_page_html_export->collectPageElements(
"wpg:pg", $page[
"id"]);
227 $this->co_page_html_export->exportPageElements();
230 $wiki_gui = new \ilObjWikiGUI([], $this->wiki->getRefId(),
true);
231 $print_view = $wiki_gui->getPrintView(
true);
232 $print_view->setOffline(
true);
233 $html = $print_view->renderPrintView();
234 file_put_contents($this->export_dir .
"/index.html", $html);
242 if (in_array($this->
getMode(), [self::MODE_COMMENTS, self::MODE_USER_COMMENTS])) {
243 $user_export = new \ILIAS\Notes\Export\UserImageExporter();
244 $user_export->exportUserImagesForRepObjId($this->export_dir, $this->wiki->getId());
255 if (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
269 $this->log->debug(
"Export page:" . $a_page_id);
276 $file = $this->export_dir .
"/wpg_" . $a_page_id .
".html";
278 if (is_file($file)) {
279 $this->log->debug(
"file already exists");
284 $this->log->debug(
"init page gui");
285 $wpg_gui = new \ilWikiPageGUI($a_page_id);
286 $wpg_gui->setOutputMode(
"offline");
287 $page_content = $wpg_gui->showPage();
290 $this->log->debug(
"init page gui-" . $this->
getMode() .
"-");
291 $ep_tpl = new \ilTemplate(
292 "tpl.export_page.html",
297 $ep_tpl->setVariable(
"PAGE_CONTENT", $page_content);
299 $comments = (in_array($this->
getMode(), [self::MODE_USER_COMMENTS, self::MODE_COMMENTS]))
300 ? $wpg_gui->getCommentsHTMLExport()
302 $ep_tpl->setVariable(
"COMMENTS",
$comments);
305 $bl = new \ilWikiImportantPagesBlockGUI();
309 $this->log->debug(
"set title");
310 $tpl->
setTitle($this->wiki->getTitle());
313 $lng->txt(
"obj_wiki")
320 $this->log->debug(
"write file: " . $file);
321 if (!($fp = fopen($file,
'wb+'))) {
322 $this->log->error(
"Could not open " . $file .
" for writing.");
323 throw new \ilWikiExportException(
"Could not open \"" . $file .
"\" for writing.");
327 $this->log->debug(
"set permissions");
331 fwrite($fp, $content);
336 if ($this->wiki->getStartPage() === $wpg_gui->getPageObject()->getTitle()) {
337 copy($file, $this->export_dir .
"/index.html");
348 $this->log->debug(
"dir: " . $exp_dir);
349 if (!is_dir($exp_dir)) {
352 foreach (
new \DirectoryIterator($exp_dir) as $fileInfo) {
353 $this->log->debug(
"file: " . $fileInfo->getFilename());
354 if (pathinfo($fileInfo->getFilename(), PATHINFO_EXTENSION) ===
"zip") {
355 $this->log->debug(
"return: " . $exp_dir .
"/" . $fileInfo->getFilename());
356 return $exp_dir .
"/" . $fileInfo->getFilename();
ILIAS Services Export HTML Util $export_util
updateUserHTMLStatusForPageElements(int $a_total, int $a_cnt)
Callback for updating the export status during elements export (media objects, files, ...)
static getLogger(string $a_component_id)
Get component logger.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Wiki HTML exporter class.
__construct(\ilObjWiki $a_wiki)
static getAllWikiPages(int $a_wiki_id)
ilWikiUserHTMLExport $user_html_exp
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getASCIIFilename(string $a_filename)
setRightContent(string $a_html)
Sets content of right column.
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
static _createExportDirectory(int $a_obj_id, string $a_export_type="xml", string $a_obj_type="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
getUserExportFile()
Get user export file.
ILIAS Style Content Object ObjectFacade $content_style_domain
printToString()
Use this method to get the finally rendered page as string.
ILIAS GlobalScreen Services $global_screen
clearTargets()
clear all targets
exportPageHTML(int $a_page_id, \ilGlobalPageTemplate $tpl)
Export page html.
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
ilCOPageHTMLExport $co_page_html_export
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
exportUserImages()
Export user images.
exportHTMLPagesPrint()
Export all pages as one print version.
ilGlobalTemplateInterface $main_tpl
const HTML_EXPORT_RENDERING
exportHTMLPages()
Export all pages.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
buildExportFile(bool $print_version=false)
Build export file.
setContent(string $a_html)
Sets content for standard template.
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...