ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSkillTemplateCategoryGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
16  protected $ctrl;
17 
21  protected $tpl;
22 
26  protected $tabs;
27 
31  protected $lng;
32 
36  protected $help;
37 
38 
42  public function __construct($a_node_id = 0, $a_tref_id)
43  {
44  global $DIC;
45 
46  $this->ctrl = $DIC->ctrl();
47  $this->tpl = $DIC["tpl"];
48  $this->tabs = $DIC->tabs();
49  $this->lng = $DIC->language();
50  $this->help = $DIC["ilHelp"];
51  $ilCtrl = $DIC->ctrl();
52 
53  $ilCtrl->saveParameter($this, "obj_id");
54  $this->tref_id = $a_tref_id;
55 
56  parent::__construct($a_node_id);
57  }
58 
62  public function getType()
63  {
64  return "sctp";
65  }
66 
70  public function executeCommand()
71  {
72  $ilCtrl = $this->ctrl;
73  $tpl = $this->tpl;
74  $ilTabs = $this->tabs;
75 
76  //$tpl->getStandardTemplate();
77 
78  $next_class = $ilCtrl->getNextClass($this);
79  $cmd = $ilCtrl->getCmd();
80 
81  switch ($next_class) {
82  default:
83  $ret = $this->$cmd();
84  break;
85  }
86  }
87 
91  public function setTabs($a_tab)
92  {
93  $ilTabs = $this->tabs;
94  $ilCtrl = $this->ctrl;
95  $tpl = $this->tpl;
96  $lng = $this->lng;
97  $ilHelp = $this->help;
98 
99  $ilTabs->clearTargets();
100  $ilHelp->setScreenIdComponent("skmg_sctp");
101 
102  // content
103  $ilTabs->addTab(
104  "content",
105  $lng->txt("content"),
106  $ilCtrl->getLinkTarget($this, 'listItems')
107  );
108 
109 
110  // properties
111  if ($this->tref_id == 0) {
112  $ilTabs->addTab(
113  "properties",
114  $lng->txt("settings"),
115  $ilCtrl->getLinkTarget($this, 'editProperties')
116  );
117  }
118 
119  // usage
120  $this->addUsageTab($ilTabs);
121 
122  // back link
123  if ($this->tref_id == 0) {
124  $ilCtrl->setParameterByClass(
125  "ilskillrootgui",
126  "obj_id",
127  $this->node_object->skill_tree->getRootId()
128  );
129  $ilTabs->setBackTarget(
130  $lng->txt("skmg_skill_templates"),
131  $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listTemplates")
132  );
133  $ilCtrl->setParameterByClass(
134  "ilskillrootgui",
135  "obj_id",
136  $_GET["obj_id"]
137  );
138  }
139 
140  parent::setTitleIcon();
141  $tpl->setTitle(
142  $lng->txt("skmg_sctp") . ": " . $this->node_object->getTitle()
143  );
144  $this->setSkillNodeDescription();
145 
146  $ilTabs->activateTab($a_tab);
147  }
148 
154  public function initForm($a_mode = "edit")
155  {
156  $r = parent::initForm($a_mode);
157  if ($a_mode == "create") {
158  $ni = $this->form->getItemByPostVar("order_nr");
159  $tree = new ilSkillTree();
160  $max = $tree->getMaxOrderNr((int) $_GET["obj_id"], true);
161  $ni->setValue($max + 10);
162  }
163  return $r;
164  }
165 
172  public function listItems()
173  {
174  $tpl = $this->tpl;
175  $lng = $this->lng;
176 
177  if ($this->isInUse()) {
178  ilUtil::sendInfo($lng->txt("skmg_skill_in_use"));
179  }
180 
181  if ($this->checkPermissionBool("write")) {
182  if ($this->tref_id == 0) {
183  self::addCreationButtons();
184  }
185  }
186 
187  $this->setTabs("content");
188 
189  $table = new ilSkillCatTableGUI(
190  $this,
191  "listItems",
192  (int) $_GET["obj_id"],
194  $this->tref_id
195  );
196 
197  $tpl->setContent($table->getHTML());
198  }
199 
206  public static function addCreationButtons()
207  {
208  global $DIC;
209 
210  $ilCtrl = $DIC->ctrl();
211  $lng = $DIC->language();
212  $ilToolbar = $DIC->toolbar();
213  $ilUser = $DIC->user();
214 
215  $ilCtrl->setParameterByClass("ilobjskillmanagementgui", "tmpmode", 1);
216 
217  $ilCtrl->setParameterByClass(
218  "ilbasicskilltemplategui",
219  "obj_id",
220  (int) $_GET["obj_id"]
221  );
222  $ilToolbar->addButton(
223  $lng->txt("skmg_create_skill_template"),
224  $ilCtrl->getLinkTargetByClass("ilbasicskilltemplategui", "create")
225  );
226  $ilCtrl->setParameterByClass(
227  "ilskilltemplatecategorygui",
228  "obj_id",
229  (int) $_GET["obj_id"]
230  );
231  $ilToolbar->addButton(
232  $lng->txt("skmg_create_skill_template_category"),
233  $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "create")
234  );
235 
236  // skill templates from clipboard
237  $sep = false;
238  if ($ilUser->clipboardHasObjectsOfType("sktp")) {
239  $ilToolbar->addSeparator();
240  $sep = true;
241  $ilToolbar->addButton(
242  $lng->txt("skmg_insert_skill_template_from_clip"),
243  $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "insertSkillTemplateClip")
244  );
245  }
246 
247  // template categories from clipboard
248  if ($ilUser->clipboardHasObjectsOfType("sctp")) {
249  if (!$sep) {
250  $ilToolbar->addSeparator();
251  $sep = true;
252  }
253  $ilToolbar->addButton(
254  $lng->txt("skmg_insert_template_category_from_clip"),
255  $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "insertTemplateCategoryClip")
256  );
257  }
258  }
259 
263  public function editProperties()
264  {
265  $this->setTabs("properties");
266  parent::editProperties();
267  }
268 
269 
273  public function saveItem()
274  {
275  if (!$this->checkPermissionBool("write")) {
276  return;
277  }
278 
279  $it = new ilSkillTemplateCategory();
280  $it->setTitle($this->form->getInput("title"));
281  $it->setDescription($this->form->getInput("description"));
282  $it->setOrderNr($this->form->getInput("order_nr"));
283  $it->create();
284  ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
285  }
286 
290  public function updateItem()
291  {
292  if (!$this->checkPermissionBool("write")) {
293  return;
294  }
295 
296  $this->node_object->setTitle($this->form->getInput("title"));
297  $this->node_object->setDescription($this->form->getInput("description"));
298  $this->node_object->setOrderNr($this->form->getInput("order_nr"));
299  $this->node_object->setSelfEvaluation($_POST["self_eval"]);
300  $this->node_object->update();
301  }
302 
306  public function afterSave()
307  {
308  $this->redirectToParent(true);
309  }
310 
314  public function showUsage()
315  {
316  $tpl = $this->tpl;
317 
318  // (a) referenced skill template category in main tree
319  if ($this->tref_id > 0) {
320  return parent::showUsage();
321  }
322 
323  // (b) skill template category in templates view
324 
325  $this->setTabs("usage");
326 
327  $usage_info = new ilSkillUsage();
328  $usages = $usage_info->getAllUsagesOfTemplate((int) $_GET["obj_id"]);
329 
330  $html = "";
331  foreach ($usages as $k => $usage) {
332  $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
333  $html .= $tab->getHTML() . "<br/><br/>";
334  }
335 
336  $tpl->setContent($html);
337  }
338 }
redirectToParent($a_tmp_mode=false)
Redirect to parent (identified by current obj_id)
addUsageTab($a_tabs)
Add usage tab.
__construct($a_node_id=0, $a_tref_id)
Constructor.
setSkillNodeDescription()
Set skill node description.
Skill tree.
$_GET["client_id"]
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
Put this object into the skill tree.
checkPermissionBool($a_perm)
Check permission pool.
help()
Definition: help.php:2
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Basic GUI class for skill tree nodes.
global $DIC
Definition: goto.php:24
TableGUI class for skill usages.
Skill template category GUI class.
const IL_LAST_NODE
Definition: class.ilTree.php:4
static addCreationButtons()
Add creation buttons.
__construct(Container $dic, ilPlugin $plugin)
$ret
Definition: parser.php:6
$ilUser
Definition: imgupload.php:18
Skill usage.
$_POST["username"]