ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 const CONTEXT_WAC = 14;
32
39 public static function init($a_type)
40 {
42 if($class_name)
43 {
44 include_once "Services/Context/classes/class.".$class_name.".php";
45 self::$class_name = $class_name;
46 self::$type = $a_type;
47 return true;
48 }
49 return false;
50 }
51
58 protected function getClassForType($a_type)
59 {
60 switch($a_type)
61 {
63 return "ilContextWeb";
64
66 return "ilContextCron";
67
69 return "ilContextRss";
70
72 return "ilContextIcal";
73
75 return "ilContextSoap";
76
78 return "ilContextWebdav";
79
81 return "ilContextRssAuth";
82
84 return "ilContextWebAccessCheck";
85
87 return "ilContextSessionReminder";
88
90 return "ilContextSoapWithoutClient";
91
93 return "ilContextUnitTest";
94
96 return 'ilContextRest';
97
99 return 'ilContextScorm';
100
102 return 'ilContextWAC';
103 }
104 }
105
112 protected static function callContext($a_method)
113 {
114 if(!self::$class_name)
115 {
116 self::init(self::CONTEXT_WEB);
117 }
118 return call_user_func(array(self::$class_name, $a_method));
119 }
120
126 public static function supportsRedirects()
127 {
128 global $ilCtrl;
129
130 // asynchronous calls must never be redirected
131 if($ilCtrl && $ilCtrl->isAsynch())
132 {
133 return false;
134 }
135
136 return (bool)self::callContext("supportsRedirects");
137 }
138
144 public static function hasUser()
145 {
146 return (bool)self::callContext("hasUser");
147 }
148
154 public static function usesHTTP()
155 {
156 return (bool)self::callContext("usesHTTP");
157 }
158
164 public static function hasHTML()
165 {
166 return (bool)self::callContext("hasHTML");
167 }
168
174 public static function usesTemplate()
175 {
176 return (bool)self::callContext("usesTemplate");
177 }
178
184 public static function initClient()
185 {
186 return (bool)self::callContext("initClient");
187 }
188
194 public static function doAuthentication()
195 {
196 return (bool)self::callContext("doAuthentication");
197 }
198
204 public static function getType()
205 {
206 return self::$type;
207 }
208}
209
210?>
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
const CONTEXT_WAC
getClassForType($a_type)
Get class name for type id.
global $ilCtrl
Definition: ilias.php:18