diff --git a/extensions/yii/debug/panels/RequestPanel.php b/extensions/yii/debug/panels/RequestPanel.php index 9d9cb02..1548c4c 100644 --- a/extensions/yii/debug/panels/RequestPanel.php +++ b/extensions/yii/debug/panels/RequestPanel.php @@ -9,10 +9,7 @@ namespace yii\debug\panels; use Yii; use yii\base\InlineAction; -use yii\bootstrap\Tabs; use yii\debug\Panel; -use yii\helpers\Html; -use yii\web\Response; /** * Debugger panel that collects and displays request data. @@ -29,62 +26,20 @@ class RequestPanel extends Panel public function getSummary() { - $url = $this->getUrl(); - $statusCode = $this->data['statusCode']; - if ($statusCode === null) { - $statusCode = 200; - } - if ($statusCode >= 200 && $statusCode < 300) { - $class = 'label-success'; - } elseif ($statusCode >= 100 && $statusCode < 200) { - $class = 'label-info'; - } else { - $class = 'label-important'; - } - $statusText = Html::encode(isset(Response::$httpStatuses[$statusCode]) ? Response::$httpStatuses[$statusCode] : ''); - - return << - Status $statusCode - -
- Action {$this->data['action']} -
-EOD; + return Yii::$app->view->render('panels/request/summary', [ + 'panel' => $this, + 'data' => $this->data, + ]); } public function getDetail() { - $data = [ - 'Route' => $this->data['route'], - 'Action' => $this->data['action'], - 'Parameters' => $this->data['actionParams'], - ]; - return Tabs::widget([ - 'items' => [ - [ - 'label' => 'Parameters', - 'content' => $this->renderData('Routing', $data) - . $this->renderData('$_GET', $this->data['GET']) - . $this->renderData('$_POST', $this->data['POST']) - . $this->renderData('$_FILES', $this->data['FILES']) - . $this->renderData('$_COOKIE', $this->data['COOKIE']), - 'active' => true, - ], - [ - 'label' => 'Headers', - 'content' => $this->renderData('Request Headers', $this->data['requestHeaders']) - . $this->renderData('Response Headers', $this->data['responseHeaders']), - ], - [ - 'label' => 'Session', - 'content' => $this->renderData('$_SESSION', $this->data['SESSION']) - . $this->renderData('Flashes', $this->data['flashes']), - ], - [ - 'label' => '$_SERVER', - 'content' => $this->renderData('$_SERVER', $this->data['SERVER']), - ], + return Yii::$app->view->render('panels/request/detail', [ + 'panel' => $this, + 'data' => [ + 'Route' => $this->data['route'], + 'Action' => $this->data['action'], + 'Parameters' => $this->data['actionParams'], ], ]); } @@ -136,32 +91,12 @@ EOD; 'action' => $action, 'actionParams' => Yii::$app->requestedParams, 'SERVER' => empty($_SERVER) ? [] : $_SERVER, - 'GET' => empty($_GET) ? [] : $_GET, - 'POST' => empty($_POST) ? [] : $_POST, - 'COOKIE' => empty($_COOKIE) ? [] : $_COOKIE, + 'GET' => empty(Yii::$app->request->get()) ? [] : Yii::$app->request->get(), + 'POST' => empty(Yii::$app->request->post()) ? [] : Yii::$app->request->post(), + 'COOKIE' => empty(Yii::$app->request->cookies) ? [] : Yii::$app->request->cookies, 'FILES' => empty($_FILES) ? [] : $_FILES, - 'SESSION' => empty($_SESSION) ? [] : $_SESSION, + 'SESSION' => empty(Yii::$app->session) ? [] : Yii::$app->session, ]; } - protected function renderData($caption, $values) - { - if (empty($values)) { - return "

$caption

\n

Empty.

"; - } - $rows = []; - foreach ($values as $name => $value) { - $rows[] = '' . Html::encode($name) . '' . htmlspecialchars(var_export($value, true), ENT_QUOTES|ENT_SUBSTITUTE, \Yii::$app->charset, TRUE) . ''; - } - $rows = implode("\n", $rows); - return <<$caption - - - -$rows - -
NameValue
-EOD; - } } diff --git a/extensions/yii/debug/views/default/panels/request/_data_table.php b/extensions/yii/debug/views/default/panels/request/_data_table.php new file mode 100644 index 0000000..b6b0036 --- /dev/null +++ b/extensions/yii/debug/views/default/panels/request/_data_table.php @@ -0,0 +1,24 @@ + +

+

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 new file mode 100644 index 0000000..5d07820 --- /dev/null +++ b/extensions/yii/debug/views/default/panels/request/detail.php @@ -0,0 +1,31 @@ + [ + [ + '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']]), + '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']]) + ], + [ + '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']]) + ], + [ + 'label' => '$_SERVER', + 'content' => $this->context->renderPartial('panels/request/_data_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 new file mode 100644 index 0000000..37bad98 --- /dev/null +++ b/extensions/yii/debug/views/default/panels/request/summary.php @@ -0,0 +1,23 @@ += 200 && $statusCode < 300) { + $class = 'label-success'; +} elseif ($statusCode >= 100 && $statusCode < 200) { + $class = 'label-info'; +} else { + $class = 'label-important'; +} +$statusText = Html::encode(isset(Response::$httpStatuses[$statusCode]) ? Response::$httpStatuses[$statusCode] : ''); +?> + + \ No newline at end of file