Skip to content

Commit b955184

Browse files
committed
SessionPanel: convert templates to Latte-like syntax
1 parent d267af0 commit b955184

File tree

7 files changed

+82
-51
lines changed

7 files changed

+82
-51
lines changed

src/Bridges/HttpTracy/SessionPanel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SessionPanel implements Tracy\IBarPanel
2424
public function getTab(): string
2525
{
2626
return Nette\Utils\Helpers::capture(function () {
27-
require __DIR__ . '/templates/SessionPanel.tab.phtml';
27+
require __DIR__ . '/dist/tab.phtml';
2828
});
2929
}
3030

@@ -35,7 +35,7 @@ public function getTab(): string
3535
public function getPanel(): string
3636
{
3737
return Nette\Utils\Helpers::capture(function () {
38-
require __DIR__ . '/templates/SessionPanel.panel.phtml';
38+
require __DIR__ . '/dist/panel.phtml';
3939
});
4040
}
4141
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
declare(strict_types=1);
3+
?>
4+
<style class="tracy-debug">
5+
#tracy-debug .nette-SessionPanel-parameters pre {
6+
background: #FDF5CE;
7+
padding: .4em .7em;
8+
border: 1px dotted silver;
9+
overflow: auto;
10+
}
11+
</style>
12+
13+
<h1>Session #<?= Tracy\Helpers::escapeHtml(substr(session_id(), 0, 10)) ?>… (Lifetime: <?= Tracy\Helpers::escapeHtml(ini_get('session.cookie_lifetime')) ?>)</h1>
14+
15+
<div class="tracy-inner nette-SessionPanel">
16+
<?php if (empty($_SESSION)): ?>
17+
<p><i>empty</i></p>
18+
<?php else: ?>
19+
<table class="tracy-sortable">
20+
<?php foreach ($_SESSION as $k => $v): ?>
21+
<?php if ($k === '__NF'): ?>
22+
<tr>
23+
<th>Nette Session</th>
24+
<td><?= Tracy\Dumper::toHtml($v['DATA'] ?? null, [Tracy\Dumper::LIVE => true]) ?></td>
25+
</tr>
26+
<?php elseif ($k !== '_tracy'): ?>
27+
<tr>
28+
<th><?= Tracy\Helpers::escapeHtml($k) ?></th>
29+
<td><?= Tracy\Dumper::toHtml($v, [Tracy\Dumper::LIVE => true]) ?></td>
30+
</tr>
31+
<?php endif ?>
32+
<?php endforeach ?>
33+
</table>
34+
<?php endif ?>
35+
</div>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
declare(strict_types=1);
3+
?>
4+
<span title="Session #<?= Tracy\Helpers::escapeHtml(session_id()) ?>">
5+
<svg viewBox="0 0 2048 2048">
6+
<path fill="#52362c" d="m1691 1396-67 394h-133s2-446 0-586v-4c0-109 89-197 200-197 110 0 200 88 200 197s-89 197-200 197zm-1131-192c-2 141 0 586 0 586h-133l-67-394h-1c-110 0-199-88-199-197s89-197 200-197c110 0 200 88 200 197v4zm865 61v394h-399-403v-394c262-27 529-27 802 0zm0-66c-273-27-541-27-802 0-2-163-119-258-266-262-176-545 233-693 669-693 440 0 841 149 665 693-148 4-265 99-266 263z"/>
7+
</svg>
8+
</span>

src/Bridges/HttpTracy/panel.latte

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<style class="tracy-debug">
2+
#tracy-debug .nette-SessionPanel-parameters pre {
3+
background: #FDF5CE;
4+
padding: .4em .7em;
5+
border: 1px dotted silver;
6+
overflow: auto;
7+
}
8+
</style>
9+
10+
<h1>Session #{substr(session_id(), 0, 10)}… (Lifetime: {ini_get('session.cookie_lifetime')})</h1>
11+
12+
<div class="tracy-inner nette-SessionPanel">
13+
{if empty($_SESSION)}
14+
<p><i>empty</i></p>
15+
{else}
16+
<table class="tracy-sortable">
17+
{foreach $_SESSION as $k => $v}
18+
{if $k === __NF}
19+
<tr>
20+
<th>Nette Session</th>
21+
<td>{Tracy\Dumper::toHtml($v[DATA] ?? null, [Tracy\Dumper::LIVE => true])}</td>
22+
</tr>
23+
{elseif $k !== '_tracy'}
24+
<tr>
25+
<th>{$k}</th>
26+
<td>{Tracy\Dumper::toHtml($v, [Tracy\Dumper::LIVE => true])}</td>
27+
</tr>
28+
{/if}
29+
{/foreach}
30+
</table>
31+
{/if}
32+
</div>

src/Bridges/HttpTracy/tab.latte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<span title="Session #{session_id()}">
2+
<svg viewBox="0 0 2048 2048">
3+
<path fill="#52362c" d="m1691 1396-67 394h-133s2-446 0-586v-4c0-109 89-197 200-197 110 0 200 88 200 197s-89 197-200 197zm-1131-192c-2 141 0 586 0 586h-133l-67-394h-1c-110 0-199-88-199-197s89-197 200-197c110 0 200 88 200 197v4zm865 61v394h-399-403v-394c262-27 529-27 802 0zm0-66c-273-27-541-27-802 0-2-163-119-258-266-262-176-545 233-693 669-693 440 0 841 149 665 693-148 4-265 99-266 263z"/>
4+
</svg>
5+
</span>

src/Bridges/HttpTracy/templates/SessionPanel.panel.phtml

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

src/Bridges/HttpTracy/templates/SessionPanel.tab.phtml

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

0 commit comments

Comments
 (0)