47 protected $mode = self::MODE_DEFAULT;
88 $this->db = $DIC->database();
89 $this->
user = $DIC->user();
90 $this->lng = $DIC->language();
91 $this->tabs = $DIC->tabs();
92 $this->wiki = $a_wiki;
94 $this->global_screen = $DIC->globalScreen();
95 $this->main_tpl = $DIC->ui()->mainTemplate();
105 $this->mode = $a_val;
131 $this->log->debug(
"buildExportFile...");
133 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
136 if (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
137 include_once(
"./Modules/Wiki/classes/class.ilWikiUserHTMLExport.php");
138 $this->user_html_exp = new \ilWikiUserHTMLExport($this->wiki,
$ilDB,
$ilUser, ($this->
getMode() == self::MODE_USER_COMMENTS));
144 include_once(
"./Services/Export/classes/class.ilExport.php");
149 if (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
153 if (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
154 $subdir = $ascii_name;
156 $subdir = $this->wiki->getType() .
"_" . $this->wiki->getId();
158 $this->export_dir = $exp_dir .
"/" . $subdir;
160 $this->export_util = new \ILIAS\Services\Export\HTML\Util($exp_dir, $subdir);
166 $this->log->debug(
"export directory: " . $this->export_dir);
169 $this->export_util->exportSystemStyle();
170 $this->export_util->exportCOPageFiles($this->wiki->getStyleSheetId(),
"wiki");
172 $this->co_page_html_export = new \ilCOPageHTMLExport($this->export_dir);
174 $this->wiki->getStyleSheetId(),
179 $this->log->debug(
"export pages");
184 $this->export_util->exportResourceFiles(
$global_screen, $this->export_dir);
187 $zip_file_name = (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS]))
188 ? $ascii_name .
".zip" 189 : $date .
"__" .
IL_INST_ID .
"__" . $this->wiki->getType() .
"_" . $this->wiki->getId() .
".zip";
195 "/" . $zip_file_name;
196 $this->log->debug(
"zip: " . $zip_file);
199 $this->log->debug(
"zip, export dir: " . $this->export_dir);
200 $this->log->debug(
"zip, export file: " . $zip_file);
220 foreach ($pages as $page) {
221 $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
222 $this->co_page_html_export->getPreparedMainTemplate(
$tpl);
223 $this->log->debug(
"page: " . $page[
"id"]);
225 $this->log->debug(
"export page");
227 $this->log->debug(
"collect page elements");
228 $this->co_page_html_export->collectPageElements(
"wpg:pg", $page[
"id"]);
231 if (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
233 $this->log->debug(
"update status: " . $cnt);
245 if (in_array($this->
getMode(), [self::MODE_COMMENTS, self::MODE_USER_COMMENTS])) {
246 $user_export = new \ILIAS\Notes\Export\UserImageExporter();
247 $user_export->exportUserImagesForRepObjId($this->export_dir, $this->wiki->getId());
258 if (in_array($this->
getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
272 $this->log->debug(
"Export page:" . $a_page_id);
276 $ilTabs->clearTargets();
281 $file = $this->export_dir .
"/wpg_" . $a_page_id .
".html";
283 if (@is_file($file)) {
284 $this->log->debug(
"file already exists");
289 $this->log->debug(
"init page gui");
290 include_once(
"./Modules/Wiki/classes/class.ilWikiPageGUI.php");
291 $wpg_gui = new \ilWikiPageGUI($a_page_id);
292 $wpg_gui->setOutputMode(
"offline");
293 $page_content = $wpg_gui->showPage();
296 $this->log->debug(
"init page gui-" . $this->
getMode() .
"-");
297 $ep_tpl = new \ilTemplate(
298 "tpl.export_page.html",
303 $ep_tpl->setVariable(
"PAGE_CONTENT", $page_content);
305 $comments = (in_array($this->
getMode(), [self::MODE_USER_COMMENTS, self::MODE_COMMENTS]))
306 ? $wpg_gui->getCommentsHTMLExport()
308 $ep_tpl->setVariable(
"COMMENTS", $comments);
311 include_once(
"./Modules/Wiki/classes/class.ilWikiImportantPagesBlockGUI.php");
312 $bl = new \ilWikiImportantPagesBlockGUI();
316 $this->log->debug(
"set title");
317 $tpl->
setTitle($this->wiki->getTitle());
320 $lng->txt(
"obj_wiki")
327 $this->log->debug(
"write file: " . $file);
328 if (!($fp = @fopen($file,
"w+"))) {
329 $this->log->error(
"Could not open " . $file .
" for writing.");
330 include_once(
"./Modules/Wiki/exceptions/class.ilWikiExportException.php");
331 throw new \ilWikiExportException(
"Could not open \"" . $file .
"\" for writing.");
335 $this->log->debug(
"set permissions");
339 fwrite($fp, $content);
344 if ($this->wiki->getStartPage() == $wpg_gui->getPageObject()->getTitle()) {
345 copy($file, $this->export_dir .
"/index.html");
356 include_once(
"./Services/Export/classes/class.ilExport.php");
359 $this->log->debug(
"dir: " . $exp_dir);
360 if (!is_dir($exp_dir)) {
364 $this->log->debug(
"file: " . $fileInfo->getFilename());
365 if (pathinfo($fileInfo->getFilename(), PATHINFO_EXTENSION) ==
"zip") {
366 $this->log->debug(
"return: " . $exp_dir .
"/" . $fileInfo->getFilename());
367 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.
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.
exportUserImages()
Export user images.
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.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively