ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFooterCustomItemInformation.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
37
42{
47 private ?string $user_language = null;
48
49 public function __construct(private readonly Container $dic)
50 {
51 }
52
54 {
55 if ($this->translations_repository !== null) {
57 }
58
59 $this->translations_repository = new TranslationsRepositoryDB($this->dic->database());
61 }
62
63 private function userLanguage(): string
64 {
65 if ($this->user_language !== null) {
67 }
68 return $this->user_language = $this->dic->user()->getLanguage();
69 }
70
71 private function groups(): GroupsRepository
72 {
73 if ($this->groups_repository !== null) {
75 }
76
77 $this->groups_repository = new GroupsRepositoryDB($this->dic->database());
78 $this->groups_repository->preload();
80 }
81
82 private function entries(): EntriesRepository
83 {
84 if ($this->entries_repository !== null) {
86 }
87
88 $this->entries_repository = new EntriesRepositoryDB($this->dic->database());
89 $this->entries_repository->preload();
91 }
92
93 private function id(): IdentificationFactory
94 {
95 return $this->identifications ?? $this->dic->globalScreen()->identification();
96 }
97
98 private function maybeGetItem(isItem $item): Group|Entry|null
99 {
100 if ($item instanceof canHaveParent) {
101 return $this->entries()->get($item->getProviderIdentification()->serialize());
102 }
103
104 if ($item instanceof isGroup) {
105 return $this->groups()->get($item->getProviderIdentification()->serialize());
106 }
107 return null;
108 }
109
110 public function isItemActive(isItem $item): bool
111 {
112 $d = $this->maybeGetItem($item);
113 if ($d === null) {
114 return $item->isAvailable();
115 }
116
117 return $d->isActive();
118 }
119
120 public function customPosition(isItem $item): isItem
121 {
122 $d = $this->maybeGetItem($item);
123 if ($d === null) {
124 return $item;
125 }
126
127 return $item->withPosition($d->getPosition());
128 }
129
131 {
132 $d = $this->maybeGetItem($item);
133 if ($d === null) {
134 return $item;
135 }
136
137 if ($d->isCore()) {
138 return $item->withIsCore();
139 }
140
141 if (
142 (($translation = $this->translations()->get($d)->getLanguageCode($this->userLanguage())) !== null)
143 && $translation->getTranslation() !== ''
144 ) {
145 return $item->withTitle($translation->getTranslation());
146 }
147
148 return $item->withTitle($d->getTitle());
149 }
150
152 {
153 $entry = $this->entries()->get($item->getProviderIdentification()->serialize());
154
155 if ($entry === null) {
156 return $item->getProviderIdentification();
157 }
158
159 return $this->id()->fromSerializedIdentification($entry->getParent());
160 }
161
162}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
__construct(private readonly Container $dic)
withIsCore()
@description Core Items are handled differently, they are not translatable via GUI and use their tran...
$dic
Definition: ltiresult.php:33