ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 {
20  protected $user;
21 
25  protected $ctrl;
26 
27 
31  public function __construct(
32  $a_parent_obj,
33  $a_parent_cmd,
34  $a_top_skill_id,
35  $a_tref_id,
36  $a_basic_skill_id
37  ) {
38  global $DIC;
39 
40  $this->user = $DIC->user();
41  $this->lng = $DIC->language();
42  $this->ctrl = $DIC->ctrl();
43  $ilUser = $DIC->user();
44 
45  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
46  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
47  $this->ws_tree = new ilWorkspaceTree($ilUser->getId());
48  if (!$this->ws_tree->getRootId()) {
49  $this->ws_tree->createTreeForUser($ilUser->getId());
50  }
51  $this->ws_access = new ilWorkspaceAccessHandler();
52 
53  $this->top_skill_id = $a_top_skill_id;
54  $this->tref_id = (int) $a_tref_id;
55  $this->basic_skill_id = $a_basic_skill_id;
56 
57 
58  // build title
59  include_once("./Services/Skill/classes/class.ilSkillTree.php");
60  $stree = new ilSkillTree();
61  $path = $stree->getPathFull($this->basic_skill_id);
62  $title = $sep = "";
63  foreach ($path as $p) {
64  if ($p["type"] != "skrt") {
65  $title .= $sep . $p["title"];
66  $sep = " > ";
67  }
68  }
69 
70  parent::__construct($a_parent_obj, $a_parent_cmd);
71  $this->setData($this->getLevels());
72  $this->setTitle($title);
73  $this->setLimit(9999);
74 
75  $this->addColumn($this->lng->txt("skmg_skill_level"));
76  $this->addColumn($this->lng->txt("description"));
77  $this->addColumn($this->lng->txt("skmg_materials"));
78  $this->addColumn($this->lng->txt("actions"));
79 
80  $this->setEnableHeader(true);
81  // $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
82  $this->setRowTemplate("tpl.skill_materials_row.html", "Services/Skill");
83  $this->disable("footer");
84  $this->setEnableTitle(true);
85 
86  // $this->addMultiCommand("", $lng->txt(""));
87 // $this->addCommandButton("", $lng->txt(""));
88  }
89 
96  public function getLevels()
97  {
98  include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
99  $this->skill = ilSkillTreeNodeFactory::getInstance($this->basic_skill_id);
100  foreach ($this->skill->getLevelData() as $k => $v) {
101  $levels[] = $v;
102  }
103 
104  return $levels;
105  }
106 
110  protected function fillRow($a_set)
111  {
112  $lng = $this->lng;
115 
116  include_once("./Services/Skill/classes/class.ilPersonalSkill.php");
117  $mat = ilPersonalSkill::getAssignedMaterial($ilUser->getId(), $this->tref_id, $a_set["id"]);
118  $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
119  foreach ($mat as $m) {
120  $this->tpl->setCurrentBlock("mat");
121  $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
122  $this->tpl->setVariable(
123  "MAT_TITLE",
124  ilObject::_lookupTitle($obj_id)
125  );
126  $this->tpl->setVariable(
127  "MAT_IMG",
128  ilUtil::img(ilUtil::getImagePath("icon_" . ilObject::_lookupType($obj_id) . ".svg"))
129  );
130  $this->tpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
131  $ilCtrl->setParameter($this->parent_obj, "wsp_id", $m["wsp_id"]);
132  $this->tpl->setVariable("HREF_REMOVE", $ilCtrl->getLinkTarget($this->parent_obj, "removeMaterial"));
133 
134  $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
135  $url = $this->ws_access->getGotoLink($m["wsp_id"], $obj_id);
136  $this->tpl->setVariable("HREF_MAT", $url);
137  $this->tpl->parseCurrentBlock();
138  }
139 
140  $this->tpl->setCurrentBlock("cmd");
141  $this->tpl->setVariable("HREF_CMD", $ilCtrl->getLinkTarget(
142  $this->parent_obj,
143  "assignMaterial"
144  ));
145  $this->tpl->setVariable("TXT_CMD", $lng->txt("skmg_assign_materials"));
146  $this->tpl->parseCurrentBlock();
147  $ilCtrl->setParameter($this->parent_obj, "level_id", "");
148 
149  $this->tpl->setVariable("LEVEL_ID", $a_set["id"]);
150  $this->tpl->setVariable("SKILL_ID", $this->basic_skill_id);
151  $this->tpl->setVariable("TXT_SKILL", $a_set["title"]);
152  $this->tpl->setVariable("TXT_SKILL_DESC", $a_set["description"]);
153  }
154 }
$path
Definition: aliased.php:25
createTreeForUser($a_user_id)
Create personal workspace tree for user.
global $DIC
Definition: saml.php:7
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.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$ilUser
Definition: imgupload.php:18
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
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
setEnableTitle($a_enabletitle)
Set Enable Title.
setLimit($a_limit=0, $a_default_limit=0)