ILIAS  release_8 Revision v8.24
ilWebLinkItemsContainer 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 ilWebLinkItemsContainer:
+ Collaboration diagram for ilWebLinkItemsContainer:

Public Member Functions

 __construct (int $webr_id, array $items=[])
 
 sort ()
 Sorts the items in this container according to the settings of this web link object. More...
 
 getItems ()
 
 getFirstItem ()
 
 getWebrId ()
 
- Public Member Functions inherited from ilWebLinkBaseItemsContainer
 __construct (array $items=[])
 
 getItems ()
 
 getFirstItem ()
 

Protected Attributes

int $webr_id
 
array $items
 
- Protected Attributes inherited from ilWebLinkBaseItemsContainer
array $items
 

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 Immutable container class for Web Link items

Author
Tim Schmitz schmi.nosp@m.tz@l.nosp@m.eifos.nosp@m..de

Definition at line 25 of file class.ilWebLinkItemsContainer.php.

Constructor & Destructor Documentation

◆ __construct()

ilWebLinkItemsContainer::__construct ( int  $webr_id,
array  $items = [] 
)
Parameters
int$webr_id
ilWebLinkItem[]$items

Definition at line 37 of file class.ilWebLinkItemsContainer.php.

38 {
39 $this->webr_id = $webr_id;
41 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $items, $webr_id, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getFirstItem()

ilWebLinkItemsContainer::getFirstItem ( )

Reimplemented from ilWebLinkBaseItemsContainer.

Definition at line 126 of file class.ilWebLinkItemsContainer.php.

127 {
128 return $this->items[0] ?? null;
129 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getItems()

ilWebLinkItemsContainer::getItems ( )
Returns
ilWebLinkItem[]

Reimplemented from ilWebLinkBaseItemsContainer.

Definition at line 121 of file class.ilWebLinkItemsContainer.php.

121 : array
122 {
123 return $this->items;
124 }

References $items.

Referenced by sort().

+ Here is the caller graph for this function:

◆ getWebrId()

ilWebLinkItemsContainer::getWebrId ( )

Definition at line 131 of file class.ilWebLinkItemsContainer.php.

131 : int
132 {
133 return $this->webr_id;
134 }

References $webr_id.

Referenced by sort().

+ Here is the caller graph for this function:

◆ sort()

ilWebLinkItemsContainer::sort ( )

Sorts the items in this container according to the settings of this web link object.

Definition at line 47 of file class.ilWebLinkItemsContainer.php.

47 : self
48 {
50 $this->getWebrId()
51 );
52
53 if ($mode == ilContainer::SORT_TITLE) {
54 $items_arr = [];
55
56 foreach ($this->getItems() as $item) {
57 $link_id = $item->getLinkId();
58 $items_arr[$link_id]['title'] = $item->getTitle();
59 $items_arr[$link_id]['item'] = $item;
60 }
61
62 $items_arr = ilArrayUtil::sortArray(
63 $items_arr,
64 'title',
65 'asc',
66 false,
67 true
68 );
69
70 $result = [];
71 foreach ($items_arr as $value) {
72 $result[] = $value['item'];
73 }
74 $this->items = $result;
75 }
76
77 $sorted = $unsorted = [];
78 if ($mode == ilContainer::SORT_MANUAL) {
80 $this->getWebrId()
81 );
82 foreach ($this->getItems() as $item) {
83 $link_id = $item->getLinkId();
84 if (isset($pos[$link_id])) {
85 $sorted[$link_id]['title'] = $item->getTitle();
86 $sorted[$link_id]['position'] = (int) $pos[$link_id];
87 $sorted[$link_id]['item'] = $item;
88 } else {
89 $unsorted[$link_id]['title'] = $item->getTitle();
90 $unsorted[$link_id]['item'] = $item;
91 }
92 }
93 $sorted = ilArrayUtil::sortArray(
94 $sorted,
95 'position',
96 'asc',
97 true,
98 true
99 );
100 $unsorted = ilArrayUtil::sortArray(
101 $unsorted,
102 'title',
103 'asc',
104 false,
105 true
106 );
107
108 $result = [];
109 foreach ($sorted + $unsorted as $value) {
110 $result[] = $value['item'];
111 }
112 $this->items = $result;
113 }
114
115 return $this;
116 }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static lookupPositions(int $a_obj_id)

References ilContainerSortingSettings\_lookupSortMode(), getItems(), getWebrId(), ILIAS\Repository\int(), ilContainerSorting\lookupPositions(), ilContainer\SORT_MANUAL, ilContainer\SORT_TITLE, and ilArrayUtil\sortArray().

+ Here is the call graph for this function:

Field Documentation

◆ $items

array ilWebLinkItemsContainer::$items
protected

Definition at line 31 of file class.ilWebLinkItemsContainer.php.

Referenced by __construct(), and getItems().

◆ $webr_id

int ilWebLinkItemsContainer::$webr_id
protected

Definition at line 27 of file class.ilWebLinkItemsContainer.php.

Referenced by __construct(), and getWebrId().


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