ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilLTIConsumerEmbeddedContentGUI.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 const CMD_SHOW_PAGE = 'showPage';
17 const CMD_SHOW_EMBEDDED = 'showEmbedded';
18
22 protected $object;
23
27 protected $cmixUser;
28
33 {
34 $this->object = $object;
35 }
36
37 public function executeCommand()
38 {
39 global $DIC; /* @var \ILIAS\DI\Container $DIC */
40
41 if ($this->object->getProvider()->getAvailability() == ilLTIConsumeProvider::AVAILABILITY_NONE) {
42 throw new ilLtiConsumerException('access denied!');
43 }
44
45 $command = $DIC->ctrl()->getCmd(self::CMD_SHOW_PAGE);
46
47 $this->{$command}();
48 }
49
50 protected function showPage()
51 {
52 global $DIC; /* @var \ILIAS\DI\Container $DIC */
53
54 $tpl = new ilTemplate('tpl.lti_content.html', true, true, 'Modules/LTIConsumer');
55
56 $tpl->setVariable("EMBEDDED_IFRAME_SRC", $DIC->ctrl()->getLinkTarget(
57 $this,
58 self::CMD_SHOW_EMBEDDED
59 ));
60
61 $DIC->ui()->mainTemplate()->setContent($tpl->get());
62 }
63
64 protected function showEmbedded()
65 {
66 $this->initCmixUser();
67
68 $tpl = new ilTemplate('tpl.lti_embedded.html', true, true, 'Modules/LTIConsumer');
69
70 foreach ($this->getLaunchParameters() as $field => $value) {
71 $tpl->setCurrentBlock('launch_parameter');
72 $tpl->setVariable('LAUNCH_PARAMETER', $field);
73 $tpl->setVariable('LAUNCH_PARAM_VALUE', $value);
74 $tpl->parseCurrentBlock();
75 }
76
77 $v = DEVMODE ? '?vers=' . time() : '?vers=' . ILIAS_VERSION_NUMERIC;
78 $tpl->setVariable("DELOS_CSS_HREF", 'templates/default/delos.css' . $v);
79 $tpl->setVariable("JQUERY_SRC", 'libs/bower/bower_components/jquery/dist/jquery.js' . $v);
80
81 $tpl->setVariable("LOADER_ICON_SRC", ilUtil::getImagePath("loader.svg"));
82 $tpl->setVariable('LAUNCH_URL', $this->object->getProvider()->getProviderUrl());
83
84 #$DIC->ui()->mainTemplate()->getStandardTemplate();
85 #$DIC->ui()->mainTemplate()->setContent($tpl->get());
86
87 echo $tpl->get();
88 exit;
89 }
90
91 protected function getLaunchParameters()
92 {
93 global $DIC; /* @var \ILIAS\DI\Container $DIC */
94
95 $ilLTIConsumerLaunch = new ilLTIConsumerLaunch($this->object->getRefId());
96 $launchContext = $ilLTIConsumerLaunch->getContext();
97
98 $launchContextType = ilLTIConsumerLaunch::getLTIContextType($launchContext["type"]);
99 $launchContextId = $launchContext["id"];
100 $launchContextTitle = $launchContext["title"];
101
103 $DIC->user()->getId(),
104 $this->object->getRefId(),
105 $this->object->getId()
106 );
107
108 return $this->object->buildLaunchParameters(
109 $this->cmixUser,
110 $token,
111 $launchContextType,
112 $launchContextId,
113 $launchContextTitle
114 );
115 }
116
117 public static function isEmbeddedLaunchRequest()
118 {
119 global $DIC; /* @var \ILIAS\DI\Container $DIC */
120
121 if ($DIC->ctrl()->getNextClass() != strtolower(self::class)) {
122 return false;
123 }
124
125 if ($DIC->ctrl()->getCmd() != self::CMD_SHOW_EMBEDDED) {
126 return false;
127 }
128
129 return true;
130 }
131
132 protected function initCmixUser()
133 {
134 global $DIC; /* @var \ILIAS\DI\Container $DIC */
135
136 $this->cmixUser = new ilCmiXapiUser($this->object->getId(), $DIC->user()->getId(), $this->object->getProvider()->getPrivacyIdent());
137 $user_ident = $this->cmixUser->getUsrIdent();
138 if ($user_ident == '' || $user_ident == null) {
139 $user_ident = ilCmiXapiUser::getIdent($this->object->getProvider()->getPrivacyIdent(), $DIC->user());
140 $this->cmixUser->setUsrIdent($user_ident);
141 $this->cmixUser->save();
142 }
143 }
144}
An exception for terminatinating execution or to throw for unit testing.
static fillToken($usrId, $refId, $objId, $lrsTypeId=0)
static getIdent($userIdentMode, ilObjUser $user)
special template class to simplify handling of ITX/PEAR
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
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$token
Definition: xapitoken.php:57
$DIC
Definition: xapitoken.php:46