ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilObjAdvancedEditingGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
28 {
30  protected string $cgrp = "";
34 
35  public function __construct(
36  $a_data,
37  int $a_id,
38  bool $a_call_by_reference
39  ) {
41  global $DIC;
42 
43  $this->component_repository = $DIC["component.repository"];
44  $this->current_user = $DIC['ilUser'];
45 
46  $this->type = "adve";
47  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
48  $this->lng->loadLanguageModule('adve');
49  $this->lng->loadLanguageModule('meta');
50  $this->std_request = new StandardGUIRequest(
51  $DIC->http(),
53  );
54  }
55 
56  public function executeCommand(): void
57  {
58  if (!$this->rbac_system->checkAccess('read', $this->object->getRefId())) {
59  $mess = str_replace("%s", $this->object->getTitle(), $this->lng->txt("msg_no_perm_read_item"));
60  $this->ilias->raiseError($mess, $this->ilias->error_obj->WARNING);
61  }
62 
63  $next_class = $this->ctrl->getNextClass($this);
64  $cmd = $this->ctrl->getCmd();
65  $this->prepareOutput();
66 
67  switch ($next_class) {
68  case 'ilpermissiongui':
69  $perm_gui = new ilPermissionGUI($this);
70  $this->ctrl->forwardCommand($perm_gui);
71  break;
72 
73  case strtolower(ilRTESettingsGUI::class):
74  $rte_gui = new ilRTESettingsGUI(
75  $this->ref_id,
76  $this->tpl,
77  $this->ctrl,
78  $this->lng,
79  $this->access,
80  $this->current_user,
81  $this->tabs_gui
82  );
83  $rte_gui->$cmd();
84  break;
85 
86  default:
87  if ($cmd === null || $cmd === "" || $cmd === "view") {
88  $cmd = "showGeneralPageEditorSettings";
89  }
90  $cmd .= "Object";
91  $this->$cmd();
92 
93  break;
94  }
95  }
96 
97  public function saveObject(): void
98  {
99  $this->checkPermission("write");
100 
101  parent::saveObject();
102 
103  // always send a message
104  $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
105  $this->ctrl->redirect($this);
106  }
107 
108  public function getAdminTabs(): void
109  {
110  $this->getTabs();
111  }
112 
113  public function addPageEditorSettingsSubtabs(): void
114  {
115  $this->tabs_gui->addSubTabTarget(
116  "adve_pe_general",
117  $this->ctrl->getLinkTarget($this, "showGeneralPageEditorSettings"),
118  array("showGeneralPageEditorSettings", "", "view")
119  );
120 
122 
123  foreach ($grps as $g => $types) {
124  $this->ctrl->setParameter($this, "grp", $g);
125  $this->tabs_gui->addSubTabTarget(
126  "adve_grp_" . $g,
127  $this->ctrl->getLinkTarget($this, "showPageEditorSettings"),
128  array("showPageEditorSettings")
129  );
130  }
131  $this->ctrl->setParameter($this, "grp", $this->std_request->getGroup());
132  }
133 
134  protected function getTabs(): void
135  {
136  if ($this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
137  $this->tabs_gui->addTarget(
138  "adve_page_editor_settings",
139  $this->ctrl->getLinkTarget($this, "showGeneralPageEditorSettings"),
140  array("showPageEditorSettings", "","view")
141  );
142 
143  $this->tabs_gui->addTarget(
144  "adve_rte_settings",
145  $this->ctrl->getLinkTargetByClass([self::class, ilRTESettingsGUI::class], "settings"),
146  array("settings","assessment", "frmPost"),
147  "",
148  ""
149  );
150  }
151 
152  if ($this->rbac_system->checkAccess('edit_permission', $this->object->getRefId())) {
153  $this->tabs_gui->addTarget(
154  "perm_settings",
155  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
156  array("perm","info","owner"),
157  'ilpermissiongui'
158  );
159  }
160  }
161 
162  public function showPageEditorSettingsObject(): void
163  {
165 
167 
168  $this->cgrp = $this->std_request->getGroup();
169  if ($this->cgrp === "") {
170  $this->cgrp = (string) key($grps);
171  }
172 
173  $this->ctrl->setParameter($this, "grp", $this->cgrp);
174  $this->tabs_gui->setSubTabActive("adve_grp_" . $this->cgrp);
175 
176  $this->initPageEditorForm();
177  $this->tpl->setContent($this->form->getHTML());
178  }
179 
180  public function initPageEditorForm(): void
181  {
182  $this->lng->loadLanguageModule("content");
183 
184  $this->form = new ilPropertyFormGUI();
185 
186  if ($this->cgrp === "test") {
187  $this->form->setTitle($this->lng->txt("adve_activation"));
188  $cb = new ilCheckboxInputGUI($this->lng->txt("advanced_editing_tst_editing"), "tst_page_edit");
189  $cb->setInfo($this->lng->txt("advanced_editing_tst_editing_desc"));
191  $cb->setChecked(true);
192  }
193  $this->form->addItem($cb);
194 
195  $sh = new ilFormSectionHeaderGUI();
196  $sh->setTitle($this->lng->txt("adve_text_content_features"));
197  $this->form->addItem($sh);
198  } elseif ($this->cgrp === "rep") {
199  $this->form->setTitle($this->lng->txt("adve_activation"));
200  $cb = new ilCheckboxInputGUI($this->lng->txt("advanced_editing_rep_page_editing"), "cat_page_edit");
201  $cb->setInfo($this->lng->txt("advanced_editing_rep_page_editing_desc"));
202  if ($this->settings->get("enable_cat_page_edit")) {
203  $cb->setChecked(true);
204  }
205  $this->form->addItem($cb);
206 
207  $sh = new ilFormSectionHeaderGUI();
208  $sh->setTitle($this->lng->txt("adve_text_content_features"));
209  $this->form->addItem($sh);
210  } else {
211  $this->form->setTitle($this->lng->txt("adve_text_content_features"));
212  }
213 
214 
216  foreach ($buttons as $b => $t) {
217  // command button activation
218  $cb = new ilCheckboxInputGUI(str_replace(":", "", $this->lng->txt("cont_text_" . $b)), "active_" . $b);
219  $cb->setChecked((bool) ilPageEditorSettings::lookupSetting($this->cgrp, "active_" . $b, true));
220  $this->form->addItem($cb);
221  }
222 
223  // save and cancel commands
224  if ($this->checkPermissionBool("write")) {
225  $this->form->addCommandButton("savePageEditorSettings", $this->lng->txt("save"));
226  }
227 
228  $this->form->setFormAction($this->ctrl->getFormAction($this));
229  }
230 
231  public function savePageEditorSettingsObject(): void
232  {
233  $lng = $this->lng;
234  $ilCtrl = $this->ctrl;
236 
237  $this->checkPermission("write");
238 
239  $this->initPageEditorForm();
240  if ($this->form->checkInput()) {
242  foreach ($buttons as $b => $t) {
244  $this->std_request->getGroup(),
245  "active_" . $b,
246  $this->form->getInput("active_" . $b)
247  );
248  }
249 
250  if ($this->std_request->getGroup() === "test") {
251  $ilSetting->set("enable_tst_page_edit", (string) $this->form->getInput("tst_page_edit"));
252  } elseif ($this->std_request->getGroup() === "rep") {
253  $ilSetting->set("enable_cat_page_edit", (string) $this->form->getInput("cat_page_edit"));
254  }
255 
256  $this->tpl->setOnScreenMessage('info', $lng->txt("msg_obj_modified"), true);
257  }
258 
259  $ilCtrl->setParameter($this, "grp", $this->std_request->getGroup());
260  $ilCtrl->redirect($this, "showPageEditorSettings");
261  }
262 
263  public function showGeneralPageEditorSettingsObject(): void
264  {
266  $this->tabs_gui->activateTab("adve_page_editor_settings");
267 
268  $form = $this->initGeneralPageSettingsForm();
269  $this->tpl->setContent($form->getHTML());
270  }
271 
273  {
274  $form = new ilPropertyFormGUI();
275 
276  $aset = new ilSetting("adve");
277 
278  // use physical character styles
279  $cb = new ilCheckboxInputGUI($this->lng->txt("adve_use_physical"), "use_physical");
280  $cb->setInfo($this->lng->txt("adve_use_physical_info"));
281  $cb->setChecked((bool) $aset->get("use_physical"));
282  $form->addItem($cb);
283 
284  // blocking mode
285  $cb = new ilCheckboxInputGUI($this->lng->txt("adve_blocking_mode"), "block_mode_act");
286  $cb->setChecked((bool) $aset->get("block_mode_minutes") > 0);
287  $form->addItem($cb);
288 
289  // number of minutes
290  $ni = new ilNumberInputGUI($this->lng->txt("adve_minutes"), "block_mode_minutes");
291  $ni->setMinValue(2);
292  $ni->setMaxLength(5);
293  $ni->setSize(5);
294  $ni->setRequired(true);
295  $ni->setInfo($this->lng->txt("adve_minutes_info"));
296  $ni->setValue($aset->get("block_mode_minutes"));
297  $cb->addSubItem($ni);
298 
299  // autosave
300  $as = new ilNumberInputGUI($this->lng->txt("adve_autosave"), "autosave");
301  $as->setSuffix($this->lng->txt("seconds"));
302  $as->setMaxLength(5);
303  $as->setSize(5);
304  $as->setInfo($this->lng->txt("adve_autosave_info"));
305  $as->setValue($aset->get("autosave"));
306  $form->addItem($as);
307 
308  // auto url linking
309  $cb = new ilCheckboxInputGUI($this->lng->txt("adve_auto_url_linking"), "auto_url_linking");
310  $cb->setChecked((bool) $aset->get("auto_url_linking"));
311  $cb->setInfo($this->lng->txt("adve_auto_url_linking_info"));
312  $form->addItem($cb);
313 
314  if ($this->checkPermissionBool("write")) {
315  $form->addCommandButton("saveGeneralPageSettings", $this->lng->txt("save"));
316  }
317 
318  // workaround for glossaries to force rewriting of short texts
320 
321 
322  $form->setTitle($this->lng->txt("adve_pe_general"));
323  $form->setFormAction($this->ctrl->getFormAction($this));
324 
325  return $form;
326  }
327 
335  protected function getPageObjectKeysWithOptionalHTML(): array
336  {
337  return ["lobj","copa","mep","blp","prtf","prtt","term","lm","qht","qpl","qfbg","qfbs","sahs","stys","cont","cstr","auth"];
338  }
339 
340  public function saveGeneralPageSettingsObject(): void
341  {
342  $this->checkPermission("write");
343 
344  $form = $this->initGeneralPageSettingsForm();
345  if ($form->checkInput()) {
346  $autosave = (int) $form->getInput("autosave");
347  $ok = true;
348 
349  // autosave must be greater 10, if activated
350  if ($autosave > 0 && $autosave < 10) {
351  $form->getItemByPostVar("autosave")->setAlert($this->lng->txt("adve_autosave_info_min_10"));
352  $ok = false;
353  }
354 
355  if ($ok) {
356  $aset = new ilSetting("adve");
357  $aset->set("use_physical", $form->getInput("use_physical"));
358  if ($form->getInput("block_mode_act")) {
359  $aset->set("block_mode_minutes", (string) (int) $form->getInput("block_mode_minutes"));
360  } else {
361  $aset->set("block_mode_minutes", 0);
362  }
363  $aset->set("auto_url_linking", $form->getInput("auto_url_linking"));
364 
365  $aset->set("autosave", $form->getInput("autosave"));
366 
367  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
368  $this->ctrl->redirect($this, "showGeneralPageEditorSettings");
369  }
370  }
371 
372  $form->setValuesByPost();
373  $this->tpl->setContent($form->getHTML());
374  }
375 }
Readable part of repository interface to ilComponentDataDB.
setSuffix(string $a_value)
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...
getItemByPostVar(string $a_post_var)
prepareOutput(bool $show_sub_objects=true)
static getGroups()
Get all settings groups.
getPageObjectKeysWithOptionalHTML()
This limits the possibility to allow html for these page objects that supported the feature in the pa...
Refinery $refinery
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-...
static lookupSetting(string $a_grp, string $a_name, string $a_default='0')
Lookup setting.
static writeSetting(string $a_grp, string $a_name, string $a_value)
Write Setting.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilLanguage $lng
setFormAction(string $a_formaction)
This class represents a number property in a property form.
Class ilObjectGUI Basic methods of all Output classes.
ilComponentRepository $component_repository
global $DIC
Definition: shib_login.php:26
Class ilObjForumAdministration.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
form( $class_path, string $cmd, string $submit_caption="")
const ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_DISABLED
setMinValue(float $a_minvalue, bool $a_display_always=false)
global $ilSetting
Definition: privfeed.php:31
__construct(Container $dic, ilPlugin $plugin)
Class ilObjAdvancedEditingGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilSetting $settings
static setShortTextsDirtyGlobally()
Set short texts dirty (for all glossaries)
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
Class ilObjAdvancedEditingGUI.