ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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 ConfigurationRepository $user_settings_config_repo)
 
 executeCommand ()
 
 showCmd (?RoundTripModal $modal=null)
 
 actionCmd ()
 
 saveCmd ()
 
 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.g. More...
 
 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 records available. More...
 
 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.g. More...
 
 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 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 42 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 ConfigurationRepository  $user_settings_config_repo 
)

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

64 {
65 $this->available_settings = $this->user_settings_config_repo->get();
66
67 $url_builder = new URLBuilder(new URI(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(self::class, 'action')));
68 [
73 ['user', 'settings'],
74 'table_action',
75 'setting'
76 );
77 }
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 101 of file class.ConfigurationGUI.php.

101 : void
102 {
103 $this->http->saveResponse(
104 $this->http->response()->withBody(
106 $this->ui_renderer->renderAsync($this->buildEditModal())
107 )
108 )
109 );
110 $this->http->sendResponse();
111 $this->http->close();
112 }
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 205 of file class.ConfigurationGUI.php.

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

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 157 of file class.ConfigurationGUI.php.

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

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 79 of file class.ConfigurationGUI.php.

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

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 172 of file class.ConfigurationGUI.php.

172 : array
173 {
174 $cf = $this->ui_factory->table()->column();
175 $icon_checked = $this->ui_factory->symbol()->icon()
176 ->custom('assets/images/standard/icon_checked.svg', '', 'small');
177 $icon_unchecked = $this->ui_factory->symbol()->icon()
178 ->custom('assets/images/standard/icon_unchecked.svg', '', 'small');
179 return [
180 'field' => $cf->text($this->lng->txt('user_field'))->withIsSortable(true),
181 'changeable_by_user' => $cf->boolean(
182 $this->lng->txt(
183 PropertyAttributes::ChangeableByUser->value
184 ),
185 $icon_checked,
186 $icon_unchecked
187 )->withIsSortable(true),
188 'changeable_in_local_user_administration' => $cf->boolean(
189 $this->lng->txt(
190 PropertyAttributes::ChangeableInLocalUserAdministration->value
191 ),
192 $icon_checked,
193 $icon_unchecked
194 )->withIsSortable(true),
195 'export' => $cf->boolean(
196 $this->lng->txt(
197 PropertyAttributes::Export->value
198 ),
199 $icon_checked,
200 $icon_unchecked
201 )->withIsSortable(true)
202 ];
203 }

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,
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.g.

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

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 131 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 ( 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 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.

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

◆ retrieveIdentifierFromQuery()

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

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

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

◆ saveCmd()

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

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

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

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 86 of file class.ConfigurationGUI.php.

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

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 241 of file class.ConfigurationGUI.php.

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

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 50 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: