ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilGlossaryPresentationGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
6
14{
18 protected $ctrl;
19
23 protected $tabs_gui;
24
28 protected $access;
29
33 protected $error;
34
38 protected $nav_history;
39
43 protected $toolbar;
44
48 protected $user;
49
53 protected $help;
54
58 protected $glossary;
59
63 protected $glossary_gui;
64
68 protected $tpl;
69
73 protected $lng;
74
78 protected $tax_node;
79
83 protected $tax_id;
84
88 protected $tax;
89
90
94 protected $service;
95
99 protected $term_id;
100
105
110
115
120
125
130
135
136
141 public function __construct($export_format = "", $export_dir = "")
142 {
143 global $DIC;
144
145 $this->export_format = $export_format;
146 $this->setOfflineDirectory($export_dir);
147 $this->offline = ($export_format != "");
148 $this->access = $DIC->access();
149 $this->error = $DIC["ilErr"];
150 $this->nav_history = $DIC["ilNavigationHistory"];
151 $this->toolbar = $DIC->toolbar();
152 $this->user = $DIC->user();
153 $this->help = $DIC["ilHelp"];
154 $lng = $DIC->language();
155 $tpl = $DIC->ui()->mainTemplate();
156 $ilCtrl = $DIC->ctrl();
157 $ilTabs = $DIC->tabs();
158
159 $this->tabs_gui = $ilTabs;
160 $this->tpl = $tpl;
161 $this->lng = $lng;
162 $this->ctrl = $ilCtrl;
163 $this->ctrl->saveParameter($this, array("ref_id", "letter", "tax_node"));
164
165 // note: using $DIC->http()->request()->getQueryParams() here will
166 // fail, since the goto magic currently relies on setting $_GET
167 $this->initByRequest($_GET);
168 }
169
179 public function initByRequest(array $query_params)
180 {
181 $this->service = new Presentation\GlossaryPresentationService(
182 $this->user,
183 $query_params,
184 $this->offline
185 );
186
187 $request = $this->service->getRequest();
188
189 $this->requested_ref_id = $request->getRequestedRefId();
190 $this->term_id = $request->getRequestedTermId();
191 $this->glossary_gui = $this->service->getGlossaryGUI();
192 $this->glossary = $this->service->getGlossary();
193 $this->requested_def_page_id = $request->getRequestedDefinitionPageId();
194 $this->requested_search_str = $request->getRequestedSearchString();
195 $this->requested_file_id = $request->getRequestedFileId();
196 $this->requested_mob_id = $request->getRequestedMobId();
197 $this->requested_export_type = (string) $query_params["type"];
198
199
200 // determine term id and check whether it is valid (belongs to
201 // current glossary or a virtual (online) sub-glossary)
202 $glo_ids = $this->glossary->getAllGlossaryIds();
203 if (!is_array($glo_ids)) {
204 $glo_ids = array($glo_ids);
205 }
206 $term_glo_id = ilGlossaryTerm::_lookGlossaryID($this->term_id);
207 if (!in_array($term_glo_id, $glo_ids) && !ilGlossaryTermReferences::isReferenced($glo_ids, $this->term_id)) {
208 if ((int) $this->term_id > 0) {
209 throw new ilGlossaryException("Term ID does not match the glossary.");
210 }
211 $this->term_id = 0;
212 }
213
214 $this->tax_node = 0;
215 $this->tax_id = $this->glossary->getTaxonomyId();
216 if ($this->tax_id > 0 && $this->glossary->getShowTaxonomy()) {
217 $this->tax = new ilObjTaxonomy($this->tax_id);
218 }
219 $requested_tax_node = $request->getRequestedTaxNode();
220 if ((int) $requested_tax_node > 1 && $this->tax->getTree()->readRootId() != $requested_tax_node) {
221 $this->tax_node = $requested_tax_node;
222 }
223
224 $this->requested_letter = $request->getRequestedLetter();
225 }
226
230 public function injectTemplate($tpl)
231 {
232 $this->tpl = $tpl;
233 }
234
238 public function setOfflineMode($a_offline = true)
239 {
240 $this->offline = $a_offline;
241 }
242
246 public function offlineMode()
247 {
248 return $this->offline;
249 }
250
254 public function setOfflineDirectory($a_dir)
255 {
256 $this->offline_dir = $a_dir;
257 }
258
259
263 public function getOfflineDirectory()
264 {
265 return $this->offline_dir;
266 }
267
268
272 public function executeCommand()
273 {
275 $ilAccess = $this->access;
277
278 $lng->loadLanguageModule("content");
279
280 $next_class = $this->ctrl->getNextClass($this);
281 $cmd = $this->ctrl->getCmd("listTerms");
282
283 // check write permission
284 if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id) &&
285 !($ilAccess->checkAccess("visible", "", $this->requested_ref_id) &&
286 ($cmd == "infoScreen" || strtolower($next_class) == "ilinfoscreengui"))) {
287 $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->MESSAGE);
288 }
289
290 if ($cmd != "listDefinitions") {
291 $this->prepareOutput();
292 }
293
294 switch ($next_class) {
295 case "ilnotegui":
296 $this->setTabs();
297 $ret = $this->listDefinitions();
298 break;
299
300 case "ilinfoscreengui":
301 $ret = $this->outputInfoScreen();
302 break;
303
304 case "ilpresentationlisttablegui":
305 $prtab = $this->getPresentationTable();
306 $this->ctrl->forwardCommand($prtab);
307 return;
308 break;
309
310 case "ilglossarydefpagegui":
311 $page_gui = new ilGlossaryDefPageGUI($this->requested_def_page_id);
312 $this->basicPageGuiInit($page_gui);
313 $this->ctrl->forwardCommand($page_gui);
314 break;
315
316 default:
317 $ret = $this->$cmd();
318 break;
319 }
320 $this->tpl->printToStdout();
321 }
322
323 public function prepareOutput()
324 {
325 $this->tpl->loadStandardTemplate();
326 $title = $this->glossary->getTitle();
327
328 $this->tpl->setTitle($title);
329 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
330
331 $this->setLocator();
332 }
333
334
341 public function basicPageGuiInit(\ilPageObjectGUI $a_page_gui)
342 {
344 $this->glossary->getStyleSheetId(),
345 "glo"
346 ));
347 if (!$this->offlineMode()) {
348 $a_page_gui->setOutputMode("presentation");
349 $this->fill_on_load_code = true;
350 } else {
351 $a_page_gui->setOutputMode("offline");
352 $a_page_gui->setOfflineDirectory($this->getOfflineDirectory());
353 $this->fill_on_load_code = false;
354 }
355 if (!$this->offlineMode()) {
356 $this->ctrl->setParameter($this, "pg_id", $a_page_gui->getId());
357 }
358 $a_page_gui->setFileDownloadLink($this->getLink($this->requested_ref_id, "downloadFile"));
359 $a_page_gui->setFullscreenLink($this->getLink($this->requested_ref_id, "fullscreen"));
360 }
361
365 public function listTerms()
366 {
367 $ilNavigationHistory = $this->nav_history;
368 $ilAccess = $this->access;
370 $ilToolbar = $this->toolbar;
371 $ilCtrl = $this->ctrl;
372 $ilTabs = $this->tabs_gui;
374
375
376 if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
377 $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->MESSAGE);
378 }
379
380 if (!$this->offlineMode()) {
381 $ilNavigationHistory->addItem(
382 $this->requested_ref_id,
383 $this->ctrl->getLinkTarget($this, "listTerms"),
384 "glo"
385 );
386
387 // alphabetical navigation
388 $ai = new ilAlphabetInputGUI($lng->txt("glo_quick_navigation"), "first");
389
390 $ai->setFixDBUmlauts(true);
391
392 $first_letters = $this->glossary->getFirstLetters($this->tax_node);
393 if (!is_array($first_letters)) {
394 $first_letters = [];
395 }
396 if (!in_array($this->requested_letter, $first_letters)) {
397 $first_letters[] = ilUtil::stripSlashes($this->requested_letter);
398 }
399 $ai->setLetters($first_letters);
400
401 $ai->setParentCommand($this, "chooseLetter");
402 $ai->setHighlighted($this->requested_letter);
403 $ilToolbar->addInputItem($ai, true);
404 }
405
406 $ret = $this->listTermByGiven();
407 $ilCtrl->setParameter($this, "term_id", "");
408
409 $ilTabs->activateTab("terms");
410
411 // show taxonomy
412 $this->showTaxonomy();
413
414 $this->tpl->setPermanentLink("glo", $this->glossary->getRefId());
415
416 return $ret;
417 }
418
422 public function listTermByGiven()
423 {
424 $ilCtrl = $this->ctrl;
425 $ilAccess = $this->access;
428
429 if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
430 $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->MESSAGE);
431 }
432
433 $this->lng->loadLanguageModule("meta");
434
435 $this->setTabs();
436
437 // load template for table
438 // $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
439
440 if ($this->glossary->getPresentationMode() == "full_def") {
441 $this->setContentStyles();
442 }
443
444 $table = $this->getPresentationTable();
445
446 if (!$this->offlineMode()) {
447 $tpl->setContent($ilCtrl->getHTML($table));
448 } else {
449 $this->tpl->setVariable("ADM_CONTENT", $table->getHTML());
450 return $this->tpl->printToString();
451 }
452 }
453
457 protected function setContentStyles()
458 {
460
461 if (!$this->offlineMode()) {
463 $this->glossary->getStyleSheetId(),
464 "glo"
465 )));
467 } else {
468 $tpl->addCss("content.css");
469 $tpl->addCss("syntaxhighlight.css");
470 }
471 }
472
479 public function getPresentationTable()
480 {
481 $table = new ilPresentationListTableGUI(
482 $this,
483 "listTerms",
484 $this->glossary,
485 $this->offlineMode(),
486 $this->tax_node,
487 $this->glossary->getTaxonomyId()
488 );
489 return $table;
490 }
491
495 public function applyFilter()
496 {
497 $ilTabs = $this->tabs_gui;
498
499 $prtab = $this->getPresentationTable();
500 $prtab->resetOffset();
501 $prtab->writeFilterToSession();
502 $this->listTerms();
503 }
504
509 public function resetFilter()
510 {
511 $prtab = $this->getPresentationTable();
512 $prtab->resetOffset();
513 $prtab->resetFilter();
514 $this->listTerms();
515 }
516
520 public function listDefinitions($a_ref_id = 0, $a_term_id = 0, $a_get_html = false, $a_page_mode = ilPageObjectGUI::PRESENTATION)
521 {
523 $ilAccess = $this->access;
527
528 if ($a_ref_id == 0) {
529 $ref_id = (int) $this->requested_ref_id;
530 } else {
531 $ref_id = $a_ref_id;
532 }
533 if ($a_term_id == 0) {
535 } else {
536 $term_id = $a_term_id;
537 }
538
539 if (!$ilAccess->checkAccess("read", "", $ref_id)) {
540 $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->MESSAGE);
541 }
542
543 // tabs
544 if ($this->glossary->getPresentationMode() != "full_def" &&
545 $a_page_mode != ilPageObjectGUI::PRINTING) {
546 $this->showDefinitionTabs("term_content");
547 }
548
549 $term = new ilGlossaryTerm($term_id);
550
551 if (!$a_get_html) {
552 $tpl->loadStandardTemplate();
553
554 $this->setContentStyles();
555
556 if (!$this->offlineMode()) {
557 $this->setLocator();
558 }
559
560 $tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
561 $tpl->setTitle($this->lng->txt("cont_term") . ": " . $term->getTerm());
562
563 // advmd block
564 $cmd = null;
565 if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
566 $cmd = array("edit" => $this->ctrl->getLinkTargetByClass(array("ilglossaryeditorgui", "ilobjglossarygui", "ilglossarytermgui", "ilobjectmetadatagui"), ""));
567 }
568 $mdgui = new ilObjectMetaDataGUI($this->glossary, "term", $term->getId());
569 $tpl->setRightContent($mdgui->getBlockHTML($cmd));
570 }
571
572 $def_tpl = new ilTemplate("tpl.glossary_definition_list.html", true, true, "Modules/Glossary");
573
575 $def_tpl->setVariable("TXT_TERM", $term->getTerm());
576 $this->mobs = array();
577
578 // toc
579 if (count($defs) > 1 && $a_page_mode == ilPageObjectGUI::PRESENTATION) {
580 $def_tpl->setCurrentBlock("toc");
581 for ($j = 1; $j <= count($defs); $j++) {
582 $def_tpl->setCurrentBlock("toc_item");
583 $def_tpl->setVariable("TOC_DEF_NR", $j);
584 $def_tpl->setVariable("TOC_DEF", $lng->txt("cont_definition"));
585 $def_tpl->parseCurrentBlock();
586 }
587 $def_tpl->setCurrentBlock("toc");
588 $def_tpl->parseCurrentBlock();
589 }
590
591 for ($j = 0; $j < count($defs); $j++) {
592 $def = $defs[$j];
593 $page_gui = new ilGlossaryDefPageGUI($def["id"]);
594 $this->basicPageGuiInit($page_gui);
595 $page_gui->setGlossary($this->glossary);
596 $page_gui->setOutputMode($a_page_mode);
597 $page_gui->setStyleId($this->glossary->getStyleSheetId());
598 $page = $page_gui->getPageObject();
599
600 // internal links
601 $page->buildDom();
602
603 if ($this->offlineMode()) {
604 $page_gui->setOutputMode("offline");
605 $page_gui->setOfflineDirectory($this->getOfflineDirectory());
606 }
607 $page_gui->setFullscreenLink($this->getLink($ref_id, "fullscreen", $term_id, $def["id"]));
608
609 $page_gui->setTemplateOutput(false);
610 $page_gui->setRawPageContent(true);
611 if (!$this->offlineMode()) {
612 $output = $page_gui->showPage();
613 } else {
614 $output = $page_gui->presentation($page_gui->getOutputMode());
615 }
616
617 if (count($defs) > 1) {
618 $def_tpl->setCurrentBlock("definition_header");
619 $def_tpl->setVariable(
620 "TXT_DEFINITION",
621 $this->lng->txt("cont_definition") . " " . ($j + 1)
622 );
623 $def_tpl->setVariable("DEF_NR", ($j + 1));
624 $def_tpl->parseCurrentBlock();
625 }
626
627 $def_tpl->setCurrentBlock("definition");
628 $def_tpl->setVariable("PAGE_CONTENT", $output);
629 $def_tpl->parseCurrentBlock();
630 }
631
632 // display possible backlinks
633 $sources = ilInternalLink::_getSourcesOfTarget('git', $this->term_id, 0);
634
635 if ($sources) {
636 $backlist_shown = false;
637 foreach ($sources as $src) {
638 $type = explode(':', $src['type']);
639
640 if ($type[0] == 'lm') {
641 if ($type[1] == 'pg') {
642 $title = ilLMPageObject::_getPresentationTitle($src['id']);
643 $lm_id = ilLMObject::_lookupContObjID($src['id']);
644 $lm_title = ilObject::_lookupTitle($lm_id);
645 $def_tpl->setCurrentBlock('backlink_item');
646 $ref_ids = ilObject::_getAllReferences($lm_id);
647 $access = false;
648 foreach ($ref_ids as $rid) {
649 if ($ilAccess->checkAccess("read", "", $rid)) {
650 $access = true;
651 }
652 }
653 if ($access) {
654 $def_tpl->setCurrentBlock("backlink_item");
655 $def_tpl->setVariable("BACKLINK_LINK", ILIAS_HTTP_PATH . "/goto.php?target=" . $type[1] . "_" . $src['id']);
656 $def_tpl->setVariable("BACKLINK_ITEM", $lm_title . ": " . $title);
657 $def_tpl->parseCurrentBlock();
658 $backlist_shown = true;
659 }
660 }
661 }
662 }
663 if ($backlist_shown) {
664 $def_tpl->setCurrentBlock("backlink_list");
665 $def_tpl->setVariable("BACKLINK_TITLE", $this->lng->txt('glo_term_used_in'));
666 $def_tpl->parseCurrentBlock();
667 }
668 }
669
670 if (!$a_get_html) {
671 $tpl->setPermanentLink("git", "", $term_id . "_" . $ref_id);
672
673 // show taxonomy
674 $this->showTaxonomy();
675 }
676
677 // highlighting?
678 if ($this->requested_search_str != "" && !$this->offlineMode()) {
679 $cache = ilUserSearchCache::_getInstance($ilUser->getId());
680 $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
681 $search_string = $cache->getQuery();
682
683 $p = new ilQueryParser($search_string);
684 $p->parse();
685
686 $words = $p->getQuotedWords();
687 if (is_array($words)) {
688 foreach ($words as $w) {
689 ilTextHighlighterGUI::highlight("ilGloContent", $w, $tpl);
690 }
691 }
692 $this->fill_on_load_code = true;
693 }
694 $tpl->setContent($def_tpl->get());
695 if ($this->offlineMode()) {
696 return $tpl->printToString();
697 } elseif ($a_get_html) {
698 return $def_tpl->get();
699 }
700 }
701
708 public function showDefinitionTabs($a_act)
709 {
710 $ilTabs = $this->tabs_gui;
712 $ilCtrl = $this->ctrl;
713 $ilHelp = $this->help;
714
715 if (!$this->offlineMode()) {
716 $ilHelp->setScreenIdComponent("glo");
717
718 $ilCtrl->setParameter($this, "term_id", "");
719 $back = $ilCtrl->getLinkTarget($this, "listTerms");
720 $ilCtrl->setParameter($this, "term_id", $this->term_id);
721 $ilCtrl->saveParameter($this, "term_id");
722
723 $ilTabs->setBackTarget($this->lng->txt("obj_glo"), $back);
724
725 $ilTabs->addTab(
726 "term_content",
727 $lng->txt("content"),
728 $ilCtrl->getLinkTarget($this, "listDefinitions")
729 );
730
731 $ilTabs->addTab(
732 "print_view",
733 $lng->txt("print_view"),
734 $ilCtrl->getLinkTarget($this, "printViewSelection")
735 );
736
737 $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $this->term_id);
738 if (ilGlossaryTerm::_lookGlossaryID($this->term_id) == $this->glossary->getId()) {
739 if ($this->access->checkAccess("write", "", (int) $this->requested_ref_id) ||
740 $this->access->checkAccess("edit_content", "", (int) $this->requested_ref_id)) {
741 $ilTabs->addNonTabbedLink(
742 "editing_view",
743 $lng->txt("glo_editing_view"),
744 $ilCtrl->getLinkTargetByClass(array("ilglossaryeditorgui",
745 "ilobjglossarygui",
746 "ilglossarytermgui"
747 ), "listDefinitions")
748 );
749 }
750 //"ilias.php?baseClass=ilGlossaryEditorGUI&amp;ref_id=".$this->requested_ref_id."&amp;edit_term=".$this->term_id);
751 }
752 $ilTabs->activateTab($a_act);
753 }
754 }
755
756
760 public function fullscreen()
761 {
762 $html = $this->media("fullscreen");
763 return $html;
764 }
765
769 public function media($a_mode = "media")
770 {
771 $this->tpl = new ilGlobalTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
772 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
773 $this->tpl->setVariable(
774 "LOCATION_CONTENT_STYLESHEET",
775 ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId())
776 );
777
778 //$int_links = $page_object->getInternalLinks();
779 $med_links = ilMediaItem::_getMapAreasIntLinks($this->requested_mob_id);
780
781 // later
782 //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
783
784 $link_xlm = "";
785
786 $media_obj = new ilObjMediaObject($this->requested_mob_id);
787
788 $xml = "<dummy>";
789 // todo: we get always the first alias now (problem if mob is used multiple
790 // times in page)
791 $xml .= $media_obj->getXML(IL_MODE_ALIAS);
792 $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
793 $xml .= $link_xml;
794 $xml .= "</dummy>";
795
796 $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
797 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
798 $xh = xslt_create();
799
800 if (!$this->offlineMode()) {
801 $enlarge_path = ilUtil::getImagePath("enlarge.svg", false, "output");
802 $wb_path = ilUtil::getWebspaceDir("output") . "/";
803 } else {
804 $enlarge_path = "images/enlarge.svg";
805 $wb_path = "";
806 }
807
808 $mode = $a_mode;
809
810 $this->ctrl->setParameter($this, "obj_type", "MediaObject");
811 $fullscreen_link =
812 $this->getLink($this->requested_ref_id, "fullscreen");
813 $this->ctrl->clearParameters($this);
814
815 $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path,
816 'link_params' => "ref_id=" . $this->requested_ref_id,'fullscreen_link' => $fullscreen_link,
817 'enable_html_mob' => ilObjMediaObject::isTypeAllowed("html") ? "y" : "n",
818 'ref_id' => $this->requested_ref_id, 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
819 $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, $params);
820 echo xslt_error($xh);
821 xslt_free($xh);
822
823 // unmask user html
824 $this->tpl->setVariable("MEDIA_CONTENT", $output);
825
826 $this->tpl->parseCurrentBlock();
827 if ($this->offlineMode()) {
828 $html = $this->tpl->get();
829 return $html;
830 }
831 }
832
836 public function showDownloadList()
837 {
838 $ilAccess = $this->access;
840 $ilTabs = $this->tabs_gui;
841
842 if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
843 $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->MESSAGE);
844 }
845
846 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.glo_download_list.html", "Modules/Glossary");
847
848 $this->setTabs();
849 $ilTabs->activateTab("download");
850
851 // set title header
852 $this->tpl->setTitle($this->glossary->getTitle());
853 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
854
855 // create table
856 $tbl = new ilTableGUI();
857
858 // load files templates
859 $this->tpl->addBlockfile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
860
861 // load template for table content data
862 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", "Modules/Glossary");
863
864 $export_files = array();
865 $types = array("xml", "html");
866 foreach ($types as $type) {
867 if ($this->glossary->getPublicExportFile($type) != "") {
868 $dir = $this->glossary->getExportDirectory($type);
869 if (is_file($this->glossary->getExportDirectory($type) . "/" .
870 $this->glossary->getPublicExportFile($type))) {
871 $size = filesize($this->glossary->getExportDirectory($type) . "/" .
872 $this->glossary->getPublicExportFile($type));
873 $export_files[] = array("type" => $type,
874 "file" => $this->glossary->getPublicExportFile($type),
875 "size" => $size);
876 }
877 }
878 }
879
880 $num = 0;
881
882 $tbl->setTitle($this->lng->txt("download"));
883
884 $tbl->setHeaderNames(array($this->lng->txt("cont_format"),
885 $this->lng->txt("cont_file"),
886 $this->lng->txt("size"), $this->lng->txt("date"),
887 ""));
888
889 $cols = array("format", "file", "size", "date", "download");
890 $header_params = array("ref_id" => $this->requested_ref_id,
891 "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
892 $tbl->setHeaderVars($cols, $header_params);
893 $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
894 $tbl->disable("sort");
895 // footer
896 $tbl->disable("footer");
897 $tbl->setMaxCount(count($export_files));
898
899 $tbl->render();
900 if (count($export_files) > 0) {
901 $i = 0;
902 foreach ($export_files as $exp_file) {
903 $this->tpl->setCurrentBlock("tbl_content");
904 $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
905
906 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
907 $this->tpl->setVariable("CSS_ROW", $css_row);
908
909 $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
910 $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
911 $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"] . ":" . $exp_file["file"]);
912
913 $file_arr = explode("__", $exp_file["file"]);
914 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s", $file_arr[0]));
915
916 $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
917 $this->ctrl->setParameter($this, "type", $exp_file["type"]);
918 $this->tpl->setVariable(
919 "LINK_DOWNLOAD",
920 $this->ctrl->getLinkTarget($this, "downloadExportFile")
921 );
922
923 $this->tpl->parseCurrentBlock();
924 }
925 } //if is_array
926 else {
927 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
928 $this->tpl->setVariable("NUM_COLS", 5);
929 $this->tpl->parseCurrentBlock();
930 }
931
932 //$this->tpl->show();
933 }
934
938 public function downloadExportFile()
939 {
940 $ilAccess = $this->access;
943
944 if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
945 $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->error_obj->MESSAGE);
946 }
947
948 $file = $this->glossary->getPublicExportFile($this->requested_export_type);
949 if ($this->glossary->getPublicExportFile($this->requested_export_type) != "") {
950 $dir = $this->glossary->getExportDirectory($this->requested_export_type);
951 if (is_file($dir . "/" . $file)) {
952 ilUtil::deliverFile($dir . "/" . $file, $file);
953 exit;
954 }
955 }
956 $ilErr->raiseError($this->lng->txt("file_not_found"), $ilErr->MESSAGE);
957 }
958
966 public function setLocator($a_tree = "", $a_id = "")
967 {
968 $gloss_loc = new ilGlossaryLocatorGUI();
969 $gloss_loc->setMode("presentation");
970 if (!empty($this->term_id)) {
971 $term = new ilGlossaryTerm($this->term_id);
972 $gloss_loc->setTerm($term);
973 }
974 $gloss_loc->setGlossary($this->glossary);
975 //$gloss_loc->setDefinition($this->definition);
976 $gloss_loc->display();
977 }
978
982 public function downloadFile()
983 {
984 $ilAccess = $this->access;
987
988 if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
989 $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->MESSAGE);
990 }
991
992 $file = explode("_", $this->requested_file_id);
993 $fileObj = new ilObjFile($file[count($file) - 1], false);
994 $fileObj->sendFile();
995 exit;
996 }
997
1001 public function setTabs()
1002 {
1003 $this->getTabs();
1004 }
1005
1006
1010 public function getLink(
1011 $a_ref_id,
1012 $a_cmd = "",
1013 $a_term_id = "",
1014 $a_def_id = "",
1015 $a_frame = "",
1016 $a_type = ""
1017 ) {
1018 if ($a_cmd == "") {
1019 $a_cmd = "layout";
1020 }
1021 //$script = "glossary_presentation.php";
1022
1023 // handle online links
1024 if (!$this->offlineMode()) {
1025 //$link = $script."?ref_id=".$a_ref_id;
1026 switch ($a_cmd) {
1027 case "fullscreen":
1028 $this->ctrl->setParameter($this, "def_id", $a_def_id);
1029 $link = $this->ctrl->getLinkTarget($this, "fullscreen");
1030 break;
1031
1032 default:
1033 $link .= "&amp;cmd=" . $a_cmd;
1034 if ($a_frame != "") {
1035 $this->ctrl->setParameter($this, "frame", $a_frame);
1036 }
1037 if ($a_obj_id != "") {
1038 switch ($a_type) {
1039 case "MediaObject":
1040 $this->ctrl->setParameter($this, "mob_id", $a_obj_id);
1041 break;
1042
1043 default:
1044 $this->ctrl->setParameter($this, "def_id", $a_def_id);
1045 break;
1046 }
1047 }
1048 if ($a_type != "") {
1049 $this->ctrl->setParameter($this, "obj_type", $a_type);
1050 }
1051 $link = $this->ctrl->getLinkTarget($this, $a_cmd);
1052// $link = str_replace("&", "&amp;", $link);
1053 break;
1054 }
1055 } else { // handle offline links
1056 switch ($a_cmd) {
1057 case "downloadFile":
1058 break;
1059
1060 case "fullscreen":
1061 $link = "fullscreen.html"; // id is handled by xslt
1062 break;
1063
1064 case "layout":
1065 break;
1066
1067 case "glossary":
1068 $link = "term_" . $a_obj_id . ".html";
1069 break;
1070
1071 case "media":
1072 $link = "media_" . $a_obj_id . ".html";
1073 break;
1074
1075 default:
1076 break;
1077 }
1078 }
1079 $this->ctrl->clearParameters($this);
1080 return $link;
1081 }
1082
1089 public function printViewSelection()
1090 {
1092 $lng = $this->lng;
1093 $ilToolbar = $this->toolbar;
1094 $ilCtrl = $this->ctrl;
1095 $tpl = $this->tpl;
1096 $ilTabs = $this->tabs_gui;
1097
1098 $ilCtrl->saveParameter($this, "term_id");
1099
1100 if ((int) $this->term_id == 0) {
1101 $this->setTabs();
1102 $ilTabs->activateTab("print_view");
1103 } else {
1104 $tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
1105 $term = new ilGlossaryTerm((int) $this->term_id);
1106 $tpl->setTitle($this->lng->txt("cont_term") . ": " . $term->getTerm());
1107 $this->showDefinitionTabs("print_view");
1108 }
1109
1111
1112 $tpl->setContent($this->form->getHTML());
1113 }
1114
1119 {
1120 $lng = $this->lng;
1121 $ilCtrl = $this->ctrl;
1122
1123 $terms = $this->glossary->getTermList();
1124
1125 $this->form = new ilPropertyFormGUI();
1126 //$this->form->setTarget("print_view");
1127 $this->form->setFormAction($ilCtrl->getFormAction($this));
1128
1129 // selection type
1130 $radg = new ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
1131 $radg->setValue("glossary");
1132
1133 // current term
1134 if ((int) $this->term_id > 0) {
1135 $op1 = new ilRadioOption($lng->txt("cont_current_term"), "term");
1136 $radg->addOption($op1);
1137 $radg->setValue("term");
1138 }
1139
1140 // whole glossary
1141 $op2 = new ilRadioOption($lng->txt("cont_whole_glossary")
1142 . " (" . $lng->txt("cont_terms") . ": " . count($terms) . ")", "glossary");
1143 $radg->addOption($op2);
1144
1145 // selected topic
1146 if (($t_id = $this->glossary->getTaxonomyId()) > 0 && $this->glossary->getShowTaxonomy()) {
1147 $op4 = new ilRadioOption($lng->txt("cont_selected_topic"), "sel_topic");
1148 $radg->addOption($op4);
1149
1150 // topic drop down
1152 $t_id,
1153 false,
1154 $lng->txt("cont_topic"),
1155 "topic",
1156 false
1157 );
1158 if ($this->tax_node > 0) {
1159 $si->setValue((int) $this->tax_node);
1160 }
1161 $op4->addSubItem($si);
1162 }
1163
1164 // selected terms
1165 $op3 = new ilRadioOption($lng->txt("cont_selected_terms"), "selection");
1166 $radg->addOption($op3);
1167
1168 $nl = new ilNestedListInputGUI("", "obj_id");
1169 $op3->addSubItem($nl);
1170 //var_dump($terms);
1171 foreach ($terms as $t) {
1172 $nl->addListNode($t["id"], $t["term"], 0, false, false);
1173 }
1174
1175 $this->form->addItem($radg);
1176
1177 $this->form->addCommandButton("printView", $lng->txt("cont_show_print_view"));
1178 $this->form->setPreventDoubleSubmission(false);
1179
1180 $this->form->setTitle($lng->txt("cont_print_selection"));
1181 }
1182
1189 public function printView()
1190 {
1191 $ilAccess = $this->access;
1192 $tpl = $this->tpl;
1193
1194 $this->tabs_gui->setBackTarget(
1195 $this->lng->txt("back"),
1196 $this->ctrl->getLinkTarget($this, "printViewSelection")
1197 );
1198
1199 if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
1200 return;
1201 }
1202
1203 $terms = array();
1204 switch ($_POST["sel_type"]) {
1205 case "glossary":
1206 $ts = $this->glossary->getTermList();
1207 foreach ($ts as $t) {
1208 $terms[] = $t["id"];
1209 }
1210 break;
1211
1212 case "sel_topic":
1213 $t_id = $this->glossary->getTaxonomyId();
1214 $items = ilObjTaxonomy::getSubTreeItems("glo", $this->glossary->getId(), "term", $t_id, (int) $_POST["topic"]);
1215 foreach ($items as $i) {
1216 if ($i["item_type"] == "term") {
1217 $terms[] = $i["item_id"];
1218 }
1219 }
1220 break;
1221
1222 case "selection":
1223 if (is_array($_POST["obj_id"])) {
1224 $terms = $_POST["obj_id"];
1225 } else {
1226 $terms = array();
1227 }
1228 break;
1229
1230 case "term":
1231 $terms = array($this->term_id);
1232 break;
1233 }
1234
1235 //$tpl->addCss(ilObjStyleSheet::getContentPrintStyle());
1236 $tpl->addOnLoadCode("il.Util.print();");
1237
1238 // determine target frames for internal links
1239
1240 $page_content = "";
1241 foreach ($terms as $t_id) {
1242 $page_content .= $this->listDefinitions($this->requested_ref_id, $t_id, true, ilPageObjectGUI::PRINTING);
1243 }
1244 $tpl->setContent($page_content);
1245 }
1246
1250 public function getTabs()
1251 {
1252 $ilAccess = $this->access;
1253 $lng = $this->lng;
1254 $ilCtrl = $this->ctrl;
1255 $ilHelp = $this->help;
1256
1257 $ilHelp->setScreenIdComponent("glo");
1258
1259 if (!$this->offlineMode()) {
1260 if ($this->ctrl->getCmd() != "listDefinitions") {
1261 if ($ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
1262 $this->tabs_gui->addTab(
1263 "terms",
1264 $lng->txt("cont_terms"),
1265 $ilCtrl->getLinkTarget($this, "listTerms")
1266 );
1267 }
1268
1269 $this->tabs_gui->addTab(
1270 "info",
1271 $lng->txt("info_short"),
1272 $ilCtrl->getLinkTarget($this, "infoScreen")
1273 );
1274
1275
1276 // glossary menu
1277 if ($ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
1278 $this->tabs_gui->addTab(
1279 "print_view",
1280 $lng->txt("cont_print_view"),
1281 $ilCtrl->getLinkTarget($this, "printViewSelection")
1282 );
1283
1284 // download links
1285 if ($this->glossary->isActiveDownloads()) {
1286 $this->tabs_gui->addTab(
1287 "download",
1288 $lng->txt("download"),
1289 $ilCtrl->getLinkTarget($this, "showDownloadList")
1290 );
1291 }
1292 //}
1293 }
1294
1295 if ($ilAccess->checkAccess("write", "", (int) $this->requested_ref_id) ||
1296 $ilAccess->checkAccess("edit_content", "", (int) $this->requested_ref_id)) {
1297 $this->tabs_gui->addNonTabbedLink(
1298 "editing_view",
1299 $lng->txt("glo_editing_view"),
1300 "ilias.php?baseClass=ilGlossaryEditorGUI&amp;ref_id=" . (int) $this->requested_ref_id,
1301 "_top"
1302 );
1303 }
1304 }
1305 } else {
1306 $this->tabs_gui->addTarget(
1307 "cont_back",
1308 "index.html#term_" . $this->term_id,
1309 "",
1310 ""
1311 );
1312 }
1313 }
1314
1320 public function infoScreen()
1321 {
1322 $this->ctrl->setCmd("showSummary");
1323 $this->ctrl->setCmdClass("ilinfoscreengui");
1324 $this->outputInfoScreen();
1325 }
1326
1330 public function outputInfoScreen()
1331 {
1332 $ilAccess = $this->access;
1333 $ilTabs = $this->tabs_gui;
1334
1335 $this->setTabs();
1336 $ilTabs->activateTab("info");
1337 $this->lng->loadLanguageModule("meta");
1338
1339 $info = new ilInfoScreenGUI($this->glossary_gui);
1340 $info->enablePrivateNotes();
1341 //$info->enableLearningProgress();
1342
1343 $info->enableNews();
1344 if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
1345 $info->enableNewsEditing();
1346 $news_set = new ilSetting("news");
1347 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1348 if ($enable_internal_rss) {
1349 $info->setBlockProperty("news", "settings", true);
1350 }
1351 }
1352
1353 // show standard meta data section
1354 $info->addMetaDataSections($this->glossary->getId(), 0, $this->glossary->getType());
1355
1356 ilObjGlossaryGUI::addUsagesToInfo($info, $this->glossary->getId());
1357
1358 if ($this->offlineMode()) {
1359 $this->tpl->setContent($info->getHTML());
1360 return $this->tpl->get();
1361 } else {
1362 // forward the command
1363 $this->ctrl->forwardCommand($info);
1364 }
1365 }
1366
1373 public function chooseLetter()
1374 {
1375 $ilCtrl = $this->ctrl;
1376
1377 $ilCtrl->redirect($this, "listTerms");
1378 }
1379
1384 public function showTaxonomy()
1385 {
1386 global $DIC;
1387
1388 $tpl = $this->tpl;
1390 if (!$this->offlineMode() && $this->glossary->getShowTaxonomy()) {
1391 $tax_ids = ilObjTaxonomy::getUsageOfObject($this->glossary->getId());
1392 if (count($tax_ids) > 0) {
1393 $tax_id = $tax_ids[0];
1394 $DIC->globalScreen()->tool()->context()->current()
1395 ->addAdditionalData(
1397 true
1398 );
1399 $DIC->globalScreen()->tool()->context()->current()
1400 ->addAdditionalData(
1402 $ctrl->getCurrentClassPath()
1403 );
1404 $DIC->globalScreen()->tool()->context()->current()
1405 ->addAdditionalData(
1407 $tax_id
1408 );
1409 $DIC->globalScreen()->tool()->context()->current()
1410 ->addAdditionalData(
1412 "listTerms"
1413 );
1414 $DIC->globalScreen()->tool()->context()->current()
1415 ->addAdditionalData(
1417 "showTaxonomy"
1418 );
1419
1420 $tax_exp = new ilTaxonomyExplorerGUI(
1421 get_class($this),
1422 "showTaxonomy",
1423 $tax_id,
1424 "ilglossarypresentationgui",
1425 "listTerms"
1426 );
1427 if (!$tax_exp->handleCommand()) {
1428 //$tpl->setLeftNavContent($tax_exp->getHTML());
1429 //$tpl->setLeftContent($tax_exp->getHTML()."&nbsp;");
1430 }
1431 return;
1432 }
1433 }
1434 }
1435}
user()
Definition: user.php:4
$size
Definition: RandomTest.php:84
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
const IL_MODE_ALIAS
const IL_MODE_OUTPUT
This class represents a text property in a property form.
special template class to simplify handling of ITX/PEAR
Glossary definition page GUI class.
static getDefinitionList($a_term_id)
static
downloadFile()
download file of file lists
getPresentationTable()
Get presentation table.
listDefinitions($a_ref_id=0, $a_term_id=0, $a_get_html=false, $a_page_mode=ilPageObjectGUI::PRESENTATION)
list definitions of a term
basicPageGuiInit(\ilPageObjectGUI $a_page_gui)
Basic page gui initialisation.
initPrintViewSelectionForm()
Init print view selection form.
media($a_mode="media")
show media object
getLink( $a_ref_id, $a_cmd="", $a_term_id="", $a_def_id="", $a_frame="", $a_type="")
handles links for learning module presentation
initByRequest(array $query_params)
Init services and this class by request params.
setOfflineDirectory($a_dir)
Set offline directory.
__construct($export_format="", $export_dir="")
Constructor @access public.
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
setOfflineMode($a_offline=true)
set offline mode (content is generated for offline package)
resetFilter()
Reset filter (note: this function existed before data table filter has been introduced.
setLocator($a_tree="", $a_id="")
set Locator
downloadExportFile()
send download file (xml/html)
offlineMode()
checks wether offline content generation is activated
static isReferenced($a_glo_id, $a_term_id)
Is a term referenced by one or multiple glossaries.
static _lookGlossaryID($term_id)
get glossary id form term id
Class ilInfoScreenGUI.
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static _getPresentationTitle( $a_pg_id, $a_mode=self::CHAPTER_TITLE, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_force_content=false, $a_lm_id=0, $a_lang="-", $a_include_short=false)
presentation title doesn't have to be page title, it may be chapter title + page title or chapter tit...
static _getMapAreasIntLinks($a_mob_id)
get all internal links of map areas of a mob
This class represents a (nested) list of checkboxes (could be extended for radio items,...
Class ilObjFile.
static addUsagesToInfo($info, $glo_id)
Add usages to info.
Class ilObjMediaObject.
static isTypeAllowed($a_type)
Is type allowed.
static getSyntaxStylePath()
get syntax style path
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
static getSubTreeItems($a_comp, $a_obj_id, $a_item_type, $a_tax_id, $a_node)
Get all assigned items under a node.
Class ilObjectMetaDataGUI.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
Class ilPageObjectGUI.
setOutputMode($a_mode=self::PRESENTATION)
Set Output Mode.
setFileDownloadLink($a_download_link)
Set file download link.
setFullscreenLink($a_fullscreen_link)
Set fullscreen link.
setStyleId($a_styleid)
Set Style Id.
setOfflineDirectory($offdir)
set offline directory to offdir
Term list table for presentation mode.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
ILIAS Setting Class.
Class ilTableGUI.
Input GUI class for taxonomy assignments.
Taxonomy explorer GUI class.
special template class to simplify handling of ITX/PEAR
static highlight($a_dom_node_id, $a_text, $a_tpl=null)
Searches for all occurences of a text (case-insensitive) and highlights it.
static _getInstance($a_usr_id)
Get singleton instance.
static getWebspaceDir($mode="filesystem")
get webspace directory
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$ilUser
Definition: imgupload.php:18
xslt_error(&$proc)
xslt_free(&$proc)
xslt_create()
exit
Definition: login.php:29
$i
Definition: metadata.php:24
$xml
Definition: metadata.php:332
$ret
Definition: parser.php:6
$type
$ilErr
Definition: raiseError.php:18
$cols
Definition: xhr_table.php:11