ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTermDefinitionEditorGUI.php
Go to the documentation of this file.
1<?php
2
25{
27 protected \ILIAS\Glossary\Editing\EditingGUIRequest $request;
28 protected ilCtrl $ctrl;
34 protected \ILIAS\Style\Content\GUIService $content_style_gui;
35 protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
36
37 public function __construct()
38 {
39 global $DIC;
40
41 $tpl = $DIC["tpl"];
42 $lng = $DIC->language();
43 $ilCtrl = $DIC->ctrl();
44 $ilTabs = $DIC->tabs();
45
46 // initiate variables
47 $this->tpl = $tpl;
48 $this->lng = $lng;
49 $this->ctrl = $ilCtrl;
50 $this->request = $DIC->glossary()
51 ->internal()
52 ->gui()
53 ->editing()
54 ->request();
55
56
57 $this->glossary = new ilObjGlossary($this->request->getRefId(), true);
58 if (($this->request->getTableGlossaryTermListAction() == "editDefinition")
59 && !empty($this->request->getTableGlossaryTermListIds())) {
60 $term_id = (int) $this->request->getTableGlossaryTermListIds()[0];
61 $this->term = new ilGlossaryTerm($term_id);
62 } else {
63 $this->term = new ilGlossaryTerm($this->request->getTermId());
64 }
65 $this->term_glossary = new ilObjGlossary(ilGlossaryTerm::_lookGlossaryID($this->term->getId()), false);
66 $this->tabs_gui = $ilTabs;
67
68 $this->ctrl->saveParameter($this, array("term"));
69
70 $cs = $DIC->contentStyle();
71 $this->content_style_gui = $cs->gui();
72 $this->content_style_domain = $cs->domain()->styleForRefId($this->glossary->getRefId());
73 }
74
75
76 public function executeCommand(): void
77 {
79 $ilCtrl = $this->ctrl;
81
82 $next_class = $this->ctrl->getNextClass($this);
83 $cmd = $this->ctrl->getCmd();
84
85 // content style
86 $this->content_style_gui->addCss(
87 $this->tpl,
88 $this->term_glossary->getRefId(),
89 $this->term_glossary->getId()
90 );
91
92 // syntax style
93 $this->tpl->setCurrentBlock("SyntaxStyle");
94 $this->tpl->setVariable(
95 "LOCATION_SYNTAX_STYLESHEET",
97 );
98 $this->tpl->parseCurrentBlock();
99
100 $gloss_loc = new ilGlossaryLocatorGUI();
101 $gloss_loc->setTerm($this->term);
102 $gloss_loc->setGlossary($this->glossary);
103
104 $this->tpl->setTitle($this->term->getTerm() . " - " .
105 $this->lng->txt("cont_definition"));
106 if ($this->ctrl->getNextClass() == "ilglossarydefpagegui") {
107 $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
108 }
109
110 switch ($next_class) {
111 case "ilglossarydefpagegui":
112 // output number of usages
113 if ($ilCtrl->getCmd() == "edit" &&
114 $ilCtrl->getCmdClass() == "ilglossarydefpagegui") {
115 $nr = ilGlossaryTerm::getNumberOfUsages($this->request->getTermId());
116 if ($nr > 0) {
117 $link = "[<a href='" .
118 $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages") .
119 "'>" . $lng->txt("glo_list_usages") . "</a>]";
120 $this->tpl->setOnScreenMessage("info", sprintf(
121 $lng->txt("glo_term_is_used_n_times"),
122 $nr
123 ) . " " . $link);
124 }
125 }
126
127 // not so nice, to do: revise locator handling
128 if ($this->ctrl->getNextClass() == "ilglossarydefpagegui"
129 || $this->ctrl->getCmdClass() == "ileditclipboardgui") {
130 $gloss_loc->display();
131 }
132 $this->setTabs();
133 $this->ctrl->setReturnByClass("ilGlossaryDefPageGUI", "edit");
134 $this->ctrl->setReturn($this, "listDefinitions");
135 $page_gui = new ilGlossaryDefPageGUI($this->term->getId());
136 // @var ilGlossaryDefPage $page
137 $page = $page_gui->getPageObject();
139 $this->term->assignPageObject($page);
140 $page->addUpdateListener($this, "saveShortText");
141 $page_gui->setEditPreview(true);
142
143 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $this->request->getRefId());
144 $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=fullscreen&amp;ref_id=" . $this->request->getRefId());
145 $page_gui->setTemplateTargetVar("ADM_CONTENT");
146 $page_gui->setOutputMode("edit");
147
148 $page_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
149
150 $page_gui->setIntLinkReturn($this->ctrl->getLinkTargetByClass(
151 "ilobjglossarygui",
152 "",
153 "",
154 false,
155 false
156 ));
157 $page_gui->setPageBackTitle($this->lng->txt("cont_definition"));
158 $page_gui->setLinkParams("ref_id=" . $this->request->getRefId());
159 $page_gui->setHeader($this->term->getTerm());
160 $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=downloadFile&amp;ref_id=" . $this->request->getRefId());
161 $page_gui->setPresentationTitle($this->term->getTerm());
162 $ret = $this->ctrl->forwardCommand($page_gui);
163 if ($ret != "") {
164 $tpl->setContent($ret);
165 }
166 break;
167
168 default:
169 $this->setTabs();
170 $gloss_loc->display();
171 $this->$cmd();
172 break;
173 }
174 }
175
176 public function setTabs(): void
177 {
178 $this->getTabs();
179 }
180
181 public function getTabs(): void
182 {
183 // back to glossary
184 $this->tabs_gui->setBack2Target(
185 $this->lng->txt("glossary"),
186 $this->ctrl->getLinkTargetByClass("ilobjglossarygui", "")
187 );
188
189 // back to upper context
190 $this->tabs_gui->setBackTarget(
191 $this->lng->txt("term"),
192 $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm")
193 );
194 }
195
196 public function saveShortText(): void
197 {
198 $this->term->updateShortText();
199 }
200}
Class ilCtrl provides processing control methods.
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...
static getNumberOfUsages(int $a_term_id)
static _lookGlossaryID(int $term_id)
get glossary id form term id
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Style Content Object ObjectFacade $content_style_domain
ILIAS Style Content GUIService $content_style_gui
ILIAS Glossary Editing EditingGUIRequest $request
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setContent(string $a_html)
Sets content for standard template.
global $DIC
Definition: shib_login.php:26