ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 {
21  protected $in_use = false;
22 
26  function __construct($a_skill_id, $a_parent_obj, $a_parent_cmd, $a_tref_id = 0, $a_in_use = false)
27  {
28  global $ilCtrl, $lng, $ilAccess, $lng;
29 
30  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
31  $this->skill_id = $a_skill_id;
32  $this->skill = new ilBasicSkill($a_skill_id);
33  $this->tref_id = $a_tref_id;
34  $this->in_use = $a_in_use;
35 
36  parent::__construct($a_parent_obj, $a_parent_cmd);
37  $this->setLimit(9999);
38  $this->setData($this->getSkillLevelData());
39  $this->setTitle($lng->txt("skmg_skill_levels"));
40  if ($this->tref_id == 0)
41  {
42  $this->setDescription($lng->txt("skmg_from_lower_to_higher_levels"));
43  }
44 
45  if ($this->tref_id == 0 && !$this->in_use)
46  {
47  $this->addColumn("", "", "1", true);
48  $this->addColumn($this->lng->txt("skmg_nr"));
49  }
50  $this->addColumn($this->lng->txt("title"));
51  $this->addColumn($this->lng->txt("description"));
52 // $this->addColumn($this->lng->txt("skmg_trigger"));
53 // $this->addColumn($this->lng->txt("skmg_certificate"))
54  $this->addColumn($this->lng->txt("resources"));
55  $this->addColumn($this->lng->txt("actions"));
56  $this->setDefaultOrderField("nr");
57  $this->setDefaultOrderDirection("asc");
58 
59  $this->setEnableHeader(true);
60  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
61  $this->setRowTemplate("tpl.skill_level_row.html", "Services/Skill");
62  $this->setEnableTitle(true);
63 
64  if ($this->tref_id == 0 && !$this->in_use && $a_parent_obj->checkPermissionBool("write"))
65  {
66  $this->addMultiCommand("confirmLevelDeletion", $lng->txt("delete"));
67  if (count($this->getData()) > 0)
68  {
69  $this->addCommandButton("updateLevelOrder", $lng->txt("skmg_update_order"));
70  }
71  }
72  }
73 
79  function numericOrdering($a_field)
80  {
81  if ($a_field == "nr")
82  {
83  return true;
84  }
85  return false;
86  }
87 
94  function getSkillLevelData()
95  {
96  $levels = $this->skill->getLevelData();
97 
98  // add ressource data
99  $res = array();
100  include_once("./Services/Skill/classes/class.ilSkillResources.php");
101  $resources = new ilSkillResources($this->skill_id, $this->tref_id);
102  foreach($resources->getResources() as $level_id => $item)
103  {
104  $res[$level_id] = array_keys($item);
105  }
106 
107  foreach($levels as $idx => $item)
108  {
109  $levels[$idx]["ressources"] = $res[$item["id"]];
110  }
111 
112  return $levels;
113  }
114 
118  protected function fillRow($a_set)
119  {
120  global $lng, $ilCtrl;
121 
122  if ($this->tref_id == 0 && !$this->in_use)
123  {
124  $this->tpl->setCurrentBlock("cb");
125  $this->tpl->setVariable("CB_ID", $a_set["id"]);
126  $this->tpl->parseCurrentBlock();
127 
128  $this->tpl->setCurrentBlock("nr");
129  $this->tpl->setVariable("ORD_ID", $a_set["id"]);
130  $this->tpl->setVariable("VAL_NR", ((int) $a_set["nr"]) * 10);
131  $this->tpl->parseCurrentBlock();
132 
133  }
134 
135  $this->tpl->setCurrentBlock("cmd");
136  $this->tpl->setVariable("TXT_CMD", $lng->txt("edit"));
137  $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
138  if ($this->tref_id == 0)
139  {
140  $this->tpl->setVariable("HREF_CMD",
141  $ilCtrl->getLinkTarget($this->parent_obj, "editLevel"));
142  }
143  else
144  {
145  $this->tpl->setVariable("HREF_CMD",
146  $ilCtrl->getLinkTarget($this->parent_obj, "showLevelResources"));
147  }
148  $this->tpl->parseCurrentBlock();
149 
150  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
151  $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
152 /* $this->tpl->setVariable("TXT_CERTIFICATE",
153  ilBasicSkill::_lookupCertificate($this->skill->getId(),
154  $a_set["id"])
155  ? $lng->txt("yes")
156  : $lng->txt("no"));*/
157 
158 /* $trigger = ilBasicSkill::lookupLevelTrigger((int) $a_set["id"]);
159  if (ilObject::_lookupType($trigger["obj_id"]) != "crs" ||
160  ilObject::_isInTrash($trigger["ref_id"]))
161  {
162  $trigger = array();
163  }
164 
165  // trigger
166  if ($trigger["obj_id"] > 0)
167  {
168  $this->tpl->setVariable("TXT_TRIGGER",
169  ilObject::_lookupTitle($trigger["obj_id"]));
170  }*/
171 
172  if(is_array($a_set["ressources"]))
173  {
174  $this->tpl->setCurrentBlock("ressource_bl");
175  foreach($a_set["ressources"] as $rref_id)
176  {
177  $robj_id = ilObject::_lookupObjId($rref_id);
178  $this->tpl->setVariable("RSRC_IMG", ilUtil::img(ilObject::_getIcon($robj_id, "tiny")));
179  $this->tpl->setVariable("RSRC_TITLE", ilObject::_lookupTitle($robj_id));
180  $this->tpl->setVariable("RSRC_URL", ilLink::_getStaticLink($rref_id));
181  $this->tpl->parseCurrentBlock();
182  }
183  }
184  }
185 
186 }
187 ?>
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.
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.
Create styles array
The data for the language used.
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:17
setEnableHeader($a_enableheader)
Set Enable Header.
__construct($a_skill_id, $a_parent_obj, $a_parent_cmd, $a_tref_id=0, $a_in_use=false)
Constructor.
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)