ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilSkillTemplateCategoryGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/Skill/classes/class.ilSkillTreeNodeGUI.php");
6include_once("./Services/Skill/classes/class.ilSkillTemplateCategory.php");
7
18{
22 protected $ctrl;
23
27 protected $tpl;
28
32 protected $tabs;
33
37 protected $lng;
38
42 protected $help;
43
44
48 public function __construct($a_node_id = 0, $a_tref_id)
49 {
50 global $DIC;
51
52 $this->ctrl = $DIC->ctrl();
53 $this->tpl = $DIC["tpl"];
54 $this->tabs = $DIC->tabs();
55 $this->lng = $DIC->language();
56 $this->help = $DIC["ilHelp"];
57 $ilCtrl = $DIC->ctrl();
58
59 $ilCtrl->saveParameter($this, "obj_id");
60 $this->tref_id = $a_tref_id;
61
62 parent::__construct($a_node_id);
63 }
64
68 public function getType()
69 {
70 return "sctp";
71 }
72
76 public function executeCommand()
77 {
80 $ilTabs = $this->tabs;
81
82 //$tpl->getStandardTemplate();
83
84 $next_class = $ilCtrl->getNextClass($this);
85 $cmd = $ilCtrl->getCmd();
86
87 switch ($next_class) {
88 default:
89 $ret = $this->$cmd();
90 break;
91 }
92 }
93
97 public function setTabs($a_tab)
98 {
99 $ilTabs = $this->tabs;
103 $ilHelp = $this->help;
104
105 $ilTabs->clearTargets();
106 $ilHelp->setScreenIdComponent("skmg_sctp");
107
108 // content
109 $ilTabs->addTab(
110 "content",
111 $lng->txt("content"),
112 $ilCtrl->getLinkTarget($this, 'listItems')
113 );
114
115
116 // properties
117 if ($this->tref_id == 0) {
118 $ilTabs->addTab(
119 "properties",
120 $lng->txt("settings"),
121 $ilCtrl->getLinkTarget($this, 'editProperties')
122 );
123 }
124
125 // usage
126 $this->addUsageTab($ilTabs);
127
128 // back link
129 if ($this->tref_id == 0) {
130 $ilCtrl->setParameterByClass(
131 "ilskillrootgui",
132 "obj_id",
133 $this->node_object->skill_tree->getRootId()
134 );
135 $ilTabs->setBackTarget(
136 $lng->txt("skmg_skill_templates"),
137 $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listTemplates")
138 );
139 $ilCtrl->setParameterByClass(
140 "ilskillrootgui",
141 "obj_id",
142 $_GET["obj_id"]
143 );
144 }
145
146 parent::setTitleIcon();
147 $tpl->setTitle(
148 $lng->txt("skmg_sctp") . ": " . $this->node_object->getTitle()
149 );
151
152 $ilTabs->activateTab($a_tab);
153 }
154
160 public function initForm($a_mode = "edit")
161 {
162 $r = parent::initForm($a_mode);
163 if ($a_mode == "create") {
164 $ni = $this->form->getItemByPostVar("order_nr");
165 include_once("./Services/Skill/classes/class.ilSkillTree.php");
166 $tree = new ilSkillTree();
167 $max = $tree->getMaxOrderNr((int) $_GET["obj_id"], true);
168 $ni->setValue($max + 10);
169 }
170 return $r;
171 }
172
179 public function listItems()
180 {
183
184 if ($this->isInUse()) {
185 ilUtil::sendInfo($lng->txt("skmg_skill_in_use"));
186 }
187
188 if ($this->checkPermissionBool("write")) {
189 if ($this->tref_id == 0) {
191 }
192 }
193
194 $this->setTabs("content");
195
196 include_once("./Services/Skill/classes/class.ilSkillCatTableGUI.php");
197 $table = new ilSkillCatTableGUI(
198 $this,
199 "listItems",
200 (int) $_GET["obj_id"],
202 $this->tref_id
203 );
204
205 $tpl->setContent($table->getHTML());
206 }
207
214 public static function addCreationButtons()
215 {
216 global $DIC;
217
218 $ilCtrl = $DIC->ctrl();
219 $lng = $DIC->language();
220 $ilToolbar = $DIC->toolbar();
221 $ilUser = $DIC->user();
222
223 $ilCtrl->setParameterByClass("ilobjskillmanagementgui", "tmpmode", 1);
224
225 $ilCtrl->setParameterByClass(
226 "ilbasicskilltemplategui",
227 "obj_id",
228 (int) $_GET["obj_id"]
229 );
230 $ilToolbar->addButton(
231 $lng->txt("skmg_create_skill_template"),
232 $ilCtrl->getLinkTargetByClass("ilbasicskilltemplategui", "create")
233 );
234 $ilCtrl->setParameterByClass(
235 "ilskilltemplatecategorygui",
236 "obj_id",
237 (int) $_GET["obj_id"]
238 );
239 $ilToolbar->addButton(
240 $lng->txt("skmg_create_skill_template_category"),
241 $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "create")
242 );
243
244 // skill templates from clipboard
245 $sep = false;
246 if ($ilUser->clipboardHasObjectsOfType("sktp")) {
247 $ilToolbar->addSeparator();
248 $sep = true;
249 $ilToolbar->addButton(
250 $lng->txt("skmg_insert_skill_template_from_clip"),
251 $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "insertSkillTemplateClip")
252 );
253 }
254
255 // template categories from clipboard
256 if ($ilUser->clipboardHasObjectsOfType("sctp")) {
257 if (!$sep) {
258 $ilToolbar->addSeparator();
259 $sep = true;
260 }
261 $ilToolbar->addButton(
262 $lng->txt("skmg_insert_template_category_from_clip"),
263 $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "insertTemplateCategoryClip")
264 );
265 }
266 }
267
271 public function editProperties()
272 {
273 $this->setTabs("properties");
274 parent::editProperties();
275 }
276
277
281 public function saveItem()
282 {
283 if (!$this->checkPermissionBool("write")) {
284 return;
285 }
286
287 $it = new ilSkillTemplateCategory();
288 $it->setTitle($this->form->getInput("title"));
289 $it->setDescription($this->form->getInput("description"));
290 $it->setOrderNr($this->form->getInput("order_nr"));
291 $it->create();
292 ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
293 }
294
298 public function updateItem()
299 {
300 if (!$this->checkPermissionBool("write")) {
301 return;
302 }
303
304 $this->node_object->setTitle($this->form->getInput("title"));
305 $this->node_object->setDescription($this->form->getInput("description"));
306 $this->node_object->setOrderNr($this->form->getInput("order_nr"));
307 $this->node_object->setSelfEvaluation($_POST["self_eval"]);
308 $this->node_object->update();
309 }
310
314 public function afterSave()
315 {
316 $this->redirectToParent(true);
317 }
318
322 public function showUsage()
323 {
325
326 // (a) referenced skill template category in main tree
327 if ($this->tref_id > 0) {
328 return parent::showUsage();
329 }
330
331 // (b) skill template category in templates view
332
333 $this->setTabs("usage");
334
335 include_once("./Services/Skill/classes/class.ilSkillUsage.php");
336 $usage_info = new ilSkillUsage();
337 $usages = $usage_info->getAllUsagesOfTemplate((int) $_GET["obj_id"]);
338
339 $html = "";
340 include_once("./Services/Skill/classes/class.ilSkillUsageTableGUI.php");
341 foreach ($usages as $k => $usage) {
342 $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
343 $html .= $tab->getHTML() . "<br/><br/>";
344 }
345
346 $tpl->setContent($html);
347 }
348}
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_LAST_NODE
Definition: class.ilTree.php:4
Skill template category GUI class.
__construct($a_node_id=0, $a_tref_id)
Constructor.
static addCreationButtons()
Add creation buttons.
Basic GUI class for skill tree nodes.
redirectToParent($a_tmp_mode=false)
Redirect to parent (identified by current obj_id)
setSkillNodeDescription()
Set skill node description.
addUsageTab($a_tabs)
Add usage tab.
checkPermissionBool($a_perm)
Check permission pool.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
Put this object into the skill tree.
TableGUI class for skill usages.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
help()
Definition: help.php:2
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46