ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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;
29  protected ilTabsGUI $tabs_gui;
31  public ilLanguage $lng;
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  $this->term = new ilGlossaryTerm($this->request->getTermId());
59  $this->term_glossary = new ilObjGlossary(ilGlossaryTerm::_lookGlossaryID($this->term->getId()), false);
60  $this->tabs_gui = $ilTabs;
61 
62  $this->ctrl->saveParameter($this, array("term"));
63 
64  $cs = $DIC->contentStyle();
65  $this->content_style_gui = $cs->gui();
66  $this->content_style_domain = $cs->domain()->styleForRefId($this->glossary->getRefId());
67  }
68 
69 
70  public function executeCommand(): void
71  {
72  $tpl = $this->tpl;
73  $ilCtrl = $this->ctrl;
74  $lng = $this->lng;
75 
76  $next_class = $this->ctrl->getNextClass($this);
77  $cmd = $this->ctrl->getCmd();
78 
79  // content style
80  $this->content_style_gui->addCss(
81  $this->tpl,
82  $this->term_glossary->getRefId(),
83  $this->term_glossary->getId()
84  );
85 
86  // syntax style
87  $this->tpl->setCurrentBlock("SyntaxStyle");
88  $this->tpl->setVariable(
89  "LOCATION_SYNTAX_STYLESHEET",
91  );
92  $this->tpl->parseCurrentBlock();
93 
94  $gloss_loc = new ilGlossaryLocatorGUI();
95  $gloss_loc->setTerm($this->term);
96  $gloss_loc->setGlossary($this->glossary);
97 
98  $this->tpl->setTitle($this->term->getTerm() . " - " .
99  $this->lng->txt("cont_definition"));
100  if ($this->ctrl->getNextClass() == "ilglossarydefpagegui") {
101  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
102  }
103 
104  switch ($next_class) {
105  case "ilglossarydefpagegui":
106  // output number of usages
107  if ($ilCtrl->getCmd() == "edit" &&
108  $ilCtrl->getCmdClass() == "ilglossarydefpagegui") {
109  $nr = ilGlossaryTerm::getNumberOfUsages($this->request->getTermId());
110  if ($nr > 0) {
111  $link = "[<a href='" .
112  $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages") .
113  "'>" . $lng->txt("glo_list_usages") . "</a>]";
114  $this->tpl->setOnScreenMessage("info", sprintf(
115  $lng->txt("glo_term_is_used_n_times"),
116  $nr
117  ) . " " . $link);
118  }
119  }
120 
121  // not so nice, to do: revise locator handling
122  if ($this->ctrl->getNextClass() == "ilglossarydefpagegui"
123  || $this->ctrl->getCmdClass() == "ileditclipboardgui") {
124  $gloss_loc->display();
125  }
126  $this->setTabs();
127  $this->ctrl->setReturnByClass("ilGlossaryDefPageGUI", "edit");
128  $this->ctrl->setReturn($this, "listDefinitions");
129  $page_gui = new ilGlossaryDefPageGUI($this->term->getId());
130  // @var ilGlossaryDefPage $page
131  $page = $page_gui->getPageObject();
133  $this->term->assignPageObject($page);
134  $page->addUpdateListener($this, "saveShortText");
135  $page_gui->setEditPreview(true);
136 
137  $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $this->request->getRefId());
138  $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=fullscreen&amp;ref_id=" . $this->request->getRefId());
139  $page_gui->setTemplateTargetVar("ADM_CONTENT");
140  $page_gui->setOutputMode("edit");
141 
142  $page_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
143 
144  $page_gui->setIntLinkReturn($this->ctrl->getLinkTargetByClass(
145  "ilobjglossarygui",
146  "quickList",
147  "",
148  false,
149  false
150  ));
151  $page_gui->setPageBackTitle($this->lng->txt("cont_definition"));
152  $page_gui->setLinkParams("ref_id=" . $this->request->getRefId());
153  $page_gui->setHeader($this->term->getTerm());
154  $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=downloadFile&amp;ref_id=" . $this->request->getRefId());
155  $page_gui->setPresentationTitle($this->term->getTerm());
156  $ret = $this->ctrl->forwardCommand($page_gui);
157  if ($ret != "") {
158  $tpl->setContent($ret);
159  }
160  break;
161 
162  default:
163  $this->setTabs();
164  $gloss_loc->display();
165  $this->$cmd();
166  break;
167  }
168  }
169 
170  public function setTabs(): void
171  {
172  $this->getTabs();
173  }
174 
175  public function getTabs(): void
176  {
177  // back to glossary
178  $this->tabs_gui->setBack2Target(
179  $this->lng->txt("glossary"),
180  $this->ctrl->getLinkTargetByClass("ilobjglossarygui", "")
181  );
182 
183  // back to upper context
184  $this->tabs_gui->setBackTarget(
185  $this->lng->txt("term"),
186  $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm")
187  );
188  }
189 
190  public function saveShortText(): void
191  {
192  $this->term->updateShortText();
193  }
194 }
setEditPreview(bool $a_editpreview)
Set Display first Edit tab, then Preview tab, instead of Page and Edit.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
ILIAS Style Content Object ObjectFacade $content_style_domain
ILIAS Glossary Editing EditingGUIRequest $request
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.
ILIAS Style Content GUIService $content_style_gui
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