19declare(strict_types=1);
51 bool $a_call_by_reference =
true,
52 bool $a_prepare_output =
true
56 $this->
ui = $DIC->ui();
57 $this->style_gui =
$DIC->contentStyle()->gui();
61 $this->
lng->loadLanguageModule(
'dash');
68 $cmd = $this->
ctrl->getCmd();
72 if (!$this->rbac_system->checkAccess(
'read', $this->object->getRefId())) {
76 switch ($this->
ctrl->getNextClass($this)) {
77 case strtolower(ilPermissionGUI::class):
78 $this->tabs_gui->activateTab(
'perm_settings');
80 $this->
ctrl->forwardCommand($perm_gui);
82 case strtolower(ilDashboardPageLanguageSelectGUI::class):
83 $this->tabs_gui->activateTab(
'dash_customization');
86 case strtolower(ilObjectContentStyleSettingsGUI::class):
87 $this->tabs_gui->clearTargets();
88 $this->
ctrl->setParameterByClass(ilDashboardPageGUI::class,
'dshs_lang', $this->request->getQueryParams()[
'dshs_lang']);
89 $this->tabs_gui->setBackTarget($this->
lng->txt(
'back'), $this->ctrl->getLinkTargetByClass(
90 [ilDashboardPageLanguageSelectGUI::class, ilDashboardPageGUI::class],
93 $gui = $this->style_gui->objectSettingsGUIForRefId(
null, $this->
getRefId());
94 $this->
ctrl->setParameter($gui,
'dshs_lang', $this->request->getQueryParams()[
'dshs_lang']);
95 $this->
ctrl->forwardCommand($gui);
98 $this->tabs_gui->activateTab(
'settings');
99 if (!$cmd || $cmd ===
'view') {
100 $cmd =
'editSettings';
110 if ($this->rbac_system->checkAccess(
'read', $this->object->getRefId())) {
111 $this->tabs_gui->addTarget(
113 $this->
ctrl->getLinkTarget($this,
'editSettings'),
114 [
'editSettings',
'view']
116 $this->tabs_gui->addTarget(
117 'dash_customization',
118 $this->
ctrl->getLinkTargetByClass(ilDashboardPageLanguageSelectGUI::class)
122 if ($this->rbac_system->checkAccess(
'edit_permission', $this->object->getRefId())) {
123 $this->tabs_gui->addTarget(
125 $this->
ctrl->getLinkTargetByClass(ilPermissionGUI::class,
'perm'),
127 ilPermissionGUI::class
134 if ($this->
settings->get(
'rep_favourites',
'0') !==
'1') {
135 $content[] = $this->ui_factory->messageBox()->info($this->
lng->txt(
'favourites_disabled_info'));
138 if ($this->
settings->get(
'mmbr_my_crs_grp',
'0') !==
'1') {
139 $content[] = $this->ui_factory->messageBox()->info($this->
lng->txt(
'memberships_disabled_info'));
143 $this->tpl->setContent($table->getHTML());
148 $this->tabs_gui->activateTab(
'settings');
150 $form = $form ?? $this->
getViewForm(self::VIEW_MODE_SORTING);
151 $this->tpl->setContent($this->ui_renderer->renderAsync($form));
159 return $this->ui_factory->input()->container()->form()->standard(
160 $this->
ctrl->getFormAction($this,
'save' . $mode),
163 $this->view_settings->getPresentationViews()
173 $this->tpl->addJavaScript(
"assets/js/SortationUserInputHandler.js");
175 $available = $this->view_settings->getAvailableSortOptionsByView($view);
176 $options = array_combine($available, $available);
177 $select_options = array_map(fn($s) => $this->
lng->txt(self::DASH_SORT_PREFIX . $s),
$options);
179 $default_sorting = $this->ui_factory
182 ->select($this->
lng->txt(
'dash_default_sortation'), $select_options)
183 ->withValue($this->view_settings->getDefaultSortingByView($view))
184 ->withAdditionalOnLoadCode(
185 static fn(
string $id) =>
"
186 document.getElementById('$id').setAttribute('data-select', 'sorting$view');
187 window.addEventListener('DOMContentLoaded', () => il.Dashboard.handleUserInputForSortationsByView($view));
191 return $this->ui_factory->input()->field()->section(
192 $this->
maybeDisable([...$available_sorting,
'default_sorting' => $default_sorting]),
203 $this->
lng->txt(
'dash_' . $this->view_settings->getViewName($view))
209 $this->
lng->txt(
'dash_' . $this->view_settings->getViewName($view))
217 $form_data = $this->request->getParsedBody();
218 foreach ($this->view_settings->getPresentationViews() as $presentation_view) {
219 if (isset($form_data[
'main_panel'][
'enable'][$presentation_view])) {
220 $this->view_settings->enableView(
222 (
bool) $form_data[
'main_panel'][
'enable'][$presentation_view]
225 $this->view_settings->enableView($presentation_view,
false);
229 $positions = $form_data[
'main_panel'][
'position'];
231 $this->view_settings->setViewPositions(array_keys($positions));
233 foreach ($this->side_panel_settings->getValidModules() as $mod) {
234 $this->side_panel_settings->enable($mod, (
bool) ($form_data[
'side_panel'][
'enable'][$mod] ??
false));
237 $positions = $form_data[
'side_panel'][
'position'];
239 $this->side_panel_settings->setPositions(array_keys($positions));
241 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'settings_saved'),
true);
243 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->
lng->txt(
'no_permission'),
true);
245 $this->
ctrl->redirect($this,
'editSettings');
254 if ($this->rbac_system->checkAccess(
'read', $this->object->getRefId())) {
263 $lng->
txt(
'dash_presentation'),
274 $tabs->activateSubTab($a_active);
279 $this->tabs_gui->activateTab(
'settings');
282 $form = $this->
getViewForm(self::VIEW_MODE_PRESENTATION);
284 $this->tpl->setContent($this->ui_renderer->renderAsync($form));
289 $this->
ui->mainTemplate()->setOnScreenMessage(
290 $this->
ui->mainTemplate()::MESSAGE_TYPE_INFO,
291 $this->lng->txt(
'dash_page_edit_info'),
295 $this->tabs_gui->activateTab(
'dash_customization');
297 $content = $this->
ui->renderer()->render(
298 $this->
ui->factory()->button()->standard(
299 $this->lng->txt(
'customize_page'),
300 $this->ctrl->getLinkTargetByClass([self::class, ilDashboardPageLanguageSelectGUI::class],
'select')
310 $this->tpl->setContent($content);
316 $ops = $this->view_settings->getAvailablePresentationsByView($view);
317 $pres_options = array_column(
319 static fn(
int $k,
string $v): array => [$v,
$lng->
txt(
'dash_' . $v)],
326 $avail_pres = $this->ui_factory->input()->field()->multiSelect(
327 $lng->
txt(
'dash_avail_presentation'),
330 ->withValue($this->view_settings->getActivePresentationsByView($view));
331 $default_pres = $this->ui_factory->input()->field()->radio(
$lng->
txt(
'dash_default_presentation'))
332 ->withOption(
'list',
$lng->
txt(
'dash_list'))
333 ->withOption(
'tile',
$lng->
txt(
'dash_tile'));
334 $default_pres = $default_pres->withValue($this->view_settings->getDefaultPresentationByView($view));
335 return $this->ui_factory->input()->field()->section(
336 $this->
maybeDisable([
'avail_pres' => $avail_pres,
'default_pres' => $default_pres]),
344 $data = $this->
getViewForm(self::VIEW_MODE_PRESENTATION)->withRequest($this->request)->getData();
346 foreach (
$data as $view => $view_data) {
347 $this->view_settings->storeViewPresentation(
349 $view_data[
'default_pres'],
350 $view_data[
'avail_pres'] ?? []
353 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'msg_obj_modified'),
true);
355 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->
lng->txt(
'no_permission'),
true);
357 $this->
ctrl->redirect($this,
'editPresentation');
364 $form = $this->
getViewForm(self::VIEW_MODE_SORTING)->withRequest($this->request);
365 $data = $form->getData();
367 foreach (
$data as $view => $view_data) {
368 $avail_sorting = array_keys(array_filter($view_data));
369 $saved = array_filter($view_data, fn($x) => !is_bool($x));
370 if (isset($view_data[
'default_sorting'])) {
371 $this->view_settings->storeViewSorting(
373 $view_data[
'default_sorting'],
376 $this->view_settings->storeViewSortingOptions($view, $saved);
379 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'msg_obj_modified'),
true);
385 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->
lng->txt(
'no_permission'),
true);
387 $this->
ctrl->redirect($this,
'editSorting');
405 return $this->rbac_system->checkAccess(
'write', $this->
object->getRefId());
413 $options = $this->view_settings->getSortingOptionsByView($view);
414 $sort_options = $this->view_settings->getAvailableOptionsBySortation($name);
415 $value = isset($saved[$name]) ?
416 [
'new_items' => (
$options[$name][
'new_items'] ??
null) ?:
'top'] :
419 return $this->ui_factory->input()->field()->optionalGroup([
420 'new_items' => array_reduce(
422 fn($r, $o) => $r->withOption($o, $this->lng->txt(
'dash_manual_new_item_pos_' . $o)),
423 $this->ui_factory->input()->field()->radio($this->lng->txt(
'dash_manual_new_item_pos'),
'')
425 ], $this->
lng->txt(self::DASH_SORT_PREFIX . $name))
434 return $this->ui_factory->input()->field()
435 ->checkbox($this->
lng->txt(self::DASH_SORT_PREFIX . $name))
436 ->withAdditionalOnLoadCode(fn(
string $id) =>
"
437 document.getElementById('$id').closest('form').addEventListener('submit', e => (
438 e.target.querySelectorAll('input[disabled]').forEach(x => {x.disabled = false;})
446 $saved = array_flip($this->view_settings->getActiveSortingsByView($view));
447 $with_js = fn($name,
$check) =>
$check->withAdditionalOnLoadCode(fn(
$id) =>
"
448 document.getElementById('$id').setAttribute('data-checkbox', 'activeSorting$view');
449 document.querySelector('#$id input').setAttribute('data-value', '$name')
452 $special_settings = [
'manually'];
453 $method_for = fn($name) => in_array($name, $special_settings,
true) ?
454 $name .
'SortingSettings' :
457 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
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)
setSettingsSubTabs(string $a_active)
editSorting(?StandardForm $form=null)
maybeDisable(array $fields)
manuallySortingSettings(int $view, string $name, array $saved)
readonly GUIService $style_gui
getAdminTabs()
administration tabs show only permissions and trash folder
const VIEW_MODE_PRESENTATION
sortingCheckbox(int $view, string $name, array $saved)
readonly ilDashboardSidePanelSettingsRepository $side_panel_settings
getViewForm(string $mode)
readonly ilPDSelectedItemsBlockViewSettings $view_settings
__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)
An entity that renders components to a string output.
const VIEW_RECOMMENDED_CONTENT
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc