Browse Source

debug toolbar WIP

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
1e93fcf252
  1. 21
      framework/yii/debug/panels/RequestPanel.php
  2. 21
      framework/yii/debug/views/default/index.php
  3. 6
      framework/yii/debug/views/layouts/main.php

21
framework/yii/debug/panels/RequestPanel.php

@ -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;
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;
'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.';
}
}
} }

21
framework/yii/debug/views/default/index.php

@ -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(); ?> <?php echo $activePanel->getDetail(); ?>
</div>
</div>

6
framework/yii/debug/views/layouts/main.php

@ -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;
</head> </head>
<body> <body>
<?php $this->beginBody(); ?> <?php $this->beginBody(); ?>
<div class="container-fluid">
<div class="row-fluid">
<?php echo $content; ?> <?php echo $content; ?>
</div>
</div>
<?php $this->endBody(); ?> <?php $this->endBody(); ?>
</body> </body>
<?php $this->endPage(); ?> <?php $this->endPage(); ?>

Loading…
Cancel
Save