ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
GlossaryHtmlExport.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use 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  $this->export_util->exportCOPageFiles($this->content_style->getEffectiveStyleId(), "glo");
86 
87  // export terms
88  $this->exportHTMLGlossaryTerms();
89 
90  $this->export_util->exportResourceFiles();
91 
92  $this->co_page_html_export->exportPageElements();
93  }
94 
96  {
97  global $DIC;
98 
99  $tabs = $DIC->tabs();
100 
101  $tabs->clearTargets();
102  $tabs->clearSubTabs();
103  $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
104 
105  $this->co_page_html_export->getPreparedMainTemplate($tpl);
106 
107  return $tpl;
108  }
109 
114  protected function initScreen(int $term_id): \ilGlobalPageTemplate
115  {
116  $this->global_screen->layout()->meta()->reset();
117 
118  // load style sheet depending on user's settings
119  $location_stylesheet = \ilUtil::getStyleSheetLocation();
120  $this->global_screen->layout()->meta()->addCss($location_stylesheet);
121  $this->global_screen->layout()->meta()->addCss(
122  \ilObjStyleSheet::getContentStylePath($this->content_style->getEffectiveStyleId())
123  );
124 
125  //$this->addSupplyingExportFiles();
126 
127  // template workaround: reset of template
128  $tpl = $this->getInitialisedTemplate();
130 
131  $params = [
132  "term_id" => $term_id,
133  "ref_id" => $this->glossary->getRefId(),
134  "frame" => "_blank"
135  ];
136 
137  $this->glo_gui->initByRequest($params);
138 
139  $this->glo_gui->injectTemplate($tpl);
140  return $tpl;
141  }
142 
143 
147  public function exportHTMLGlossaryTerms(): void
148  {
149  $tpl = $this->initScreen(0);
150  $tpl->setTitle($this->glossary->getTitle());
151  if ($this->glossary->getPresentationMode() == "full_def") {
152  $content = $this->glo_full_gui->renderPanelForOffline();
153  } else {
154  $content = $this->glo_table_gui->renderPresentationTableForOffline();
155  }
156  $this->collector->addString($content, "index.html");
157 
158  $terms = $this->glossary->getTermList();
159  foreach ($terms as $term) {
160  $this->initScreen($term["id"]);
161  $content = $this->glo_gui->listDefinitions($this->glossary->getRefId(), $term["id"], false);
162  $this->collector->addString($content, "term_" . $term["id"] . ".html");
163 
164  // store linked/embedded media objects of glosssary term
165  $this->co_page_html_export->collectPageElements("term:pg", $term["id"], "");
166  }
167  }
168 }
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
__construct(\ilObjGlossary $glo, string $exp_dir, string $sub_dir)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ILIAS GlobalScreen Services $global_screen
ILIAS Glossary InternalService $service
global $DIC
Definition: shib_login.php:22
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
Util This class is an interim solution for the HTML export handling with 6.0.
Definition: class.Util.php:32
static resetInitialState()
Reset initial state (for exports)
ILIAS Style Content Object ObjectFacade $content_style