ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
5include_once("./Services/Table/classes/class.ilTable2GUI.php");
6include_once("./Services/Link/classes/class.ilLink.php");
7
17{
21 protected $ctrl;
22
26 protected $access;
27
31 protected $in_use = false;
32
36 public function __construct($a_skill_id, $a_parent_obj, $a_parent_cmd, $a_tref_id = 0, $a_in_use = false)
37 {
38 global $DIC;
39
40 $this->ctrl = $DIC->ctrl();
41 $this->lng = $DIC->language();
42 $this->access = $DIC->access();
43 $ilCtrl = $DIC->ctrl();
44 $lng = $DIC->language();
45 $ilAccess = $DIC->access();
46 $lng = $DIC->language();
47
48 include_once("./Services/Skill/classes/class.ilBasicSkill.php");
49 $this->skill_id = $a_skill_id;
50 $this->skill = new ilBasicSkill($a_skill_id);
51 $this->tref_id = $a_tref_id;
52 $this->in_use = $a_in_use;
53
54 parent::__construct($a_parent_obj, $a_parent_cmd);
55 $this->setLimit(9999);
56 $this->setData($this->getSkillLevelData());
57 $this->setTitle($lng->txt("skmg_skill_levels"));
58 if ($this->tref_id == 0) {
59 $this->setDescription($lng->txt("skmg_from_lower_to_higher_levels"));
60 }
61
62 if ($this->tref_id == 0 && !$this->in_use) {
63 $this->addColumn("", "", "1", true);
64 $this->addColumn($this->lng->txt("skmg_nr"));
65 }
66 $this->addColumn($this->lng->txt("title"));
67 $this->addColumn($this->lng->txt("description"));
68 // $this->addColumn($this->lng->txt("skmg_trigger"));
69 // $this->addColumn($this->lng->txt("skmg_certificate"))
70 $this->addColumn($this->lng->txt("resources"));
71 $this->addColumn($this->lng->txt("actions"));
72 $this->setDefaultOrderField("nr");
73 $this->setDefaultOrderDirection("asc");
74
75 $this->setEnableHeader(true);
76 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
77 $this->setRowTemplate("tpl.skill_level_row.html", "Services/Skill");
78 $this->setEnableTitle(true);
79
80 if ($this->tref_id == 0 && !$this->in_use && $a_parent_obj->checkPermissionBool("write")) {
81 $this->addMultiCommand("confirmLevelDeletion", $lng->txt("delete"));
82 if (count($this->getData()) > 0) {
83 $this->addCommandButton("updateLevelOrder", $lng->txt("skmg_update_order"));
84 }
85 }
86 }
87
93 public function numericOrdering($a_field)
94 {
95 if ($a_field == "nr") {
96 return true;
97 }
98 return false;
99 }
100
107 public function getSkillLevelData()
108 {
109 $levels = $this->skill->getLevelData();
110
111 // add ressource data
112 $res = array();
113 include_once("./Services/Skill/classes/class.ilSkillResources.php");
114 $resources = new ilSkillResources($this->skill_id, $this->tref_id);
115 foreach ($resources->getResources() as $level_id => $item) {
116 $res[$level_id] = array_keys($item);
117 }
118
119 foreach ($levels as $idx => $item) {
120 $levels[$idx]["ressources"] = $res[$item["id"]];
121 }
122
123 return $levels;
124 }
125
129 protected function fillRow($a_set)
130 {
133
134 if ($this->tref_id == 0 && !$this->in_use) {
135 $this->tpl->setCurrentBlock("cb");
136 $this->tpl->setVariable("CB_ID", $a_set["id"]);
137 $this->tpl->parseCurrentBlock();
138
139 $this->tpl->setCurrentBlock("nr");
140 $this->tpl->setVariable("ORD_ID", $a_set["id"]);
141 $this->tpl->setVariable("VAL_NR", ((int) $a_set["nr"]) * 10);
142 $this->tpl->parseCurrentBlock();
143 }
144
145 $this->tpl->setCurrentBlock("cmd");
146 $this->tpl->setVariable("TXT_CMD", $lng->txt("edit"));
147 $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
148 if ($this->tref_id == 0) {
149 $this->tpl->setVariable(
150 "HREF_CMD",
151 $ilCtrl->getLinkTarget($this->parent_obj, "editLevel")
152 );
153 } else {
154 $this->tpl->setVariable(
155 "HREF_CMD",
156 $ilCtrl->getLinkTarget($this->parent_obj, "showLevelResources")
157 );
158 }
159 $this->tpl->parseCurrentBlock();
160
161 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
162 $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
163 /* $this->tpl->setVariable("TXT_CERTIFICATE",
164 ilBasicSkill::_lookupCertificate($this->skill->getId(),
165 $a_set["id"])
166 ? $lng->txt("yes")
167 : $lng->txt("no"));*/
168
169 /* $trigger = ilBasicSkill::lookupLevelTrigger((int) $a_set["id"]);
170 if (ilObject::_lookupType($trigger["obj_id"]) != "crs" ||
171 ilObject::_isInTrash($trigger["ref_id"]))
172 {
173 $trigger = array();
174 }
175
176 // trigger
177 if ($trigger["obj_id"] > 0)
178 {
179 $this->tpl->setVariable("TXT_TRIGGER",
180 ilObject::_lookupTitle($trigger["obj_id"]));
181 }*/
182
183 if (is_array($a_set["ressources"])) {
184 $this->tpl->setCurrentBlock("ressource_bl");
185 foreach ($a_set["ressources"] as $rref_id) {
186 $robj_id = ilObject::_lookupObjId($rref_id);
187 $this->tpl->setVariable("RSRC_IMG", ilUtil::img(ilObject::_getIcon($robj_id, "tiny")));
188 $this->tpl->setVariable("RSRC_TITLE", ilObject::_lookupTitle($robj_id));
189 $this->tpl->setVariable("RSRC_URL", ilLink::_getStaticLink($rref_id));
190 $this->tpl->parseCurrentBlock();
191 }
192 }
193 }
194}
An exception for terminatinating execution or to throw for unit testing.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
__construct($a_skill_id, $a_parent_obj, $a_parent_cmd, $a_tref_id=0, $a_in_use=false)
Constructor.
fillRow($a_set)
Fill table row.
getSkillLevelData()
Get skill level data.
numericOrdering($a_field)
Should this field be sorted numeric?
Manages resources for skills.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setDescription($a_val)
Set description.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
foreach($_POST as $key=> $value) $res
$DIC
Definition: xapitoken.php:46