ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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)
 
 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 ()
 
 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 26 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 
)
Parameters
int$modeself::TREE|self::FLAT|self::SINGLE

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

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().

59  {
60  $this->parent_ref_id = $parent_ref_id;
61  $this->parent_obj_id = \ilObject::_lookupObjId($this->parent_ref_id);
62  $this->parent_type = \ilObject::_lookupType($this->parent_obj_id);
63  $this->user_filter = $user_filter;
64  $this->force_session_order_by_date = $force_session_order_by_date;
65 
66  $this->single_ref_id = $single_ref_id;
67  $this->domain = $domain;
68  $this->mode = $mode; // might be refactored as subclasses
69  $this->admin_mode = $admin_mode;
70  $this->init();
71  }
static _lookupObjId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Member Function Documentation

◆ addAdditionalSubItemInformationToObject()

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

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

References ilObjectActivation\addAdditionalSubItemInformation().

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

224  : void
225  {
227  }
static addAdditionalSubItemInformation(array &$item)
Parse item data for list entries.
+ 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 324 of file class.ItemSetManager.php.

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

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

324  : void
325  {
326  // apply container classification filters
327  $classification = $this->domain->classification($this->parent_ref_id);
329  $this->parent_ref_id,
330  $this->parent_obj_id,
331  $this->parent_type
332  ) as $class_provider) {
333  $id = get_class($class_provider);
334  $current = $classification->getSelectionOfProvider($id);
335  if ($current) {
336  $class_provider->setSelection($current);
337  $filtered = $class_provider->getFilteredObjects();
338  $this->raw = array_filter($this->raw, static function ($i) use ($filtered) {
339  return (is_array($filtered) && in_array($i["obj_id"], $filtered));
340  });
341  }
342  }
343  }
$classification
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getValidProviders(int $a_parent_ref_id, int $a_parent_obj_id, string $a_parent_obj_type)
Get all valid providers (for parent container)
+ 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 150 of file class.ItemSetManager.php.

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

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

150  : void
151  {
152  $sort = \ilContainerSorting::_getInstance($this->parent_obj_id);
153  $all = $sort->sortItems(["all" => $this->raw]);
154  $this->raw = $all["all"];
155  //$this->raw_by_type = $sort->sortItems($this->raw_by_type);
156  }
static _getInstance(int $a_obj_id)
+ 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

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

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

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

255  : void
256  {
257  if (is_null($this->user_filter)) {
258  return;
259  }
260  $filter = $this->domain->content()->filter(
261  $this->raw,
262  $this->user_filter,
264  $this->parent_obj_id,
265  "filter_show_empty",
266  "0"
267  )
268  );
269  $this->raw = $filter->apply();
270  }
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
+ 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 217 of file class.ItemSetManager.php.

References ILIAS\LTI\ToolProvider\$key, ILIAS\Container\Content\ItemSetManager\addAdditionalSubItemInformationToObject(), and ILIAS\Repository\raw().

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

217  : void
218  {
219  foreach ($this->raw as $key => $object) {
221  }
222  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ 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 130 of file class.ItemSetManager.php.

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

130  : array
131  {
132  $this->init();
133  return array_keys($this->raw_by_type["_all"]);
134  }
+ Here is the call graph for this function:

◆ getCompleteDescriptions()

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

From ilContainer.

Todo:
remove there

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

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

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

275  : void
276  {
277  $ilSetting = $this->domain->settings();
278  $ilObjDataCache = $this->domain->objectDataCache();
279 
280  // using long descriptions?
281  $short_desc = $ilSetting->get("rep_shorten_description");
282  $short_desc_max_length = (int) $ilSetting->get("rep_shorten_description_length");
283  if (!$short_desc || $short_desc_max_length != \ilObject::DESC_LENGTH) {
284  // using (part of) shortened description
285  if ($short_desc && $short_desc_max_length && $short_desc_max_length < \ilObject::DESC_LENGTH) {
286  foreach ($this->raw as $key => $object) {
287  $this->raw[$key]["description"] = \ilStr::shortenTextExtended(
288  $object["description"],
289  $short_desc_max_length,
290  true
291  );
292  }
293  }
294  // using (part of) long description
295  else {
296  $obj_ids = array();
297  foreach ($this->raw as $key => $object) {
298  $obj_ids[] = $object["obj_id"];
299  }
300  if (count($obj_ids) > 0) {
301  $long_desc = \ilObject::getLongDescriptions($obj_ids);
302  foreach ($this->raw as $key => $object) {
303  // #12166 - keep translation, ignore long description
304  if ($ilObjDataCache->isTranslatedDescription((int) $object["obj_id"])) {
305  $long_desc[$object["obj_id"]] = $object["description"];
306  }
307  if ($short_desc && $short_desc_max_length) {
308  $long_desc[$object["obj_id"]] = \ilStr::shortenTextExtended(
309  (string) ($long_desc[$object["obj_id"]] ?? ""),
310  $short_desc_max_length,
311  true
312  );
313  }
314  $this->raw[$key]["description"] = $long_desc[$object["obj_id"]] ?? '';
315  }
316  }
317  }
318  }
319  }
const DESC_LENGTH
static getLongDescriptions(array $obj_ids)
string $key
Consumer key/client ID value.
Definition: System.php:193
global $ilSetting
Definition: privfeed.php:18
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
+ 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 136 of file class.ItemSetManager.php.

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

136  : ?array
137  {
138  $this->init();
139  return $this->raw_by_type["_all"][$ref_id] ?? null;
140  }
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

◆ getRefIdsOfType()

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

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

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

119  : array
120  {
121  $this->init();
122  if (isset($this->raw_by_type[$type])) {
123  return array_map(static function ($item) {
124  return (int) $item["child"];
125  }, $this->raw_by_type[$type]);
126  }
127  return [];
128  }
+ Here is the call graph for this function:

◆ groupItems()

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

Internally group all items.

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

References ILIAS\LTI\ToolProvider\$key, ilObjFileAccess\_isFileHidden(), ILIAS\Repository\int(), ILIAS\Container\Content\ItemSetManager\isClassificationFilterActive(), ILIAS\Repository\raw(), and ILIAS\Container\Content\ItemSetManager\setHiddenFilesFound().

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

161  : void
162  {
163  $obj_definition = $this->domain->objectDefinition();
164  $classification_filter_active = $this->isClassificationFilterActive();
165  $this->raw_by_type["_all"] = [];
166  foreach ($this->raw as $key => $object) {
167 
168  // hide object types in devmode
169  if ($object["type"] === "adm" || $object["type"] === "rolf" ||
170  $obj_definition->getDevMode($object["type"])) {
171  continue;
172  }
173 
174  // remove inactive plugins
175  if ($obj_definition->isInactivePlugin($object["type"])) {
176  continue;
177  }
178 
179  // BEGIN WebDAV: Don't display hidden Files, Folders and Categories
180  if (in_array($object['type'], array('file','fold','cat'))) {
181  if (\ilObjFileAccess::_isFileHidden($object['title'])) {
182  $this->setHiddenFilesFound(true);
183  if (!$this->admin_mode) {
184  continue;
185  }
186  }
187  }
188  // END WebDAV: Don't display hidden Files, Folders and Categories
189 
190  // group object type groups together (e.g. learning resources)
191  $type = $obj_definition->getGroupOfObj($object["type"]);
192  if ($type == "") {
193  $type = $object["type"];
194  }
195 
196  $new_key = (int) $object["child"];
197  $this->rendered[$new_key] = false;
198  $this->raw_by_type[$type][$new_key] = $object;
199 
200  $this->raw_by_type["_all"][$new_key] = $object;
201  if ($object["type"] !== "sess") {
202  $this->raw_by_type["_non_sess"][$new_key] = $object;
203  }
204  }
205  }
static _isFileHidden(string $a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
setHiddenFilesFound(bool $a_hiddenfilesfound)
string $key
Consumer key/client ID value.
Definition: System.php:193
+ 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 113 of file class.ItemSetManager.php.

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

113  : bool
114  {
115  $this->init();
116  return count($this->raw) > 0;
117  }
+ 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 86 of file class.ItemSetManager.php.

References 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().

86  : void
87  {
88  if ($this->initialised) {
89  return;
90  }
91  $tree = $this->domain->repositoryTree();
92  if ($this->mode === self::TREE) {
93  $this->raw = $tree->getSubTree($tree->getNodeData($this->parent_ref_id));
94  } elseif ($this->mode === self::FLAT) {
95  $this->raw = $tree->getChilds($this->parent_ref_id, "title");
96  } else {
97  $this->raw[] = $tree->getNodeData($this->single_ref_id);
98  }
99  $this->applyUserFilter();
100  $this->getCompleteDescriptions();
101  $this->applyClassificationFilter();
103  $this->applySorting();
104  $this->groupItems();
105  $this->sortSessions();
106  $this->preloadAdvancedMDValues();
107  $this->initialised = true;
108  }
applyUserFilter()
Apply container user filter on objects.
groupItems()
Internally group all items.
+ 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 232 of file class.ItemSetManager.php.

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

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

232  : bool
233  {
234  // apply container classification filters
235  $classification = $this->domain->classification($this->parent_ref_id);
237  $this->parent_ref_id,
238  $this->parent_obj_id,
239  $this->parent_type
240  ) as $class_provider) {
241  $id = get_class($class_provider);
242  $current = $classification->getSelectionOfProvider($id);
243  if ($current) {
244  return true;
245  }
246  }
247  return false;
248  }
$classification
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getValidProviders(int $a_parent_ref_id, int $a_parent_obj_id, string $a_parent_obj_type)
Get all valid providers (for parent container)
+ 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 142 of file class.ItemSetManager.php.

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

142  : bool
143  {
144  $this->init();
145  $type = $this->raw_by_type["_all"][$ref_id]["type"] ?? "";
146  $obj_definition = $this->domain->objectDefinition();
147  return $obj_definition->isSideBlock($type);
148  }
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

◆ preloadAdvancedMDValues()

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

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

References ilAdvancedMDValues\preloadByObjIds().

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

345  : void
346  {
347  $obj_ids = [];
348  foreach ($this->raw_by_type["_all"] as $object) {
349  $obj_ids[] = $object["obj_id"];
350  }
352  }
static preloadByObjIds(array $a_obj_ids)
Preload list gui data.
+ 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 73 of file class.ItemSetManager.php.

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

73  : void
74  {
75  $this->hiddenfilesfound = $a_hiddenfilesfound;
76  }
+ Here is the caller graph for this function:

◆ sortSessions()

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

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

References ilArrayUtil\sortArray().

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

207  : void
208  {
209  if (!$this->force_session_order_by_date) {
210  return;
211  }
212  if (isset($this->raw_by_type["sess"]) && count($this->raw_by_type["sess"]) > 0) {
213  $this->raw_by_type["sess"] = \ilArrayUtil::sortArray($this->raw_by_type["sess"], 'start', 'ASC', true, true);
214  }
215  }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ 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 46 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 35 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 34 of file class.ItemSetManager.php.

◆ $raw

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

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

◆ $raw_by_type

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

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

◆ $rendered

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

Definition at line 43 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

◆ TREE

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

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