Commit 1e93fcf2 by Qiang Xue

debug toolbar WIP

parent a622424d
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace yii\debug\panels; namespace yii\debug\panels;
use yii\debug\Panel; use yii\debug\Panel;
use yii\helpers\Html;
/** /**
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
...@@ -38,7 +39,12 @@ EOD; ...@@ -38,7 +39,12 @@ EOD;
public function getDetail() public function getDetail()
{ {
return '<h2>Request</h2>'; return "<h3>\$_GET</h3>\n" . $this->renderTable($this->data['GET']) . "\n"
. "<h3>\$_POST</h3>\n" . $this->renderTable($this->data['POST']) . "\n"
. "<h3>\$_COOKIE</h3>\n" . $this->renderTable($this->data['COOKIE']) . "\n"
. "<h3>\$_FILES</h3>\n" . $this->renderTable($this->data['FILES']) . "\n"
. "<h3>\$_SESSION</h3>\n" . $this->renderTable($this->data['SESSION']) . "\n"
. "<h3>\$_SERVER</h3>\n" . $this->renderTable($this->data['SERVER']);
} }
public function save() public function save()
...@@ -54,4 +60,17 @@ EOD; ...@@ -54,4 +60,17 @@ EOD;
'SESSION' => empty($_SESSION) ? array() : $_SESSION, 'SESSION' => empty($_SESSION) ? array() : $_SESSION,
); );
} }
protected function renderTable($values)
{
$rows = array();
foreach ($values as $name => $value) {
$rows[] = '<tr><th>' . Html::encode($name) . '</th><td>' . Html::encode(var_export($value, true)) . '</td></tr>';
}
if (!empty($rows)) {
return "<table class=\"table table-condensed table-bordered table-hover\">\n<thead>\n<tr><th>Name</th><th>Value</th></tr>\n</thead>\n<tbody>\n" . implode("\n", $rows) . "\n</tbody>\n</table>";
} else {
return 'Empty.';
}
}
} }
...@@ -9,8 +9,21 @@ use yii\helpers\Html; ...@@ -9,8 +9,21 @@ use yii\helpers\Html;
* @var \yii\debug\Panel $activePanel * @var \yii\debug\Panel $activePanel
*/ */
?> ?>
<?php foreach ($panels as $panel): ?> <div class="default-index">
<?php echo Html::a(Html::encode($panel->getName()), array('debug/default/index', 'tag' => $tag, 'panel' => $panel->id)); ?><br> <div class="span3">
<?php endforeach; ?> <div class="well sidebar-nav">
<ul class="nav nav-list">
<?php
foreach ($panels as $panel) {
$link = Html::a(Html::encode($panel->getName()), array('debug/default/index', 'tag' => $tag, 'panel' => $panel->id));
echo Html::tag('li', $link, array('class' => $panel === $activePanel ? 'active' : null));
}
?>
</ul>
</div><!--/.well -->
</div><!--/span-->
<div class="span9">
<?php echo $activePanel->getDetail(); ?>
</div>
</div>
<?php echo $activePanel->getDetail(); ?>
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
* @var string $content * @var string $content
*/ */
use yii\helpers\Html; use yii\helpers\Html;
Yii::$app->getView()->registerAssetBundle('yii/bootstrap/responsive');
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
...@@ -14,7 +16,11 @@ use yii\helpers\Html; ...@@ -14,7 +16,11 @@ use yii\helpers\Html;
</head> </head>
<body> <body>
<?php $this->beginBody(); ?> <?php $this->beginBody(); ?>
<?php echo $content; ?> <div class="container-fluid">
<div class="row-fluid">
<?php echo $content; ?>
</div>
</div>
<?php $this->endBody(); ?> <?php $this->endBody(); ?>
</body> </body>
<?php $this->endPage(); ?> <?php $this->endPage(); ?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment