ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjectAdditionalPropertiesLegacyRepository.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 use ILIAS\Object\Properties\ObjectTypeSpecificProperties\Factory as ObjectTypeSpecificPropertiesFactory;
22 
28 {
29  public function __construct(
30  private ilObjectCustomIconFactory $custom_icon_factory,
31  private ObjectTypeSpecificPropertiesFactory $object_type_specific_properties_factory
32  ) {
33  }
34 
35  public function getFor(int $object_id): ilObjectAdditionalProperties
36  {
37  if ($object_id === 0) {
38  return $this->getDefaultAdditionalProperties();
39  }
40 
41  $type = ilObject::_lookupType($object_id);
42  $object_type_specific_properties = $this->object_type_specific_properties_factory->getForObjectTypeString($type);
43  $providers = null;
44  if ($object_type_specific_properties !== null) {
45  $providers = $object_type_specific_properties->getProviders();
46  }
47 
53  $this->areCustomIconsEnabled(),
54  $this->custom_icon_factory->getByObjId($object_id),
55  $providers
56  ),
57  $object_id
58  );
59  }
60 
62  {
63  if ($properties->getObjectId() === null) {
64  throw new \Exception('The current configuration cannot be saved.');
65  }
66 
67  $object_id = $properties->getObjectId();
68 
69  if ($properties->wasPropertyTitleAndIconVisibilityUpdated()) {
71  $object_id,
72  $properties->getPropertyTitleAndIconVisibility()->getVisibility()
73  );
74  }
75 
76  if ($properties->wasPropertyHeaderActionVisbilityUpdated()) {
78  $object_id,
79  $properties->getPropertyHeaderActionVisibility()->getVisibility()
80  );
81  }
82 
83  if ($properties->wasPropertyInfoTabVisbilityUpdated()) {
85  $object_id,
86  $properties->getPropertyInfoTabVisibility()->getVisibility()
87  );
88  }
89 
90  if ($properties->wasPropertyIconUpdated()) {
91  $this->storeIcon($properties->getPropertyIcon());
92  }
93 
94  return $properties->withResetUpdatedFlags();
95  }
96 
98  {
104  $this->areCustomIconsEnabled()
105  )
106  );
107  }
108 
109  private function getTitleAndIconVisibility(int $object_id): bool
110  {
111  return !((bool) ilContainer::_lookupContainerSetting($object_id, 'hide_header_icon_and_title'));
112  }
113 
114  private function storeTitleAndIconVisibility(int $object_id, bool $visibility): void
115  {
116  $hide_header_icon_and_title = $visibility ? '' : '1';
118  $object_id,
119  'hide_header_icon_and_title',
120  $hide_header_icon_and_title
121  );
122  }
123 
124  private function getHeaderActionVisibility(int $object_id): bool
125  {
126  return !((bool) ilContainer::_lookupContainerSetting($object_id, 'hide_top_actions'));
127  }
128 
129  private function storeHeaderActionVisibility(int $object_id, bool $visibility): void
130  {
131  $hide_top_actions = $visibility ? '' : '1';
133  $object_id,
134  'hide_top_actions',
135  $hide_top_actions
136  );
137  }
138 
139  private function getInfoTabVisibility(int $object_id): bool
140  {
141  return ((bool) ilContainer::_lookupContainerSetting($object_id, 'cont_show_info_tab'));
142  }
143 
144  private function storeInfoTabVisibility(int $object_id, bool $visibility): void
145  {
146  $show_info_tab = $visibility ? '1' : '';
148  $object_id,
149  'cont_show_info_tab',
150  $show_info_tab
151  );
152  }
153 
154  private function areCustomIconsEnabled(): bool
155  {
156  return (bool) ilSetting::_lookupValue('common', 'custom_icons');
157  }
158 
159  private function storeIcon(ilObjectPropertyIcon $property_icon): void
160  {
161  if ($property_icon->getDeletedFlag()) {
162  $property_icon->getCustomIcon()->remove();
163  }
164 
165  if ($property_icon->getTempFileName()) {
166  $property_icon->getCustomIcon()->saveFromTempFileName($property_icon->getTempFileName());
167  }
168  }
169 }
static _lookupValue(string $a_module, string $a_keyword)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Builds data types.
Definition: Factory.php:35
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
__construct(private ilObjectCustomIconFactory $custom_icon_factory, private ObjectTypeSpecificPropertiesFactory $object_type_specific_properties_factory)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
static _lookupType(int $id, bool $reference=false)