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