ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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.

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

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  }
ilContainerSorting $container_sorting
Definition: ilLSItemsDB.php:27
LSItemOnlineStatus $ls_item_online_status
Definition: ilLSItemsDB.php:29
ilTree $tree
Definition: ilLSItemsDB.php:26
ilLSPostConditionDB $post_conditions_db
Definition: ilLSItemsDB.php:28

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.

Referenced by getLSItems().

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  }
+ Here is the caller graph for this function:

◆ getCurrentLPMode()

ilLSItemsDB::getCurrentLPMode ( int  $obj_id)
protected

Definition at line 79 of file ilLSItemsDB.php.

References ilObjectLP\getInstance().

Referenced by getLSItems().

79  : int
80  {
81  $obj_lp = ilObjectLP::getInstance($obj_id);
82  return $obj_lp->getCurrentMode();
83  }
static getInstance(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIconPathForType()

ilLSItemsDB::getIconPathForType ( string  $type)
protected

Definition at line 85 of file ilLSItemsDB.php.

References ilObject\_getIcon().

Referenced by getLSItems().

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.
+ 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.

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

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:24
$ref_id
Definition: ltiauth.php:65
getConditionsForChildren(array $children)
Collect all conditions at once.
Definition: ilLSItemsDB.php:94
getIconPathForType(string $type)
Definition: ilLSItemsDB.php:85
getCurrentLPMode(int $obj_id)
Definition: ilLSItemsDB.php:79
+ Here is the call graph for this function:

◆ getObjectFor()

ilLSItemsDB::getObjectFor ( int  $ref_id)
protected

Definition at line 149 of file ilLSItemsDB.php.

References ilObjectFactory\getInstanceByRefId().

149  : \ilObject
150  {
152  }
Class ilObject Basic functions for all objects.
$ref_id
Definition: ltiauth.php:65
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
+ 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.

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

140  : void
141  {
142  $this->storeOnlineStatus($ls_items);
143  $this->storeItemsOrder($ls_items);
144  $this->storePostconditions($ls_items);
145  }
storeItemsOrder(array $ls_items)
storeOnlineStatus(array $ls_items)
storePostconditions(array $ls_items)
+ Here is the call graph for this function:

◆ storeItemsOrder()

ilLSItemsDB::storeItemsOrder ( array  $ls_items)
protected

Definition at line 109 of file ilLSItemsDB.php.

Referenced by storeItems().

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  }
+ Here is the caller graph for this function:

◆ storeOnlineStatus()

ilLSItemsDB::storeOnlineStatus ( array  $ls_items)
protected

Definition at line 118 of file ilLSItemsDB.php.

Referenced by storeItems().

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  }
+ Here is the caller graph for this function:

◆ storePostconditions()

ilLSItemsDB::storePostconditions ( array  $ls_items)
protected

Definition at line 128 of file ilLSItemsDB.php.

Referenced by storeItems().

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