ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjBlogAdministrationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
29 {
30  public function __construct(
31  $a_data,
32  int $a_id,
33  bool $a_call_by_reference = true,
34  bool $a_prepare_output = true
35  ) {
36  global $DIC;
37 
38  $this->lng = $DIC->language();
39  $this->settings = $DIC->settings();
40  $this->ctrl = $DIC->ctrl();
41  $this->type = "blga";
42  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
43 
44  $this->lng->loadLanguageModule("blog");
45  }
46 
47  public function executeCommand(): void
48  {
49  $next_class = $this->ctrl->getNextClass($this);
50  $cmd = $this->ctrl->getCmd();
51 
52  $this->prepareOutput();
53 
54  switch ($next_class) {
55  case 'ilpermissiongui':
56  $this->tabs_gui->setTabActive('perm_settings');
57  $perm_gui = new ilPermissionGUI($this);
58  $this->ctrl->forwardCommand($perm_gui);
59  break;
60 
61  default:
62  if (!$cmd || $cmd === 'view') {
63  $cmd = "editSettings";
64  }
65 
66  $this->$cmd();
67  break;
68  }
69  }
70 
71  public function getAdminTabs(): void
72  {
73  if ($this->checkPermissionBool("visible,read")) {
74  $this->tabs_gui->addTarget(
75  "settings",
76  $this->ctrl->getLinkTarget($this, "editSettings"),
77  array("editSettings", "view")
78  );
79  }
80 
81  if ($this->checkPermissionBool('edit_permission')) {
82  $this->tabs_gui->addTarget(
83  "perm_settings",
84  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
85  array(),
86  'ilpermissiongui'
87  );
88  }
89  }
90 
91  public function editSettings(?ilPropertyFormGUI $a_form = null): void
92  {
93  $lng = $this->lng;
95 
96  $this->tabs_gui->setTabActive('settings');
97 
98  if (!$ilSetting->get("disable_wsp_blogs")) {
99  $this->tpl->setOnScreenMessage('info', $lng->txt("blog_admin_toggle_info"));
100  } else {
101  $this->tpl->setOnScreenMessage('info', $lng->txt("blog_admin_inactive_info"));
102  }
103 
104  if (!$a_form) {
105  $a_form = $this->initFormSettings();
106  }
107  $this->tpl->setContent($a_form->getHTML());
108  }
109 
110  public function saveSettings(): void
111  {
112  $ilCtrl = $this->ctrl;
113 
114  $this->checkPermission("write");
115 
116  $form = $this->initFormSettings();
117  if ($form->checkInput()) {
118  $banner = (bool) $form->getInput("banner");
119 
120  $blga_set = new ilSetting("blga");
121  $blga_set->set("banner", (string) $banner);
122  $blga_set->set("banner_width", (string) (int) $form->getInput("width"));
123  $blga_set->set("banner_height", (string) (int) $form->getInput("height"));
124  $blga_set->set("mask", (string) (bool) $form->getInput("mask"));
125  $blga_set->set("est_reading_time", (string) (bool) $form->getInput("est_reading_time"));
126 
127  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
128  $ilCtrl->redirect($this, "editSettings");
129  }
130 
131  $form->setValuesByPost();
132  $this->editSettings($form);
133  }
134 
135  public function cancel(): void
136  {
137  $ilCtrl = $this->ctrl;
138 
139  $ilCtrl->redirect($this, "view");
140  }
141 
142  protected function initFormSettings(): ilPropertyFormGUI
143  {
144  $lng = $this->lng;
145 
146  $form = new ilPropertyFormGUI();
147  $form->setFormAction($this->ctrl->getFormAction($this));
148  $form->setTitle($this->lng->txt('blog_settings'));
149 
150  if ($this->checkPermissionBool("write")) {
151  $form->addCommandButton('saveSettings', $this->lng->txt('save'));
152  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
153  }
154 
155  $banner = new ilCheckboxInputGUI($lng->txt("blog_preview_banner"), "banner");
156  $banner->setInfo($lng->txt("blog_preview_banner_info"));
157  $form->addItem($banner);
158 
159  $width = new ilNumberInputGUI($lng->txt("blog_preview_banner_width"), "width");
160  $width->setRequired(true);
161  $width->setSize(4);
162  $banner->addSubItem($width);
163 
164  $height = new ilNumberInputGUI($lng->txt("blog_preview_banner_height"), "height");
165  $height->setRequired(true);
166  $height->setSize(4);
167  $banner->addSubItem($height);
168 
169  $blga_set = new ilSetting("blga");
170  $banner->setChecked((bool) $blga_set->get("banner", '0'));
171  if ($blga_set->get("banner")) {
172  $width->setValue($blga_set->get("banner_width"));
173  $height->setValue($blga_set->get("banner_height"));
174  } else {
175  $width->setValue("1370");
176  $height->setValue("100");
177  }
178 
179  $cb_prop = new ilCheckboxInputGUI(
180  $lng->txt("blog_est_reading_time"),
181  "est_reading_time"
182  );
183  $cb_prop->setInfo($lng->txt("blog_est_reading_time_info"));
184  $cb_prop->setChecked((bool) $blga_set->get("est_reading_time"));
185  $form->addItem($cb_prop);
186 
187  return $form;
188  }
189 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
prepareOutput(bool $show_sub_objects=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
editSettings(?ilPropertyFormGUI $a_form=null)
global $DIC
Definition: feed.php:28
ilLanguage $lng
__construct(VocabulariesInterface $vocabularies)
Class ilObjectGUI Basic methods of all Output classes.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
global $ilSetting
Definition: privfeed.php:18
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
ilSetting $settings
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)