ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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 
13 class ilContext
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;
24  const CONTEXT_RSS_AUTH = 7;
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  {
61  case self::CONTEXT_WEB:
62  return "ilContextWeb";
63 
64  case self::CONTEXT_CRON:
65  return "ilContextCron";
66 
67  case self::CONTEXT_RSS:
68  return "ilContextRss";
69 
70  case self::CONTEXT_ICAL:
71  return "ilContextIcal";
72 
73  case self::CONTEXT_SOAP:
74  return "ilContextSoap";
75 
76  case self::CONTEXT_WEBDAV:
77  return "ilContextWebdav";
78 
79  case self::CONTEXT_RSS_AUTH:
80  return "ilContextRssAuth";
81 
82  case self::CONTEXT_WEB_ACCESS_CHECK:
83  return "ilContextWebAccessCheck";
84 
85  case self::CONTEXT_SESSION_REMINDER:
86  return "ilContextSessionReminder";
87 
88  case self::CONTEXT_SOAP_WITHOUT_CLIENT:
89  return "ilContextSoapWithoutClient";
90 
91  case self::CONTEXT_UNITTEST:
92  return "ilContextUnitTest";
93 
94  case self::CONTEXT_REST:
95  return 'ilContextRest';
96 
97  case self::CONTEXT_SCORM:
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 ?>