Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Design Logout Page #7906

Merged
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
eed538b
Feature: Design Logout Page
Aug 7, 2024
a70a1c0
cs fixer
Aug 7, 2024
939a58a
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
d837e4f
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
0ea9701
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
87573f2
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
da259f6
Update components/ILIAS/Authentication/classes/class.ilObjAuthSetting…
Aug 8, 2024
c1b87a4
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
a85904e
Update components/ILIAS/Authentication/classes/class.ilObjAuthSetting…
Aug 8, 2024
6c94c84
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
afa8ef8
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
cd16f4d
Update components/ILIAS/Authentication/classes/LogoutPage/LogoutPageL…
Aug 8, 2024
4b86cca
Update components/ILIAS/Init/classes/class.ilStartUpGUI.php
Aug 8, 2024
fc2288e
Update components/ILIAS/Init/classes/class.ilStartUpGUI.php
Aug 8, 2024
c3fcd8b
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
b4c84a5
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
5984b37
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
05c4ca5
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
cf3bfd5
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
396139d
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
53c7ad1
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
4726454
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
d5c1bf5
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
d497a79
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
a7b0b3d
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
46fc83d
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
c23a3fe
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
275b705
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
1cef9a7
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
abf5a4b
Code improvement
Aug 8, 2024
2ee1d4c
Code improvement
Aug 8, 2024
b36ba36
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
5993e0d
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
ce706f6
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
f742253
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
d5de4bd
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
0dd3532
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 8, 2024
20ce8a5
Code improvement
Aug 9, 2024
856b70d
Code style
Aug 9, 2024
443a65d
Removed unused properties
Aug 9, 2024
a91b3f0
code style
Aug 9, 2024
1b6738a
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 9, 2024
a6fc036
Update components/ILIAS/Authentication/classes/class.ilAuthLogoutPage…
Aug 12, 2024
75396b7
Added missing strtolower
Aug 12, 2024
dfabd35
Fixed lang vars
Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\Authentication\LogoutPage;

use ILIAS\Data;
use ILIAS\UI;
use ilArrayUtil;
use Psr\Http\Message\ServerRequestInterface;
use ilAuthLoginPageEditorSettings;
use ilLanguage;
use ilCtrl;
use ilAuthLogoutPageEditorSettings;

class LogoutPageLanguagesOverviewTable implements UI\Component\Table\DataRetrieval
{
private ServerRequestInterface $request;
private Data\Factory $data_factory;
/**
* @var list<array<string, mixed>>|null
*/
private ?array $records = null;

public function __construct(
private readonly ilCtrl $ctrl,
private readonly ilLanguage $lng,
\ILIAS\HTTP\Services $http,
private readonly \ILIAS\UI\Factory $ui_factory,
private readonly \ILIAS\UI\Renderer $ui_renderer
) {
$this->request = $http->request();
$this->data_factory = new Data\Factory();
}

public function getComponent(): UI\Component\Table\Data
{
$columns = $this->getColumns();
$actions = $this->getActions();

return $this->ui_factory
->table()
->data($this->lng->txt('logout_pages'), $columns, $this)
->withActions($actions)
->withRequest($this->request);
}

/**
* @return array<string, \ILIAS\UI\Component\Table\Column\Column>
*/
private function getColumns(): array
{
return [
'language' => $this->ui_factory
->table()
->column()
->text($this->lng->txt('logout_page'))
->withIsSortable(false),
'status_icon' => $this->ui_factory
->table()
->column()
->text($this->lng->txt('active'))
->withIsSortable(false)
];
}

/**
* @return array<string, \ILIAS\UI\Component\Table\Action\Action>
*/
protected function getActions(): array
{
$query_params_namespace = ['logoutpage', 'languages'];

$overview_uri = $this->data_factory->uri(
ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
\ilAuthLogoutPageEditorGUI::class,
'handleLogoutPageActions'
)
);

$overview_url_builder = new UI\URLBuilder($overview_uri);
[
$overview_url_builder,
$overview_action_parameter,
$overview_row_id
] = $overview_url_builder->acquireParameters(
$query_params_namespace,
'action',
'key'
);

return [
'edit' => $this->ui_factory->table()->action()->single(
$this->lng->txt('edit'),
$overview_url_builder->withParameter($overview_action_parameter, 'edit'),
$overview_row_id
),
'activate' => $this->ui_factory->table()->action()->standard(
$this->lng->txt('page_design_activate'),
$overview_url_builder->withParameter($overview_action_parameter, 'activate'),
$overview_row_id
),
'deactivate' => $this->ui_factory->table()->action()->standard(
$this->lng->txt('page_design_deactivate'),
$overview_url_builder->withParameter($overview_action_parameter, 'deactivate'),
$overview_row_id
)
];
}

private function initRecords(): void
{
if ($this->records === null) {
$this->records = [];
$i = 0;
$entries = $this->lng->getInstalledLanguages();
foreach ($entries as $langkey) {
$this->records[$i]['key'] = $langkey;
$this->records[$i]['id'] = ilLanguage::lookupId($langkey);
$status = ilAuthLogoutPageEditorSettings::getInstance()->isIliasEditorEnabled(
$langkey
);

$this->records[$i]['status_icon'] = $this->getStatusIcon($status);
$this->records[$i]['status'] = $status;
$this->records[$i]['language'] = $this->lng->txt('meta_l_' . $langkey);

++$i;
}
}
}

private function getStatusIcon(bool $status): string
{
if ($status) {
$icon = $this->ui_renderer->render(
$this->ui_factory->symbol()->icon()->custom(
\ilUtil::getImagePath('standard/icon_ok.svg'),
$this->lng->txt('active')
)
);
} else {
$icon = $this->ui_renderer->render(
$this->ui_factory->symbol()->icon()->custom(
\ilUtil::getImagePath('standard/icon_not_ok.svg'),
$this->lng->txt('inactive')
)
);
}

return $icon;
}

public function getRows(
UI\Component\Table\DataRowBuilder $row_builder,
array $visible_column_ids,
Data\Range $range,
Data\Order $order,
?array $filter_data,
?array $additional_parameters
): \Generator {
$records = $this->getRecords($range, $order);

foreach ($records as $record) {
$row_id = (string) $record['key'];
$deactivate_action = (bool) $record['status'] == true ? 'activate' : 'deactivate';
yield $row_builder->buildDataRow($row_id, $record)->withDisabledAction($deactivate_action);
}
}

public function getTotalRowCount(
?array $filter_data,
?array $additional_parameters
): ?int {
$this->initRecords();

return count($this->records);
}

/**
* @return list<array<string, mixed>>
*/
private function sortedRecords(Data\Order $order): array
{
$records = $this->records;
[$order_field, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);

return ilArrayUtil::stableSortArray($records, $order_field, strtolower($order_direction));
}

/**
* @return list<array<string, mixed>>
*/
private function getRecords(Data\Range $range, Data\Order $order): array
{
$this->initRecords();

$records = $this->sortedRecords($order);

return $this->limitRecords($records, $range);
}

/**
* @param list<array<string, mixed>> $records
* @return list<array<string, mixed>>
*/
private function limitRecords(array $records, Data\Range $range): array
{
return array_slice($records, $range->getStart(), $range->getLength());
}
}
Loading
Loading