Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
c79cbb38
Commit
c79cbb38
authored
Jan 01, 2014
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug module request panel improved
parent
7a1949fe
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
76 deletions
+92
-76
RequestPanel.php
extensions/yii/debug/panels/RequestPanel.php
+11
-76
_data_table.php
...ns/yii/debug/views/default/panels/request/_data_table.php
+25
-0
detail.php
extensions/yii/debug/views/default/panels/request/detail.php
+32
-0
summary.php
...nsions/yii/debug/views/default/panels/request/summary.php
+24
-0
No files found.
extensions/yii/debug/panels/RequestPanel.php
View file @
c79cbb38
...
...
@@ -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
<<<EOD
<div class="yii-debug-toolbar-block">
<a href="$url" title="Status code: $statusCode $statusText">Status <span class="label $class">$statusCode</span></a>
</div>
<div class="yii-debug-toolbar-block">
<a href="$url">Action <span class="label">{$this->data['action']}</span></a>
</div>
EOD;
return
Yii
::
$app
->
view
->
render
(
'panels/request/summary'
,
[
'panel'
=>
$this
,
'data'
=>
$this
->
data
,
]);
}
public
function
getDetail
()
{
$data
=
[
return
Yii
::
$app
->
view
->
render
(
'panels/request/detail'
,
[
'panel'
=>
$this
,
'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'
]),
],
],
]);
}
...
...
@@ -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
"<h3>
$caption
</h3>
\n
<p>Empty.</p>"
;
}
$rows
=
[];
foreach
(
$values
as
$name
=>
$value
)
{
$rows
[]
=
'<tr><th style="width: 200px;">'
.
Html
::
encode
(
$name
)
.
'</th><td>'
.
htmlspecialchars
(
var_export
(
$value
,
true
),
ENT_QUOTES
|
ENT_SUBSTITUTE
,
\Yii
::
$app
->
charset
,
TRUE
)
.
'</td></tr>'
;
}
$rows
=
implode
(
"
\n
"
,
$rows
);
return
<<<EOD
<h3>$caption</h3>
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead><tr><th style="width: 200px;">Name</th><th>Value</th></tr></thead>
<tbody>
$rows
</tbody>
</table>
EOD;
}
}
extensions/yii/debug/views/default/panels/request/_data_table.php
0 → 100644
View file @
c79cbb38
<?php
use
yii\helpers\Html
;
if
(
empty
(
$values
))
:
?>
<h3>
<?php
echo
$caption
;
?>
</h3>
<p>
Empty.
</p>
<?php
else
:
?>
<h3>
<?php
echo
$caption
;
?>
</h3>
<table
class=
"table table-condensed table-bordered table-striped table-hover"
style=
"table-layout: fixed;"
>
<thead>
<tr>
<th
style=
"width: 200px;"
>
Name
</th>
<th>
Value
</th>
</tr>
</thead>
<?php
foreach
(
$values
as
$name
=>
$value
)
:
?>
<tr>
<th
style=
"width: 200px;"
>
<?php
echo
Html
::
encode
(
$name
);
?>
</th>
<td>
<?php
echo
htmlspecialchars
(
var_export
(
$value
,
true
),
ENT_QUOTES
|
ENT_SUBSTITUTE
,
\Yii
::
$app
->
charset
,
TRUE
);
?>
</td>
</tr>
<?php
endforeach
;
?>
</tbody>
</table>
<?php
endif
;
?>
\ No newline at end of file
extensions/yii/debug/views/default/panels/request/detail.php
0 → 100644
View file @
c79cbb38
<?php
use
yii\bootstrap\Tabs
;
echo
Tabs
::
widget
([
'items'
=>
[
[
'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
extensions/yii/debug/views/default/panels/request/summary.php
0 → 100644
View file @
c79cbb38
<?php
use
yii\helpers\Html
;
use
yii\web\Response
;
$statusCode
=
$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
]
:
''
);
?>
<div
class=
"yii-debug-toolbar-block"
>
<a
href=
"
<?php
echo
$panel
->
getUrl
();
?>
"
title=
"Status code:
<?php
echo
$statusCode
;
?>
<?php
echo
$statusText
;
?>
"
>
Status
<span
class=
"label
<?php
echo
$class
;
?>
"
>
<?php
echo
$statusCode
;
?>
</span></a>
</div>
<div
class=
"yii-debug-toolbar-block"
>
<a
href=
"
<?php
echo
$panel
->
getUrl
();
?>
"
>
Action
<span
class=
"label"
>
<?php
echo
$data
[
'action'
];
?>
</span></a>
</div>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment