ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilGlossaryPresentationGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
27 {
28  protected \ILIAS\Glossary\Taxonomy\TaxonomyManager $tax_manager;
29  protected \ILIAS\COPage\Xsl\XslManager $xsl;
30  protected \ILIAS\GlobalScreen\Services $global_screen;
31  protected \ILIAS\Glossary\InternalGUIService $gui;
32  protected \ILIAS\Glossary\InternalDomainService $domain;
33  protected array $mobs;
34  protected bool $fill_on_load_code;
35  protected string $offline_dir;
37  protected bool $offline;
38  protected string $export_format;
39  protected ilCtrl $ctrl;
40  protected ilTabsGUI $tabs_gui;
44  protected \ilObjUser $user;
45  protected \ilHelpGUI $help;
46  protected \ilObjGlossary $glossary;
47  protected \ilObjGlossaryGUI $glossary_gui;
48  protected \ilGlobalTemplateInterface $tpl;
49  protected \ilLanguage $lng;
50  protected int $tax_node;
51  protected int $tax_id;
52  protected \ilObjTaxonomy $tax;
53  protected int $term_id;
54  protected int $requested_ref_id;
55  protected string $requested_letter;
56  protected int $requested_def_page_id;
57  protected string $requested_search_str;
58  protected string $requested_file_id;
59  protected int $requested_mob_id;
60  protected string $requested_export_type;
61  protected \ILIAS\Style\Content\Service $content_style_service;
62  protected \ILIAS\Style\Content\GUIService $content_style_gui;
63  protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
64  protected \ILIAS\UI\Factory $ui_fac;
65  protected \ILIAS\UI\Renderer $ui_ren;
66 
67  public function __construct(
68  string $export_format = "",
69  string $export_dir = ""
70  ) {
71  global $DIC;
72 
73  $service = $DIC->glossary()->internal();
74 
75  $this->domain = $domain = $service->domain();
76  $this->gui = $gui = $service->gui();
77 
78  $this->access = $DIC->access();
79  $this->user = $domain->user();
80  $this->lng = $DIC->language();
81 
82  $this->toolbar = $gui->toolbar();
83  $this->help = $gui->help();
84  $this->nav_history = $DIC["ilNavigationHistory"];
85  $this->tpl = $gui->ui()->mainTemplate();
86  $this->ctrl = $gui->ctrl();
87  $this->tabs_gui = $gui->tabs();
88  $this->global_screen = $gui->globalScreen();
89 
90  $this->export_format = $export_format;
91  $this->setOfflineDirectory($export_dir);
92  $this->offline = ($export_format != "");
93  $this->ui_fac = $DIC->ui()->factory();
94  $this->ui_ren = $DIC->ui()->renderer();
95  $this->offline = ($export_format !== "");
96 
97  $this->ctrl->saveParameter($this, array("ref_id", "letter", "tax_node"));
98  $this->content_style_service =
99  $DIC->contentStyle();
100  $this->initByRequest();
101  $this->xsl = $DIC->copage()->internal()->domain()->xsl();
102  $this->tax_manager = $domain->taxonomy($this->glossary);
103  }
104 
112  public function initByRequest(?array $query_params = null): void
113  {
114  $request = $this->gui
115  ->presentation()
116  ->request($query_params);
117 
118  $this->requested_ref_id = $request->getRefId();
119  $this->term_id = $request->getTermId();
120  $this->glossary_gui = $this->gui->presentation()->ObjGlossaryGUI($this->requested_ref_id);
121  $this->glossary = $this->glossary_gui->getGlossary();
122  $this->requested_def_page_id = $request->getDefinitionPageId();
123  $this->requested_search_str = $request->getSearchString();
124  $this->requested_file_id = $request->getFileId();
125  $this->requested_mob_id = $request->getMobId();
126  $this->requested_export_type = $request->getExportType();
127 
128 
129  // determine term id and check whether it is valid (belongs to
130  // current glossary or a virtual (online) sub-glossary)
131  $glo_ids = $this->glossary->getAllGlossaryIds();
132  $term_glo_id = ilGlossaryTerm::_lookGlossaryID($this->term_id);
133  if (!in_array($term_glo_id, $glo_ids) && !ilGlossaryTermReferences::isReferenced($glo_ids, $this->term_id)) {
134  if ($this->term_id > 0) {
135  throw new ilGlossaryException("Term ID does not match the glossary.");
136  }
137  $this->term_id = 0;
138  }
139 
140  $this->tax_node = 0;
141  $this->tax_id = $this->glossary->getTaxonomyId();
142  if ($this->tax_id > 0 && $this->glossary->getShowTaxonomy()) {
143  $this->tax = new ilObjTaxonomy($this->tax_id);
144  }
145  $requested_tax_node = $request->getTaxNode();
146  if ($requested_tax_node > 1 && $this->tax->getTree()->readRootId() != $requested_tax_node) {
147  $this->tax_node = $requested_tax_node;
148  }
149 
150  $this->requested_letter = $request->getLetter();
151 
152  $this->content_style_domain = $this->content_style_service->domain()->styleForRefId($this->glossary->getRefId());
153  $this->content_style_gui = $this->content_style_service->gui();
154  }
155 
156  public function injectTemplate(ilGlobalTemplateInterface $tpl): void
157  {
158  $this->tpl = $tpl;
159  }
160 
164  public function setOfflineMode(bool $a_offline = true): void
165  {
166  $this->offline = $a_offline;
167  }
168 
172  public function offlineMode(): bool
173  {
174  return $this->offline;
175  }
176 
177  public function setOfflineDirectory(string $a_dir): void
178  {
179  $this->offline_dir = $a_dir;
180  }
181 
182  public function getOfflineDirectory(): string
183  {
184  return $this->offline_dir;
185  }
186 
190  public function executeCommand(): void
191  {
192  $lng = $this->lng;
193  $ilAccess = $this->access;
194 
195  $lng->loadLanguageModule("content");
196 
197  $next_class = $this->ctrl->getNextClass($this);
198  if ($this->glossary->isActiveFlashcards()) {
199  $cmd = $this->ctrl->getCmd("showFlashcards");
200  } else {
201  $cmd = $this->ctrl->getCmd("listTerms");
202  }
203 
204  // check write permission
205  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id) &&
206  !($ilAccess->checkAccess("visible", "", $this->requested_ref_id) &&
207  ($cmd == "infoScreen" || strtolower($next_class) == "ilinfoscreengui"))) {
208  throw new ilPermissionException($lng->txt("permission_denied"));
209  }
210 
211  if ($cmd != "listDefinitions") {
212  $this->prepareOutput();
213  }
214 
215  switch ($next_class) {
216  case "ilnotegui":
217  $this->setTabs();
218  $ret = $this->listDefinitions();
219  break;
220 
221  case "ilinfoscreengui":
222  $ret = $this->outputInfoScreen();
223  break;
224 
225  case "ilpresentationfullgui":
226  $this->setTabs();
227  $this->showTaxonomy();
228  $full_gui = $this->gui->presentation()
229  ->PresentationFullGUI($this, $this->glossary, $this->offlineMode(), $this->tax_node);
230  $this->ctrl->forwardCommand($full_gui);
231  break;
232 
233  case "ilpresentationlisttablegui":
234  $prtab = $this->getPresentationTable();
235  $this->ctrl->forwardCommand($prtab);
236  return;
237 
238  case "ilglossarydefpagegui":
239  $page_gui = new ilGlossaryDefPageGUI($this->requested_def_page_id);
240  $this->basicPageGuiInit($page_gui);
241  $this->ctrl->forwardCommand($page_gui);
242  break;
243 
244  case "ilglossaryflashcardgui":
245  $flash_gui = new ilGlossaryFlashcardGUI();
246  $this->ctrl->forwardCommand($flash_gui);
247  break;
248 
249  case "ilglossaryflashcardboxgui":
250  $flash_box_gui = new ilGlossaryFlashcardBoxGUI();
251  $this->ctrl->forwardCommand($flash_box_gui);
252  break;
253 
254  default:
255  $this->$cmd();
256  break;
257  }
258  $this->tpl->printToStdout();
259  }
260 
261  public function prepareOutput(): void
262  {
263  $this->tpl->loadStandardTemplate();
264  $title = $this->glossary->getTitle();
265 
266  $this->tpl->setTitle($title);
267  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
268 
269  $this->setLocator();
270  }
271 
272 
276  public function basicPageGuiInit(
277  \ilPageObjectGUI $a_page_gui
278  ): void {
279  $a_page_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
280  if (!$this->offlineMode()) {
281  $a_page_gui->setOutputMode("presentation");
282  $this->fill_on_load_code = true;
283  } else {
284  $a_page_gui->setOutputMode("offline");
285  $a_page_gui->setOfflineDirectory($this->getOfflineDirectory());
286  $this->fill_on_load_code = false;
287  }
288  if (!$this->offlineMode()) {
289  $this->ctrl->setParameter($this, "pg_id", $a_page_gui->getId());
290  }
291  $a_page_gui->setFileDownloadLink($this->getLink($this->requested_ref_id, "downloadFile"));
292  $a_page_gui->setFullscreenLink($this->getLink($this->requested_ref_id, "fullscreen"));
293  }
294 
295  public function listTerms(): string
296  {
297  $ilNavigationHistory = $this->nav_history;
298  $ilAccess = $this->access;
299  $lng = $this->lng;
300  $ilToolbar = $this->toolbar;
301  $ilCtrl = $this->ctrl;
302  $ilTabs = $this->tabs_gui;
303 
304  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
305  throw new ilPermissionException($lng->txt("permission_denied"));
306  }
307 
308  $ret = "";
309  if ($this->glossary->getPresentationMode() == "full_def") {
310  $this->listTermByGivenAsPanel();
311  } else {
312  if (!$this->offlineMode()) {
313  $ilNavigationHistory->addItem(
314  $this->requested_ref_id,
315  $this->ctrl->getLinkTarget($this, "listTerms"),
316  "glo"
317  );
318 
319  // alphabetical navigation
320  $ai = new ilAlphabetInputGUI($lng->txt("glo_quick_navigation"), "first");
321 
322  $ai->setFixDBUmlauts(true);
323 
324  $first_letters = $this->glossary->getFirstLetters($this->tax_node);
325  if (!in_array($this->requested_letter, $first_letters)) {
326  $first_letters[] = ilUtil::stripSlashes($this->requested_letter);
327  }
328  $ai->setLetters($first_letters);
329 
330  $ai->setParentCommand($this, "chooseLetter");
331  $ai->setHighlighted($this->requested_letter);
332  $ilToolbar->addInputItem($ai, true);
333  }
334 
335  $ret = $this->listTermByGivenAsTable();
336  }
337 
338  $ilCtrl->setParameter($this, "term_id", "");
339 
340  $ilTabs->activateTab("terms");
341 
342  // show taxonomy
343  $this->showTaxonomy();
344 
345  $this->tpl->setPermanentLink("glo", $this->glossary->getRefId());
346 
347  return $ret;
348  }
349 
353  public function listTermByGivenAsTable(): string
354  {
355  $ilCtrl = $this->ctrl;
356  $ilAccess = $this->access;
357  $lng = $this->lng;
358  $tpl = $this->tpl;
359 
360  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
361  throw new ilPermissionException($lng->txt("permission_denied"));
362  }
363 
364  $this->lng->loadLanguageModule("meta");
365 
366  $this->setTabs();
367 
368  // load template for table
369  // $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
370 
371  $table = $this->getPresentationTable();
372 
373  if (!$this->offlineMode()) {
374  $tpl->setContent($ilCtrl->getHTML($table));
375  } else {
376  $this->tpl->setVariable("ADM_CONTENT", $table->getHTML());
377  return $this->tpl->printToString();
378  }
379  return "";
380  }
381 
385  public function listTermByGivenAsPanel(): void
386  {
387  $ilCtrl = $this->ctrl;
388 
389  $ilCtrl->redirectByClass("ilPresentationFullGUI", "show");
390  }
391 
392  protected function setContentStyles(): void
393  {
394  $tpl = $this->tpl;
395 
396  if (!$this->offlineMode()) {
397  $this->content_style_gui->addCss($tpl, $this->glossary->getRefId());
398  $tpl->addCss(ilObjStyleSheet::getSyntaxStylePath());
399  } else {
400  $tpl->addCss("content.css");
401  $tpl->addCss("syntaxhighlight.css");
402  }
403  }
404 
409  {
410  $table = new ilPresentationListTableGUI(
411  $this,
412  "listTerms",
413  $this->glossary,
414  $this->offlineMode(),
415  $this->tax_node,
416  $this->glossary->getTaxonomyId()
417  );
418  return $table;
419  }
420 
421  public function applyFilter(): void
422  {
423  $prtab = $this->getPresentationTable();
424  $prtab->resetOffset();
425  $prtab->writeFilterToSession();
426  $this->listTerms();
427  }
428 
429  public function resetFilter(): void
430  {
431  $prtab = $this->getPresentationTable();
432  $prtab->resetOffset();
433  $prtab->resetFilter();
434  $this->listTerms();
435  }
436 
440  public function listDefinitions(
441  int $a_ref_id = 0,
442  int $a_term_id = 0,
443  bool $a_get_html = false,
444  bool $render_term = true,
445  string $a_page_mode = ilPageObjectGUI::PRESENTATION,
446  bool $render_page_container = true
447  ): string {
448  $ilUser = $this->user;
449  $ilAccess = $this->access;
450  $lng = $this->lng;
451  $tpl = $this->tpl;
452 
453  if ($a_ref_id == 0) {
455  } else {
456  $ref_id = $a_ref_id;
457  }
458  if ($a_term_id == 0) {
459  $term_id = $this->term_id;
460  } else {
461  $term_id = $a_term_id;
462  }
463 
464  if (!$ilAccess->checkAccess("read", "", $ref_id)) {
465  throw new ilPermissionException($lng->txt("permission_denied"));
466  }
467 
468  // tabs
469  if ($this->glossary->getPresentationMode() != "full_def" &&
470  $a_page_mode != ilPageObjectGUI::PRINTING) {
471  $this->showDefinitionTabs("term_content");
472  }
473 
474  try {
475  $term = new ilGlossaryTerm($term_id);
476  } catch (Exception $e) {
477  return "";
478  }
479 
480  if (!$a_get_html) {
481  $tpl->loadStandardTemplate();
482 
483  $this->setContentStyles();
484 
485  if (!$this->offlineMode()) {
486  $this->setLocator();
487  }
488 
489  $tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
490  $tpl->setTitle($this->lng->txt("cont_term") . ": " . $term->getTerm());
491 
492  // advmd block
493  $cmd = null;
494  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
495  $cmd = array("edit" => $this->ctrl->getLinkTargetByClass(array("ilglossaryeditorgui", "ilobjglossarygui", "ilglossarytermgui", "ilobjectmetadatagui"), ""));
496  }
497  $mdgui = new ilObjectMetaDataGUI($this->glossary, "term", $term->getId());
498  $tpl->setRightContent($mdgui->getBlockHTML($cmd));
499  }
500 
501  $def_tpl = new ilTemplate("tpl.glossary_definition_list.html", true, true, "Modules/Glossary");
502 
503  if ($render_page_container) {
504  $def_tpl->touchBlock("page_container_1");
505  $def_tpl->touchBlock("page_container_2");
506  }
507 
508  if ($render_term) {
509  $def_tpl->setVariable("TXT_TERM", $term->getTerm());
510  }
511  $this->mobs = array();
512 
513  $page_gui = new ilGlossaryDefPageGUI($term_id);
514  $this->basicPageGuiInit($page_gui);
515  $page_gui->setGlossary($this->glossary);
516  $page_gui->setOutputMode($a_page_mode);
517  $page_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
518  $page = $page_gui->getPageObject();
519 
520  // internal links
521  $page->buildDom();
522 
523  if ($this->offlineMode()) {
524  $page_gui->setOutputMode("offline");
525  $page_gui->setOfflineDirectory($this->getOfflineDirectory());
526  }
527  $page_gui->setFullscreenLink($this->getLink($ref_id, "fullscreen", $term_id));
528 
529  $page_gui->setTemplateOutput(false);
530  $page_gui->setRawPageContent(true);
531  if (!$this->offlineMode()) {
532  $output = $page_gui->showPage();
533  } else {
534  $output = $page_gui->presentation($page_gui->getOutputMode());
535  }
536 
537  $def_tpl->setCurrentBlock("definition");
538  $def_tpl->setVariable("PAGE_CONTENT", $output);
539  $def_tpl->parseCurrentBlock();
540 
541  // display possible backlinks
542  $sources = ilInternalLink::_getSourcesOfTarget('git', $this->term_id, 0);
543 
544  if ($sources) {
545  $backlist_shown = false;
546  foreach ($sources as $src) {
547  $type = explode(':', $src['type']);
548 
549  if ($type[0] == 'lm' && $type[1] == 'pg') {
550  $title = ilLMPageObject::_getPresentationTitle($src['id']);
551  $lm_id = ilLMObject::_lookupContObjID($src['id']);
552  $lm_title = ilObject::_lookupTitle($lm_id);
553  $def_tpl->setCurrentBlock('backlink_item');
554  $ref_ids = ilObject::_getAllReferences($lm_id);
555  $access = false;
556  foreach ($ref_ids as $rid) {
557  if ($ilAccess->checkAccess("read", "", $rid)) {
558  $access = true;
559  }
560  }
561  if ($access) {
562  $def_tpl->setCurrentBlock("backlink_item");
563  $def_tpl->setVariable("BACKLINK_LINK", ILIAS_HTTP_PATH . "/goto.php?target=" . $type[1] . "_" . $src['id']);
564  $def_tpl->setVariable("BACKLINK_ITEM", $lm_title . ": " . $title);
565  $def_tpl->parseCurrentBlock();
566  $backlist_shown = true;
567  }
568  }
569  }
570  if ($backlist_shown) {
571  $def_tpl->setCurrentBlock("backlink_list");
572  $def_tpl->setVariable("BACKLINK_TITLE", $this->lng->txt('glo_term_used_in'));
573  $def_tpl->parseCurrentBlock();
574  }
575  }
576 
577  if (!$a_get_html) {
578  $tpl->setPermanentLink("git", null, $term_id . "_" . $ref_id);
579 
580  // show taxonomy
581  $this->showTaxonomy();
582  }
583 
584  // highlighting?
585  if ($this->requested_search_str != "" && !$this->offlineMode()) {
586  $cache = ilUserSearchCache::_getInstance($ilUser->getId());
587  $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
588  $search_string = $cache->getQuery();
589 
590  $p = new ilQueryParser($search_string);
591  $p->parse();
592 
593  $words = $p->getQuotedWords();
594  foreach ($words as $w) {
595  ilTextHighlighterGUI::highlight("ilGloContent", $w, $tpl);
596  }
597  $this->fill_on_load_code = true;
598  }
599  $tpl->setContent($def_tpl->get());
600  if ($this->offlineMode()) {
601  return $tpl->printToString();
602  } elseif ($a_get_html) {
603  return $def_tpl->get();
604  }
605  return "";
606  }
607 
608  public function showDefinitionTabs(string $a_act): void
609  {
610  $ilTabs = $this->tabs_gui;
611  $lng = $this->lng;
612  $ilCtrl = $this->ctrl;
613  $ilHelp = $this->help;
614 
615  if (!$this->offlineMode()) {
616  $ilHelp->setScreenIdComponent("glo");
617 
618  $ilCtrl->setParameter($this, "term_id", "");
619  $back = $ilCtrl->getLinkTarget($this, "listTerms");
620  $ilCtrl->setParameter($this, "term_id", $this->term_id);
621  $ilCtrl->saveParameter($this, "term_id");
622 
623  $ilTabs->setBackTarget($this->lng->txt("obj_glo"), $back);
624 
625  $ilTabs->addTab(
626  "term_content",
627  $lng->txt("content"),
628  $ilCtrl->getLinkTarget($this, "listDefinitions")
629  );
630 
631  $ilTabs->addTab(
632  "print_view",
633  $lng->txt("print_view"),
634  $ilCtrl->getLinkTarget($this, "printViewSelection")
635  );
636 
637  $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $this->term_id);
638  if (ilGlossaryTerm::_lookGlossaryID($this->term_id) == $this->glossary->getId()) {
639  if ($this->access->checkAccess("write", "", (int) $this->requested_ref_id) ||
640  $this->access->checkAccess("edit_content", "", (int) $this->requested_ref_id)) {
641  $ilTabs->addNonTabbedLink(
642  "editing_view",
643  $lng->txt("glo_editing_view"),
644  $ilCtrl->getLinkTargetByClass(array("ilglossaryeditorgui",
645  "ilobjglossarygui",
646  "ilglossarytermgui"
647  ), "editTerm")
648  );
649  }
650  //"ilias.php?baseClass=ilGlossaryEditorGUI&amp;ref_id=".$this->requested_ref_id."&amp;edit_term=".$this->term_id);
651  }
652  $ilTabs->activateTab($a_act);
653  }
654  }
655 
656 
657  public function fullscreen(): string
658  {
659  $html = $this->media("fullscreen");
660  return $html;
661  }
662 
666  public function media(string $a_mode = "media"): string
667  {
668  $this->tpl = new ilGlobalTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
669  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
670  $this->tpl->setVariable(
671  "LOCATION_CONTENT_STYLESHEET",
672  ilObjStyleSheet::getContentStylePath($this->content_style_domain->getEffectiveStyleId())
673  );
674 
675  //$int_links = $page_object->getInternalLinks();
676  $med_links = ilMediaItem::_getMapAreasIntLinks($this->requested_mob_id);
677 
678  // later
679  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
680 
681  $link_xml = "";
682 
683  $media_obj = new ilObjMediaObject($this->requested_mob_id);
684 
685  $xml = "<dummy>";
686  // todo: we get always the first alias now (problem if mob is used multiple
687  // times in page)
688  $xml .= $media_obj->getXML(IL_MODE_ALIAS);
689  $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
690  $xml .= $link_xml;
691  $xml .= "</dummy>";
692 
693  if (!$this->offlineMode()) {
694  $enlarge_path = ilUtil::getImagePath("media/enlarge.svg", false, "output");
695  $wb_path = ilFileUtils::getWebspaceDir("output") . "/";
696  } else {
697  $enlarge_path = "images/media/enlarge.svg";
698  $wb_path = "";
699  }
700 
701  $mode = $a_mode;
702 
703  $this->ctrl->setParameter($this, "obj_type", "MediaObject");
704  $fullscreen_link =
705  $this->getLink($this->requested_ref_id, "fullscreen");
706  $this->ctrl->clearParameters($this);
707 
708  $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path,
709  'link_params' => "ref_id=" . $this->requested_ref_id,'fullscreen_link' => $fullscreen_link,
710  'enable_html_mob' => ilObjMediaObject::isTypeAllowed("html") ? "y" : "n",
711  'ref_id' => $this->requested_ref_id, 'pg_frame' => "", 'webspace_path' => $wb_path);
712  $output = $this->xsl->process($xml, $params);
713 
714  // unmask user html
715  $this->tpl->setVariable("MEDIA_CONTENT", $output);
716 
717  $this->tpl->parseCurrentBlock();
718  if ($this->offlineMode()) {
719  $html = $this->tpl->get();
720  return $html;
721  }
722  return "";
723  }
724 
728  public function showDownloadList(): void
729  {
730  $ilAccess = $this->access;
731  $lng = $this->lng;
732  $ilTabs = $this->tabs_gui;
733 
734  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
735  throw new ilPermissionException($lng->txt("permission_denied"));
736  }
737 
738  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.glo_download_list.html", "Modules/Glossary");
739 
740  $this->setTabs();
741  $ilTabs->activateTab("download");
742 
743  // set title header
744  $this->tpl->setTitle($this->glossary->getTitle());
745  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
746 
747  // create table
748  $tbl = new ilTableGUI();
749 
750  // load files templates
751  $this->tpl->addBlockFile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
752 
753  // load template for table content data
754  $this->tpl->addBlockFile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", "Modules/Glossary");
755 
756  $export_files = array();
757  $types = array("xml", "html");
758  foreach ($types as $type) {
759  if ($this->glossary->getPublicExportFile($type) != "") {
760  $dir = $this->glossary->getExportDirectory($type);
761  if (is_file($this->glossary->getExportDirectory($type) . "/" .
762  $this->glossary->getPublicExportFile($type))) {
763  $size = filesize($this->glossary->getExportDirectory($type) . "/" .
764  $this->glossary->getPublicExportFile($type));
765  $export_files[] = array("type" => $type,
766  "file" => $this->glossary->getPublicExportFile($type),
767  "size" => $size);
768  }
769  }
770  }
771 
772  $num = 0;
773 
774  $tbl->setTitle($this->lng->txt("download"));
775 
776  $tbl->setHeaderNames(array($this->lng->txt("cont_format"),
777  $this->lng->txt("cont_file"),
778  $this->lng->txt("size"), $this->lng->txt("date"),
779  ""));
780 
781  $cols = array("format", "file", "size", "date", "download");
782  $header_params = array("ref_id" => $this->requested_ref_id,
783  "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
784  $tbl->setHeaderVars($cols, $header_params);
785  $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
786  $tbl->disable("sort");
787  // footer
788  $tbl->disable("footer");
789  $tbl->setMaxCount(count($export_files));
790 
791  $tbl->render();
792  if (count($export_files) > 0) {
793  $i = 0;
794  foreach ($export_files as $exp_file) {
795  $this->tpl->setCurrentBlock("tbl_content");
796  $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
797 
798  $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
799  $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
800  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"] . ":" . $exp_file["file"]);
801 
802  $file_arr = explode("__", $exp_file["file"]);
803  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s", $file_arr[0]));
804 
805  $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
806  $this->ctrl->setParameter($this, "type", $exp_file["type"]);
807  $this->tpl->setVariable(
808  "LINK_DOWNLOAD",
809  $this->ctrl->getLinkTarget($this, "downloadExportFile")
810  );
811 
812  $this->tpl->parseCurrentBlock();
813  }
814  } else {
815  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
816  $this->tpl->setVariable("NUM_COLS", 5);
817  $this->tpl->parseCurrentBlock();
818  }
819  }
820 
824  public function downloadExportFile(): void
825  {
826  $ilAccess = $this->access;
827  $lng = $this->lng;
828 
829  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
830  throw new ilPermissionException($lng->txt("permission_denied"));
831  }
832 
833  $file = $this->glossary->getPublicExportFile($this->requested_export_type);
834  if ($this->glossary->getPublicExportFile($this->requested_export_type) != "") {
835  $dir = $this->glossary->getExportDirectory($this->requested_export_type);
836  if (is_file($dir . "/" . $file)) {
837  ilFileDelivery::deliverFileLegacy($dir . "/" . $file, $file);
838  exit;
839  }
840  }
841  throw new ilGlossaryException($lng->txt("file_not_found"));
842  }
843 
844  public function setLocator(): void
845  {
846  $gloss_loc = new ilGlossaryLocatorGUI();
847  $gloss_loc->setMode("presentation");
848  if (!empty($this->term_id)) {
849  $term = new ilGlossaryTerm($this->term_id);
850  $gloss_loc->setTerm($term);
851  }
852  $gloss_loc->setGlossary($this->glossary);
853  $gloss_loc->display();
854  }
855 
856  public function downloadFile(): void
857  {
858  $ilAccess = $this->access;
859  $lng = $this->lng;
860 
861  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
862  throw new ilPermissionException($lng->txt("permission_denied"));
863  }
864 
865  $file = explode("_", $this->requested_file_id);
866  $fileObj = new ilObjFile($file[count($file) - 1], false);
867  $fileObj->sendFile();
868  exit;
869  }
870 
871  public function setTabs(): void
872  {
873  $this->getTabs();
874  }
875 
876  public function getLink(
877  int $a_ref_id,
878  string $a_cmd = "",
879  int $a_term_id = 0,
880  string $a_frame = "",
881  string $a_type = ""
882  ): string {
883  $link = "";
884  if ($a_cmd == "") {
885  $a_cmd = "layout";
886  }
887  //$script = "glossary_presentation.php";
888 
889  // handle online links
890  if (!$this->offlineMode()) {
891  //$link = $script."?ref_id=".$a_ref_id;
892  switch ($a_cmd) {
893  case "fullscreen":
894  $this->ctrl->setParameter($this, "term_id", $a_term_id);
895  $link = $this->ctrl->getLinkTarget($this, "fullscreen");
896  break;
897 
898  default:
899  $link .= "&amp;cmd=" . $a_cmd;
900  if ($a_frame != "") {
901  $this->ctrl->setParameter($this, "frame", $a_frame);
902  }
903  if ($a_type != "") {
904  $this->ctrl->setParameter($this, "obj_type", $a_type);
905  }
906  $link = $this->ctrl->getLinkTarget($this, $a_cmd);
907  break;
908  }
909  } else { // handle offline links
910  switch ($a_cmd) {
911  case "fullscreen":
912  $link = "fullscreen.html"; // id is handled by xslt
913  break;
914 
915  case "glossary":
916  $link = "term_" . $a_term_id . ".html";
917  break;
918 
919  case "downloadFile":
920  case "layout":
921  default:
922  break;
923  }
924  }
925  $this->ctrl->clearParameters($this);
926  return $link;
927  }
928 
929  public function printViewSelection(): void
930  {
931  $ilCtrl = $this->ctrl;
932  $tpl = $this->tpl;
933  $ilTabs = $this->tabs_gui;
934 
935  $ilCtrl->saveParameter($this, "term_id");
936 
937  if ($this->term_id == 0) {
938  $this->setTabs();
939  $ilTabs->activateTab("print_view");
940  } else {
941  $tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
942  $term = new ilGlossaryTerm($this->term_id);
943  $tpl->setTitle($this->lng->txt("cont_term") . ": " . $term->getTerm());
944  $this->showDefinitionTabs("print_view");
945  }
946 
948 
949  $tpl->setContent($this->form->getHTML());
950  }
951 
955  public function initPrintViewSelectionForm(): void
956  {
957  $lng = $this->lng;
958  $ilCtrl = $this->ctrl;
959 
960  $terms = $this->glossary->getTermList();
961 
962  $this->form = new ilPropertyFormGUI();
963  //$this->form->setTarget("print_view");
964  $this->form->setFormAction($ilCtrl->getFormAction($this));
965 
966  // selection type
967  $radg = new ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
968  $radg->setValue("glossary");
969 
970  // current term
971  if ($this->term_id > 0) {
972  $op1 = new ilRadioOption($lng->txt("cont_current_term"), "term");
973  $radg->addOption($op1);
974  $radg->setValue("term");
975  }
976 
977  // whole glossary
978  $op2 = new ilRadioOption($lng->txt("cont_whole_glossary")
979  . " (" . $lng->txt("cont_terms") . ": " . count($terms) . ")", "glossary");
980  $radg->addOption($op2);
981 
982  // selected topic
983  if (($t_id = $this->glossary->getTaxonomyId()) > 0 && $this->glossary->getShowTaxonomy()) {
984  $op4 = new ilRadioOption($lng->txt("cont_selected_topic"), "sel_topic");
985  $radg->addOption($op4);
986 
987  // topic drop down
988  $si = new ilTaxAssignInputGUI(
989  $t_id,
990  false,
991  $lng->txt("cont_topic"),
992  "topic",
993  false
994  );
995  if ($this->tax_node > 0) {
996  $si->setValue($this->tax_node);
997  }
998  $op4->addSubItem($si);
999  }
1000 
1001  // selected terms
1002  $op3 = new ilRadioOption($lng->txt("cont_selected_terms"), "selection");
1003  $radg->addOption($op3);
1004 
1005  $nl = new ilNestedListInputGUI("", "obj_id");
1006  $op3->addSubItem($nl);
1007  foreach ($terms as $t) {
1008  $nl->addListNode((string) $t["id"], (string) $t["term"], "0", false, false);
1009  }
1010 
1011  $this->form->addItem($radg);
1012 
1013  $this->form->addCommandButton("printView", $lng->txt("cont_show_print_view"));
1014  $this->form->setPreventDoubleSubmission(false);
1015 
1016  $this->form->setTitle($lng->txt("cont_print_selection"));
1017  }
1018 
1019  public function printView(): void
1020  {
1021  $ilAccess = $this->access;
1022  $tpl = $this->tpl;
1023 
1024  $this->tabs_gui->setBackTarget(
1025  $this->lng->txt("back"),
1026  $this->ctrl->getLinkTarget($this, "printViewSelection")
1027  );
1028 
1029  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
1030  return;
1031  }
1032 
1033  $this->initPrintViewSelectionForm();
1034  $this->form->checkInput();
1035 
1036  $terms = array();
1037  switch ($this->form->getInput("sel_type")) {
1038  case "glossary":
1039  $ts = $this->glossary->getTermList();
1040  foreach ($ts as $t) {
1041  $terms[] = $t["id"];
1042  }
1043  break;
1044 
1045  case "sel_topic":
1046  $t_id = $this->glossary->getTaxonomyId();
1047  $items = ilObjTaxonomy::getSubTreeItems("glo", $this->glossary->getId(), "term", $t_id, (int) $this->form->getInput("topic"));
1048  foreach ($items as $i) {
1049  if ($i["item_type"] == "term") {
1050  $terms[] = $i["item_id"];
1051  }
1052  }
1053  break;
1054 
1055  case "selection":
1056  $terms = $this->form->getInput("obj_id");
1057  break;
1058 
1059  case "term":
1060  $terms = array($this->term_id);
1061  break;
1062  }
1063 
1064  //$tpl->addCss(ilObjStyleSheet::getContentPrintStyle());
1065  $tpl->addOnLoadCode("il.Util.print();");
1066 
1067  // determine target frames for internal links
1068 
1069  $page_content = "";
1070  foreach ($terms as $t_id) {
1071  $page_content .= $this->listDefinitions($this->requested_ref_id, $t_id, true, true, ilPageObjectGUI::PRINTING);
1072  }
1073  $tpl->setContent($page_content);
1074  }
1075 
1076  public function getTabs(): void
1077  {
1078  $ilAccess = $this->access;
1079  $lng = $this->lng;
1080  $ilCtrl = $this->ctrl;
1081  $ilHelp = $this->help;
1082 
1083  $ilHelp->setScreenIdComponent("glo");
1084 
1085  if (!$this->offlineMode()) {
1086  if ($this->ctrl->getCmd() != "listDefinitions") {
1087  if ($ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
1088  if ($this->glossary->isActiveFlashcards()) {
1089  $this->tabs_gui->addTab(
1090  "flashcards",
1091  $lng->txt("glo_flashcards"),
1092  $ilCtrl->getLinkTarget($this, "showFlashcards")
1093  );
1094  }
1095  $this->tabs_gui->addTab(
1096  "terms",
1097  $lng->txt("content"),
1098  $ilCtrl->getLinkTarget($this, "listTerms")
1099  );
1100  }
1101 
1102  $this->tabs_gui->addTab(
1103  "info",
1104  $lng->txt("info_short"),
1105  $ilCtrl->getLinkTarget($this, "infoScreen")
1106  );
1107 
1108 
1109  // glossary menu
1110  if ($ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
1111  $this->tabs_gui->addTab(
1112  "print_view",
1113  $lng->txt("cont_print_view"),
1114  $ilCtrl->getLinkTarget($this, "printViewSelection")
1115  );
1116 
1117  // download links
1118  if ($this->glossary->isActiveDownloads()) {
1119  $this->tabs_gui->addTab(
1120  "download",
1121  $lng->txt("download"),
1122  $ilCtrl->getLinkTarget($this, "showDownloadList")
1123  );
1124  }
1125  //}
1126  }
1127 
1128  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id) ||
1129  $ilAccess->checkAccess("edit_content", "", $this->requested_ref_id)) {
1130  $this->tabs_gui->addNonTabbedLink(
1131  "editing_view",
1132  $lng->txt("glo_editing_view"),
1133  "ilias.php?baseClass=ilGlossaryEditorGUI&amp;ref_id=" . $this->requested_ref_id,
1134  "_top"
1135  );
1136  }
1137  }
1138  } else {
1139  $this->tabs_gui->addTarget(
1140  "cont_back",
1141  "index.html#term_" . $this->term_id,
1142  "",
1143  ""
1144  );
1145  }
1146  }
1147 
1151  public function infoScreen(): void
1152  {
1153  $this->ctrl->setCmd("showSummary");
1154  $this->ctrl->setCmdClass("ilinfoscreengui");
1155  $this->outputInfoScreen();
1156  }
1157 
1158  public function outputInfoScreen(): string
1159  {
1160  $ilAccess = $this->access;
1161  $ilTabs = $this->tabs_gui;
1162 
1163  $this->setTabs();
1164  $ilTabs->activateTab("info");
1165  $this->lng->loadLanguageModule("meta");
1166 
1167  $info = new ilInfoScreenGUI($this->glossary_gui);
1168  $info->enablePrivateNotes();
1169  //$info->enableLearningProgress();
1170 
1171  $info->enableNews();
1172  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
1173  $info->enableNewsEditing();
1174  $news_set = new ilSetting("news");
1175  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1176  if ($enable_internal_rss) {
1177  $info->setBlockProperty("news", "settings", true);
1178  }
1179  }
1180 
1181  // show standard meta data section
1182  $info->addMetaDataSections($this->glossary->getId(), 0, $this->glossary->getType());
1183 
1184  ilObjGlossaryGUI::addUsagesToInfo($info, $this->glossary->getId());
1185 
1186  if ($this->offlineMode()) {
1187  $this->tpl->setContent($info->getHTML());
1188  return $this->tpl->get();
1189  } else {
1190  // forward the command
1191  $this->ctrl->forwardCommand($info);
1192  }
1193  return "";
1194  }
1195 
1196  public function chooseLetter(): void
1197  {
1198  $ilCtrl = $this->ctrl;
1199  $ilCtrl->redirect($this, "listTerms");
1200  }
1201 
1202  public function showTaxonomy(): void
1203  {
1204  $ctrl = $this->ctrl;
1205 
1206  if ($this->offlineMode() || !$this->tax_manager->showInPresentation()) {
1207  return;
1208  }
1209 
1210  $tax_id = $this->tax_manager->getTaxonomyId();
1211 
1212  $tool_context = $this->global_screen->tool()->context()->current();
1213 
1214  $tool_context->addAdditionalData(
1216  true
1217  );
1218  $tool_context->addAdditionalData(
1220  [self::class]
1221  );
1222  $tool_context->addAdditionalData(
1224  $tax_id
1225  );
1226  $tool_context->addAdditionalData(
1228  "listTerms"
1229  );
1230  $tool_context->addAdditionalData(
1232  "showTaxonomy"
1233  );
1234  }
1235 
1236  public function showFlashcards(): void
1237  {
1238  $ilTabs = $this->tabs_gui;
1239 
1240  $this->setTabs();
1241  $ilTabs->activateTab("flashcards");
1242  $flashcards = new ilGlossaryFlashcardGUI();
1243  $flashcards->listBoxes();
1244  }
1245 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getWebspaceDir(string $mode="filesystem")
get webspace directory
ILIAS Style Content Service $content_style_service
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...
exit
Definition: login.php:29
Class ilInfoScreenGUI.
static addUsagesToInfo(ilInfoScreenGUI $info, int $glo_id)
Add usages to info screen.
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
initPrintViewSelectionForm()
Init print view selection form.
setOfflineMode(bool $a_offline=true)
set offline mode (content is generated for offline package)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
basicPageGuiInit(\ilPageObjectGUI $a_page_gui)
Basic page gui initialisation.
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
special template class to simplify handling of ITX/PEAR
static getSubTreeItems(string $a_comp, int $a_obj_id, string $a_item_type, int $a_tax_id, $a_node)
Get all assigned items under a node.
setOutputMode(string $a_mode=self::PRESENTATION)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static _getInstance(int $a_usr_id)
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Class ilPageObjectGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initByRequest(?array $query_params=null)
Init services and this class by request params.
GUI class for glossary flashcard boxes.
infoScreen()
this one is called from the info button in the repository
ILIAS Style Content GUIService $content_style_gui
setOfflineDirectory(string $offdir)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
setStyleId(int $a_styleid)
static isReferenced(array $a_glo_id, int $a_term_id)
Is a term referenced by a set of glossaries.
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
ILIAS Style Content Object ObjectFacade $content_style_domain
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
This class represents a property in a property form.
static _lookupTitle(int $obj_id)
setValue($a_value)
Set Value.
__construct(string $export_format="", string $export_dir="")
static isTypeAllowed(string $a_type)
setScreenIdComponent(string $a_comp)
GUI class for glossary flashcards.
setValue(string $a_value)
ILIAS Glossary InternalGUIService $gui
Class ilObjFile.
ILIAS Glossary InternalDomainService $domain
static _getMapAreasIntLinks(int $a_mob_id)
get all internal links of map areas of a mob
setFullscreenLink(string $a_fullscreen_link)
injectTemplate(ilGlobalTemplateInterface $tpl)
const IL_MODE_ALIAS
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
Last visited history for repository items.
media(string $a_mode="media")
show media object
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFileDownloadLink(string $a_download_link)
form( $class_path, string $cmd, string $submit_caption="")
listDefinitions(int $a_ref_id=0, int $a_term_id=0, bool $a_get_html=false, bool $render_term=true, string $a_page_mode=ilPageObjectGUI::PRESENTATION, bool $render_page_container=true)
list definitions of a term
static _getPresentationTitle(int $a_pg_id, string $a_mode=self::CHAPTER_TITLE, bool $a_include_numbers=false, bool $a_time_scheduled_activation=false, bool $a_force_content=false, int $a_lm_id=0, string $a_lang="-", bool $a_include_short=false)
presentation title doesn&#39;t have to be page title, it may be chapter title + page title or chapter tit...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
offlineMode()
checks wether offline content generation is activated
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupContObjID(int $a_id)
get learning module id for lm object
const IL_MODE_OUTPUT
ILIAS GlobalScreen Services $global_screen
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPresentationTable()
Get presentation table.
$service
Definition: ltiservices.php:43
getLink(int $a_ref_id, string $a_cmd="", int $a_term_id=0, string $a_frame="", string $a_type="")
ILIAS Glossary Taxonomy TaxonomyManager $tax_manager
downloadExportFile()
send download file (xml/html)
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookGlossaryID(int $term_id)
get glossary id form term id