ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilGlossaryPresentationGUI.php
Go to the documentation of this file.
1 <?php
2 
26 {
27  protected \ILIAS\Glossary\Taxonomy\TaxonomyManager $tax_manager;
28  protected \ILIAS\COPage\Xsl\XslManager $xsl;
29  protected \ILIAS\GlobalScreen\Services $global_screen;
30  protected \ILIAS\Glossary\InternalGUIService $gui;
31  protected \ILIAS\Glossary\InternalDomainService $domain;
32  protected array $mobs;
33  protected bool $fill_on_load_code;
34  protected string $offline_dir;
36  protected bool $offline;
37  protected string $export_format;
38  protected ilCtrl $ctrl;
39  protected ilTabsGUI $tabs_gui;
43  protected \ilObjUser $user;
44  protected \ilHelpGUI $help;
45  protected \ilObjGlossary $glossary;
46  protected \ilObjGlossaryGUI $glossary_gui;
47  protected \ilGlobalTemplateInterface $tpl;
48  protected \ilLanguage $lng;
49  protected int $tax_node;
50  protected int $tax_id;
51  protected \ilObjTaxonomy $tax;
52  protected int $term_id;
53  protected int $requested_ref_id;
54  protected string $requested_letter;
55  protected int $requested_def_page_id;
56  protected string $requested_search_str;
57  protected string $requested_file_id;
58  protected int $requested_mob_id;
64  protected \ILIAS\Style\Content\Service $content_style_service;
65  protected \ILIAS\Style\Content\GUIService $content_style_gui;
66  protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
67  protected \ILIAS\UI\Factory $ui_fac;
68  protected \ILIAS\UI\Renderer $ui_ren;
69 
70  public function __construct(
71  string $export_format = "",
72  string $export_dir = ""
73  ) {
74  global $DIC;
75 
76  $service = $DIC->glossary()->internal();
77 
78  $this->domain = $domain = $service->domain();
79  $this->gui = $gui = $service->gui();
80 
81  $this->access = $DIC->access();
82  $this->user = $domain->user();
83  $this->lng = $DIC->language();
84 
85  $this->toolbar = $gui->toolbar();
86  $this->help = $gui->help();
87  $this->nav_history = $DIC["ilNavigationHistory"];
88  $this->tpl = $gui->ui()->mainTemplate();
89  $this->ctrl = $gui->ctrl();
90  $this->tabs_gui = $gui->tabs();
91  $this->global_screen = $gui->globalScreen();
92 
93  $this->export_format = $export_format;
94  $this->setOfflineDirectory($export_dir);
95  $this->offline = ($export_format != "");
96  $this->ui_fac = $DIC->ui()->factory();
97  $this->ui_ren = $DIC->ui()->renderer();
98  $this->offline = ($export_format !== "");
99 
100  $this->ctrl->saveParameter($this, array("ref_id", "letter", "tax_node"));
101  $this->content_style_service =
102  $DIC->contentStyle();
103  $this->initByRequest();
104  $this->xsl = $DIC->copage()->internal()->domain()->xsl();
105  $this->tax_manager = $domain->taxonomy($this->glossary);
106  }
107 
115  public function initByRequest(?array $query_params = null): void
116  {
117  $request = $this->gui
118  ->presentation()
119  ->request($query_params);
120 
121  $this->requested_ref_id = $request->getRefId();
122  $this->term_id = $request->getTermId();
123  $this->glossary_gui = $this->gui->presentation()->ObjGlossaryGUI($this->requested_ref_id);
124  $this->glossary = $this->glossary_gui->getGlossary();
125  $this->requested_def_page_id = $request->getDefinitionPageId();
126  $this->requested_search_str = $request->getSearchString();
127  $this->requested_file_id = $request->getFileId();
128  $this->requested_mob_id = $request->getMobId();
129  $this->requested_table_glossary_download_list_action = $request->getTableGlossaryDownloadListAction();
130  $this->requested_table_glossary_download_file_ids = $request->getTableGlossaryDownloadFileIds();
131 
132 
133  // determine term id and check whether it is valid (belongs to
134  // current glossary or a virtual (online) sub-glossary)
135  $glo_ids = $this->glossary->getAllGlossaryIds();
136  $term_glo_id = ilGlossaryTerm::_lookGlossaryID($this->term_id);
137  if (!in_array($term_glo_id, $glo_ids) && !ilGlossaryTermReferences::isReferenced($glo_ids, $this->term_id)) {
138  if ($this->term_id > 0) {
139  throw new ilGlossaryException("Term ID does not match the glossary.");
140  }
141  $this->term_id = 0;
142  }
143 
144  $this->tax_node = 0;
145  $this->tax_id = $this->glossary->getTaxonomyId();
146  if ($this->tax_id > 0 && $this->glossary->getShowTaxonomy()) {
147  $this->tax = new ilObjTaxonomy($this->tax_id);
148  }
149  $requested_tax_node = $request->getTaxNode();
150  if ($requested_tax_node > 1 && $this->tax->getTree()->readRootId() != $requested_tax_node) {
151  $this->tax_node = $requested_tax_node;
152  }
153 
154  $this->requested_letter = $request->getLetter();
155 
156  $this->content_style_domain = $this->content_style_service->domain()->styleForRefId($this->glossary->getRefId());
157  $this->content_style_gui = $this->content_style_service->gui();
158  }
159 
160  public function injectTemplate(ilGlobalTemplateInterface $tpl): void
161  {
162  $this->tpl = $tpl;
163  }
164 
168  public function setOfflineMode(bool $a_offline = true): void
169  {
170  $this->offline = $a_offline;
171  }
172 
176  public function offlineMode(): bool
177  {
178  return $this->offline;
179  }
180 
181  public function setOfflineDirectory(string $a_dir): void
182  {
183  $this->offline_dir = $a_dir;
184  }
185 
186  public function getOfflineDirectory(): string
187  {
188  return $this->offline_dir;
189  }
190 
194  public function executeCommand(): void
195  {
196  $lng = $this->lng;
197  $ilAccess = $this->access;
198 
199  $lng->loadLanguageModule("content");
200 
201  $next_class = $this->ctrl->getNextClass($this);
202  if ($this->glossary->isActiveFlashcards()) {
203  $cmd = $this->ctrl->getCmd("showFlashcards");
204  } else {
205  $cmd = $this->ctrl->getCmd("listTerms");
206  }
207 
208  // check write permission
209  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id) &&
210  !($ilAccess->checkAccess("visible", "", $this->requested_ref_id) &&
211  ($cmd == "infoScreen" || strtolower($next_class) == "ilinfoscreengui"))) {
212  throw new ilPermissionException($lng->txt("permission_denied"));
213  }
214 
215  if ($cmd != "listDefinitions") {
216  $this->prepareOutput();
217  }
218 
219  switch ($next_class) {
220  case "ilnotegui":
221  $this->setTabs();
222  $ret = $this->listDefinitions();
223  break;
224 
225  case "ilinfoscreengui":
226  $ret = $this->outputInfoScreen();
227  break;
228 
229  case "ilpresentationfullgui":
230  $this->setTabs();
231  $this->showTaxonomy();
232  $full_gui = $this->gui->presentation()
233  ->PresentationFullGUI($this, $this->glossary, $this->offlineMode(), $this->tax_node);
234  $this->ctrl->forwardCommand($full_gui);
235  break;
236 
237  case "ilpresentationtablegui":
238  $this->setTabs();
239  $this->showTaxonomy();
240  $pt_gui = $this->gui->presentation()
241  ->PresentationTableGUI($this, $this->glossary, $this->offlineMode(), $this->tax_node);
242  $this->ctrl->forwardCommand($pt_gui);
243  break;
244 
245  case "ilglossarydefpagegui":
246  $page_gui = new ilGlossaryDefPageGUI($this->requested_def_page_id);
247  $this->basicPageGuiInit($page_gui);
248  $this->ctrl->forwardCommand($page_gui);
249  break;
250 
251  case "ilglossaryflashcardgui":
252  $flash_gui = new ilGlossaryFlashcardGUI();
253  $this->ctrl->forwardCommand($flash_gui);
254  break;
255 
256  case "ilglossaryflashcardboxgui":
257  $flash_box_gui = new ilGlossaryFlashcardBoxGUI();
258  $this->ctrl->forwardCommand($flash_box_gui);
259  break;
260 
261  default:
262  $this->$cmd();
263  break;
264  }
265  $this->tpl->printToStdout();
266  }
267 
268  public function prepareOutput(): void
269  {
270  $this->tpl->loadStandardTemplate();
271  $title = $this->glossary->getTitle();
272 
273  $this->tpl->setTitle($title);
274  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
275 
276  $this->setLocator();
277  }
278 
279 
283  public function basicPageGuiInit(
284  \ilPageObjectGUI $a_page_gui
285  ): void {
286  $a_page_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
287  if (!$this->offlineMode()) {
288  $a_page_gui->setOutputMode("presentation");
289  $this->fill_on_load_code = true;
290  } else {
291  $a_page_gui->setOutputMode("offline");
292  $a_page_gui->setOfflineDirectory($this->getOfflineDirectory());
293  $this->fill_on_load_code = false;
294  }
295  if (!$this->offlineMode()) {
296  $this->ctrl->setParameter($this, "pg_id", $a_page_gui->getId());
297  }
298  $a_page_gui->setFileDownloadLink($this->getLink($this->requested_ref_id, "downloadFile"));
299  $a_page_gui->setFullscreenLink($this->getLink($this->requested_ref_id, "fullscreen"));
300  }
301 
302  public function listTerms(): void
303  {
304  $ilNavigationHistory = $this->nav_history;
305  $ilAccess = $this->access;
306  $lng = $this->lng;
307  $ilToolbar = $this->toolbar;
308  $ilCtrl = $this->ctrl;
309  $ilTabs = $this->tabs_gui;
310 
311  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
312  throw new ilPermissionException($lng->txt("permission_denied"));
313  }
314 
315  $ret = "";
316  if ($this->glossary->getPresentationMode() == "full_def") {
317  $this->listTermByGivenAsPanel();
318  } else {
319  if (!$this->offlineMode()) {
320  $ilNavigationHistory->addItem(
321  $this->requested_ref_id,
322  $this->ctrl->getLinkTarget($this, "listTerms"),
323  "glo"
324  );
325  }
326  $this->listTermByGivenAsTable();
327  }
328  }
329 
333  public function listTermByGivenAsTable(): void
334  {
335  $ilCtrl = $this->ctrl;
336  $ilAccess = $this->access;
337  $lng = $this->lng;
338  $tpl = $this->tpl;
339 
340  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
341  throw new ilPermissionException($lng->txt("permission_denied"));
342  }
343 
344  $ilCtrl->redirectByClass("ilPresentationTableGUI", "show");
345  }
346 
350  public function listTermByGivenAsPanel(): void
351  {
352  $ilCtrl = $this->ctrl;
353 
354  $ilCtrl->redirectByClass("ilPresentationFullGUI", "show");
355  }
356 
357  protected function setContentStyles(): void
358  {
359  $tpl = $this->tpl;
360 
361  if (!$this->offlineMode()) {
362  $this->content_style_gui->addCss($tpl, $this->glossary->getRefId());
363  $tpl->addCss(ilObjStyleSheet::getSyntaxStylePath());
364  } else {
365  $tpl->addCss("content.css");
366  $tpl->addCss("syntaxhighlight.css");
367  }
368  }
369 
374  {
375  $pres_table = $this->gui->presentation()->PresentationTableGUI(
376  $this,
377  $this->glossary,
378  $this->offlineMode(),
379  $this->tax_node
380  );
381  return $pres_table;
382  }
383 
387  public function listDefinitions(
388  int $a_ref_id = 0,
389  int $a_term_id = 0,
390  bool $a_get_html = false,
391  bool $render_term = true,
392  string $a_page_mode = ilPageObjectGUI::PRESENTATION,
393  bool $render_page_container = true
394  ): string {
395  $ilUser = $this->user;
396  $ilAccess = $this->access;
397  $lng = $this->lng;
398  $tpl = $this->tpl;
399 
400  if ($a_ref_id == 0) {
402  } else {
403  $ref_id = $a_ref_id;
404  }
405  if ($a_term_id == 0) {
406  $term_id = $this->term_id;
407  } else {
408  $term_id = $a_term_id;
409  }
410 
411  if (!$ilAccess->checkAccess("read", "", $ref_id)) {
412  throw new ilPermissionException($lng->txt("permission_denied"));
413  }
414 
415  try {
416  $term = new ilGlossaryTerm($term_id);
417  } catch (Exception $e) {
418  return "";
419  }
420 
421  if (!$a_get_html) {
422  $tpl->loadStandardTemplate();
423 
424  $this->setContentStyles();
425 
426  if (!$this->offlineMode()) {
427  $this->setLocator();
428  }
429 
430  $tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
431  $tpl->setTitle($this->lng->txt("cont_term") . ": " . $term->getTerm());
432 
433  // advmd block
434  $cmd = null;
435  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
436  $cmd = array("edit" => $this->ctrl->getLinkTargetByClass(array("ilglossaryeditorgui", "ilobjglossarygui", "ilglossarytermgui", "ilobjectmetadatagui"), ""));
437  }
438  $mdgui = new ilObjectMetaDataGUI($this->glossary, "term", $term->getId());
439  $tpl->setRightContent($mdgui->getBlockHTML($cmd));
440  }
441 
442  $def_tpl = new ilTemplate("tpl.glossary_definition_list.html", true, true, "components/ILIAS/Glossary");
443 
444  if ($render_page_container) {
445  $def_tpl->touchBlock("page_container_1");
446  $def_tpl->touchBlock("page_container_2");
447  }
448 
449  if ($render_term) {
450  $def_tpl->setVariable("TXT_TERM", $term->getTerm());
451  }
452  $this->mobs = array();
453 
454  $page_gui = new ilGlossaryDefPageGUI($term_id);
455  $this->basicPageGuiInit($page_gui);
456  $page_gui->setGlossary($this->glossary);
457  $page_gui->setOutputMode($a_page_mode);
458  $page_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
459  $page = $page_gui->getPageObject();
460 
461  // internal links
462  $page->buildDom();
463 
464  if ($this->offlineMode()) {
465  $page_gui->setOutputMode("offline");
466  $page_gui->setOfflineDirectory($this->getOfflineDirectory());
467  }
468  $page_gui->setFullscreenLink($this->getLink($ref_id, "fullscreen", $term_id));
469 
470  $page_gui->setTemplateOutput(false);
471  $page_gui->setRawPageContent(true);
472  if (!$this->offlineMode()) {
473  $output = $page_gui->showPage();
474  } else {
475  $output = $page_gui->presentation($page_gui->getOutputMode());
476  }
477 
478  $def_tpl->setCurrentBlock("definition");
479  $def_tpl->setVariable("PAGE_CONTENT", $output);
480  $def_tpl->parseCurrentBlock();
481 
482  // display possible backlinks
483  $sources = ilInternalLink::_getSourcesOfTarget('git', $this->term_id, 0);
484 
485  if ($sources) {
486  $backlist_shown = false;
487  foreach ($sources as $src) {
488  $type = explode(':', $src['type']);
489 
490  if ($type[0] == 'lm' && $type[1] == 'pg') {
491  $title = ilLMPageObject::_getPresentationTitle($src['id']);
492  $lm_id = ilLMObject::_lookupContObjID($src['id']);
493  $lm_title = ilObject::_lookupTitle($lm_id);
494  $def_tpl->setCurrentBlock('backlink_item');
495  $ref_ids = ilObject::_getAllReferences($lm_id);
496  $access = false;
497  foreach ($ref_ids as $rid) {
498  if ($ilAccess->checkAccess("read", "", $rid)) {
499  $access = true;
500  }
501  }
502  if ($access) {
503  $def_tpl->setCurrentBlock("backlink_item");
504  $def_tpl->setVariable("BACKLINK_LINK", ILIAS_HTTP_PATH . "/goto.php?target=" . $type[1] . "_" . $src['id']);
505  $def_tpl->setVariable("BACKLINK_ITEM", $lm_title . ": " . $title);
506  $def_tpl->parseCurrentBlock();
507  $backlist_shown = true;
508  }
509  }
510  }
511  if ($backlist_shown) {
512  $def_tpl->setCurrentBlock("backlink_list");
513  $def_tpl->setVariable("BACKLINK_TITLE", $this->lng->txt('glo_term_used_in'));
514  $def_tpl->parseCurrentBlock();
515  }
516  }
517 
518  if (!$a_get_html) {
519  $tpl->setPermanentLink("git", null, $term_id . "_" . $ref_id);
520 
521  // show taxonomy
522  $this->showTaxonomy();
523  }
524 
525  // highlighting?
526  if ($this->requested_search_str != "" && !$this->offlineMode()) {
527  $cache = ilUserSearchCache::_getInstance($ilUser->getId());
528  $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
529  $search_string = $cache->getQuery();
530 
531  $p = new ilQueryParser($search_string);
532  $p->parse();
533 
534  $words = $p->getQuotedWords();
535  foreach ($words as $w) {
536  ilTextHighlighterGUI::highlight("ilGloContent", $w, $tpl);
537  }
538  $this->fill_on_load_code = true;
539  }
540  $tpl->setContent($def_tpl->get());
541  if ($this->offlineMode()) {
542  return $tpl->printToString();
543  } elseif ($a_get_html) {
544  return $def_tpl->get();
545  }
546  return "";
547  }
548 
549  public function fullscreen(): string
550  {
551  $html = $this->media("fullscreen");
552  return $html;
553  }
554 
558  public function media(string $a_mode = "media"): string
559  {
560  $this->tpl = new ilGlobalTemplate("tpl.fullscreen.html", true, true, "components/ILIAS/COPage");
561  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
562  $this->tpl->setVariable(
563  "LOCATION_CONTENT_STYLESHEET",
564  ilObjStyleSheet::getContentStylePath($this->content_style_domain->getEffectiveStyleId())
565  );
566 
567  //$int_links = $page_object->getInternalLinks();
568  $med_links = ilMediaItem::_getMapAreasIntLinks($this->requested_mob_id);
569 
570  // later
571  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
572 
573  $link_xml = "";
574 
575  $media_obj = new ilObjMediaObject($this->requested_mob_id);
576 
577  $xml = "<dummy>";
578  // todo: we get always the first alias now (problem if mob is used multiple
579  // times in page)
580  $xml .= $media_obj->getXML(IL_MODE_ALIAS);
581  $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
582  $xml .= $link_xml;
583  $xml .= "</dummy>";
584 
585  if (!$this->offlineMode()) {
586  $enlarge_path = ilUtil::getImagePath("media/enlarge.svg", false, "output");
587  $wb_path = ilFileUtils::getWebspaceDir("output") . "/";
588  } else {
589  $enlarge_path = "images/media/enlarge.svg";
590  $wb_path = "";
591  }
592 
593  $mode = $a_mode;
594 
595  $this->ctrl->setParameter($this, "obj_type", "MediaObject");
596  $fullscreen_link =
597  $this->getLink($this->requested_ref_id, "fullscreen");
598  $this->ctrl->clearParameters($this);
599 
600  $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path,
601  'link_params' => "ref_id=" . $this->requested_ref_id,'fullscreen_link' => $fullscreen_link,
602  'enable_html_mob' => ilObjMediaObject::isTypeAllowed("html") ? "y" : "n",
603  'ref_id' => $this->requested_ref_id, 'pg_frame' => "", 'webspace_path' => $wb_path);
604  $output = $this->xsl->process($xml, $params);
605 
606  // unmask user html
607  $this->tpl->setVariable("MEDIA_CONTENT", $output);
608 
609  $this->tpl->parseCurrentBlock();
610  if ($this->offlineMode()) {
611  $html = $this->tpl->get();
612  return $html;
613  }
614  return "";
615  }
616 
620  public function showDownloadList(): void
621  {
622  $ilAccess = $this->access;
623  $lng = $this->lng;
624  $ilTabs = $this->tabs_gui;
625 
626  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
627  throw new ilPermissionException($lng->txt("permission_denied"));
628  }
629 
630  $this->setTabs();
631  $ilTabs->activateTab("download");
632 
633  // set title header
634  $this->tpl->setTitle($this->glossary->getTitle());
635  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
636 
637  $table = $this->domain->table()->getDownloadListTable($this->glossary)->getComponent();
638 
639  $this->tpl->setContent($this->ui_ren->render($table));
640  }
641 
645  public function downloadExportFile(): void
646  {
647  $ilAccess = $this->access;
648  $lng = $this->lng;
649 
650  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
651  throw new ilPermissionException($lng->txt("permission_denied"));
652  }
653 
654  $file_type = "";
655  if (($this->requested_table_glossary_download_list_action == "downloadExportFile")
656  && !empty($this->requested_table_glossary_download_file_ids)) {
657  $file_id = $this->requested_table_glossary_download_file_ids[0];
658  $file_type = explode(":", $file_id)[0];
659  }
660 
661  $file = $this->glossary->getPublicExportFile($file_type);
662  if ($file != "") {
663  $dir = $this->glossary->getExportDirectory($file_type);
664  if (is_file($dir . "/" . $file)) {
665  ilFileDelivery::deliverFileLegacy($dir . "/" . $file, $file);
666  exit;
667  }
668  }
669  throw new ilGlossaryException($lng->txt("file_not_found"));
670  }
671 
672  public function setLocator(): void
673  {
674  $gloss_loc = new ilGlossaryLocatorGUI();
675  $gloss_loc->setMode("presentation");
676  if (!empty($this->term_id)) {
677  $term = new ilGlossaryTerm($this->term_id);
678  $gloss_loc->setTerm($term);
679  }
680  $gloss_loc->setGlossary($this->glossary);
681  $gloss_loc->display();
682  }
683 
684  public function downloadFile(): void
685  {
686  $ilAccess = $this->access;
687  $lng = $this->lng;
688 
689  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
690  throw new ilPermissionException($lng->txt("permission_denied"));
691  }
692 
693  $file = explode("_", $this->requested_file_id);
694  $fileObj = new ilObjFile($file[count($file) - 1], false);
695  $fileObj->sendFile();
696  exit;
697  }
698 
699  public function setTabs(): void
700  {
701  $this->getTabs();
702  }
703 
704  public function getLink(
705  int $a_ref_id,
706  string $a_cmd = "",
707  int $a_term_id = 0,
708  string $a_frame = "",
709  string $a_type = ""
710  ): string {
711  $link = "";
712  if ($a_cmd == "") {
713  $a_cmd = "layout";
714  }
715  //$script = "glossary_presentation.php";
716 
717  // handle online links
718  if (!$this->offlineMode()) {
719  //$link = $script."?ref_id=".$a_ref_id;
720  switch ($a_cmd) {
721  case "fullscreen":
722  $this->ctrl->setParameter($this, "term_id", $a_term_id);
723  $link = $this->ctrl->getLinkTarget($this, "fullscreen");
724  break;
725 
726  default:
727  $link .= "&amp;cmd=" . $a_cmd;
728  if ($a_frame != "") {
729  $this->ctrl->setParameter($this, "frame", $a_frame);
730  }
731  if ($a_type != "") {
732  $this->ctrl->setParameter($this, "obj_type", $a_type);
733  }
734  $link = $this->ctrl->getLinkTarget($this, $a_cmd);
735  break;
736  }
737  } else { // handle offline links
738  switch ($a_cmd) {
739  case "fullscreen":
740  $link = "fullscreen.html"; // id is handled by xslt
741  break;
742 
743  case "glossary":
744  $link = "term_" . $a_term_id . ".html";
745  break;
746 
747  case "downloadFile":
748  case "layout":
749  default:
750  break;
751  }
752  }
753  $this->ctrl->clearParameters($this);
754  return $link;
755  }
756 
757  public function printViewSelection(): void
758  {
759  $ilCtrl = $this->ctrl;
760  $tpl = $this->tpl;
761  $ilTabs = $this->tabs_gui;
762 
763  $this->setTabs();
764  $ilTabs->activateTab("print_view");
765 
767 
768  $tpl->setContent($this->form->getHTML());
769  }
770 
774  public function initPrintViewSelectionForm(): void
775  {
776  $lng = $this->lng;
777  $ilCtrl = $this->ctrl;
778 
779  $terms = $this->glossary->getTermList();
780 
781  $this->form = new ilPropertyFormGUI();
782  //$this->form->setTarget("print_view");
783  $this->form->setFormAction($ilCtrl->getFormAction($this));
784 
785  // selection type
786  $radg = new ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
787  $radg->setValue("glossary");
788 
789  // whole glossary
790  $op1 = new ilRadioOption($lng->txt("cont_whole_glossary")
791  . " (" . $lng->txt("cont_terms") . ": " . count($terms) . ")", "glossary");
792  $radg->addOption($op1);
793 
794  // selected topic
795  if (($t_id = $this->glossary->getTaxonomyId()) > 0 && $this->glossary->getShowTaxonomy()) {
796  $op3 = new ilRadioOption($lng->txt("cont_selected_topic"), "sel_topic");
797  $radg->addOption($op3);
798 
799  // topic drop down
800  $si = new ilTaxAssignInputGUI(
801  $t_id,
802  false,
803  $lng->txt("cont_topic"),
804  "topic",
805  false
806  );
807  if ($this->tax_node > 0) {
808  $si->setValue($this->tax_node);
809  }
810  $op3->addSubItem($si);
811  }
812 
813  // selected terms
814  $op2 = new ilRadioOption($lng->txt("cont_selected_terms"), "selection");
815  $radg->addOption($op2);
816 
817  $nl = new ilNestedListInputGUI("", "obj_id");
818  $op2->addSubItem($nl);
819  foreach ($terms as $t) {
820  $nl->addListNode((string) $t["id"], (string) $t["term"], "0", false, false);
821  }
822 
823  $this->form->addItem($radg);
824 
825  $this->form->addCommandButton("printView", $lng->txt("cont_show_print_view"));
826  $this->form->setPreventDoubleSubmission(false);
827 
828  $this->form->setTitle($lng->txt("cont_print_selection"));
829  }
830 
831  public function printView(): void
832  {
833  $ilAccess = $this->access;
834  $tpl = $this->tpl;
835 
836  $this->tabs_gui->setBackTarget(
837  $this->lng->txt("back"),
838  $this->ctrl->getLinkTarget($this, "printViewSelection")
839  );
840 
841  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
842  return;
843  }
844 
846  $this->form->checkInput();
847 
848  $terms = array();
849  switch ($this->form->getInput("sel_type")) {
850  case "glossary":
851  $ts = $this->glossary->getTermList();
852  foreach ($ts as $t) {
853  $terms[] = $t["id"];
854  }
855  break;
856 
857  case "sel_topic":
858  $t_id = $this->glossary->getTaxonomyId();
859  $items = ilObjTaxonomy::getSubTreeItems("glo", $this->glossary->getId(), "term", $t_id, (int) $this->form->getInput("topic"));
860  foreach ($items as $i) {
861  if ($i["item_type"] == "term") {
862  $terms[] = $i["item_id"];
863  }
864  }
865  break;
866 
867  case "selection":
868  $terms = $this->form->getInput("obj_id");
869  break;
870  }
871 
872  //$tpl->addCss(ilObjStyleSheet::getContentPrintStyle());
873  $tpl->addOnLoadCode("il.Util.print();");
874 
875  // determine target frames for internal links
876 
877  $page_content = "";
878  foreach ($terms as $t_id) {
879  $page_content .= $this->listDefinitions($this->requested_ref_id, $t_id, true, true, ilPageObjectGUI::PRINTING);
880  }
881  $tpl->setContent($page_content);
882  }
883 
884  public function getTabs(): void
885  {
886  $ilAccess = $this->access;
887  $lng = $this->lng;
888  $ilCtrl = $this->ctrl;
889  $ilHelp = $this->help;
890 
891  $ilHelp->setScreenIdComponent("glo");
892 
893  if (!$this->offlineMode()) {
894  if ($this->ctrl->getCmd() != "listDefinitions") {
895  if ($ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
896  if ($this->glossary->isActiveFlashcards()) {
897  $this->tabs_gui->addTab(
898  "flashcards",
899  $lng->txt("glo_flashcards"),
900  $ilCtrl->getLinkTarget($this, "showFlashcards")
901  );
902  }
903  $this->tabs_gui->addTab(
904  "terms",
905  $lng->txt("content"),
906  $ilCtrl->getLinkTarget($this, "listTerms")
907  );
908  }
909 
910  $this->tabs_gui->addTab(
911  "info",
912  $lng->txt("info_short"),
913  $ilCtrl->getLinkTarget($this, "infoScreen")
914  );
915 
916 
917  // glossary menu
918  if ($ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
919  $this->tabs_gui->addTab(
920  "print_view",
921  $lng->txt("cont_print_view"),
922  $ilCtrl->getLinkTarget($this, "printViewSelection")
923  );
924 
925  // download links
926  if ($this->glossary->isActiveDownloads()) {
927  $this->tabs_gui->addTab(
928  "download",
929  $lng->txt("download"),
930  $ilCtrl->getLinkTarget($this, "showDownloadList")
931  );
932  }
933  //}
934  }
935 
936  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id) ||
937  $ilAccess->checkAccess("edit_content", "", $this->requested_ref_id)) {
938  $this->tabs_gui->addNonTabbedLink(
939  "editing_view",
940  $lng->txt("glo_editing_view"),
941  "ilias.php?baseClass=ilGlossaryEditorGUI&amp;ref_id=" . $this->requested_ref_id
942  );
943  }
944  }
945  } else {
946  $this->tabs_gui->addTarget(
947  "cont_back",
948  "index.html#term_" . $this->term_id,
949  "",
950  ""
951  );
952  }
953  }
954 
958  public function infoScreen(): void
959  {
960  $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
961  }
962 
963  public function outputInfoScreen(): string
964  {
965  $ilAccess = $this->access;
966  $ilTabs = $this->tabs_gui;
967 
968  $this->setTabs();
969  $ilTabs->activateTab("info");
970  $this->lng->loadLanguageModule("meta");
971 
972  $info = new ilInfoScreenGUI($this->glossary_gui);
973  $info->enablePrivateNotes();
974  //$info->enableLearningProgress();
975 
976  $info->enableNews();
977  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
978  $info->enableNewsEditing();
979  $news_set = new ilSetting("news");
980  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
981  if ($enable_internal_rss) {
982  $info->setBlockProperty("news", "settings", true);
983  }
984  }
985 
986  // show standard meta data section
987  $info->addMetaDataSections($this->glossary->getId(), 0, $this->glossary->getType());
988 
989  ilObjGlossaryGUI::addUsagesToInfo($info, $this->glossary->getId());
990 
991  if ($this->offlineMode()) {
992  $this->tpl->setContent($info->getHTML());
993  return $this->tpl->get();
994  } else {
995  // forward the command
996  $this->ctrl->forwardCommand($info);
997  }
998  return "";
999  }
1000 
1001  public function showTaxonomy(): void
1002  {
1003  $ctrl = $this->ctrl;
1004 
1005  if ($this->offlineMode() || !$this->tax_manager->showInPresentation()) {
1006  return;
1007  }
1008 
1009  $tax_id = $this->tax_manager->getTaxonomyId();
1010 
1011  $tool_context = $this->global_screen->tool()->context()->current();
1012 
1013  $tool_context->addAdditionalData(
1015  true
1016  );
1017  $tool_context->addAdditionalData(
1019  [self::class]
1020  );
1021  $tool_context->addAdditionalData(
1023  $tax_id
1024  );
1025  $tool_context->addAdditionalData(
1027  "listTerms"
1028  );
1029  $tool_context->addAdditionalData(
1031  "showTaxonomy"
1032  );
1033  }
1034 
1035  public function showFlashcards(): void
1036  {
1037  $ilTabs = $this->tabs_gui;
1038  $ilNavigationHistory = $this->nav_history;
1039 
1040  $this->setTabs();
1041  $ilTabs->activateTab("flashcards");
1042  $ilNavigationHistory->addItem(
1043  $this->requested_ref_id,
1044  $this->ctrl->getLinkTarget($this, "showFlashcards"),
1045  "glo"
1046  );
1047  $flashcards = new ilGlossaryFlashcardGUI();
1048  $flashcards->listBoxes();
1049  }
1050 }
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
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
This class represents an option in a radio group.
Class ilObjectMetaDataGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
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:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstance(int $a_usr_id)
static _getAllReferences(int $id)
get all reference ids for object ID
Class ilPageObjectGUI.
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)
setStyleId(int $a_styleid)
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
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
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:65
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.
ILIAS Glossary InternalGUIService $gui
Class ilObjFile.
global $DIC
Definition: shib_login.php:22
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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...
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
This class represents a (nested) list of checkboxes (could be extended for radio items, too)
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.
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$service
Definition: ltiservices.php:40
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)
static _lookGlossaryID(int $term_id)
get glossary id form term id