ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.BlogSettingsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
29{
30 protected int $blog_id;
31 protected \ilLanguage $lng;
33
34 public function __construct(int $blog_id)
35 {
36 global $DIC;
37
38 $this->manager = new ReadingTimeManager();
39 $this->lng = $DIC->language();
40 $this->blog_id = $blog_id;
41 }
42
43 public function addSettingToForm(\ilPropertyFormGUI $form): void
44 {
45 if ($this->manager->isGloballyActivated()) {
46 $cb = new \ilCheckboxInputGUI($this->lng->txt("blog_est_reading_time"), "est_reading_time");
47 $cb->setChecked($this->manager->isActivated($this->blog_id));
48 $form->addItem($cb);
49 }
50 }
51
53 {
54 if ($this->manager->isGloballyActivated()) {
55 $form = $form->checkbox(
56 "est_reading_time",
57 $this->lng->txt("blog_est_reading_time"),
58 "",
59 $this->manager->isActivated($this->blog_id)
60 );
61 }
62 return $form;
63 }
64
65 public function addValueToArray(array $values): array
66 {
67 $values["est_reading_time"] = $this->manager->isActivated($this->blog_id);
68 return $values;
69 }
70
71 public function saveSettingFromForm(\ilPropertyFormGUI $form): void
72 {
73 if ($this->manager->isGloballyActivated()) {
74 $this->manager->activate(
75 $this->blog_id,
76 (bool) $form->getInput("est_reading_time")
77 );
78 }
79 }
80
81 public function saveSettingFromFormAdapter(FormAdapterGUI $form): void
82 {
83 if ($this->manager->isGloballyActivated()) {
84 $this->manager->activate(
85 $this->blog_id,
86 (bool) $form->getData("est_reading_time")
87 );
88 }
89 }
90
91}
checkbox(string $key, string $title, string $description="", ?bool $value=null)
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
global $DIC
Definition: shib_login.php:26