ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSkillLevelTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Table/classes/class.ilTable2GUI.php");
6 include_once("./Services/Link/classes/class.ilLink.php");
7 
17 {
18 
22  function __construct($a_skill_id, $a_parent_obj, $a_parent_cmd, $a_tref_id = 0)
23  {
24  global $ilCtrl, $lng, $ilAccess, $lng;
25 
26  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
27  $this->skill_id = $a_skill_id;
28  $this->skill = new ilBasicSkill($a_skill_id);
29  $this->tref_id = $a_tref_id;
30 
31  parent::__construct($a_parent_obj, $a_parent_cmd);
32  $this->setLimit(9999);
33  $this->setData($this->getSkillLevelData());
34  $this->setTitle($lng->txt("skmg_skill_levels"));
35  if ($this->tref_id == 0)
36  {
37  $this->setDescription($lng->txt("skmg_from_lower_to_higher_levels"));
38  }
39 
40  if ($this->tref_id == 0)
41  {
42  $this->addColumn("", "", "1", true);
43  $this->addColumn($this->lng->txt("skmg_nr"));
44  }
45  $this->addColumn($this->lng->txt("title"));
46  $this->addColumn($this->lng->txt("description"));
47 // $this->addColumn($this->lng->txt("skmg_trigger"));
48 // $this->addColumn($this->lng->txt("skmg_certificate"))
49  $this->addColumn($this->lng->txt("resources"));
50  $this->addColumn($this->lng->txt("actions"));
51  $this->setDefaultOrderField("nr");
52  $this->setDefaultOrderDirection("asc");
53 
54  $this->setEnableHeader(true);
55  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
56  $this->setRowTemplate("tpl.skill_level_row.html", "Services/Skill");
57  $this->setEnableTitle(true);
58 
59  if ($a_parent_obj->checkPermissionBool("write"))
60  {
61  if ($this->tref_id == 0)
62  {
63  $this->addMultiCommand("confirmLevelDeletion", $lng->txt("delete"));
64  if (count($this->getData()) > 0)
65  {
66  $this->addCommandButton("updateLevelOrder", $lng->txt("skmg_update_order"));
67  }
68  }
69  }
70  }
71 
77  function numericOrdering($a_field)
78  {
79  if ($a_field == "nr")
80  {
81  return true;
82  }
83  return false;
84  }
85 
92  function getSkillLevelData()
93  {
94  $levels = $this->skill->getLevelData();
95 
96  // add ressource data
97  $res = array();
98  include_once("./Services/Skill/classes/class.ilSkillResources.php");
99  $resources = new ilSkillResources($this->skill_id, $this->tref_id);
100  foreach($resources->getResources() as $level_id => $item)
101  {
102  $res[$level_id] = array_keys($item);
103  }
104 
105  foreach($levels as $idx => $item)
106  {
107  $levels[$idx]["ressources"] = $res[$item["id"]];
108  }
109 
110  return $levels;
111  }
112 
116  protected function fillRow($a_set)
117  {
118  global $lng, $ilCtrl;
119 
120  if ($this->tref_id == 0)
121  {
122  $this->tpl->setCurrentBlock("cb");
123  $this->tpl->setVariable("CB_ID", $a_set["id"]);
124  $this->tpl->parseCurrentBlock();
125 
126  $this->tpl->setCurrentBlock("nr");
127  $this->tpl->setVariable("ORD_ID", $a_set["id"]);
128  $this->tpl->setVariable("VAL_NR", ((int) $a_set["nr"]) * 10);
129  $this->tpl->parseCurrentBlock();
130 
131  }
132 
133  $this->tpl->setCurrentBlock("cmd");
134  $this->tpl->setVariable("TXT_CMD", $lng->txt("edit"));
135  $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
136  if ($this->tref_id == 0)
137  {
138  $this->tpl->setVariable("HREF_CMD",
139  $ilCtrl->getLinkTarget($this->parent_obj, "editLevel"));
140  }
141  else
142  {
143  $this->tpl->setVariable("HREF_CMD",
144  $ilCtrl->getLinkTarget($this->parent_obj, "showLevelResources"));
145  }
146  $this->tpl->parseCurrentBlock();
147 
148  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
149  $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
150 /* $this->tpl->setVariable("TXT_CERTIFICATE",
151  ilBasicSkill::_lookupCertificate($this->skill->getId(),
152  $a_set["id"])
153  ? $lng->txt("yes")
154  : $lng->txt("no"));*/
155 
156 /* $trigger = ilBasicSkill::lookupLevelTrigger((int) $a_set["id"]);
157  if (ilObject::_lookupType($trigger["obj_id"]) != "crs" ||
158  ilObject::_isInTrash($trigger["ref_id"]))
159  {
160  $trigger = array();
161  }
162 
163  // trigger
164  if ($trigger["obj_id"] > 0)
165  {
166  $this->tpl->setVariable("TXT_TRIGGER",
167  ilObject::_lookupTitle($trigger["obj_id"]));
168  }*/
169 
170  if(is_array($a_set["ressources"]))
171  {
172  $this->tpl->setCurrentBlock("ressource_bl");
173  foreach($a_set["ressources"] as $rref_id)
174  {
175  $robj_id = ilObject::_lookupObjId($rref_id);
176  $this->tpl->setVariable("RSRC_IMG", ilUtil::img(ilObject::_getIcon($robj_id, "tiny")));
177  $this->tpl->setVariable("RSRC_TITLE", ilObject::_lookupTitle($robj_id));
178  $this->tpl->setVariable("RSRC_URL", ilLink::_getStaticLink($rref_id));
179  $this->tpl->parseCurrentBlock();
180  }
181  }
182  }
183 
184 }
185 ?>
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setDescription($a_val)
Set description.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
static _lookupTitle($a_id)
lookup object title
fillRow($a_set)
Fill table row.
__construct($a_skill_id, $a_parent_obj, $a_parent_cmd, $a_tref_id=0)
Constructor.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
numericOrdering($a_field)
Should this field be sorted numeric?
static _lookupObjId($a_id)
Manages resources for skills.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
getSkillLevelData()
Get skill level data.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
global $lng
Definition: privfeed.php:40
setEnableHeader($a_enableheader)
Set Enable Header.
setEnableTitle($a_enabletitle)
Set Enable Title.
Basic Skill.
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.
setLimit($a_limit=0, $a_default_limit=0)