ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\User\Settings\ConfigurationGUI Class Reference
+ Inheritance diagram for ILIAS\User\Settings\ConfigurationGUI:
+ Collaboration diagram for ILIAS\User\Settings\ConfigurationGUI:

Public Member Functions

 __construct (private readonly \ILIAS\Language\Language $lng, private readonly \ilCtrl $ctrl, private readonly \ilAccess $access, private readonly \ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly Refinery $refinery, private readonly ServerRequestInterface $request, private readonly RequestWrapper $request_wrapper, private readonly HttpService $http, private readonly Repository $user_settings_repository)
 
 executeCommand ()
 
 showCmd (?RoundTripModal $modal=null)
 
 actionCmd ()
 
 saveCmd ()
 
 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.g. More...
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
 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.g. More...
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Private Member Functions

 buildTable ()
 
 getColumns ()
 
 buildEditModal ()
 
 retrieveIdentifierFromQuery ()
 
 sortRows (Order $order)
 

Private Attributes

readonly URLBuilder $url_builder
 
readonly URLBuilderToken $action_token
 
readonly URLBuilderToken $setting_id_token
 
array $available_settings
 

Detailed Description

Definition at line 43 of file class.ConfigurationGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\User\Settings\ConfigurationGUI::__construct ( private readonly \ILIAS\Language\Language  $lng,
private readonly \ilCtrl  $ctrl,
private readonly \ilAccess  $access,
private readonly \ilGlobalTemplateInterface  $tpl,
private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private readonly Refinery  $refinery,
private readonly ServerRequestInterface  $request,
private readonly RequestWrapper  $request_wrapper,
private readonly HttpService  $http,
private readonly Repository  $user_settings_repository 
)

Definition at line 53 of file class.ConfigurationGUI.php.

65 {
66 $this->available_settings = $this->user_settings_repository->get();
67
68 $url_builder = new URLBuilder(new URI(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(self::class, 'action')));
69 [
74 ['user', 'settings'],
75 'table_action',
76 'setting'
77 );
78 }
acquireParameters(array $namespace, string ... $names)
Definition: URLBuilder.php:138

References ILIAS\User\Settings\ConfigurationGUI\$action_token, ILIAS\User\Settings\ConfigurationGUI\$setting_id_token, ILIAS\User\Settings\ConfigurationGUI\$url_builder, ILIAS\UI\URLBuilder\acquireParameters(), and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

Member Function Documentation

◆ actionCmd()

ILIAS\User\Settings\ConfigurationGUI::actionCmd ( )

Definition at line 102 of file class.ConfigurationGUI.php.

102 : void
103 {
104 $this->http->saveResponse(
105 $this->http->response()->withBody(
107 $this->ui_renderer->renderAsync($this->buildEditModal())
108 )
109 )
110 );
111 $this->http->sendResponse();
112 $this->http->close();
113 }
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
static http()
Fetches the global http state from ILIAS.

References ILIAS\FileDelivery\http(), and ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ buildEditModal()

ILIAS\User\Settings\ConfigurationGUI::buildEditModal ( )
private

Definition at line 200 of file class.ConfigurationGUI.php.

200 : RoundTripModal
201 {
202 $identifier = $this->retrieveIdentifierFromQuery();
203 $this->ctrl->setParameterByClass(self::class, $this->setting_id_token->getName(), $identifier);
204 return $this->ui_factory->modal()->roundtrip(
205 $this->lng->txt('edit_setting'),
206 null,
207 $this->user_settings_repository->getByIdentifier(
208 $identifier
209 )->getForm(
210 $this->lng,
211 $this->ui_factory->input()->field(),
212 $this->refinery
213 ),
214 $this->ctrl->getFormActionByClass(self::class, 'save')
215 );
216 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by ILIAS\User\Settings\ConfigurationGUI\saveCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTable()

ILIAS\User\Settings\ConfigurationGUI::buildTable ( )
private

Definition at line 156 of file class.ConfigurationGUI.php.

156 : DataTable
157 {
158 return $this->ui_factory->table()->data(
159 $this,
160 $this->lng->txt('user_settings'),
161 $this->getColumns()
162 )->withActions([
163 $this->ui_factory->table()->action()->single(
164 $this->lng->txt('edit_setting'),
165 $this->url_builder,
166 $this->setting_id_token
167 )->withAsync(true)
168 ])->withRequest($this->request);
169 }

References ILIAS\Repository\lng().

Referenced by ILIAS\User\Settings\ConfigurationGUI\showCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ILIAS\User\Settings\ConfigurationGUI::executeCommand ( )

Definition at line 80 of file class.ConfigurationGUI.php.

80 : void
81 {
82 $this->redirectOnMissingWrite($this->access, $this->ctrl, $this->tpl, $this->lng);
83 $cmd = $this->ctrl->getCmd() . 'Cmd';
84 $this->$cmd();
85 }

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getColumns()

ILIAS\User\Settings\ConfigurationGUI::getColumns ( )
private

Definition at line 171 of file class.ConfigurationGUI.php.

171 : array
172 {
173 $cf = $this->ui_factory->table()->column();
174 return [
175 'field' => $cf->text($this->lng->txt('user_field'))->withIsSortable(true),
176 'changeable_by_user' => $cf->boolean(
177 $this->lng->txt(
178 PropertyAttributes::ChangeableByUser->value
179 ),
180 $this->ui_factory->symbol()->glyph()->checked(),
181 $this->ui_factory->symbol()->glyph()->unchecked()
182 )->withIsSortable(true),
183 'changeable_in_local_user_administration' => $cf->boolean(
184 $this->lng->txt(
185 PropertyAttributes::ChangeableInLocalUserAdministration->value
186 ),
187 $this->ui_factory->symbol()->glyph()->checked(),
188 $this->ui_factory->symbol()->glyph()->unchecked()
189 )->withIsSortable(true),
190 'export' => $cf->boolean(
191 $this->lng->txt(
192 PropertyAttributes::Export->value
193 ),
194 $this->ui_factory->symbol()->glyph()->checked(),
195 $this->ui_factory->symbol()->glyph()->unchecked()
196 )->withIsSortable(true)
197 ];
198 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRows()

ILIAS\User\Settings\ConfigurationGUI::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.g.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 132 of file class.ConfigurationGUI.php.

139 : \Generator {
140 $this->sortRows($order);
141 foreach ($this->available_settings as $setting) {
142 yield $setting->getTableRow(
143 $row_builder,
144 $this->lng
145 );
146 }
147 }
ilSetting $setting
Definition: class.ilias.php:68

References ILIAS\$setting, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\User\Settings\ConfigurationGUI::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 149 of file class.ConfigurationGUI.php.

152 : ?int {
153 return count($this->available_settings);
154 }

◆ retrieveIdentifierFromQuery()

ILIAS\User\Settings\ConfigurationGUI::retrieveIdentifierFromQuery ( )
private

Definition at line 218 of file class.ConfigurationGUI.php.

218 : string
219 {
220 $identifier = $this->request_wrapper->retrieve(
221 $this->setting_id_token->getName(),
222 $this->refinery->byTrying([
223 $this->refinery->kindlyTo()->string(),
224 $this->refinery->kindlyTo()->listOf(
225 $this->refinery->kindlyTo()->string()
226 )
227 ])
228 );
229
230 if (is_array($identifier)) {
231 return $identifier[0];
232 }
233 return $identifier;
234 }

◆ saveCmd()

ILIAS\User\Settings\ConfigurationGUI::saveCmd ( )

Definition at line 115 of file class.ConfigurationGUI.php.

115 : void
116 {
117 $modal = $this->buildEditModal()->withRequest($this->request);
118 $data = $modal->getData();
119 if ($data === null) {
120 $this->showCmd(
121 $modal->withOnLoad($modal->getShowSignal())
122 );
123 return;
124 }
125
126 $this->user_settings_repository->storeConfiguration($data['setting']);
127 $this->available_settings = $this->user_settings_repository->get();
128 $this->tpl->setOnScreenMessage('success', $this->lng->txt('usr_settings_saved'));
129 $this->showCmd();
130 }

References $data, ILIAS\User\Settings\ConfigurationGUI\buildEditModal(), ILIAS\Repository\lng(), and ILIAS\User\Settings\ConfigurationGUI\showCmd().

+ Here is the call graph for this function:

◆ showCmd()

ILIAS\User\Settings\ConfigurationGUI::showCmd ( ?RoundTripModal  $modal = null)

Definition at line 87 of file class.ConfigurationGUI.php.

87 : void
88 {
89 $content = [
90 $this->buildTable()
91 ];
92
93 if ($modal !== null) {
94 $content[] = $modal;
95 }
96
97 $this->tpl->setContent(
98 $this->ui_renderer->render($content)
99 );
100 }

References ILIAS\User\Settings\ConfigurationGUI\buildTable().

Referenced by ILIAS\User\Settings\ConfigurationGUI\saveCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sortRows()

ILIAS\User\Settings\ConfigurationGUI::sortRows ( Order  $order)
private

Definition at line 236 of file class.ConfigurationGUI.php.

236 : void
237 {
238 $order_array = $order->get();
239 $key = array_key_first($order_array);
240 $factor = array_shift($order_array) === 'ASC' ? 1 : -1;
241 if ($key === 'field') {
242 usort(
243 $this->available_settings,
244 fn(Setting $v1, Setting $v2): int =>
245 $factor * ($v1->getLabel($this->lng) <=> $v2->getLabel($this->lng))
246 );
247 }
248
249 if ($key === 'export') {
250 usort(
251 $this->available_settings,
252 fn(Setting $v1, Setting $v2): int =>
253 $factor * ($v1->export() <=> $v2->export())
254 );
255 }
256
257 if ($key === 'changeable_by_user') {
258 usort(
259 $this->available_settings,
260 fn(Setting $v1, Setting $v2): int =>
261 $factor * ($v1->isChangeableByUser() <=> $v2->isChangeableByUser())
262 );
263 }
264
265 if ($key === 'changeable_in_local_user_administration') {
266 usort(
267 $this->available_settings,
268 fn(Setting $v1, Setting $v2): int =>
269 $factor * ($v1->isChangeableInLocalUserAdministration() <=> $v2->isChangeableInLocalUserAdministration())
270 );
271 }
272 }

References ILIAS\User\Settings\Setting\export(), ILIAS\Data\Order\get(), ILIAS\User\Settings\Setting\getLabel(), ILIAS\User\Settings\Setting\isChangeableByUser(), and ILIAS\User\Settings\Setting\isChangeableInLocalUserAdministration().

+ Here is the call graph for this function:

Field Documentation

◆ $action_token

readonly URLBuilderToken ILIAS\User\Settings\ConfigurationGUI::$action_token
private

◆ $available_settings

array ILIAS\User\Settings\ConfigurationGUI::$available_settings
private

Definition at line 51 of file class.ConfigurationGUI.php.

◆ $setting_id_token

readonly URLBuilderToken ILIAS\User\Settings\ConfigurationGUI::$setting_id_token
private

◆ $url_builder

readonly URLBuilder ILIAS\User\Settings\ConfigurationGUI::$url_builder
private

The documentation for this class was generated from the following file: