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