71 if (self::$constructed ===
true) {
72 throw new \LogicException(
"only one Instance of MainMenuMainCollector Collector is possible");
74 self::$constructed =
true;
93 return $this->getStackedTopItems();
101 private function getStackedTopItems() : array
105 foreach (self::$topitems as $top_item) {
109 if ($top_item instanceof
isTopItem && $this->information) {
110 if ($top_item instanceof
isParent) {
111 $has_always_available_item =
false;
117 foreach ($top_item->getChildren() as $child) {
122 $position_of_sub_item = $this->information->getPositionOfSubItem($child);
123 if (isset($children[$position_of_sub_item])) {
124 $position_of_sub_item = max(array_keys($children)) + 1;
126 $children[$position_of_sub_item] = $child;
127 if ($child->isAlwaysAvailable() ===
true) {
128 $has_always_available_item =
true;
137 if (count($children) === 0) {
142 $top_item = $top_item->withChildren($children);
143 if ($has_always_available_item ===
true) {
144 $top_item = $top_item->withAlwaysAvailable(
true);
148 $position_of_top_item = $this->information->getPositionOfTopItem($top_item);
149 if (isset($top_items[$position_of_top_item])) {
150 $position_of_top_item = max(array_keys($top_items)) + 1;
152 $top_items[$position_of_top_item] = $top_item;
170 $is_item_active = $this->information->isItemActive($item);
173 return !(!$is_visible || !$is_item_active && !$is_always_available);
187 return self::$items[$identification->serialize()];
203 return $DIC->globalScreen()->mainmenu()->custom(Lost::class,
new NullIdentification($identification))
204 ->withAlwaysAvailable(
true)
205 ->setTypeInformation($this->type_information_collection->get(Lost::class))
206 ->withNonAvailableReason($DIC->ui()->factory()->legacy(
"{$DIC->language()->txt('mme_lost_item_reason')}"))
207 ->withVisibilityCallable(
208 function () use ($DIC) {
209 return (
bool) ($DIC->rbac()->system()->checkAccess(
"visible", SYSTEM_FOLDER_ID));
211 )->withTitle($DIC->language()->txt(
"mme_lost_item_title"));
219 private function load() :
bool 221 if ($this->loaded ===
false || $this->loaded === null) {
228 $this->loaded =
true;
243 foreach ($this->providers as
$provider) {
244 foreach ($provider->getStaticTopItems() as $top_item) {
245 if ($top_item instanceof
hasTitle && $this->information) {
246 $top_item = $this->information->translateItemForUser($top_item);
256 foreach ($this->providers as
$provider) {
257 foreach ($provider->getStaticSubItems() as $sub_item) {
258 if ($sub_item instanceof
hasTitle && $this->information) {
259 $sub_item = $this->information->translateItemForUser($sub_item);
262 $new_parent_identification = $this->information->getParent($sub_item);
263 $parent_item = $this->
getSingleItem($new_parent_identification);
268 $sub_item->overrideParent($parent_item->getProviderIdentification());
270 $sub_item->overrideParent($new_parent_identification);
273 $this->
getItemFromMap($sub_item->getParent())->appendChild($sub_item);
275 if ($sub_item->isAlwaysAvailable()) {
276 $parent = $this->
getItemFromMap($sub_item->getParent())->withAlwaysAvailable(
true);
296 $item = $this->getHandlerForItem($item)->enrichItem($item);
312 $type = get_class($item);
313 $type_information = $this->type_information_collection->get(
$type);
314 if (is_null($type_information)) {
317 $handler = $type_information->getTypeHandler();
331 foreach ($children as $position => $child) {
337 if ($separators > 1) {
338 unset($children[$position]);
356 foreach ($children as $position => $child) {
359 if (count($children) === 1) {
360 unset($children[$position]);
365 if ($position == min(array_keys($children))) {
366 unset($children[$position]);
370 if ($position == max(array_keys($children))) {
371 unset($children[$position]);
392 foreach ($this->providers as
$provider) {
394 $this->type_information_collection->append($provider->provideTypeInformation());
405 if ($item instanceof
isItem) {
423 return isset(self::$items[$identification->serialize()]);
438 return self::$items[$identification->serialize()];
Class MainMenuMainCollector.
getProviderIdentification()
getItemFromMap(IdentificationInterface $identification)
addItemToMap(isItem $item)
getTypeInformationCollection()
Interface IdentificationInterface.
Class NullIdentification.
itemExistsInMap(IdentificationInterface $identification)
handleSolitaryDividers($children, $top_item)
bugfix mantis 25577: prevent solitary dividers from being shown
checkAvailability(isItem $item)
setTypeInformation(TypeInformation $information)
Class TypeInformationCollection.
getSingleItem(IdentificationInterface $identification)
$type_information_collection
handleDoubleDividers($children)
getStackedTopItemsForPresentation()
This will return all available topitems, stacked based on the configuration in "Administration" and f...
getLostItem(IdentificationInterface $identification)
applyTypeHandler(isItem $item)
Interface StaticMainMenuProvider.
__construct(array $providers, ItemInformation $information=null)
MainMenuMainCollector constructor.