ILIAS  release_7 Revision v7.30-3-g800a261c036
ilLTIConsumerContentGUI Class Reference
+ Collaboration diagram for ilLTIConsumerContentGUI:

Public Member Functions

 __construct (ilObjLTIConsumer $object)
 
 executeCommand ()
 

Static Public Member Functions

static isEmbeddedLaunchRequest ()
 

Data Fields

const CMD_LAUNCH = 'launch'
 
const CMD_SHOW_EMBEDDED = 'showEmbedded'
 

Protected Member Functions

 launch ()
 
 getStartButtonTxt11 ()
 
 showEmbedded ()
 
 getLaunchParameters ()
 
 initCmixUser ()
 

Protected Attributes

 $object
 
 $cmixUser
 

Private Attributes

 $dic
 
 $lng
 
 $user
 

Detailed Description

Definition at line 14 of file class.ilLTIConsumerContentGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilLTIConsumerContentGUI::__construct ( ilObjLTIConsumer  $object)
Parameters
ilObjLTIConsumer$object

Definition at line 46 of file class.ilLTIConsumerContentGUI.php.

47 {
48 global $DIC;
49 $this->dic = $DIC;
50 $this->lng = $DIC->language();
51 $this->user = $DIC->user();
52 $this->object = $object;
53 }
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24

References $DIC, $object, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilLTIConsumerContentGUI::executeCommand ( )

Definition at line 55 of file class.ilLTIConsumerContentGUI.php.

56 {
57 global $DIC; /* @var \ILIAS\DI\Container $DIC */
58
59 if ($this->object->getProvider()->getAvailability() == ilLTIConsumeProvider::AVAILABILITY_NONE) {
60 throw new ilLtiConsumerException('access denied!');
61 }
62
63 $command = $DIC->ctrl()->getCmd(self::CMD_LAUNCH);
64
65 $this->{$command}();
66 }

References $DIC, and ilLTIConsumeProvider\AVAILABILITY_NONE.

◆ getLaunchParameters()

ilLTIConsumerContentGUI::getLaunchParameters ( )
protected

Definition at line 192 of file class.ilLTIConsumerContentGUI.php.

193 {
194 $ilLTIConsumerLaunch = new ilLTIConsumerLaunch($this->object->getRefId());
195 $launchContext = $ilLTIConsumerLaunch->getContext();
196
197 $launchContextType = ilLTIConsumerLaunch::getLTIContextType($launchContext["type"]);
198 $launchContextId = $launchContext["id"];
199 $launchContextTitle = $launchContext["title"];
200
202 $this->dic->user()->getId(),
203 $this->object->getRefId(),
204 $this->object->getId()
205 );
206
207 return $this->object->buildLaunchParameters(
208 $this->cmixUser,
209 $token,
210 $launchContextType,
211 $launchContextId,
212 $launchContextTitle
213 );
214 }
static fillToken($usrId, $refId, $objId, $lrsTypeId=0)
$token
Definition: xapitoken.php:52

References $token, ilCmiXapiAuthToken\fillToken(), and ilLTIConsumerLaunch\getLTIContextType().

Referenced by showEmbedded().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStartButtonTxt11()

ilLTIConsumerContentGUI::getStartButtonTxt11 ( )
protected

Definition at line 102 of file class.ilLTIConsumerContentGUI.php.

102 : string
103 {
104 if ($this->object->getOfflineStatus() ||
105 $this->object->isLaunchMethodEmbedded() ||
106 $this->object->getProvider()->getAvailability() == ilLTIConsumeProvider::AVAILABILITY_NONE) {
107 return "";
108 }
109
111 $this->object->getId(),
112 $this->user->getId(),
113 $this->object->getProvider()->getPrivacyIdent()
114 );
115 $user_ident = $cmixUser->getUsrIdent();
116 if ($user_ident == '' || $user_ident == null) {
117 $user_ident = ilCmiXapiUser::getIdent($this->object->getProvider()->getPrivacyIdent(), $this->dic->user());
118 $cmixUser->setUsrIdent($user_ident);
119 $cmixUser->save();
120 }
121 $ilLTIConsumerLaunch = new ilLTIConsumerLaunch($this->object->getRefId());
122 $context = $ilLTIConsumerLaunch->getContext();
123 $contextType = $ilLTIConsumerLaunch::getLTIContextType($context["type"]);
124 $contextId = $context["id"];
125 $contextTitle = $context["title"];
126
128 $this->dic->user()->getId(),
129 $this->object->getRefId(),
130 $this->object->getId()
131 );
132
133 $returnUrl = !$this->object->isLaunchMethodOwnWin() ? '' : str_replace(
134 '&',
135 '&',
136 ILIAS_HTTP_PATH . "/" . $this->dic->ctrl()->getLinkTarget($this, "", "", false)
137 );
138
139 $launchParameters = $this->object->buildLaunchParameters(
140 $cmixUser,
141 $token,
142 $contextType,
143 $contextId,
144 $contextTitle,
145 $returnUrl
146 );
147
148 $target = $this->object->getLaunchMethod() == "newWin" ? "_blank" : "_self";
149 $button = '<input class="btn btn-default ilPre" type="button" onClick="ltilaunch()" value = "' . $this->lng->txt("show_content") . '" />';
150 $output = '<form id="lti_launch_form" name="lti_launch_form" action="' . $this->object->getProvider()->getProviderUrl() . '" method="post" target="' . $target . '" encType="application/x-www-form-urlencoded">';
151 foreach ($launchParameters as $field => $value) {
152 $output .= sprintf('<input type="hidden" name="%s" value="%s" />', $field, $value) . "\n";
153 }
154 $output .= $button;
155 $output .= '</form>';
156 $output .= '<span id ="lti_launched" style="display:none">' . $this->lng->txt("launched") . '</span>';
157 $output .= '<script type="text/javascript">
158 function ltilaunch() {
159 document.lti_launch_form.submit();
160 document.getElementById("lti_launch_form").style.display = "none";
161 document.getElementById("lti_launched").style.display = "inline";
162 }</script>';
163 return($output);
164 }
static getIdent($userIdentMode, ilObjUser $user)
$context
Definition: webdav.php:26

References $cmixUser, $context, $token, ilLTIConsumeProvider\AVAILABILITY_NONE, ilCmiXapiAuthToken\fillToken(), and ilCmiXapiUser\getIdent().

Referenced by launch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initCmixUser()

ilLTIConsumerContentGUI::initCmixUser ( )
protected

Definition at line 231 of file class.ilLTIConsumerContentGUI.php.

232 {
233 global $DIC; /* @var \ILIAS\DI\Container $DIC */
234
235 $this->cmixUser = new ilCmiXapiUser($this->object->getId(), $DIC->user()->getId(), $this->object->getProvider()->getPrivacyIdent());
236 $user_ident = $this->cmixUser->getUsrIdent();
237 if ($user_ident == '' || $user_ident == null) {
238 $user_ident = ilCmiXapiUser::getIdent($this->object->getProvider()->getPrivacyIdent(), $DIC->user());
239 $this->cmixUser->setUsrIdent($user_ident);
240 $this->cmixUser->save();
241 }
242 }

References $DIC, and ilCmiXapiUser\getIdent().

Referenced by showEmbedded().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isEmbeddedLaunchRequest()

static ilLTIConsumerContentGUI::isEmbeddedLaunchRequest ( )
static

Definition at line 216 of file class.ilLTIConsumerContentGUI.php.

216 : bool
217 {
218 global $DIC; /* @var \ILIAS\DI\Container $DIC */
219
220 if ($DIC->ctrl()->getNextClass() != strtolower(self::class)) {
221 return false;
222 }
223
224 if ($DIC->ctrl()->getCmd() != self::CMD_SHOW_EMBEDDED) {
225 return false;
226 }
227
228 return true;
229 }

References $DIC.

Referenced by ilObjLTIConsumerGUI\executeCommand().

+ Here is the caller graph for this function:

◆ launch()

ilLTIConsumerContentGUI::launch ( )
protected
Exceptions
ilCtrlException
ilTemplateException

Definition at line 86 of file class.ilLTIConsumerContentGUI.php.

86 : void
87 {
88 if ($this->dic->access()->checkAccess('read', '', $this->object->getRefId())) {
89 if ($this->object->isLaunchMethodEmbedded()) {
90 $tpl = new ilTemplate('tpl.lti_content.html', true, true, 'Modules/LTIConsumer');
91 $tpl->setVariable("EMBEDDED_IFRAME_SRC", $this->dic->ctrl()->getLinkTarget(
92 $this,
93 self::CMD_SHOW_EMBEDDED
94 ));
95 $this->dic->ui()->mainTemplate()->setContent($tpl->get());
96 } else {
97 $this->dic->toolbar()->addText($this->getStartButtonTxt11());
98 }
99 }
100 }
special template class to simplify handling of ITX/PEAR
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References $tpl, and getStartButtonTxt11().

+ Here is the call graph for this function:

◆ showEmbedded()

ilLTIConsumerContentGUI::showEmbedded ( )
protected

Definition at line 165 of file class.ilLTIConsumerContentGUI.php.

166 {
167 $this->initCmixUser();
168
169 $tpl = new ilTemplate('tpl.lti_embedded.html', true, true, 'Modules/LTIConsumer');
170
171 foreach ($this->getLaunchParameters() as $field => $value) {
172 $tpl->setCurrentBlock('launch_parameter');
173 $tpl->setVariable('LAUNCH_PARAMETER', $field);
174 $tpl->setVariable('LAUNCH_PARAM_VALUE', $value);
175 $tpl->parseCurrentBlock();
176 }
177
178 $v = DEVMODE ? '?vers=' . time() : '?vers=' . ILIAS_VERSION_NUMERIC;
179 $tpl->setVariable("DELOS_CSS_HREF", 'templates/default/delos.css' . $v);
180 $tpl->setVariable("JQUERY_SRC", 'libs/bower/bower_components/jquery/dist/jquery.js' . $v);
181
182 $tpl->setVariable("LOADER_ICON_SRC", ilUtil::getImagePath("loader.svg"));
183 $tpl->setVariable('LAUNCH_URL', $this->object->getProvider()->getProviderUrl());
184
185 #$DIC->ui()->mainTemplate()->getStandardTemplate();
186 #$DIC->ui()->mainTemplate()->setContent($tpl->get());
187
188 echo $tpl->get();
189 exit;
190 }
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
const ILIAS_VERSION_NUMERIC
exit
Definition: login.php:29

References $tpl, exit, ilUtil\getImagePath(), getLaunchParameters(), ILIAS_VERSION_NUMERIC, and initCmixUser().

+ Here is the call graph for this function:

Field Documentation

◆ $cmixUser

ilLTIConsumerContentGUI::$cmixUser
protected

Definition at line 27 of file class.ilLTIConsumerContentGUI.php.

Referenced by getStartButtonTxt11().

◆ $dic

ilLTIConsumerContentGUI::$dic
private

Definition at line 32 of file class.ilLTIConsumerContentGUI.php.

◆ $lng

ilLTIConsumerContentGUI::$lng
private

Definition at line 37 of file class.ilLTIConsumerContentGUI.php.

◆ $object

ilLTIConsumerContentGUI::$object
protected

Definition at line 22 of file class.ilLTIConsumerContentGUI.php.

Referenced by __construct().

◆ $user

ilLTIConsumerContentGUI::$user
private

Definition at line 42 of file class.ilLTIConsumerContentGUI.php.

◆ CMD_LAUNCH

const ilLTIConsumerContentGUI::CMD_LAUNCH = 'launch'

Definition at line 16 of file class.ilLTIConsumerContentGUI.php.

◆ CMD_SHOW_EMBEDDED

const ilLTIConsumerContentGUI::CMD_SHOW_EMBEDDED = 'showEmbedded'

Definition at line 17 of file class.ilLTIConsumerContentGUI.php.


The documentation for this class was generated from the following file: