ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable Class Reference
+ Inheritance diagram for ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable:
+ Collaboration diagram for ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable:

Public Member Functions

 __construct (private readonly ilCtrlInterface $ctrl, private readonly ilLanguage $lng, \ILIAS\HTTP\Services $http, private readonly \ILIAS\UI\Factory $ui_factory, private readonly \ILIAS\UI\Renderer $ui_renderer, private readonly AuthPageEditorContext $context, private readonly bool $has_write_access)
 
 getComponent ()
 
 getRows (UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, Data\Range $range, Data\Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 
 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...
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 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...
 

Data Fields

const string ACTIVATE = 'activate'
 
const string DEACTIVATE = 'deactivate'
 
const string EDIT = 'edit'
 
const string PREVIEW = 'preview'
 

Protected Member Functions

 getActions ()
 

Private Member Functions

 getColumns ()
 
 initRecords ()
 
 getStatusIcon (bool $status)
 
 sortedRecords (Data\Order $order)
 
 getRecords (Data\Range $range, Data\Order $order)
 
 limitRecords (array $records, Data\Range $range)
 

Private Attributes

ServerRequestInterface $request
 
Data Factory $data_factory
 
array $records = null
 

Detailed Description

Definition at line 33 of file AuthPageLanguagesOverviewTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::__construct ( private readonly ilCtrlInterface  $ctrl,
private readonly ilLanguage  $lng,
\ILIAS\HTTP\Services  $http,
private readonly \ILIAS\UI\Factory  $ui_factory,
private readonly \ILIAS\UI\Renderer  $ui_renderer,
private readonly AuthPageEditorContext  $context,
private readonly bool  $has_write_access 
)

Definition at line 47 of file AuthPageLanguagesOverviewTable.php.

55 {
56 $this->request = $http->request();
57 $this->data_factory = new Data\Factory();
58 }
$http
Definition: deliver.php:30

References $http.

Member Function Documentation

◆ getActions()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::getActions ( )
protected
Returns
array<string, \ILIAS\UI\Component\Table\Action\Action>

Definition at line 97 of file AuthPageLanguagesOverviewTable.php.

97 : array
98 {
99 $query_params_namespace = ['authpage', 'languages'];
100
101 $overview_uri = $this->data_factory->uri(
102 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
103 \ilAuthPageEditorGUI::class,
105 )
106 );
107
108 $overview_url_builder = new UI\URLBuilder($overview_uri);
109 [
110 $overview_url_builder,
111 $overview_action_parameter,
112 $overview_row_id
113 ] = $overview_url_builder->acquireParameters(
114 $query_params_namespace,
115 'action',
116 'key'
117 );
118
119 $actions = [];
120 $actions[self::EDIT] = $this->ui_factory->table()->action()->single(
121 $this->lng->txt($this->has_write_access ? 'edit' : 'preview'),
122 $overview_url_builder->withParameter($overview_action_parameter, $this->has_write_access ? self::EDIT : self::PREVIEW),
123 $overview_row_id
124 );
125
126 if ($this->has_write_access) {
127 $actions[self::ACTIVATE] = $this->ui_factory->table()->action()->standard(
128 $this->lng->txt('page_design_activate'),
129 $overview_url_builder->withParameter($overview_action_parameter, self::ACTIVATE),
130 $overview_row_id
131 );
132
133 $actions[self::DEACTIVATE] = $this->ui_factory->table()->action()->standard(
134 $this->lng->txt('page_design_deactivate'),
135 $overview_url_builder->withParameter($overview_action_parameter, self::DEACTIVATE),
136 $overview_row_id
137 );
138 }
139
140 return $actions;
141 }
final const string LANGUAGE_TABLE_ACTIONS_COMMAND

References ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable\ACTIVATE, ILIAS\Repository\ctrl(), ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable\DEACTIVATE, ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable\EDIT, ilAuthPageEditorGUI\LANGUAGE_TABLE_ACTIONS_COMMAND, and ILIAS\Repository\lng().

Referenced by ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable\getComponent().

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

◆ getColumns()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::getColumns ( )
private
Returns
array<string, \ILIAS\UI\Component\Table\Column\Column>

Definition at line 78 of file AuthPageLanguagesOverviewTable.php.

78 : array
79 {
80 return [
81 'language' => $this->ui_factory
82 ->table()
83 ->column()
84 ->text($this->lng->txt($this->context->pageLanguageIdentifier()))
85 ->withIsSortable(true),
86 'status_icon' => $this->ui_factory
87 ->table()
88 ->column()
89 ->statusIcon($this->lng->txt('active'))
90 ->withIsSortable(true)
91 ];
92 }

References ILIAS\Repository\lng().

Referenced by ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable\getComponent().

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

◆ getComponent()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::getComponent ( )

Definition at line 60 of file AuthPageLanguagesOverviewTable.php.

60 : UI\Component\Table\Data
61 {
62 $columns = $this->getColumns();
63 $actions = $this->getActions();
64
65 return $this->ui_factory
66 ->table()
67 ->data($this, $this->lng->txt($this->context->pageLanguageIdentifier(true)), $columns)
68 ->withId(str_replace('\\', '', self::class) . '_' . $this->context->value)
69 ->withOrder(new \ILIAS\Data\Order('language', \ILIAS\Data\Order::ASC))
70 ->withRange(new Range(0, 100))
71 ->withActions($actions)
72 ->withRequest($this->request);
73 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\Data\Order\ASC, ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable\getActions(), ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable\getColumns(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRecords()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::getRecords ( Data\Range  $range,
Data\Order  $order 
)
private

◆ getRows()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::getRows ( UI\Component\Table\DataRowBuilder  $row_builder,
array  $visible_column_ids,
Data\Range  $range,
Data\Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Definition at line 180 of file AuthPageLanguagesOverviewTable.php.

188 : \Generator {
189 $records = $this->getRecords($range, $order);
190
191 foreach ($records as $record) {
192 $row_id = (string) $record['key'];
193 $deactivate_action = (bool) $record['status'] === true ? self::ACTIVATE : self::DEACTIVATE;
194 yield $row_builder->buildDataRow($row_id, $record)->withDisabledAction($deactivate_action);
195 }
196 }

◆ getStatusIcon()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::getStatusIcon ( bool  $status)
private

Definition at line 165 of file AuthPageLanguagesOverviewTable.php.

166 {
167 if ($status) {
168 return $this->ui_factory->symbol()->icon()->custom(
169 \ilUtil::getImagePath('standard/icon_ok.svg'),
170 $this->lng->txt('active')
171 );
172 }
173
174 return $this->ui_factory->symbol()->icon()->custom(
175 \ilUtil::getImagePath('standard/icon_not_ok.svg'),
176 $this->lng->txt('inactive')
177 );
178 }
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This describes how an icon could be modified during construction of UI.
Definition: Icon.php:29

References ilUtil\getImagePath(), and ILIAS\Repository\lng().

Referenced by ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable\initRecords().

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

◆ getTotalRowCount()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::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 198 of file AuthPageLanguagesOverviewTable.php.

202 : ?int {
203 $this->initRecords();
204
205 return \count($this->records);
206 }

◆ initRecords()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::initRecords ( )
private

Definition at line 143 of file AuthPageLanguagesOverviewTable.php.

143 : void
144 {
145 if ($this->records === null) {
146 $this->records = [];
147 $i = 0;
148 $entries = $this->lng->getInstalledLanguages();
149 foreach ($entries as $langkey) {
150 $this->records[$i]['key'] = $langkey;
151 $this->records[$i]['id'] = ilLanguage::lookupId($langkey);
152 $status = ilAuthPageEditorSettings::getInstance($this->context)->isIliasEditorEnabled(
153 $langkey
154 );
155
156 $this->records[$i]['status'] = $status;
157 $this->records[$i]['status_icon'] = $this->getStatusIcon($status);
158 $this->records[$i]['language'] = $this->lng->txt('meta_l_' . $langkey);
159
160 ++$i;
161 }
162 }
163 }
static getInstance(AuthPageEditorContext $context)
static lookupId(string $a_lang_key)
Lookup obj_id of language.

References ilAuthPageEditorSettings\getInstance(), ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable\getStatusIcon(), ILIAS\Repository\lng(), and ilLanguage\lookupId().

+ Here is the call graph for this function:

◆ limitRecords()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::limitRecords ( array  $records,
Data\Range  $range 
)
private
Parameters
list<array<string,mixed>>$records
Returns
list<array<string, mixed>>

Definition at line 239 of file AuthPageLanguagesOverviewTable.php.

239 : array
240 {
241 return \array_slice($records, $range->getStart(), $range->getLength());
242 }

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

+ Here is the call graph for this function:

◆ sortedRecords()

ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::sortedRecords ( Data\Order  $order)
private
Returns
list<array<string, mixed>>

Definition at line 211 of file AuthPageLanguagesOverviewTable.php.

211 : array
212 {
214 [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
215
216 if ($order_field === 'status_icon') {
217 $order_field = 'status';
218 }
219
220 return ilArrayUtil::stableSortArray($records, $order_field, strtolower($order_direction));
221 }
static stableSortArray(array $array, string $a_array_sortby, string $a_array_sortorder="asc", bool $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...

References ilArrayUtil\stableSortArray().

+ Here is the call graph for this function:

Field Documentation

◆ $data_factory

Data Factory ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::$data_factory
private

Definition at line 41 of file AuthPageLanguagesOverviewTable.php.

◆ $records

array ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::$records = null
private

◆ $request

ServerRequestInterface ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::$request
private

Definition at line 40 of file AuthPageLanguagesOverviewTable.php.

◆ ACTIVATE

const string ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::ACTIVATE = 'activate'

◆ DEACTIVATE

const string ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::DEACTIVATE = 'deactivate'

◆ EDIT

const string ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::EDIT = 'edit'

◆ PREVIEW

const string ILIAS\components\Authentication\Pages\AuthPageLanguagesOverviewTable::PREVIEW = 'preview'

Definition at line 38 of file AuthPageLanguagesOverviewTable.php.


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