ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
14 class ilContext
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;
49  self::$type = $a_type;
50 
51  return true;
52  }
53 
60  public static function directCall($a_type, $a_method)
61  {
62  $class_name = $a_type;
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, array $args = [])
78  {
79  if (!self::$class_name) {
80  self::init(self::CONTEXT_WEB);
81  }
82 
83  return call_user_func_array([self::$class_name, $a_method], $args);
84  }
85 
91  public static function supportsRedirects()
92  {
93  global $DIC;
94 
95  $ilCtrl = null;
96  if (isset($DIC["ilCtrl"])) {
97  $ilCtrl = $DIC->ctrl();
98  }
99 
100  // asynchronous calls must never be redirected
101  if ($ilCtrl && $ilCtrl->isAsynch()) {
102  return false;
103  }
104 
105  return (bool) self::callContext("supportsRedirects");
106  }
107 
113  public static function hasUser()
114  {
115  return (bool) self::callContext("hasUser");
116  }
117 
123  public static function usesHTTP()
124  {
125  return (bool) self::callContext("usesHTTP");
126  }
127 
133  public static function hasHTML()
134  {
135  return (bool) self::callContext("hasHTML");
136  }
137 
143  public static function usesTemplate()
144  {
145  return (bool) self::callContext("usesTemplate");
146  }
147 
153  public static function initClient()
154  {
155  return (bool) self::callContext("initClient");
156  }
157 
163  public static function doAuthentication()
164  {
165  return (bool) self::callContext("doAuthentication");
166  }
167 
173  public static function supportsPushMessages()
174  {
175  return (bool) self::callContext("supportsPushMessages");
176  }
177 
183  public static function getType()
184  {
185  return self::$type;
186  }
187 
195  public static function supportsPersistentSessions()
196  {
197  return (bool) self::callContext('supportsPersistentSessions');
198  }
199 
205  public static function isSessionMainContext()
206  {
207  return (bool) self::callContext('isSessionMainContext');
208  }
209 
214  public static function modifyHttpPath(string $httpPath) : string
215  {
216  return self::callContext('modifyHttpPath', [$httpPath]);
217  }
218 }
static hasUser()
Based on user authentication?
const CONTEXT_WAC
const CONTEXT_RSS
$type
static usesHTTP()
Uses HTTP aka browser.
const CONTEXT_WEBDAV
const CONTEXT_UNITTEST
const CONTEXT_CRON
const CONTEXT_SCORM
static isSessionMainContext()
Context that are not only temporary in a session (e.g.
const CONTEXT_LTI_PROVIDER
const CONTEXT_SHIBBOLETH
static directCall($a_type, $a_method)
Call context method directly without internal handling.
const CONTEXT_SOAP_NO_AUTH
const CONTEXT_RSS_AUTH
static modifyHttpPath(string $httpPath)
const CONTEXT_SESSION_REMINDER
static usesTemplate()
Uses template engine.
const CONTEXT_REST
const CONTEXT_SAML
static hasHTML()
Has HTML output.
const CONTEXT_ICAL
global $DIC
Definition: goto.php:24
static callContext($a_method, array $args=[])
Call current content.
const CONTEXT_SOAP_WITHOUT_CLIENT
static init($a_type)
Init context by type.
static supportsPushMessages()
Supports push messages.
static supportsPersistentSessions()
Check if context supports persistent session handling.
static $class_name
static initClient()
Init client.
const CONTEXT_WEB
static getType()
Get context type.
const CONTEXT_SOAP
static doAuthentication()
Try authentication.
const CONTEXT_APACHE_SSO
static supportsRedirects()
Are redirects supported?