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
b703169d
Commit
b703169d
authored
May 07, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #163 from creocoder/array-to-empty
=== array() => empty() && !== array() => !empty()
parents
86a47f55
82bcd0b2
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
46 additions
and
43 deletions
+46
-43
YiiBase.php
framework/YiiBase.php
+2
-2
Controller.php
framework/base/Controller.php
+1
-1
Dictionary.php
framework/base/Dictionary.php
+2
-2
Vector.php
framework/base/Vector.php
+1
-1
Controller.php
framework/console/Controller.php
+4
-4
HelpController.php
framework/console/controllers/HelpController.php
+3
-3
MigrateController.php
framework/console/controllers/MigrateController.php
+8
-5
ActiveQuery.php
framework/db/ActiveQuery.php
+1
-1
Command.php
framework/db/Command.php
+1
-1
Query.php
framework/db/Query.php
+1
-1
QueryBuilder.php
framework/db/QueryBuilder.php
+4
-4
ArrayHelper.php
framework/helpers/base/ArrayHelper.php
+1
-1
Html.php
framework/helpers/base/Html.php
+1
-1
Json.php
framework/helpers/base/Json.php
+1
-1
I18N.php
framework/i18n/I18N.php
+1
-1
FileValidator.php
framework/validators/FileValidator.php
+1
-1
Sort.php
framework/web/Sort.php
+1
-1
UrlManager.php
framework/web/UrlManager.php
+3
-3
UrlRule.php
framework/web/UrlRule.php
+2
-2
ActiveField.php
framework/widgets/ActiveField.php
+2
-2
ActiveForm.php
framework/widgets/ActiveForm.php
+2
-2
FragmentCache.php
framework/widgets/FragmentCache.php
+2
-2
Menu.php
framework/widgets/Menu.php
+1
-1
No files found.
framework/YiiBase.php
View file @
b703169d
...
@@ -451,12 +451,12 @@ class YiiBase
...
@@ -451,12 +451,12 @@ class YiiBase
}
}
$args
=
func_get_args
();
$args
=
func_get_args
();
array_shift
(
$args
);
// remove $config
array_shift
(
$args
);
// remove $config
if
(
$config
!==
array
(
))
{
if
(
!
empty
(
$config
))
{
$args
[]
=
$config
;
$args
[]
=
$config
;
}
}
return
$reflection
->
newInstanceArgs
(
$args
);
return
$reflection
->
newInstanceArgs
(
$args
);
}
else
{
}
else
{
return
$config
===
array
(
)
?
new
$class
:
new
$class
(
$config
);
return
empty
(
$config
)
?
new
$class
:
new
$class
(
$config
);
}
}
}
}
...
...
framework/base/Controller.php
View file @
b703169d
...
@@ -183,7 +183,7 @@ class Controller extends Component
...
@@ -183,7 +183,7 @@ class Controller extends Component
}
}
}
}
if
(
$missing
!==
array
(
))
{
if
(
!
empty
(
$missing
))
{
throw
new
InvalidRequestException
(
Yii
::
t
(
'yii|Missing required parameters: {params}'
,
array
(
throw
new
InvalidRequestException
(
Yii
::
t
(
'yii|Missing required parameters: {params}'
,
array
(
'{params}'
=>
implode
(
', '
,
$missing
),
'{params}'
=>
implode
(
', '
,
$missing
),
)));
)));
...
...
framework/base/Dictionary.php
View file @
b703169d
...
@@ -51,7 +51,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
...
@@ -51,7 +51,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
*/
*/
public
function
__construct
(
$data
=
array
(),
$config
=
array
())
public
function
__construct
(
$data
=
array
(),
$config
=
array
())
{
{
if
(
$data
!==
array
(
))
{
if
(
!
empty
(
$data
))
{
$this
->
copyFrom
(
$data
);
$this
->
copyFrom
(
$data
);
}
}
parent
::
__construct
(
$config
);
parent
::
__construct
(
$config
);
...
@@ -187,7 +187,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
...
@@ -187,7 +187,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
public
function
copyFrom
(
$data
)
public
function
copyFrom
(
$data
)
{
{
if
(
is_array
(
$data
)
||
$data
instanceof
\Traversable
)
{
if
(
is_array
(
$data
)
||
$data
instanceof
\Traversable
)
{
if
(
$this
->
_d
!==
array
(
))
{
if
(
!
empty
(
$this
->
_d
))
{
$this
->
removeAll
();
$this
->
removeAll
();
}
}
if
(
$data
instanceof
self
)
{
if
(
$data
instanceof
self
)
{
...
...
framework/base/Vector.php
View file @
b703169d
...
@@ -58,7 +58,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
...
@@ -58,7 +58,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
*/
*/
public
function
__construct
(
$data
=
array
(),
$config
=
array
())
public
function
__construct
(
$data
=
array
(),
$config
=
array
())
{
{
if
(
$data
!==
array
(
))
{
if
(
!
empty
(
$data
))
{
$this
->
copyFrom
(
$data
);
$this
->
copyFrom
(
$data
);
}
}
parent
::
__construct
(
$config
);
parent
::
__construct
(
$config
);
...
...
framework/console/Controller.php
View file @
b703169d
...
@@ -45,7 +45,7 @@ class Controller extends \yii\base\Controller
...
@@ -45,7 +45,7 @@ class Controller extends \yii\base\Controller
*/
*/
public
function
runAction
(
$id
,
$params
=
array
())
public
function
runAction
(
$id
,
$params
=
array
())
{
{
if
(
$params
!==
array
(
))
{
if
(
!
empty
(
$params
))
{
$options
=
$this
->
globalOptions
();
$options
=
$this
->
globalOptions
();
foreach
(
$params
as
$name
=>
$value
)
{
foreach
(
$params
as
$name
=>
$value
)
{
if
(
in_array
(
$name
,
$options
,
true
))
{
if
(
in_array
(
$name
,
$options
,
true
))
{
...
@@ -69,7 +69,7 @@ class Controller extends \yii\base\Controller
...
@@ -69,7 +69,7 @@ class Controller extends \yii\base\Controller
*/
*/
public
function
bindActionParams
(
$action
,
$params
)
public
function
bindActionParams
(
$action
,
$params
)
{
{
if
(
$params
!==
array
(
))
{
if
(
!
empty
(
$params
))
{
$options
=
$this
->
globalOptions
();
$options
=
$this
->
globalOptions
();
foreach
(
$params
as
$name
=>
$value
)
{
foreach
(
$params
as
$name
=>
$value
)
{
if
(
in_array
(
$name
,
$options
,
true
))
{
if
(
in_array
(
$name
,
$options
,
true
))
{
...
@@ -81,7 +81,7 @@ class Controller extends \yii\base\Controller
...
@@ -81,7 +81,7 @@ class Controller extends \yii\base\Controller
$args
=
isset
(
$params
[
Request
::
ANONYMOUS_PARAMS
])
?
$params
[
Request
::
ANONYMOUS_PARAMS
]
:
array
();
$args
=
isset
(
$params
[
Request
::
ANONYMOUS_PARAMS
])
?
$params
[
Request
::
ANONYMOUS_PARAMS
]
:
array
();
unset
(
$params
[
Request
::
ANONYMOUS_PARAMS
]);
unset
(
$params
[
Request
::
ANONYMOUS_PARAMS
]);
if
(
$params
!==
array
(
))
{
if
(
!
empty
(
$params
))
{
throw
new
Exception
(
Yii
::
t
(
'yii|Unknown options: {params}'
,
array
(
throw
new
Exception
(
Yii
::
t
(
'yii|Unknown options: {params}'
,
array
(
'{params}'
=>
implode
(
', '
,
array_keys
(
$params
)),
'{params}'
=>
implode
(
', '
,
array_keys
(
$params
)),
)));
)));
...
@@ -105,7 +105,7 @@ class Controller extends \yii\base\Controller
...
@@ -105,7 +105,7 @@ class Controller extends \yii\base\Controller
}
}
}
}
if
(
$missing
!==
array
(
))
{
if
(
!
empty
(
$missing
))
{
throw
new
Exception
(
Yii
::
t
(
'yii|Missing required arguments: {params}'
,
array
(
throw
new
Exception
(
Yii
::
t
(
'yii|Missing required arguments: {params}'
,
array
(
'{params}'
=>
implode
(
', '
,
$missing
),
'{params}'
=>
implode
(
', '
,
$missing
),
)));
)));
...
...
framework/console/controllers/HelpController.php
View file @
b703169d
...
@@ -142,7 +142,7 @@ class HelpController extends Controller
...
@@ -142,7 +142,7 @@ class HelpController extends Controller
protected
function
getHelp
()
protected
function
getHelp
()
{
{
$commands
=
$this
->
getCommands
();
$commands
=
$this
->
getCommands
();
if
(
$commands
!==
array
(
))
{
if
(
!
empty
(
$commands
))
{
echo
"The following commands are available:
\n\n
"
;
echo
"The following commands are available:
\n\n
"
;
foreach
(
$commands
as
$command
)
{
foreach
(
$commands
as
$command
)
{
echo
"*
$command
\n
"
;
echo
"*
$command
\n
"
;
...
@@ -172,7 +172,7 @@ class HelpController extends Controller
...
@@ -172,7 +172,7 @@ class HelpController extends Controller
}
}
$actions
=
$this
->
getActions
(
$controller
);
$actions
=
$this
->
getActions
(
$controller
);
if
(
$actions
!==
array
(
))
{
if
(
!
empty
(
$actions
))
{
echo
"
\n
SUB-COMMANDS
\n\n
"
;
echo
"
\n
SUB-COMMANDS
\n\n
"
;
$prefix
=
$controller
->
getUniqueId
();
$prefix
=
$controller
->
getUniqueId
();
foreach
(
$actions
as
$action
)
{
foreach
(
$actions
as
$action
)
{
...
@@ -280,7 +280,7 @@ class HelpController extends Controller
...
@@ -280,7 +280,7 @@ class HelpController extends Controller
}
}
$options
=
$this
->
getOptionHelps
(
$controller
);
$options
=
$this
->
getOptionHelps
(
$controller
);
if
(
$options
!==
array
(
))
{
if
(
!
empty
(
$options
))
{
echo
"
\n
OPTIONS
\n\n
"
;
echo
"
\n
OPTIONS
\n\n
"
;
echo
implode
(
"
\n\n
"
,
$options
)
.
"
\n\n
"
;
echo
implode
(
"
\n\n
"
,
$options
)
.
"
\n\n
"
;
}
}
...
...
framework/console/controllers/MigrateController.php
View file @
b703169d
...
@@ -144,7 +144,8 @@ class MigrateController extends Controller
...
@@ -144,7 +144,8 @@ class MigrateController extends Controller
*/
*/
public
function
actionUp
(
$limit
=
0
)
public
function
actionUp
(
$limit
=
0
)
{
{
if
((
$migrations
=
$this
->
getNewMigrations
())
===
array
())
{
$migrations
=
$this
->
getNewMigrations
();
if
(
empty
(
$migrations
))
{
echo
"No new migration found. Your system is up-to-date.
\n
"
;
echo
"No new migration found. Your system is up-to-date.
\n
"
;
Yii
::
$app
->
end
();
Yii
::
$app
->
end
();
}
}
...
@@ -198,7 +199,8 @@ class MigrateController extends Controller
...
@@ -198,7 +199,8 @@ class MigrateController extends Controller
throw
new
Exception
(
"The step argument must be greater than 0."
);
throw
new
Exception
(
"The step argument must be greater than 0."
);
}
}
if
((
$migrations
=
$this
->
getMigrationHistory
(
$limit
))
===
array
())
{
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
if
(
empty
(
$migrations
))
{
echo
"No migration has been done before.
\n
"
;
echo
"No migration has been done before.
\n
"
;
return
;
return
;
}
}
...
@@ -244,7 +246,8 @@ class MigrateController extends Controller
...
@@ -244,7 +246,8 @@ class MigrateController extends Controller
throw
new
Exception
(
"The step argument must be greater than 0."
);
throw
new
Exception
(
"The step argument must be greater than 0."
);
}
}
if
((
$migrations
=
$this
->
getMigrationHistory
(
$limit
))
===
array
())
{
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
if
(
empty
(
$migrations
))
{
echo
"No migration has been done before.
\n
"
;
echo
"No migration has been done before.
\n
"
;
return
;
return
;
}
}
...
@@ -407,7 +410,7 @@ class MigrateController extends Controller
...
@@ -407,7 +410,7 @@ class MigrateController extends Controller
{
{
$limit
=
(
int
)
$limit
;
$limit
=
(
int
)
$limit
;
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
if
(
$migrations
===
array
(
))
{
if
(
empty
(
$migrations
))
{
echo
"No migration has been done before.
\n
"
;
echo
"No migration has been done before.
\n
"
;
}
else
{
}
else
{
$n
=
count
(
$migrations
);
$n
=
count
(
$migrations
);
...
@@ -441,7 +444,7 @@ class MigrateController extends Controller
...
@@ -441,7 +444,7 @@ class MigrateController extends Controller
{
{
$limit
=
(
int
)
$limit
;
$limit
=
(
int
)
$limit
;
$migrations
=
$this
->
getNewMigrations
();
$migrations
=
$this
->
getNewMigrations
();
if
(
$migrations
===
array
(
))
{
if
(
empty
(
$migrations
))
{
echo
"No new migrations found. Your system is up-to-date.
\n
"
;
echo
"No new migrations found. Your system is up-to-date.
\n
"
;
}
else
{
}
else
{
$n
=
count
(
$migrations
);
$n
=
count
(
$migrations
);
...
...
framework/db/ActiveQuery.php
View file @
b703169d
...
@@ -103,7 +103,7 @@ class ActiveQuery extends Query
...
@@ -103,7 +103,7 @@ class ActiveQuery extends Query
{
{
$command
=
$this
->
createCommand
();
$command
=
$this
->
createCommand
();
$rows
=
$command
->
queryAll
();
$rows
=
$command
->
queryAll
();
if
(
$rows
!==
array
(
))
{
if
(
!
empty
(
$rows
))
{
$models
=
$this
->
createModels
(
$rows
);
$models
=
$this
->
createModels
(
$rows
);
if
(
!
empty
(
$this
->
with
))
{
if
(
!
empty
(
$this
->
with
))
{
$this
->
populateRelations
(
$models
,
$this
->
with
);
$this
->
populateRelations
(
$models
,
$this
->
with
);
...
...
framework/db/Command.php
View file @
b703169d
...
@@ -106,7 +106,7 @@ class Command extends \yii\base\Component
...
@@ -106,7 +106,7 @@ class Command extends \yii\base\Component
*/
*/
public
function
getRawSql
()
public
function
getRawSql
()
{
{
if
(
$this
->
_params
===
array
(
))
{
if
(
empty
(
$this
->
_params
))
{
return
$this
->
_sql
;
return
$this
->
_sql
;
}
else
{
}
else
{
$params
=
array
();
$params
=
array
();
...
...
framework/db/Query.php
View file @
b703169d
...
@@ -589,7 +589,7 @@ class Query extends \yii\base\Component
...
@@ -589,7 +589,7 @@ class Query extends \yii\base\Component
*/
*/
public
function
addParams
(
$params
)
public
function
addParams
(
$params
)
{
{
if
(
$params
!==
array
(
))
{
if
(
!
empty
(
$params
))
{
if
(
$this
->
params
===
null
)
{
if
(
$this
->
params
===
null
)
{
$this
->
params
=
$params
;
$this
->
params
=
$params
;
}
else
{
}
else
{
...
...
framework/db/QueryBuilder.php
View file @
b703169d
...
@@ -722,7 +722,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -722,7 +722,7 @@ class QueryBuilder extends \yii\base\Object
if
(
!
is_array
(
$condition
))
{
if
(
!
is_array
(
$condition
))
{
return
(
string
)
$condition
;
return
(
string
)
$condition
;
}
elseif
(
$condition
===
array
(
))
{
}
elseif
(
empty
(
$condition
))
{
return
''
;
return
''
;
}
}
if
(
isset
(
$condition
[
0
]))
{
// operator format: operator, operand 1, operand 2, ...
if
(
isset
(
$condition
[
0
]))
{
// operator format: operator, operand 1, operand 2, ...
...
@@ -777,7 +777,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -777,7 +777,7 @@ class QueryBuilder extends \yii\base\Object
$parts
[]
=
$operand
;
$parts
[]
=
$operand
;
}
}
}
}
if
(
$parts
!==
array
(
))
{
if
(
!
empty
(
$parts
))
{
return
'('
.
implode
(
")
$operator
("
,
$parts
)
.
')'
;
return
'('
.
implode
(
")
$operator
("
,
$parts
)
.
')'
;
}
else
{
}
else
{
return
''
;
return
''
;
...
@@ -813,7 +813,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -813,7 +813,7 @@ class QueryBuilder extends \yii\base\Object
$values
=
(
array
)
$values
;
$values
=
(
array
)
$values
;
if
(
$values
===
array
(
)
||
$column
===
array
())
{
if
(
empty
(
$values
)
||
$column
===
array
())
{
return
$operator
===
'IN'
?
'0=1'
:
''
;
return
$operator
===
'IN'
?
'0=1'
:
''
;
}
}
...
@@ -885,7 +885,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -885,7 +885,7 @@ class QueryBuilder extends \yii\base\Object
$values
=
(
array
)
$values
;
$values
=
(
array
)
$values
;
if
(
$values
===
array
(
))
{
if
(
empty
(
$values
))
{
return
$operator
===
'LIKE'
||
$operator
===
'OR LIKE'
?
'0=1'
:
''
;
return
$operator
===
'LIKE'
||
$operator
===
'OR LIKE'
?
'0=1'
:
''
;
}
}
...
...
framework/helpers/base/ArrayHelper.php
View file @
b703169d
...
@@ -36,7 +36,7 @@ class ArrayHelper
...
@@ -36,7 +36,7 @@ class ArrayHelper
{
{
$args
=
func_get_args
();
$args
=
func_get_args
();
$res
=
array_shift
(
$args
);
$res
=
array_shift
(
$args
);
while
(
$args
!==
array
(
))
{
while
(
!
empty
(
$args
))
{
$next
=
array_shift
(
$args
);
$next
=
array_shift
(
$args
);
foreach
(
$next
as
$k
=>
$v
)
{
foreach
(
$next
as
$k
=>
$v
)
{
if
(
is_integer
(
$k
))
{
if
(
is_integer
(
$k
))
{
...
...
framework/helpers/base/Html.php
View file @
b703169d
...
@@ -324,7 +324,7 @@ class Html
...
@@ -324,7 +324,7 @@ class Html
$options
[
'action'
]
=
$action
;
$options
[
'action'
]
=
$action
;
$options
[
'method'
]
=
$method
;
$options
[
'method'
]
=
$method
;
$form
=
static
::
beginTag
(
'form'
,
$options
);
$form
=
static
::
beginTag
(
'form'
,
$options
);
if
(
$hiddenInputs
!==
array
(
))
{
if
(
!
empty
(
$hiddenInputs
))
{
$form
.=
"
\n
"
.
implode
(
"
\n
"
,
$hiddenInputs
);
$form
.=
"
\n
"
.
implode
(
"
\n
"
,
$hiddenInputs
);
}
}
...
...
framework/helpers/base/Json.php
View file @
b703169d
...
@@ -34,7 +34,7 @@ class Json
...
@@ -34,7 +34,7 @@ class Json
$expressions
=
array
();
$expressions
=
array
();
$value
=
static
::
processData
(
$value
,
$expressions
);
$value
=
static
::
processData
(
$value
,
$expressions
);
$json
=
json_encode
(
$value
,
$options
);
$json
=
json_encode
(
$value
,
$options
);
return
$expressions
===
array
(
)
?
$json
:
strtr
(
$json
,
$expressions
);
return
empty
(
$expressions
)
?
$json
:
strtr
(
$json
,
$expressions
);
}
}
/**
/**
...
...
framework/i18n/I18N.php
View file @
b703169d
...
@@ -109,7 +109,7 @@ class I18N extends Component
...
@@ -109,7 +109,7 @@ class I18N extends Component
unset
(
$params
[
0
]);
unset
(
$params
[
0
]);
}
}
return
$params
===
array
(
)
?
$message
:
strtr
(
$message
,
$params
);
return
empty
(
$params
)
?
$message
:
strtr
(
$message
,
$params
);
}
}
/**
/**
...
...
framework/validators/FileValidator.php
View file @
b703169d
...
@@ -138,7 +138,7 @@ class FileValidator extends Validator
...
@@ -138,7 +138,7 @@ class FileValidator extends Validator
}
}
}
}
$object
->
$attribute
=
array_values
(
$files
);
$object
->
$attribute
=
array_values
(
$files
);
if
(
$files
===
array
(
))
{
if
(
empty
(
$files
))
{
$this
->
addError
(
$object
,
$attribute
,
$this
->
uploadRequired
);
$this
->
addError
(
$object
,
$attribute
,
$this
->
uploadRequired
);
}
}
if
(
count
(
$files
)
>
$this
->
maxFiles
)
{
if
(
count
(
$files
)
>
$this
->
maxFiles
)
{
...
...
framework/web/Sort.php
View file @
b703169d
...
@@ -251,7 +251,7 @@ class Sort extends \yii\base\Object
...
@@ -251,7 +251,7 @@ class Sort extends \yii\base\Object
}
}
}
}
}
}
if
(
$this
->
_attributeOrders
===
array
(
)
&&
is_array
(
$this
->
defaults
))
{
if
(
empty
(
$this
->
_attributeOrders
)
&&
is_array
(
$this
->
defaults
))
{
$this
->
_attributeOrders
=
$this
->
defaults
;
$this
->
_attributeOrders
=
$this
->
defaults
;
}
}
}
}
...
...
framework/web/UrlManager.php
View file @
b703169d
...
@@ -90,7 +90,7 @@ class UrlManager extends Component
...
@@ -90,7 +90,7 @@ class UrlManager extends Component
*/
*/
protected
function
compileRules
()
protected
function
compileRules
()
{
{
if
(
!
$this
->
enablePrettyUrl
||
$this
->
rules
===
array
(
))
{
if
(
!
$this
->
enablePrettyUrl
||
empty
(
$this
->
rules
))
{
return
;
return
;
}
}
if
(
is_string
(
$this
->
cache
))
{
if
(
is_string
(
$this
->
cache
))
{
...
@@ -190,13 +190,13 @@ class UrlManager extends Component
...
@@ -190,13 +190,13 @@ class UrlManager extends Component
if
(
$this
->
suffix
!==
null
)
{
if
(
$this
->
suffix
!==
null
)
{
$route
.=
$this
->
suffix
;
$route
.=
$this
->
suffix
;
}
}
if
(
$params
!==
array
(
))
{
if
(
!
empty
(
$params
))
{
$route
.=
'?'
.
http_build_query
(
$params
);
$route
.=
'?'
.
http_build_query
(
$params
);
}
}
return
rtrim
(
$baseUrl
,
'/'
)
.
'/'
.
$route
.
$anchor
;
return
rtrim
(
$baseUrl
,
'/'
)
.
'/'
.
$route
.
$anchor
;
}
else
{
}
else
{
$url
=
$baseUrl
.
'?'
.
$this
->
routeVar
.
'='
.
$route
;
$url
=
$baseUrl
.
'?'
.
$this
->
routeVar
.
'='
.
$route
;
if
(
$params
!==
array
(
))
{
if
(
!
empty
(
$params
))
{
$url
.=
'&'
.
http_build_query
(
$params
);
$url
.=
'&'
.
http_build_query
(
$params
);
}
}
return
$url
;
return
$url
;
...
...
framework/web/UrlRule.php
View file @
b703169d
...
@@ -144,7 +144,7 @@ class UrlRule extends Object
...
@@ -144,7 +144,7 @@ class UrlRule extends Object
$this
->
_template
=
preg_replace
(
'/<(\w+):?([^>]+)?>/'
,
'<$1>'
,
$this
->
pattern
);
$this
->
_template
=
preg_replace
(
'/<(\w+):?([^>]+)?>/'
,
'<$1>'
,
$this
->
pattern
);
$this
->
pattern
=
'#^'
.
trim
(
strtr
(
$this
->
_template
,
$tr
),
'/'
)
.
'$#u'
;
$this
->
pattern
=
'#^'
.
trim
(
strtr
(
$this
->
_template
,
$tr
),
'/'
)
.
'$#u'
;
if
(
$this
->
_routeParams
!==
array
(
))
{
if
(
!
empty
(
$this
->
_routeParams
))
{
$this
->
_routeRule
=
'#^'
.
strtr
(
$this
->
route
,
$tr2
)
.
'$#u'
;
$this
->
_routeRule
=
'#^'
.
strtr
(
$this
->
route
,
$tr2
)
.
'$#u'
;
}
}
}
}
...
@@ -275,7 +275,7 @@ class UrlRule extends Object
...
@@ -275,7 +275,7 @@ class UrlRule extends Object
$url
.=
(
$this
->
suffix
===
null
?
$manager
->
suffix
:
$this
->
suffix
);
$url
.=
(
$this
->
suffix
===
null
?
$manager
->
suffix
:
$this
->
suffix
);
}
}
if
(
$params
!==
array
(
))
{
if
(
!
empty
(
$params
))
{
$url
.=
'?'
.
http_build_query
(
$params
);
$url
.=
'?'
.
http_build_query
(
$params
);
}
}
return
$url
;
return
$url
;
...
...
framework/widgets/ActiveField.php
View file @
b703169d
...
@@ -104,7 +104,7 @@ class ActiveField extends Component
...
@@ -104,7 +104,7 @@ class ActiveField extends Component
public
function
begin
()
public
function
begin
()
{
{
$options
=
$this
->
getClientOptions
();
$options
=
$this
->
getClientOptions
();
if
(
$options
!==
array
(
))
{
if
(
!
empty
(
$options
))
{
$this
->
form
->
attributes
[
$this
->
attribute
]
=
$options
;
$this
->
form
->
attributes
[
$this
->
attribute
]
=
$options
;
}
}
...
@@ -143,7 +143,7 @@ class ActiveField extends Component
...
@@ -143,7 +143,7 @@ class ActiveField extends Component
$validators
[]
=
$js
;
$validators
[]
=
$js
;
}
}
}
}
if
(
$validators
!==
array
(
))
{
if
(
!
empty
(
$validators
))
{
$options
[
'validate'
]
=
new
JsExpression
(
"function(attribute,value,messages){"
.
implode
(
''
,
$validators
)
.
'}'
);
$options
[
'validate'
]
=
new
JsExpression
(
"function(attribute,value,messages){"
.
implode
(
''
,
$validators
)
.
'}'
);
}
}
}
}
...
...
framework/widgets/ActiveForm.php
View file @
b703169d
...
@@ -130,7 +130,7 @@ class ActiveForm extends Widget
...
@@ -130,7 +130,7 @@ class ActiveForm extends Widget
*/
*/
public
function
run
()
public
function
run
()
{
{
if
(
$this
->
attributes
!==
array
(
))
{
if
(
!
empty
(
$this
->
attributes
))
{
$id
=
$this
->
options
[
'id'
];
$id
=
$this
->
options
[
'id'
];
$options
=
Json
::
encode
(
$this
->
getClientOptions
());
$options
=
Json
::
encode
(
$this
->
getClientOptions
());
$attributes
=
Json
::
encode
(
$this
->
attributes
);
$attributes
=
Json
::
encode
(
$this
->
attributes
);
...
@@ -197,7 +197,7 @@ class ActiveForm extends Widget
...
@@ -197,7 +197,7 @@ class ActiveForm extends Widget
$options
[
'class'
]
.=
' '
.
$this
->
errorSummaryCssClass
;
$options
[
'class'
]
.=
' '
.
$this
->
errorSummaryCssClass
;
}
}
if
(
$lines
!==
array
(
))
{
if
(
!
empty
(
$lines
))
{
$content
=
"<ul><li>"
.
implode
(
"</li>
\n
<li>"
,
$lines
)
.
"</li><ul>"
;
$content
=
"<ul><li>"
.
implode
(
"</li>
\n
<li>"
,
$lines
)
.
"</li><ul>"
;
return
Html
::
tag
(
'div'
,
$header
.
$content
.
$footer
,
$options
);
return
Html
::
tag
(
'div'
,
$header
.
$content
.
$footer
,
$options
);
}
else
{
}
else
{
...
...
framework/widgets/FragmentCache.php
View file @
b703169d
...
@@ -107,7 +107,7 @@ class FragmentCache extends Widget
...
@@ -107,7 +107,7 @@ class FragmentCache extends Widget
$data
=
array
(
$content
,
$this
->
dynamicPlaceholders
);
$data
=
array
(
$content
,
$this
->
dynamicPlaceholders
);
$this
->
cache
->
set
(
$this
->
calculateKey
(),
$data
,
$this
->
duration
,
$this
->
dependency
);
$this
->
cache
->
set
(
$this
->
calculateKey
(),
$data
,
$this
->
duration
,
$this
->
dependency
);
if
(
$this
->
view
->
cacheStack
===
array
(
)
&&
!
empty
(
$this
->
dynamicPlaceholders
))
{
if
(
empty
(
$this
->
view
->
cacheStack
)
&&
!
empty
(
$this
->
dynamicPlaceholders
))
{
$content
=
$this
->
updateDynamicContent
(
$content
,
$this
->
dynamicPlaceholders
);
$content
=
$this
->
updateDynamicContent
(
$content
,
$this
->
dynamicPlaceholders
);
}
}
echo
$content
;
echo
$content
;
...
@@ -133,7 +133,7 @@ class FragmentCache extends Widget
...
@@ -133,7 +133,7 @@ class FragmentCache extends Widget
if
(
is_array
(
$data
)
&&
count
(
$data
)
===
2
)
{
if
(
is_array
(
$data
)
&&
count
(
$data
)
===
2
)
{
list
(
$content
,
$placeholders
)
=
$data
;
list
(
$content
,
$placeholders
)
=
$data
;
if
(
is_array
(
$placeholders
)
&&
count
(
$placeholders
)
>
0
)
{
if
(
is_array
(
$placeholders
)
&&
count
(
$placeholders
)
>
0
)
{
if
(
$this
->
view
->
cacheStack
===
array
(
))
{
if
(
empty
(
$this
->
view
->
cacheStack
))
{
// outermost cache: replace placeholder with dynamic content
// outermost cache: replace placeholder with dynamic content
$content
=
$this
->
updateDynamicContent
(
$content
,
$placeholders
);
$content
=
$this
->
updateDynamicContent
(
$content
,
$placeholders
);
}
}
...
...
framework/widgets/Menu.php
View file @
b703169d
...
@@ -166,7 +166,7 @@ class Menu extends Widget
...
@@ -166,7 +166,7 @@ class Menu extends Widget
if
(
$this
->
itemCssClass
!==
null
)
{
if
(
$this
->
itemCssClass
!==
null
)
{
$class
[]
=
$this
->
itemCssClass
;
$class
[]
=
$this
->
itemCssClass
;
}
}
if
(
$class
!==
array
(
))
{
if
(
!
empty
(
$class
))
{
if
(
empty
(
$options
[
'class'
]))
{
if
(
empty
(
$options
[
'class'
]))
{
$options
[
'class'
]
=
implode
(
' '
,
$class
);
$options
[
'class'
]
=
implode
(
' '
,
$class
);
}
else
{
}
else
{
...
...
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