19 declare(strict_types=1);
67 $this->
lng = $DIC->language();
68 $this->tpl = $DIC->ui()->mainTemplate();
69 $this->
factory = $DIC->ui()->factory();
70 $this->
renderer = $DIC->ui()->renderer();
71 $this->request = $DIC->http()->request();
72 $this->
user = $DIC->user();
73 $this->
access = $DIC->access();
74 $this->tile =
new Tile($DIC);
79 array $visible_column_ids,
83 ?array $additional_parameters
88 [$order_field, $order_direction] = $order->
join(
90 fn($ret, $key, $value) => [$key, $value]
93 usort($records,
static function (array $left, array $right) use ($order_field):
int {
94 if (in_array($order_field, [
'title',
'awarded_by'],
true)) {
95 if (in_array($order_field, [
'title',
'awarded_by'],
true)) {
96 $order_field .=
'_sortable';
105 if ($order_field ===
'active') {
106 return $right[$order_field] <=> $left[$order_field];
109 return $left[$order_field] <=> $right[$order_field];
112 if ($order_direction === Order::DESC) {
113 $records = array_reverse($records);
121 foreach ($records as $record) {
122 yield $row_builder->
buildDataRow((
string) $record[
'id'], $record);
128 ?array $additional_parameters
147 if ($this->cached_records !==
null) {
152 $a_user_id = $this->
user->getId();
155 $badge =
new ilBadge($ass->getBadgeId());
158 if ($badge->getParentId()) {
160 if ($parent[
'type'] ===
'bdga') {
166 $awarded_by_sortable =
'';
167 if ($parent !==
null) {
171 $awarded_by = $parent[
'title'];
172 $awarded_by_sortable = $parent[
'title'];
174 $awarded_by = $this->
renderer->render(
182 $awarded_by = implode(
' ', [
184 $this->factory->symbol()->icon()->standard(
194 'id' => $badge->getId(),
196 $this->tile->asImage(
197 $this->tile->modalContentWithAssignment($badge, $ass),
198 ilBadgeImage::IMAGE_SIZE_XS
202 $this->tile->asTitle(
203 $this->tile->modalContentWithAssignment($badge, $ass)
206 'title_sortable' => $badge->getTitle(),
208 ->setTimestamp($ass->getTimestamp())
210 'awarded_by' => $awarded_by,
211 'awarded_by_sortable' => $awarded_by_sortable,
212 'active' => (bool) $ass->getPosition()
216 $this->cached_records = $rows;
227 'image' => $this->
factory->table()->column()->text($this->
lng->txt(
'image'))->withIsSortable(
false),
228 'title' => $this->
factory->table()->column()->text($this->
lng->txt(
'title')),
229 'awarded_by' => $this->
factory->table()->column()->text($this->
lng->txt(
'awarded_by')),
230 'badge_issued_on' => $this->
factory->table()->column()->date(
231 $this->
lng->txt(
'badge_issued_on'),
234 'active' => $this->
factory->table()->column()->boolean(
235 $this->
lng->txt(
'badge_in_profile'),
236 $this->
lng->txt(
'yes'),
237 $this->
lng->txt(
'no')
238 )->withOrderingLabels(
239 $this->
lng->txt(
'badge_sort_added_to_profile_first'),
240 $this->
lng->txt(
'badge_sort_excluded_from_profile_first')
254 'obj_badge_activate' => $this->
factory->table()->action()->multi(
255 $this->
lng->txt(
'badge_add_to_profile'),
256 $url_builder->
withParameter($action_parameter_token,
'obj_badge_activate'),
259 'obj_badge_deactivate' =>
260 $this->
factory->table()->action()->multi(
261 $this->
lng->txt(
'badge_remove_from_profile'),
262 $url_builder->
withParameter($action_parameter_token,
'obj_badge_deactivate'),
270 $df = new \ILIAS\Data\Factory();
272 $date_format = $df->dateFormat()->withTime12($this->
user->getDateFormat());
274 $date_format = $df->dateFormat()->withTime24($this->
user->getDateFormat());
277 $table_uri = $df->uri($this->request->getUri()->__toString());
279 $query_params_namespace = [
'badge'];
281 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
282 $query_params_namespace,
291 $this->
lng->txt(
'badge_personal_badges'),
294 ->withId(self::class)
295 ->withOrder(
new Order(
'title', Order::ASC))
296 ->withActions($this->
getActions($url_builder, $action_parameter_token, $row_id_token))
297 ->withRequest($this->request);
300 $pres->show($this->
lng->txt(
'table_view'));
302 $this->tpl->setContent($this->
renderer->render($table));
join($init, callable $fn)
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e...
static getInstancesByUserId(int $a_user_id)
Interface Observer Contains several chained tasks and infos about them.
static _getAllReferences(int $id)
get all reference ids for object ID
readonly Factory $factory
getColumns(\ILIAS\Data\DateFormat\DateFormat $date_format)
Both the subject and the direction need to be specified when expressing an order. ...
buildDataRow(string $id, array $record)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
readonly ServerRequestInterface RequestInterface $request
This is how the factory for UI elements looks.
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
readonly Renderer $renderer
static strCmp(string $a, string $b)
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
readonly ILIAS DI Container $dic
A simple class to express a naive range of whole positive numbers.
readonly ilAccessHandler $access
readonly ilGlobalTemplateInterface $tpl