ILIAS  release_8 Revision v8.24
class.ilObjectContentStyleSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
25
32{
37 protected int $current_style_id;
38 protected int $ref_id;
39 protected int $obj_id;
41
42 public function __construct(
43 InternalDomainService $domain_service,
44 InternalGUIService $gui_service,
46 int $ref_id,
47 int $obj_id
48 ) {
49 global $DIC;
50 $this->main_tpl = $DIC->ui()->mainTemplate();
51 $this->domain = $domain_service;
52 $this->gui = $gui_service;
53 $this->ref_id = $ref_id;
54 $this->obj_id = ($obj_id > 0)
55 ? $obj_id
57 $this->container_manager = $domain_service->repositoryContainer($ref_id);
58 $this->object_manager = $domain_service->object($ref_id, $this->obj_id);
59 $this->current_style_id = $current_style_id ?? $this->object_manager->getStyleId();
60 }
61
62 public function executeCommand(): void
63 {
64 $ctrl = $this->gui->ctrl();
65
66 $next_class = $ctrl->getNextClass($this);
67 $cmd = $ctrl->getCmd("settings");
68
69 switch ($next_class) {
70
71 case "ilobjstylesheetgui":
72 $this->gui->tabs()->clearTargets();
73 $ctrl->setReturn($this, "settings");
74 $this->forwardToStyleSheet();
75 break;
76
77 default:
78 if (in_array($cmd, [
79 "settings",
80 "editStyle",
81 "updateStyle",
82 "createStyle",
83 "deleteStyle",
84 "saveStyleSettings",
85 "saveIndividualStyleSettings"
86 ])) {
87 $this->$cmd();
88 }
89 }
90 }
91
92 protected function settings(): void
93 {
94 $mt = $this->gui->mainTemplate();
95 $form = $this->initStylePropertiesForm();
96 $mt->setContent(
97 $form->getHTML()
98 );
99 }
100
105 {
106 $ilCtrl = $this->gui->ctrl();
107 $lng = $this->domain->lng();
108 $tabs = $this->gui->tabs();
109 $settings = $this->domain->settings();
110 $mt = $this->gui->mainTemplate();
111
112 $style_id = $this->current_style_id;
113 /*
114 if (ilObject::_lookupType($style_id) == "sty") {
115 $page_gui->setStyleId($style_id);
116 } else {
117 $style_id = 0;
118 }
119
120 $page_gui->setTabHook($this, "addPageTabs");
121 $ilCtrl->getHTML($page_gui);
122 $ilTabs->setTabActive("obj_sty");*/
123
124 $lng->loadLanguageModule("style");
125
126 $form = new ilPropertyFormGUI();
127 if ($this->object_manager->globalFixed()) {
128 $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
129 $st->setValue($this->object_manager->getGlobalFixedTitle() . " (" .
130 $lng->txt("global_fixed") . ")");
131 $form->addItem($st);
132 } else {
133 $st_styles = $this->object_manager->getSelectableStyles();
134
135 $st_styles[0] = $lng->txt("default");
136 ksort($st_styles);
137
138 // individual style
139 if ($this->object_manager->hasEffectiveIndividualStyle($style_id)) {
140 $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
141 $st->setValue(ilObject::_lookupTitle($style_id));
142 $form->addItem($st);
143
144 if ($this->isContainer()) {
145 $cb = new ilCheckboxInputGUI($lng->txt("style_support_reuse"), "support_reuse");
146 $cb->setInfo($lng->txt("style_support_reuse_info"));
147 $cb->setChecked($this->container_manager->getReuse());
148 $form->addItem($cb);
149 $form->addCommandButton(
150 "saveIndividualStyleSettings",
151 $lng->txt("save")
152 );
153 }
154
155 $form->addCommandButton(
156 "editStyle",
157 $lng->txt("style_edit_style")
158 );
159 $form->addCommandButton(
160 "deleteStyle",
161 $lng->txt("style_delete_style")
162 );
163 }
164
165 if ($this->object_manager->canSelectStyle($style_id)) {
166 $style_sel = new ilSelectInputGUI(
167 $lng->txt("style_current_style"),
168 "style_id"
169 );
170 $style_sel->setOptions($st_styles);
171 $style_sel->setValue($style_id);
172 $form->addItem($style_sel);
173 $form->addCommandButton(
174 "saveStyleSettings",
175 $lng->txt("save")
176 );
177 $form->addCommandButton(
178 "createStyle",
179 $lng->txt("sty_create_ind_style")
180 );
181 }
182 }
183 $form->setTitle($lng->txt("obj_sty"));
184 $form->setFormAction($ilCtrl->getFormAction($this));
185
186 return $form;
187 }
188
189 protected function isContainer(): bool
190 {
191 if ($this->ref_id > 0) {
192 $type = ilObject::_lookupType($this->ref_id, true);
193 if ($this->domain->objectDefinition()->isContainer($type)) {
194 return true;
195 }
196 }
197 return false;
198 }
199
200 public function forwardToStyleSheet()
201 {
202 $ctrl = $this->gui->ctrl();
203 $cmd = $ctrl->getCmd();
204
205 $style_gui = new ilObjStyleSheetGUI(
206 "",
207 $this->current_style_id,
208 false
209 );
210 $style_id = $ctrl->forwardCommand($style_gui);
211 if (in_array($cmd, ["save", "copyStyle", "importStyle", "confirmedDelete"])) {
212 $style_id = $style_gui->getObject()->getId();
213 if ($cmd == "confirmedDelete") {
214 $style_id = 0;
215 } else {
216 $this->setOwnerId($style_id);
217 }
218 $this->updateStyleId($style_id);
219 $ctrl->redirect($this, "settings");
220 }
221 }
222
223 protected function updateStyleId(int $style_id): void
224 {
225 $this->object_manager->updateStyleId($style_id);
226 }
227
228 protected function setOwnerId(int $style_id): void
229 {
230 $this->object_manager->setOwnerOfStyle($style_id);
231 }
232
233 public function createStyle(): void
234 {
235 $ctrl = $this->gui->ctrl();
236 $ctrl->redirectByClass("ilobjstylesheetgui", "create");
237 }
238
239 public function editStyle(): void
240 {
241 $ctrl = $this->gui->ctrl();
242 $ctrl->redirectByClass("ilobjstylesheetgui", "edit");
243 }
244
245 public function deleteStyle(): void
246 {
247 $ctrl = $this->gui->ctrl();
248 $ctrl->redirectByClass("ilobjstylesheetgui", "delete");
249 }
250
254 protected function saveStyleSettings(): void
255 {
256 $settings = $this->domain->settings();
257 $lng = $this->domain->lng();
258 $ctrl = $this->gui->ctrl();
259
260 $form = $this->initStylePropertiesForm();
261 $form->checkInput();
262 if ($this->object_manager->canSelectStyle($this->current_style_id)) {
263 $style_id = (int) $form->getInput("style_id");
264 $this->updateStyleId($style_id);
265 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
266 }
267 $ctrl->redirect($this, "settings");
268 }
269
270 protected function saveIndividualStyleSettings(): void
271 {
272 $lng = $this->domain->lng();
273 $ctrl = $this->gui->ctrl();
274
275 $form = $this->initStylePropertiesForm();
276 $form->checkInput();
277 if ($this->isContainer()) {
278 $this->container_manager->saveReuse((bool) $form->getInput("support_reuse"));
279 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
280 }
281 $ctrl->redirect($this, "settings");
282 }
283}
Manages container related content style behaviour.
object(int $ref_id, int $obj_id=0)
Objects without ref id (e.g.
Content style internal ui factory.
Manages repository object related content style behaviour.
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjStyleSheetGUI.
Style settings of a repository object.
__construct(InternalDomainService $domain_service, InternalGUIService $gui_service, ?int $current_style_id, int $ref_id, int $obj_id)
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This class represents a property form user interface.
This class represents a selection list property in a property form.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
$type
$lng