Yii2 Bootstrap 3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.0 KiB

12 years ago
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\debug\panels;
use yii\debug\Panel;
12 years ago
use yii\helpers\Html;
12 years ago
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class RequestPanel extends Panel
{
public function getName()
{
return 'Request';
}
public function getSummary()
{
$memory = sprintf('%.2fMB', $this->data['memory'] / 1048576);
$time = sprintf('%.3fs', $this->data['time']);
return <<<EOD
<div class="yii-debug-toolbar-block">
Peak memory: $memory
</div>
<div class="yii-debug-toolbar-block">
Time spent: $time
</div>
EOD;
}
public function getDetail()
{
12 years ago
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']);
12 years ago
}
public function save()
{
return array(
'memory' => memory_get_peak_usage(),
'time' => microtime(true) - YII_BEGIN_TIME,
'SERVER' => $_SERVER,
'GET' => $_GET,
'POST' => $_POST,
'COOKIE' => $_COOKIE,
'FILES' => empty($_FILES) ? array() : $_FILES,
'SESSION' => empty($_SESSION) ? array() : $_SESSION,
);
}
12 years ago
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.';
}
}
12 years ago
}