ILIAS  release_8 Revision v8.24
class.ilSkillLevelTableGUI.php
Go to the documentation of this file.
1<?php
2
27{
29 protected int $skill_id = 0;
31 protected int $tref_id = 0;
32 protected bool $in_use = false;
33 protected bool $manage_perm = false;
34 protected \ILIAS\UI\Factory $ui_fac;
35 protected \ILIAS\UI\Renderer $ui_ren;
36
37 public function __construct(
38 int $a_skill_id,
39 $a_parent_obj,
40 string $a_parent_cmd,
41 int $a_tref_id = 0,
42 bool $a_in_use = false,
43 bool $a_manage_perm = false
44 ) {
45 global $DIC;
46
47 $this->ctrl = $DIC->ctrl();
48 $this->lng = $DIC->language();
49 $this->access = $DIC->access();
50 $ilCtrl = $DIC->ctrl();
51 $lng = $DIC->language();
52 $this->ui_fac = $DIC->ui()->factory();
53 $this->ui_ren = $DIC->ui()->renderer();
54
55 $this->skill_id = $a_skill_id;
56 $this->skill = new ilBasicSkill($a_skill_id);
57 $this->tref_id = $a_tref_id;
58 $this->in_use = $a_in_use;
59 $this->manage_perm = $a_manage_perm;
60
61 parent::__construct($a_parent_obj, $a_parent_cmd);
62 $this->setLimit(9999);
63 $this->setData($this->getSkillLevelData());
64 $this->setTitle($lng->txt("skmg_skill_levels"));
65 if ($this->tref_id == 0) {
66 $this->setDescription($lng->txt("skmg_from_lower_to_higher_levels"));
67 }
68
69 if ($this->tref_id == 0 && !$this->in_use) {
70 if ($this->manage_perm) {
71 $this->addColumn("", "", "1", true);
72 }
73 $this->addColumn($this->lng->txt("skmg_nr"));
74 }
75 $this->addColumn($this->lng->txt("title"));
76 $this->addColumn($this->lng->txt("description"));
77 $this->addColumn($this->lng->txt("skmg_suggested"));
78 $this->addColumn($this->lng->txt("skmg_lp_triggers_level"));
79 if ($this->manage_perm) {
80 $this->addColumn($this->lng->txt("actions"));
81 }
82 $this->setDefaultOrderField("nr");
83 $this->setDefaultOrderDirection("asc");
84
85 $this->setEnableHeader(true);
86 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
87 $this->setRowTemplate("tpl.skill_level_row.html", "Services/Skill");
88 $this->setEnableTitle(true);
89
90 if ($this->tref_id == 0 && !$this->in_use && $this->manage_perm) {
91 $this->addMultiCommand("confirmLevelDeletion", $lng->txt("delete"));
92 if (count($this->getData()) > 0) {
93 $this->addCommandButton("updateLevelOrder", $lng->txt("skmg_update_order"));
94 }
95 }
96 }
97
101 public function numericOrdering(string $a_field): bool
102 {
103 if ($a_field == "nr") {
104 return true;
105 }
106 return false;
107 }
108
109 public function getSkillLevelData(): array
110 {
111 $levels = $this->skill->getLevelData();
112
113 // add ressource data
114 $res = [];
115 $resources = new ilSkillResources($this->skill_id, $this->tref_id);
116 foreach ($resources->getResources() as $level_id => $item) {
117 $res[$level_id] = $item;
118 }
119
120 foreach ($levels as $idx => $item) {
121 if (isset($res[$item["id"]])) {
122 $levels[$idx]["ressources"] = $res[$item["id"]];
123 }
124 }
125
126 return $levels;
127 }
128
129 protected function fillRow(array $a_set): void
130 {
132 $ilCtrl = $this->ctrl;
133
134 if ($this->tref_id == 0 && !$this->in_use) {
135 if ($this->manage_perm) {
136 $this->tpl->setCurrentBlock("cb");
137 $this->tpl->setVariable("CB_ID", $a_set["id"]);
138 $this->tpl->parseCurrentBlock();
139 }
140
141 $this->tpl->setCurrentBlock("nr");
142 $this->tpl->setVariable("ORD_ID", $a_set["id"]);
143 $this->tpl->setVariable("VAL_NR", ((int) $a_set["nr"]) * 10);
144 if (!$this->manage_perm) {
145 $this->tpl->touchBlock("disabled");
146 }
147 $this->tpl->parseCurrentBlock();
148 }
149
150 $this->tpl->setCurrentBlock("cmd");
151 if ($this->manage_perm) {
152 $this->tpl->setVariable("TXT_CMD", $lng->txt("edit"));
153 }
154 $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
155 if ($this->tref_id == 0) {
156 $this->tpl->setVariable(
157 "HREF_CMD",
158 $ilCtrl->getLinkTarget($this->parent_obj, "editLevel")
159 );
160 } else {
161 $this->tpl->setVariable(
162 "HREF_CMD",
163 $ilCtrl->getLinkTarget($this->parent_obj, "showLevelResources")
164 );
165 }
166 $this->tpl->parseCurrentBlock();
167
168 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
169 $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
170 if (isset($a_set["ressources"]) && is_array($a_set["ressources"])) {
171 foreach ($a_set["ressources"] as $rref_id => $ressource) {
172 $robj_id = ilObject::_lookupObjId($rref_id);
173 $robj_type = ilObject::_lookupType($robj_id);
174 $robj_icon = $this->ui_fac->symbol()->icon()->standard(
175 $robj_type,
176 $this->lng->txt("icon") . " " . $this->lng->txt($robj_type),
177 "medium"
178 );
179 $robj_title = ilObject::_lookupTitle($robj_id);
180 $robj_link = ilLink::_getStaticLink($rref_id);
181
182 if ($ressource["imparting"]) {
183 $this->tpl->setCurrentBlock("ressource_sugg");
184 $this->tpl->setVariable("RSRC_IMG", $this->ui_ren->render($robj_icon));
185 $this->tpl->setVariable("RSRC_TITLE", $robj_title);
186 $this->tpl->setVariable("RSRC_URL", $robj_link);
187 $this->tpl->parseCurrentBlock();
188 }
189
190 if ($ressource["trigger"]) {
191 $this->tpl->setCurrentBlock("ressource_trigg");
192 $this->tpl->setVariable("RSRC_IMG", $this->ui_ren->render($robj_icon));
193 $this->tpl->setVariable("RSRC_TITLE", $robj_title);
194 $this->tpl->setVariable("RSRC_URL", $robj_link);
195 $this->tpl->parseCurrentBlock();
196 }
197 }
198 }
199 }
200}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillRow(array $a_set)
Standard Version of Fill Row.
numericOrdering(string $a_field)
Should this field be sorted numeric?
__construct(int $a_skill_id, $a_parent_obj, string $a_parent_cmd, int $a_tref_id=0, bool $a_in_use=false, bool $a_manage_perm=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setEnableTitle(bool $a_enabletitle)
setDescription(string $a_val)
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
ilLanguage $lng
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69
$resources
Definition: ltiservices.php:68
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc