ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSkillAssignMaterialsTableGUI.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 
11 {
15  protected $user;
16 
20  protected $ctrl;
21 
22 
26  public function __construct(
27  $a_parent_obj,
28  $a_parent_cmd,
29  $a_top_skill_id,
30  $a_tref_id,
31  $a_basic_skill_id
32  ) {
33  global $DIC;
34 
35  $this->user = $DIC->user();
36  $this->lng = $DIC->language();
37  $this->ctrl = $DIC->ctrl();
38  $ilUser = $DIC->user();
39 
40  $this->ws_tree = new ilWorkspaceTree($ilUser->getId());
41  if (!$this->ws_tree->getRootId()) {
42  $this->ws_tree->createTreeForUser($ilUser->getId());
43  }
44  $this->ws_access = new ilWorkspaceAccessHandler();
45 
46  $this->top_skill_id = $a_top_skill_id;
47  $this->tref_id = (int) $a_tref_id;
48  $this->basic_skill_id = $a_basic_skill_id;
49 
50 
51  // build title
52  $stree = new ilSkillTree();
53  $path = $stree->getPathFull($this->basic_skill_id);
54  $title = $sep = "";
55  foreach ($path as $p) {
56  if ($p["type"] != "skrt") {
57  $title .= $sep . $p["title"];
58  $sep = " > ";
59  }
60  }
61 
62  parent::__construct($a_parent_obj, $a_parent_cmd);
63  $this->setData($this->getLevels());
64  $this->setTitle($title);
65  $this->setLimit(9999);
66 
67  $this->addColumn($this->lng->txt("skmg_skill_level"));
68  $this->addColumn($this->lng->txt("description"));
69  $this->addColumn($this->lng->txt("skmg_materials"));
70  $this->addColumn($this->lng->txt("actions"));
71 
72  $this->setEnableHeader(true);
73  // $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
74  $this->setRowTemplate("tpl.skill_materials_row.html", "Services/Skill");
75  $this->disable("footer");
76  $this->setEnableTitle(true);
77 
78  // $this->addMultiCommand("", $lng->txt(""));
79 // $this->addCommandButton("", $lng->txt(""));
80  }
81 
88  public function getLevels()
89  {
90  $this->skill = ilSkillTreeNodeFactory::getInstance($this->basic_skill_id);
91  foreach ($this->skill->getLevelData() as $k => $v) {
92  $levels[] = $v;
93  }
94 
95  return $levels;
96  }
97 
101  protected function fillRow($a_set)
102  {
103  $lng = $this->lng;
104  $ilCtrl = $this->ctrl;
106 
107  $mat = ilPersonalSkill::getAssignedMaterial($ilUser->getId(), $this->tref_id, $a_set["id"]);
108  $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
109  foreach ($mat as $m) {
110  $this->tpl->setCurrentBlock("mat");
111  $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
112  $this->tpl->setVariable(
113  "MAT_TITLE",
114  ilObject::_lookupTitle($obj_id)
115  );
116  $this->tpl->setVariable(
117  "MAT_IMG",
118  ilUtil::img(ilUtil::getImagePath("icon_" . ilObject::_lookupType($obj_id) . ".svg"))
119  );
120  $this->tpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
121  $ilCtrl->setParameter($this->parent_obj, "wsp_id", $m["wsp_id"]);
122  $this->tpl->setVariable("HREF_REMOVE", $ilCtrl->getLinkTarget($this->parent_obj, "removeMaterial"));
123 
124  $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
125  $url = $this->ws_access->getGotoLink($m["wsp_id"], $obj_id);
126  $this->tpl->setVariable("HREF_MAT", $url);
127  $this->tpl->parseCurrentBlock();
128  }
129 
130  $this->tpl->setCurrentBlock("cmd");
131  $this->tpl->setVariable("HREF_CMD", $ilCtrl->getLinkTarget(
132  $this->parent_obj,
133  "assignMaterial"
134  ));
135  $this->tpl->setVariable("TXT_CMD", $lng->txt("skmg_assign_materials"));
136  $this->tpl->parseCurrentBlock();
137  $ilCtrl->setParameter($this->parent_obj, "level_id", "");
138 
139  $this->tpl->setVariable("LEVEL_ID", $a_set["id"]);
140  $this->tpl->setVariable("SKILL_ID", $this->basic_skill_id);
141  $this->tpl->setVariable("TXT_SKILL", $a_set["title"]);
142  $this->tpl->setVariable("TXT_SKILL_DESC", $a_set["description"]);
143  }
144 }
createTreeForUser($a_user_id)
Create personal workspace tree for user.
Skill tree.
Access handler for personal workspace.
static _lookupTitle($a_id)
lookup object title
Assign materials to skill levels table.
user()
Definition: user.php:4
Tree handler for personal workspace.
__construct( $a_parent_obj, $a_parent_cmd, $a_top_skill_id, $a_tref_id, $a_basic_skill_id)
Constructor.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: goto.php:24
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getAssignedMaterial($a_user_id, $a_tref_id, $a_level)
Get assigned material (for a skill level and user)
disable($a_module_name)
diesables particular modules of table
__construct(Container $dic, ilPlugin $plugin)
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setEnableHeader($a_enableheader)
Set Enable Header.
$url
$ilUser
Definition: imgupload.php:18
setEnableTitle($a_enabletitle)
Set Enable Title.
setLimit($a_limit=0, $a_default_limit=0)