ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPStatusFactory.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 
18 {
19  static private $class_by_obj_id = array();
20 
21  function _getClassById($a_obj_id, $a_mode = NULL)
22  {
23  include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
24 
25  if($a_mode === NULL)
26  {
27  $a_mode = ilLPObjSettings::_lookupMode($a_obj_id);
28 
29  // please keep the cache in this if-block, otherwise default values
30  // will not trigger the include_once calls
31  if (isset(self::$class_by_obj_id[$a_obj_id]))
32  {
33  return self::$class_by_obj_id[$a_obj_id];
34  }
35  }
36 
37  switch($a_mode)
38  {
39  case LP_MODE_VISITS:
40  include_once 'Services/Tracking/classes/class.ilLPStatusVisits.php';
41  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusVisits';
42 
43  case LP_MODE_COLLECTION:
44  include_once 'Services/Tracking/classes/class.ilLPStatusCollection.php';
45  return self::$class_by_obj_id[$a_obj_id] ='ilLPStatusCollection';
46 
47  case LP_MODE_TLT:
48  include_once 'Services/Tracking/classes/class.ilLPStatusTypicalLearningTime.php';
49  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusTypicalLearningTime';
50 
51  case LP_MODE_SCORM:
52  include_once 'Services/Tracking/classes/class.ilLPStatusSCORM.php';
53  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusSCORM';
54 
56  include_once 'Services/Tracking/classes/class.ilLPStatus.php';
57  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatus';
58 
60  include_once 'Services/Tracking/classes/class.ilLPStatusTestFinished.php';
61  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusTestFinished';
62 
64  include_once 'Services/Tracking/classes/class.ilLPStatusTestPassed.php';
65  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusTestPassed';
66 
67  case LP_MODE_MANUAL:
68  include_once 'Services/Tracking/classes/class.ilLPStatusManual.php';
69  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusManual';
70 
72  include_once 'Services/Tracking/classes/class.ilLPStatusManualByTutor.php';
73  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusManualByTutor';
74 
76  include_once 'Services/Tracking/classes/class.ilLPStatusExerciseReturned.php';
77  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusExerciseReturned';
78 
79  case LP_MODE_OBJECTIVES:
80  include_once 'Services/Tracking/classes/class.ilLPStatusObjectives.php';
81  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusObjectives';
82 
84  include_once 'Services/Tracking/classes/class.ilLPStatusSCORMPackage.php';
85  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusSCORMPackage';
86 
87  case LP_MODE_EVENT:
88  include_once('./Services/Tracking/classes/class.ilLPStatusEvent.php');
89  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusEvent';
90 
91  case LP_MODE_PLUGIN:
92  include_once('./Services/Tracking/classes/class.ilLPStatusPlugin.php');
93  return self::$class_by_obj_id[$a_obj_id] = 'ilLPStatusPlugin';
94 
95  case LP_MODE_UNDEFINED:
96  $type = ilObject::_lookupType($a_obj_id);
97  $mode = ilLPObjSettings::__getDefaultMode($a_obj_id, $type);
98  if($mode != LP_MODE_UNDEFINED)
99  {
100  return self::$class_by_obj_id[$a_obj_id] = self::_getClassById($a_obj_id, $mode);
101  }
102  // fallthrough
103 
104  default:
105  echo "ilLPStatusFactory: unknown type ".ilLPObjSettings::_lookupMode($a_obj_id);
106  exit;
107  }
108  }
109 
110  function _getClassByIdAndType($a_obj_id,$a_type)
111  {
112  // id is ignored in the moment
113  switch($a_type)
114  {
115  case 'event':
116  include_once 'Services/Tracking/classes/class.ilLPStatusEvent.php';
117  return 'ilLPStatusEvent';
118 
119  default:
120  echo "ilLPStatusFactory: unknown type: ".$a_type;
121  exit;
122  }
123  }
124 
125  function &_getInstance($a_obj_id, $a_mode = NULL)
126  {
127  include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
128 
129  if($a_mode === NULL)
130  {
131  $a_mode = ilLPObjSettings::_lookupMode($a_obj_id);
132  }
133 
134  switch($a_mode)
135  {
136  case LP_MODE_VISITS:
137  include_once 'Services/Tracking/classes/class.ilLPStatusVisits.php';
138  return new ilLPStatusVisits($a_obj_id);
139 
140  case LP_MODE_COLLECTION:
141  include_once 'Services/Tracking/classes/class.ilLPStatusCollection.php';
142  return new ilLPStatusCollection($a_obj_id);
143 
144  case LP_MODE_TLT:
145  include_once 'Services/Tracking/classes/class.ilLPStatusTypicalLearningTime.php';
146  return new ilLPStatusTypicalLearningTime($a_obj_id);
147 
148  case LP_MODE_SCORM:
149  include_once 'Services/Tracking/classes/class.ilLPStatusSCORM.php';
150  return new ilLPStatusSCORM($a_obj_id);
151 
153  include_once 'Services/Tracking/classes/class.ilLPStatusTestFinished.php';
154  return new ilLPStatusTestFinished($a_obj_id);
155 
156  case LP_MODE_TEST_PASSED:
157  include_once 'Services/Tracking/classes/class.ilLPStatusTestPassed.php';
158  return new ilLPStatusTestPassed($a_obj_id);
159 
160  case LP_MODE_MANUAL:
161  include_once 'Services/Tracking/classes/class.ilLPStatusManual.php';
162  return new ilLPStatusManual($a_obj_id);
163 
165  include_once 'Services/Tracking/classes/class.ilLPStatusManualByTutor.php';
166  return new ilLPStatusManualByTutor($a_obj_id);
167 
169  include_once 'Services/Tracking/classes/class.ilLPStatusExerciseReturned.php';
170  return new ilLPStatusExerciseReturned($a_obj_id);
171 
172  case LP_MODE_OBJECTIVES:
173  include_once 'Services/Tracking/classes/class.ilLPStatusObjectives.php';
174  return new ilLPStatusObjectives($a_obj_id);
175 
176  case LP_MODE_EVENT:
177  include_once 'Services/Tracking/classes/class.ilLPStatusEvent.php';
178  return new ilLPStatusEvent($a_obj_id);
179 
180  case LP_MODE_PLUGIN:
181  include_once 'Services/Tracking/classes/class.ilLPStatusPlugin.php';
182  return new ilLPStatusPlugin($a_obj_id);
183 
184  case LP_MODE_UNDEFINED:
185  $type = ilObject::_lookupType($a_obj_id);
186  $mode = ilLPObjSettings::__getDefaultMode($a_obj_id, $type);
187  if($mode != LP_MODE_UNDEFINED)
188  {
189  return self::_getInstance($a_obj_id, $mode);
190  }
191  // fallthrough
192 
193  default:
194  echo "ilLPStatusFactory: unknown type ".ilLPObjSettings::_lookupMode($a_obj_id);
195  exit;
196  }
197  }
198 }
199 ?>