ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilCachedComponentData.php
Go to the documentation of this file.
1 <?php
2 
10 
14  protected $cached_results = array();
18  protected static $instance;
22  protected $changed = false;
26  protected $loaded = false;
30  protected $obj_def_name_to_id = array();
38  protected $il_component = array();
42  protected $il_object_def = array();
46  protected $il_object_subobj = array();
50  protected $subobj_for_parent = array();
62  protected $il_pluginslot_by_id = array();
70  protected $il_plugin_by_id = array();
74  protected $il_object_group = array();
78  protected $il_object_sub_type = array();
82  protected $il_plugin_active = array();
86  protected $il_plugin_by_name = array();
87 
88 
89  protected function __construct() {
91  $this->readFromDB();
92  }
93 
94 
98  public function getLoaded() {
99  return $this->loaded;
100  }
101 
102 
106  public function setLoaded($loaded) {
107  $this->loaded = $loaded;
108  }
109 
110 
111  protected function readFromDB() {
112  global $ilDB;
117  $set = $ilDB->query('SELECT * FROM il_component');
118  while ($rec = $ilDB->fetchAssoc($set)) {
119  $this->il_component[$rec['id']] = $rec;
120  $this->obj_def_name_to_id[$rec['id']] = $rec['name'];
121  $this->obj_def_name_and_type_raw[$rec['type']][$rec['name']] = $rec;
122  }
123 
124  $set = $ilDB->query('SELECT * FROM il_object_def');
125  while ($rec = $ilDB->fetchAssoc($set)) {
126  $this->il_object_def[$rec['id']] = $rec;
127  }
128 
129  $set = $ilDB->query('SELECT * FROM il_object_subobj');
130  while ($rec = $ilDB->fetchAssoc($set)) {
131  $this->il_object_subobj[] = $rec;
132  $parent = $rec['parent'];
133  $this->subobj_for_parent[$parent][] = $rec;
134  }
135  $set = $ilDB->query('SELECT DISTINCT(id) AS sid, parent, il_object_def.* FROM il_object_def, il_object_subobj WHERE NOT (system = 1) AND NOT (sideblock = 1) AND subobj = id');
136  while ($rec = $ilDB->fetchAssoc($set)) {
137  $this->grouped_rep_obj_types[$rec['parent']][] = $rec;
138  }
139 
140  $set = $ilDB->query('SELECT * FROM il_pluginslot');
141  while ($rec = $ilDB->fetchAssoc($set)) {
142  $this->il_pluginslot_by_comp[$rec['component']][] = $rec;
143  $this->il_pluginslot_by_id[$rec['id']] = $rec;
144  $this->il_pluginslot_by_name[$rec['name']] = $rec;
145  }
146 
147  $set = $ilDB->query('SELECT * FROM il_plugin');
148  $this->il_plugin_active = array();
149  while ($rec = $ilDB->fetchAssoc($set)) {
150  $this->il_plugin_by_id[$rec['plugin_id']] = $rec;
151  $this->il_plugin_by_name[$rec['name']] = $rec;
152  if ($rec['active'] == 1) {
153  $this->il_plugin_active[$rec['slot_id']][] = $rec;
154  }
155  }
156  $set = $ilDB->query('SELECT * FROM il_object_group');
157  while ($rec = $ilDB->fetchAssoc($set)) {
158  $this->il_object_group[$rec['id']] = $rec;
159  }
160  $set = $ilDB->query('SELECT * FROM il_object_sub_type');
161  while ($rec = $ilDB->fetchAssoc($set)) {
162  $this->il_object_sub_type[$rec['obj_type']][] = $rec;
163  }
164  }
165 
166 
170  public function getIlComponent() {
171  return $this->il_component;
172  }
173 
174 
178  public function setIlComponent($il_component) {
179  $this->il_component = $il_component;
180  }
181 
182 
186  public function getObjDefNameAndTypeRaw() {
188  }
189 
190 
195  $this->obj_def_name_and_type_raw = $obj_def_name_and_type_raw;
196  }
197 
198 
202  public function getObjDefNameToId() {
204  }
205 
206 
211  $this->obj_def_name_to_id = $obj_def_name_to_id;
212  }
213 
214 
218  public function getIlObjectDef() {
219  return $this->il_object_def;
220  }
221 
222 
226  public function setIlObjectDef($il_object_def) {
227  $this->il_object_def = $il_object_def;
228  }
229 
230 
234  public function getIlObjectSubobj() {
236  }
237 
238 
243  $this->il_object_subobj = $il_object_subobj;
244  }
245 
246 
250  public function getGroupedRepObjTypes() {
252  }
253 
254 
259  $this->grouped_rep_obj_types = $grouped_rep_obj_types;
260  }
261 
262 
266  public function getIlPluginslotByComp() {
268  }
269 
270 
274  public function setIlPluginslotByComp($il_pluginslot_by_service) {
275  $this->il_pluginslot_by_comp = $il_pluginslot_by_service;
276  }
277 
278 
282  public function getIlPluginslotById() {
284  }
285 
286 
291  $this->il_pluginslot_by_id = $il_pluginslot_by_id;
292  }
293 
294 
298  public function getIlPluginslotByName() {
300  }
301 
302 
307  $this->il_pluginslot_by_name = $il_pluginslot_by_name;
308  }
309 
310 
314  public function getIlPluginById() {
315  return $this->il_plugin_by_id;
316  }
317 
318 
323  $this->il_plugin_by_id = $il_plugin_by_id;
324  }
325 
326 
330  public function getIlPluginByName() {
332  }
333 
334 
339  $this->il_plugin_by_name = $il_plugin_by_name;
340  }
341 
342 
346  public function getIlPluginActive() {
348  }
349 
350 
355  $this->il_plugin_active = $il_plugin_active;
356  }
357 
358 
362  public function getIlObjectGroup() {
363  return $this->il_object_group;
364  }
365 
366 
371  $this->il_object_group = $il_object_group;
372  }
373 
374 
378  public function getIlObjectSubType() {
380  }
381 
382 
387  $this->il_object_sub_type = $il_object_sub_type;
388  }
389 
390 
394  public static function getInstance() {
395  if (!isset(self::$instance)) {
397  $cached_obj = $global_cache->get('ilCachedComponentData');
398  if ($cached_obj instanceof ilCachedComponentData) {
399  self::$instance = $cached_obj;
400  } else {
401  self::$instance = new self();
402  $global_cache->set('ilCachedComponentData', self::$instance);
403  }
404  }
405 
406  return self::$instance;
407  }
408 
409 
410  public static function flush() {
412  self::$instance = null;
413  }
414 
415 
421  public function lookupPluginByName($name) {
422  return $this->il_plugin_by_name[$name];
423  }
424 
425 
431  public function lookupActivePluginsBySlotId($slot_id) {
432  if (is_array($this->il_plugin_active[$slot_id])) {
433  return $this->il_plugin_active[$slot_id];
434  } else {
435  return array();
436  }
437  }
438 
439 
445  public function lookupSubObjForParent($parent) {
446  if (is_array($parent)) {
447  $index = md5(serialize($parent));
448  if (isset($this->cached_results['subop_par'][$index])) {
449  return $this->cached_results['subop_par'][$index];
450  }
451 
452  $return = array();
453  foreach ($parent as $p) {
454  if (is_array($this->subobj_for_parent[$p])) {
455  foreach ($this->subobj_for_parent[$p] as $rec) {
456  $return[] = $rec;
457  }
458  }
459  }
460 
461  $this->cached_results['subop_par'][$index] = $return;
462  $this->changed = true;
463 
464  return $return;
465  }
466 
467  return $this->subobj_for_parent[$parent];
468  }
469 
470 
477  public function lookCompId($type, $name) {
478  return $this->obj_def_name_and_type_raw[$type][$name]['id'];
479  }
480 
481 
488  public function lookupCompInfo($type, $name) {
489  if (!$type) {
490  if (isset($this->obj_def_name_and_type_raw['Modules'][$name])) {
491  $type = 'Modules';
492  } else {
493  $type = 'Services';
494  }
495  }
496 
497  return $this->obj_def_name_and_type_raw[$type][$name];
498  }
499 
500 
501  public function __destruct() {
503  if ($this->changed && $ilGlobalCache->isActive()) {
504  $this->changed = false;
505  $ilGlobalCache->set('ilCachedComponentData', $this);
506  }
507  }
508 
509 
515  public function lookupGroupedRepObj($parent) {
516  if (is_array($parent)) {
517  $index = md5(serialize($parent));
518  if (isset($this->cached_results['grpd_repo'][$index])) {
519  return $this->cached_results['grpd_repo'][$index];
520  }
521 
522  $return = array();
523  $sids = array();
524  foreach ($parent as $p) {
525  $s = $this->grouped_rep_obj_types[$p];
526  foreach ($s as $child) {
527  if (!in_array($child['sid'], $sids)) {
528  $sids[] = $child['sid'];
529  $return[] = $child;
530  }
531  }
532  }
533  $this->changed = true;
534  $this->cached_results['grpd_repo'][$index] = $return;
535 
536  return $return;
537  } else {
538  return $this->grouped_rep_obj_types[$parent];
539  }
540  }
541 
542 
548  public function lookupPluginSlotByComponent($component) {
549  if (is_array($this->il_pluginslot_by_comp[$component])) {
550  return $this->il_pluginslot_by_comp[$component];
551  }
552 
553  return array();
554  }
555 
556 
562  public function lookupPluginSlotById($id) {
563  return $this->il_pluginslot_by_id[$id];
564  }
565 
566 
572  public function lookupPluginSlotByName($name) {
573  return $this->il_pluginslot_by_name[$name];
574  }
575 
576 
580  public function getSubobjForParent() {
582  }
583 
584 
589  $this->subobj_for_parent = $subobj_for_parent;
590  }
591 }
592 
593 ?>
setIlPluginslotByName($il_pluginslot_by_name)
setIlPluginslotByComp($il_pluginslot_by_service)
setIlObjectSubType($il_object_sub_type)
static getInstance($component)
Class ilCachedComponentData.
setGroupedRepObjTypes($grouped_rep_obj_types)
setIlPluginslotById($il_pluginslot_by_id)
setObjDefNameToId($obj_def_name_to_id)
setSubobjForParent($subobj_for_parent)
Create styles array
The data for the language used.
global $ilDB
setObjDefNameAndTypeRaw($obj_def_name_and_type_raw)