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. 70
      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

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

@ -9,7 +9,6 @@ namespace yii\debug\panels;
use Yii; use Yii;
use yii\debug\Panel; use yii\debug\Panel;
use yii\helpers\Html;
/** /**
* Debugger panel that collects and displays application configuration and environment. * Debugger panel that collects and displays application configuration and environment.
@ -31,79 +30,40 @@ class ConfigPanel extends Panel
public function getSummary() public function getSummary()
{ {
$yiiLogo = $this->getYiiLogo(); return Yii::$app->view->render('panels/config/summary', [
$url = $this->getUrl(); 'panel' => $this,
$phpUrl = Yii::$app->getUrlManager()->createUrl($this->module->id . '/default/phpinfo'); 'data' => $this->data,
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;
} }
public function getDetail() public function getDetail()
{ {
$app = [ return Yii::$app->view->render('panels/config/detail', [
'panel' => $this,
'data' => $this->data,
'app' => [
'Yii Version' => $this->data['application']['yii'], 'Yii Version' => $this->data['application']['yii'],
'Application Name' => $this->data['application']['name'], 'Application Name' => $this->data['application']['name'],
'Environment' => $this->data['application']['env'], 'Environment' => $this->data['application']['env'],
'Debug Mode' => $this->data['application']['debug'] ? 'Yes' : 'No', 'Debug Mode' => $this->data['application']['debug'] ? 'Yes' : 'No',
]; ],
$php = [ 'php' => [
'PHP Version' => $this->data['php']['version'], 'PHP Version' => $this->data['php']['version'],
'Xdebug' => $this->data['php']['xdebug'] ? 'Enabled' : 'Disabled', 'Xdebug' => $this->data['php']['xdebug'] ? 'Enabled' : 'Disabled',
'APC' => $this->data['php']['apc'] ? 'Enabled' : 'Disabled', 'APC' => $this->data['php']['apc'] ? 'Enabled' : 'Disabled',
'Memcache' => $this->data['php']['memcache'] ? 'Enabled' : 'Disabled', 'Memcache' => $this->data['php']['memcache'] ? 'Enabled' : 'Disabled',
]; ],
return "<h1>Configuration</h1>\n" 'extensions' => $this->getExtensions(),
. $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;
} }
protected function renderExtensions() public function getExtensions()
{ {
if (empty($this->data['extensions'])) {
return '';
}
$data = []; $data = [];
foreach ($this->data['extensions'] as $extension) { foreach ($this->data['extensions'] as $extension) {
$data[$extension['name']] = $extension['version']; $data[$extension['name']] = $extension['version'];
} }
return $this->renderData('Installed Extensions', $data) . "\n"; return $data;
} }
public function save() 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