ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDclSwitcher.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
24 protected \ILIAS\UI\Factory $ui_factory;
25 protected ilLanguage $lng;
26 protected ilCtrl $ctrl;
27
29 {
30 $this->toolbar = $toolbar;
31 $this->ui_factory = $ui_factory;
32 $this->ctrl = $ctrl;
33 $this->lng = $lng;
34 }
35
43 public function addTableSwitcherToToolbar(array $tables, string $target_class, string $target_cmd): void
44 {
45 $links = [];
46
47 $this->ctrl->clearParameterByClass(ilObjDataCollectionGUI::class, "tableview_id");
48 $this->ctrl->clearParameterByClass($target_class, "tableview_id");
49
50 foreach ($tables as $table) {
51 $this->ctrl->setParameterByClass($target_class, "table_id", $table->getId());
52 $links[] = $this->ui_factory->link()->standard($table->getTitle(), $this->ctrl->getLinkTargetByClass($target_class, $target_cmd));
53 }
54 $this->ctrl->clearParameterByClass($target_class, "table_id");
55
56 $this->addSwitcherToToolbar($links, $this->lng->txt('dcl_switch_table'));
57 }
58
67 public function addViewSwitcherToToolbar(array $views, int $table_id, string $target_class, string $target_cmd): void
68 {
69 $links = [];
70 $this->ctrl->setParameterByClass($target_class, "table_id", $table_id);
71 foreach ($views as $view) {
72 $this->ctrl->setParameterByClass($target_class, "tableview_id", $view->getId());
73 $links[] = $this->ui_factory->link()->standard($view->getTitle(), $this->ctrl->getLinkTargetByClass($target_class, $target_cmd));
74 }
75 $this->addSwitcherToToolbar($links, $this->lng->txt('dcl_switch_view'));
76 }
77
83 protected function addSwitcherToToolbar(array $links, string $label): void
84 {
85 if (count($links) > 1) {
86 $this->toolbar->addComponent(
87 $this->ui_factory->dropdown()->standard($links)->withLabel($label)
88 );
89 }
90 }
91}
Class ilCtrl provides processing control methods.
ILIAS UI Factory $ui_factory
addTableSwitcherToToolbar(array $tables, string $target_class, string $target_cmd)
ilToolbarGUI $toolbar
addViewSwitcherToToolbar(array $views, int $table_id, string $target_class, string $target_cmd)
addSwitcherToToolbar(array $links, string $label)
__construct(ilToolbarGUI $toolbar, \ILIAS\UI\Factory $ui_factory, ilCtrl $ctrl, ilLanguage $lng)
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.