ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjBlogAdministrationGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
14{
20 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
21 {
22 global $DIC;
23
24 $this->lng = $DIC->language();
25 $this->settings = $DIC->settings();
26 $this->ctrl = $DIC->ctrl();
27 $this->type = "blga";
28 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
29
30 $this->lng->loadLanguageModule("blog");
31 }
32
39 public function executeCommand()
40 {
41 $next_class = $this->ctrl->getNextClass($this);
42 $cmd = $this->ctrl->getCmd();
43
44 $this->prepareOutput();
45
46 switch ($next_class) {
47 case 'ilpermissiongui':
48 $this->tabs_gui->setTabActive('perm_settings');
49 $perm_gui = new ilPermissionGUI($this);
50 $this->ctrl->forwardCommand($perm_gui);
51 break;
52
53 default:
54 if (!$cmd || $cmd == 'view') {
55 $cmd = "editSettings";
56 }
57
58 $this->$cmd();
59 break;
60 }
61 return true;
62 }
63
70 public function getAdminTabs()
71 {
72 if ($this->checkPermissionBool("visible,read")) {
73 $this->tabs_gui->addTarget(
74 "settings",
75 $this->ctrl->getLinkTarget($this, "editSettings"),
76 array("editSettings", "view")
77 );
78 }
79
80 if ($this->checkPermissionBool('edit_permission')) {
81 $this->tabs_gui->addTarget(
82 "perm_settings",
83 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
84 array(),
85 'ilpermissiongui'
86 );
87 }
88 }
89
90
94 public function editSettings($a_form = null)
95 {
98
99 $this->tabs_gui->setTabActive('settings');
100
101 if (!$ilSetting->get("disable_wsp_blogs")) {
102 ilUtil::sendInfo($lng->txt("blog_admin_toggle_info"));
103 } else {
104 ilUtil::sendInfo($lng->txt("blog_admin_inactive_info"));
105 }
106
107 if (!$a_form) {
108 $a_form = $this->initFormSettings();
109 }
110 $this->tpl->setContent($a_form->getHTML());
111 return true;
112 }
113
117 public function saveSettings()
118 {
119 $ilCtrl = $this->ctrl;
120
121 $this->checkPermission("write");
122
123 $form = $this->initFormSettings();
124 if ($form->checkInput()) {
125 $banner = (bool) $form->getInput("banner");
126
127 $blga_set = new ilSetting("blga");
128 $blga_set->set("banner", $banner);
129 $blga_set->set("banner_width", (int) $form->getInput("width"));
130 $blga_set->set("banner_height", (int) $form->getInput("height"));
131 $blga_set->set("mask", (bool) $form->getInput("mask"));
132
133 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
134 $ilCtrl->redirect($this, "editSettings");
135 }
136
137 $form->setValuesByPost();
138 $this->editSettings($form);
139 }
140
144 public function cancel()
145 {
146 $ilCtrl = $this->ctrl;
147
148 $ilCtrl->redirect($this, "view");
149 }
150
156 protected function initFormSettings()
157 {
159
160 $form = new ilPropertyFormGUI();
161 $form->setFormAction($this->ctrl->getFormAction($this));
162 $form->setTitle($this->lng->txt('blog_settings'));
163
164 if ($this->checkPermissionBool("write")) {
165 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
166 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
167 }
168
169 $banner = new ilCheckboxInputGUI($lng->txt("blog_preview_banner"), "banner");
170 $banner->setInfo($lng->txt("blog_preview_banner_info"));
171 $form->addItem($banner);
172
173 $width = new ilNumberInputGUI($lng->txt("blog_preview_banner_width"), "width");
174 $width->setRequired(true);
175 $width->setSize(4);
176 $banner->addSubItem($width);
177
178 $height = new ilNumberInputGUI($lng->txt("blog_preview_banner_height"), "height");
179 $height->setRequired(true);
180 $height->setSize(4);
181 $banner->addSubItem($height);
182
183 $blga_set = new ilSetting("blga");
184 $banner->setChecked($blga_set->get("banner", false));
185 if ($blga_set->get("banner")) {
186 $width->setValue($blga_set->get("banner_width"));
187 $height->setValue($blga_set->get("banner_height"));
188 } else {
189 $width->setValue(1370);
190 $height->setValue(100);
191 }
192
193 /*
194 $mask = new ilCheckboxInputGUI($lng->txt("blog_allow_html"), "mask");
195 $mask->setInfo($lng->txt("blog_allow_html_info"));
196 $mask->setChecked($blga_set->get("mask", false));
197 $form->addItem($mask);*/
198
200 $ne = new ilNonEditableValueGUI($lng->txt("blog_allow_html"), "", true);
201 $this->ctrl->setParameter($gui, "ref_id", $gui->object->getRefId());
202 $link = $this->ctrl->getLinkTarget($gui);
203 $ne->setValue("<a href='$link'> >> " . $this->lng->txt("settings") . "</a>");
204 $form->addItem($ne);
205
206
207 return $form;
208 }
209}
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
This class represents a non editable value in a property form.
This class represents a number property in a property form.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
editSettings($a_form=null)
Edit settings.
initFormSettings()
Init settings property form.
Class ilObjectGUI Basic methods of all Output classes.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
ILIAS Setting Class.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
settings()
Definition: settings.php:2