ILIAS  release_8 Revision v8.24
class.ilObjectCommonSettingFormAdapter.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22{
24 protected ilObject $object;
26
28 {
29 $this->service = $service;
30 $this->legacy_form = $legacy_form;
31 $this->object = $object;
32
33 $lng = $this->service->language();
34 $lng->loadLanguageModule('obj');
35 $lng->loadLanguageModule('cntr');
36 }
37
38 public function addIcon(): ?ilPropertyFormGUI
39 {
40 global $DIC;
41
42 if (!is_null($this->legacy_form) && $this->service->settings()->get('custom_icons')) {
43 // we do not clone for legacy forms, since initEditCustomForm relies on 'call by reference' behaviour
44 //$this->legacy_form = clone $this->legacy_form;
45 $gui = new ilObjectCustomIconConfigurationGUI($DIC, null, $this->object);
46 $gui->addSettingsToForm($this->legacy_form);
47 }
48
49 return $this->legacy_form;
50 }
51
52 public function saveIcon(): void
53 {
54 global $DIC;
55
56 if (!is_null($this->legacy_form) && $this->service->settings()->get('custom_icons')) {
57 $this->legacy_form = clone $this->legacy_form;
58 $gui = new ilObjectCustomIconConfigurationGUI($DIC, null, $this->object);
59 $gui->saveIcon($this->legacy_form);
60 }
61 }
62
63 public function addTileImage(): ?ilPropertyFormGUI
64 {
65 $lng = $this->service->language();
66 $tile_image_fac = $this->service->commonSettings()->tileImage();
67
68 if (!is_null($this->legacy_form)) {
69 // we do not clone for legacy forms, since initEditCustomForm relies on 'call by reference' behaviour
70 //$this->legacy_form = clone $this->legacy_form;
71
72 $tile_image = $tile_image_fac->getByObjId($this->object->getId());
73 $timg = new ilImageFileInputGUI($lng->txt('obj_tile_image'), 'tile_image');
74 $timg->setInfo($lng->txt('obj_tile_image_info'));
75 $timg->setSuffixes($tile_image_fac->getSupportedFileExtensions());
76 $timg->setUseCache(false);
77 if ($tile_image->exists()) {
78 $timg->setImage($tile_image->getFullPath());
79 } else {
80 $timg->setImage('');
81 }
82 $this->legacy_form->addItem($timg);
83 }
84
85 return $this->legacy_form;
86 }
87
88 public function saveTileImage(): void
89 {
90 $tile_image_fac = $this->service->commonSettings()->tileImage();
91
92 if (!is_null($this->legacy_form)) {
93 $tile_image = $tile_image_fac->getByObjId($this->object->getId());
94
96 $item = $this->legacy_form->getItemByPostVar('tile_image');
97 if ($item && $item->getDeletionFlag()) {
98 $tile_image->delete();
99 }
100
101 $file_data = $this->legacy_form->getInput('tile_image');
102 if (isset($file_data['tmp_name']) && $file_data['tmp_name'] &&
103 isset($file_data['size']) && $file_data['size'] > 0) {
104 $tile_image->saveFromHttpRequest($file_data['tmp_name']);
105 }
106 }
107 }
108
110 {
111 $hide = new ilCheckboxInputGUI(
112 $this->service->language()->txt('obj_show_title_and_icon'),
113 'show_header_icon_and_title'
114 );
115 $hide->setValue('1');
116 $hide->setChecked(
117 !((bool) ilContainer::_lookupContainerSetting($this->object->getId(), 'hide_header_icon_and_title'))
118 );
119 $this->legacy_form->addItem($hide);
120
121 return $this->legacy_form;
122 }
123
124 public function saveTitleIconVisibility(): void
125 {
126 if (!is_null($this->legacy_form)) {
127 // hide icon/title
129 $this->object->getId(),
130 'hide_header_icon_and_title',
131 (string) !$this->legacy_form->getInput('show_header_icon_and_title')
132 );
133 }
134 }
135
137 {
138 $hide = new ilCheckboxInputGUI(
139 $this->service->language()->txt('obj_show_header_actions'),
140 'show_top_actions'
141 );
142 $hide->setValue('1');
143 $hide->setChecked(
144 !((bool) ilContainer::_lookupContainerSetting($this->object->getId(), 'hide_top_actions'))
145 );
146 $this->legacy_form->addItem($hide);
147
148 return $this->legacy_form;
149 }
150
151 public function saveTopActionsVisibility(): void
152 {
153 if (!is_null($this->legacy_form)) {
154 // hide icon/title
156 $this->object->getId(),
157 'hide_top_actions',
158 (string) !$this->legacy_form->getInput('show_top_actions')
159 );
160 }
161 }
162}
This class represents a checkbox property in a property form.
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTopActionsVisibility()
Add top actions visibility setting to form.
saveTopActionsVisibility()
Save top actions visibility setting from form.
addTitleIconVisibility()
Add title icon visibility setting to form.
__construct(ilObjectService $service, ilObject $object, ilPropertyFormGUI $legacy_form=null)
saveTitleIconVisibility()
Save title icon visibility setting from form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveTileImage()
Save tile image setting from form.
$lng