ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSkillLevelTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
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 protected \ILIAS\Skill\Resource\SkillResourcesManager $resource_manager;
37
38 public function __construct(
39 int $a_skill_id,
40 $a_parent_obj,
41 string $a_parent_cmd,
42 int $a_tref_id = 0,
43 bool $a_in_use = false,
44 bool $a_manage_perm = false
45 ) {
46 global $DIC;
47
48 $this->ctrl = $DIC->ctrl();
49 $this->lng = $DIC->language();
50 $this->access = $DIC->access();
51 $ilCtrl = $DIC->ctrl();
52 $lng = $DIC->language();
53 $this->ui_fac = $DIC->ui()->factory();
54 $this->ui_ren = $DIC->ui()->renderer();
55 $this->resource_manager = $DIC->skills()->internal()->manager()->getResourceManager();
56
57 $this->skill_id = $a_skill_id;
58 $this->skill = new ilBasicSkill($a_skill_id);
59 $this->tref_id = $a_tref_id;
60 $this->in_use = $a_in_use;
61 $this->manage_perm = $a_manage_perm;
62
63 parent::__construct($a_parent_obj, $a_parent_cmd);
64 $this->setLimit(9999);
65 $this->setData($this->getSkillLevelData());
66 $this->setTitle($lng->txt("skmg_skill_levels"));
67 if ($this->tref_id == 0) {
68 $this->setDescription($lng->txt("skmg_from_lower_to_higher_levels"));
69 }
70
71 if ($this->tref_id == 0 && !$this->in_use) {
72 if ($this->manage_perm) {
73 $this->addColumn("", "", "1", true);
74 }
75 $this->addColumn($this->lng->txt("skmg_nr"));
76 }
77 $this->addColumn($this->lng->txt("title"));
78 $this->addColumn($this->lng->txt("description"));
79 $this->addColumn($this->lng->txt("skmg_suggested"));
80 $this->addColumn($this->lng->txt("skmg_lp_triggers_level"));
81 if ($this->manage_perm) {
82 $this->addColumn($this->lng->txt("actions"));
83 }
84 $this->setDefaultOrderField("nr");
85 $this->setDefaultOrderDirection("asc");
86
87 $this->setEnableHeader(true);
88 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
89 $this->setRowTemplate("tpl.skill_level_row.html", "components/ILIAS/Skill");
90 $this->setEnableTitle(true);
91
92 if ($this->tref_id == 0 && !$this->in_use && $this->manage_perm) {
93 $this->addMultiCommand("confirmLevelDeletion", $lng->txt("delete"));
94 if (count($this->getData()) > 0) {
95 $this->addCommandButton("updateLevelOrder", $lng->txt("skmg_update_order"));
96 }
97 }
98 }
99
103 public function numericOrdering(string $a_field): bool
104 {
105 if ($a_field == "nr") {
106 return true;
107 }
108 return false;
109 }
110
111 public function getSkillLevelData(): array
112 {
113 $levels = $this->skill->getLevelData();
114
115 // add ressource data
116 $res = [];
117 foreach ($this->resource_manager->getResources($this->skill_id, $this->tref_id) as $level_id => $item) {
118 $res[$level_id] = $item;
119 }
120
121 foreach ($levels as $idx => $item) {
122 if (isset($res[$item["id"]])) {
123 $levels[$idx]["ressources"] = $res[$item["id"]];
124 }
125 }
126
127 return $levels;
128 }
129
130 protected function fillRow(array $a_set): void
131 {
133 $ilCtrl = $this->ctrl;
134
135 if ($this->tref_id == 0 && !$this->in_use) {
136 if ($this->manage_perm) {
137 $this->tpl->setCurrentBlock("cb");
138 $this->tpl->setVariable("CB_ID", $a_set["id"]);
139 $this->tpl->parseCurrentBlock();
140 }
141
142 $this->tpl->setCurrentBlock("nr");
143 $this->tpl->setVariable("ORD_ID", $a_set["id"]);
144 $this->tpl->setVariable("VAL_NR", ((int) $a_set["nr"]) * 10);
145 if (!$this->manage_perm) {
146 $this->tpl->touchBlock("disabled");
147 }
148 $this->tpl->parseCurrentBlock();
149 }
150
151 $this->tpl->setCurrentBlock("cmd");
152 if ($this->manage_perm) {
153 $this->tpl->setVariable("TXT_CMD", $lng->txt("edit"));
154 }
155 $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
156 if ($this->tref_id == 0) {
157 $this->tpl->setVariable(
158 "HREF_CMD",
159 $ilCtrl->getLinkTarget($this->parent_obj, "editLevel")
160 );
161 } else {
162 $this->tpl->setVariable(
163 "HREF_CMD",
164 $ilCtrl->getLinkTarget($this->parent_obj, "showLevelResources")
165 );
166 }
167 $this->tpl->parseCurrentBlock();
168
169 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
170 $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
171 if (isset($a_set["ressources"]) && is_array($a_set["ressources"])) {
172 foreach ($a_set["ressources"] as $ressource) {
173 $robj_id = ilObject::_lookupObjId($ressource->getRepoRefId());
174 $robj_type = ilObject::_lookupType($robj_id);
175 $robj_icon = $this->ui_fac->symbol()->icon()->standard(
176 $robj_type,
177 $this->lng->txt("icon") . " " . $this->lng->txt($robj_type),
178 "medium"
179 );
180 $robj_title = ilObject::_lookupTitle($robj_id);
181 $robj_link = ilLink::_getStaticLink($ressource->getRepoRefId());
182
183 if ($ressource->getImparting()) {
184 $this->tpl->setCurrentBlock("ressource_sugg");
185 $this->tpl->setVariable("RSRC_IMG", $this->ui_ren->render($robj_icon));
186 $this->tpl->setVariable("RSRC_TITLE", $robj_title);
187 $this->tpl->setVariable("RSRC_URL", $robj_link);
188 $this->tpl->parseCurrentBlock();
189 }
190
191 if ($ressource->getTrigger()) {
192 $this->tpl->setCurrentBlock("ressource_trigg");
193 $this->tpl->setVariable("RSRC_IMG", $this->ui_ren->render($robj_icon));
194 $this->tpl->setVariable("RSRC_TITLE", $robj_title);
195 $this->tpl->setVariable("RSRC_URL", $robj_link);
196 $this->tpl->parseCurrentBlock();
197 }
198 }
199 }
200 }
201}
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)
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)
ILIAS Skill Resource SkillResourcesManager $resource_manager
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
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26