ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLSItemsDB Class Reference

Class ilLSItemsDB. 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

 getCurrentLPMode (int $obj_id)
 
 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

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 94 of file ilLSItemsDB.php.

94 : array
95 {
96 $ref_ids = array_map(
97 fn ($i) => (int) $i['child'],
98 $children
99 );
100
101 $conditions = [];
102 foreach ($this->post_conditions_db->select($ref_ids) as $condition) {
103 $conditions[$condition->getRefId()] = $condition;
104 }
105
106 return $conditions;
107 }

Referenced by getLSItems().

+ Here is the caller graph for this function:

◆ getCurrentLPMode()

ilLSItemsDB::getCurrentLPMode ( int  $obj_id)
protected

Reimplemented in ilLSItemsDBStub.

Definition at line 79 of file ilLSItemsDB.php.

79 : int
80 {
81 $obj_lp = ilObjectLP::getInstance($obj_id);
82 return $obj_lp->getCurrentMode();
83 }
static getInstance(int $obj_id)

References ilObjectLP\getInstance().

Referenced by getLSItems().

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

◆ getIconPathForType()

ilLSItemsDB::getIconPathForType ( string  $type)
protected

Reimplemented in ilLSItemsDBStub.

Definition at line 85 of file ilLSItemsDB.php.

85 : string
86 {
87 return ilObject2::_getIcon(0, "big", $type);
88 }
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.

References 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 $obj_id = (int) $child['obj_id'];
61 $lp_mode = $this->getCurrentLPMode($obj_id);
62
63 $items[] = new LSItem(
64 $child['type'],
65 $child['title'],
66 $child['description'] ?? "",
67 $this->getIconPathForType($child['type']),
68 $this->ls_item_online_status->getOnlineStatus($ref_id),
69 $position,
70 $conditions[$ref_id],
71 $ref_id,
72 $lp_mode
73 );
74 }
75
76 return $items;
77 }
Data holding class LSItem .
Definition: LSItem.php:25
getIconPathForType(string $type)
Definition: ilLSItemsDB.php:85
getConditionsForChildren(array $children)
Collect all conditions at once.
Definition: ilLSItemsDB.php:94
getCurrentLPMode(int $obj_id)
Definition: ilLSItemsDB.php:79
$ref_id
Definition: ltiauth.php:66

References $ref_id, getConditionsForChildren(), getCurrentLPMode(), 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 149 of file ilLSItemsDB.php.

149 : \ilObject
150 {
152 }
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObject Basic functions for all objects.

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 140 of file ilLSItemsDB.php.

140 : void
141 {
142 $this->storeOnlineStatus($ls_items);
143 $this->storeItemsOrder($ls_items);
144 $this->storePostconditions($ls_items);
145 }
storePostconditions(array $ls_items)
storeOnlineStatus(array $ls_items)
storeItemsOrder(array $ls_items)

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

+ Here is the call graph for this function:

◆ storeItemsOrder()

ilLSItemsDB::storeItemsOrder ( array  $ls_items)
protected

Definition at line 109 of file ilLSItemsDB.php.

109 : void
110 {
111 $type_positions = [];
112 foreach ($ls_items as $item) {
113 $type_positions[$item->getRefId()] = $item->getOrderNumber();
114 }
115 $this->container_sorting->savePost($type_positions);
116 }

Referenced by storeItems().

+ Here is the caller graph for this function:

◆ storeOnlineStatus()

ilLSItemsDB::storeOnlineStatus ( array  $ls_items)
protected

Definition at line 118 of file ilLSItemsDB.php.

118 : void
119 {
120 foreach ($ls_items as $item) {
121 $this->ls_item_online_status->setOnlineStatus(
122 $item->getRefId(),
123 $item->isOnline()
124 );
125 }
126 }

Referenced by storeItems().

+ Here is the caller graph for this function:

◆ storePostconditions()

ilLSItemsDB::storePostconditions ( array  $ls_items)
protected

Definition at line 128 of file ilLSItemsDB.php.

128 : void
129 {
130 $conditions = [];
131 foreach ($ls_items as $item) {
132 $conditions[] = $item->getPostCondition();
133 }
134 $this->post_conditions_db->upsert($conditions);
135 }

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: