ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTermDefinitionEditorGUI.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
12{
16 protected $ctrl;
17
21 protected $tabs_gui;
22
23 public $tpl;
24 public $lng;
25 public $glossary;
27 public $term;
28
33 public function __construct()
34 {
35 global $DIC;
36
37 $tpl = $DIC["tpl"];
38 $lng = $DIC->language();
39 $ilCtrl = $DIC->ctrl();
40 $ilTabs = $DIC->tabs();
41
42 // initiate variables
43 $this->tpl = $tpl;
44 $this->lng = $lng;
45 $this->ctrl = $ilCtrl;
46 $this->glossary = new ilObjGlossary($_GET["ref_id"], true);
47 $this->definition = new ilGlossaryDefinition($_GET["def"]);
48 $this->term = new ilGlossaryTerm($this->definition->getTermId());
49 $this->term_glossary = new ilObjGlossary(ilGlossaryTerm::_lookGlossaryID($this->definition->getTermId()), false);
50 $this->tabs_gui = $ilTabs;
51
52 $this->ctrl->saveParameter($this, array("def"));
53 }
54
55
56 public function executeCommand()
57 {
59 $ilCtrl = $this->ctrl;
61
62 $next_class = $this->ctrl->getNextClass($this);
63 $cmd = $this->ctrl->getCmd();
64
65 // content style
66 $this->tpl->setCurrentBlock("ContentStyle");
67 $this->tpl->setVariable(
68 "LOCATION_CONTENT_STYLESHEET",
69 ilObjStyleSheet::getContentStylePath($this->term_glossary->getStyleSheetId())
70 );
71 $this->tpl->parseCurrentBlock();
72
73 // syntax style
74 $this->tpl->setCurrentBlock("SyntaxStyle");
75 $this->tpl->setVariable(
76 "LOCATION_SYNTAX_STYLESHEET",
78 );
79 $this->tpl->parseCurrentBlock();
80
81 $gloss_loc = new ilGlossaryLocatorGUI();
82 $gloss_loc->setTerm($this->term);
83 $gloss_loc->setGlossary($this->glossary);
84 $gloss_loc->setDefinition($this->definition);
85
86 $this->tpl->setTitle($this->term->getTerm() . " - " .
87 $this->lng->txt("cont_definition") . " " .
88 $this->definition->getNr());
89 if ($this->ctrl->getNextClass() == "ilglossarydefpagegui") {
90 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
91 }
92
93 switch ($next_class) {
94
95 case "ilglossarydefpagegui":
96
97 // output number of usages
98 if ($ilCtrl->getCmd() == "edit" &&
99 $ilCtrl->getCmdClass() == "ilglossarydefpagegui") {
101 if ($nr > 0) {
102 $link = "[<a href='" .
103 $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages") .
104 "'>" . $lng->txt("glo_list_usages") . "</a>]";
105 ilUtil::sendInfo(sprintf(
106 $lng->txt("glo_term_is_used_n_times"),
107 $nr
108 ) . " " . $link);
109 }
110 }
111
112 // not so nice, to do: revise locator handling
113 if ($this->ctrl->getNextClass() == "ilglossarydefpagegui"
114 || $this->ctrl->getCmdClass() == "ileditclipboardgui") {
115 $gloss_loc->display();
116 }
117 $this->setTabs();
118 $this->ctrl->setReturnByClass("ilGlossaryDefPageGUI", "edit");
119 $this->ctrl->setReturn($this, "listDefinitions");
120 $page_gui = new ilGlossaryDefPageGUI($this->definition->getId());
121 $page = $page_gui->getPageObject();
122 $this->definition->assignPageObject($page);
123 $page->addUpdateListener($this, "saveShortText");
124 $page_gui->setEditPreview(true);
125
126 // metadata
127 // ... set title to term, if no title is given
128 $md = new ilMD($this->term_glossary->getId(), $this->definition->getId(), "gdf");
129 $md_gen = $md->getGeneral();
130 if ($md_gen->getTitle() == "") {
131 $md_gen->setTitle($this->term->getTerm());
132 $md_gen->update();
133 }
134
135 $page_gui->activateMetaDataEditor($this->term_glossary, "gdf", $this->definition->getId());
136
137 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $_GET["ref_id"]);
138 $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=fullscreen&amp;ref_id=" . $_GET["ref_id"]);
139 $page_gui->setTemplateTargetVar("ADM_CONTENT");
140 $page_gui->setOutputMode("edit");
141
143 $this->term_glossary->getStyleSheetId(),
144 "glo"
145 ));
146 $page_gui->setLocator($gloss_loc);
147 $page_gui->setIntLinkReturn($this->ctrl->getLinkTargetByClass(
148 "ilobjglossarygui",
149 "quickList",
150 "",
151 false,
152 false
153 ));
154 $page_gui->setPageBackTitle($this->lng->txt("cont_definition"));
155 $page_gui->setLinkParams("ref_id=" . $_GET["ref_id"]);
156 $page_gui->setHeader($this->term->getTerm());
157 $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=downloadFile&amp;ref_id=" . $_GET["ref_id"]);
158 $page_gui->setPresentationTitle($this->term->getTerm());
159 $ret = $this->ctrl->forwardCommand($page_gui);
160 if ($ret != "") {
161 $tpl->setContent($ret);
162 }
163 break;
164
165 default:
166 $this->setTabs();
167 $gloss_loc->display();
168 $ret = $this->$cmd();
169 break;
170
171 }
172 }
173
174
178 public function main_header($a_header_title)
179 {
181
182 $this->tpl->loadStandardTemplate();
183 $this->tpl->setTitle($a_header_title);
184 $this->displayLocator();
185 //$this->setAdminTabs($a_type);
186 }
187
191 public function setTabs()
192 {
193 // catch feedback message
194 $this->getTabs();
195 }
196
200 public function getTabs()
201 {
202 // back to glossary
203 $this->tabs_gui->setBack2Target(
204 $this->lng->txt("glossary"),
205 $this->ctrl->getParentReturn($this)
206 );
207
208 // back to upper context
209 $this->tabs_gui->setBackTarget(
210 $this->lng->txt("term"),
211 $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm")
212 );
213 }
214
215
216 public function saveShortText()
217 {
218 $this->definition->updateShortText();
219 }
220}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Glossary definition page GUI class.
Class ilGlossaryDefinition.
static getNumberOfUsages($a_term_id)
Get number of usages.
static _lookGlossaryID($term_id)
get glossary id form term id
Class ilObjGlossary.
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
GUI class for glossary term definition editor.
main_header($a_header_title)
output main header (title and locator)
__construct()
Constructor @access public.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
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
$ret
Definition: parser.php:6