-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,35 @@ class Bar extends Nette\Object | |
/** @var array */ | ||
private $panels = array(); | ||
|
||
private $handle; | ||
|
||
|
||
|
||
public function init() | ||
{ | ||
if (isset($_GET['_nette_debug']) && preg_match('#^\w+$#', $_GET['_nette_debug'])) { | ||
$file = $this->getFileName($_GET['_nette_debug']); | ||
header('Content-Type: text/javascript'); | ||
$html = @file_get_contents($file); | ||
if ($html) { | ||
echo 'Nette.Debug.newContent(' . json_encode(Nette\Utils\Strings::fixEncoding($html)) . ');'; | ||
unlink($file); | ||
} | ||
exit; | ||
} | ||
$id = uniqid(); | ||
$this->handle = fopen($this->getFileName($id), 'w'); | ||
flock($this->handle, LOCK_EX); | ||
setCookie('ajax', $id, 0, '/'); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
|
||
|
||
|
||
public function getFileName($id) | ||
{ | ||
return Debugger::$logDirectory . "/data.$id.dat"; | ||
This comment has been minimized.
Sorry, something went wrong.
Majkl578
Contributor
|
||
} | ||
|
||
|
||
|
||
/** | ||
|
@@ -65,6 +94,9 @@ public function getPanel($id) | |
*/ | ||
public function render() | ||
{ | ||
if (!$this->handle) { | ||
return; | ||
} | ||
$obLevel = ob_get_level(); | ||
$panels = array(); | ||
foreach ($this->panels as $id => $panel) { | ||
|
@@ -105,8 +137,14 @@ public function render() | |
} | ||
} | ||
$session = NULL; | ||
ob_start(); | ||
require __DIR__ . '/templates/bar.content.phtml'; | ||
fwrite($this->handle, ob_get_clean()); | ||
fclose($this->handle); | ||
|
||
require __DIR__ . '/templates/bar.phtml'; | ||
if (preg_match('#^Content-Type: text/html#im', implode("\n", headers_list())) && !isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { | ||
require __DIR__ . '/templates/bar.phtml'; | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* Debug Bar screen template. | ||
* | ||
* It uses Silk Icons created by Mark James and released under Creative Commons Attribution 2.5 License. | ||
* | ||
* This file is part of the Nette Framework (http://nette.org) | ||
* Copyright (c) 2004 David Grudl (http://davidgrudl.com) | ||
* | ||
* @param array $panels | ||
* @return void | ||
*/ | ||
|
||
namespace Nette\Diagnostics; | ||
|
||
use Nette; | ||
|
||
foreach ($panels as $id => $panel): if (!$panel['panel']) continue; ?> | ||
<div class="nette-panel" id="nette-debug-panel-<?php echo $panel['id'] ?>"> | ||
<?php echo $panel['panel'] ?> | ||
<div class="nette-icons"> | ||
<a href="#" title="open in window">¤</a> | ||
<a href="#" rel="close" title="close window">×</a> | ||
</div> | ||
</div> | ||
<?php endforeach ?> | ||
|
||
<div id="nette-debug-bar"> | ||
<ul> | ||
<li id="nette-debug-logo" title="PHP <?php echo htmlSpecialChars(PHP_VERSION . " |\n" | ||
. (isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] . " |\n" : '') | ||
. (class_exists('Nette\Framework') ? 'Nette Framework ' . Nette\Framework::VERSION . ' (' . substr(Nette\Framework::REVISION, 8) . ')' : '')) ?>"> <span>Nette Framework</span></li> | ||
<?php foreach ($panels as $panel): if (!$panel['tab']) continue; ?> | ||
<?php if (!empty($panel['previous'])) echo '</ul><ul class="nette-previous">'; ?> | ||
<li><?php if ($panel['panel']): ?><a href="#" rel="<?php echo $panel['id'] ?>"><?php echo trim($panel['tab']) ?></a><?php else: echo '<span>', trim($panel['tab']), '</span>'; endif ?></li> | ||
<?php endforeach ?> | ||
<li><a href="#" rel="close" title="close debug bar">×</a></li> | ||
</ul> | ||
</div> |
3 comments
on commit 1ba4499
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's a status of this? Will it make it to 2.1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dg are there any problems in this we can help with? Is there any chance this will make it's way to master?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'd also like to see this in master asap.
This cookie name is too generic. Also the path is wrong, imagine multiple instances (e.g. localhost/*).