ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilContext.php
Go to the documentation of this file.
1<?php
2
26{
27 protected static string $class_name = "";
28 protected static string $type = "";
29
30 public const CONTEXT_WEB = ilContextWeb::class;
31 public const CONTEXT_CRON = ilContextCron::class;
32 public const CONTEXT_RSS = ilContextRss::class;
33 public const CONTEXT_ICAL = ilContextIcal::class;
34 public const CONTEXT_SOAP = ilContextSoap::class;
35 public const CONTEXT_SOAP_NO_AUTH = ilContextSoapNoAuth::class;
36 public const CONTEXT_WEBDAV = ilContextWebdav::class;
37 public const CONTEXT_RSS_AUTH = ilContextRssAuth::class;
38 public const CONTEXT_SESSION_REMINDER = ilContextSessionReminder::class;
39 public const CONTEXT_SOAP_WITHOUT_CLIENT = ilContextSoapWithoutClient::class;
40 public const CONTEXT_UNITTEST = ilContextUnitTest::class;
41 public const CONTEXT_REST = ilContextRest::class;
42 public const CONTEXT_SCORM = ilContextScorm::class;
43 public const CONTEXT_WAC = ilContextWAC::class;
44 public const CONTEXT_APACHE_SSO = ilContextApacheSSO::class;
45 public const CONTEXT_SHIBBOLETH = ilContextShibboleth::class;
46 public const CONTEXT_LTI_PROVIDER = ilContextLTIProvider::class;
47 public const CONTEXT_SAML = ilContextSaml::class;
48
52 public static function init(string $a_type): bool
53 {
54 self::$class_name = $a_type;
55 self::$type = $a_type;
56
57 return true;
58 }
59
64 public static function directCall(string $a_type, string $a_method)
65 {
66 $class_name = $a_type;
67 if ($class_name && method_exists($class_name, $a_method)) {
68 return call_user_func(array($class_name, $a_method));
69 }
70
71 return null;
72 }
73
78 protected static function callContext(string $a_method, array $args = [])
79 {
80 if (!self::$class_name) {
81 self::init(self::CONTEXT_WEB);
82 }
83 return call_user_func_array([self::$class_name, $a_method], $args);
84 }
85
89 public static function supportsRedirects(): bool
90 {
91 global $DIC;
92
93 $ilCtrl = null;
94 if (isset($DIC["ilCtrl"])) {
95 $ilCtrl = $DIC->ctrl();
96 }
97
98 // asynchronous calls must never be redirected
99 if ($ilCtrl && $ilCtrl->isAsynch()) {
100 return false;
101 }
102
103 return (bool) self::callContext("supportsRedirects");
104 }
105
109 public static function hasUser(): bool
110 {
111 return (bool) self::callContext("hasUser");
112 }
113
117 public static function usesHTTP(): bool
118 {
119 return (bool) self::callContext("usesHTTP");
120 }
121
125 public static function hasHTML(): bool
126 {
127 return (bool) self::callContext("hasHTML");
128 }
129
133 public static function usesTemplate(): bool
134 {
135 return (bool) self::callContext("usesTemplate");
136 }
137
141 public static function initClient(): bool
142 {
143 return (bool) self::callContext("initClient");
144 }
145
149 public static function doAuthentication(): bool
150 {
151 return (bool) self::callContext("doAuthentication");
152 }
153
157 public static function supportsPushMessages(): bool
158 {
159 return (bool) self::callContext("supportsPushMessages");
160 }
161
165 public static function getType(): string
166 {
167 return self::$type;
168 }
169
175 public static function supportsPersistentSessions(): bool
176 {
177 return (bool) self::callContext('supportsPersistentSessions');
178 }
179
183 public static function isSessionMainContext(): bool
184 {
185 return (bool) self::callContext('isSessionMainContext');
186 }
187
188 public static function modifyHttpPath(string $httpPath): string
189 {
190 return (string) self::callContext('modifyHttpPath', [$httpPath]);
191 }
192}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CONTEXT_CRON
static string $type
static usesTemplate()
Uses template engine.
const CONTEXT_RSS_AUTH
static doAuthentication()
Try authentication.
const CONTEXT_SOAP_WITHOUT_CLIENT
const CONTEXT_WEB
const CONTEXT_SOAP_NO_AUTH
const CONTEXT_WEBDAV
static modifyHttpPath(string $httpPath)
const CONTEXT_SHIBBOLETH
const CONTEXT_UNITTEST
const CONTEXT_APACHE_SSO
static supportsRedirects()
Are redirects supported?
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
static callContext(string $a_method, array $args=[])
Call current content.
static string $class_name
const CONTEXT_SESSION_REMINDER
static directCall(string $a_type, string $a_method)
Call context method directly without internal handling.
static supportsPersistentSessions()
Check if context supports persistent session handling.
static getType()
Get context type.
static hasHTML()
Has HTML output.
static init(string $a_type)
Init context by type.
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 $DIC
Definition: shib_login.php:26