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
dafd3601
Commit
dafd3601
authored
Dec 28, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CS fixes.
parent
1106ad19
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
25 deletions
+29
-25
Filter.php
extensions/yii/debug/components/search/Filter.php
+3
-6
Exact.php
extensions/yii/debug/components/search/matches/Exact.php
+2
-2
Debug.php
extensions/yii/debug/models/search/Debug.php
+16
-12
index.php
extensions/yii/debug/views/default/index.php
+8
-5
No files found.
extensions/yii/debug/components/search/Filter.php
View file @
dafd3601
...
@@ -35,8 +35,7 @@ class Filter extends Component
...
@@ -35,8 +35,7 @@ class Filter extends Component
{
{
$filtered
=
[];
$filtered
=
[];
foreach
(
$data
as
$row
)
foreach
(
$data
as
$row
)
{
{
if
(
$this
->
checkFilter
(
$row
))
{
if
(
$this
->
checkFilter
(
$row
))
{
$filtered
[]
=
$row
;
$filtered
[]
=
$row
;
}
}
...
@@ -53,14 +52,12 @@ class Filter extends Component
...
@@ -53,14 +52,12 @@ class Filter extends Component
{
{
$matched
=
true
;
$matched
=
true
;
foreach
(
$row
as
$name
=>
$value
)
foreach
(
$row
as
$name
=>
$value
)
{
{
if
(
isset
(
$this
->
rules
[
$name
]))
{
if
(
isset
(
$this
->
rules
[
$name
]))
{
#check all rules for given attribute
#check all rules for given attribute
foreach
(
$this
->
rules
[
$name
]
as
$rule
)
foreach
(
$this
->
rules
[
$name
]
as
$rule
)
{
{
if
(
!
$rule
->
check
(
$value
))
{
if
(
!
$rule
->
check
(
$value
))
{
$matched
=
false
;
$matched
=
false
;
}
}
...
...
extensions/yii/debug/components/search/matches/Exact.php
View file @
dafd3601
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
namespace
yii\debug\components\search\matches
;
namespace
yii\debug\components\search\matches
;
/**
/**
*
*
* @author Mark Jebri <mark.github@yandex.ru>
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
* @since 2.0
*/
*/
...
@@ -27,7 +27,7 @@ class Exact extends Base
...
@@ -27,7 +27,7 @@ class Exact extends Base
public
function
check
(
$value
)
public
function
check
(
$value
)
{
{
if
(
!
$this
->
partial
)
{
if
(
!
$this
->
partial
)
{
return
(
mb_strtolower
(
$this
->
value
,
'utf8'
)
==
mb_strtolower
(
$value
,
'utf8'
));
return
(
mb_strtolower
(
$this
->
value
,
'utf8'
)
==
mb_strtolower
(
$value
,
'utf8'
));
}
else
{
}
else
{
return
(
mb_strpos
(
$value
,
$this
->
value
)
!==
false
);
return
(
mb_strpos
(
$value
,
$this
->
value
)
!==
false
);
}
}
...
...
extensions/yii/debug/models/search/Debug.php
View file @
dafd3601
...
@@ -38,7 +38,7 @@ class Debug extends Model
...
@@ -38,7 +38,7 @@ class Debug extends Model
public
$url
;
public
$url
;
/**
/**
* @var string status code attribute input search value
* @var string status code attribute input search value
*/
*/
public
$statusCode
;
public
$statusCode
;
...
@@ -56,7 +56,7 @@ class Debug extends Model
...
@@ -56,7 +56,7 @@ class Debug extends Model
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'tag'
,
'ip'
,
'method'
,
'ajax'
,
'url'
,
'statusCode'
,
'sqlCount'
],
'safe'
],
[[
'tag'
,
'ip'
,
'method'
,
'ajax'
,
'url'
,
'statusCode'
,
'sqlCount'
],
'safe'
],
];
];
}
}
...
@@ -78,8 +78,8 @@ class Debug extends Model
...
@@ -78,8 +78,8 @@ class Debug extends Model
/**
/**
* Returns data provider with filled models. Filter applied if needed.
* Returns data provider with filled models. Filter applied if needed.
* @param
type
$params
* @param
array
$params
* @param
type
$models
* @param
array
$models
* @return \yii\data\ArrayDataProvider
* @return \yii\data\ArrayDataProvider
*/
*/
public
function
search
(
$params
,
$models
)
public
function
search
(
$params
,
$models
)
...
@@ -87,7 +87,7 @@ class Debug extends Model
...
@@ -87,7 +87,7 @@ class Debug extends Model
$dataProvider
=
new
ArrayDataProvider
([
$dataProvider
=
new
ArrayDataProvider
([
'allModels'
=>
$models
,
'allModels'
=>
$models
,
'sort'
=>
[
'sort'
=>
[
'attributes'
=>
[
'method'
,
'ip'
,
'tag'
,
'time'
,
'statusCode'
,
'sqlCount'
],
'attributes'
=>
[
'method'
,
'ip'
,
'tag'
,
'time'
,
'statusCode'
,
'sqlCount'
],
],
],
'pagination'
=>
[
'pagination'
=>
[
'pageSize'
=>
10
,
'pageSize'
=>
10
,
...
@@ -121,25 +121,29 @@ class Debug extends Model
...
@@ -121,25 +121,29 @@ class Debug extends Model
return
in_array
(
$code
,
$this
->
criticalCodes
);
return
in_array
(
$code
,
$this
->
criticalCodes
);
}
}
public
function
addCondition
(
$filter
,
$attribute
,
$partial
=
false
)
/**
* @param Filter $filter
* @param string $attribute
* @param boolean $partial
*/
public
function
addCondition
(
$filter
,
$attribute
,
$partial
=
false
)
{
{
$value
=
$this
->
$attribute
;
$value
=
$this
->
$attribute
;
if
(
mb_strpos
(
$value
,
'>'
)
!==
false
)
if
(
mb_strpos
(
$value
,
'>'
)
!==
false
)
{
{
$value
=
intval
(
str_replace
(
'>'
,
''
,
$value
));
$value
=
intval
(
str_replace
(
'>'
,
''
,
$value
));
$filter
->
addMatch
(
$attribute
,
new
matches\Greater
([
'value'
=>
$value
]));
$filter
->
addMatch
(
$attribute
,
new
matches\Greater
([
'value'
=>
$value
]));
}
elseif
(
mb_strpos
(
$value
,
'<'
)
!==
false
)
{
}
elseif
(
mb_strpos
(
$value
,
'<'
)
!==
false
)
{
$value
=
intval
(
str_replace
(
'<'
,
''
,
$value
));
$value
=
intval
(
str_replace
(
'<'
,
''
,
$value
));
$filter
->
addMatch
(
$attribute
,
new
matches\Lower
([
'value'
=>
$value
]));
$filter
->
addMatch
(
$attribute
,
new
matches\Lower
([
'value'
=>
$value
]));
}
else
{
}
else
{
$filter
->
addMatch
(
$attribute
,
new
matches\Exact
([
'value'
=>
$value
,
'partial'
=>
$partial
]));
$filter
->
addMatch
(
$attribute
,
new
matches\Exact
([
'value'
=>
$value
,
'partial'
=>
$partial
]));
}
}
}
}
}
}
extensions/yii/debug/views/default/index.php
View file @
dafd3601
<?php
<?php
use
Yii
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\grid\GridView
;
use
yii\grid\GridView
;
use
yii\data\ArrayDataProvider
;
use
yii\data\ArrayDataProvider
;
...
@@ -8,6 +7,8 @@ use yii\data\ArrayDataProvider;
...
@@ -8,6 +7,8 @@ use yii\data\ArrayDataProvider;
/**
/**
* @var \yii\web\View $this
* @var \yii\web\View $this
* @var array $manifest
* @var array $manifest
* @var \yii\debug\models\search\Debug $searchModel
* @var ArrayDataProvider $dataProvider
*/
*/
$this
->
title
=
'Yii Debugger'
;
$this
->
title
=
'Yii Debugger'
;
...
@@ -30,10 +31,12 @@ $timeFormatter = extension_loaded('intl') ? Yii::createObject(['class' => 'yii\i
...
@@ -30,10 +31,12 @@ $timeFormatter = extension_loaded('intl') ? Yii::createObject(['class' => 'yii\i
echo
GridView
::
widget
([
echo
GridView
::
widget
([
'dataProvider'
=>
$dataProvider
,
'dataProvider'
=>
$dataProvider
,
'filterModel'
=>
$searchModel
,
'filterModel'
=>
$searchModel
,
'rowOptions'
=>
function
(
$model
,
$key
,
$index
,
$grid
)
use
(
$searchModel
)
'rowOptions'
=>
function
(
$model
,
$key
,
$index
,
$grid
)
use
(
$searchModel
)
{
{
if
(
$searchModel
->
isCodeCritical
(
$model
[
'statusCode'
]))
{
if
(
$searchModel
->
isCodeCritical
(
$model
[
'statusCode'
]))
return
[
'class'
=>
'danger'
];
return
[
'class'
=>
'danger'
];
}
else
{
return
[];
}
},
},
'columns'
=>
[
'columns'
=>
[
[
'class'
=>
'yii\grid\SerialColumn'
],
[
'class'
=>
'yii\grid\SerialColumn'
],
...
@@ -72,7 +75,7 @@ echo GridView::widget([
...
@@ -72,7 +75,7 @@ echo GridView::widget([
'url'
,
'url'
,
[
[
'attribute'
=>
'statusCode'
,
'attribute'
=>
'statusCode'
,
'filter'
=>
[
200
=>
200
,
404
=>
404
,
403
=>
403
,
500
=>
500
],
'filter'
=>
[
200
=>
200
,
404
=>
404
,
403
=>
403
,
500
=>
500
],
'label'
=>
'Status code'
'label'
=>
'Status code'
],
],
],
],
...
...
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