ILIAS  release_8 Revision v8.24
class.ilObjectBadgeTableGUI.php
Go to the documentation of this file.
1<?php
2
25{
27 protected bool $has_write;
28 protected array $filter = [];
29
30 public function __construct(
31 object $a_parent_obj,
32 string $a_parent_cmd = "",
33 bool $a_has_write = false
34 ) {
35 global $DIC;
36
37 $this->ctrl = $DIC->ctrl();
38 $this->lng = $DIC->language();
39 $this->access = $DIC->access();
40 $ilCtrl = $DIC->ctrl();
41 $lng = $DIC->language();
42
43 $this->setId("bdgobdg");
44 $this->has_write = $a_has_write;
45
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47
48 $this->setLimit(9999);
49
50 $this->setTitle($lng->txt("badge_object_badges"));
51
52 if ($this->has_write) {
53 $this->addColumn("", "", 1);
54 }
55
56 $this->addColumn($lng->txt("title"), "title");
57 $this->addColumn($lng->txt("type"), "type");
58 $this->addColumn($lng->txt("object"), "container");
59 $this->addColumn($lng->txt("active"), "active");
60 $this->addColumn($lng->txt("action"), "");
61
62 if ($this->has_write) {
63 $this->addMultiCommand("activateObjectBadges", $lng->txt("activate"));
64 $this->addMultiCommand("deactivateObjectBadges", $lng->txt("deactivate"));
65 $this->addMultiCommand("confirmDeleteObjectBadges", $lng->txt("delete"));
66 $this->setSelectAllCheckbox("id");
67 }
68
69 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
70 $this->setRowTemplate("tpl.object_badge_row.html", "Services/Badge");
71 $this->setDefaultOrderField("title");
72
73 $this->setFilterCommand("applyObjectFilter");
74 $this->setResetCommand("resetObjectFilter");
75
76 $this->initFilter();
77
78 $this->getItems();
79 }
80
81 public function initFilter(): void
82 {
84
85 $title = $this->addFilterItemByMetaType("title", self::FILTER_TEXT, false, $lng->txt("title"));
86 $this->filter["title"] = $title->getValue();
87
88 $object = $this->addFilterItemByMetaType("object", self::FILTER_TEXT, false, $lng->txt("object"));
89 $this->filter["object"] = $object->getValue();
90
91 $lng->loadLanguageModule("search");
92
93 $options = array(
94 "" => $lng->txt("search_any"),
95 );
96 foreach (ilBadgeHandler::getInstance()->getAvailableTypes() as $id => $type) {
97 // no activity badges
98 if (!in_array("bdga", $type->getValidObjectTypes(), true)) {
100 }
101 }
102 asort($options);
103
104 $type = $this->addFilterItemByMetaType("type", self::FILTER_SELECT, false, $lng->txt("type"));
105 $type->setOptions($options);
106 $this->filter["type"] = $type->getValue();
107 }
108
109 public function getItems(): void
110 {
112 $ilAccess = $this->access;
113
114 $data = [];
115
116 $types = ilBadgeHandler::getInstance()->getAvailableTypes(false);
117
118 foreach (ilBadge::getObjectInstances($this->filter) as $badge_item) {
119 // :TODO: container presentation
120 $container_url = null;
121 $container = '<img class="ilIcon" src="' .
122 ilObject::_getIcon((int) $badge_item["parent_id"], "big", $badge_item["parent_type"]) .
123 '" alt="' . $lng->txt("obj_" . $badge_item["parent_type"]) .
124 '" title="' . $lng->txt("obj_" . $badge_item["parent_type"]) . '" /> ' .
125 $badge_item["parent_title"];
126
127 if ($badge_item["deleted"] ?? false) {
128 $container .= ' <span class="il_ItemAlertProperty">' . $lng->txt("deleted") . '</span>';
129 } else {
130 $ref_ids = ilObject::_getAllReferences($badge_item["parent_id"]);
131 $ref_id = array_shift($ref_ids);
132 if ($ilAccess->checkAccess("read", "", $ref_id)) {
133 $container_url = ilLink::_getLink($ref_id);
134 }
135 }
136
137 $type_caption = ilBadge::getExtendedTypeCaption($types[$badge_item["type_id"]]);
138
139 $data[] = array(
140 "id" => $badge_item["id"],
141 "active" => $badge_item["active"],
142 "type" => $type_caption,
143 "title" => $badge_item["title"],
144 "container_meta" => $container,
145 "container_url" => $container_url,
146 "container_id" => $badge_item["parent_id"],
147 "renderer" => new ilBadgeRenderer(null, new ilBadge($badge_item["id"]))
148 );
149 }
150
151 $this->setData($data);
152 }
153
154 protected function fillRow(array $a_set): void
155 {
157 $ilCtrl = $this->ctrl;
158
159 if ($a_set["container_url"]) {
160 $this->tpl->setCurrentBlock("container_link_bl");
161 $this->tpl->setVariable("TXT_CONTAINER", $a_set["container_meta"]);
162 $this->tpl->setVariable("URL_CONTAINER", $a_set["container_url"]);
163 } else {
164 $this->tpl->setCurrentBlock("container_nolink_bl");
165 $this->tpl->setVariable("TXT_CONTAINER_STATIC", $a_set["container_meta"]);
166 }
167 $this->tpl->parseCurrentBlock();
168
169 if ($this->has_write) {
170 $this->tpl->setVariable("VAL_ID", $a_set["id"]);
171 }
172
173 $this->tpl->setVariable("PREVIEW", $a_set["renderer"]->getHTML());
174 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
175 $this->tpl->setVariable("TXT_TYPE", $a_set["type"]);
176 $this->tpl->setVariable("TXT_ACTIVE", $a_set["active"]
177 ? $lng->txt("yes")
178 : $lng->txt("no"));
179
180 if ($this->has_write) {
181 $ilCtrl->setParameter($this->getParentObject(), "pid", $a_set["container_id"]);
182 $ilCtrl->setParameter($this->getParentObject(), "bid", $a_set["id"]);
183 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "listObjectBadgeUsers");
184 $ilCtrl->setParameter($this->getParentObject(), "bid", "");
185 $ilCtrl->setParameter($this->getParentObject(), "pid", "");
186
187 $this->tpl->setVariable("TXT_LIST", $lng->txt("users"));
188 $this->tpl->setVariable("URL_LIST", $url);
189 }
190 }
191}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getExtendedTypeCaption(ilBadgeType $a_type)
static getObjectInstances(array $a_filter=null)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
loadLanguageModule(string $a_module)
Load language module.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd="", bool $a_has_write=false)
fillRow(array $a_set)
Standard Version of Fill Row.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFilterCommand(string $a_val, string $a_caption="")
getHTML()
Get HTML.
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addMultiCommand(string $a_cmd, string $a_text)
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
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)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setResetCommand(string $a_val, string $a_caption="")
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...
$ref_id
Definition: ltiauth.php:67
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$url
$container
@noRector
Definition: wac.php:14