1
|
|
|
<?php |
2
|
|
|
/* @var $panel yii\debug\panels\LogPanel */ |
3
|
|
|
|
4
|
|
|
use yii\bootstrap\Tabs; |
5
|
|
|
use yii\helpers\Html; |
6
|
|
|
use bedezign\yii2\audit\components\Helper; |
7
|
|
|
|
8
|
1 |
|
if (!function_exists('formatDataString')) { |
9
|
|
|
function formatDataString($types, $data, $preformatted, &$tabs) { foreach ($types as $function => $title) { $result = Helper::$function($data); if ($result) { $tabs[] = ['label' => $title, 'content' => Html::tag('div', $result, $preformatted)]; break; }}} |
10
|
1 |
|
} |
11
|
|
|
|
12
|
1 |
|
$post = empty($request['post']) ? false : $request['post']; |
13
|
1 |
|
$headers = empty($request['headers']) ? false : $request['headers']; |
14
|
1 |
|
$content = empty($request['content']) ? false : $request['content']; |
15
|
1 |
|
$log = empty($request['log']) ? false : $request['log']; |
16
|
1 |
|
unset($request['post'], $request['content'], $request['headers'], $request['log']); |
17
|
|
|
|
18
|
1 |
|
$preformatted = ['class' => 'well', 'style' => 'overflow: auto; white-space: pre']; |
19
|
1 |
|
$formatter = \Yii::$app->formatter; |
20
|
|
|
|
21
|
|
|
$tabs = [ |
22
|
|
|
[ |
23
|
1 |
|
'label' => \Yii::t('audit', 'Info'), |
24
|
1 |
|
'content' => $this->render('info_table', ['request' => $request]), |
25
|
|
|
'active' => true |
26
|
1 |
|
] |
27
|
1 |
|
]; |
28
|
|
|
|
29
|
1 |
|
if ($post) { |
30
|
|
|
$tabs[] = [ |
31
|
|
|
'label' => \Yii::t('audit', 'POST'), |
32
|
|
|
'content' => Html::tag('div', $post, $preformatted) |
33
|
|
|
]; |
34
|
|
|
formatDataString( |
35
|
|
|
['formatAsQuery' => \Yii::t('audit', 'POST - Query'), 'formatAsJSON' => \Yii::t('audit', 'POST - JSON'), |
36
|
|
|
'formatAsXML' => \Yii::t('audit', 'POST - XML'), 'formatAsHTML' => \Yii::t('audit', 'POST - HTML')], |
37
|
|
|
$post, $preformatted, $tabs |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
if ($headers) |
42
|
1 |
|
$tabs[] = [ |
43
|
1 |
|
'label' => \Yii::t('audit', 'Headers'), |
44
|
1 |
|
'content' => Html::tag('div', $formatter->asNtext(implode('', $headers)), ['class' => 'well']) |
45
|
1 |
|
]; |
46
|
|
|
|
47
|
1 |
|
if ($content) { |
48
|
1 |
|
$tabs[] = [ |
49
|
1 |
|
'label' => \Yii::t('audit', 'Content'), |
50
|
1 |
|
'content' => Html::tag('div', $formatter->asText($content), $preformatted) |
51
|
1 |
|
]; |
52
|
1 |
|
formatDataString( |
53
|
1 |
|
['formatAsQuery' => \Yii::t('audit', 'Content - Query'), 'formatAsJSON' => \Yii::t('audit', 'Content - JSON'), |
54
|
1 |
|
'formatAsXML' => \Yii::t('audit', 'Content - XML'), 'formatAsHTML' => \Yii::t('audit', 'Content - HTML')], |
55
|
1 |
|
$content, $preformatted, $tabs |
56
|
1 |
|
); |
57
|
1 |
|
} |
58
|
|
|
|
59
|
|
|
if ($log) |
60
|
1 |
|
$tabs[] = [ |
61
|
1 |
|
'label' => \Yii::t('audit', 'Log'), |
62
|
1 |
|
'content' => Html::tag('div', $formatter->asText($log), $preformatted) |
63
|
1 |
|
]; |
64
|
|
|
|
65
|
|
|
|
66
|
1 |
|
echo Html::tag('h2', \Yii::t('audit', 'Request #{id}', ['id' => $index])), |
67
|
|
|
Tabs::widget(['items' => $tabs]); |
68
|
|
|
|