ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSkillTemplateCategoryGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30{
31 protected ilCtrl $ctrl;
33 protected ilTabsGUI $tabs;
34 protected ilLanguage $lng;
35 protected ilHelpGUI $help;
36
37 protected int $tref_id = 0;
38
39 public function __construct(Node\SkillTreeNodeManager $node_manager, int $a_node_id = 0, int $a_tref_id = 0)
40 {
41 global $DIC;
42
43 $this->ctrl = $DIC->ctrl();
44 $this->tpl = $DIC["tpl"];
45 $this->tabs = $DIC->tabs();
46 $this->lng = $DIC->language();
47 $this->help = $DIC["ilHelp"];
48 $ilCtrl = $DIC->ctrl();
49
50 $ilCtrl->saveParameter($this, "node_id");
51 $this->tref_id = $a_tref_id;
52
53 parent::__construct($node_manager, $a_node_id);
54 }
55
56 public function getType(): string
57 {
58 return "sctp";
59 }
60
61 public function executeCommand(): void
62 {
63 $ilCtrl = $this->ctrl;
65 $ilTabs = $this->tabs;
66
67 //$tpl->getStandardTemplate();
68
69 $next_class = $ilCtrl->getNextClass($this);
70 $cmd = $ilCtrl->getCmd();
71
72 switch ($next_class) {
73 default:
74 $ret = $this->$cmd();
75 break;
76 }
77 }
78
79 public function setTabs(string $a_tab): void
80 {
81 $ilTabs = $this->tabs;
82 $ilCtrl = $this->ctrl;
85 $ilHelp = $this->help;
86
87 $ilTabs->clearTargets();
88 $ilHelp->setScreenIdComponent("skmg_sctp");
89
90 // content
91 $ilTabs->addTab(
92 "content",
93 $lng->txt("content"),
94 $ilCtrl->getLinkTarget($this, 'listItems')
95 );
96
97
98 // properties
99 if ($this->tref_id == 0) {
100 $ilTabs->addTab(
101 "properties",
102 $lng->txt("settings"),
103 $ilCtrl->getLinkTarget($this, 'editProperties')
104 );
105 }
106
107 // usage
108 $this->addUsageTab($ilTabs);
109
110 $parent_node_id = $this->tree_repo->getParentNodeIdForNodeId($this->requested_node_id);
111 $parent_title = ilSkillTreeNode::_lookupTitle($parent_node_id);
112 $parent_type = ilSkillTreeNode::_lookupType($parent_node_id);
113
114 // back link
115 if ($this->tref_id == 0) {
116 if ($parent_type === "sctp") {
117 $ilCtrl->setParameter(
118 $this,
119 "node_id",
120 $parent_node_id
121 );
122 $ilTabs->setBackTarget(
123 $parent_title,
124 $ilCtrl->getLinkTarget($this, "listItems")
125 );
126 $ilCtrl->setParameter(
127 $this,
128 "node_id",
129 $this->requested_node_id
130 );
131 } else {
132 $ilCtrl->setParameterByClass(
133 "ilskillrootgui",
134 "node_id",
135 $this->skill_tree_node_manager->getRootId()
136 );
137 $ilTabs->setBackTarget(
138 $lng->txt("skmg_skill_templates"),
139 $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listTemplates")
140 );
141 $ilCtrl->setParameterByClass(
142 "ilskillrootgui",
143 "node_id",
144 $this->requested_node_id
145 );
146 }
147 }
148
149 parent::setTitleIcon();
150 $tpl->setTitle(
151 $lng->txt("skmg_sctp") . ": " . $this->node_object->getTitle()
152 );
154
155 $ilTabs->activateTab($a_tab);
156 }
157
158 public function initForm(string $a_mode = "edit"): void
159 {
161 $ilCtrl = $this->ctrl;
162
163 $this->form = new ilPropertyFormGUI();
164
165 // title
166 $ti = new ilTextInputGUI($lng->txt("title"), "title");
167 $ti->setMaxLength(200);
168 $ti->setSize(50);
169 $ti->setRequired(true);
170 $this->form->addItem($ti);
171
172 // description
173 $ta = new ilTextAreaInputGUI($lng->txt("description"), "description");
174 $ta->setRows(5);
175 $this->form->addItem($ta);
176
177 // save and cancel commands
178 if ($this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
179 if ($a_mode == "create") {
180 $this->form->addCommandButton("save", $lng->txt("save"));
181 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
182 $this->form->setTitle($lng->txt("skmg_create_" . $this->getType()));
183 } else {
184 $this->form->addCommandButton("update", $lng->txt("save"));
185 $this->form->setTitle($lng->txt("skmg_edit_" . $this->getType()));
186 }
187 } else {
188 foreach ($this->form->getItems() as $item) {
189 $item->setDisabled(true);
190 }
191 }
192
193 $ilCtrl->setParameter($this, "node_id", $this->requested_node_id);
194 $this->form->setFormAction($ilCtrl->getFormAction($this));
195 }
196
197 public function listItems(): void
198 {
201
202 if ($this->isInUse()) {
203 $this->tpl->setOnScreenMessage('info', $lng->txt("skmg_skill_in_use"));
204 }
205
206 if ($this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
207 if ($this->tref_id == 0) {
209 }
210 }
211
212 $this->setTabs("content");
213
214 $table = new ilSkillCatTableGUI(
215 $this,
216 "listItems",
217 $this->requested_node_id,
219 $this->tref_id
220 );
221
222 $tpl->setContent($table->getHTML());
223 }
224
225 public static function addCreationButtons(): void
226 {
227 global $DIC;
228
229 $ilCtrl = $DIC->ctrl();
230 $lng = $DIC->language();
231 $ilToolbar = $DIC->toolbar();
232 $ilUser = $DIC->user();
233 $admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
234
236
237 $ilCtrl->setParameterByClass("ilobjskillmanagementgui", "tmpmode", 1);
238
239 $ilCtrl->setParameterByClass(
240 "ilbasicskilltemplategui",
241 "node_id",
243 );
244 $ilToolbar->addButton(
245 $lng->txt("skmg_create_skill_template"),
246 $ilCtrl->getLinkTargetByClass("ilbasicskilltemplategui", "create")
247 );
248 $ilCtrl->setParameterByClass(
249 "ilskilltemplatecategorygui",
250 "node_id",
252 );
253 $ilToolbar->addButton(
254 $lng->txt("skmg_create_skill_template_category"),
255 $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "create")
256 );
257
258 // skill templates from clipboard
259 $sep = false;
260 if ($ilUser->clipboardHasObjectsOfType("sktp")) {
261 $ilToolbar->addSeparator();
262 $sep = true;
263 $ilToolbar->addButton(
264 $lng->txt("skmg_insert_skill_template_from_clip"),
265 $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "insertSkillTemplateClip")
266 );
267 }
268
269 // template categories from clipboard
270 if ($ilUser->clipboardHasObjectsOfType("sctp")) {
271 if (!$sep) {
272 $ilToolbar->addSeparator();
273 $sep = true;
274 }
275 $ilToolbar->addButton(
276 $lng->txt("skmg_insert_template_category_from_clip"),
277 $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "insertTemplateCategoryClip")
278 );
279 }
280 }
281
282 public function editProperties(): void
283 {
284 $this->setTabs("properties");
285 parent::editProperties();
286 }
287
288 public function saveItem(): void
289 {
290 if (!$this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
291 return;
292 }
293
294 $it = new ilSkillTemplateCategory();
295 $it->setTitle($this->form->getInput("title"));
296 $it->setDescription($this->form->getInput("description"));
297 $it->create();
298 $this->skill_tree_node_manager->putIntoTree($it, $this->requested_node_id, ilTree::POS_LAST_NODE);
299 }
300
301 public function updateItem(): void
302 {
303 if (!$this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
304 return;
305 }
306
307 $this->node_object->setTitle($this->form->getInput("title"));
308 $this->node_object->setDescription($this->form->getInput("description"));
309 $this->node_object->setOrderNr((int) $this->form->getInput("order_nr"));
310 $this->node_object->setSelfEvaluation((bool) $this->form->getInput("self_eval"));
311 $this->node_object->update();
312 }
313
314 public function afterSave(): void
315 {
316 $this->redirectToParent(true);
317 }
318
319 public function showUsage(): void
320 {
322
323 // (a) referenced skill template category in main tree
324 if ($this->tref_id > 0) {
325 parent::showUsage();
326 return;
327 }
328
329 // (b) skill template category in templates view
330
331 $this->setTabs("usage");
332
333 $usages = $this->usage_manager->getAllUsagesOfTemplate($this->requested_node_id);
334
335 $html = "";
336 foreach ($usages as $k => $usage) {
337 $usages_ui = $this->skill_ui_service->getUsagesUI($k, $usage);
338 $html .= $usages_ui->render() . "<br/><br/>";
339 }
340
341 $tpl->setContent($html);
342 }
343
344 public function redirectToParent(bool $a_tmp_mode = false): void
345 {
346 parent::redirectToParent(true);
347 }
348}
Class ilCtrl provides processing control methods.
Help GUI class.
setScreenIdComponent(string $a_comp)
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 class represents a property form user interface.
Skill template category GUI class.
redirectToParent(bool $a_tmp_mode=false)
Redirect to parent (identified by current node_id)
__construct(Node\SkillTreeNodeManager $node_manager, int $a_node_id=0, int $a_tref_id=0)
Basic GUI class for skill tree nodes.
addUsageTab(ilTabsGUI $a_tabs)
SkillAdminGUIRequest $admin_gui_request
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
static _lookupType(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
const POS_LAST_NODE
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd, string $submit_caption="")
global $DIC
Definition: shib_login.php:26