ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCachedComponentData.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
15  protected $cached_results = array();
19  protected static $instance;
23  protected $changed = false;
27  protected $loaded = false;
31  protected $obj_def_name_to_id = array();
39  protected $il_component = array();
43  protected $il_object_def = array();
47  protected $il_object_subobj = array();
51  protected $subobj_for_parent = array();
63  protected $il_pluginslot_by_id = array();
71  protected $il_plugin_by_id = array();
75  protected $il_object_group = array();
79  protected $il_object_sub_type = array();
83  protected $il_plugin_active = array();
87  protected $il_plugin_by_name = array();
88 
89 
90  protected function __construct()
91  {
93  $this->readFromDB();
94  }
95 
96 
100  public function getLoaded()
101  {
102  return $this->loaded;
103  }
104 
105 
109  public function setLoaded($loaded)
110  {
111  $this->loaded = $loaded;
112  }
113 
114 
115  protected function readFromDB()
116  {
117  global $ilDB;
122  $set = $ilDB->query('SELECT * FROM il_component');
123  while ($rec = $ilDB->fetchAssoc($set)) {
124  $this->il_component[$rec['id']] = $rec;
125  $this->obj_def_name_to_id[$rec['id']] = $rec['name'];
126  $this->obj_def_name_and_type_raw[$rec['type']][$rec['name']] = $rec;
127  }
128 
129  $set = $ilDB->query('SELECT * FROM il_object_def');
130  while ($rec = $ilDB->fetchAssoc($set)) {
131  $this->il_object_def[$rec['id']] = $rec;
132  }
133 
134  $set = $ilDB->query('SELECT * FROM il_object_subobj');
135  while ($rec = $ilDB->fetchAssoc($set)) {
136  $this->il_object_subobj[] = $rec;
137  $parent = $rec['parent'];
138  $this->subobj_for_parent[$parent][] = $rec;
139  }
140  $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');
141  while ($rec = $ilDB->fetchAssoc($set)) {
142  $this->grouped_rep_obj_types[$rec['parent']][] = $rec;
143  }
144 
145  $set = $ilDB->query('SELECT * FROM il_pluginslot');
146  while ($rec = $ilDB->fetchAssoc($set)) {
147  $this->il_pluginslot_by_comp[$rec['component']][] = $rec;
148  $this->il_pluginslot_by_id[$rec['id']] = $rec;
149  $this->il_pluginslot_by_name[$rec['name']] = $rec;
150  }
151 
152  $set = $ilDB->query('SELECT * FROM il_plugin');
153  $this->il_plugin_active = array();
154  while ($rec = $ilDB->fetchAssoc($set)) {
155  $this->il_plugin_by_id[$rec['plugin_id']] = $rec;
156  $this->il_plugin_by_name[$rec['name']] = $rec;
157  if ($rec['active'] == 1) {
158  $this->il_plugin_active[$rec['slot_id']][] = $rec;
159  }
160  }
161  $set = $ilDB->query('SELECT * FROM il_object_group');
162  while ($rec = $ilDB->fetchAssoc($set)) {
163  $this->il_object_group[$rec['id']] = $rec;
164  }
165  $set = $ilDB->query('SELECT * FROM il_object_sub_type');
166  while ($rec = $ilDB->fetchAssoc($set)) {
167  $this->il_object_sub_type[$rec['obj_type']][] = $rec;
168  }
169  }
170 
171 
175  public function getIlComponent()
176  {
177  return $this->il_component;
178  }
179 
180 
184  public function setIlComponent($il_component)
185  {
186  $this->il_component = $il_component;
187  }
188 
189 
193  public function getObjDefNameAndTypeRaw()
194  {
196  }
197 
198 
203  {
204  $this->obj_def_name_and_type_raw = $obj_def_name_and_type_raw;
205  }
206 
207 
211  public function getObjDefNameToId()
212  {
214  }
215 
216 
221  {
222  $this->obj_def_name_to_id = $obj_def_name_to_id;
223  }
224 
225 
229  public function getIlObjectDef()
230  {
231  return $this->il_object_def;
232  }
233 
234 
239  {
240  $this->il_object_def = $il_object_def;
241  }
242 
243 
247  public function getIlObjectSubobj()
248  {
250  }
251 
252 
257  {
258  $this->il_object_subobj = $il_object_subobj;
259  }
260 
261 
265  public function getGroupedRepObjTypes()
266  {
268  }
269 
270 
275  {
276  $this->grouped_rep_obj_types = $grouped_rep_obj_types;
277  }
278 
279 
283  public function getIlPluginslotByComp()
284  {
286  }
287 
288 
292  public function setIlPluginslotByComp($il_pluginslot_by_service)
293  {
294  $this->il_pluginslot_by_comp = $il_pluginslot_by_service;
295  }
296 
297 
301  public function getIlPluginslotById()
302  {
304  }
305 
306 
311  {
312  $this->il_pluginslot_by_id = $il_pluginslot_by_id;
313  }
314 
315 
319  public function getIlPluginslotByName()
320  {
322  }
323 
324 
329  {
330  $this->il_pluginslot_by_name = $il_pluginslot_by_name;
331  }
332 
333 
337  public function getIlPluginById()
338  {
339  return $this->il_plugin_by_id;
340  }
341 
342 
347  {
348  $this->il_plugin_by_id = $il_plugin_by_id;
349  }
350 
351 
355  public function getIlPluginByName()
356  {
358  }
359 
360 
365  {
366  $this->il_plugin_by_name = $il_plugin_by_name;
367  }
368 
369 
373  public function getIlPluginActive()
374  {
376  }
377 
378 
383  {
384  $this->il_plugin_active = $il_plugin_active;
385  }
386 
387 
391  public function getIlObjectGroup()
392  {
393  return $this->il_object_group;
394  }
395 
396 
401  {
402  $this->il_object_group = $il_object_group;
403  }
404 
405 
409  public function getIlObjectSubType()
410  {
412  }
413 
414 
419  {
420  $this->il_object_sub_type = $il_object_sub_type;
421  }
422 
423 
427  public static function getInstance()
428  {
429  if (!isset(self::$instance)) {
431  $cached_obj = $global_cache->get('ilCachedComponentData');
432  if ($cached_obj instanceof ilCachedComponentData) {
433  self::$instance = $cached_obj;
434  } else {
435  self::$instance = new self();
436  $global_cache->set('ilCachedComponentData', self::$instance);
437  }
438  }
439 
440  return self::$instance;
441  }
442 
443 
444  public static function flush()
445  {
447  self::$instance = null;
448  }
449 
450 
456  public function lookupPluginByName($name)
457  {
458  return $this->il_plugin_by_name[$name];
459  }
460 
461 
467  public function lookupActivePluginsBySlotId($slot_id)
468  {
469  if (is_array($this->il_plugin_active[$slot_id])) {
470  return $this->il_plugin_active[$slot_id];
471  } else {
472  return array();
473  }
474  }
475 
476 
482  public function lookupSubObjForParent($parent)
483  {
484  if (is_array($parent)) {
485  $index = md5(serialize($parent));
486  if (isset($this->cached_results['subop_par'][$index])) {
487  return $this->cached_results['subop_par'][$index];
488  }
489 
490  $return = array();
491  foreach ($parent as $p) {
492  if (is_array($this->subobj_for_parent[$p])) {
493  foreach ($this->subobj_for_parent[$p] as $rec) {
494  $return[] = $rec;
495  }
496  }
497  }
498 
499  $this->cached_results['subop_par'][$index] = $return;
500  $this->changed = true;
501 
502  return $return;
503  }
504 
505  return $this->subobj_for_parent[$parent];
506  }
507 
508 
515  public function lookCompId($type, $name)
516  {
517  return $this->obj_def_name_and_type_raw[$type][$name]['id'];
518  }
519 
520 
527  public function lookupCompInfo($type, $name)
528  {
529  if (!$type) {
530  if (isset($this->obj_def_name_and_type_raw['Modules'][$name])) {
531  $type = 'Modules';
532  } else {
533  $type = 'Services';
534  }
535  }
536 
537  return $this->obj_def_name_and_type_raw[$type][$name];
538  }
539 
540 
541  public function __destruct()
542  {
544  if ($this->changed && $ilGlobalCache->isActive()) {
545  $this->changed = false;
546  $ilGlobalCache->set('ilCachedComponentData', $this);
547  }
548  }
549 
550 
556  public function lookupGroupedRepObj($parent)
557  {
558  if (is_array($parent)) {
559  $index = md5(serialize($parent));
560  if (isset($this->cached_results['grpd_repo'][$index])) {
561  return $this->cached_results['grpd_repo'][$index];
562  }
563 
564  $return = array();
565  $sids = array();
566  foreach ($parent as $p) {
567  $s = $this->grouped_rep_obj_types[$p];
568  foreach ($s as $child) {
569  if (!in_array($child['sid'], $sids)) {
570  $sids[] = $child['sid'];
571  $return[] = $child;
572  }
573  }
574  }
575  $this->changed = true;
576  $this->cached_results['grpd_repo'][$index] = $return;
577 
578  return $return;
579  } else {
580  return $this->grouped_rep_obj_types[$parent];
581  }
582  }
583 
584 
590  public function lookupPluginSlotByComponent($component)
591  {
592  if (is_array($this->il_pluginslot_by_comp[$component])) {
593  return $this->il_pluginslot_by_comp[$component];
594  }
595 
596  return array();
597  }
598 
599 
605  public function lookupPluginSlotById($id)
606  {
607  return $this->il_pluginslot_by_id[$id];
608  }
609 
610 
616  public function lookupPluginSlotByName($name)
617  {
618  return $this->il_pluginslot_by_name[$name];
619  }
620 
621 
625  public function getSubobjForParent()
626  {
628  }
629 
630 
635  {
636  $this->subobj_for_parent = $subobj_for_parent;
637  }
638 }
setIlPluginslotByName($il_pluginslot_by_name)
setIlPluginslotByComp($il_pluginslot_by_service)
setIlObjectSubType($il_object_sub_type)
$type
static getInstance($component)
if(!array_key_exists('StateId', $_REQUEST)) $id
Class ilCachedComponentData.
$s
Definition: pwgen.php:45
$index
Definition: metadata.php:60
setGroupedRepObjTypes($grouped_rep_obj_types)
setIlPluginslotById($il_pluginslot_by_id)
if($format !==null) $name
Definition: metadata.php:146
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)