ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilLTIViewGUI Class Reference

@classDescription class for ILIAS ViewLTI More...

+ Collaboration diagram for ilLTIViewGUI:

Public Member Functions

 __construct (\ilObjUser $user)
 Constructor. More...
 
 executeCommand ()
 for ctrl commands More...
 
 activate ()
 activate LTI GUI More...
 
 deactivate ()
 deactivate LTI GUI More...
 
 isActive ()
 LTI is active. More...
 
 initGUI ()
 Set the environment backend for GUI (tree and locator behaviour, home link, ....) it is also possible to hide locator and treeicon, but if activated elsewhere a clean root folder is defined ToDo: conceptual discussion. More...
 
 render ($tpl, $part)
 
 addCss ()
 add css files to the header More...
 
 appendInlineCss ()
 append css styles just before </body> More...
 
 getHomeTitle ()
 
 exitLti ()
 exit LTI session and if defined redirecting to returnUrl ToDo: Standard Template with delos ... More...
 
 logout ()
 logout ILIAS and destroys Session and ilClientId cookie More...
 
 getSessionValue ($sess_key)
 get session value != '' More...
 

Static Public Member Functions

static getInstance ()
 for compatiblity with ilLTIRouterGUI More...
 

Data Fields

const LTI_DEBUG = false
 
const MSG_ERROR = "failure"
 messsage codes More...
 
const MSG_INFO = "info"
 
const MSG_QUESTION = "question"
 
const MSG_SUCCESS = "success"
 
 $show_locator = true
 public variables More...
 
 $member_view = false
 
 $member_view_url = ""
 
 $member_view_close_txt = ""
 

Protected Member Functions

 getHomeLink ()
 helper function for home link creation More...
 
 getCmdLink ($cmd)
 helper function for cmd link creation More...
 

Private Member Functions

 init ()
 Init LTI mode for lit authenticated users. More...
 
 isLTIUser ()
 get LTI Mode from Users->getAuthMode More...
 
 getNavEntries ()
 
 findEffectiveRefId ()
 Find effective ref_id for request. More...
 
 showLocator ($obj_type)
 
 log ($txt)
 

Private Attributes

 $user = null
 private variables More...
 
 $home_id = ""
 
 $home_obj_id = ""
 
 $home_type = ""
 
 $home_title = ""
 
 $home_url = ""
 
 $link_dir = ""
 
 $current_ref_id = ""
 
 $current_type = ""
 

Detailed Description

@classDescription class for ILIAS ViewLTI

Author
Stefan Schneider <schne.nosp@m.ider.nosp@m.@hrz..nosp@m.uni-.nosp@m.marbu.nosp@m.rg.d.nosp@m.e
Version
$id$

@ilCtrl_IsCalledBy ilLTIViewGUI: ilLTIRouterGUI

Definition at line 33 of file class.ilLTIViewGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilLTIViewGUI::__construct ( \ilObjUser  $user)

Constructor.

Returns

Definition at line 70 of file class.ilLTIViewGUI.php.

71 {
72 if (ilContext::hasUser()) {
73 $this->user = $user;
74 $this->init();
75 } else {
76 if ($this->isActive()) {
77 $this->deactivate();
78 }
79 }
80 }
user()
Definition: user.php:4
static hasUser()
Based on user authentication?
deactivate()
deactivate LTI GUI
$user
private variables
init()
Init LTI mode for lit authenticated users.
isActive()
LTI is active.

References $user, deactivate(), ilContext\hasUser(), init(), isActive(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ activate()

ilLTIViewGUI::activate ( )

activate LTI GUI

Returns
void

Definition at line 139 of file class.ilLTIViewGUI.php.

140 {
141 $this->findEffectiveRefId();
142 $_SESSION['il_lti_mode'] = "1";
143 $this->initGUI();
144 $this->log("lti view activated");
145 }
$_SESSION["AccountId"]
initGUI()
Set the environment backend for GUI (tree and locator behaviour, home link, ....) it is also possible...
findEffectiveRefId()
Find effective ref_id for request.

References $_SESSION, findEffectiveRefId(), initGUI(), and log().

Referenced by init().

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

◆ addCss()

ilLTIViewGUI::addCss ( )

add css files to the header

Definition at line 304 of file class.ilLTIViewGUI.php.

305 {
306 $arr = array();
307 //$arr[] = "./Services/LTI/templates/default/hide.css";
308 return $arr;
309 }

◆ appendInlineCss()

ilLTIViewGUI::appendInlineCss ( )

append css styles just before </body>

Definition at line 314 of file class.ilLTIViewGUI.php.

315 {
316 $arr = array();
317 $arr[] = "./Services/LTI/templates/default/lti.css";
318
319 if (isset($_SESSION['lti_launch_css_url']) && $_SESSION['lti_launch_css_url'] != "") {
320 $arr[] = $_SESSION['lti_launch_css_url'];
321 }
322 return $arr;
323 }

References $_SESSION.

◆ deactivate()

ilLTIViewGUI::deactivate ( )

deactivate LTI GUI

Returns
void

Definition at line 151 of file class.ilLTIViewGUI.php.

152 {
153 unset($_SESSION['il_lti_mode']);
154 $this->log("lti view deactivated");
155 }

References $_SESSION, and log().

Referenced by __construct(), init(), and logout().

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

◆ executeCommand()

ilLTIViewGUI::executeCommand ( )

for ctrl commands

Definition at line 124 of file class.ilLTIViewGUI.php.

125 {
126 global $ilCtrl;
127 $cmd = $ilCtrl->getCmd();
128 switch ($cmd) {
129 case 'exit':
130 $this->exitLti();
131 break;
132 }
133 }
exitLti()
exit LTI session and if defined redirecting to returnUrl ToDo: Standard Template with delos ....
global $ilCtrl
Definition: ilias.php:18

References $ilCtrl, and exitLti().

+ Here is the call graph for this function:

◆ exitLti()

ilLTIViewGUI::exitLti ( )

exit LTI session and if defined redirecting to returnUrl ToDo: Standard Template with delos ...

Definition at line 342 of file class.ilLTIViewGUI.php.

343 {
344 global $lng;
345 $lng->loadLanguageModule("lti");
346 $this->log("exitLti");
347 if ($this->getSessionValue('lti_launch_presentation_return_url') === '') {
348 $tplExit = new ilTemplate("tpl.lti_exit.html", true, true, "Services/LTI");
349 $tplExit->setVariable('TXT_LTI_EXITED', $lng->txt('lti_exited'));
350 $tplExit->setVariable('LTI_EXITED_INFO', $lng->txt('lti_exited_info'));
351 $html = $tplExit->get();
352 $this->logout();
353 print $html;
354 exit;
355 } else {
356 $this->logout();
357 header('Location: ' . $_SESSION['lti_launch_presentation_return_url']);
358 exit;
359 }
360 }
if(! $in) print
logout()
logout ILIAS and destroys Session and ilClientId cookie
getSessionValue($sess_key)
get session value != ''
special template class to simplify handling of ITX/PEAR
$html
Definition: example_001.php:87
global $lng
Definition: privfeed.php:17

References $_SESSION, $html, $lng, exit, getSessionValue(), log(), logout(), and print.

Referenced by executeCommand().

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

◆ findEffectiveRefId()

ilLTIViewGUI::findEffectiveRefId ( )
private

Find effective ref_id for request.

Definition at line 380 of file class.ilLTIViewGUI.php.

381 {
382 if ((int) $_GET['ref_id']) {
383 $this->current_type = ilObject::_lookupType($_GET['ref_id'], true);
384 return $this->current_ref_id = (int) $_GET['ref_id'];
385 }
386
387 $target_arr = explode('_', (string) $_GET['target']);
388 if (isset($target_arr[1]) and (int) $target_arr[1]) {
389 $this->current_type = ilObject::_lookupType($target_arr[1], true);
391 return $this->current_ref_id = (int) $target_arr[1];
392 }
393 }
$_GET["client_id"]
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
$target_arr
Definition: goto.php:47

References $_GET, $target_arr, ilObject\_lookupObjectId(), ilObject\_lookupTitle(), and ilObject\_lookupType().

Referenced by activate().

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

◆ getCmdLink()

ilLTIViewGUI::getCmdLink (   $cmd)
protected

helper function for cmd link creation

Definition at line 407 of file class.ilLTIViewGUI.php.

408 {
409 global $ilCtrl;
410 $targetScript = ($ilCtrl->getTargetScript() !== 'ilias.php') ? "ilias.php" : "";
411 return $this->link_dir . $targetScript . $ilCtrl->getLinkTargetByClass(array('illtiroutergui',strtolower(get_class($this))), $cmd) . "&baseClass=illtiroutergui";
412 }

References $ilCtrl.

Referenced by render().

+ Here is the caller graph for this function:

◆ getHomeLink()

ilLTIViewGUI::getHomeLink ( )
protected

helper function for home link creation

Definition at line 328 of file class.ilLTIViewGUI.php.

329 {
330 return $this->link_dir . "goto.php?target=" . $this->home_type . "_" . $this->home_id;
331 }

References $home_id.

Referenced by getNavEntries(), and initGUI().

+ Here is the caller graph for this function:

◆ getHomeTitle()

ilLTIViewGUI::getHomeTitle ( )

Definition at line 333 of file class.ilLTIViewGUI.php.

334 {
335 return ilObject::_lookupTitle($this->home_obj_id);
336 }

References ilObject\_lookupTitle().

Referenced by getNavEntries(), and initGUI().

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

◆ getInstance()

static ilLTIViewGUI::getInstance ( )
static

for compatiblity with ilLTIRouterGUI

Definition at line 103 of file class.ilLTIViewGUI.php.

104 {
105 global $DIC;
106 return $DIC["lti"];
107 }
global $DIC
Definition: saml.php:7

References $DIC.

◆ getNavEntries()

ilLTIViewGUI::getNavEntries ( )
private

Definition at line 245 of file class.ilLTIViewGUI.php.

246 {
247 global $lng, $ilNavigationHistory, $ilSetting, $ilCtrl;
248 include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
249 $gl = new ilGroupedListGUI();
250 $gl->setAsDropDown(true);
251
252 include_once("./Services/Link/classes/class.ilLink.php");
253
254 $icon = ilUtil::img(ilObject::_getIcon((int) $this->home_obj_id, "tiny"));
255
256 $gl->addEntry(
257 $icon . " " . $this->getHomeTitle(),
258 $this->getHomeLink(),
259 "_self"
260 );
261
262
263 $items = $ilNavigationHistory->getItems();
264 reset($items);
265 $cnt = 0;
266 $first = true;
267
268 foreach ($items as $k => $item) {
269 if ($cnt >= 10) {
270 break;
271 }
272
273 if (!isset($item["ref_id"]) || !isset($_GET["ref_id"]) ||
274 ($item["ref_id"] != $_GET["ref_id"] || !$first) && $this->home_id != $item["ref_id"]) { // do not list current item
275 if ($cnt == 0) {
276 $gl->addGroupHeader($lng->txt("last_visited"), "ilLVNavEnt");
277 }
278 $obj_id = ilObject::_lookupObjId($item["ref_id"]);
279 $cnt++;
280 $icon = ilUtil::img(ilObject::_getIcon($obj_id, "tiny"));
281 $ititle = ilUtil::shortenText(strip_tags($item["title"]), 50, true); // #11023
282 $gl->addEntry($icon . " " . $ititle, $item["link"], "_self", "", "ilLVNavEnt");
283 }
284 $first = false;
285 }
286
287 if ($cnt > 0) {
288 $gl->addEntry(
289 "» " . $lng->txt("remove_entries"),
290 "#",
291 "",
292 "return il.MainMenu.removeLastVisitedItems('" .
293 $ilCtrl->getLinkTargetByClass("ilnavigationhistorygui", "removeEntries", "", true) . "');",
294 "ilLVNavEnt"
295 );
296 }
297
298 return $gl->getHTML();
299 }
Grouped list GUI class.
getHomeLink()
helper function for home link creation
static _lookupObjId($a_id)
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
global $ilSetting
Definition: privfeed.php:17

References $_GET, $ilCtrl, $ilSetting, $lng, ilObject\_getIcon(), ilObject\_lookupObjId(), getHomeLink(), getHomeTitle(), ilUtil\img(), and ilUtil\shortenText().

Referenced by render().

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

◆ getSessionValue()

ilLTIViewGUI::getSessionValue (   $sess_key)

get session value != ''

Parameters
$sess_keystring
Returns
string

Definition at line 420 of file class.ilLTIViewGUI.php.

421 {
422 if (isset($_SESSION[$sess_key]) && $_SESSION[$sess_key] != '') {
423 return $_SESSION[$sess_key];
424 } else {
425 return '';
426 }
427 }

References $_SESSION.

Referenced by exitLti().

+ Here is the caller graph for this function:

◆ init()

ilLTIViewGUI::init ( )
private

Init LTI mode for lit authenticated users.

Definition at line 85 of file class.ilLTIViewGUI.php.

86 {
87 $this->link_dir = (defined("ILIAS_MODULE"))
88 ? "../"
89 : "";
90 if ($this->isLTIUser()) {
91 $this->activate();
92 } else {
93 if ($this->isActive()) {
94 $this->deactivate();
95 }
96 }
97 }
isLTIUser()
get LTI Mode from Users->getAuthMode
activate()
activate LTI GUI
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27

References activate(), deactivate(), defined, isActive(), and isLTIUser().

Referenced by __construct().

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

◆ initGUI()

ilLTIViewGUI::initGUI ( )

Set the environment backend for GUI (tree and locator behaviour, home link, ....) it is also possible to hide locator and treeicon, but if activated elsewhere a clean root folder is defined ToDo: conceptual discussion.

Definition at line 171 of file class.ilLTIViewGUI.php.

172 {
173 global $lng;
174 $this->log("initGUI");
175 $lng->loadLanguageModule("lti");
176 $baseclass = strtolower($_GET['baseClass']);
177 $cmdclass = strtolower($_GET['cmdClass']);
178
179 // init home_id, home_type, home_url and home_items if not already set
180 if ($this->home_id === '') {
181 $this->home_id = $_SESSION['lti_context_id'];
182 }
183 if ($this->home_obj_id === '') {
184 $this->home_obj_id = ilObject::_lookupObjectId($this->home_id);
185 }
186 if ($this->home_type === '') {
187 $this->home_type = ilObject::_lookupType($this->home_id, true);
188 $this->show_locator = $this->showLocator($this->home_type);
189 }
190 if ($this->home_url === '') {
191 $this->home_url = $this->getHomeLink();
192 }
193 if ($this->home_title === '') {
194 $this->home_title = $this->getHomeTitle();
195 }
196
197 switch ($baseclass) {
198 case 'illtiroutergui':
199 return;
200 break;
201 }
202 }
showLocator($obj_type)

References $_GET, $_SESSION, $lng, ilObject\_lookupObjectId(), ilObject\_lookupType(), getHomeLink(), getHomeTitle(), log(), and showLocator().

Referenced by activate().

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

◆ isActive()

ilLTIViewGUI::isActive ( )

LTI is active.

Returns
boolean

Definition at line 161 of file class.ilLTIViewGUI.php.

162 {
163 return (isset($_SESSION['il_lti_mode']));
164 }

References $_SESSION.

Referenced by __construct(), and init().

+ Here is the caller graph for this function:

◆ isLTIUser()

ilLTIViewGUI::isLTIUser ( )
private

get LTI Mode from Users->getAuthMode

Returns
boolean

Definition at line 113 of file class.ilLTIViewGUI.php.

114 {
115 if (!$this->user instanceof ilObjUser) {
116 return false;
117 }
118 return (strpos($this->user->getAuthMode(), 'lti_') === 0);
119 }

References user().

Referenced by init().

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

◆ log()

ilLTIViewGUI::log (   $txt)
private

Definition at line 429 of file class.ilLTIViewGUI.php.

430 {
431 global $DIC;
432 if (self::LTI_DEBUG) {
433 $DIC->logger()->lti()->write($txt);
434 }
435 }
$txt
Definition: error.php:11

References $DIC, and $txt.

Referenced by activate(), deactivate(), exitLti(), and initGUI().

+ Here is the caller graph for this function:

◆ logout()

ilLTIViewGUI::logout ( )

logout ILIAS and destroys Session and ilClientId cookie

Definition at line 365 of file class.ilLTIViewGUI.php.

366 {
367 //$DIC->logger()->root()->debug("logout");
368 $this->deactivate();
370 //$this->dic['ilAuthSession']->logout();
371 $GLOBALS['DIC']['ilAuthSession']->logout();
372 // reset cookie
373 $client_id = $_COOKIE["ilClientId"];
374 ilUtil::setCookie("ilClientId", "");
375 }
$_COOKIE['client_id']
Definition: server.php:9
const SESSION_CLOSE_USER
static setClosingContext($a_context)
set closing context (for statistics)
static setCookie($a_cookie_name, $a_cookie_value='', $a_also_set_super_global=true, $a_set_cookie_invalid=false)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$client_id

References $_COOKIE, $client_id, $GLOBALS, deactivate(), ilSession\SESSION_CLOSE_USER, ilSession\setClosingContext(), and ilUtil\setCookie().

Referenced by exitLti().

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

◆ render()

ilLTIViewGUI::render (   $tpl,
  $part 
)

Definition at line 204 of file class.ilLTIViewGUI.php.

205 {
206 global $lng, $DIC;
207 $lng->loadLanguageModule("lti");
208 $f = $DIC->ui()->factory();
209 $renderer = $DIC->ui()->renderer();
210 switch ($part) {
211 case 'top_bar_header':
212 if (!$this->member_view) {
213 if (!$tpl->blockExists("header_top_title")) {
214 $tpl->addBlockFile("HEADER_TOP_TITLE", "header_top_title", "tpl.header_top_title.html", "Services/LTI");
215 }
216 $tpl->setVariable("TXT_HEADER_TITLE", $lng->txt("lti_session"));
217 } else {
218 if (!$tpl->blockExists("header_back_bl")) {
219 $tpl->addBlockFile("HEADER_BACK_BL", "header_back_bl", "tpl.header_back_bl.html", "Services/LTI");
220 }
221 $tpl->setVariable("URL_HEADER_BACK", $this->member_view_url);
222 //$tpl->setVariable("TXT_HEADER_BACK", $lng->txt("lti_back_to_home")); // ToDo: $lng variable
223 $tpl->setVariable("TXT_HEADER_BACK", $this->member_view_close_txt); // ToDo: $lng variable
224 }
225 break;
226 case 'view_nav':
227 $tpl->setVariable("TXT_VIEW_NAV", $lng->txt("lti_navigation")); // ToDo: language files
228 $nav_entries = $this->getNavEntries();
229 $tpl->setVariable("VIEW_NAV_EN", $nav_entries);
230
231 break;
232 case 'user_logged_in':
233 if (!$tpl->blockExists("userisloggedin")) {
234 $tpl->addBlockFile("USERLOGGEDIN", "userisloggedin", "tpl.user_logged_in.html", "Services/LTI");
235 }
236 $tpl->setVariable("LINK_LTI_EXIT", $this->getCmdLink('exit'));
237 $tpl->setVariable("TXT_LTI_EXIT", $lng->txt("lti_exit"));
238 $btn = $f->button()->close();
239 $btnHtml = $renderer->render($btn);
240 $tpl->setVariable("EXIT_BUTTON", $btnHtml);
241 break;
242 }
243 }
$tpl
Definition: ilias.php:10
getCmdLink($cmd)
helper function for cmd link creation

References $DIC, $lng, $tpl, getCmdLink(), and getNavEntries().

+ Here is the call graph for this function:

◆ showLocator()

ilLTIViewGUI::showLocator (   $obj_type)
private
Returns
bool

Definition at line 398 of file class.ilLTIViewGUI.php.

399 {
400 //return true;
401 return preg_match("/(crs|grp|cat|root|fold|lm)/", $obj_type);
402 }

Referenced by initGUI().

+ Here is the caller graph for this function:

Field Documentation

◆ $current_ref_id

ilLTIViewGUI::$current_ref_id = ""
private

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

◆ $current_type

ilLTIViewGUI::$current_type = ""
private

Definition at line 56 of file class.ilLTIViewGUI.php.

◆ $home_id

ilLTIViewGUI::$home_id = ""
private

Definition at line 49 of file class.ilLTIViewGUI.php.

Referenced by getHomeLink().

◆ $home_obj_id

ilLTIViewGUI::$home_obj_id = ""
private

Definition at line 50 of file class.ilLTIViewGUI.php.

◆ $home_title

ilLTIViewGUI::$home_title = ""
private

Definition at line 52 of file class.ilLTIViewGUI.php.

◆ $home_type

ilLTIViewGUI::$home_type = ""
private

Definition at line 51 of file class.ilLTIViewGUI.php.

◆ $home_url

ilLTIViewGUI::$home_url = ""
private

Definition at line 53 of file class.ilLTIViewGUI.php.

◆ $link_dir

ilLTIViewGUI::$link_dir = ""
private

Definition at line 54 of file class.ilLTIViewGUI.php.

◆ $member_view

ilLTIViewGUI::$member_view = false

Definition at line 62 of file class.ilLTIViewGUI.php.

◆ $member_view_close_txt

ilLTIViewGUI::$member_view_close_txt = ""

Definition at line 64 of file class.ilLTIViewGUI.php.

◆ $member_view_url

ilLTIViewGUI::$member_view_url = ""

Definition at line 63 of file class.ilLTIViewGUI.php.

◆ $show_locator

ilLTIViewGUI::$show_locator = true

public variables

Definition at line 61 of file class.ilLTIViewGUI.php.

◆ $user

ilLTIViewGUI::$user = null
private

private variables

Definition at line 48 of file class.ilLTIViewGUI.php.

Referenced by __construct().

◆ LTI_DEBUG

const ilLTIViewGUI::LTI_DEBUG = false

Definition at line 35 of file class.ilLTIViewGUI.php.

◆ MSG_ERROR

const ilLTIViewGUI::MSG_ERROR = "failure"

messsage codes

Definition at line 40 of file class.ilLTIViewGUI.php.

◆ MSG_INFO

const ilLTIViewGUI::MSG_INFO = "info"

Definition at line 41 of file class.ilLTIViewGUI.php.

◆ MSG_QUESTION

const ilLTIViewGUI::MSG_QUESTION = "question"

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

◆ MSG_SUCCESS

const ilLTIViewGUI::MSG_SUCCESS = "success"

Definition at line 43 of file class.ilLTIViewGUI.php.


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