-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionPanel.php
More file actions
99 lines (81 loc) · 2.92 KB
/
SessionPanel.php
File metadata and controls
99 lines (81 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
namespace Webwings\Tracy;
use Tracy;
/**
* Session Nette Debug Panel
* @author Jiří Dorazil <dorazil@webwings.cz>
* @author Pavel Železný <info@pavelzelezny.cz>
*/
class SessionPanel implements Tracy\IBarPanel {
/** @var \Nette\Http\Session $session */
private $session;
/** @var array $hiddenSection */
private $hiddenSections = array();
/**
*
* @param \Nette\Http\Session $session
*/
public function register(\Nette\Http\Session $session)
{
$this->session = $session;
Tracy\Debugger::getBar()->addPanel($this);
Tracy\Debugger::getBlueScreen()->addPanel([__CLASS__, 'renderException']);
}
/**
* Add section name in list of hidden
* @param string $sectionName
* @return void
*/
public function hideSection($sectionName) {
$this->hiddenSections[] = $sectionName;
}
/**
* Return panel ID
* @return string
*/
public function getId() {
return __CLASS__;
}
/**
* Html code for DebugerBar Tab
* @return string
*/
public function getTab() {
return $this->getFileTemplate(__DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'tab.latte');
}
/**
* Html code for DebugerBar Panel
* @return string
*/
public function getPanel() {
$params['session'] = $this->session->isStarted() ? $this->session : FALSE;
$params['sessionMetaStore'] = isset($_SESSION['__NF']['META']) ? $_SESSION['__NF']['META'] : array();
$params['sessionMaxTime'] = ini_get('session.gc_maxlifetime');
$params['hiddenSections'] = $this->hiddenSections;
return $this->getFileTemplate(__DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'panel.latte',$params);
}
/**
* Load template file path with aditional macros and variables
* @param string $templateFilePath
* @return String
* @throws \Nette\FileNotFoundException
*/
private function getFileTemplate($templateFilePath,$params = []) {
if (file_exists($templateFilePath)) {
$latte = new \Latte\Engine;
$latte->onCompile[] = function ($latte){
$set = new \Latte\Macros\MacroSet($latte->getCompiler());
$set->addMacro('src', NULL, NULL, 'echo \'src="\'.\Nette\Templating\Helpers::dataStream(file_get_contents(%node.word)).\'"\'');
$set->addMacro('stylesheet', 'echo \'<style type="text/css">\'.file_get_contents(%node.word).\'</style>\'');
$set->addMacro('dumper', 'echo \Tracy\Dumper::toHtml(%node.word)');
};
$params['basePath'] = realpath(__DIR__);
$template = $latte->renderToString($templateFilePath,$params);
return $template;
} else {
throw new \Nette\FileNotFoundException('Requested template file is not exist.');
}
}
public static function renderException(){
}
}