ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Wiki\Export\WikiHtmlExport Class Reference

Wiki HTML exporter class. More...

+ Collaboration diagram for ILIAS\Wiki\Export\WikiHtmlExport:

Public Member Functions

 __construct (\ilObjWiki $a_wiki)
 
 setMode (string $a_val)
 
 getMode ()
 
 buildExportFile (bool $print_version=false)
 Build export file. More...
 
 exportHTMLPages ()
 Export all pages. More...
 
 exportHTMLPagesPrint ()
 Export all pages as one print version. More...
 
 updateUserHTMLStatusForPageElements (int $a_total, int $a_cnt)
 Export user images. More...
 
 exportPageHTML (int $a_page_id, \ilGlobalPageTemplate $tpl)
 Export page html. More...
 
 getUserExportFile ()
 Get user export file. More...
 
 deliverLatest ()
 
 getLatest ()
 

Data Fields

const MODE_DEFAULT = "html"
 
const MODE_COMMENTS = "html_comments"
 
const MODE_USER = "user_html"
 
const MODE_USER_COMMENTS = "user_html_comments"
 

Protected Attributes

ILIAS components Export HTML ExportCollector $collector
 
ILIAS Export HTML ExternalDomainService $html_export
 
ILIAS components Export HTML Util $export_util
 
ilDBInterface $db
 
ilObjUser $user
 
ilLanguage $lng
 
ilTabsGUI $tabs
 
ilObjWiki $wiki
 
string $mode = self::MODE_DEFAULT
 
ilLogger $log
 
ilCOPageHTMLExport $co_page_html_export
 
string $export_dir
 
ILIAS GlobalScreen Services $global_screen
 
ilGlobalTemplateInterface $main_tpl
 
ilWikiUserHTMLExport $user_html_exp
 
ILIAS Style Content Object ObjectFacade $content_style_domain
 

Static Protected Attributes

static $context_init = false
 

Detailed Description

Wiki HTML exporter class.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 30 of file WikiHtmlExport.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Wiki\Export\WikiHtmlExport::__construct ( \ilObjWiki  $a_wiki)

Definition at line 57 of file WikiHtmlExport.php.

58 {
59 global $DIC;
60
61 $this->db = $DIC->database();
62 $this->user = $DIC->user();
63 $this->lng = $DIC->language();
64 $this->tabs = $DIC->tabs();
65 $this->wiki = $a_wiki;
66 $this->log = \ilLoggerFactory::getLogger('wiki');
67 $this->global_screen = $DIC->globalScreen();
68 $this->main_tpl = $DIC->ui()->mainTemplate();
69 $this->content_style_domain = $DIC
70 ->contentStyle()
71 ->domain()
72 ->styleForRefId($a_wiki->getRefId());
73 $this->html_export = $DIC->export()->domain()->html();
74 }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:26

References $DIC, ilLoggerFactory\getLogger(), ilObject\getRefId(), ILIAS\Repository\lng(), ILIAS\Repository\tabs(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildExportFile()

ILIAS\Wiki\Export\WikiHtmlExport::buildExportFile ( bool  $print_version = false)

Build export file.

Exceptions

ilTemplateException

Exceptions

ilWikiExportException

Definition at line 92 of file WikiHtmlExport.php.

93 {
96 $ilUser = $this->user;
97
98 $this->log->debug("buildExportFile...");
99
100 if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
101 $this->user_html_exp = new \ilWikiUserHTMLExport($this->wiki, $ilDB, $ilUser, ($this->getMode() === self::MODE_USER_COMMENTS));
102 }
103
104 $ascii_name = str_replace(" ", "_", ilFileUtils::getASCIIFilename($this->wiki->getTitle()));
105
106 /*
107 \ilExport::_createExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
108 $exp_dir =
109 \ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
110
111 if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
112 ilFileUtils::delDir($exp_dir, true);
113 }*/
114
115 if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
116 $subdir = $ascii_name;
117 } else {
118 $subdir = $this->wiki->getType() . "_" . $this->wiki->getId();
119 }
120
121 if ($print_version) {
122 $subdir .= "print";
123 }
124
125 //$this->export_dir = $exp_dir . "/" . $subdir;
126
127
128 $date = time();
129 $zip_file_name = (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS]))
130 ? $ascii_name . ".zip"
131 : $date . "__" . IL_INST_ID . "__" . $this->wiki->getType() . "_" . $this->wiki->getId() . ".zip";
132
133 $this->collector = $this->html_export->collector($this->wiki->getId(), $this->getMode());
134 $this->collector->init($zip_file_name);
135
136 $this->export_util = new \ILIAS\components\Export\HTML\Util("", "", $this->collector);
137 $this->co_page_html_export = new \ilCOPageHTMLExport("", null, 0, $this->collector);
138
139 $this->export_util->exportSystemStyle(
140 [
141 "icon_wiki.svg"
142 ]
143 );
144 $eff_style_id = $this->content_style_domain->getEffectiveStyleId();
145 $this->export_util->exportCOPageFiles($eff_style_id, "wiki");
146 $this->co_page_html_export->setContentStyleId($eff_style_id);
147
148 // export pages
149 $this->log->debug("export pages");
150 if (!self::$context_init) {
151 $global_screen->tool()->context()->current()->addAdditionalData(
153 true
154 );
155 self::$context_init = true;
156 }
157 if ($print_version) {
158 $this->exportHTMLPagesPrint();
159 } else {
160 $this->exportHTMLPages();
161 }
162 //$this->exportUserImages();
163
164 $this->export_util->exportResourceFiles();
165
166
167 // zip everything
168 /*
169 if (true) {
170 // zip it all
171 $zip_file = \ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki") .
172 "/" . $zip_file_name;
173 $this->log->debug("zip: " . $zip_file);
174 //var_dump($zip_file);
175 //exit;
176 $this->log->debug("zip, export dir: " . $this->export_dir);
177 $this->log->debug("zip, export file: " . $zip_file);
178 ilFileUtils::zip($this->export_dir, $zip_file);
179 ilFileUtils::delDir($this->export_dir);
180 }*/
181 return $this->collector;
182 }
ILIAS GlobalScreen Services $global_screen
exportHTMLPagesPrint()
Export all pages as one print version.
ILIAS components Export HTML ExportCollector $collector
static getASCIIFilename(string $a_filename)
const IL_INST_ID
Definition: constants.php:40

References ILIAS\$db, $ilDB, ilFileUtils\getASCIIFilename(), ilHTMLExportViewLayoutProvider\HTML_EXPORT_RENDERING, and IL_INST_ID.

+ Here is the call graph for this function:

◆ deliverLatest()

ILIAS\Wiki\Export\WikiHtmlExport::deliverLatest ( )

Definition at line 374 of file WikiHtmlExport.php.

374 : void
375 {
376 $fm = $this->html_export->fileManager();
377 $latest = $fm->getLatestOfObjectIdAndType($this->wiki->getId(), $this->getMode());
378 if ($latest) {
379 $fm->deliver($latest);
380 }
381 }

◆ exportHTMLPages()

ILIAS\Wiki\Export\WikiHtmlExport::exportHTMLPages ( )

Export all pages.

Exceptions

ilTemplateException

Exceptions

ilWikiExportException

Definition at line 189 of file WikiHtmlExport.php.

189 : void
190 {
191 global $DIC;
192
193 $pages = \ilWikiPage::getAllWikiPages($this->wiki->getId());
194
195 $cnt = 0;
196
197 foreach ($pages as $page) {
198 $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
199 $this->co_page_html_export->getPreparedMainTemplate($tpl);
200 $this->log->debug("page: " . $page["id"]);
201 if (\ilWikiPage::_exists("wpg", $page["id"])) {
202 $this->log->debug("export page");
203 $this->exportPageHTML($page["id"], $tpl);
204 $this->log->debug("collect page elements");
205 $this->co_page_html_export->collectPageElements("wpg:pg", $page["id"]);
206 }
207
208 if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
209 $cnt++;
210 $this->log->debug("update status: " . $cnt);
211 $this->user_html_exp->updateStatus((int) (50 / count($pages) * $cnt), \ilWikiUserHTMLExport::RUNNING);
212 }
213 }
214 $this->co_page_html_export->exportPageElements(
215 function (int $total, int $cnt): void {
216 $this->updateUserHTMLStatusForPageElements($total, $cnt);
217 }
218 );
219 }
updateUserHTMLStatusForPageElements(int $a_total, int $a_cnt)
Export user images.
exportPageHTML(int $a_page_id, \ilGlobalPageTemplate $tpl)
Export page html.
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
static getAllWikiPages(int $a_wiki_id, string $lang="-")

References $DIC, ilPageObject\_exists(), ilWikiPage\getAllWikiPages(), and ilWikiUserHTMLExport\RUNNING.

+ Here is the call graph for this function:

◆ exportHTMLPagesPrint()

ILIAS\Wiki\Export\WikiHtmlExport::exportHTMLPagesPrint ( )

Export all pages as one print version.

Definition at line 224 of file WikiHtmlExport.php.

224 : void
225 {
226 // collect page elements
227 $pages = \ilWikiPage::getAllWikiPages($this->wiki->getId());
228 foreach ($pages as $page) {
229 if (\ilWikiPage::_exists("wpg", $page["id"])) {
230 $this->co_page_html_export->collectPageElements("wpg:pg", $page["id"]);
231 }
232 }
233 $this->co_page_html_export->exportPageElements();
234
235 // render print view
236 $wiki_gui = new \ilObjWikiGUI([], $this->wiki->getRefId(), true);
237 $print_view = $wiki_gui->getPrintView(true);
238 $print_view->setOffline(true);
239 $html = $print_view->renderPrintView();
240 $this->collector->addString($html, "index.html");
241 }

References ilPageObject\_exists(), and ilWikiPage\getAllWikiPages().

+ Here is the call graph for this function:

◆ exportPageHTML()

ILIAS\Wiki\Export\WikiHtmlExport::exportPageHTML ( int  $a_page_id,
\ilGlobalPageTemplate  $tpl 
)

Export page html.

Exceptions

ilWikiExportException

Definition at line 271 of file WikiHtmlExport.php.

274 : void {
275 $this->log->debug("Export page:" . $a_page_id);
277 $ilTabs = $this->tabs;
278
279 $ilTabs->clearTargets();
280
281 //$this->tpl->loadStandardTemplate();
282 $file = "wpg_" . $a_page_id . ".html";
283 // return if file is already existing
284 /*
285 if (is_file($file)) {
286 $this->log->debug("file already exists");
287 return;
288 }*/
289
290 // page
291 $this->log->debug("init page gui");
292 $wpg_gui = new \ilWikiPageGUI(
293 $a_page_id,
294 0,
295 $this->wiki->getRefId()
296 );
297 $wpg_gui->setOutputMode("offline");
298 $page_content = $wpg_gui->showPage();
299
300 // export template: page content
301 $this->log->debug("init page gui-" . $this->getMode() . "-");
302 $ep_tpl = new \ilTemplate(
303 "tpl.export_page.html",
304 true,
305 true,
306 "components/ILIAS/Wiki"
307 );
308 $ep_tpl->setVariable("PAGE_CONTENT", $page_content);
309
310 $comments = (in_array($this->getMode(), [self::MODE_USER_COMMENTS, self::MODE_COMMENTS]))
311 ? $wpg_gui->getCommentsHTMLExport()
312 : "";
313 $ep_tpl->setVariable("COMMENTS", $comments);
314
315 // export template: right content
316 $bl = new \ilWikiImportantPagesBlockGUI();
317 $tpl->setRightContent($bl->getHTML(true));
318
319
320 $this->log->debug("set title");
321 $tpl->setTitle($this->wiki->getTitle());
322 $tpl->setTitleIcon(
323 \ilUtil::getImagePath("standard/icon_wiki.svg"),
324 $lng->txt("obj_wiki")
325 );
326
327 $tpl->setContent($ep_tpl->get());
328 $content = $tpl->printToString();
329
330 // open file
331 /*$this->log->debug("write file: " . $file);
332 if (!($fp = fopen($file, 'wb+'))) {
333 $this->log->error("Could not open " . $file . " for writing.");
334 throw new \ilWikiExportException("Could not open \"" . $file . "\" for writing.");
335 }*/
336
337 // set file permissions
338 /*$this->log->debug("set permissions");
339 chmod($file, 0770);*/
340
341 // write xml data into the file
342 //fwrite($fp, $content);
343 $this->collector->addString($content, $file);
344
345 // close file
346 //fclose($fp);
347
348 if ($this->wiki->getStartPage() === $wpg_gui->getPageObject()->getTitle()) {
349 $this->collector->addString($content, "index.html");
350 }
351 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
clearTargets()
clear all targets
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$comments

◆ getLatest()

ILIAS\Wiki\Export\WikiHtmlExport::getLatest ( )

Definition at line 383 of file WikiHtmlExport.php.

383 : ?ExportFile
384 {
385 return $this->html_export->fileManager()->getLatestOfObjectIdAndType($this->wiki->getId(), $this->getMode());
386 }

◆ getMode()

ILIAS\Wiki\Export\WikiHtmlExport::getMode ( )

Definition at line 82 of file WikiHtmlExport.php.

82 : string
83 {
84 return $this->mode;
85 }

◆ getUserExportFile()

ILIAS\Wiki\Export\WikiHtmlExport::getUserExportFile ( )

Get user export file.

Definition at line 356 of file WikiHtmlExport.php.

356 : string
357 {
358 $exp_dir =
359 \ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
360 $this->log->debug("dir: " . $exp_dir);
361 if (!is_dir($exp_dir)) {
362 return "";
363 }
364 foreach (new \DirectoryIterator($exp_dir) as $fileInfo) {
365 $this->log->debug("file: " . $fileInfo->getFilename());
366 if (pathinfo($fileInfo->getFilename(), PATHINFO_EXTENSION) === "zip") {
367 $this->log->debug("return: " . $exp_dir . "/" . $fileInfo->getFilename());
368 return $exp_dir . "/" . $fileInfo->getFilename();
369 }
370 }
371 return "";
372 }
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
@depricated Get export directory for an repository object

References ilExport\_getExportDirectory().

+ Here is the call graph for this function:

◆ setMode()

ILIAS\Wiki\Export\WikiHtmlExport::setMode ( string  $a_val)

Definition at line 76 of file WikiHtmlExport.php.

78 : void {
79 $this->mode = $a_val;
80 }

◆ updateUserHTMLStatusForPageElements()

ILIAS\Wiki\Export\WikiHtmlExport::updateUserHTMLStatusForPageElements ( int  $a_total,
int  $a_cnt 
)

Export user images.

Callback for updating the export status during elements export (media objects, files, ...)

Definition at line 257 of file WikiHtmlExport.php.

260 : void {
261 if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
262 $this->user_html_exp->updateStatus((int) (50 + (50 / $a_total * $a_cnt)), \ilWikiUserHTMLExport::RUNNING);
263 }
264 }

References ilWikiUserHTMLExport\RUNNING.

Field Documentation

◆ $co_page_html_export

ilCOPageHTMLExport ILIAS\Wiki\Export\WikiHtmlExport::$co_page_html_export
protected

Definition at line 47 of file WikiHtmlExport.php.

◆ $collector

ILIAS components Export HTML ExportCollector ILIAS\Wiki\Export\WikiHtmlExport::$collector
protected

Definition at line 36 of file WikiHtmlExport.php.

◆ $content_style_domain

ILIAS Style Content Object ObjectFacade ILIAS\Wiki\Export\WikiHtmlExport::$content_style_domain
protected

Definition at line 52 of file WikiHtmlExport.php.

◆ $context_init

ILIAS\Wiki\Export\WikiHtmlExport::$context_init = false
staticprotected

Definition at line 55 of file WikiHtmlExport.php.

◆ $db

ilDBInterface ILIAS\Wiki\Export\WikiHtmlExport::$db
protected

Definition at line 40 of file WikiHtmlExport.php.

◆ $export_dir

string ILIAS\Wiki\Export\WikiHtmlExport::$export_dir
protected

Definition at line 48 of file WikiHtmlExport.php.

◆ $export_util

ILIAS components Export HTML Util ILIAS\Wiki\Export\WikiHtmlExport::$export_util
protected

Definition at line 38 of file WikiHtmlExport.php.

◆ $global_screen

ILIAS GlobalScreen Services ILIAS\Wiki\Export\WikiHtmlExport::$global_screen
protected

Definition at line 49 of file WikiHtmlExport.php.

◆ $html_export

ILIAS Export HTML ExternalDomainService ILIAS\Wiki\Export\WikiHtmlExport::$html_export
protected

Definition at line 37 of file WikiHtmlExport.php.

◆ $lng

ilLanguage ILIAS\Wiki\Export\WikiHtmlExport::$lng
protected

Definition at line 42 of file WikiHtmlExport.php.

◆ $log

ilLogger ILIAS\Wiki\Export\WikiHtmlExport::$log
protected

Definition at line 46 of file WikiHtmlExport.php.

◆ $main_tpl

ilGlobalTemplateInterface ILIAS\Wiki\Export\WikiHtmlExport::$main_tpl
protected

Definition at line 50 of file WikiHtmlExport.php.

◆ $mode

string ILIAS\Wiki\Export\WikiHtmlExport::$mode = self::MODE_DEFAULT
protected

Definition at line 45 of file WikiHtmlExport.php.

◆ $tabs

ilTabsGUI ILIAS\Wiki\Export\WikiHtmlExport::$tabs
protected

Definition at line 43 of file WikiHtmlExport.php.

◆ $user

ilObjUser ILIAS\Wiki\Export\WikiHtmlExport::$user
protected

Definition at line 41 of file WikiHtmlExport.php.

◆ $user_html_exp

ilWikiUserHTMLExport ILIAS\Wiki\Export\WikiHtmlExport::$user_html_exp
protected

Definition at line 51 of file WikiHtmlExport.php.

◆ $wiki

ilObjWiki ILIAS\Wiki\Export\WikiHtmlExport::$wiki
protected

Definition at line 44 of file WikiHtmlExport.php.

◆ MODE_COMMENTS

const ILIAS\Wiki\Export\WikiHtmlExport::MODE_COMMENTS = "html_comments"

Definition at line 33 of file WikiHtmlExport.php.

◆ MODE_DEFAULT

const ILIAS\Wiki\Export\WikiHtmlExport::MODE_DEFAULT = "html"

Definition at line 32 of file WikiHtmlExport.php.

◆ MODE_USER

const ILIAS\Wiki\Export\WikiHtmlExport::MODE_USER = "user_html"

Definition at line 34 of file WikiHtmlExport.php.

◆ MODE_USER_COMMENTS

const ILIAS\Wiki\Export\WikiHtmlExport::MODE_USER_COMMENTS = "user_html_comments"

Definition at line 35 of file WikiHtmlExport.php.


The documentation for this class was generated from the following file: