ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjLTIConsumerListGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
15{
16 public function init()
17 {
18 $this->static_link_enabled = true; // Create static links for default command (linked title) or not
19 $this->delete_enabled = true;
20 $this->cut_enabled = true;
21 $this->subscribe_enabled = false;
22 $this->link_enabled = true;
23 $this->copy_enabled = true;
24 $this->progress_enabled = true;
25 $this->notice_properties_enabled = true;
26 $this->info_screen_enabled = true;
27 $this->type = "lti";
28 $this->gui_class_name = "ilObjLTIConsumerGUI";
29
30 $this->commands = ilObjLTIConsumerAccess::_getCommands();
31 }
35 public function insertIconsAndCheckboxes()
36 {
38 $objDefinition = $this->obj_definition;
39
40 $cnt = 0;
41 if ($this->getCheckboxStatus()) {
42 $this->tpl->setCurrentBlock("check");
43 $this->tpl->setVariable("VAL_ID", $this->getCommandId());
44 $this->tpl->parseCurrentBlock();
45 $cnt += 1;
46 } elseif ($this->getDownloadCheckboxState() != self::DOWNLOAD_CHECKBOX_NONE) {
47 $this->tpl->setCurrentBlock("check_download");
48 if ($this->getDownloadCheckboxState() == self::DOWNLOAD_CHECKBOX_ENABLED) {
49 $this->tpl->setVariable("VAL_ID", $this->getCommandId());
50 } else {
51 $this->tpl->setVariable("VAL_VISIBILITY", "visibility: hidden;\" disabled=\"disabled");
52 }
53 $this->tpl->parseCurrentBlock();
54 $cnt += 1;
55 } elseif ($this->getExpandStatus()) {
56 $this->tpl->setCurrentBlock('expand');
57
58 if ($this->isExpanded()) {
59 $this->ctrl->setParameter($this->container_obj, 'expand', -1 * $this->obj_id);
60 // "view" added, see #19922
61 $this->tpl->setVariable('EXP_HREF', $this->ctrl->getLinkTarget($this->container_obj, 'view', $this->getUniqueItemId(true)));
62 $this->ctrl->clearParameters($this->container_obj);
63 $this->tpl->setVariable('EXP_IMG', ilUtil::getImagePath('tree_exp.svg'));
64 $this->tpl->setVariable('EXP_ALT', $this->lng->txt('collapse'));
65 } else {
66 $this->ctrl->setParameter($this->container_obj, 'expand', $this->obj_id);
67 // "view" added, see #19922
68 $this->tpl->setVariable('EXP_HREF', $this->ctrl->getLinkTarget($this->container_obj, 'view', $this->getUniqueItemId(true)));
69 $this->ctrl->clearParameters($this->container_obj);
70 $this->tpl->setVariable('EXP_IMG', ilUtil::getImagePath('tree_col.svg'));
71 $this->tpl->setVariable('EXP_ALT', $this->lng->txt('expand'));
72 }
73
74 $this->tpl->parseCurrentBlock();
75 $cnt += 1;
76 }
77
78 if ($this->getIconStatus()) {
79 if ($cnt == 1) {
80 $this->tpl->touchBlock("i_1"); // indent
81 }
82
83 // icon link
84 if ($this->title_link_disabled || !$this->default_command || (!$this->getCommandsStatus() && !$this->restrict_to_goto)) {
85 } else {
86 $this->tpl->setCurrentBlock("icon_link_s");
87
88 if ($this->default_command["frame"] != "") {
89 $this->tpl->setVariable("ICON_TAR", "target='" . $this->default_command["frame"] . "'");
90 }
91
92 $this->tpl->setVariable(
93 "ICON_HREF",
94 $this->default_command["link"]
95 );
96 $this->tpl->parseCurrentBlock();
97 $this->tpl->touchBlock("icon_link_e");
98 }
99
100 $this->tpl->setCurrentBlock("icon");
101 if (!$objDefinition->isPlugin($this->getIconImageType())) {
102 $this->tpl->setVariable("ALT_ICON", $lng->txt("icon") . " " . $lng->txt("obj_" . $this->getIconImageType()));
103 } else {
104 include_once("Services/Component/classes/class.ilPlugin.php");
105 $this->tpl->setVariable("ALT_ICON", $lng->txt("icon") . " " .
106 ilObjectPlugin::lookupTxtById($this->getIconImageType(), "obj_" . $this->getIconImageType()));
107 }
108
109 $this->tpl->setVariable("SRC_ICON", $this->getIconHref());
110 $this->tpl->parseCurrentBlock();
111 $cnt += 1;
112 }
113
114 $this->tpl->touchBlock("d_" . $cnt); // indent main div
115 }
116
117 protected function getIconHref()
118 {
119 /* @var ilObjLTIConsumer $object */
120 $object = ilObjectFactory::getInstanceByObjId($this->obj_id);
121
122 if ($object->getProvider()->hasProviderIcon()) {
123 return $object->getProvider()->getProviderIcon()->getAbsoluteFilePath();
124 }
125
126 return ilObject::_getIcon($this->obj_id, "small", $this->getIconImageType());
127 }
128
129 public function getProperties()
130 {
131 global $DIC; /* @var \ILIAS\DI\Container $DIC */
132
133 $props = array();
134
135 if (ilObjLTIConsumerAccess::_isOffline($this->obj_id)) {
136 $props[] = array("alert" => true, "property" => $DIC->language()->txt("status"),
137 "value" => $DIC->language()->txt("offline"));
138 }
139
140 $props[] = array(
141 'alert' => false, 'property' => $DIC->language()->txt('type'),
142 'value' => $DIC->language()->txt('obj_lti')
143 );
144
145 $validator = new ilCertificateDownloadValidator();
146 if ($validator->isCertificateDownloadable((int) $DIC->user()->getId(), (int) $this->obj_id)) {
147 $DIC->ctrl()->setParameterByClass(ilLTIConsumerSettingsGUI::class, 'ref_id', $this->ref_id);
148
149 $certLink = $DIC->ui()->factory()->link()->standard(
150 $DIC->language()->txt('download_certificate'),
151 $DIC->ctrl()->getLinkTargetByClass(
152 [ilObjLTIConsumerGUI::class, ilLTIConsumerSettingsGUI::class],
154 )
155 );
156
157 $props[] = array(
158 'alert' => false, 'property' => $DIC->language()->txt('certificate'),
159 'value' => $DIC->ui()->renderer()->render($certLink)
160 );
161 }
162
163 return $props;
164 }
165
166 public function getCommandLink($a_cmd)
167 {
168 global $DIC; /* @var \ILIAS\DI\Container $DIC */
169
170 $a_cmd = explode('::', $a_cmd);
171
172 if (count($a_cmd) == 2) {
173 $cmd_link = $DIC->ctrl()->getLinkTargetByClass(array('ilRepositoryGUI', 'ilObjLTIConsumerGUI', $a_cmd[0]), $a_cmd[1]);
174 } else {
175 $cmd_link = $DIC->ctrl()->getLinkTargetByClass(array('ilRepositoryGUI', 'ilObjLTIConsumerGUI'), $a_cmd[0]);
176 }
177
178 return $cmd_link;
179 }
180}
An exception for terminatinating execution or to throw for unit testing.
Validates if an active certificate is stored in the database and can be downloaded by the user.
insertIconsAndCheckboxes()
Insert icons and checkboxes.
getCommandLink($a_cmd)
Get command link url.
static _isOffline($a_obj_id)
Type-specific implementation of general status, has to be overwritten if object type does not support...
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjectListGUI.
getIconImageType()
Returns the icon image type.
getCheckboxStatus()
Are checkboxes enabled?
getCommandId()
get command id Normally the ref id.
getIconStatus()
Are icons enabled?
getExpandStatus()
Is expand/collapse enabled.
static lookupTxtById($plugin_id, $lang_var)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$DIC
Definition: xapitoken.php:46