ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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 mixed $additional_viewcontrol_data,
83 mixed $filter_data,
84 mixed $additional_parameters
85 ): Generator {
86 $records = $this->provider->limitData($range, $order);
87 foreach ($records as $row) {
88 $id = $row['id'];
89 yield $row_builder->buildDataRow((string) $id, $row);
90 }
91 }
92
93 public function getTotalRowCount(
94 mixed $additional_viewcontrol_data,
95 mixed $filter_data,
96 mixed $additional_parameters
97 ): ?int {
98 return count($this->provider->getData());
99 }
100
101 protected function getColumns(): array
102 {
103 return [
104 'trigger' => $this->ui_factory
105 ->table()
106 ->column()
107 ->link($this->lng->txt('rbac_precondition_source')),
108 'condition' => $this->ui_factory
109 ->table()
110 ->column()
111 ->text($this->lng->txt('rbac_precondition_condition'))
112 ->withIsSortable(true),
113 'obligatory' => $this->ui_factory
114 ->table()
115 ->column()
116 ->statusIcon($this->lng->txt('precondition_obligatory'))
117 ->withIsSortable(false)
118 ];
119 }
120
124 protected function getActions(): array
125 {
126 $uri_command_handler = $this->data_factory->uri(
127 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
128 ilConditionHandlerGUI::class,
129 'handleConditionTriggerTableActions'
130 )
131 );
132 [
133 $url_builder,
134 $action_parameter_token,
135 $row_id_token
136 ] =
137 (new URLBuilder($uri_command_handler))->acquireParameters(
138 [self::TABLE_NS],
139 self::ACTION_TOKEN,
140 self::ID_TOKEN
141 );
142
143 $actions['edit'] = $this->ui_factory->table()->action()->single(
144 $this->lng->txt('edit'),
145 $url_builder->withParameter($action_parameter_token, 'editConditionTrigger'),
146 $row_id_token
147 );
148 if ($this->allow_optional_conditions) {
149 $actions['saveCompulsory'] = $this->ui_factory->table()->action()->multi(
150 $this->lng->txt('rbac_precondition_save_obligatory'),
151 $url_builder->withParameter($action_parameter_token, 'saveCompulsory'),
152 $row_id_token
153 );
154 }
155 $actions['confirmDeleteConditionTrigger'] = $this->ui_factory->table()->action()->standard(
156 $this->lng->txt('delete'),
157 $url_builder->withParameter($action_parameter_token, 'confirmDeleteConditionTrigger'),
158 $row_id_token
159 )->withAsync(true);
160 return $actions;
161 }
162
163
164 public function get(): Data
165 {
166 return $this->ui_factory
167 ->table()
168 ->data(
169 $this,
170 $this->lng->txt('active_preconditions'),
171 $this->getColumns(),
172 )
173 ->withId(self::class)
174 ->withActions($this->getActions())
175 ->withRequest($this->http_request);
176 }
177
178
179 public function render(): string
180 {
181 return $this->ui_renderer->render(
182 [
183 $this->get()
184 ]
185 );
186 }
187
188}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $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, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $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.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildDataRow(string $id, array $record)
This describes a Data Table.
Definition: Data.php:33
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