ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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.

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

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
+ 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

Definition at line 92 of file WikiHtmlExport.php.

References ILIAS\Wiki\Export\WikiHtmlExport\$collector, ILIAS\Wiki\Export\WikiHtmlExport\$db, ILIAS\Wiki\Export\WikiHtmlExport\$global_screen, $ilDB, ILIAS\Wiki\Export\WikiHtmlExport\$user, ILIAS\Wiki\Export\WikiHtmlExport\exportHTMLPages(), ILIAS\Wiki\Export\WikiHtmlExport\exportHTMLPagesPrint(), ilFileUtils\getASCIIFilename(), ilMathJax\getInstance(), ILIAS\Wiki\Export\WikiHtmlExport\getMode(), ilHTMLExportViewLayoutProvider\HTML_EXPORT_RENDERING, IL_INST_ID, null, and ilMathJax\PURPOSE_EXPORT.

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

◆ deliverLatest()

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

Definition at line 376 of file WikiHtmlExport.php.

References ILIAS\Wiki\Export\WikiHtmlExport\getMode().

376  : void
377  {
378  $fm = $this->html_export->fileManager();
379  $latest = $fm->getLatestOfObjectIdAndType($this->wiki->getId(), $this->getMode());
380  if ($latest) {
381  $fm->deliver($latest);
382  }
383  }
+ Here is the call graph for this function:

◆ exportHTMLPages()

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

Export all pages.

Exceptions

Definition at line 191 of file WikiHtmlExport.php.

References $DIC, ilPageObject\_exists(), ILIAS\Wiki\Export\WikiHtmlExport\exportPageHTML(), ilWikiPage\getAllWikiPages(), ILIAS\Wiki\Export\WikiHtmlExport\getMode(), ilWikiUserHTMLExport\RUNNING, and ILIAS\Wiki\Export\WikiHtmlExport\updateUserHTMLStatusForPageElements().

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\buildExportFile().

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

◆ exportHTMLPagesPrint()

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

Export all pages as one print version.

Definition at line 226 of file WikiHtmlExport.php.

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

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\buildExportFile().

226  : void
227  {
228  // collect page elements
229  $pages = \ilWikiPage::getAllWikiPages($this->wiki->getId());
230  foreach ($pages as $page) {
231  if (\ilWikiPage::_exists("wpg", $page["id"])) {
232  $this->co_page_html_export->collectPageElements("wpg:pg", $page["id"]);
233  }
234  }
235  $this->co_page_html_export->exportPageElements();
236 
237  // render print view
238  $wiki_gui = new \ilObjWikiGUI([], $this->wiki->getRefId(), true);
239  $print_view = $wiki_gui->getPrintView(true);
240  $print_view->setOffline(true);
241  $html = $print_view->renderPrintView();
242  $this->collector->addString($html, "index.html");
243  }
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="-")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportPageHTML()

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

Export page html.

Exceptions

Definition at line 273 of file WikiHtmlExport.php.

References $comments, ILIAS\Wiki\Export\WikiHtmlExport\$lng, ILIAS\Wiki\Export\WikiHtmlExport\$tabs, ilTabsGUI\clearTargets(), ilUtil\getImagePath(), ILIAS\Wiki\Export\WikiHtmlExport\getMode(), ilGlobalPageTemplate\printToString(), ilGlobalPageTemplate\setContent(), ilGlobalPageTemplate\setRightContent(), ilGlobalPageTemplate\setTitle(), and ilGlobalPageTemplate\setTitleIcon().

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\exportHTMLPages().

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

◆ getLatest()

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

Definition at line 385 of file WikiHtmlExport.php.

References ILIAS\Wiki\Export\WikiHtmlExport\getMode().

385  : ?ExportFile
386  {
387  return $this->html_export->fileManager()->getLatestOfObjectIdAndType($this->wiki->getId(), $this->getMode());
388  }
+ Here is the call graph for this function:

◆ getMode()

◆ getUserExportFile()

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

Get user export file.

Definition at line 358 of file WikiHtmlExport.php.

References ilExport\_getExportDirectory(), and ILIAS\Wiki\Export\WikiHtmlExport\getMode().

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

References ILIAS\Wiki\Export\WikiHtmlExport\getMode(), and ilWikiUserHTMLExport\RUNNING.

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\exportHTMLPages().

262  : void {
263  if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
264  $this->user_html_exp->updateStatus((int) (50 + (50 / $a_total * $a_cnt)), \ilWikiUserHTMLExport::RUNNING);
265  }
266  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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.

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\buildExportFile().

◆ $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.

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\buildExportFile().

◆ $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.

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\buildExportFile().

◆ $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.

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\exportPageHTML().

◆ $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.

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\getMode().

◆ $tabs

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

Definition at line 43 of file WikiHtmlExport.php.

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\exportPageHTML().

◆ $user

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

Definition at line 41 of file WikiHtmlExport.php.

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\buildExportFile().

◆ $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: