ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
5 include_once("./Services/Skill/classes/class.ilSkillTreeNodeGUI.php");
6 include_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  {
79  $tpl = $this->tpl;
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;
101  $tpl = $this->tpl;
102  $lng = $this->lng;
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  );
150  $this->setSkillNodeDescription();
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  {
181  $tpl = $this->tpl;
182  $lng = $this->lng;
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) {
190  self::addCreationButtons();
191  }
192  }
193 
194  $this->setTabs("content");
195 
196  include_once("./Services/Skill/classes/class.ilSkillCatTableGUI.php");
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->setOrderNr($this->form->getInput("order_nr"));
290  $it->create();
291  ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
292  }
293 
297  public function updateItem()
298  {
299  if (!$this->checkPermissionBool("write")) {
300  return;
301  }
302 
303  $this->node_object->setTitle($this->form->getInput("title"));
304  $this->node_object->setOrderNr($this->form->getInput("order_nr"));
305  $this->node_object->setSelfEvaluation($_POST["self_eval"]);
306  $this->node_object->update();
307  }
308 
312  public function afterSave()
313  {
314  $this->redirectToParent(true);
315  }
316 
320  public function showUsage()
321  {
322  $tpl = $this->tpl;
323 
324  // (a) referenced skill template category in main tree
325  if ($this->tref_id > 0) {
326  return parent::showUsage();
327  }
328 
329  // (b) skill template category in templates view
330 
331  $this->setTabs("usage");
332 
333  include_once("./Services/Skill/classes/class.ilSkillUsage.php");
334  $usage_info = new ilSkillUsage();
335  $usages = $usage_info->getAllUsagesOfTemplate((int) $_GET["obj_id"]);
336 
337  $html = "";
338  include_once("./Services/Skill/classes/class.ilSkillUsageTableGUI.php");
339  foreach ($usages as $k => $usage) {
340  $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
341  $html .= $tab->getHTML() . "<br/><br/>";
342  }
343 
344  $tpl->setContent($html);
345  }
346 }
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.
global $DIC
Definition: saml.php:7
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.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$r
Definition: example_031.php:79
Basic GUI class for skill tree nodes.
$ilUser
Definition: imgupload.php:18
TableGUI class for skill usages.
Skill template category GUI class.
const IL_LAST_NODE
Definition: class.ilTree.php:4
static addCreationButtons()
Add creation buttons.
$ret
Definition: parser.php:6
if(empty($password)) $table
Definition: pwgen.php:24
Skill usage.
$_POST["username"]
$html
Definition: example_001.php:87