3 declare(strict_types=1);
47 public function sort(): self
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;
71 foreach ($items_arr as $value) {
72 $result[] = $value[
'item'];
74 $this->items = $result;
77 $sorted = $unsorted = [];
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;
89 $unsorted[$link_id][
'title'] = $item->getTitle();
90 $unsorted[$link_id][
'item'] = $item;
109 foreach ($sorted + $unsorted as $value) {
110 $result[] = $value[
'item'];
112 $this->items = $result;
128 return $this->items[0] ?? null;
__construct(int $webr_id, array $items=[])
static lookupPositions(int $a_obj_id)
static _lookupSortMode(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
sort()
Sorts the items in this container according to the settings of this web link object.
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)