1 <?php declare(strict_types=1);
41 public function __construct($a_data, $a_id, $a_call_by_reference =
true, $a_prepare_output =
true)
47 $this->lng->loadLanguageModule($this->type);
49 $this->uiFactory = $DIC->ui()->factory();
50 $this->uiRenderer = $DIC->ui()->renderer();
51 $this->httpRequest = $DIC->http()->request();
52 $this->refinery = $DIC->refinery();
53 $this->error = $DIC[
'ilErr'];
54 $this->settingsStorage =
new StorageImpl($DIC->settings());
62 if ($this->rbacsystem->checkAccess(
'visible,read', $this->object->getRefId())) {
63 $this->tabs_gui->addTarget(
'settings', $this->ctrl->getLinkTargetByClass(self::class, self::CMD_EDIT));
66 if ($this->rbacsystem->checkAccess(
'edit_permission', $this->object->getRefId())) {
67 $this->tabs_gui->addTarget(
'perm_settings', $this->ctrl->getLinkTargetByClass(
'ilpermissiongui',
'perm'), [],
'ilpermissiongui');
76 if (!$this->rbacsystem->checkAccess(
'visible,read', $this->object->getRefId())) {
77 $this->error->raiseError($this->lng->txt(
'no_permission'), $this->error->WARNING);
80 $nextClass = $this->ctrl->getNextClass($this);
81 $cmd = $this->ctrl->getCmd();
84 switch (strtolower($nextClass)) {
85 case 'ilpermissiongui':
86 $this->tabs_gui->setTabActive(
'perm_settings');
88 $this->ctrl->forwardCommand($perm_gui);
101 throw new Exception(__METHOD__ .
" :: Unknown command " . $cmd);
112 $action = $this->ctrl->getLinkTargetByClass(self::class, self::CMD_SAVE);
114 $readingTimeStatus = $this->uiFactory
118 $this->lng->txt(
'cpad_reading_time_status'),
119 $this->lng->txt(
'cpad_reading_time_status_desc')
122 if (isset($values[self::F_READING_TIME])) {
123 $readingTimeStatus = $readingTimeStatus->withValue($values[self::F_READING_TIME]);
126 $section = $this->uiFactory->input()->field()->section(
127 [self::F_READING_TIME => $readingTimeStatus],
128 $this->lng->txt(
'settings')
131 return $this->uiFactory
136 ->withAdditionalTransformation($this->refinery->custom()->transformation(
static function ($values) : array {
137 return call_user_func_array(
'array_merge', $values);
144 protected function show(array $components) : void
146 $this->tpl->setContent(
147 $this->uiRenderer->render($components)
151 protected function edit() : void
154 self::F_READING_TIME => $this->settingsStorage->getSettings()->isReadingTimeEnabled(),
157 $form = $this->
getForm($values);
159 $this->
show([$form]);
162 protected function save() : void
165 $this->error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
168 $form = $this->
getForm()->withRequest($this->httpRequest);
170 $data = $form->getData();
172 $readingTime =
$data[self::F_READING_TIME];
173 $settings = $this->settingsStorage->getSettings()
174 ->withDisabledReadingTime();
178 $this->settingsStorage->store(
$settings);
182 [$this->uiFactory->messageBox()->success($this->lng->txt(
'saved_successfully')), $form]
getForm(array $values=[])
prepareOutput($a_show_subobjects=true)
prepare output
Class ilObjectGUI Basic methods of all Output classes.
Class ilObjContentPageAdministrationGUI.
__construct(Container $dic, ilPlugin $plugin)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.