Browse Source

Merge pull request #1732 from Ragazzo/debug_module_config_panel_improvements

Debug module config panel improvements
tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
555ff9dc3b
  1. 86
      extensions/yii/debug/panels/ConfigPanel.php
  2. 24
      extensions/yii/debug/views/default/panels/config/_data_table.php
  3. 14
      extensions/yii/debug/views/default/panels/config/detail.php
  4. 9
      extensions/yii/debug/views/default/panels/config/summary.php

86
extensions/yii/debug/panels/ConfigPanel.php

@ -9,7 +9,6 @@ namespace yii\debug\panels;
use Yii;
use yii\debug\Panel;
use yii\helpers\Html;
/**
* Debugger panel that collects and displays application configuration and environment.
@ -31,79 +30,40 @@ class ConfigPanel extends Panel
public function getSummary()
{
$yiiLogo = $this->getYiiLogo();
$url = $this->getUrl();
$phpUrl = Yii::$app->getUrlManager()->createUrl($this->module->id . '/default/phpinfo');
return <<<EOD
<div class="yii-debug-toolbar-block">
<a href="$url">
<img width="29" height="30" alt="" src="$yiiLogo">
<span>{$this->data['application']['yii']}</span>
</a>
</div>
<div class="yii-debug-toolbar-block">
<a href="$phpUrl" title="Show phpinfo()">PHP {$this->data['php']['version']}</a>
</div>
EOD;
return Yii::$app->view->render('panels/config/summary', [
'panel' => $this,
'data' => $this->data,
]);
}
public function getDetail()
{
$app = [
'Yii Version' => $this->data['application']['yii'],
'Application Name' => $this->data['application']['name'],
'Environment' => $this->data['application']['env'],
'Debug Mode' => $this->data['application']['debug'] ? 'Yes' : 'No',
];
$php = [
'PHP Version' => $this->data['php']['version'],
'Xdebug' => $this->data['php']['xdebug'] ? 'Enabled' : 'Disabled',
'APC' => $this->data['php']['apc'] ? 'Enabled' : 'Disabled',
'Memcache' => $this->data['php']['memcache'] ? 'Enabled' : 'Disabled',
];
return "<h1>Configuration</h1>\n"
. $this->renderData('Application Configuration', $app) . "\n"
. $this->renderExtensions()
. $this->renderData('PHP Configuration', $php) . "\n"
. $this->getPhpInfo();
}
protected function getPhpInfo()
{
return '<div>' . Html::a('Show phpinfo »', ['phpinfo'], ['class' => 'btn btn-primary']) . "</div>\n";
}
protected function renderData($caption, $values)
{
if (empty($values)) {
return "<h3>$caption</h3>\n<p>Empty.</p>";
}
$rows = [];
foreach ($values as $name => $value) {
$rows[] = '<tr><th style="width:200px;">' . Html::encode($name) . '</th><td style="overflow:auto">' . Html::encode($value) . '</td></tr>';
}
$rows = implode("\n", $rows);
return <<<EOD
<h3>$caption</h3>
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead><tr><th style="width: 200px;">Name</th><th>Value</th></tr></thead>
<tbody>
$rows
</tbody>
</table>
EOD;
return Yii::$app->view->render('panels/config/detail', [
'panel' => $this,
'data' => $this->data,
'app' => [
'Yii Version' => $this->data['application']['yii'],
'Application Name' => $this->data['application']['name'],
'Environment' => $this->data['application']['env'],
'Debug Mode' => $this->data['application']['debug'] ? 'Yes' : 'No',
],
'php' => [
'PHP Version' => $this->data['php']['version'],
'Xdebug' => $this->data['php']['xdebug'] ? 'Enabled' : 'Disabled',
'APC' => $this->data['php']['apc'] ? 'Enabled' : 'Disabled',
'Memcache' => $this->data['php']['memcache'] ? 'Enabled' : 'Disabled',
],
'extensions' => $this->getExtensions(),
]);
}
protected function renderExtensions()
public function getExtensions()
{
if (empty($this->data['extensions'])) {
return '';
}
$data = [];
foreach ($this->data['extensions'] as $extension) {
$data[$extension['name']] = $extension['version'];
}
return $this->renderData('Installed Extensions', $data) . "\n";
return $data;
}
public function save()

24
extensions/yii/debug/views/default/panels/config/_data_table.php

@ -0,0 +1,24 @@
<?php
use yii\helpers\Html;
if (empty($values)): ?>
<h3><?php echo $caption; ?></h3>
<p>Empty.</p>
<?php else: ?>
<h3><?php echo $caption; ?></h3>
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead>
<tr>
<th style="width: 200px;">Name</th>
<th>Value</th>
</tr>
</thead>
<?php foreach($values as $name => $value): ?>
<tr>
<th style="width: 200px;"><?php echo Html::encode($name); ?></th>
<td style="overflow:auto"><?php echo Html::encode($value); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>

14
extensions/yii/debug/views/default/panels/config/detail.php

@ -0,0 +1,14 @@
<?php
use yii\helpers\Html;
?>
<h1>Configuration</h1>
<?php
echo $this->context->renderPartial('panels/config/_data_table',[ 'caption' => 'Application Configuration', 'values' => $app]);
if (!empty($extensions)) {
echo $this->context->renderPartial('panels/config/_data_table',[ 'caption' => 'Installed Extensions', 'values' => $extensions]);
}
echo $this->context->renderPartial('panels/config/_data_table',[ 'caption' => 'PHP Configuration', 'values' => $php]);
?>
<div><?php echo Html::a('Show phpinfo »', ['phpinfo'], ['class' => 'btn btn-primary']); ?></div>

9
extensions/yii/debug/views/default/panels/config/summary.php

@ -0,0 +1,9 @@
<div class="yii-debug-toolbar-block">
<a href="<?php echo $panel->getUrl(); ?>">
<img width="29" height="30" alt="" src="<?php echo $panel->getYiiLogo();?>">
<span><?php echo $data['application']['yii'];?></span>
</a>
</div>
<div class="yii-debug-toolbar-block">
<a href="<?php echo $this->context->createUrl('phpinfo');?>" title="Show phpinfo()">PHP <?php echo $data['php']['version'];?></a>
</div>
Loading…
Cancel
Save