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. 8
      framework/yii/debug/views/layouts/main.php

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

@ -8,6 +8,7 @@
namespace yii\debug\panels;
use yii\debug\Panel;
use yii\helpers\Html;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
@ -38,7 +39,12 @@ EOD;
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()
@ -54,4 +60,17 @@ EOD;
'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
*/
?>
<?php foreach ($panels as $panel): ?>
<?php echo Html::a(Html::encode($panel->getName()), array('debug/default/index', 'tag' => $tag, 'panel' => $panel->id)); ?><br>
<?php endforeach; ?>
<div class="default-index">
<div class="span3">
<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(); ?>

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

@ -4,6 +4,8 @@
* @var string $content
*/
use yii\helpers\Html;
Yii::$app->getView()->registerAssetBundle('yii/bootstrap/responsive');
?>
<!DOCTYPE html>
<html>
@ -14,7 +16,11 @@ use yii\helpers\Html;
</head>
<body>
<?php $this->beginBody(); ?>
<?php echo $content; ?>
<div class="container-fluid">
<div class="row-fluid">
<?php echo $content; ?>
</div>
</div>
<?php $this->endBody(); ?>
</body>
<?php $this->endPage(); ?>

Loading…
Cancel
Save