ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSkillAssignMaterialsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Table/classes/class.ilTable2GUI.php");
6 
16 {
17 
21  function __construct($a_parent_obj, $a_parent_cmd, $a_top_skill_id, $a_tref_id,
22  $a_basic_skill_id)
23  {
24  global $ilUser;
25 
26  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
27  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
28  $this->ws_tree = new ilWorkspaceTree($ilUser->getId());
29  $this->ws_access = new ilWorkspaceAccessHandler();
30 
31  $this->top_skill_id = $a_top_skill_id;
32  $this->tref_id = (int) $a_tref_id;
33  $this->basic_skill_id = $a_basic_skill_id;
34 
35  // workspace tree
36  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
37  $this->ws_tree = new ilWorkspaceTree($ilUser->getId());
38 
39 
40  // build title
41  include_once("./Services/Skill/classes/class.ilSkillTree.php");
42  $stree = new ilSkillTree();
43  $path = $stree->getPathFull($this->basic_skill_id);
44  $title = $sep = "";
45  foreach ($path as $p)
46  {
47  if ($p["type"] != "skrt")
48  {
49  $title.= $sep.$p["title"];
50  $sep = " > ";
51  }
52  }
53 
54  parent::__construct($a_parent_obj, $a_parent_cmd);
55  $this->setData($this->getLevels());
56  $this->setTitle($title);
57  $this->setLimit(9999);
58 
59  $this->addColumn($this->lng->txt("skmg_skill_level"));
60  $this->addColumn($this->lng->txt("description"), "", "60%");
61  $this->addColumn($this->lng->txt("skmg_materials"));
62  $this->addColumn($this->lng->txt("actions"));
63 
64  $this->setEnableHeader(true);
65 // $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
66  $this->setRowTemplate("tpl.skill_materials_row.html", "Services/Skill");
67  $this->disable("footer");
68  $this->setEnableTitle(true);
69 
70 // $this->addMultiCommand("", $lng->txt(""));
71 // $this->addCommandButton("", $lng->txt(""));
72  }
73 
80  function getLevels()
81  {
82  include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
83  $this->skill = ilSkillTreeNodeFactory::getInstance($this->basic_skill_id);
84  foreach ($this->skill->getLevelData() as $k => $v)
85  {
86  $levels[] = $v;
87  }
88 
89  return $levels;
90  }
91 
95  protected function fillRow($a_set)
96  {
97  global $lng, $ilCtrl, $ilUser;
98 
99  include_once("./Services/Skill/classes/class.ilPersonalSkill.php");
100  $mat = ilPersonalSkill::getAssignedMaterial($ilUser->getId(), $this->tref_id, $a_set["id"]);
101  $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
102  foreach ($mat as $m)
103  {
104  $this->tpl->setCurrentBlock("mat");
105  $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
106  $this->tpl->setVariable("MAT_TITLE",
107  ilObject::_lookupTitle($obj_id));
108  $this->tpl->setVariable("MAT_IMG",
109  ilUtil::img(ilUtil::getImagePath("icon_".ilObject::_lookupType($obj_id).".svg")));
110  $this->tpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
111  $ilCtrl->setParameter($this->parent_obj, "wsp_id", $m["wsp_id"]);
112  $this->tpl->setVariable("HREF_REMOVE", $ilCtrl->getLinkTarget($this->parent_obj, "removeMaterial"));
113 
114  $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
115  $url = $this->ws_access->getGotoLink($m["wsp_id"], $obj_id);
116  $this->tpl->setVariable("HREF_MAT", $url);
117  $this->tpl->parseCurrentBlock();
118  }
119 
120  $this->tpl->setCurrentBlock("cmd");
121  $this->tpl->setVariable("HREF_CMD", $ilCtrl->getLinkTarget($this->parent_obj,
122  "assignMaterial"));
123  $this->tpl->setVariable("TXT_CMD", $lng->txt("skmg_assign_materials"));
124  $this->tpl->parseCurrentBlock();
125  $ilCtrl->setParameter($this->parent_obj, "level_id", "");
126 
127  $this->tpl->setVariable("LEVEL_ID", $a_set["id"]);
128  $this->tpl->setVariable("SKILL_ID", $this->basic_skill_id);
129  $this->tpl->setVariable("TXT_SKILL", $a_set["title"]);
130  $this->tpl->setVariable("TXT_SKILL_DESC", $a_set["description"]);
131  }
132 
133 }
134 ?>