ILIAS  release_8 Revision v8.24
ilLSItemsDB Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilLSItemsDB:
+ Collaboration diagram for ilLSItemsDB:

Public Member Functions

 __construct (ilTree $tree, ilContainerSorting $container_sorting, ilLSPostConditionDB $post_conditions_db, LSItemOnlineStatus $ls_item_online_status)
 
 getLSItems (int $ref_id)
 
 storeItems (array $ls_items)
 Use this to apply settings made in ContentGUI. More...
 

Protected Member Functions

 getIconPathForType (string $type)
 
 getConditionsForChildren (array $children)
 Collect all conditions at once. More...
 
 storeItemsOrder (array $ls_items)
 
 storeOnlineStatus (array $ls_items)
 
 storePostconditions (array $ls_items)
 
 getObjectFor (int $ref_id)
 

Protected Attributes

ilTree $tree
 
ilContainerSorting $container_sorting
 
ilLSPostConditionDB $post_conditions_db
 
LSItemOnlineStatus $ls_item_online_status
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilLSItemsDB

Definition at line 24 of file ilLSItemsDB.php.

Constructor & Destructor Documentation

◆ __construct()

ilLSItemsDB::__construct ( ilTree  $tree,
ilContainerSorting  $container_sorting,
ilLSPostConditionDB  $post_conditions_db,
LSItemOnlineStatus  $ls_item_online_status 
)

Definition at line 31 of file ilLSItemsDB.php.

36 {
37 $this->tree = $tree;
38 $this->container_sorting = $container_sorting;
39 $this->post_conditions_db = $post_conditions_db;
40 $this->ls_item_online_status = $ls_item_online_status;
41 }
ilLSPostConditionDB $post_conditions_db
Definition: ilLSItemsDB.php:28
ilContainerSorting $container_sorting
Definition: ilLSItemsDB.php:27
ilTree $tree
Definition: ilLSItemsDB.php:26
LSItemOnlineStatus $ls_item_online_status
Definition: ilLSItemsDB.php:29

References $container_sorting, $ls_item_online_status, $post_conditions_db, and $tree.

Member Function Documentation

◆ getConditionsForChildren()

ilLSItemsDB::getConditionsForChildren ( array  $children)
protected

Collect all conditions at once.

Returns
array <int,ilLSPostCondition>

Definition at line 84 of file ilLSItemsDB.php.

84 : array
85 {
86 $ref_ids = array_map(
87 fn ($i) => (int) $i['child'],
88 $children
89 );
90
91 $conditions = [];
92 foreach ($this->post_conditions_db->select($ref_ids) as $condition) {
93 $conditions[$condition->getRefId()] = $condition;
94 }
95
96 return $conditions;
97 }
$i
Definition: metadata.php:41

References $i.

Referenced by getLSItems().

+ Here is the caller graph for this function:

◆ getIconPathForType()

ilLSItemsDB::getIconPathForType ( string  $type)
protected

Reimplemented in ilLSItemsDBStub.

Definition at line 75 of file ilLSItemsDB.php.

75 : string
76 {
77 return ilObject2::_getIcon(0, "big", $type);
78 }
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
$type

References $type, and ilObject\_getIcon().

Referenced by getLSItems().

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

◆ getLSItems()

ilLSItemsDB::getLSItems ( int  $ref_id)
Returns
LSItem[]

Definition at line 46 of file ilLSItemsDB.php.

46 : array
47 {
48 $children = $this->tree->getChilds($ref_id);
49
50 $sorting_settings = $this->container_sorting->getSortingSettings();
51 $sorting_settings->setSortMode(ilContainer::SORT_MANUAL);
52 $sorted = $this->container_sorting->sortItems(['lsitems' => $children]);
53 $children = $sorted['lsitems'];
54
55 $conditions = $this->getConditionsForChildren($children);
56
57 $items = [];
58 foreach ($children as $position => $child) {
59 $ref_id = (int) $child['child'];
60 $items[] = new LSItem(
61 $child['type'],
62 $child['title'],
63 $child['description'] ?? "",
64 $this->getIconPathForType($child['type']),
65 $this->ls_item_online_status->getOnlineStatus($ref_id),
66 $position,
67 $conditions[$ref_id],
69 );
70 }
71
72 return $items;
73 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: LSItem.php:25
getIconPathForType(string $type)
Definition: ilLSItemsDB.php:75
getConditionsForChildren(array $children)
Collect all conditions at once.
Definition: ilLSItemsDB.php:84
$ref_id
Definition: ltiauth.php:67

References $ref_id, getConditionsForChildren(), getIconPathForType(), ILIAS\Repository\int(), and ilContainer\SORT_MANUAL.

+ Here is the call graph for this function:

◆ getObjectFor()

ilLSItemsDB::getObjectFor ( int  $ref_id)
protected

Definition at line 139 of file ilLSItemsDB.php.

139 : \ilObject
140 {
142 }
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $ref_id, and ilObjectFactory\getInstanceByRefId().

+ Here is the call graph for this function:

◆ storeItems()

ilLSItemsDB::storeItems ( array  $ls_items)

Use this to apply settings made in ContentGUI.

Definition at line 130 of file ilLSItemsDB.php.

130 : void
131 {
132 $this->storeOnlineStatus($ls_items);
133 $this->storeItemsOrder($ls_items);
134 $this->storePostconditions($ls_items);
135 }
storePostconditions(array $ls_items)
storeOnlineStatus(array $ls_items)
storeItemsOrder(array $ls_items)
Definition: ilLSItemsDB.php:99

References storeItemsOrder(), storeOnlineStatus(), and storePostconditions().

+ Here is the call graph for this function:

◆ storeItemsOrder()

ilLSItemsDB::storeItemsOrder ( array  $ls_items)
protected

Definition at line 99 of file ilLSItemsDB.php.

99 : void
100 {
101 $type_positions = [];
102 foreach ($ls_items as $item) {
103 $type_positions[$item->getRefId()] = $item->getOrderNumber();
104 }
105 $this->container_sorting->savePost($type_positions);
106 }

Referenced by storeItems().

+ Here is the caller graph for this function:

◆ storeOnlineStatus()

ilLSItemsDB::storeOnlineStatus ( array  $ls_items)
protected

Definition at line 108 of file ilLSItemsDB.php.

108 : void
109 {
110 foreach ($ls_items as $item) {
111 $this->ls_item_online_status->setOnlineStatus(
112 $item->getRefId(),
113 $item->isOnline()
114 );
115 }
116 }

Referenced by storeItems().

+ Here is the caller graph for this function:

◆ storePostconditions()

ilLSItemsDB::storePostconditions ( array  $ls_items)
protected

Definition at line 118 of file ilLSItemsDB.php.

118 : void
119 {
120 $conditions = [];
121 foreach ($ls_items as $item) {
122 $conditions[] = $item->getPostCondition();
123 }
124 $this->post_conditions_db->upsert($conditions);
125 }

Referenced by storeItems().

+ Here is the caller graph for this function:

Field Documentation

◆ $container_sorting

ilContainerSorting ilLSItemsDB::$container_sorting
protected

Definition at line 27 of file ilLSItemsDB.php.

Referenced by __construct().

◆ $ls_item_online_status

LSItemOnlineStatus ilLSItemsDB::$ls_item_online_status
protected

Definition at line 29 of file ilLSItemsDB.php.

Referenced by __construct().

◆ $post_conditions_db

ilLSPostConditionDB ilLSItemsDB::$post_conditions_db
protected

Definition at line 28 of file ilLSItemsDB.php.

Referenced by __construct().

◆ $tree

ilTree ilLSItemsDB::$tree
protected

Definition at line 26 of file ilLSItemsDB.php.

Referenced by __construct().


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