ILIAS  trunk Revision v12.0_alpha-1338-g8f7e531aa3c
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->co_page_html_export->exportPageElements();
95 }
96
98 {
99 global $DIC;
100
101 $tabs = $DIC->tabs();
102
103 $tabs->clearTargets();
104 $tabs->clearSubTabs();
105 $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
106
107 $this->co_page_html_export->getPreparedMainTemplate($tpl);
108
109 return $tpl;
110 }
111
116 protected function initScreen(int $term_id): \ilGlobalPageTemplate
117 {
118 $this->export_util->resetGlobalScreen();
119
120 // load style sheet depending on user's settings
121 $location_stylesheet = \ilUtil::getStyleSheetLocation();
122 $this->global_screen->layout()->meta()->addCss($location_stylesheet);
123 $this->global_screen->layout()->meta()->addCss(
124 \ilObjStyleSheet::getContentStylePath($this->content_style->getEffectiveStyleId())
125 );
126
127 //$this->addSupplyingExportFiles();
128
129 // template workaround: reset of template
130 $tpl = $this->getInitialisedTemplate();
132
133 $params = [
134 "term_id" => $term_id,
135 "ref_id" => $this->glossary->getRefId(),
136 "frame" => "_blank"
137 ];
138
139 $this->glo_gui->initByRequest($params);
140
141 $this->glo_gui->injectTemplate($tpl);
142 return $tpl;
143 }
144
145
149 public function exportHTMLGlossaryTerms(): void
150 {
151 $tpl = $this->initScreen(0);
152 $tpl->setTitle($this->glossary->getTitle());
153 if ($this->glossary->getPresentationMode() == "full_def") {
154 $content = $this->glo_full_gui->renderPanelForOffline();
155 } else {
156 $content = $this->glo_table_gui->renderPresentationTableForOffline();
157 }
158 $tpl->setContent($content);
159 $this->collector->addString($tpl->printToString(), "index.html");
160 $this->export_util->exportResourceFiles(); // same level as init screen which calls reset
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 $this->export_util->exportResourceFiles(); // same level as init screen which calls reset
168
169 // store linked/embedded media objects of glosssary term
170 $this->co_page_html_export->collectPageElements("term:pg", $term["id"], "");
171 }
172 }
173}
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