ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjLTIConsumerListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
30{
31 public function init(): void
32 {
33 $this->static_link_enabled = true; // Create static links for default command (linked title) or not
34 $this->delete_enabled = true;
35 $this->cut_enabled = true;
36 $this->subscribe_enabled = false;
37 $this->link_enabled = true;
38 $this->copy_enabled = true;
39 $this->progress_enabled = true;
40 $this->notice_properties_enabled = true;
41 $this->info_screen_enabled = true;
42 $this->type = "lti";
43 $this->gui_class_name = "ilObjLTIConsumerGUI";
44
45 $this->commands = ilObjLTIConsumerAccess::_getCommands();
46 }
50 public function insertIconsAndCheckboxes(): void
51 {
53 $objDefinition = $this->obj_definition;
54
55 $cnt = 0;
56 if ($this->getCheckboxStatus()) {
57 $this->tpl->setCurrentBlock("check");
58 $this->tpl->setVariable("VAL_ID", $this->getCommandId());
59 $this->tpl->parseCurrentBlock();
60 $cnt += 1;
61 } elseif ($this->getDownloadCheckboxState() != self::DOWNLOAD_CHECKBOX_NONE) {
62 $this->tpl->setCurrentBlock("check_download");
63 if ($this->getDownloadCheckboxState() == self::DOWNLOAD_CHECKBOX_ENABLED) {
64 $this->tpl->setVariable("VAL_ID", $this->getCommandId());
65 } else {
66 $this->tpl->setVariable("VAL_VISIBILITY", "visibility: hidden;\" disabled=\"disabled");
67 }
68 $this->tpl->parseCurrentBlock();
69 $cnt += 1;
70 } elseif ($this->getExpandStatus()) {
71 $this->tpl->setCurrentBlock('expand');
72
73 if ($this->isExpanded()) {
74 $this->ctrl->setParameter($this->container_obj, 'expand', -1 * $this->obj_id);
75 // "view" added, see #19922
76 $this->tpl->setVariable('EXP_HREF', $this->ctrl->getLinkTarget($this->container_obj, 'view', $this->getUniqueItemId(true)));
77 $this->ctrl->clearParameters($this->container_obj);
78 $this->tpl->setVariable('EXP_IMG', ilUtil::getImagePath('nav/tree_exp.svg'));
79 $this->tpl->setVariable('EXP_ALT', $this->lng->txt('collapse'));
80 } else {
81 $this->ctrl->setParameter($this->container_obj, 'expand', $this->obj_id);
82 // "view" added, see #19922
83 $this->tpl->setVariable('EXP_HREF', $this->ctrl->getLinkTarget($this->container_obj, 'view', $this->getUniqueItemId(true)));
84 $this->ctrl->clearParameters($this->container_obj);
85 $this->tpl->setVariable('EXP_IMG', ilUtil::getImagePath('nav/tree_col.svg'));
86 $this->tpl->setVariable('EXP_ALT', $this->lng->txt('expand'));
87 }
88
89 $this->tpl->parseCurrentBlock();
90 $cnt += 1;
91 }
92
93 if ($this->getIconStatus()) {
94 if ($cnt == 1) {
95 $this->tpl->touchBlock("i_1"); // indent
96 }
97
98 // icon link
99 if ($this->title_link_disabled || !$this->default_command || (!$this->getCommandsStatus() && !$this->restrict_to_goto)) {
100 } else {
101 $this->tpl->setCurrentBlock("icon_link_s");
102
103 if ($this->default_command["frame"] != "") {
104 $this->tpl->setVariable("ICON_TAR", "target='" . $this->default_command["frame"] . "'");
105 }
106
107 $this->tpl->setVariable(
108 "ICON_HREF",
109 $this->default_command["link"]
110 );
111 $this->tpl->parseCurrentBlock();
112 $this->tpl->touchBlock("icon_link_e");
113 }
114
115 $this->tpl->setCurrentBlock("icon");
116 if (!$objDefinition->isPlugin($this->getIconImageType())) {
117 $this->tpl->setVariable("ALT_ICON", $lng->txt("icon") . " " . $lng->txt("obj_" . $this->getIconImageType()));
118 } else {
119 $this->tpl->setVariable("ALT_ICON", $lng->txt("icon") . " " .
120 ilObjectPlugin::lookupTxtById($this->getIconImageType(), "obj_" . $this->getIconImageType()));
121 }
122
123 $this->tpl->setVariable("SRC_ICON", $this->getIconHref());
124 $this->tpl->parseCurrentBlock();
125 $cnt += 1;
126 }
127
128 $this->tpl->touchBlock("d_" . $cnt); // indent main div
129 }
130
131 protected function getIconHref(): string
132 {
133 /* @var ilObjLTIConsumer $object */
134 $object = ilObjectFactory::getInstanceByObjId($this->obj_id);
135
136 if ($object !== null && $object->getProvider() !== null && $object->getProvider()->hasProviderIcon()) {
137 return $object->getProvider()->getProviderIcon()->getAbsoluteFilePath();
138 }
139
140 return ilObject::_getIcon($this->obj_id, "small", $this->getIconImageType());
141 }
142
147 public function getProperties(): array
148 {
149 global $DIC; /* @var \ILIAS\DI\Container $DIC */
150
151 $props = array();
152
153 if (ilObjLTIConsumerAccess::_isOffline($this->obj_id)) {
154 $props[] = array("alert" => true, "property" => $DIC->language()->txt("status"),
155 "value" => $DIC->language()->txt("offline"));
156 }
157
158 $props[] = array(
159 'alert' => false, 'property' => $DIC->language()->txt('type'),
160 'value' => $DIC->language()->txt('obj_lti')
161 );
162
163 $validator = new ilCertificateDownloadValidator();
164 if ($validator->isCertificateDownloadable($DIC->user()->getId(), $this->obj_id)) {
165 $DIC->ctrl()->setParameterByClass(ilLTIConsumerSettingsGUI::class, 'ref_id', $this->ref_id);
166
167 $certLink = $DIC->ui()->factory()->link()->standard(
168 $DIC->language()->txt('download_certificate'),
169 $DIC->ctrl()->getLinkTargetByClass(
170 [ilObjLTIConsumerGUI::class, ilLTIConsumerSettingsGUI::class],
172 )
173 );
174
175 $props[] = array(
176 'alert' => false, 'property' => $DIC->language()->txt('certificate'),
177 'value' => $DIC->ui()->renderer()->render($certLink)
178 );
179 }
180
181 return $props;
182 }
183
187 public function getCommandLink(string $cmd): string
188 {
189 global $DIC; /* @var \ILIAS\DI\Container $DIC */
190
191 $commands = explode('::', $cmd);
192
193 $DIC->ctrl()->setParameterByClass('ilLTIConsumerSettingsGUI', 'ref_id', $this->ref_id);
194
195 if (count($commands) == 2) {
196 $cmd_link = $DIC->ctrl()->getLinkTargetByClass(
197 [
198 'ilRepositoryGUI',
199 'ilObjLTIConsumerGUI',
200 $commands[0]
201 ],
202 $commands[1]
203 );
204 } else {
205 $cmd_link = $DIC->ctrl()->getLinkTargetByClass(['ilRepositoryGUI', 'ilObjLTIConsumerGUI'], $commands[0]);
206 }
207
208 return $cmd_link;
209 }
210}
Validates if an active certificate is stored in the database and can be downloaded by the user.
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...
insertIconsAndCheckboxes()
Insert icons and checkboxes.
static _isOffline(int $obj_id)
Type-specific implementation of general status, has to be overwritten if object type does not support...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
ilObjectDefinition $obj_definition
getIconImageType()
Returns the icon image type.
getCommandId()
get command id Normally the ref id.
static lookupTxtById(string $plugin_id, string $lang_var)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: shib_login.php:26