19 declare(strict_types=1);
47 public function sort(): self
54 foreach ($this->
getItems() as $item) {
55 $link_id = $item->getLinkId();
56 $items_arr[$link_id][
'title'] = $item->getTitle();
57 $items_arr[$link_id][
'item'] = $item;
67 foreach ($items_arr as $value) {
68 $result[] = $value[
'item'];
70 $this->items = $result;
73 $sorted = $unsorted = [];
76 foreach ($this->
getItems() as $item) {
77 $link_id = $item->getLinkId();
78 if (isset($pos[$link_id])) {
79 $sorted[$link_id][
'title'] = $item->getTitle();
80 $sorted[$link_id][
'position'] = (
int) $pos[$link_id];
81 $sorted[$link_id][
'item'] = $item;
83 $unsorted[$link_id][
'title'] = $item->getTitle();
84 $unsorted[$link_id][
'item'] = $item;
99 foreach ($sorted + $unsorted as $value) {
100 $result[] = $value[
'item'];
102 $this->items = $result;
121 protected function sortArray(array $array,
string $sort_by_key,
bool $numeric): array
142 return $this->items[0] ??
null;
__construct(int $webr_id, array $items=[])
static lookupPositions(int $a_obj_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _lookupSortMode(int $a_obj_id)
Base container class for Web Link items.
Immutable container class for Web Link items.
sortArray(array $array, string $sort_by_key, bool $numeric)
sort()
Sorts the items in this container according to the settings of this web link object.
lookupManualPositions(int $webr_id)
__construct(Container $dic, ilPlugin $plugin)
Immutable class for Web Link items.
lookupSortMode(int $webr_id)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)