ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ConditionTriggerTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28use ILIAS\Data\Factory as DataFactory;
30use Generator;
31use ilLanguage;
32use ilObjUser;
33use ilCtrl;
35
37{
38 public const string ACTION_TOKEN = 'action';
39 public const string ID_TOKEN = 'id';
40 public const string TABLE_NS = 'cond_trigger_table';
41
42 public const string ACTION_TOKEN_NS = self::TABLE_NS . '_' . self::ACTION_TOKEN;
43
44 public const string ID_TOKEN_NS = self::TABLE_NS . '_' . self::ID_TOKEN;
45
46 protected \Psr\Http\Message\ServerRequestInterface $http_request;
47 protected \ILIAS\UI\Renderer $ui_renderer;
48 protected \ILIAS\UI\Factory $ui_factory;
49 protected DataFactory $data_factory;
50
53
54 protected readonly ilLanguage $lng;
55 protected readonly ilObjUser $user;
56 protected readonly ilCtrl $ctrl;
57
58
60 {
61 global $DIC;
62
63 $this->provider = $provider;
64 $this->allow_optional_conditions = $allow_optional_conditions;
65
66 $this->lng = $DIC->language();
67 $this->lng->loadLanguageModule('rbac');
68 $this->user = $DIC->user();
69 $this->ctrl = $DIC->ctrl();
70 $this->ui_factory = $DIC->ui()->factory();
71 $this->data_factory = new DataFactory();
72 $this->ui_renderer = $DIC->ui()->renderer();
73 $this->http_request = $DIC->http()->request();
74 }
75
76
77 public function getRows(
78 DataRowBuilder $row_builder,
79 array $visible_column_ids,
81 Order $order,
82 ?array $filter_data,
83 ?array $additional_parameters
84 ): Generator {
85 $records = $this->provider->limitData($range, $order);
86 foreach ($records as $row) {
87 $id = $row['id'];
88 yield $row_builder->buildDataRow((string) $id, $row);
89 }
90 }
91
92 public function getTotalRowCount(?array $filter_data, ?array $additional_parameters): ?int
93 {
94 return count($this->provider->getData());
95 }
96
97 protected function getColumns(): array
98 {
99 return [
100 'trigger' => $this->ui_factory
101 ->table()
102 ->column()
103 ->link($this->lng->txt('rbac_precondition_source')),
104 'condition' => $this->ui_factory
105 ->table()
106 ->column()
107 ->text($this->lng->txt('rbac_precondition_condition'))
108 ->withIsSortable(true),
109 'obligatory' => $this->ui_factory
110 ->table()
111 ->column()
112 ->statusIcon($this->lng->txt('precondition_obligatory'))
113 ->withIsSortable(false)
114 ];
115 }
116
120 protected function getActions(): array
121 {
122 $uri_command_handler = $this->data_factory->uri(
123 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
124 ilConditionHandlerGUI::class,
125 'handleConditionTriggerTableActions'
126 )
127 );
128 [
129 $url_builder,
130 $action_parameter_token,
131 $row_id_token
132 ] =
133 (new URLBuilder($uri_command_handler))->acquireParameters(
134 [self::TABLE_NS],
135 self::ACTION_TOKEN,
136 self::ID_TOKEN
137 );
138
139 $actions['edit'] = $this->ui_factory->table()->action()->single(
140 $this->lng->txt('edit'),
141 $url_builder->withParameter($action_parameter_token, 'editConditionTrigger'),
142 $row_id_token
143 );
144 if ($this->allow_optional_conditions) {
145 $actions['saveCompulsory'] = $this->ui_factory->table()->action()->multi(
146 $this->lng->txt('rbac_precondition_save_obligatory'),
147 $url_builder->withParameter($action_parameter_token, 'saveCompulsory'),
148 $row_id_token
149 );
150 }
151 $actions['confirmDeleteConditionTrigger'] = $this->ui_factory->table()->action()->standard(
152 $this->lng->txt('delete'),
153 $url_builder->withParameter($action_parameter_token, 'confirmDeleteConditionTrigger'),
154 $row_id_token
155 )->withAsync(true);
156 return $actions;
157 }
158
159
160 public function get(): Data
161 {
162 return $this->ui_factory
163 ->table()
164 ->data(
165 $this,
166 $this->lng->txt('active_preconditions'),
167 $this->getColumns(),
168 )
169 ->withId(self::class)
170 ->withActions($this->getActions())
171 ->withRequest($this->http_request);
172 }
173
174
175 public function render(): string
176 {
177 return $this->ui_renderer->render(
178 [
179 $this->get()
180 ]
181 );
182 }
183
184}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
__construct(ConditionTriggerProvider $provider, bool $allow_optional_conditions)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
Builds data types.
Definition: Factory.php:36
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
class ilConditionHandlerGUI
Class ilCtrl provides processing control methods.
language handling
User class.
buildDataRow(string $id, array $record)
This describes a Data Table.
Definition: Data.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26