ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

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 53 of file class.LMHtmlExport.php.

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

251 : void
252 {
253 foreach ($this->getSupplyingExportFiles() as $f) {
254 if ($f["source"] != "") {
255 if ($f["type"] == "js") {
256 $this->global_screen->layout()->meta()->addJs($f["source"]);
257 }
258 if ($f["type"] == "css") {
259 $this->global_screen->layout()->meta()->addCss($f["source"]);
260 }
261 }
262 }
263 }
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 218 of file class.LMHtmlExport.php.

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

References $lang, and 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 364 of file class.LMHtmlExport.php.

364 : void
365 {
366 $lm = $this->lm;
368 $lang = $lm_gui->lang;
369 $all_languages = ($this->lang == "all");
371 $ilLocator = $this->locator;
372
374
375 $lm_tree = $lm->getLMTree();
376 $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg");
377 $first_page_id = $first_page["child"];
378
379 // iterate all learning module pages
380 $mobs = [];
381 $int_links = [];
382 $this->offline_files = [];
383
384 // get html export id mapping
385
386 $exp_id_map = array();
387
388 if ($lm_set->get("html_export_ids")) {
389 foreach ($pages as $page) {
390 $exp_id = \ilLMPageObject::getExportId($this->lm->getId(), $page["obj_id"]);
391 if (trim($exp_id) != "") {
392 $exp_id_map[$page["obj_id"]] = trim($exp_id);
393 }
394 }
395 }
396
397 if ($lang == "") {
398 $lang = "-";
399 }
400
401 reset($pages);
402 foreach ($pages as $page) {
403 if (\ilLMPage::_exists($this->lm->getType(), $page["obj_id"])) {
404 $ilLocator->clearItems();
405 $this->exportPageHTML($page["obj_id"], ($first_page_id == $page["obj_id"]), $lang, "", $exp_id_map);
406 $this->co_page_html_export->collectPageElements("lm:pg", $page["obj_id"], $lang);
407 }
408 }
409 }
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 $lang, $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 464 of file class.LMHtmlExport.php.

470 : void {
472 $lang_suffix = "";
473 if (!in_array($lang, ["-", ""]) && $this->lang === "all") {
474 $lang_suffix = "_" . $lang;
475 }
476
477 // Init template, lm_gui
478 $this->initScreen($lm_page_id, $frame);
479
480 if ($frame == "") {
481 if (is_array($exp_id_map) && isset($a_exp_id_map[$lm_page_id])) {
482 $file = "lm_pg_" . $exp_id_map[$lm_page_id] . $lang_suffix . ".html";
483 } else {
484 $file = "lm_pg_" . $lm_page_id . $lang_suffix . ".html";
485 }
486 } else {
487 if ($frame != "toc") {
488 $file = "frame_" . $lm_page_id . "_" . $frame . $lang_suffix . ".html";
489 } else {
490 $file = "frame_" . $frame . $lang_suffix . ".html";
491 }
492 }
493
494 // return if file is already existing
495 /*
496 if (is_file($file)) {
497 return;
498 }*/
499
500 $content = $this->lm_gui->layout("main.xml", false);
501
502 $this->collector->addString($content, $file);
503
504 if ($is_first && $frame == "") {
505 $this->collector->addString($content, "index" . $lang_suffix . ".html");
506 }
507 }
initScreen(int $lm_page_id, string $frame)
Init global screen and learning module presentation gui for page.

References $lang.

◆ getInitialisedTemplate()

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

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

412 {
413 global $DIC;
414
415 $tabs = $DIC->tabs();
416
417 $tabs->clearTargets();
418 $tabs->clearSubTabs();
419 $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
420
421 $this->co_page_html_export->getPreparedMainTemplate($tpl);
422
423 return $tpl;
424 }

References $DIC.

◆ getLinker()

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

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

97 : PageLinker
98 {
99 return new \ilLMPresentationLinker(
100 $this->lm,
101 new \ilLMTree($this->lm->getId()),
102 0,
103 $this->lm->getRefId(),
104 $this->lang,
105 "",
106 "",
107 true,
108 "html",
109 false
110 );
111 }
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 268 of file class.LMHtmlExport.php.

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

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

+ Here is the call graph for this function:

◆ initGlobalScreen()

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

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

205 : void
206 {
207 // set global
208 $this->global_screen->tool()->context()->current()->addAdditionalData(
210 true
211 );
212 }

References ilLMHtmlExportViewLayoutProvider\LM_HTML_EXPORT_RENDERING.

◆ initLanguage()

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

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

185 : void {
186 $user_lang = $user->getLanguage();
187
188 if ($lang != "") {
191 } else {
192 $user->setLanguage($user_lang);
193 $user->setCurrentLanguage($user_lang);
194 }
195
196 if ($lang != "") {
197 if ($lang == $this->obj_transl->getBaseLanguage()) {
198 $lm_gui->lang = "";
199 } else {
200 $lm_gui->lang = $lang;
201 }
202 }
203 }
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 430 of file class.LMHtmlExport.php.

433 : void {
434 $this->global_screen->layout()->meta()->reset();
435
436 // load style sheet depending on user's settings
437 $location_stylesheet = \ilUtil::getStyleSheetLocation();
438 $this->global_screen->layout()->meta()->addCss($location_stylesheet);
439
441
442 // template workaround: reset of template
443 $tpl = $this->getInitialisedTemplate();
445
446 $params = [
447 "obj_id" => $lm_page_id,
448 "ref_id" => $this->lm->getRefId(),
449 "frame" => $frame
450 ];
451
452 $this->lm_gui->initByRequest($params);
453
456
457 $this->lm_gui->injectTemplate($tpl);
458 }
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 126 of file class.LMHtmlExport.php.

126 : void
127 {
128 $this->user->setLanguage($this->initial_user_language);
129 $this->user->setCurrentLanguage($this->initial_current_user_language);
130 }

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 116 of file class.LMHtmlExport.php.

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

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 41 of file class.LMHtmlExport.php.

◆ $collector

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

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

◆ $content_style_domain

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

Definition at line 51 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 32 of file class.LMHtmlExport.php.

◆ $global_screen

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

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

◆ $initial_current_user_language

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

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

◆ $initial_user_language

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

Definition at line 48 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 43 of file class.LMHtmlExport.php.

◆ $lm_settings

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

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

◆ $locator

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

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

◆ $log

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

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

◆ $main_tpl

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

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

◆ $obj_transl

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

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

◆ $offline_files

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

Definition at line 47 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 34 of file class.LMHtmlExport.php.

◆ $user

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

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