ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMMItemInformation.php
Go to the documentation of this file.
1<?php
2
12
19{
20
24 private $translations = [];
28 private $items = [];
29
30
36 public function __construct()
37 {
38 $this->items = ilMMItemStorage::getArray('identification');
39 $this->translations = ilMMItemTranslationStorage::getArray('id', 'translation');
40 }
41
42
46 public function translateItemForUser(hasTitle $item) : hasTitle
47 {
51 global $DIC;
52 static $usr_language_key;
53 static $default_language;
54 if (!$usr_language_key) {
55 $usr_language_key = $DIC->language()->getUserLanguage() ? $DIC->language()->getUserLanguage() : $DIC->language()->getDefaultLanguage();
56 }
57 if (!$default_language) {
59 }
60
62 'identification' => $item->getProviderIdentification()->serialize()
63 ], '=')->first();
64
65 if (null !== $ar && $item instanceof RepositoryLink && empty($item->getTitle())) {
66 $item = $item->withTitle(($ar->getAction() > 0) ?
68 ""
69 );
70 }
71 if (null !== $ar && $item instanceof Link && empty($item->getTitle())) {
72 $item = $item->withTitle($ar->getAction());
73 }
74 if ($item instanceof hasTitle && isset($this->translations["{$item->getProviderIdentification()->serialize()}|$usr_language_key"])
75 && $this->translations["{$item->getProviderIdentification()->serialize()}|$usr_language_key"] !== ''
76 ) {
77 $item = $item->withTitle((string) $this->translations["{$item->getProviderIdentification()->serialize()}|$usr_language_key"]);
78 }
79
80 return $item;
81 }
82
83
87 public function getPositionOfSubItem(isChild $child) : int
88 {
89 $position = $this->getPosition($child);
90
91 return $position;
92 }
93
94
98 public function getPositionOfTopItem(isTopItem $top_item) : int
99 {
100 return $this->getPosition($top_item);
101 }
102
103
104 private function getPosition(isItem $item) : int
105 {
106 if (isset($this->items[$item->getProviderIdentification()->serialize()]['position'])) {
107 return (int) $this->items[$item->getProviderIdentification()->serialize()]['position'];
108 }
109
110 return $item->getPosition();
111 }
112
113
117 public function isItemActive(isItem $item) : bool
118 {
119 $serialize = $item->getProviderIdentification()->serialize();
120 if (isset($this->items[$serialize]['active'])) {
121 return $this->items[$serialize]['active'] === "1";
122 }
123
124 return $item->isActive();
125 }
126
127
132 {
133 global $DIC;
134 $parent_string = $item->getProviderIdentification()->serialize();
135 if (isset($this->items[$parent_string]['parent_identification'])) {
136 return $DIC->globalScreen()->identification()->fromSerializedIdentification($this->items[$parent_string]['parent_identification']);
137 }
138
139 return $item->getParent();
140 }
141}
static where($where, $operator=null)
static getArray($key=null, $values=null)
An exception for terminatinating execution or to throw for unit testing.
Class ilMMItemInformation.
__construct()
ilMMItemInformation constructor.
getPositionOfTopItem(isTopItem $top_item)
@inheritDoc
getPositionOfSubItem(isChild $child)
@inheritDoc
getParent(isChild $item)
@inheritDoc
isItemActive(isItem $item)
@inheritDoc
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
getPosition()
Return the default position for installation, this will be overridden by the configuration later.
global $DIC
Definition: saml.php:7