ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjectListGUIPreloader.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
29 protected ilTree $tree;
31 protected ilObjUser $user;
34
35 protected int $context;
36
37 protected array $obj_ids = [];
38 protected array $obj_ids_by_type = [];
39 protected array $ref_ids = [];
40 protected array $ref_ids_by_type = [];
41 protected array $types = [];
42
43 public function __construct(int $context)
44 {
45 global $DIC;
46
47 $this->obj_definition = $DIC["objDefinition"];
48 $this->tree = $DIC->repositoryTree();
49 $this->obj_data_cache = $DIC["ilObjDataCache"];
50 $this->user = $DIC->user();
51 $this->rbacsystem = $DIC->rbac()->system();
52 $this->fav_manager = new ilFavouritesManager();
53 $this->context = $context;
54 }
55
56 public function addItem(int $obj_id, string $type, ?int $ref_id = null): void
57 {
58 $this->obj_ids[] = $obj_id;
59 $this->obj_ids_by_type[$type][] = $obj_id;
60 $this->types[] = $type;
61
62 if ($ref_id) {
63 $this->ref_ids[] = $ref_id;
64 $this->ref_ids_by_type[$type][] = $ref_id;
65 }
66 }
67
68 public function preload(): void
69 {
70 if (!$this->obj_ids) {
71 return;
72 }
73
74 $this->obj_ids = array_unique($this->obj_ids);
75 $this->types = array_unique($this->types);
76 if ($this->ref_ids) {
77 $this->ref_ids = array_unique($this->ref_ids);
78 }
79
80 // type specific preloads
81 foreach ($this->types as $type) {
82 $this->obj_ids_by_type[$type] = array_unique($this->obj_ids_by_type[$type]);
83
84 if (isset($this->ref_ids_by_type[$type])) {
85 $this->ref_ids_by_type[$type] = array_unique($this->ref_ids_by_type[$type]);
86 }
87
88 if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY ||
90 $this->context == ilObjectListGUI::CONTEXT_SEARCH) {
92 $type,
93 $this->obj_ids_by_type[$type]
94 );
95 }
96
97 $class = $this->obj_definition->getClassName($type);
98 $location = $this->obj_definition->getLocation($type);
99 if ($class && $location) { // #12775
100 $full_class = "ilObj" . $class . "Access";
101 if (class_exists($full_class)) {
102 call_user_func(
103 [$full_class, "_preloadData"],
104 $this->obj_ids_by_type[$type] ?? [],
105 $this->ref_ids_by_type[$type] ?? []
106 );
107 }
108 }
109 }
110
111 if ($this->ref_ids) {
112 $this->tree->preloadDeleted($this->ref_ids);
113 $this->tree->preloadDepthParent($this->ref_ids);
114 $this->obj_data_cache->preloadReferenceCache($this->ref_ids, false);
115 $this->rbacsystem->preloadRbacPaCache($this->ref_ids, $this->user->getId());
116
117 if ($this->user->getId() != ANONYMOUS_USER_ID &&
119 $this->fav_manager->loadData($this->user->getId(), $this->ref_ids);
120 }
121
122 ilObjectActivation::preloadData($this->ref_ids);
123 }
124
125 ilObjectListGUI::preloadCommonProperties($this->obj_ids, $this->context);
126
127 if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY) {
128 ilRating::preloadListGUIData($this->obj_ids);
129
131 }
132
133 if ($this->context == ilObjectListGUI::CONTEXT_REPOSITORY ||
135 $this->context == ilObjectListGUI::CONTEXT_SEARCH) {
136 ilLPStatus::preloadListGUIData($this->obj_ids);
137 }
138 }
139}
$location
Definition: buildRTE.php:22
static preloadByObjIds(array $a_obj_ids)
Preload list gui data.
static preloadPersistedConditionsForTargetRecords(string $a_type, array $a_obj_ids)
Manages favourites, currently the interface for other components, needs discussion.
static preloadListGUIData(array $a_obj_ids)
User class.
static preloadData(array $ref_ids)
Preload data to internal cache.
class ilObjectDataCache
parses the objects.xml it handles the xml-description of all ilias objects
Preloader for object list GUIs.
addItem(int $obj_id, string $type, ?int $ref_id=null)
static preloadCommonProperties(array $obj_ids, int $context)
static preloadListGUIData(array $a_obj_ids)
Preload rating data for list guis.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
const ANONYMOUS_USER_ID
Definition: constants.php:27
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26