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