ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.SettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
29 {
30  protected \ilSetting $global_settings;
31 
32  public function __construct(
33  protected InternalDataService $data,
34  protected InternalDomainService $domain,
35  protected InternalGUIService $gui,
36  protected int $obj_id
37  ) {
38  }
39 
40  public function executeCommand(): void
41  {
42  $ctrl = $this->gui->ctrl();
43  $next_class = $ctrl->getNextClass($this);
44  $cmd = $ctrl->getCmd("edit");
45 
46  switch ($next_class) {
47  default:
48  if (in_array($cmd, ["edit", "save"])) {
49  $this->$cmd();
50  }
51  }
52  }
53 
54  protected function edit(): void
55  {
56  $mt = $this->gui->ui()->mainTemplate();
57  $form = $this->getEditForm();
58  $mt->setContent($form->render());
59  }
60 
61  protected function getEditForm(): FormAdapterGUI
62  {
63  $settings = $this->domain->mediapoolSettings()->getById($this->obj_id);
64  $lng = $this->domain->lng();
65 
66  $form = $this->gui
67  ->form(self::class, "save")
68  ->section("general", $lng->txt("mep_edit"))
69  ->addStdTitleAndDescription($this->obj_id, "mep")
70  ->section("avail", $lng->txt("rep_activation_availability"))
71  ->addOnline($this->obj_id, "mep")
72  ->section("presentation", $lng->txt("obj_presentation"))
73  ->addStdTile($this->obj_id, "mep")
74  ->number(
75  "default_width",
76  $lng->txt("mep_default_width"),
77  "",
78  $settings->getDefaultWidth(),
79  0
80  )
81  ->number(
82  "default_height",
83  $lng->txt("mep_default_height"),
84  $lng->txt("mep_default_width_height_info"),
85  $settings->getDefaultHeight(),
86  0
87  )
89  $this->obj_id,
90  [
92  ]
93  );
94 
95  return $form;
96  }
97 
98  protected function save(): void
99  {
100  $mt = $this->gui->ui()->mainTemplate();
101  $form = $this->getEditForm();
102  $ctrl = $this->gui->ctrl();
103  $lng = $this->domain->lng();
104 
105  $old_settings = $this->domain->mediapoolSettings()->getById($this->obj_id);
106 
107  if ($form->isValid()) {
108 
109  $form->saveStdTitleAndDescription($this->obj_id, "mep");
110  $form->saveStdTile($this->obj_id, "mep");
111  $form->saveOnline($this->obj_id, "mep");
112  $form->saveAdditionalFeatures(
113  $this->obj_id,
114  [
116  ]
117  );
118 
119 
120  $settings = $this->data->settings(
121  $this->obj_id,
122  (int) $form->getData("default_width"),
123  (int) $form->getData("default_height"),
124  $old_settings->getForTranslation()
125  );
126  $this->domain->mediapoolSettings()->update($settings);
127 
128  $news_set = new \ilSetting("news");
129  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
130 
131  if ($enable_internal_rss) {
133  "news",
134  "public_feed",
135  (string) $form->getData("extra_feed"),
136  0,
137  $this->obj_id
138  );
139 
141  "news",
142  "keep_rss_min",
143  (string) $form->getData("keep_rss_min"),
144  0,
145  $this->obj_id
146  );
147  }
148 
149  $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
150  $ctrl->redirectByClass(self::class, "edit");
151  } else {
152  $mt = $this->gui->ui()->mainTemplate();
153  $mt->setContent($form->render());
154  }
155  }
156 }
addAdditionalFeatures(int $obj_id, array $services)
__construct(protected InternalDataService $data, protected InternalDomainService $domain, protected InternalGUIService $gui, protected int $obj_id)
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
addStdTitleAndDescription(int $obj_id, string $type)
addStdTile(int $obj_id, string $type)
global $lng
Definition: privfeed.php:31
addOnline(int $obj_id, string $type)