ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilObjectDataCache Class Reference

class ilObjectDataCache More...

+ Collaboration diagram for ilObjectDataCache:

Public Member Functions

 __construct ()
 
 deleteCachedEntry ($a_obj_id)
 
 lookupObjId ($a_ref_id)
 
 lookupTitle ($a_obj_id)
 
 lookupType ($a_obj_id)
 
 lookupOwner ($a_obj_id)
 
 lookupDescription ($a_obj_id)
 
 lookupLastUpdate ($a_obj_id)
 
 lookupOfflineStatus ($a_obj_id)
 Check if supports centralized offline handling and is offline. More...
 
 __isReferenceCached ($a_ref_id)
 checks whether an reference id is already in cache or not More...
 
 __isObjectCached ($a_obj_id)
 checks whether an object is aleady in cache or not More...
 
 __storeReference ($a_ref_id)
 Stores Reference in cache. More...
 
 __storeObjectData ($a_obj_id, $a_lang="")
 Stores object data in cache. More...
 
 isTranslatedDescription ($a_obj_id)
 
 preloadObjectCache ($a_obj_ids, $a_lang="")
 Stores object data in cache. More...
 
 preloadTranslations ($a_obj_ids, $a_lang)
 Preload translation informations. More...
 
 preloadReferenceCache ($a_ref_ids, $a_incl_obj=true)
 

Data Fields

 $db = null
 
 $reference_cache = array()
 
 $object_data_cache = array()
 
 $description_trans = array()
 

Detailed Description

class ilObjectDataCache

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

This class caches some properties of the object_data table. Like title description owner obj_id

Definition at line 13 of file class.ilObjectDataCache.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectDataCache::__construct ( )

Definition at line 20 of file class.ilObjectDataCache.php.

References $DIC, and $ilDB.

21  {
22  global $DIC;
23 
24  $ilDB = $DIC->database();
25 
26  $this->db = $ilDB;
27  }
global $DIC
Definition: saml.php:7
global $ilDB

Member Function Documentation

◆ __isObjectCached()

ilObjectDataCache::__isObjectCached (   $a_obj_id)

checks whether an object is aleady in cache or not

private

Parameters
int$a_obj_idobject id
Returns
boolean

Definition at line 128 of file class.ilObjectDataCache.php.

Referenced by lookupDescription(), lookupLastUpdate(), lookupOfflineStatus(), lookupOwner(), lookupTitle(), and lookupType().

129  {
130  static $cached = 0;
131  static $not_cached = 0;
132 
133 
134  if (@$this->object_data_cache[$a_obj_id]) {
135  #echo "Object ". ++$cached ."cached<br>";
136  return true;
137  }
138  #echo "Object ". ++$not_cached ." not cached<br>";
139  return false;
140  }
+ Here is the caller graph for this function:

◆ __isReferenceCached()

ilObjectDataCache::__isReferenceCached (   $a_ref_id)

checks whether an reference id is already in cache or not

private

Parameters
int$a_ref_idreference id
Returns
boolean

Definition at line 107 of file class.ilObjectDataCache.php.

Referenced by lookupObjId().

108  {
109  #return false;
110  #static $cached = 0;
111  #static $not_cached = 0;
112 
113  if (@$this->reference_cache[$a_ref_id]) {
114  #echo "Reference ". ++$cached ."cached<br>";
115  return true;
116  }
117  #echo "Reference ". ++$not_cached ." not cached<br>";
118  return false;
119  }
+ Here is the caller graph for this function:

◆ __storeObjectData()

ilObjectDataCache::__storeObjectData (   $a_obj_id,
  $a_lang = "" 
)

Stores object data in cache.

private

Parameters
int$a_obj_idobject id
Returns
bool

Definition at line 171 of file class.ilObjectDataCache.php.

References $db, $DIC, $ilDB, $ilUser, $query, $r, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by lookupDescription(), lookupLastUpdate(), lookupObjId(), lookupOfflineStatus(), lookupOwner(), lookupTitle(), and lookupType().

172  {
173  global $DIC;
174 
175  $ilDB = $this->db;
176  $objDefinition = $DIC["objDefinition"];
177  $ilUser = $DIC["ilUser"];
178 
179  if (is_object($ilUser) && $a_lang == "") {
180  $a_lang = $ilUser->getLanguage();
181  }
182 
183  $query = "SELECT * FROM object_data WHERE obj_id = " .
184  $ilDB->quote($a_obj_id, 'integer');
185  $res = $this->db->query($query);
186  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
187  $this->object_data_cache[$a_obj_id]['title'] = $row->title;
188  $this->object_data_cache[$a_obj_id]['description'] = $row->description;
189  $this->object_data_cache[$a_obj_id]['type'] = $row->type;
190  $this->object_data_cache[$a_obj_id]['owner'] = $row->owner;
191  $this->object_data_cache[$a_obj_id]['last_update'] = $row->last_update;
192  $this->object_data_cache[$a_obj_id]['offline'] = $row->offline;
193 
194  if (is_object($objDefinition)) {
195  $translation_type = $objDefinition->getTranslationType($row->type);
196  }
197 
198  if ($translation_type == "db") {
199  if (!$this->trans_loaded[$a_obj_id]) {
200  $q = "SELECT title,description FROM object_translation " .
201  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
202  "AND lang_code = " . $ilDB->quote($a_lang, 'text') . " " .
203  "AND NOT lang_default = 1";
204  $r = $ilDB->query($q);
205 
207  if ($row) {
208  $this->object_data_cache[$a_obj_id]['title'] = $row->title;
209  $this->object_data_cache[$a_obj_id]['description'] = $row->description;
210  $this->description_trans[] = $a_obj_id;
211  }
212  $this->trans_loaded[$a_obj_id] = true;
213  }
214  }
215  }
216 
217  return true;
218  }
global $DIC
Definition: saml.php:7
$r
Definition: example_031.php:79
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ __storeReference()

ilObjectDataCache::__storeReference (   $a_ref_id)

Stores Reference in cache.

Maybe it could be useful to find all references of that object andd store them also in the cache. But this would be an extra query.

private

Parameters
int$a_ref_idreference id
Returns
int $obj_id

Definition at line 152 of file class.ilObjectDataCache.php.

References $db, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by lookupObjId().

153  {
154  $ilDB = $this->db;
155 
156  $query = "SELECT obj_id FROM object_reference WHERE ref_id = " . $ilDB->quote($a_ref_id, 'integer');
157  $res = $this->db->query($query);
158  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
159  $this->reference_cache[$a_ref_id] = $row['obj_id'];
160  }
161  return (int) @$this->reference_cache[$a_ref_id];
162  }
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ deleteCachedEntry()

ilObjectDataCache::deleteCachedEntry (   $a_obj_id)

Definition at line 29 of file class.ilObjectDataCache.php.

30  {
31  unset($this->object_data_cache[$a_obj_id]);
32  }

◆ isTranslatedDescription()

ilObjectDataCache::isTranslatedDescription (   $a_obj_id)

Definition at line 220 of file class.ilObjectDataCache.php.

221  {
222  return (is_array($this->description_trans) &&
223  in_array($a_obj_id, $this->description_trans));
224  }

◆ lookupDescription()

ilObjectDataCache::lookupDescription (   $a_obj_id)

Definition at line 69 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

70  {
71  if (!$this->__isObjectCached($a_obj_id)) {
72  $this->__storeObjectData($a_obj_id);
73  }
74  return @$this->object_data_cache[$a_obj_id]['description'];
75  }
__isObjectCached($a_obj_id)
checks whether an object is aleady in cache or not
__storeObjectData($a_obj_id, $a_lang="")
Stores object data in cache.
+ Here is the call graph for this function:

◆ lookupLastUpdate()

ilObjectDataCache::lookupLastUpdate (   $a_obj_id)

Definition at line 77 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

78  {
79  if (!$this->__isObjectCached($a_obj_id)) {
80  $this->__storeObjectData($a_obj_id);
81  }
82  return @$this->object_data_cache[$a_obj_id]['last_update'];
83  }
__isObjectCached($a_obj_id)
checks whether an object is aleady in cache or not
__storeObjectData($a_obj_id, $a_lang="")
Stores object data in cache.
+ Here is the call graph for this function:

◆ lookupObjId()

ilObjectDataCache::lookupObjId (   $a_ref_id)

Definition at line 34 of file class.ilObjectDataCache.php.

References __isReferenceCached(), __storeObjectData(), and __storeReference().

35  {
36  if (!$this->__isReferenceCached($a_ref_id)) {
37  //echo"-objidmissed-$a_ref_id-";
38  $obj_id = $this->__storeReference($a_ref_id);
39  $this->__storeObjectData($obj_id);
40  }
41  return (int) @$this->reference_cache[$a_ref_id];
42  }
__isReferenceCached($a_ref_id)
checks whether an reference id is already in cache or not
__storeObjectData($a_obj_id, $a_lang="")
Stores object data in cache.
__storeReference($a_ref_id)
Stores Reference in cache.
+ Here is the call graph for this function:

◆ lookupOfflineStatus()

ilObjectDataCache::lookupOfflineStatus (   $a_obj_id)

Check if supports centralized offline handling and is offline.

Parameters
$a_obj_id
Returns
bool

Definition at line 90 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

91  {
92  if (!$this->__isObjectCached($a_obj_id)) {
93  $this->__storeObjectData($a_obj_id);
94  }
95  return (bool) $this->object_data_cache[$a_obj_id]['offline'];
96  }
__isObjectCached($a_obj_id)
checks whether an object is aleady in cache or not
__storeObjectData($a_obj_id, $a_lang="")
Stores object data in cache.
+ Here is the call graph for this function:

◆ lookupOwner()

ilObjectDataCache::lookupOwner (   $a_obj_id)

Definition at line 61 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

62  {
63  if (!$this->__isObjectCached($a_obj_id)) {
64  $this->__storeObjectData($a_obj_id);
65  }
66  return @$this->object_data_cache[$a_obj_id]['owner'];
67  }
__isObjectCached($a_obj_id)
checks whether an object is aleady in cache or not
__storeObjectData($a_obj_id, $a_lang="")
Stores object data in cache.
+ Here is the call graph for this function:

◆ lookupTitle()

ilObjectDataCache::lookupTitle (   $a_obj_id)

Definition at line 44 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

45  {
46  if (!$this->__isObjectCached($a_obj_id)) {
47  $this->__storeObjectData($a_obj_id);
48  }
49  return @$this->object_data_cache[$a_obj_id]['title'];
50  }
__isObjectCached($a_obj_id)
checks whether an object is aleady in cache or not
__storeObjectData($a_obj_id, $a_lang="")
Stores object data in cache.
+ Here is the call graph for this function:

◆ lookupType()

ilObjectDataCache::lookupType (   $a_obj_id)

Definition at line 52 of file class.ilObjectDataCache.php.

References __isObjectCached(), and __storeObjectData().

53  {
54  if (!$this->__isObjectCached($a_obj_id)) {
55  //echo"-typemissed-$a_obj_id-";
56  $this->__storeObjectData($a_obj_id);
57  }
58  return @$this->object_data_cache[$a_obj_id]['type'];
59  }
__isObjectCached($a_obj_id)
checks whether an object is aleady in cache or not
__storeObjectData($a_obj_id, $a_lang="")
Stores object data in cache.
+ Here is the call graph for this function:

◆ preloadObjectCache()

ilObjectDataCache::preloadObjectCache (   $a_obj_ids,
  $a_lang = "" 
)

Stores object data in cache.

private

Parameters
int$a_obj_idobject id
Returns
bool

Definition at line 233 of file class.ilObjectDataCache.php.

References $db, $DIC, $ilDB, $ilUser, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and preloadTranslations().

Referenced by preloadReferenceCache().

234  {
235  global $DIC;
236 
237  $ilDB = $this->db;
238  $objDefinition = $DIC["objDefinition"];
239  $ilUser = $DIC["ilUser"];
240 
241  if (is_object($ilUser) && $a_lang == "") {
242  $a_lang = $ilUser->getLanguage();
243  }
244  if (!is_array($a_obj_ids)) {
245  return;
246  }
247  if (count($a_obj_ids) == 0) {
248  return;
249  }
250 
251 
252  $query = "SELECT * FROM object_data " .
253  "WHERE " . $ilDB->in('obj_id', $a_obj_ids, false, 'integer');
254  $res = $ilDB->query($query);
255  $db_trans = array();
256  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
257 
258  // this if fixes #9960
259  if (!$this->trans_loaded[$row->obj_id]) {
260  $this->object_data_cache[$row->obj_id]['title'] = $row->title;
261  $this->object_data_cache[$row->obj_id]['description'] = $row->description;
262  }
263  $this->object_data_cache[$row->obj_id]['type'] = $row->type;
264  $this->object_data_cache[$row->obj_id]['owner'] = $row->owner;
265  $this->object_data_cache[$row->obj_id]['last_update'] = $row->last_update;
266  $this->object_data_cache[$row->obj_id]['offline'] = $row->offline;
267 
268  if (is_object($objDefinition)) {
269  $translation_type = $objDefinition->getTranslationType($row->type);
270  }
271 
272  if ($translation_type == "db") {
273  $db_trans[$row->obj_id] = $row->obj_id;
274  }
275  }
276  if (count($db_trans) > 0) {
277  $this->preloadTranslations($db_trans, $a_lang);
278  }
279  }
global $DIC
Definition: saml.php:7
preloadTranslations($a_obj_ids, $a_lang)
Preload translation informations.
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18
$query
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preloadReferenceCache()

ilObjectDataCache::preloadReferenceCache (   $a_ref_ids,
  $a_incl_obj = true 
)

Definition at line 312 of file class.ilObjectDataCache.php.

References $db, $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_ASSOC, and preloadObjectCache().

313  {
314  $ilDB = $this->db;
315 
316  if (!is_array($a_ref_ids)) {
317  return;
318  }
319  if (count($a_ref_ids) == 0) {
320  return;
321  }
322 
323  $query = "SELECT ref_id, obj_id FROM object_reference " .
324  "WHERE " . $ilDB->in('ref_id', $a_ref_ids, false, 'integer');
325  $res = $ilDB->query($query);
326 
327  $obj_ids = array();
328  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
329  $this->reference_cache[$row['ref_id']] = $row['obj_id'];
330  //echo "<br>store_ref-".$row['ref_id']."-".$row['obj_id']."-";
331  $obj_ids[] = $row['obj_id'];
332  }
333  if ($a_incl_obj) {
334  $this->preloadObjectCache($obj_ids);
335  }
336  }
preloadObjectCache($a_obj_ids, $a_lang="")
Stores object data in cache.
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the call graph for this function:

◆ preloadTranslations()

ilObjectDataCache::preloadTranslations (   $a_obj_ids,
  $a_lang 
)

Preload translation informations.

Parameters
array$a_obj_idsarray of object ids

Definition at line 286 of file class.ilObjectDataCache.php.

References $db, $id, $ilDB, $r, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by preloadObjectCache().

287  {
288  $ilDB = $this->db;
289 
290  $obj_ids = array();
291  foreach ($a_obj_ids as $id) {
292  // do not load an id more than one time
293  if (!$this->trans_loaded[$id]) {
294  $obj_ids[] = $id;
295  $this->trans_loaded[$id] = true;
296  }
297  }
298  if (count($obj_ids) > 0) {
299  $q = "SELECT obj_id, title, description FROM object_translation " .
300  "WHERE " . $ilDB->in('obj_id', $obj_ids, false, 'integer') . " " .
301  "AND lang_code = " . $ilDB->quote($a_lang, 'text') . " " .
302  "AND NOT lang_default = 1";
303  $r = $ilDB->query($q);
304  while ($row2 = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
305  $this->object_data_cache[$row2->obj_id]['title'] = $row2->title;
306  $this->object_data_cache[$row2->obj_id]['description'] = $row2->description;
307  $this->description_trans[] = $row2->obj_id;
308  }
309  }
310  }
if(!array_key_exists('StateId', $_REQUEST)) $id
$r
Definition: example_031.php:79
global $ilDB
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilObjectDataCache::$db = null

◆ $description_trans

ilObjectDataCache::$description_trans = array()

Definition at line 18 of file class.ilObjectDataCache.php.

◆ $object_data_cache

ilObjectDataCache::$object_data_cache = array()

Definition at line 17 of file class.ilObjectDataCache.php.

◆ $reference_cache

ilObjectDataCache::$reference_cache = array()

Definition at line 16 of file class.ilObjectDataCache.php.


The documentation for this class was generated from the following file: