ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSkillRootGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
23 
31 {
32  protected ilCtrl $ctrl;
34  protected ilTabsGUI $tabs;
36  protected ilLanguage $lng;
37 
38  public function __construct(Node\SkillTreeNodeManager $node_manager, int $a_node_id = 0)
39  {
40  global $DIC;
41 
42  $this->ctrl = $DIC->ctrl();
43  $this->tpl = $DIC["tpl"];
44  $this->tabs = $DIC->tabs();
45  $this->toolbar = $DIC->toolbar();
46  $this->lng = $DIC->language();
47  $ilCtrl = $DIC->ctrl();
48 
49  $ilCtrl->saveParameter($this, "node_id");
50 
51  parent::__construct($node_manager, $a_node_id);
52  }
53 
54  public function getType(): string
55  {
56  return "skrt";
57  }
58 
59  public function executeCommand(): void
60  {
61  $ilCtrl = $this->ctrl;
62  $tpl = $this->tpl;
63  $ilTabs = $this->tabs;
64 
65  $next_class = $ilCtrl->getNextClass($this);
66  $cmd = $ilCtrl->getCmd();
67 
68  switch ($next_class) {
69  default:
70  $ret = $this->$cmd();
71  break;
72  }
73  }
74 
75  public function listTemplates(): void
76  {
77  $tpl = $this->tpl;
78  $ilToolbar = $this->toolbar;
79  $ilCtrl = $this->ctrl;
80  $lng = $this->lng;
81  $ilTabs = $this->tabs;
82 
83  $skmg_set = new ilSetting("skmg");
84  $enable_skmg = $skmg_set->get("enable_skmg");
85  if (!$enable_skmg) {
86  $this->tpl->setOnScreenMessage('info', $lng->txt("skmg_skill_management_deactivated"));
87  }
88 
89  $this->getParentGUI()->showTree(true, $this, "listTemplates");
90  $ilTabs->activateTab("skill_templates");
91 
92  if ($this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
94  }
95 
96  $table = new ilSkillCatTableGUI(
97  $this,
98  "listTemplates",
99  $this->requested_node_id,
101  );
102 
103  $tpl->setContent($table->getHTML());
104  }
105 
106  public function listSkills(): void
107  {
108  $tpl = $this->tpl;
109  $ilToolbar = $this->toolbar;
110  $ilCtrl = $this->ctrl;
111  $lng = $this->lng;
112  $ilTabs = $this->tabs;
113 
114  $skmg_set = new ilSetting("skmg");
115  $enable_skmg = $skmg_set->get("enable_skmg");
116  if (!$enable_skmg) {
117  $this->tpl->setOnScreenMessage('info', $lng->txt("skmg_skill_management_deactivated"));
118  }
119 
120  $this->getParentGUI()->showTree(false, $this, "listSkills");
121  $ilTabs->activateTab("skills");
122 
123  if ($this->tree_access_manager->hasManageCompetencesPermission()) {
125  }
126 
127  $table = new ilSkillCatTableGUI(
128  $this,
129  "listSkills",
130  $this->requested_node_id,
132  );
133 
134  $tpl->setContent($table->getHTML());
135  }
136 
137  public function cancelDelete(): void
138  {
139  $ilCtrl = $this->ctrl;
140 
141  if ($this->requested_tmpmode) {
142  $ilCtrl->redirect($this, "listTemplates");
143  } else {
144  $ilCtrl->redirect($this, "listSkills");
145  }
146  }
147 
148  public function showImportForm(): void
149  {
150  $tpl = $this->tpl;
151  $ilTabs = $this->tabs;
152  $lng = $this->lng;
153  $ctrl = $this->ctrl;
154 
155  $ilTabs->setBackTarget(
156  $lng->txt("back"),
157  $ctrl->getLinkTarget($this, "listSkills")
158  );
159 
160  $ilTabs->activateTab("skills");
161  $tpl->setContent($this->initInputForm()->getHTML());
162  }
163 
164  public function initInputForm(): ilPropertyFormGUI
165  {
166  $lng = $this->lng;
167  $ilCtrl = $this->ctrl;
168 
169  $form = new ilPropertyFormGUI();
170 
171  $fi = new ilFileInputGUI($lng->txt("skmg_input_file"), "import_file");
172  $fi->setSuffixes(array("zip"));
173  $fi->setRequired(true);
174  $form->addItem($fi);
175 
176  // save and cancel commands
177  $form->addCommandButton("importSkills", $lng->txt("import"));
178  $form->addCommandButton("listSkills", $lng->txt("cancel"));
179 
180  $form->setTitle($lng->txt("skmg_import_skills"));
181  $form->setFormAction($ilCtrl->getFormAction($this));
182 
183  return $form;
184  }
185 
186  public function importSkills(): void
187  {
188  $tpl = $this->tpl;
189  $lng = $this->lng;
190  $ilCtrl = $this->ctrl;
191  $ilTabs = $this->tabs;
192 
193  $form = $this->initInputForm();
194  if ($form->checkInput()) {
195  $imp = new ilImport();
196  $conf = $imp->getConfig("Services/Skill");
197  $conf->setSkillTreeId($this->skill_tree_id);
198  $imp->importEntity($_FILES["import_file"]["tmp_name"], $_FILES["import_file"]["name"], "skmg", "Services/Skill");
199 
200  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
201  $ilCtrl->redirect($this, "listSkills");
202  } else {
203  $ilTabs->activateTab("skills");
205  $tpl->setContent($form->getHTML());
206  }
207  }
208 }
ilGlobalTemplateInterface $tpl
Skill root GUI class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
This class represents a file property in a property form.
Import class.
setSuffixes(array $a_suffixes)
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
setContent(string $a_html)
Sets content for standard template.
Basic GUI class for skill tree nodes.
setFormAction(string $a_formaction)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Node\SkillTreeNodeManager $node_manager, int $a_node_id=0)