ILIAS  release_8 Revision v8.24
class.ilLTIConsumerProviderUsageTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
30{
35
40 public function __construct(ilLTIConsumerAdministrationGUI $a_parent_obj, string $a_parent_cmd)
41 {
42 global $DIC; /* @var \ILIAS\DI\Container $DIC */
43
44 $this->setId('usages');
45 parent::__construct($a_parent_obj, $a_parent_cmd);
46
47 //$this->setFormAction($DIC->ctrl()->getFormAction($a_parent_obj, $a_parent_cmd));
48 $this->setRowTemplate('tpl.lti_consume_provider_usage_table_row.html', 'Modules/LTIConsumer');
49
50 $this->setTitle($DIC->language()->txt('tbl_provider_usage_header'));
51 $this->setDescription($DIC->language()->txt('tbl_provider_usage_header_info'));
52 }
53
54 public function init(): void
55 {
56 parent::determineSelectedColumns();
57 $this->initColumns();
58 }
59
60 protected function initColumns(): void
61 {
62 global $DIC; /* @var \ILIAS\DI\Container $DIC */
63
64 $this->addColumn($DIC->language()->txt('tbl_lti_prov_icon'), 'icon');
65 $this->addColumn($DIC->language()->txt('tbl_lti_prov_title'), 'title');
66 $this->addColumn($DIC->language()->txt('tbl_lti_prov_usages_trashed'), 'usedByIsTrashed');
67 $this->addColumn($DIC->language()->txt('tbl_lti_prov_used_by'), 'used_by');
68 }
69
70 protected function fillRow(array $a_set): void
71 {
72 global $DIC; /* @var \ILIAS\DI\Container $DIC */
73 // TITLE
74 $this->tpl->setVariable('TITLE', $a_set['title']);
75
76 // TRASHED
77 $this->tpl->setCurrentBlock('usages_trashed');
78 $usagesTrashed = $a_set['usedByIsTrashed'] && $this->isTrashEnabled() ? $DIC->language()->txt('yes') : '';
79 $this->tpl->setVariable('USAGES_TRASHED', $usagesTrashed);
80 $this->tpl->parseCurrentBlock();
81
82 // USED BY
83 $this->tpl->setCurrentBlock('used_by');
84 $tree = $this->buildLinkToUsedBy($a_set['usedByObjId'], (int) $a_set['usedByRefId'], (string) $a_set['usedByTitle'], (bool) $usagesTrashed);
85 $this->tpl->setVariable('TREE_TO_USED_BY', $tree['tree']);
86 $this->tpl->parseCurrentBlock();
87
88 // ICON
89 if (isset($a_set['icon'])) {
90 $this->tpl->setVariable('ICON_SRC', $a_set['icon']);
91 $this->tpl->setVariable('ICON_ALT', basename($a_set['icon']));
92 } else {
93 $icon = ilObject::_getIcon(0, "small", "lti");
94 $this->tpl->setVariable('ICON_SRC', $icon);
95 $this->tpl->setVariable('ICON_ALT', 'lti');
96 }
97 }
98
102 protected function buildLinkToUsedBy(int $objId, int $refId, string $title, bool $trashed): array
103 {
104 global $DIC; /* @var \ILIAS\DI\Container $DIC */
105
106 $tree = $DIC->repositoryTree()->getPathFull($refId);
107 $treeNodes = [];
108 foreach ($tree as $node) {
109 $node['title'] = (int) $node['parent'] === 0 ? $DIC->language()->txt('repository') : $node['title'];
110 $treeNodes[] = $trashed === true ? $node['title'] : '<a href="' . ilLink::_getLink((int) $node['ref_id']) . '">' . $node['title'] . '</a>';
111 }
112 $endnode = '<a href="' . ilLink::_getLink((int) $refId) . '">' . $title . '</a>';
113 if ($trashed === true) {
114 $treeNodes[] = $title;
115 }
116
117 return ['endnode' => $endnode, 'tree' => implode(' > ', $treeNodes)];
118 }
119
120 protected static function isTrashEnabled(): bool
121 {
122 global $DIC; /* @var \ILIAS\DI\Container $DIC */
123 return (bool) ((int) $DIC->settings()->get('enable_trash', "0"));
124 }
125} // EOF class
buildLinkToUsedBy(int $objId, int $refId, string $title, bool $trashed)
__construct(ilLTIConsumerAdministrationGUI $a_parent_obj, string $a_parent_cmd)
ilLTIConsumerProviderUsageTableGUI constructor.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setDescription(string $a_val)
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)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$objId
Definition: xapitoken.php:57
$refId
Definition: xapitoken.php:58