From 508d43bf63b7195bcdcd86c566eff42efe0e3e15 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 1 Jan 2014 23:17:39 +0400 Subject: [PATCH 1/2] debug module config panel improved --- extensions/yii/debug/panels/ConfigPanel.php | 88 +++++++--------------- .../views/default/panels/config/_data_table.php | 24 ++++++ .../debug/views/default/panels/config/detail.php | 14 ++++ .../debug/views/default/panels/config/summary.php | 9 +++ 4 files changed, 75 insertions(+), 60 deletions(-) create mode 100644 extensions/yii/debug/views/default/panels/config/_data_table.php create mode 100644 extensions/yii/debug/views/default/panels/config/detail.php create mode 100644 extensions/yii/debug/views/default/panels/config/summary.php 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']} - - - -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 From 05c230e2536e06726645f35cdcbd86a4ceb1231d Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 1 Jan 2014 23:19:34 +0400 Subject: [PATCH 2/2] removed unnecessary method --- extensions/yii/debug/panels/ConfigPanel.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/extensions/yii/debug/panels/ConfigPanel.php b/extensions/yii/debug/panels/ConfigPanel.php index b0e6b07..316e8d1 100644 --- a/extensions/yii/debug/panels/ConfigPanel.php +++ b/extensions/yii/debug/panels/ConfigPanel.php @@ -57,14 +57,6 @@ class ConfigPanel extends Panel ]); } - public function renderData($caption, $values) - { - return Yii::$app->view->render('panels/config/_data_table', [ - 'caption' => $caption, - 'values' => $values, - ]); - } - public function getExtensions() { $data = [];