ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTermDefinitionEditorGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
6require_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
7require_once("./Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php");
8
20{
24 protected $ctrl;
25
29 protected $tabs_gui;
30
31 public $tpl;
32 public $lng;
33 public $glossary;
35 public $term;
36
41 public function __construct()
42 {
43 global $DIC;
44
45 $tpl = $DIC["tpl"];
46 $lng = $DIC->language();
47 $ilCtrl = $DIC->ctrl();
48 $ilTabs = $DIC->tabs();
49
50 // initiate variables
51 $this->tpl = $tpl;
52 $this->lng = $lng;
53 $this->ctrl = $ilCtrl;
54 $this->glossary = new ilObjGlossary($_GET["ref_id"], true);
55 $this->definition = new ilGlossaryDefinition($_GET["def"]);
56 $this->term = new ilGlossaryTerm($this->definition->getTermId());
57 $this->term_glossary = new ilObjGlossary(ilGlossaryTerm::_lookGlossaryID($this->definition->getTermId()), false);
58 $this->tabs_gui = $ilTabs;
59
60 $this->ctrl->saveParameter($this, array("def"));
61 }
62
63
64 public function executeCommand()
65 {
69
70 $next_class = $this->ctrl->getNextClass($this);
71 $cmd = $this->ctrl->getCmd();
72
73 // content style
74 $this->tpl->setCurrentBlock("ContentStyle");
75 $this->tpl->setVariable(
76 "LOCATION_CONTENT_STYLESHEET",
77 ilObjStyleSheet::getContentStylePath($this->term_glossary->getStyleSheetId())
78 );
79 $this->tpl->parseCurrentBlock();
80
81 // syntax style
82 $this->tpl->setCurrentBlock("SyntaxStyle");
83 $this->tpl->setVariable(
84 "LOCATION_SYNTAX_STYLESHEET",
86 );
87 $this->tpl->parseCurrentBlock();
88
89 require_once("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
90 $gloss_loc = new ilGlossaryLocatorGUI();
91 $gloss_loc->setTerm($this->term);
92 $gloss_loc->setGlossary($this->glossary);
93 $gloss_loc->setDefinition($this->definition);
94
95 // $this->tpl->getStandardTemplate();
96 $this->tpl->setTitle($this->term->getTerm() . " - " .
97 $this->lng->txt("cont_definition") . " " .
98 $this->definition->getNr());
99 if ($this->ctrl->getNextClass() == "ilglossarydefpagegui") {
100 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
101 }
102
103 switch ($next_class) {
104
105 case "ilglossarydefpagegui":
106
107 // output number of usages
108 if ($ilCtrl->getCmd() == "edit" &&
109 $ilCtrl->getCmdClass() == "ilglossarydefpagegui") {
111 if ($nr > 0) {
112 $link = "[<a href='" .
113 $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages") .
114 "'>" . $lng->txt("glo_list_usages") . "</a>]";
115 ilUtil::sendInfo(sprintf(
116 $lng->txt("glo_term_is_used_n_times"),
117 $nr
118 ) . " " . $link);
119 }
120 }
121
122 // not so nice, to do: revise locator handling
123 if ($this->ctrl->getNextClass() == "ilglossarydefpagegui"
124 || $this->ctrl->getCmdClass() == "ileditclipboardgui") {
125 $gloss_loc->display();
126 }
127 $this->setTabs();
128 $this->ctrl->setReturnByClass("ilGlossaryDefPageGUI", "edit");
129 $this->ctrl->setReturn($this, "listDefinitions");
130 $page_gui = new ilGlossaryDefPageGUI($this->definition->getId());
131 $page = $page_gui->getPageObject();
132 $this->definition->assignPageObject($page);
133 $page->addUpdateListener($this, "saveShortText");
134 $page_gui->setEditPreview(true);
135
136 // metadata
137 // ... set title to term, if no title is given
138 include_once("./Services/MetaData/classes/class.ilMD.php");
139 $md = new ilMD($this->term_glossary->getId(), $this->definition->getId(), "gdf");
140 $md_gen = $md->getGeneral();
141 if ($md_gen->getTitle() == "") {
142 $md_gen->setTitle($this->term->getTerm());
143 $md_gen->update();
144 }
145
146 $page_gui->activateMetaDataEditor($this->term_glossary, "gdf", $this->definition->getId());
147
148 $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $_GET["ref_id"]);
149 $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=fullscreen&amp;ref_id=" . $_GET["ref_id"]);
150 $page_gui->setTemplateTargetVar("ADM_CONTENT");
151 $page_gui->setOutputMode("edit");
152
154 $this->term_glossary->getStyleSheetId(),
155 "glo"
156 ));
157 $page_gui->setLocator($gloss_loc);
158 $page_gui->setIntLinkReturn($this->ctrl->getLinkTargetByClass(
159 "ilobjglossarygui",
160 "quickList",
161 "",
162 false,
163 false
164 ));
165 $page_gui->setPageBackTitle($this->lng->txt("cont_definition"));
166 $page_gui->setLinkParams("ref_id=" . $_GET["ref_id"]);
167 $page_gui->setHeader($this->term->getTerm());
168 $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=downloadFile&amp;ref_id=" . $_GET["ref_id"]);
169 $page_gui->setPresentationTitle($this->term->getTerm());
170 $ret = $this->ctrl->forwardCommand($page_gui);
171 $tpl->setContent($ret);
172 break;
173
174 default:
175 $this->setTabs();
176 $gloss_loc->display();
177 $ret = $this->$cmd();
178 break;
179
180 }
181 }
182
183
187 public function main_header($a_header_title)
188 {
190
191 $this->tpl->getStandardTemplate();
192 $this->tpl->setTitle($a_header_title);
193 $this->displayLocator();
194 //$this->setAdminTabs($a_type);
195 }
196
200 public function setTabs()
201 {
202 // catch feedback message
203 $this->getTabs();
204 }
205
209 public function getTabs()
210 {
211 // back to glossary
212 $this->tabs_gui->setBack2Target(
213 $this->lng->txt("glossary"),
214 $this->ctrl->getParentReturn($this)
215 );
216
217 // back to upper context
218 $this->tabs_gui->setBackTarget(
219 $this->lng->txt("term"),
220 $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm")
221 );
222 }
223
224
225 public function saveShortText()
226 {
227 $this->definition->updateShortText();
228 }
229}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Glossary definition page GUI class.
Class ilGlossaryDefinition.
Class ilGlossaryTerm.
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)
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 $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
global $DIC
Definition: saml.php:7