Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 44 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
OlzAppsList | |
0.00% |
0 / 44 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
getHtml | |
0.00% |
0 / 44 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | |
3 | namespace Olz\Components\Apps\OlzAppsList; |
4 | |
5 | use Olz\Apps\OlzApps; |
6 | use Olz\Components\Common\OlzComponent; |
7 | use Olz\Entity\Users\User; |
8 | |
9 | /** @extends OlzComponent<array<string, mixed>> */ |
10 | class OlzAppsList extends OlzComponent { |
11 | public function getHtml(mixed $args): string { |
12 | $code_href = $this->envUtils()->getCodeHref(); |
13 | $user = $this->authUtils()->getCurrentUser(); |
14 | $available_apps = OlzApps::getAppsForUser($user); |
15 | $out = ''; |
16 | $out .= "<div class='apps-list'>"; |
17 | $out .= implode('', array_map(function ($app) use ($code_href) { |
18 | $icon = $app->getIcon(); |
19 | $display_name = $app->getDisplayName(); |
20 | $href = $app->getHref(); |
21 | $basename = $app->getBasename(); |
22 | return <<<ZZZZZZZZZZ |
23 | <a href='{$code_href}{$href}'> |
24 | <div class='app-container'> |
25 | <img src='{$icon}' alt='{$basename}-icon' class='app-icon' /> |
26 | <div>{$display_name}</div> |
27 | </div> |
28 | </a> |
29 | ZZZZZZZZZZ; |
30 | }, $available_apps)); |
31 | $out .= "</div>"; |
32 | |
33 | if (!$this->authUtils()->hasPermission('any')) { |
34 | $hypothetical_logged_in_user = new User(); |
35 | $hypothetical_logged_in_user->setPermissions(' verified_email '); |
36 | $logged_in_apps = OlzApps::getAppsForUser($hypothetical_logged_in_user); |
37 | foreach ($available_apps as $available_app) { |
38 | $available_apps[$available_app->getPath()] = true; |
39 | } |
40 | $additional_logged_in_apps = []; |
41 | foreach ($logged_in_apps as $logged_in_app) { |
42 | if (!($available_apps[$logged_in_app->getPath()] ?? false)) { |
43 | $additional_logged_in_apps[] = $logged_in_app; |
44 | } |
45 | } |
46 | $out .= "<div class='hypothetical-container'>"; |
47 | $out .= <<<'ZZZZZZZZZZ' |
48 | <div class='hypothetical-overlay'> |
49 | <div>Diese zusätzlichen Apps sind nur für eingeloggte Benutzer verfügbar.</div> |
50 | <div class='auth-buttons'> |
51 | <a class='btn btn-primary' href='#login-dialog' role='button'>Login</a> |
52 | </div> |
53 | </div> |
54 | ZZZZZZZZZZ; |
55 | $out .= "<div class='apps-list hypothetical'>"; |
56 | $out .= implode('', array_map(function ($app) { |
57 | $icon = $app->getIcon(); |
58 | $display_name = $app->getDisplayName(); |
59 | $href = $app->getHref(); |
60 | $basename = $app->getBasename(); |
61 | return <<<ZZZZZZZZZZ |
62 | <div class='app-container'> |
63 | <img src='{$icon}' alt='{$basename}-icon' class='app-icon' /> |
64 | <div>{$display_name}</div> |
65 | </div> |
66 | ZZZZZZZZZZ; |
67 | }, $additional_logged_in_apps)); |
68 | $out .= "</div>"; |
69 | $out .= "</div>"; |
70 | } |
71 | |
72 | $out .= "<div class='openmoji-credits'>Einige Icons mit Emojis von <a href='https://openmoji.org/' target='_blank'>OpenMoji</a> — dem open-source Emoji- und Icon-Projekt. Lizenz: <a href='https://creativecommons.org/licenses/by-sa/4.0/#' target='_blank'>CC BY-SA 4.0</a></div>"; |
73 | |
74 | return $out; |
75 | } |
76 | } |