ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilContext.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
15{
16 protected static $class_name; // [string]
17 protected static $type; // [string]
18
19 const CONTEXT_WEB = "ilContextWeb";
20 const CONTEXT_CRON = "ilContextCron";
21 const CONTEXT_RSS = "ilContextRss";
22 const CONTEXT_ICAL = "ilContextIcal";
23 const CONTEXT_SOAP = "ilContextSoap";
24 const CONTEXT_SOAP_NO_AUTH = 'ilContextSoapNoAuth';
25 const CONTEXT_WEBDAV = "ilContextWebdav";
26 const CONTEXT_RSS_AUTH = "ilContextRssAuth";
27 const CONTEXT_SESSION_REMINDER = "ilContextSessionReminder";
28 const CONTEXT_SOAP_WITHOUT_CLIENT = "ilContextSoapWithoutClient";
29 const CONTEXT_UNITTEST = "ilContextUnitTest";
30 const CONTEXT_REST = "ilContextRest";
31 const CONTEXT_SCORM = "ilContextScorm";
32 const CONTEXT_WAC = "ilContextWAC";
33 const CONTEXT_APACHE_SSO = 'ilContextApacheSSO';
34 const CONTEXT_SHIBBOLETH = 'ilContextShibboleth';
35 const CONTEXT_LTI_PROVIDER = 'ilContextLTIProvider';
36 const CONTEXT_SAML = 'ilContextSaml';
37
38
45 public static function init($a_type)
46 {
47 include_once "Services/Context/classes/class." . $a_type . ".php";
48 self::$class_name = $a_type;
50
51 return true;
52 }
53
60 public static function directCall($a_type, $a_method)
61 {
63 if ($class_name) {
64 include_once "Services/Context/classes/class." . $class_name . ".php";
65 if (method_exists($class_name, $a_method)) {
66 return call_user_func(array($class_name, $a_method));
67 }
68 }
69 }
70
77 protected static function callContext($a_method)
78 {
79 if (!self::$class_name) {
80 self::init(self::CONTEXT_WEB);
81 }
82 return call_user_func(array(self::$class_name, $a_method));
83 }
84
90 public static function supportsRedirects()
91 {
92 global $DIC;
93
94 $ilCtrl = null;
95 if (isset($DIC["ilCtrl"])) {
96 $ilCtrl = $DIC->ctrl();
97 }
98
99 // asynchronous calls must never be redirected
100 if ($ilCtrl && $ilCtrl->isAsynch()) {
101 return false;
102 }
103
104 return (bool) self::callContext("supportsRedirects");
105 }
106
112 public static function hasUser()
113 {
114 return (bool) self::callContext("hasUser");
115 }
116
122 public static function usesHTTP()
123 {
124 return (bool) self::callContext("usesHTTP");
125 }
126
132 public static function hasHTML()
133 {
134 return (bool) self::callContext("hasHTML");
135 }
136
142 public static function usesTemplate()
143 {
144 return (bool) self::callContext("usesTemplate");
145 }
146
152 public static function initClient()
153 {
154 return (bool) self::callContext("initClient");
155 }
156
162 public static function doAuthentication()
163 {
164 return (bool) self::callContext("doAuthentication");
165 }
166
172 public static function supportsPushMessages()
173 {
174 return (bool) self::callContext("supportsPushMessages");
175 }
176
182 public static function getType()
183 {
184 return self::$type;
185 }
186
194 public static function supportsPersistentSessions()
195 {
196 return (bool) self::callContext('supportsPersistentSessions');
197 }
198
204 public static function isSessionMainContext()
205 {
206 return (bool) self::callContext('isSessionMainContext');
207 }
208}
An exception for terminatinating execution or to throw for unit testing.
Service context (factory) class.
const CONTEXT_CRON
static usesTemplate()
Uses template engine.
const CONTEXT_RSS_AUTH
static doAuthentication()
Try authentication.
const CONTEXT_SOAP_WITHOUT_CLIENT
static callContext($a_method)
Call current content.
const CONTEXT_WEB
const CONTEXT_SOAP_NO_AUTH
const CONTEXT_WEBDAV
const CONTEXT_SHIBBOLETH
const CONTEXT_UNITTEST
static init($a_type)
Init context by type.
const CONTEXT_APACHE_SSO
static supportsRedirects()
Are redirects supported?
static $class_name
static hasUser()
Based on user authentication?
const CONTEXT_SAML
const CONTEXT_SCORM
static isSessionMainContext()
Context that are not only temporary in a session (e.g.
const CONTEXT_ICAL
const CONTEXT_SESSION_REMINDER
static supportsPersistentSessions()
Check if context supports persistent session handling.
static getType()
Get context type.
static hasHTML()
Has HTML output.
static directCall($a_type, $a_method)
Call context method directly without internal handling.
static usesHTTP()
Uses HTTP aka browser.
const CONTEXT_LTI_PROVIDER
static initClient()
Init client.
static supportsPushMessages()
Supports push messages.
const CONTEXT_SOAP
const CONTEXT_RSS
const CONTEXT_REST
const CONTEXT_WAC
global $ilCtrl
Definition: ilias.php:18
$type
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92