ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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_WEBDAV = "ilContextWebdav";
25  const CONTEXT_RSS_AUTH = "ilContextRssAuth";
26  const CONTEXT_SESSION_REMINDER = "ilContextSessionReminder";
27  const CONTEXT_SOAP_WITHOUT_CLIENT = "ilContextSoapWithoutClient";
28  const CONTEXT_UNITTEST = "ilContextUnitTest";
29  const CONTEXT_REST = "ilContextRest";
30  const CONTEXT_SCORM = "ilContextScorm";
31  const CONTEXT_WAC = "ilContextWAC";
32  const CONTEXT_APACHE_SSO = 'ilContextApacheSSO';
33  const CONTEXT_SHIBBOLETH = 'ilContextShibboleth';
34 
35 
42  public static function init($a_type)
43  {
44  include_once "Services/Context/classes/class.".$a_type.".php";
45  self::$class_name = $a_type;
46  self::$type = $a_type;
47 
48  return true;
49  }
50 
57  protected static function callContext($a_method)
58  {
59  if(!self::$class_name)
60  {
61  self::init(self::CONTEXT_WEB);
62  }
63  return call_user_func(array(self::$class_name, $a_method));
64  }
65 
71  public static function supportsRedirects()
72  {
73  global $ilCtrl;
74 
75  // asynchronous calls must never be redirected
76  if($ilCtrl && $ilCtrl->isAsynch())
77  {
78  return false;
79  }
80 
81  return (bool)self::callContext("supportsRedirects");
82  }
83 
89  public static function hasUser()
90  {
91  return (bool)self::callContext("hasUser");
92  }
93 
99  public static function usesHTTP()
100  {
101  return (bool)self::callContext("usesHTTP");
102  }
103 
109  public static function hasHTML()
110  {
111  return (bool)self::callContext("hasHTML");
112  }
113 
119  public static function usesTemplate()
120  {
121  return (bool)self::callContext("usesTemplate");
122  }
123 
129  public static function initClient()
130  {
131  return (bool)self::callContext("initClient");
132  }
133 
139  public static function doAuthentication()
140  {
141  return (bool)self::callContext("doAuthentication");
142  }
143 
149  public static function getType()
150  {
151  return self::$type;
152  }
153 
161  public static function supportsPersistentSessions()
162  {
163  return (bool) self::callContext('supportsPersistentSessions');
164  }
165 }
166 
167 ?>
static hasUser()
Based on user authentication?
const CONTEXT_WAC
const CONTEXT_RSS
static usesHTTP()
Uses HTTP aka browser.
const CONTEXT_WEBDAV
const CONTEXT_UNITTEST
const CONTEXT_CRON
const CONTEXT_SCORM
const CONTEXT_SHIBBOLETH
const CONTEXT_RSS_AUTH
const CONTEXT_SESSION_REMINDER
global $ilCtrl
Definition: ilias.php:18
$a_type
Definition: workflow.php:93
static usesTemplate()
Uses template engine.
const CONTEXT_REST
static callContext($a_method)
Call current content.
static hasHTML()
Has HTML output.
const CONTEXT_ICAL
const CONTEXT_SOAP_WITHOUT_CLIENT
Create styles array
The data for the language used.
static init($a_type)
Init context by type.
Service context (factory) class.
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?