ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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{
15 protected static $class_name; // [string]
16 protected static $type; // [int]
17
18 const CONTEXT_WEB = 1;
19 const CONTEXT_CRON = 2;
20 const CONTEXT_RSS = 3;
21 const CONTEXT_ICAL = 4;
22 const CONTEXT_SOAP = 5;
23 const CONTEXT_WEBDAV = 6;
28 const CONTEXT_UNITTEST = 11;
29 const CONTEXT_REST = 12;
30 const CONTEXT_SCORM = 13;
31
38 public static function init($a_type)
39 {
41 if($class_name)
42 {
43 include_once "Services/Context/classes/class.".$class_name.".php";
44 self::$class_name = $class_name;
45 self::$type = $a_type;
46 return true;
47 }
48 return false;
49 }
50
57 protected function getClassForType($a_type)
58 {
59 switch($a_type)
60 {
62 return "ilContextWeb";
63
65 return "ilContextCron";
66
68 return "ilContextRss";
69
71 return "ilContextIcal";
72
74 return "ilContextSoap";
75
77 return "ilContextWebdav";
78
80 return "ilContextRssAuth";
81
83 return "ilContextWebAccessCheck";
84
86 return "ilContextSessionReminder";
87
89 return "ilContextSoapWithoutClient";
90
92 return "ilContextUnitTest";
93
95 return 'ilContextRest';
96
98 return 'ilContextScorm';
99 }
100 }
101
108 protected static function callContext($a_method)
109 {
110 if(!self::$class_name)
111 {
112 self::init(self::CONTEXT_WEB);
113 }
114 return call_user_func(array(self::$class_name, $a_method));
115 }
116
122 public static function supportsRedirects()
123 {
124 global $ilCtrl;
125
126 // asynchronous calls must never be redirected
127 if($ilCtrl && $ilCtrl->isAsynch())
128 {
129 return false;
130 }
131
132 return (bool)self::callContext("supportsRedirects");
133 }
134
140 public static function hasUser()
141 {
142 return (bool)self::callContext("hasUser");
143 }
144
150 public static function usesHTTP()
151 {
152 return (bool)self::callContext("usesHTTP");
153 }
154
160 public static function hasHTML()
161 {
162 return (bool)self::callContext("hasHTML");
163 }
164
170 public static function usesTemplate()
171 {
172 return (bool)self::callContext("usesTemplate");
173 }
174
180 public static function initClient()
181 {
182 return (bool)self::callContext("initClient");
183 }
184
190 public static function doAuthentication()
191 {
192 return (bool)self::callContext("doAuthentication");
193 }
194
200 public static function getType()
201 {
202 return self::$type;
203 }
204}
205
206?>
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_WEBDAV
const CONTEXT_UNITTEST
static init($a_type)
Init context by type.
static supportsRedirects()
Are redirects supported?
static $class_name
static hasUser()
Based on user authentication?
const CONTEXT_SCORM
const CONTEXT_ICAL
const CONTEXT_WEB_ACCESS_CHECK
const CONTEXT_SESSION_REMINDER
static getType()
Get context type.
static hasHTML()
Has HTML output.
static usesHTTP()
Uses HTTP aka browser.
static initClient()
Init client.
const CONTEXT_SOAP
const CONTEXT_RSS
const CONTEXT_REST
getClassForType($a_type)
Get class name for type id.
global $ilCtrl
Definition: ilias.php:18