ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilFooterCustomItemInformation.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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) {
66  return $this->user_language;
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 (
138  (($translation = $this->translations()->get($d)->getLanguageCode($this->userLanguage())) !== null)
139  && $translation->getTranslation() !== ''
140  ) {
141  return $item->withTitle($translation->getTranslation());
142  }
143 
144  return $item->withTitle($d->getTitle());
145  }
146 
147  public function getParent(isItem $item): IdentificationInterface
148  {
149  $entry = $this->entries()->get($item->getProviderIdentification()->serialize());
150 
151  if ($entry === null) {
152  return $item->getProviderIdentification();
153  }
154 
155  return $this->id()->fromSerializedIdentification($entry->getParent());
156  }
157 
158 }
__construct(private readonly Container $dic)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
$dic
Definition: result.php:31