ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
GlossaryHtmlExport.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ilFileUtils;
26
28{
30 protected \ilGlossaryPresentationGUI $glo_gui;
31 protected \ilObjGlossary $glossary;
32 protected string $export_dir;
33 protected string $sub_dir;
34 protected string $target_dir;
35 protected \ILIAS\GlobalScreen\Services $global_screen;
36 protected Util $export_util;
37 protected \ilCOPageHTMLExport $co_page_html_export;
38 protected \ILIAS\Style\Content\Object\ObjectFacade $content_style;
39 protected \ILIAS\Glossary\InternalService $service;
40 protected \ilPresentationFullGUI $glo_full_gui;
41 protected \ilPresentationTableGUI $glo_table_gui;
42
43 public function __construct(
44 \ilObjGlossary $glo,
45 string $exp_dir,
46 string $sub_dir
47 ) {
48 global $DIC;
49
50 $this->glossary = $glo;
51 $this->export_dir = $exp_dir;
52 $this->sub_dir = $sub_dir;
53 $this->target_dir = $exp_dir . "/" . $sub_dir;
54
55 $this->service = $DIC->glossary()
56 ->internal();
57 $this->global_screen = $DIC->globalScreen();
58
59 $this->collector = $DIC->export()->domain()->html()->collector($glo->getId());
60 $this->collector->init();
61 $this->export_util = new Util("", "", $this->collector);
62 $this->co_page_html_export = new \ilCOPageHTMLExport($this->target_dir, null, 0, $this->collector);
63
64 // get glossary presentation gui classes
65 $this->glo_gui = new \ilGlossaryPresentationGUI("html", $this->target_dir);
66 $this->glo_full_gui = $this->service
67 ->gui()
68 ->presentation()
69 ->PresentationFullGUI($this->glo_gui, $this->glossary, true);
70 $this->glo_table_gui = $this->service
71 ->gui()
72 ->presentation()
73 ->PresentationTableGUI($this->glo_gui, $this->glossary, true);
74
75 $this->global_screen->tool()->context()->current()->addAdditionalData(\ilHTMLExportViewLayoutProvider::HTML_EXPORT_RENDERING, true);
76 $this->content_style = $DIC
77 ->contentStyle()
78 ->domain()
79 ->styleForRefId($glo->getRefId());
80 }
81
82 public function exportHTML(): void
83 {
84 $this->export_util->exportSystemStyle(
85 [
86 "icon_glo.svg"
87 ]
88 );
89 $this->export_util->exportCOPageFiles($this->content_style->getEffectiveStyleId(), "glo");
90
91 // export terms
93
94 $this->export_util->exportResourceFiles();
95
96 $this->co_page_html_export->exportPageElements();
97 }
98
100 {
101 global $DIC;
102
103 $tabs = $DIC->tabs();
104
105 $tabs->clearTargets();
106 $tabs->clearSubTabs();
107 $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
108
109 $this->co_page_html_export->getPreparedMainTemplate($tpl);
110
111 return $tpl;
112 }
113
118 protected function initScreen(int $term_id): \ilGlobalPageTemplate
119 {
120 $this->global_screen->layout()->meta()->reset();
121
122 // load style sheet depending on user's settings
123 $location_stylesheet = \ilUtil::getStyleSheetLocation();
124 $this->global_screen->layout()->meta()->addCss($location_stylesheet);
125 $this->global_screen->layout()->meta()->addCss(
126 \ilObjStyleSheet::getContentStylePath($this->content_style->getEffectiveStyleId())
127 );
128
129 //$this->addSupplyingExportFiles();
130
131 // template workaround: reset of template
132 $tpl = $this->getInitialisedTemplate();
134
135 $params = [
136 "term_id" => $term_id,
137 "ref_id" => $this->glossary->getRefId(),
138 "frame" => "_blank"
139 ];
140
141 $this->glo_gui->initByRequest($params);
142
143 $this->glo_gui->injectTemplate($tpl);
144 return $tpl;
145 }
146
147
151 public function exportHTMLGlossaryTerms(): void
152 {
153 $tpl = $this->initScreen(0);
154 $tpl->setTitle($this->glossary->getTitle());
155 if ($this->glossary->getPresentationMode() == "full_def") {
156 $content = $this->glo_full_gui->renderPanelForOffline();
157 } else {
158 $content = $this->glo_table_gui->renderPresentationTableForOffline();
159 }
160 $this->collector->addString($content, "index.html");
161
162 $terms = $this->glossary->getTermList();
163 foreach ($terms as $term) {
164 $this->initScreen($term["id"]);
165 $content = $this->glo_gui->listDefinitions($this->glossary->getRefId(), $term["id"], false);
166 $this->collector->addString($content, "term_" . $term["id"] . ".html");
167
168 // store linked/embedded media objects of glosssary term
169 $this->co_page_html_export->collectPageElements("term:pg", $term["id"], "");
170 }
171 }
172}
ILIAS Style Content Object ObjectFacade $content_style
ILIAS GlobalScreen Services $global_screen
ILIAS Glossary InternalService $service
__construct(\ilObjGlossary $glo, string $exp_dir, string $sub_dir)
Util This class is an interim solution for the HTML export handling with 6.0.
Definition: class.Util.php:33
Class ilFileUtils.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
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
global $DIC
Definition: shib_login.php:26