ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLSItemsDB Class Reference

Class ilLSItemsDB. More...

+ 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

 $tree
 
 $container_sorting
 
 $post_conditions_db
 
 $ls_item_online_status
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 33 of file ilLSItemsDB.php.

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

38  {
39  $this->tree = $tree;
40  $this->container_sorting = $container_sorting;
41  $this->post_conditions_db = $post_conditions_db;
42  $this->ls_item_online_status = $ls_item_online_status;
43  }

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.

References $i.

Referenced by getLSItems().

84  : array
85  {
86  $ref_ids = array_map(
87  function ($i) {
88  return (int) $i['child'];
89  },
90  $children
91  );
92 
93  $conditions = [];
94  foreach ($this->post_conditions_db->select($ref_ids) as $condition) {
95  $conditions[$condition->getRefId()] = $condition;
96  }
97 
98  return $conditions;
99  }
$i
Definition: disco.tpl.php:19
+ Here is the caller graph for this function:

◆ getIconPathForType()

ilLSItemsDB::getIconPathForType ( string  $type)
protected

Definition at line 75 of file ilLSItemsDB.php.

References ilObject2\_getIcon().

Referenced by getLSItems().

75  : string
76  {
77  return ilObject2::_getIcon("", "big", $type);
78  }
$type
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLSItems()

ilLSItemsDB::getLSItems ( int  $ref_id)

Definition at line 45 of file ilLSItemsDB.php.

References ilObject2\_getIcon(), getConditionsForChildren(), getIconPathForType(), and ilContainer\SORT_MANUAL.

45  : array
46  {
47  $children = $this->tree->getChilds($ref_id);
48 
49  $sorting_settings = $this->container_sorting->getSortingSettings();
50  $sorting_settings->setSortMode(ilContainer::SORT_MANUAL);
51  $sorted = $this->container_sorting->sortItems(array('lsitems' => $children));
52  $children = $sorted['lsitems'];
53 
54  $conditions = $this->getConditionsForChildren($children);
55 
56  $items = [];
57  foreach ($children as $position => $child) {
58  $ref_id = (int) $child['child'];
59  $icon_path = ilObject2::_getIcon("", "big", $child['type']);
60  $items[] = new LSItem(
61  $child['type'],
62  $child['title'],
63  $child['description'] ?? "",
64  $icon_path = $this->getIconPathForType($child['type']),
65  $this->ls_item_online_status->getOnlineStatus($ref_id),
66  $position,
67  $conditions[$ref_id],
68  $ref_id
69  );
70  }
71 
72  return $items;
73  }
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Data holding class LSItem .
Definition: LSItem.php:11
getConditionsForChildren(array $children)
Collect all conditions at once.
Definition: ilLSItemsDB.php:84
getIconPathForType(string $type)
Definition: ilLSItemsDB.php:75
+ Here is the call graph for this function:

◆ getObjectFor()

ilLSItemsDB::getObjectFor ( int  $ref_id)
protected

Definition at line 139 of file ilLSItemsDB.php.

References ilObjectFactory\getInstanceByRefId().

139  : ilObject
140  {
141  return ilObjectFactory::getInstanceByRefId($ref_id);
142  }
static getInstanceByRefId($a_ref_id, $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 132 of file ilLSItemsDB.php.

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

133  {
134  $this->storeOnlineStatus($ls_items);
135  $this->storeItemsOrder($ls_items);
136  $this->storePostconditions($ls_items);
137  }
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 101 of file ilLSItemsDB.php.

Referenced by storeItems().

102  {
103  $type_positions = [];
104  foreach ($ls_items as $item) {
105  $type_positions[$item->getRefId()] = $item->getOrderNumber();
106  }
107  $this->container_sorting->savePost($type_positions);
108  }
+ Here is the caller graph for this function:

◆ storeOnlineStatus()

ilLSItemsDB::storeOnlineStatus ( array  $ls_items)
protected

Definition at line 110 of file ilLSItemsDB.php.

Referenced by storeItems().

111  {
112  foreach ($ls_items as $item) {
113  $this->ls_item_online_status->setOnlineStatus(
114  $item->getRefId(),
115  $item->isOnline()
116  );
117  }
118  }
+ Here is the caller graph for this function:

◆ storePostconditions()

ilLSItemsDB::storePostconditions ( array  $ls_items)
protected

Definition at line 120 of file ilLSItemsDB.php.

Referenced by storeItems().

121  {
122  $conditions = [];
123  foreach ($ls_items as $item) {
124  $conditions[] = $item->getPostCondition();
125  }
126  $this->post_conditions_db->upsert($conditions);
127  }
+ Here is the caller graph for this function:

Field Documentation

◆ $container_sorting

ilLSItemsDB::$container_sorting
protected

Definition at line 21 of file ilLSItemsDB.php.

Referenced by __construct().

◆ $ls_item_online_status

ilLSItemsDB::$ls_item_online_status
protected

Definition at line 31 of file ilLSItemsDB.php.

Referenced by __construct().

◆ $post_conditions_db

ilLSItemsDB::$post_conditions_db
protected

Definition at line 26 of file ilLSItemsDB.php.

Referenced by __construct().

◆ $tree

ilLSItemsDB::$tree
protected

Definition at line 16 of file ilLSItemsDB.php.

Referenced by __construct().


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