Skip to content

Commit beca675

Browse files
committed
UserPanel: convert templates to Latte-like syntax
1 parent 3bc104f commit beca675

File tree

7 files changed

+41
-26
lines changed

7 files changed

+41
-26
lines changed

src/Bridges/SecurityTracy/UserPanel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function getTab(): ?string
4141
$status = session_status() === PHP_SESSION_ACTIVE
4242
? $this->user->isLoggedIn()
4343
: '?';
44-
require __DIR__ . '/templates/UserPanel.tab.phtml';
44+
require __DIR__ . '/dist/tab.phtml';
4545
});
4646
}
4747

@@ -57,7 +57,7 @@ public function getPanel(): ?string
5757

5858
return Nette\Utils\Helpers::capture(function () {
5959
$user = $this->user;
60-
require __DIR__ . '/templates/UserPanel.panel.phtml';
60+
require __DIR__ . '/dist/panel.phtml';
6161
});
6262
}
6363
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
declare(strict_types=1);
3+
?>
4+
<h1><?php if ($user->isLoggedIn()): ?>
5+
Logged in<?php else: ?>
6+
Unlogged<?php endif ?>
7+
</h1>
8+
9+
<div class="tracy-inner nette-UserPanel">
10+
<?php if ($user->getIdentity()): ?> <?= Tracy\Dumper::toHtml($user->getIdentity(), [Tracy\Dumper::LIVE => true]) ?>
11+
12+
<?php else: ?> <p>no identity</p>
13+
<?php endif ?></div>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
declare(strict_types=1);
3+
?>
4+
<?php $messages = [true => 'Logged in', false => 'Unlogged', '?' => 'Session is closed'] ?><?php $colors = [true => '#61A519', false => '#ababab', '?' => '#bb0000'] ?><span title="<?= Tracy\Helpers::escapeHtml($messages[$status]) ?>
5+
">
6+
<svg viewBox="0 -50 2048 2048">
7+
<path fill="<?= Tracy\Helpers::escapeHtml($colors[$status]) ?>
8+
" d="m1615 1803.5c-122 17-246 7-369 8-255 1-510 3-765-1-136-2-266-111-273-250-11-192 11-290.5 115-457.5 62-100 192-191 303-147 110 44 201 130 321 149 160 25 317-39 446-130 82-58 200-9 268 51 157 173 186.8 275.49 184 484.49-1.9692 147.11-108.91 271.41-230 293zm-144-1226.5c0 239-208 447-447 447s-447-208-447-447 208-447 447-447c240 1 446 207 447 447z"/>
9+
</svg>
10+
</span>

src/Bridges/SecurityTracy/panel.latte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<h1>{if $user->isLoggedIn()}Logged in{else}Unlogged{/if}</h1>
2+
3+
<div class="tracy-inner nette-UserPanel">
4+
{if $user->getIdentity()}
5+
{Tracy\Dumper::toHtml($user->getIdentity(), [Tracy\Dumper::LIVE => true])}
6+
{else}
7+
<p>no identity</p>
8+
{/if}
9+
</div>

src/Bridges/SecurityTracy/tab.latte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{do $messages = [true => 'Logged in', false => Unlogged, '?' => 'Session is closed']}
2+
{do $colors = [true => '#61A519', false => '#ababab', '?' => '#bb0000']}
3+
<span title="{$messages[$status]}">
4+
<svg viewBox="0 -50 2048 2048">
5+
<path fill="{$colors[$status]}" d="m1615 1803.5c-122 17-246 7-369 8-255 1-510 3-765-1-136-2-266-111-273-250-11-192 11-290.5 115-457.5 62-100 192-191 303-147 110 44 201 130 321 149 160 25 317-39 446-130 82-58 200-9 268 51 157 173 186.8 275.49 184 484.49-1.9692 147.11-108.91 271.41-230 293zm-144-1226.5c0 239-208 447-447 447s-447-208-447-447 208-447 447-447c240 1 446 207 447 447z"/>
6+
</svg>
7+
</span>

src/Bridges/SecurityTracy/templates/UserPanel.panel.phtml

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)