ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Container\Content\ItemSetManager Class Reference

Manages container subitems set. More...

+ Collaboration diagram for ILIAS\Container\Content\ItemSetManager:

Public Member Functions

 __construct (InternalDomainService $domain, int $mode, int $parent_ref_id, ?\ilContainerUserFilter $user_filter=null, int $single_ref_id=0, bool $admin_mode=false, bool $force_session_order_by_date=true, protected bool $include_objective_items=false)
 
 setHiddenFilesFound (bool $a_hiddenfilesfound)
 
 getHiddenFilesFound ()
 
 hasItems ()
 
 getRefIdsOfType (string $type)
 
 getAllRefIds ()
 
 getRawDataByRefId (int $ref_id)
 
 isSideBlockItem (int $ref_id)
 
 isClassificationFilterActive ()
 

Data Fields

const FLAT = 0
 
const TREE = 1
 
const SINGLE = 2
 

Protected Member Functions

 init ()
 
 addObjectiveItems ()
 
 addToItems (array $item)
 
 applySorting ()
 
 groupItems ()
 Internally group all items. More...
 
 sortSessions ()
 
 getAdditionalSubItemInformation ()
 
 addAdditionalSubItemInformationToObject (array &$object)
 
 applyUserFilter ()
 Apply container user filter on objects. More...
 
 getCompleteDescriptions ()
 From ilContainer. More...
 
 applyClassificationFilter ()
 From ilContainer. More...
 
 preloadAdvancedMDValues ()
 

Protected Attributes

bool $force_session_order_by_date
 
bool $admin_mode
 
bool $hiddenfilesfound = false
 
string $parent_type
 
int $parent_obj_id
 
int $parent_ref_id = 0
 
int $single_ref_id = 0
 
InternalDomainService $domain
 
array $raw = []
 
array $raw_by_type = []
 
array $rendered = []
 
int $mode = self::FLAT
 
ilContainerUserFilter $user_filter = null
 
bool $initialised = false
 

Detailed Description

Manages container subitems set.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Container\Content\ItemSetManager::__construct ( InternalDomainService  $domain,
int  $mode,
int  $parent_ref_id,
?\ilContainerUserFilter  $user_filter = null,
int  $single_ref_id = 0,
bool  $admin_mode = false,
bool  $force_session_order_by_date = true,
protected bool  $include_objective_items = false 
)
Parameters
int$modeself::TREE|self::FLAT|self::SINGLE

Definition at line 54 of file class.ItemSetManager.php.

63 {
64 $this->parent_ref_id = $parent_ref_id;
65 $this->parent_obj_id = \ilObject::_lookupObjId($this->parent_ref_id);
66 $this->parent_type = \ilObject::_lookupType($this->parent_obj_id);
67 $this->user_filter = $user_filter;
68 $this->force_session_order_by_date = $force_session_order_by_date;
69
70 $this->single_ref_id = $single_ref_id;
71 $this->domain = $domain;
72 $this->mode = $mode; // might be refactored as subclasses
73 $this->admin_mode = $admin_mode;
74 $this->init();
75 }
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)

References ILIAS\Container\Content\ItemSetManager\$admin_mode, ILIAS\Container\Content\ItemSetManager\$domain, ILIAS\Container\Content\ItemSetManager\$force_session_order_by_date, ILIAS\Container\Content\ItemSetManager\$mode, ILIAS\Container\Content\ItemSetManager\$parent_ref_id, ILIAS\Container\Content\ItemSetManager\$single_ref_id, ILIAS\Container\Content\ItemSetManager\$user_filter, ilObject\_lookupObjId(), ilObject\_lookupType(), and ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAdditionalSubItemInformationToObject()

ILIAS\Container\Content\ItemSetManager::addAdditionalSubItemInformationToObject ( array &  $object)
protected

Definition at line 257 of file class.ItemSetManager.php.

257 : void
258 {
260 }
static addAdditionalSubItemInformation(array &$item)
Parse item data for list entries.

References ilObjectActivation\addAdditionalSubItemInformation().

Referenced by ILIAS\Container\Content\ItemSetManager\getAdditionalSubItemInformation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addObjectiveItems()

ILIAS\Container\Content\ItemSetManager::addObjectiveItems ( )
protected

Definition at line 117 of file class.ItemSetManager.php.

117 : void
118 {
119 if (count($objective_ids = \ilCourseObjective::_getObjectiveIds(\ilObject::_lookupObjId($this->parent_ref_id), true)) > 0) {
120 foreach ($objective_ids as $objective_id) {
121 foreach (\ilObjectActivation::getItemsByObjective($objective_id) as $item) {
122 $this->addToItems($item);
123 }
124 }
125 }
126 }
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
static getItemsByObjective(int $objective_id)
Get objective items.

References ilCourseObjective\_getObjectiveIds(), ilObject\_lookupObjId(), ILIAS\Container\Content\ItemSetManager\addToItems(), and ilObjectActivation\getItemsByObjective().

Referenced by ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addToItems()

ILIAS\Container\Content\ItemSetManager::addToItems ( array  $item)
protected

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

128 : void
129 {
130 if (($ref_id = $item["ref_id"] ?? 0) > 0) {
131 foreach ($this->raw as $raw_item) {
132 if ($raw_item["ref_id"] == $ref_id) {
133 return;
134 }
135 }
136 $this->raw[] = $item;
137 }
138 }
$ref_id
Definition: ltiauth.php:66

References $ref_id, and ILIAS\Repository\raw().

Referenced by ILIAS\Container\Content\ItemSetManager\addObjectiveItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyClassificationFilter()

ILIAS\Container\Content\ItemSetManager::applyClassificationFilter ( )
protected

From ilContainer.

Todo:
remove there

Definition at line 355 of file class.ItemSetManager.php.

355 : void
356 {
357 // apply container classification filters
358 $classification = $this->domain->classification($this->parent_ref_id);
360 $this->parent_ref_id,
361 $this->parent_obj_id,
362 $this->parent_type
363 ) as $class_provider) {
364 $id = get_class($class_provider);
365 $current = $classification->getSelectionOfProvider($id);
366 if ($current) {
367 $class_provider->setSelection($current);
368 $filtered = $class_provider->getFilteredObjects();
369 $this->raw = array_filter($this->raw, static function ($i) use ($filtered) {
370 return (is_array($filtered) && in_array($i["obj_id"], $filtered));
371 });
372 }
373 }
374 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$classification
static getValidProviders(int $a_parent_ref_id, int $a_parent_obj_id, string $a_parent_obj_type)
Get all valid providers (for parent container)

References $classification, $id, ilClassificationProvider\getValidProviders(), and ILIAS\Repository\raw().

Referenced by ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applySorting()

ILIAS\Container\Content\ItemSetManager::applySorting ( )
protected

Definition at line 180 of file class.ItemSetManager.php.

180 : void
181 {
182 $sort = \ilContainerSorting::_getInstance($this->parent_obj_id);
183 $all = $sort->sortItems(["all" => $this->raw]);
184 $this->raw = $all["all"];
185 //$this->raw_by_type = $sort->sortItems($this->raw_by_type);
186 }
static _getInstance(int $a_obj_id)

References ilContainerSorting\_getInstance(), and ILIAS\Repository\raw().

Referenced by ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyUserFilter()

ILIAS\Container\Content\ItemSetManager::applyUserFilter ( )
protected

Apply container user filter on objects.

Exceptions

ilException

Definition at line 288 of file class.ItemSetManager.php.

288 : void
289 {
290 if (is_null($this->user_filter)) {
291 return;
292 }
293 $filter = $this->domain->content()->filter(
294 $this->raw,
295 $this->user_filter,
297 $this->parent_obj_id,
298 "filter_show_empty",
299 "0"
300 )
301 );
302 $this->raw = $filter->apply();
303 }
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)

References ilContainer\_lookupContainerSetting(), and ILIAS\Repository\raw().

Referenced by ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalSubItemInformation()

ILIAS\Container\Content\ItemSetManager::getAdditionalSubItemInformation ( )
protected

Definition at line 250 of file class.ItemSetManager.php.

250 : void
251 {
252 foreach ($this->raw as $key => $object) {
253 $this->addAdditionalSubItemInformationToObject($this->raw[$key]);
254 }
255 }

References ILIAS\Container\Content\ItemSetManager\addAdditionalSubItemInformationToObject(), and ILIAS\Repository\raw().

Referenced by ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllRefIds()

ILIAS\Container\Content\ItemSetManager::getAllRefIds ( )

Definition at line 160 of file class.ItemSetManager.php.

160 : array
161 {
162 $this->init();
163 return array_keys($this->raw_by_type["_all"]);
164 }

References ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:

◆ getCompleteDescriptions()

ILIAS\Container\Content\ItemSetManager::getCompleteDescriptions ( )
protected

From ilContainer.

Todo:
remove there

Definition at line 308 of file class.ItemSetManager.php.

308 : void
309 {
310 $ilSetting = $this->domain->settings();
311 $ilObjDataCache = $this->domain->objectDataCache();
312
313 // using long descriptions?
314 $short_desc = $ilSetting->get("rep_shorten_description");
315 $short_desc_max_length = (int) $ilSetting->get("rep_shorten_description_length");
316 // using (part of) shortened description
317 if ($short_desc && $short_desc_max_length && $short_desc_max_length < \ilObject::DESC_LENGTH) {
318 foreach ($this->raw as $key => $object) {
319 $this->raw[$key]["description"] = \ilStr::shortenTextExtended(
320 $object["description"],
321 $short_desc_max_length,
322 true
323 );
324 }
325 }
326 // using (part of) long description
327 else {
328 $obj_ids = array();
329 foreach ($this->raw as $key => $object) {
330 $obj_ids[] = $object["obj_id"];
331 }
332 if (count($obj_ids) > 0) {
333 $long_desc = \ilObject::getLongDescriptions($obj_ids);
334 foreach ($this->raw as $key => $object) {
335 // #12166 - keep translation, ignore long description
336 if ($ilObjDataCache->isTranslatedDescription((int) $object["obj_id"])) {
337 $long_desc[$object["obj_id"]] = $object["description"];
338 }
339 if ($short_desc && $short_desc_max_length) {
340 $long_desc[$object["obj_id"]] = \ilStr::shortenTextExtended(
341 (string) ($long_desc[$object["obj_id"]] ?? ""),
342 $short_desc_max_length,
343 true
344 );
345 }
346 $this->raw[$key]["description"] = $long_desc[$object["obj_id"]] ?? '';
347 }
348 }
349 }
350 }
const DESC_LENGTH
static getLongDescriptions(array $obj_ids)
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
global $ilSetting
Definition: privfeed.php:31

References $ilSetting, ilObject\DESC_LENGTH, ilObject\getLongDescriptions(), ILIAS\Repository\int(), ILIAS\Repository\raw(), and ilStr\shortenTextExtended().

Referenced by ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHiddenFilesFound()

ILIAS\Container\Content\ItemSetManager::getHiddenFilesFound ( )

◆ getRawDataByRefId()

ILIAS\Container\Content\ItemSetManager::getRawDataByRefId ( int  $ref_id)

Definition at line 166 of file class.ItemSetManager.php.

166 : ?array
167 {
168 $this->init();
169 return $this->raw_by_type["_all"][$ref_id] ?? null;
170 }

References $ref_id, and ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:

◆ getRefIdsOfType()

ILIAS\Container\Content\ItemSetManager::getRefIdsOfType ( string  $type)

Definition at line 149 of file class.ItemSetManager.php.

149 : array
150 {
151 $this->init();
152 if (isset($this->raw_by_type[$type])) {
153 return array_map(static function ($item) {
154 return (int) $item["child"];
155 }, $this->raw_by_type[$type]);
156 }
157 return [];
158 }

References ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:

◆ groupItems()

ILIAS\Container\Content\ItemSetManager::groupItems ( )
protected

Internally group all items.

Definition at line 191 of file class.ItemSetManager.php.

191 : void
192 {
193 $obj_definition = $this->domain->objectDefinition();
194 $classification_filter_active = $this->isClassificationFilterActive();
195 $this->raw_by_type["_all"] = [];
196 foreach ($this->raw as $key => $object) {
197
198 // hide object types in devmode
199 if ($object["type"] === "adm" || $object["type"] === "rolf" ||
200 $obj_definition->getDevMode($object["type"])) {
201 continue;
202 }
203
204 // remove inactive plugins
205 if ($obj_definition->isInactivePlugin($object["type"])) {
206 continue;
207 }
208
209 // BEGIN WebDAV: Don't display hidden Files, Folders and Categories
210 /* this is an old webdav hack, which leads to issues in item groups
211 these objects would be "invisible" but accessible (via url) which makes the behaviour very strange.
212 They are hidden here, but shown in explorer trees and other places...
213 if (in_array($object['type'], array('file','fold','cat'))) {
214 if (\ilObjFileAccess::_isFileHidden($object['title'])) {
215 $this->setHiddenFilesFound(true);
216 if (!$this->admin_mode) {
217 continue;
218 }
219 }
220 }*/
221 // END WebDAV: Don't display hidden Files, Folders and Categories
222
223 // group object type groups together (e.g. learning resources)
224 $type = $obj_definition->getGroupOfObj($object["type"]);
225 if ($type == "") {
226 $type = $object["type"];
227 }
228
229 $new_key = (int) $object["child"];
230 $this->rendered[$new_key] = false;
231 $this->raw_by_type[$type][$new_key] = $object;
232
233 $this->raw_by_type["_all"][$new_key] = $object;
234 if ($object["type"] !== "sess") {
235 $this->raw_by_type["_non_sess"][$new_key] = $object;
236 }
237 }
238 }

References ILIAS\Repository\int(), ILIAS\Container\Content\ItemSetManager\isClassificationFilterActive(), and ILIAS\Repository\raw().

Referenced by ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasItems()

ILIAS\Container\Content\ItemSetManager::hasItems ( )
Todo:
from ilContainer, should be removed there

Definition at line 143 of file class.ItemSetManager.php.

143 : bool
144 {
145 $this->init();
146 return count($this->raw) > 0;
147 }

References ILIAS\Container\Content\ItemSetManager\init(), and ILIAS\Repository\raw().

+ Here is the call graph for this function:

◆ init()

ILIAS\Container\Content\ItemSetManager::init ( )
protected
Todo:
from ilContainer, should be removed there

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

90 : void
91 {
92 if ($this->initialised) {
93 return;
94 }
95 $tree = $this->domain->repositoryTree();
96 if ($this->mode === self::TREE) {
97 $this->raw = $tree->getSubTree($tree->getNodeData($this->parent_ref_id));
98 } elseif ($this->mode === self::FLAT) {
99 $this->raw = $tree->getChilds($this->parent_ref_id, "title");
100 } else {
101 $this->raw[] = $tree->getNodeData($this->single_ref_id);
102 }
103 if ($this->include_objective_items) {
104 $this->addObjectiveItems();
105 }
106 $this->applyUserFilter();
110 $this->applySorting();
111 $this->groupItems();
112 $this->sortSessions();
114 $this->initialised = true;
115 }
applyUserFilter()
Apply container user filter on objects.

References ILIAS\Container\Content\ItemSetManager\addObjectiveItems(), ILIAS\Container\Content\ItemSetManager\applyClassificationFilter(), ILIAS\Container\Content\ItemSetManager\applySorting(), ILIAS\Container\Content\ItemSetManager\applyUserFilter(), ILIAS\Container\Content\ItemSetManager\getAdditionalSubItemInformation(), ILIAS\Container\Content\ItemSetManager\getCompleteDescriptions(), ILIAS\Container\Content\ItemSetManager\groupItems(), ILIAS\Container\Content\ItemSetManager\preloadAdvancedMDValues(), ILIAS\Repository\raw(), and ILIAS\Container\Content\ItemSetManager\sortSessions().

Referenced by ILIAS\Container\Content\ItemSetManager\__construct(), ILIAS\Container\Content\ItemSetManager\getAllRefIds(), ILIAS\Container\Content\ItemSetManager\getRawDataByRefId(), ILIAS\Container\Content\ItemSetManager\getRefIdsOfType(), ILIAS\Container\Content\ItemSetManager\hasItems(), and ILIAS\Container\Content\ItemSetManager\isSideBlockItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isClassificationFilterActive()

ILIAS\Container\Content\ItemSetManager::isClassificationFilterActive ( )
Todo:
from ilContainer, remove there

Definition at line 265 of file class.ItemSetManager.php.

265 : bool
266 {
267 // apply container classification filters
268 $classification = $this->domain->classification($this->parent_ref_id);
270 $this->parent_ref_id,
271 $this->parent_obj_id,
272 $this->parent_type
273 ) as $class_provider) {
274 $id = get_class($class_provider);
275 $current = $classification->getSelectionOfProvider($id);
276 if ($current) {
277 return true;
278 }
279 }
280 return false;
281 }

References $classification, $id, and ilClassificationProvider\getValidProviders().

Referenced by ILIAS\Container\Content\ItemSetManager\groupItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSideBlockItem()

ILIAS\Container\Content\ItemSetManager::isSideBlockItem ( int  $ref_id)

Definition at line 172 of file class.ItemSetManager.php.

172 : bool
173 {
174 $this->init();
175 $type = $this->raw_by_type["_all"][$ref_id]["type"] ?? "";
176 $obj_definition = $this->domain->objectDefinition();
177 return $obj_definition->isSideBlock($type);
178 }

References $ref_id, and ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:

◆ preloadAdvancedMDValues()

ILIAS\Container\Content\ItemSetManager::preloadAdvancedMDValues ( )
protected

Definition at line 376 of file class.ItemSetManager.php.

376 : void
377 {
378 $obj_ids = [];
379 foreach ($this->raw_by_type["_all"] as $object) {
380 $obj_ids[] = $object["obj_id"];
381 }
383 }
static preloadByObjIds(array $a_obj_ids)
Preload list gui data.

References ilAdvancedMDValues\preloadByObjIds().

Referenced by ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHiddenFilesFound()

ILIAS\Container\Content\ItemSetManager::setHiddenFilesFound ( bool  $a_hiddenfilesfound)

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

77 : void
78 {
79 $this->hiddenfilesfound = $a_hiddenfilesfound;
80 }

◆ sortSessions()

ILIAS\Container\Content\ItemSetManager::sortSessions ( )
protected

Definition at line 240 of file class.ItemSetManager.php.

240 : void
241 {
242 if (!$this->force_session_order_by_date) {
243 return;
244 }
245 if (isset($this->raw_by_type["sess"]) && count($this->raw_by_type["sess"]) > 0) {
246 $this->raw_by_type["sess"] = \ilArrayUtil::sortArray($this->raw_by_type["sess"], 'start', 'ASC', true, true);
247 }
248 }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)

References ilArrayUtil\sortArray().

Referenced by ILIAS\Container\Content\ItemSetManager\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $admin_mode

bool ILIAS\Container\Content\ItemSetManager::$admin_mode
protected

◆ $domain

InternalDomainService ILIAS\Container\Content\ItemSetManager::$domain
protected

◆ $force_session_order_by_date

bool ILIAS\Container\Content\ItemSetManager::$force_session_order_by_date
protected

◆ $hiddenfilesfound

bool ILIAS\Container\Content\ItemSetManager::$hiddenfilesfound = false
protected

◆ $initialised

bool ILIAS\Container\Content\ItemSetManager::$initialised = false
protected

Definition at line 49 of file class.ItemSetManager.php.

◆ $mode

int ILIAS\Container\Content\ItemSetManager::$mode = self::FLAT
protected

◆ $parent_obj_id

int ILIAS\Container\Content\ItemSetManager::$parent_obj_id
protected

Definition at line 38 of file class.ItemSetManager.php.

◆ $parent_ref_id

int ILIAS\Container\Content\ItemSetManager::$parent_ref_id = 0
protected

◆ $parent_type

string ILIAS\Container\Content\ItemSetManager::$parent_type
protected

Definition at line 37 of file class.ItemSetManager.php.

◆ $raw

array ILIAS\Container\Content\ItemSetManager::$raw = []
protected

Definition at line 43 of file class.ItemSetManager.php.

◆ $raw_by_type

array ILIAS\Container\Content\ItemSetManager::$raw_by_type = []
protected

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

◆ $rendered

array ILIAS\Container\Content\ItemSetManager::$rendered = []
protected

Definition at line 46 of file class.ItemSetManager.php.

◆ $single_ref_id

int ILIAS\Container\Content\ItemSetManager::$single_ref_id = 0
protected

◆ $user_filter

ilContainerUserFilter ILIAS\Container\Content\ItemSetManager::$user_filter = null
protected

◆ FLAT

const ILIAS\Container\Content\ItemSetManager::FLAT = 0

◆ SINGLE

const ILIAS\Container\Content\ItemSetManager::SINGLE = 2

Definition at line 33 of file class.ItemSetManager.php.

◆ TREE

const ILIAS\Container\Content\ItemSetManager::TREE = 1

Definition at line 32 of file class.ItemSetManager.php.


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