ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
ILIAS\LearningModule\Export\LMHtmlExport Class Reference
+ Collaboration diagram for ILIAS\LearningModule\Export\LMHtmlExport:

Public Member Functions

 __construct (\ilObjLearningModule $lm, string $export_dir, string $sub_dir, string $export_format="html", string $lang="")
 
 exportHTML (bool $zip=true)
 
 exportHTMLPages ()
 export all pages of learning module to html file More...
 
 exportPageHTML (int $lm_page_id, bool $is_first=false, string $lang="-", string $frame="", array $exp_id_map=[])
 export single page to file More...
 

Protected Member Functions

 getLinker ()
 
 setAdditionalContextData (string $key, $data)
 
 resetUserLanguage ()
 
 initLanguage (\ilObjUser $user, \ilLMPresentationGUI $lm_gui, string $lang)
 
 initGlobalScreen ()
 
 addSupplyingExportFiles ()
 Add supplying export files. More...
 
 getSupplyingExportFiles (string $a_target_dir=".")
 
 getInitialisedTemplate ()
 
 initScreen (int $lm_page_id, string $frame)
 Init global screen and learning module presentation gui for page. More...
 

Protected Attributes

ILIAS DI UIServices $ui
 
ExportCollector $collector
 
Util $export_util
 
ilLogger $log
 
string $target_dir = ""
 
string $sub_dir = ""
 
string $export_dir = ""
 
ilObjLearningModule $lm
 
ilGlobalTemplateInterface $main_tpl
 
ilObjUser $user
 
ilLocatorGUI $locator
 
ilCOPageHTMLExport $co_page_html_export
 
string $export_format = ""
 
ilLMPresentationGUI $lm_gui
 
Translations $obj_transl
 
string $lang = ""
 
ilSetting $lm_settings
 
array $offline_files = []
 
string $initial_user_language = ""
 
string $initial_current_user_language = ""
 
ILIAS GlobalScreen Services $global_screen
 
ILIAS Style Content Object ObjectFacade $content_style_domain
 

Detailed Description

Definition at line 29 of file class.LMHtmlExport.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LearningModule\Export\LMHtmlExport::__construct ( \ilObjLearningModule  $lm,
string  $export_dir,
string  $sub_dir,
string  $export_format = "html",
string  $lang = "" 
)

Definition at line 54 of file class.LMHtmlExport.php.

60 {
61 global $DIC;
62
63 $this->locator = $DIC["ilLocator"];
64 $this->user = $DIC->user();
65 $this->lm = $lm;
66 $this->export_dir = $export_dir;
67 $this->sub_dir = $sub_dir;
68 $this->lang = $lang;
69 $this->target_dir = $export_dir . "/" . $sub_dir;
70 $cs = $DIC->contentStyle();
71 $this->ui = $DIC->ui();
72 $this->content_style_domain = $cs->domain()->styleForRefId($this->lm->getRefId());
73 $this->collector = $DIC->export()->domain()->html()->collector($this->lm->getId());
74 $this->collector->init();
75
76 $this->export_util = new Util("", "", $this->collector);
77 $this->co_page_html_export = new \ilCOPageHTMLExport($this->target_dir, $this->getLinker(), $lm->getRefId(), $this->collector);
78
79 $this->co_page_html_export->setContentStyleId(
80 $this->content_style_domain->getEffectiveStyleId()
81 );
82 $this->export_format = $export_format;
83
84 // get learning module presentation gui class
85 $this->lm_gui = new \ilLMPresentationGUI($export_format, ($lang == "all"), $this->target_dir, false);
86 $this->obj_transl = $lm->getObjectProperties()->getPropertyTranslations();
87
88 $this->lm_settings = new \ilSetting("lm");
89
90 $this->log = \ilLoggerFactory::getLogger("lm");
91
92 $this->initial_user_language = $this->user->getLanguage();
93 $this->initial_current_user_language = $this->user->getCurrentLanguage();
94
95 $this->global_screen = $DIC->globalScreen();
96
98 }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\LearningModule\Export\LMHtmlExport\$export_dir, ILIAS\LearningModule\Export\LMHtmlExport\$export_format, ILIAS\LearningModule\Export\LMHtmlExport\$lang, ILIAS\LearningModule\Export\LMHtmlExport\$lm, ILIAS\LearningModule\Export\LMHtmlExport\$sub_dir, ILIAS\LearningModule\Export\LMHtmlExport\getLinker(), ilLoggerFactory\getLogger(), ilObject\getObjectProperties(), ilObject\getRefId(), ILIAS\Repository\locator(), ILIAS\LearningModule\Export\LMHtmlExport\setAdditionalContextData(), ilLMEditGSToolProvider\SHOW_TREE, ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addSupplyingExportFiles()

ILIAS\LearningModule\Export\LMHtmlExport::addSupplyingExportFiles ( )
protected

Add supplying export files.

Definition at line 252 of file class.LMHtmlExport.php.

252 : void
253 {
254 foreach ($this->getSupplyingExportFiles() as $f) {
255 if ($f["source"] != "") {
256 if ($f["type"] == "js") {
257 $this->global_screen->layout()->meta()->addJs($f["source"]);
258 }
259 if ($f["type"] == "css") {
260 $this->global_screen->layout()->meta()->addCss($f["source"]);
261 }
262 }
263 }
264 }
getSupplyingExportFiles(string $a_target_dir=".")

References Vendor\Package\$f.

◆ exportHTML()

ILIAS\LearningModule\Export\LMHtmlExport::exportHTML ( bool  $zip = true)
Parameters
bool$zipperform a zip at the end

Definition at line 221 of file class.LMHtmlExport.php.

221 : void
222 {
223 $this->initGlobalScreen();
224
225 $this->export_util->exportSystemStyle(
226 [
227 "icon_lm.svg"
228 ]
229 );
230 $this->export_util->exportCOPageFiles($this->content_style_domain->getEffectiveStyleId(), "lm");
231
232 $lang_iterator = $this->getLanguageIterator();
233
234 // iterate all languages
235 foreach ($lang_iterator as $lang) {
236 $this->initLanguage($this->user, $this->lm_gui, $lang);
237 $this->exportHTMLPages();
238 }
239
240 $this->resetUserLanguage();
241
243
244 $this->co_page_html_export->exportPageElements();
245
246 }
addSupplyingExportFiles()
Add supplying export files.
exportHTMLPages()
export all pages of learning module to html file
initLanguage(\ilObjUser $user, \ilLMPresentationGUI $lm_gui, string $lang)

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ exportHTMLPages()

ILIAS\LearningModule\Export\LMHtmlExport::exportHTMLPages ( )

export all pages of learning module to html file

Definition at line 353 of file class.LMHtmlExport.php.

353 : void
354 {
355 $lm = $this->lm;
357 $lang = $lm_gui->lang;
358 $all_languages = ($this->lang == "all");
360 $ilLocator = $this->locator;
361
363
364 $lm_tree = $lm->getLMTree();
365 $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg");
366 $first_page_id = $first_page["child"];
367
368 // iterate all learning module pages
369 $mobs = [];
370 $int_links = [];
371 $this->offline_files = [];
372
373 // get html export id mapping
374
375 $exp_id_map = array();
376
377 if ($lm_set->get("html_export_ids")) {
378 foreach ($pages as $page) {
379 $exp_id = \ilLMPageObject::getExportId($this->lm->getId(), $page["obj_id"]);
380 if (trim($exp_id) != "") {
381 $exp_id_map[$page["obj_id"]] = trim($exp_id);
382 }
383 }
384 }
385
386 if ($lang == "") {
387 $lang = "-";
388 }
389
390 reset($pages);
391 foreach ($pages as $page) {
392 if (\ilLMPage::_exists($this->lm->getType(), $page["obj_id"])) {
393 $ilLocator->clearItems();
394 $this->exportPageHTML($page["obj_id"], ($first_page_id == $page["obj_id"]), $lang, "", $exp_id_map);
395 $this->co_page_html_export->collectPageElements("lm:pg", $page["obj_id"], $lang);
396 }
397 }
398 }
exportPageHTML(int $lm_page_id, bool $is_first=false, string $lang="-", string $frame="", array $exp_id_map=[])
export single page to file
static getExportId(int $a_lm_id, int $a_lmobj_id, string $a_type="pg")
static getPageList(int $lm_id)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
$lm_set

References $lm_set, ilPageObject\_exists(), ilLMObject\getExportId(), and ilLMPageObject\getPageList().

+ Here is the call graph for this function:

◆ exportPageHTML()

ILIAS\LearningModule\Export\LMHtmlExport::exportPageHTML ( int  $lm_page_id,
bool  $is_first = false,
string  $lang = "-",
string  $frame = "",
array  $exp_id_map = [] 
)

export single page to file

Definition at line 452 of file class.LMHtmlExport.php.

458 : void {
460 $lang_suffix = "";
461 if (!in_array($lang, ["-", ""]) && $this->lang === "all") {
462 $lang_suffix = "_" . $lang;
463 }
464 // Init template, lm_gui
465 $this->initScreen($lm_page_id, $frame);
466
467 if ($frame == "") {
468 if (is_array($exp_id_map) && isset($a_exp_id_map[$lm_page_id])) {
469 $file = "lm_pg_" . $exp_id_map[$lm_page_id] . $lang_suffix . ".html";
470 } else {
471 $file = "lm_pg_" . $lm_page_id . $lang_suffix . ".html";
472 }
473 } else {
474 if ($frame != "toc") {
475 $file = "frame_" . $lm_page_id . "_" . $frame . $lang_suffix . ".html";
476 } else {
477 $file = "frame_" . $frame . $lang_suffix . ".html";
478 }
479 }
480
481 // return if file is already existing
482 /*
483 if (is_file($file)) {
484 return;
485 }*/
486
487 $content = $this->lm_gui->layout("main.xml", false);
488
489 $this->collector->addString($content, $file);
490
491 if ($is_first && $frame == "") {
492 $this->collector->addString($content, "index" . $lang_suffix . ".html");
493 }
494 $this->export_util->exportResourceFiles(); // same iteration level as initScreen which calls reset
495 }
initScreen(int $lm_page_id, string $frame)
Init global screen and learning module presentation gui for page.

◆ getInitialisedTemplate()

ILIAS\LearningModule\Export\LMHtmlExport::getInitialisedTemplate ( )
protected

Definition at line 400 of file class.LMHtmlExport.php.

401 {
402 global $DIC;
403
404 $tabs = $DIC->tabs();
405
406 $tabs->clearTargets();
407 $tabs->clearSubTabs();
408 $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
409
410 $this->co_page_html_export->getPreparedMainTemplate($tpl);
411
412 return $tpl;
413 }

References $DIC.

◆ getLinker()

ILIAS\LearningModule\Export\LMHtmlExport::getLinker ( )
protected

Definition at line 100 of file class.LMHtmlExport.php.

100 : PageLinker
101 {
102 return new \ilLMPresentationLinker(
103 $this->lm,
104 new \ilLMTree($this->lm->getId()),
105 0,
106 $this->lm->getRefId(),
107 $this->lang,
108 "",
109 "",
110 true,
111 "html",
112 false
113 );
114 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by ILIAS\LearningModule\Export\LMHtmlExport\__construct().

+ Here is the caller graph for this function:

◆ getSupplyingExportFiles()

ILIAS\LearningModule\Export\LMHtmlExport::getSupplyingExportFiles ( string  $a_target_dir = ".")
protected
Todo:
modularize!

Definition at line 269 of file class.LMHtmlExport.php.

269 : array
270 {
271 $scripts = array(
272 array("source" => './components/ILIAS/Accordion/css/accordion.css',
273 "target" => $a_target_dir . '/css/accordion.css',
274 "type" => "css"),
275 array("source" => './components/ILIAS/TestQuestionPool/resources/js/dist/pure_rendering.js',
276 "target" => $a_target_dir . '/js/pure.js',
277 "type" => "js"),
278 array("source" => './components/ILIAS/TestQuestionPool/resources/js/dist/question_handling.js',
279 "target" => $a_target_dir . '/js/question_handling.js',
280 "type" => "js"),
281 array("source" => './components/ILIAS/TestQuestionPool/resources/js/dist/question_handling.css',
282 "target" => $a_target_dir . '/css/question_handling.css',
283 "type" => "css"),
284 array("source" => './components/ILIAS/TestQuestionPool/templates/default/test_javascript.css',
285 "target" => $a_target_dir . '/css/test_javascript.css',
286 "type" => "css"),
288 "target" => $a_target_dir . "/" . \ilExplorerBaseGUI::getLocalExplorerJsPath(),
289 "type" => "js"),
290 array("source" => \ilExplorerBaseGUI::getLocalJsTreeJsPath(),
291 "target" => $a_target_dir . "/" . \ilExplorerBaseGUI::getLocalJsTreeJsPath(),
292 "type" => "js"),
293 array("source" => \ilExplorerBaseGUI::getLocalJsTreeCssPath(),
294 "target" => $a_target_dir . "/" . \ilExplorerBaseGUI::getLocalJsTreeCssPath(),
295 "type" => "css"),
296 array("source" => './components/ILIAS/LearningModule/js/LearningModule.js',
297 "target" => $a_target_dir . '/js/LearningModule.js',
298 "type" => "js")
299 );
300
301 $mathJaxSetting = new \ilSetting("MathJax");
302 $use_mathjax = (bool) $mathJaxSetting->get("enable");
303 if ($use_mathjax) {
304 $scripts[] = array("source" => "",
305 "target" => $mathJaxSetting->get("path_to_mathjax"),
306 "type" => "js");
307 }
308
309 // auto linking js
310 foreach (\ilLinkifyUtil::getLocalJsPaths() as $p) {
311 if (is_int(strpos($p, "ExtLink"))) {
312 $scripts[] = array("source" => $p,
313 "target" => $a_target_dir . '/js/ilExtLink.js',
314 "type" => "js");
315 }
316 if (is_int(strpos($p, "linkify"))) {
317 $scripts[] = array("source" => $p,
318 "target" => $a_target_dir . '/js/linkify.js',
319 "type" => "js");
320 }
321 }
322
323 // check, why these do not come with the gs meta collector
324 $scripts[] = [
325 "source" => "assets/js/mainbar.js",
326 "type" => "js"
327 ];
328 $scripts[] = [
329 "source" => "assets/js/metabar.js",
330 "type" => "js"
331 ];
332 $scripts[] = [
333 "source" => "assets/js/slate.js",
334 "type" => "js"
335 ];
336 $scripts[] = [
337 "source" => "assets/js/stdpage.js",
338 "type" => "js"
339 ];
340 $scripts[] = [
341 "source" => "assets/js/GS.js",
342 "type" => "js"
343 ];
344
345 return $scripts;
346 }
static getLocalJsPaths()
Get paths of necessary js files.

References ilExplorerBaseGUI\getLocalExplorerJsPath(), ilLinkifyUtil\getLocalJsPaths(), ilExplorerBaseGUI\getLocalJsTreeCssPath(), and ilExplorerBaseGUI\getLocalJsTreeJsPath().

+ Here is the call graph for this function:

◆ initGlobalScreen()

ILIAS\LearningModule\Export\LMHtmlExport::initGlobalScreen ( )
protected

Definition at line 208 of file class.LMHtmlExport.php.

208 : void
209 {
210 // set global
211 $this->global_screen->tool()->context()->current()->addAdditionalData(
213 true
214 );
215 }

References ilLMHtmlExportViewLayoutProvider\LM_HTML_EXPORT_RENDERING.

◆ initLanguage()

ILIAS\LearningModule\Export\LMHtmlExport::initLanguage ( \ilObjUser  $user,
\ilLMPresentationGUI  $lm_gui,
string  $lang 
)
protected

Definition at line 184 of file class.LMHtmlExport.php.

188 : void {
189 $user_lang = $user->getLanguage();
190
191 if ($lang != "") {
194 } else {
195 $user->setLanguage($user_lang);
196 $user->setCurrentLanguage($user_lang);
197 }
198
199 if ($lang != "") {
200 if ($lang == $this->obj_transl->getBaseLanguage()) {
201 $lm_gui->lang = "";
202 } else {
203 $lm_gui->lang = $lang;
204 }
205 }
206 }
setLanguage(string $language)
setCurrentLanguage(string $language)
Set current language.

References ILIAS\LearningModule\Export\LMHtmlExport\$lang, ILIAS\LearningModule\Export\LMHtmlExport\$user, ilObjUser\setCurrentLanguage(), and ilObjUser\setLanguage().

+ Here is the call graph for this function:

◆ initScreen()

ILIAS\LearningModule\Export\LMHtmlExport::initScreen ( int  $lm_page_id,
string  $frame 
)
protected

Init global screen and learning module presentation gui for page.

Definition at line 419 of file class.LMHtmlExport.php.

422 : void {
423 $this->export_util->resetGlobalScreen();
424 // load style sheet depending on user's settings
425 $location_stylesheet = \ilUtil::getStyleSheetLocation();
426 $this->global_screen->layout()->meta()->addCss($location_stylesheet);
427
429
430 // template workaround: reset of template
431 $tpl = $this->getInitialisedTemplate();
433
434 $params = [
435 "obj_id" => $lm_page_id,
436 "ref_id" => $this->lm->getRefId(),
437 "frame" => $frame
438 ];
439
440 $this->lm_gui->initByRequest($params);
441
444
445 $this->lm_gui->injectTemplate($tpl);
446 }
static resetInitialState()
Reset initial state (for exports)
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31

◆ resetUserLanguage()

ILIAS\LearningModule\Export\LMHtmlExport::resetUserLanguage ( )
protected

Definition at line 129 of file class.LMHtmlExport.php.

129 : void
130 {
131 $this->user->setLanguage($this->initial_user_language);
132 $this->user->setCurrentLanguage($this->initial_current_user_language);
133 }

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ setAdditionalContextData()

ILIAS\LearningModule\Export\LMHtmlExport::setAdditionalContextData ( string  $key,
  $data 
)
protected
Parameters
mixed$data

Definition at line 119 of file class.LMHtmlExport.php.

119 : void
120 {
121 $additional_data = $this->global_screen->tool()->context()->current()->getAdditionalData();
122 if ($additional_data->exists($key)) {
123 $additional_data->replace($key, $data);
124 } else {
125 $additional_data->add($key, $data);
126 }
127 }

References $data.

Referenced by ILIAS\LearningModule\Export\LMHtmlExport\__construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $co_page_html_export

ilCOPageHTMLExport ILIAS\LearningModule\Export\LMHtmlExport::$co_page_html_export
protected

Definition at line 42 of file class.LMHtmlExport.php.

◆ $collector

ExportCollector ILIAS\LearningModule\Export\LMHtmlExport::$collector
protected

Definition at line 32 of file class.LMHtmlExport.php.

◆ $content_style_domain

ILIAS Style Content Object ObjectFacade ILIAS\LearningModule\Export\LMHtmlExport::$content_style_domain
protected

Definition at line 52 of file class.LMHtmlExport.php.

◆ $export_dir

string ILIAS\LearningModule\Export\LMHtmlExport::$export_dir = ""
protected

◆ $export_format

string ILIAS\LearningModule\Export\LMHtmlExport::$export_format = ""
protected

◆ $export_util

Util ILIAS\LearningModule\Export\LMHtmlExport::$export_util
protected

Definition at line 33 of file class.LMHtmlExport.php.

◆ $global_screen

ILIAS GlobalScreen Services ILIAS\LearningModule\Export\LMHtmlExport::$global_screen
protected

Definition at line 51 of file class.LMHtmlExport.php.

◆ $initial_current_user_language

string ILIAS\LearningModule\Export\LMHtmlExport::$initial_current_user_language = ""
protected

Definition at line 50 of file class.LMHtmlExport.php.

◆ $initial_user_language

string ILIAS\LearningModule\Export\LMHtmlExport::$initial_user_language = ""
protected

Definition at line 49 of file class.LMHtmlExport.php.

◆ $lang

string ILIAS\LearningModule\Export\LMHtmlExport::$lang = ""
protected

◆ $lm

ilObjLearningModule ILIAS\LearningModule\Export\LMHtmlExport::$lm
protected

◆ $lm_gui

ilLMPresentationGUI ILIAS\LearningModule\Export\LMHtmlExport::$lm_gui
protected

Definition at line 44 of file class.LMHtmlExport.php.

◆ $lm_settings

ilSetting ILIAS\LearningModule\Export\LMHtmlExport::$lm_settings
protected

Definition at line 47 of file class.LMHtmlExport.php.

◆ $locator

ilLocatorGUI ILIAS\LearningModule\Export\LMHtmlExport::$locator
protected

Definition at line 41 of file class.LMHtmlExport.php.

◆ $log

ilLogger ILIAS\LearningModule\Export\LMHtmlExport::$log
protected

Definition at line 34 of file class.LMHtmlExport.php.

◆ $main_tpl

ilGlobalTemplateInterface ILIAS\LearningModule\Export\LMHtmlExport::$main_tpl
protected

Definition at line 39 of file class.LMHtmlExport.php.

◆ $obj_transl

Translations ILIAS\LearningModule\Export\LMHtmlExport::$obj_transl
protected

Definition at line 45 of file class.LMHtmlExport.php.

◆ $offline_files

array ILIAS\LearningModule\Export\LMHtmlExport::$offline_files = []
protected

Definition at line 48 of file class.LMHtmlExport.php.

◆ $sub_dir

string ILIAS\LearningModule\Export\LMHtmlExport::$sub_dir = ""
protected

◆ $target_dir

string ILIAS\LearningModule\Export\LMHtmlExport::$target_dir = ""
protected

Definition at line 35 of file class.LMHtmlExport.php.

◆ $ui

ILIAS DI UIServices ILIAS\LearningModule\Export\LMHtmlExport::$ui
protected

Definition at line 31 of file class.LMHtmlExport.php.

◆ $user

ilObjUser ILIAS\LearningModule\Export\LMHtmlExport::$user
protected

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