19declare(strict_types=1);
53 bool $a_call_by_reference =
true,
54 bool $a_prepare_output =
true
58 $this->
lng = $DIC->language();
59 $this->rbac_system =
$DIC->rbac()->system();
60 $this->
access = $DIC->access();
61 $this->
ctrl = $DIC->ctrl();
64 $this->ui_factory =
$DIC->ui()->factory();
65 $this->ui_renderer =
$DIC->ui()->renderer();
66 $this->request =
$DIC->http()->request();
67 $this->
ui = $DIC->ui();
68 $this->style_gui =
$DIC->contentStyle()->gui();
82 $cmd = $this->
ctrl->getCmd();
86 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
90 switch ($this->
ctrl->getNextClass($this)) {
91 case strtolower(ilPermissionGUI::class):
92 $this->tabs_gui->activateTab(
'perm_settings');
94 $this->
ctrl->forwardCommand($perm_gui);
96 case strtolower(ilDashboardPageLanguageSelectGUI::class):
97 $this->tabs_gui->activateTab(
'dash_customization');
100 case strtolower(ilObjectContentStyleSettingsGUI::class):
101 $this->tabs_gui->clearTargets();
102 $this->
ctrl->setParameterByClass(ilDashboardPageGUI::class,
'dshs_lang', $this->request->getQueryParams()[
'dshs_lang']);
103 $this->tabs_gui->setBackTarget($this->
lng->txt(
'back'), $this->ctrl->getLinkTargetByClass(
104 [ilDashboardPageLanguageSelectGUI::class, ilDashboardPageGUI::class],
107 $gui = $this->style_gui->objectSettingsGUIForRefId(
null, $this->
getRefId());
108 $this->
ctrl->setParameter($gui,
'dshs_lang', $this->request->getQueryParams()[
'dshs_lang']);
109 $this->
ctrl->forwardCommand($gui);
112 $this->tabs_gui->activateTab(
'settings');
113 if (!$cmd || $cmd ===
'view') {
114 $cmd =
'editSettings';
124 if ($this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
125 $this->tabs_gui->addTarget(
127 $this->
ctrl->getLinkTarget($this,
'editSettings'),
128 [
'editSettings',
'view']
130 $this->tabs_gui->addTarget(
131 'dash_customization',
132 $this->
ctrl->getLinkTargetByClass(ilDashboardPageLanguageSelectGUI::class)
136 if ($this->rbac_system->checkAccess(
'edit_permission', $this->object->getRefId())) {
137 $this->tabs_gui->addTarget(
139 $this->
ctrl->getLinkTargetByClass(ilPermissionGUI::class,
'perm'),
141 ilPermissionGUI::class
148 if ($this->
settings->get(
'rep_favourites',
'0') !==
'1') {
149 $content[] = $this->ui_factory->messageBox()->info($this->
lng->txt(
'favourites_disabled_info'));
152 if ($this->
settings->get(
'mmbr_my_crs_grp',
'0') !==
'1') {
153 $content[] = $this->ui_factory->messageBox()->info($this->
lng->txt(
'memberships_disabled_info'));
157 $this->tpl->setContent($table->getHTML());
162 $this->tabs_gui->activateTab(
'settings');
164 $form = $form ?? $this->
getViewForm(self::VIEW_MODE_SORTING);
165 $this->tpl->setContent($this->
ui->renderer()->renderAsync($form));
173 return $this->ui_factory->input()->container()->form()->standard(
174 $this->
ctrl->getFormAction($this,
'save' . $mode),
177 $this->viewSettings->getPresentationViews()
187 $this->tpl->addJavaScript(
"assets/js/SortationUserInputHandler.js");
189 $available = $this->viewSettings->getAvailableSortOptionsByView($view);
190 $options = array_combine($available, $available);
191 $select_options = array_map(fn($s) => $this->
lng->txt(self::DASH_SORT_PREFIX . $s), $options);
192 $available_sorting = array_map($this->
sortingInputs($view), $options);
193 $default_sorting = $this->ui_factory
196 ->select($this->
lng->txt(
'dash_default_sortation'), $select_options)
197 ->withValue($this->viewSettings->getDefaultSortingByView($view))
198 ->withAdditionalOnLoadCode(
199 static fn(
string $id) =>
"
200 document.getElementById('$id').setAttribute('data-select', 'sorting$view');
201 window.addEventListener('DOMContentLoaded', () => il.Dashboard.handleUserInputForSortationsByView($view));
205 return $this->ui_factory->input()->field()->section(
206 $this->
maybeDisable([...$available_sorting,
'default_sorting' => $default_sorting]),
217 $this->
lng->txt(
'dash_' . $this->viewSettings->getViewName($view))
223 $this->
lng->txt(
'dash_' . $this->viewSettings->getViewName($view))
231 $form_data = $this->request->getParsedBody();
232 foreach ($this->viewSettings->getPresentationViews() as $presentation_view) {
233 if (isset($form_data[
'main_panel'][
'enable'][$presentation_view])) {
234 $this->viewSettings->enableView(
236 (
bool) $form_data[
'main_panel'][
'enable'][$presentation_view]
239 $this->viewSettings->enableView($presentation_view,
false);
243 $positions = $form_data[
'main_panel'][
'position'];
245 $this->viewSettings->setViewPositions(array_keys($positions));
247 foreach ($this->side_panel_settings->getValidModules() as $mod) {
248 $this->side_panel_settings->enable($mod, (
bool) ($form_data[
'side_panel'][
'enable'][$mod] ??
false));
251 $positions = $form_data[
'side_panel'][
'position'];
253 $this->side_panel_settings->setPositions(array_keys($positions));
255 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'settings_saved'),
true);
257 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->
lng->txt(
'no_permission'),
true);
268 if ($this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
277 $lng->
txt(
'dash_presentation'),
288 $tabs->activateSubTab($a_active);
293 $this->tabs_gui->activateTab(
'settings');
296 $form = $this->
getViewForm(self::VIEW_MODE_PRESENTATION);
298 $this->tpl->setContent($this->
ui->renderer()->renderAsync($form));
303 $this->
ui->mainTemplate()->setOnScreenMessage(
304 $this->
ui->mainTemplate()::MESSAGE_TYPE_INFO,
305 $this->lng->txt(
'dash_page_edit_info'),
309 $this->tabs_gui->activateTab(
'dash_customization');
311 $content = $this->
ui->renderer()->render(
312 $this->
ui->factory()->button()->standard(
313 $this->lng->txt(
'customize_page'),
314 $this->ctrl->getLinkTargetByClass([self::class, ilDashboardPageLanguageSelectGUI::class],
'select')
324 $this->tpl->setContent($content);
330 $ops = $this->viewSettings->getAvailablePresentationsByView($view);
331 $pres_options = array_column(
333 static fn(
int $k,
string $v): array => [$v,
$lng->
txt(
'dash_' . $v)],
340 $avail_pres = $this->ui_factory->input()->field()->multiSelect(
341 $lng->
txt(
'dash_avail_presentation'),
344 ->withValue($this->viewSettings->getActivePresentationsByView($view));
345 $default_pres = $this->ui_factory->input()->field()->radio(
$lng->
txt(
'dash_default_presentation'))
346 ->withOption(
'list',
$lng->
txt(
'dash_list'))
347 ->withOption(
'tile',
$lng->
txt(
'dash_tile'));
348 $default_pres = $default_pres->withValue($this->viewSettings->getDefaultPresentationByView($view));
349 return $this->ui_factory->input()->field()->section(
350 $this->
maybeDisable([
'avail_pres' => $avail_pres,
'default_pres' => $default_pres]),
358 $data = $this->
getViewForm(self::VIEW_MODE_PRESENTATION)->withRequest($this->request)->getData();
360 foreach (
$data as $view => $view_data) {
361 $this->viewSettings->storeViewPresentation(
363 $view_data[
'default_pres'],
364 $view_data[
'avail_pres'] ?? []
367 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'msg_obj_modified'),
true);
369 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->
lng->txt(
'no_permission'),
true);
378 $form = $this->
getViewForm(self::VIEW_MODE_SORTING)->withRequest($this->request);
379 $data = $form->getData();
381 foreach (
$data as $view => $view_data) {
382 $avail_sorting = array_keys(array_filter($view_data));
383 $saved = array_filter($view_data, fn($x) => !is_bool($x));
384 if (isset($view_data[
'default_sorting'])) {
385 $this->viewSettings->storeViewSorting(
387 $view_data[
'default_sorting'],
390 $this->viewSettings->storeViewSortingOptions($view, $saved);
393 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'msg_obj_modified'),
true);
396 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->
lng->txt(
'no_permission'),
true);
416 return $this->rbac_system->checkAccess(
'write', $this->
object->getRefId());
424 $options = $this->viewSettings->getSortingOptionsByView($view);
425 $sort_options = $this->viewSettings->getAvailableOptionsBySortation($name);
426 $value = isset($saved[$name]) ?
427 [
'new_items' => ($options[$name][
'new_items'] ??
null) ?:
'top'] :
430 return $this->ui_factory->input()->field()->optionalGroup([
431 'new_items' => array_reduce(
433 fn($r, $o) => $r->withOption($o, $this->lng->txt(
'dash_manual_new_item_pos_' . $o)),
434 $this->ui_factory->input()->field()->radio($this->lng->txt(
'dash_manual_new_item_pos'),
'')
436 ], $this->
lng->txt(self::DASH_SORT_PREFIX . $name))
445 return $this->ui_factory->input()->field()
446 ->checkbox($this->
lng->txt(self::DASH_SORT_PREFIX . $name))
447 ->withAdditionalOnLoadCode(fn(
string $id) =>
"
448 document.getElementById('$id').closest('form').addEventListener('submit', e => (
449 e.target.querySelectorAll('input[disabled]').forEach(x => {x.disabled = false;})
457 $saved = array_flip($this->viewSettings->getActiveSortingsByView($view));
458 $with_js = fn($name,
$check) =>
$check->withAdditionalOnLoadCode(fn(
$id) =>
"
459 document.getElementById('$id').setAttribute('data-checkbox', 'activeSorting$view');
460 document.querySelector('#$id input').setAttribute('data-value', '$name')
463 $special_settings = [
'manually'];
464 $method_for = fn($name) => in_array($name, $special_settings,
true) ?
465 $name .
'SortingSettings' :
468 return fn(
string $name) => $with_js($name, $this->{$method_for($name)}($view, $name, $saved));
Provides fluid interface to RBAC services.
Builds a Color from either hex- or rgb values.
Facade for consumer gui interface.
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
@ilCtrl_Calls ilDashboardPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI @ilCtrl_isCalled...
static isLanguageAvailable(string $lang)
@ilCtrl_isCalledBy ilDashboardPageLanguageSelectGUI: ilObjDashboardSettingsGUI
loadLanguageModule(string $a_module)
Load language module.
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...
@ilCtrl_Calls ilObjDashboardSettingsGUI: ilPermissionGUI @ilCtrl_Calls ilObjDashboardSettingsGUI: ilD...
getViewSectionPresentation(int $view, string $title)
ilDashboardSidePanelSettingsRepository $side_panel_settings
setSettingsSubTabs(string $a_active)
editSorting(?StandardForm $form=null)
maybeDisable(array $fields)
manuallySortingSettings(int $view, string $name, array $saved)
ilPDSelectedItemsBlockViewSettings $viewSettings
getAdminTabs()
administration tabs show only permissions and trash folder
const VIEW_MODE_PRESENTATION
sortingCheckbox(int $view, string $name, array $saved)
getViewForm(string $mode)
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
getViewSectionSorting(int $view, string $title)
getViewByMode(string $mode, int $view)
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput(bool $show_sub_objects=true)
This is how the factory for UI elements looks.
An entity that renders components to a string output.
const VIEW_RECOMMENDED_CONTENT
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc