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