ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjectCommonSettingsFormAdapter.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
16  protected $service;
17 
21  protected $legacy_form;
22 
26  protected $object;
27 
32  {
33  $this->service = $service;
34  $this->legacy_form = $legacy_form;
35  $this->object = $object;
36 
37  $lng = $this->service->language();
38  $lng->loadLanguageModule("obj");
39  $lng->loadLanguageModule("cntr");
40  }
41 
45  public function addIcon() : ilPropertyFormGUI
46  {
47  global $DIC;
48 
49  if ($this->service->settings()->get('custom_icons')) {
50  if (!is_null($this->legacy_form)) {
51  // we do not clone for legacy forms, since initEditCustomForm relies on "call by reference" behaviour
52  //$this->legacy_form = clone $this->legacy_form;
53  require_once 'Services/Object/Icon/classes/class.ilObjectCustomIconConfigurationGUI.php';
54  $gui = new \ilObjectCustomIconConfigurationGUI($DIC, null, $this->object);
55  $gui->addSettingsToForm($this->legacy_form);
56  }
57  }
58  return $this->legacy_form;
59  }
60 
64  public function saveIcon()
65  {
66  global $DIC;
67 
68  if ($this->service->settings()->get('custom_icons')) {
69  if (!is_null($this->legacy_form)) {
70  $this->legacy_form = clone $this->legacy_form;
71  require_once 'Services/Object/Icon/classes/class.ilObjectCustomIconConfigurationGUI.php';
72  $gui = new \ilObjectCustomIconConfigurationGUI($DIC, null, $this->object);
73  $gui->saveIcon($this->legacy_form);
74  }
75  }
76  }
77 
81  public function addTileImage() : ilPropertyFormGUI
82  {
83  $lng = $this->service->language();
84  $tile_image_fac = $this->service->commonSettings()->tileImage();
85 
86  if (!is_null($this->legacy_form)) {
87  // we do not clone for legacy forms, since initEditCustomForm relies on "call by reference" behaviour
88  //$this->legacy_form = clone $this->legacy_form;
89 
90  $tile_image = $tile_image_fac->getByObjId($this->object->getId());
91  $timg = new \ilImageFileInputGUI($lng->txt('obj_tile_image'), 'tile_image');
92  $timg->setInfo($lng->txt('obj_tile_image_info'));
93  $timg->setSuffixes($tile_image_fac->getSupportedFileExtensions());
94  $timg->setUseCache(false);
95  if ($tile_image->exists()) {
96  $timg->setImage($tile_image->getFullPath());
97  } else {
98  $timg->setImage('');
99  }
100  $this->legacy_form->addItem($timg);
101 
102  /*
103  $file = new ilFileStandardDropzoneInputGUI($lng->txt('obj_tile_image'), 'tile_image');
104  $file->setRequired(false);
105  $file->setSuffixes($tile_image_fac->getSupportedFileExtensions());
106  $this->legacy_form->addItem($file);*/
107  }
108 
109  return $this->legacy_form;
110  }
111 
115  public function saveTileImage()
116  {
117  $tile_image_fac = $this->service->commonSettings()->tileImage();
118 
119  if (!is_null($this->legacy_form)) {
120  $tile_image = $tile_image_fac->getByObjId($this->object->getId());
121 
123  $item = $this->legacy_form->getItemByPostVar('tile_image');
124  if ($item->getDeletionFlag()) {
125  $tile_image->delete();
126  }
127 
128  $file_data = $this->legacy_form->getInput('tile_image');
129  if ($file_data['tmp_name']) {
130  $tile_image->saveFromHttpRequest($file_data['tmp_name']);
131  }
132  }
133  }
134 
139  {
140  $lng = $this->service->language();
141  $hide = new ilCheckboxInputGUI($lng->txt("obj_show_title_and_icon"), "show_header_icon_and_title");
142  $hide->setChecked(!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"));
143  $this->legacy_form->addItem($hide);
144  return $this->legacy_form;
145  }
146 
150  public function saveTitleIconVisibility()
151  {
152  if (!is_null($this->legacy_form)) {
153  // hide icon/title
155  $this->object->getId(),
156  "hide_header_icon_and_title",
157  !$this->legacy_form->getInput("show_header_icon_and_title")
158  );
159  }
160  }
161 
166  {
167  $lng = $this->service->language();
168  $hide = new ilCheckboxInputGUI($lng->txt("obj_show_header_actions"), "show_top_actions");
169  $hide->setChecked(!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_top_actions"));
170  $this->legacy_form->addItem($hide);
171  return $this->legacy_form;
172  }
173 
177  public function saveTopActionsVisibility()
178  {
179  if (!is_null($this->legacy_form)) {
180  // hide icon/title
182  $this->object->getId(),
183  "hide_top_actions",
184  !$this->legacy_form->getInput("show_top_actions")
185  );
186  }
187  }
188 }
addTopActionsVisibility()
Add top actions visibility setting to form.null|ilPropertyFormGUI
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
This class represents a checkbox property in a property form.
addIcon()
Add icon setting to form.null|ilPropertyFormGUI
saveTitleIconVisibility()
Save title icon visibility setting from form.
addTitleIconVisibility()
Add title icon visibility setting to form.null|ilPropertyFormGUI
setChecked($a_checked)
Set Checked.
saveTopActionsVisibility()
Save top actions visibility setting from form.
$lng
addTileImage()
Add tile image setting to form.null|ilPropertyFormGUI
__construct(ilObjectService $service, ilObject $object, ilPropertyFormGUI $legacy_form=null)
Constructor.
static _writeContainerSetting($a_id, $a_keyword, $a_value)
saveTileImage()
Save tile image setting from form.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.