From babee51dfe5639ad34d2248c1231f0acef26f791 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Wed, 1 Jan 2014 21:45:47 -0500 Subject: [PATCH] refactored debug module --- extensions/yii/debug/panels/ConfigPanel.php | 23 ++------------ extensions/yii/debug/panels/RequestPanel.php | 14 ++------- .../views/default/panels/config/_data_table.php | 24 --------------- .../debug/views/default/panels/config/detail.php | 36 ++++++++++++++++++---- .../debug/views/default/panels/config/summary.php | 18 ++++++++--- .../debug/views/default/panels/config/table.php | 35 +++++++++++++++++++++ .../yii/debug/views/default/panels/db/summary.php | 6 ++-- .../yii/debug/views/default/panels/log/summary.php | 8 ++--- .../debug/views/default/panels/profile/detail.php | 2 +- .../debug/views/default/panels/profile/summary.php | 6 ++-- .../views/default/panels/request/_data_table.php | 24 --------------- .../debug/views/default/panels/request/detail.php | 26 +++++++++------- .../debug/views/default/panels/request/summary.php | 12 +++++--- .../debug/views/default/panels/request/table.php | 34 ++++++++++++++++++++ 14 files changed, 150 insertions(+), 118 deletions(-) delete mode 100644 extensions/yii/debug/views/default/panels/config/_data_table.php create mode 100644 extensions/yii/debug/views/default/panels/config/table.php delete mode 100644 extensions/yii/debug/views/default/panels/request/_data_table.php create mode 100644 extensions/yii/debug/views/default/panels/request/table.php diff --git a/extensions/yii/debug/panels/ConfigPanel.php b/extensions/yii/debug/panels/ConfigPanel.php index 316e8d1..8e1b9ed 100644 --- a/extensions/yii/debug/panels/ConfigPanel.php +++ b/extensions/yii/debug/panels/ConfigPanel.php @@ -30,31 +30,12 @@ class ConfigPanel extends Panel public function getSummary() { - return Yii::$app->view->render('panels/config/summary', [ - 'panel' => $this, - 'data' => $this->data, - ]); + return Yii::$app->view->render('panels/config/summary', ['panel' => $this]); } public function getDetail() { - 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(), - ]); + return Yii::$app->view->render('panels/config/detail', ['panel' => $this]); } public function getExtensions() diff --git a/extensions/yii/debug/panels/RequestPanel.php b/extensions/yii/debug/panels/RequestPanel.php index 1548c4c..90f51fe 100644 --- a/extensions/yii/debug/panels/RequestPanel.php +++ b/extensions/yii/debug/panels/RequestPanel.php @@ -26,22 +26,12 @@ class RequestPanel extends Panel public function getSummary() { - return Yii::$app->view->render('panels/request/summary', [ - 'panel' => $this, - 'data' => $this->data, - ]); + return Yii::$app->view->render('panels/request/summary', ['panel' => $this]); } public function getDetail() { - return Yii::$app->view->render('panels/request/detail', [ - 'panel' => $this, - 'data' => [ - 'Route' => $this->data['route'], - 'Action' => $this->data['action'], - 'Parameters' => $this->data['actionParams'], - ], - ]); + return Yii::$app->view->render('panels/request/detail', ['panel' => $this]); } 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 deleted file mode 100644 index 5f449de..0000000 --- a/extensions/yii/debug/views/default/panels/config/_data_table.php +++ /dev/null @@ -1,24 +0,0 @@ - -

-

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 index b34e8c7..e8bdf73 100644 --- a/extensions/yii/debug/views/default/panels/config/detail.php +++ b/extensions/yii/debug/views/default/panels/config/detail.php @@ -1,14 +1,38 @@ -getExtensions(); ?>

Configuration

context->renderPartial('panels/config/_data_table',[ 'caption' => 'Application Configuration', 'values' => $app]); +echo $this->render('panels/config/table', [ + 'caption' => 'Application Configuration', + 'values' => [ + 'Yii Version' => $panel->data['application']['yii'], + 'Application Name' => $panel->data['application']['name'], + 'Environment' => $panel->data['application']['env'], + 'Debug Mode' => $panel->data['application']['debug'] ? 'Yes' : 'No', + ], +]); if (!empty($extensions)) { - echo $this->context->renderPartial('panels/config/_data_table',[ 'caption' => 'Installed Extensions', 'values' => $extensions]); + echo $this->render('panels/config/table', [ + 'caption' => 'Installed Extensions', + 'values' => $extensions, + ]); } -echo $this->context->renderPartial('panels/config/_data_table',[ 'caption' => 'PHP Configuration', 'values' => $php]); +echo $this->render('panels/config/table', [ + 'caption' => 'PHP Configuration', + 'values' => [ + 'PHP Version' => $panel->data['php']['version'], + 'Xdebug' => $panel->data['php']['xdebug'] ? 'Enabled' : 'Disabled', + 'APC' => $panel->data['php']['apc'] ? 'Enabled' : 'Disabled', + 'Memcache' => $panel->data['php']['memcache'] ? 'Enabled' : 'Disabled', + ], +]); ?> -
'btn btn-primary']); ?>
\ No newline at end of file +
'btn btn-primary']) ?>
diff --git a/extensions/yii/debug/views/default/panels/config/summary.php b/extensions/yii/debug/views/default/panels/config/summary.php index 3688306..5ee3766 100644 --- a/extensions/yii/debug/views/default/panels/config/summary.php +++ b/extensions/yii/debug/views/default/panels/config/summary.php @@ -1,9 +1,17 @@ +
- - - + + + data['application']['yii'] ?>
- PHP -
\ No newline at end of file + data['php']['version'], ['phpinfo'], ['title' => 'Show phpinfo()']) ?> + diff --git a/extensions/yii/debug/views/default/panels/config/table.php b/extensions/yii/debug/views/default/panels/config/table.php new file mode 100644 index 0000000..0dc2d8d --- /dev/null +++ b/extensions/yii/debug/views/default/panels/config/table.php @@ -0,0 +1,35 @@ + + +

+ + + +

Empty.

+ + + + + + + + + + + + $value): ?> + + + + + + +
NameValue
+ + diff --git a/extensions/yii/debug/views/default/panels/db/summary.php b/extensions/yii/debug/views/default/panels/db/summary.php index c21715e..122999c 100644 --- a/extensions/yii/debug/views/default/panels/db/summary.php +++ b/extensions/yii/debug/views/default/panels/db/summary.php @@ -1,7 +1,7 @@
- - DB + + DB
- \ No newline at end of file + diff --git a/extensions/yii/debug/views/default/panels/log/summary.php b/extensions/yii/debug/views/default/panels/log/summary.php index f2fdbdc..a8a931b 100644 --- a/extensions/yii/debug/views/default/panels/log/summary.php +++ b/extensions/yii/debug/views/default/panels/log/summary.php @@ -21,8 +21,8 @@ if ($warningCount) { ?>
- Log - - + Log + + -
\ No newline at end of file + diff --git a/extensions/yii/debug/views/default/panels/profile/detail.php b/extensions/yii/debug/views/default/panels/profile/detail.php index 8c4c346..61f2c2e 100644 --- a/extensions/yii/debug/views/default/panels/profile/detail.php +++ b/extensions/yii/debug/views/default/panels/profile/detail.php @@ -3,7 +3,7 @@ use yii\grid\GridView; use yii\helpers\Html; ?>

Performance Profiling

-

Total processing time: ; Peak memory: .

+

Total processing time: ; Peak memory: .

$dataProvider, diff --git a/extensions/yii/debug/views/default/panels/profile/summary.php b/extensions/yii/debug/views/default/panels/profile/summary.php index dd2a679..f12ea88 100644 --- a/extensions/yii/debug/views/default/panels/profile/summary.php +++ b/extensions/yii/debug/views/default/panels/profile/summary.php @@ -1,6 +1,6 @@
- Time + Time
- Memory -
\ No newline at end of file + Memory + diff --git a/extensions/yii/debug/views/default/panels/request/_data_table.php b/extensions/yii/debug/views/default/panels/request/_data_table.php deleted file mode 100644 index b6b0036..0000000 --- a/extensions/yii/debug/views/default/panels/request/_data_table.php +++ /dev/null @@ -1,24 +0,0 @@ - -

-

Empty.

- -

- - - - - - - - $value): ?> - - - - - - -
NameValue
charset, TRUE); ?>
- \ No newline at end of file diff --git a/extensions/yii/debug/views/default/panels/request/detail.php b/extensions/yii/debug/views/default/panels/request/detail.php index 5d07820..3098f65 100644 --- a/extensions/yii/debug/views/default/panels/request/detail.php +++ b/extensions/yii/debug/views/default/panels/request/detail.php @@ -1,31 +1,35 @@ [ [ 'label' => 'Parameters', - 'content' => $this->context->renderPartial('panels/request/_data_table', ['caption' => 'Routing', 'values' => $data]) - . $this->context->renderPartial('panels/request/_data_table', ['caption' => '$_GET', 'values' => $panel->data['GET']]) - . $this->context->renderPartial('panels/request/_data_table', ['caption' => '$_POST', 'values' => $panel->data['POST']]) - . $this->context->renderPartial('panels/request/_data_table', ['caption' => '$_FILES', 'values' => $panel->data['FILES']]) - . $this->context->renderPartial('panels/request/_data_table', ['caption' => '$_COOKIE', 'values' => $panel->data['COOKIE']]), + 'content' => $this->render('panels/request/table', ['caption' => 'Routing', 'values' => ['Route' => $panel->data['route'], 'Action' => $panel->data['action'], 'Parameters' => $panel->data['actionParams']]]) + . $this->render('panels/request/table', ['caption' => '$_GET', 'values' => $panel->data['GET']]) + . $this->render('panels/request/table', ['caption' => '$_POST', 'values' => $panel->data['POST']]) + . $this->render('panels/request/table', ['caption' => '$_FILES', 'values' => $panel->data['FILES']]) + . $this->render('panels/request/table', ['caption' => '$_COOKIE', 'values' => $panel->data['COOKIE']]), 'active' => true, ], [ 'label' => 'Headers', - 'content' => $this->context->renderPartial('panels/request/_data_table', ['caption' => 'Request Headers', 'values' => $panel->data['requestHeaders']]) - . $this->context->renderPartial('panels/request/_data_table', ['caption' => 'Response Headers', 'values' => $panel->data['responseHeaders']]) + 'content' => $this->render('panels/request/table', ['caption' => 'Request Headers', 'values' => $panel->data['requestHeaders']]) + . $this->render('panels/request/table', ['caption' => 'Response Headers', 'values' => $panel->data['responseHeaders']]) ], [ 'label' => 'Session', - 'content' => $this->context->renderPartial('panels/request/_data_table', ['caption' => '$_SESSION', 'values' => $panel->data['SESSION']]) - . $this->context->renderPartial('panels/request/_data_table', ['caption' => 'Flashes', 'values' => $panel->data['flashes']]) + 'content' => $this->render('panels/request/table', ['caption' => '$_SESSION', 'values' => $panel->data['SESSION']]) + . $this->render('panels/request/table', ['caption' => 'Flashes', 'values' => $panel->data['flashes']]) ], [ 'label' => '$_SERVER', - 'content' => $this->context->renderPartial('panels/request/_data_table', ['caption' => '$_SERVER', 'values' => $panel->data['SERVER']]), + 'content' => $this->render('panels/request/table', ['caption' => '$_SERVER', 'values' => $panel->data['SERVER']]), ], ], ]); -?> \ No newline at end of file +?> diff --git a/extensions/yii/debug/views/default/panels/request/summary.php b/extensions/yii/debug/views/default/panels/request/summary.php index 37bad98..ca4386f 100644 --- a/extensions/yii/debug/views/default/panels/request/summary.php +++ b/extensions/yii/debug/views/default/panels/request/summary.php @@ -2,7 +2,11 @@ use yii\helpers\Html; use yii\web\Response; -$statusCode = $data['statusCode']; +/** + * @var yii\debug\panels\RequestPanel $panel + */ + +$statusCode = $panel->data['statusCode']; if ($statusCode === null) { $statusCode = 200; } @@ -16,8 +20,8 @@ if ($statusCode >= 200 && $statusCode < 300) { $statusText = Html::encode(isset(Response::$httpStatuses[$statusCode]) ? Response::$httpStatuses[$statusCode] : ''); ?>
- Status + Status
- Action -
\ No newline at end of file + Action data['action'] ?> + diff --git a/extensions/yii/debug/views/default/panels/request/table.php b/extensions/yii/debug/views/default/panels/request/table.php new file mode 100644 index 0000000..c5a5d89 --- /dev/null +++ b/extensions/yii/debug/views/default/panels/request/table.php @@ -0,0 +1,34 @@ + +

+ + + +

Empty.

+ + + + + + + + + + + + $value): ?> + + + + + + +
NameValue
charset, true) ?>
+ +