diff --git a/extensions/yii/debug/panels/ConfigPanel.php b/extensions/yii/debug/panels/ConfigPanel.php index 59cabf3..b0e6b07 100644 --- a/extensions/yii/debug/panels/ConfigPanel.php +++ b/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,48 @@ class ConfigPanel extends Panel public function getSummary() { - $yiiLogo = $this->getYiiLogo(); - $url = $this->getUrl(); - $phpUrl = Yii::$app->getUrlManager()->createUrl($this->module->id . '/default/phpinfo'); - return << - - - {$this->data['application']['yii']} - - -
- PHP {$this->data['php']['version']} -
-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 "

Configuration

\n" - . $this->renderData('Application Configuration', $app) . "\n" - . $this->renderExtensions() - . $this->renderData('PHP Configuration', $php) . "\n" - . $this->getPhpInfo(); - } - - protected function getPhpInfo() - { - return '
' . Html::a('Show phpinfo »', ['phpinfo'], ['class' => 'btn btn-primary']) . "
\n"; + 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 renderData($caption, $values) + public function renderData($caption, $values) { - if (empty($values)) { - return "

$caption

\n

Empty.

"; - } - $rows = []; - foreach ($values as $name => $value) { - $rows[] = '' . Html::encode($name) . '' . Html::encode($value) . ''; - } - $rows = implode("\n", $rows); - return <<$caption - - - -$rows - -
NameValue
-EOD; + return Yii::$app->view->render('panels/config/_data_table', [ + 'caption' => $caption, + 'values' => $values, + ]); } - 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() diff --git a/extensions/yii/debug/views/default/panels/config/_data_table.php b/extensions/yii/debug/views/default/panels/config/_data_table.php new file mode 100644 index 0000000..5f449de --- /dev/null +++ b/extensions/yii/debug/views/default/panels/config/_data_table.php @@ -0,0 +1,24 @@ + +

+

Empty.

+ +

+ + + + + + + + $value): ?> + + + + + + +
NameValue
+ \ No newline at end of file diff --git a/extensions/yii/debug/views/default/panels/config/detail.php b/extensions/yii/debug/views/default/panels/config/detail.php new file mode 100644 index 0000000..b34e8c7 --- /dev/null +++ b/extensions/yii/debug/views/default/panels/config/detail.php @@ -0,0 +1,14 @@ + +

Configuration

+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]); +?> +
'btn btn-primary']); ?>
\ No newline at end of file diff --git a/extensions/yii/debug/views/default/panels/config/summary.php b/extensions/yii/debug/views/default/panels/config/summary.php new file mode 100644 index 0000000..3688306 --- /dev/null +++ b/extensions/yii/debug/views/default/panels/config/summary.php @@ -0,0 +1,9 @@ + +
+ PHP +
\ No newline at end of file