ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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...
 

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 29 of file WikiHtmlExport.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 56 of file WikiHtmlExport.php.

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

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

91  : ExportCollector
92  {
94  $ilDB = $this->db;
95  $ilUser = $this->user;
96 
97  $this->log->debug("buildExportFile...");
98  //init the mathjax rendering for HTML export
100 
101  if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
102  $this->user_html_exp = new \ilWikiUserHTMLExport($this->wiki, $ilDB, $ilUser, ($this->getMode() === self::MODE_USER_COMMENTS));
103  }
104 
105  $ascii_name = str_replace(" ", "_", ilFileUtils::getASCIIFilename($this->wiki->getTitle()));
106 
107  /*
108  \ilExport::_createExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
109  $exp_dir =
110  \ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
111 
112  if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
113  ilFileUtils::delDir($exp_dir, true);
114  }*/
115 
116  if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
117  $subdir = $ascii_name;
118  } else {
119  $subdir = $this->wiki->getType() . "_" . $this->wiki->getId();
120  }
121 
122  if ($print_version) {
123  $subdir .= "print";
124  }
125 
126  //$this->export_dir = $exp_dir . "/" . $subdir;
127 
128 
129  $date = time();
130  $zip_file_name = (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS]))
131  ? $ascii_name . ".zip"
132  : $date . "__" . IL_INST_ID . "__" . $this->wiki->getType() . "_" . $this->wiki->getId() . ".zip";
133 
134  $this->collector = $this->html_export->collector($this->wiki->getId());
135  $this->collector->init($zip_file_name);
136 
137  $this->export_util = new \ILIAS\components\Export\HTML\Util("", "", $this->collector);
138  $this->co_page_html_export = new \ilCOPageHTMLExport("", null, 0, $this->collector);
139 
140  // initialize temporary target directory
141  //ilFileUtils::delDir($this->export_dir);
142  //ilFileUtils::makeDir($this->export_dir);
143 
144  //$this->log->debug("export directory: " . $this->export_dir);
145 
146 
147  $this->export_util->exportSystemStyle(
148  [
149  "icon_wiki.svg"
150  ]
151  );
152  $eff_style_id = $this->content_style_domain->getEffectiveStyleId();
153  $this->export_util->exportCOPageFiles($eff_style_id, "wiki");
154  $this->co_page_html_export->setContentStyleId($eff_style_id);
155 
156  // export pages
157  $this->log->debug("export pages");
158  if (!self::$context_init) {
159  $global_screen->tool()->context()->current()->addAdditionalData(
161  true
162  );
163  self::$context_init = true;
164  }
165  if ($print_version) {
166  $this->exportHTMLPagesPrint();
167  } else {
168  $this->exportHTMLPages();
169  }
170  //$this->exportUserImages();
171 
172  $this->export_util->exportResourceFiles();
173 
174 
175  // zip everything
176  /*
177  if (true) {
178  // zip it all
179  $zip_file = \ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki") .
180  "/" . $zip_file_name;
181  $this->log->debug("zip: " . $zip_file);
182  //var_dump($zip_file);
183  //exit;
184  $this->log->debug("zip, export dir: " . $this->export_dir);
185  $this->log->debug("zip, export file: " . $zip_file);
186  ilFileUtils::zip($this->export_dir, $zip_file);
187  ilFileUtils::delDir($this->export_dir);
188  }*/
189  return $this->collector;
190  }
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()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
exportHTMLPagesPrint()
Export all pages as one print version.
exportHTMLPages()
Export all pages.
+ Here is the call graph for this function:

◆ exportHTMLPages()

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

Export all pages.

Exceptions

Definition at line 197 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().

197  : void
198  {
199  global $DIC;
200 
201  $pages = \ilWikiPage::getAllWikiPages($this->wiki->getId());
202 
203  $cnt = 0;
204 
205  foreach ($pages as $page) {
206  $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
207  $this->co_page_html_export->getPreparedMainTemplate($tpl);
208  $this->log->debug("page: " . $page["id"]);
209  if (\ilWikiPage::_exists("wpg", $page["id"])) {
210  $this->log->debug("export page");
211  $this->exportPageHTML($page["id"], $tpl);
212  $this->log->debug("collect page elements");
213  $this->co_page_html_export->collectPageElements("wpg:pg", $page["id"]);
214  }
215 
216  if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
217  $cnt++;
218  $this->log->debug("update status: " . $cnt);
219  $this->user_html_exp->updateStatus((int) (50 / count($pages) * $cnt), \ilWikiUserHTMLExport::RUNNING);
220  }
221  }
222  $this->co_page_html_export->exportPageElements(
223  function (int $total, int $cnt): void {
224  $this->updateUserHTMLStatusForPageElements($total, $cnt);
225  }
226  );
227  }
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:22
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 232 of file WikiHtmlExport.php.

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

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

232  : void
233  {
234  // collect page elements
235  $pages = \ilWikiPage::getAllWikiPages($this->wiki->getId());
236  foreach ($pages as $page) {
237  if (\ilWikiPage::_exists("wpg", $page["id"])) {
238  $this->co_page_html_export->collectPageElements("wpg:pg", $page["id"]);
239  }
240  }
241  $this->co_page_html_export->exportPageElements();
242 
243  // render print view
244  $wiki_gui = new \ilObjWikiGUI([], $this->wiki->getRefId(), true);
245  $print_view = $wiki_gui->getPrintView(true);
246  $print_view->setOffline(true);
247  $html = $print_view->renderPrintView();
248  $this->collector->addString($html, "index.html");
249  }
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 279 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().

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

◆ getMode()

◆ getUserExportFile()

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

Get user export file.

Definition at line 364 of file WikiHtmlExport.php.

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

364  : string
365  {
366  $exp_dir =
367  \ilExport::_getExportDirectory($this->wiki->getId(), $this->getMode(), "wiki");
368  $this->log->debug("dir: " . $exp_dir);
369  if (!is_dir($exp_dir)) {
370  return "";
371  }
372  foreach (new \DirectoryIterator($exp_dir) as $fileInfo) {
373  $this->log->debug("file: " . $fileInfo->getFilename());
374  if (pathinfo($fileInfo->getFilename(), PATHINFO_EXTENSION) === "zip") {
375  $this->log->debug("return: " . $exp_dir . "/" . $fileInfo->getFilename());
376  return $exp_dir . "/" . $fileInfo->getFilename();
377  }
378  }
379  return "";
380  }
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 75 of file WikiHtmlExport.php.

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

◆ 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 265 of file WikiHtmlExport.php.

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

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

268  : void {
269  if (in_array($this->getMode(), [self::MODE_USER, self::MODE_USER_COMMENTS])) {
270  $this->user_html_exp->updateStatus((int) (50 + (50 / $a_total * $a_cnt)), \ilWikiUserHTMLExport::RUNNING);
271  }
272  }
+ 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 46 of file WikiHtmlExport.php.

◆ $collector

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

Definition at line 35 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 51 of file WikiHtmlExport.php.

◆ $context_init

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

Definition at line 54 of file WikiHtmlExport.php.

◆ $db

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

Definition at line 39 of file WikiHtmlExport.php.

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

◆ $export_dir

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

Definition at line 47 of file WikiHtmlExport.php.

◆ $export_util

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

Definition at line 37 of file WikiHtmlExport.php.

◆ $global_screen

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

Definition at line 48 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 36 of file WikiHtmlExport.php.

◆ $lng

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

Definition at line 41 of file WikiHtmlExport.php.

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

◆ $log

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

Definition at line 45 of file WikiHtmlExport.php.

◆ $main_tpl

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

Definition at line 49 of file WikiHtmlExport.php.

◆ $mode

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

Definition at line 44 of file WikiHtmlExport.php.

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

◆ $tabs

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

Definition at line 42 of file WikiHtmlExport.php.

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

◆ $user

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

Definition at line 40 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 50 of file WikiHtmlExport.php.

◆ $wiki

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

Definition at line 43 of file WikiHtmlExport.php.

◆ MODE_COMMENTS

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

Definition at line 32 of file WikiHtmlExport.php.

◆ MODE_DEFAULT

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

Definition at line 31 of file WikiHtmlExport.php.

◆ MODE_USER

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

Definition at line 33 of file WikiHtmlExport.php.

◆ MODE_USER_COMMENTS

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

Definition at line 34 of file WikiHtmlExport.php.


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