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
08c844f3
Commit
08c844f3
authored
Oct 28, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1093 from mongosoft/master
code style
parents
66b27fca
0d04846c
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
45 additions
and
45 deletions
+45
-45
contact.php
apps/advanced/frontend/views/site/contact.php
+2
-2
init
apps/advanced/init
+1
-1
contact.php
apps/basic/views/site/contact.php
+2
-2
login.php
apps/basic/views/site/login.php
+2
-2
PhpDocController.php
build/controllers/PhpDocController.php
+5
-5
controller.md
docs/guide/controller.md
+4
-4
upgrade-from-v1.md
docs/guide/upgrade-from-v1.md
+1
-1
view.md
docs/guide/view.md
+2
-2
BaseYii.php
framework/yii/BaseYii.php
+1
-1
View.php
framework/yii/base/View.php
+2
-2
RedisCache.php
framework/yii/caching/RedisCache.php
+1
-1
ActiveDataProvider.php
framework/yii/data/ActiveDataProvider.php
+1
-1
Schema.php
framework/yii/db/cubrid/Schema.php
+2
-2
action.php
framework/yii/gii/generators/form/templates/action.php
+1
-1
view.php
framework/yii/gii/views/default/view.php
+5
-5
MessageFormatter.php
framework/yii/i18n/MessageFormatter.php
+4
-4
Connection.php
framework/yii/redis/Connection.php
+3
-3
exception.php
framework/yii/views/errorHandler/exception.php
+2
-2
RedisCacheTest.php
tests/unit/framework/caching/RedisCacheTest.php
+2
-2
ConsoleTest.php
tests/unit/framework/helpers/ConsoleTest.php
+1
-1
UrlValidatorTest.php
tests/unit/framework/validators/UrlValidatorTest.php
+1
-1
No files found.
apps/advanced/frontend/views/site/contact.php
View file @
08c844f3
...
...
@@ -25,10 +25,10 @@ $this->params['breadcrumbs'][] = $this->title;
<?=
$form
->
field
(
$model
,
'email'
)
?>
<?=
$form
->
field
(
$model
,
'subject'
)
?>
<?=
$form
->
field
(
$model
,
'body'
)
->
textArea
([
'rows'
=>
6
])
?>
<?=
$form
->
field
(
$model
,
'verifyCode'
)
->
widget
(
Captcha
::
className
(),
[
<?=
$form
->
field
(
$model
,
'verifyCode'
)
->
widget
(
Captcha
::
className
(),
[
'options'
=>
[
'class'
=>
'form-control'
],
'template'
=>
'<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>'
,
])
;
?>
])
?>
<div
class=
"form-group"
>
<?=
Html
::
submitButton
(
'Submit'
,
[
'class'
=>
'btn btn-primary'
])
?>
</div>
...
...
apps/advanced/init
View file @
08c844f3
...
...
@@ -21,7 +21,7 @@ if (empty($params['env'])) {
exit
(
1
);
}
if
(
isset
(
$envNames
[
$answer
]))
{
if
(
isset
(
$envNames
[
$answer
]))
{
$envName
=
$envNames
[
$answer
];
}
}
...
...
apps/basic/views/site/contact.php
View file @
08c844f3
...
...
@@ -33,10 +33,10 @@ $this->params['breadcrumbs'][] = $this->title;
<?=
$form
->
field
(
$model
,
'email'
)
?>
<?=
$form
->
field
(
$model
,
'subject'
)
?>
<?=
$form
->
field
(
$model
,
'body'
)
->
textArea
([
'rows'
=>
6
])
?>
<?=
$form
->
field
(
$model
,
'verifyCode'
)
->
widget
(
Captcha
::
className
(),
[
<?=
$form
->
field
(
$model
,
'verifyCode'
)
->
widget
(
Captcha
::
className
(),
[
'options'
=>
[
'class'
=>
'form-control'
],
'template'
=>
'<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>'
,
])
;
?>
])
?>
<div
class=
"form-group"
>
<?=
Html
::
submitButton
(
'Submit'
,
[
'class'
=>
'btn btn-primary'
])
?>
</div>
...
...
apps/basic/views/site/login.php
View file @
08c844f3
...
...
@@ -28,9 +28,9 @@ $this->params['breadcrumbs'][] = $this->title;
<?=
$form
->
field
(
$model
,
'password'
)
->
passwordInput
()
?>
<?=
$form
->
field
(
$model
,
'rememberMe'
,
[
<?=
$form
->
field
(
$model
,
'rememberMe'
,
[
'template'
=>
"<div class=
\"
col-lg-offset-1 col-lg-3
\"
>
{
input
}
</div>
\n
<div class=
\"
col-lg-8
\"
>
{
error
}
</div>"
,
])
->
checkbox
()
;
?>
])
->
checkbox
()
?>
<div
class=
"form-group"
>
<div
class=
"col-lg-offset-1 col-lg-11"
>
...
...
build/controllers/PhpDocController.php
View file @
08c844f3
...
...
@@ -115,7 +115,7 @@ class PhpDocController extends Controller
if
(
trim
(
$lines
[
1
])
==
'*'
||
substr
(
trim
(
$lines
[
1
]),
0
,
3
)
==
'* @'
)
{
$this
->
stderr
(
"[WARN] Class
$className
has no short description.
\n
"
,
Console
::
FG_YELLOW
,
Console
::
BOLD
);
}
foreach
(
$lines
as
$line
)
{
foreach
(
$lines
as
$line
)
{
if
(
substr
(
trim
(
$line
),
0
,
9
)
==
'* @since '
)
{
$seenSince
=
true
;
}
elseif
(
substr
(
trim
(
$line
),
0
,
10
)
==
'* @author '
)
{
...
...
@@ -138,7 +138,7 @@ class PhpDocController extends Controller
$newFileContent
=
[];
$n
=
count
(
$fileContent
);
for
(
$i
=
0
;
$i
<
$n
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
$n
;
$i
++
)
{
if
(
$i
>
$start
||
$i
<
$docStart
)
{
$newFileContent
[]
=
$fileContent
[
$i
];
}
else
{
...
...
@@ -164,7 +164,7 @@ class PhpDocController extends Controller
{
$lines
=
explode
(
"
\n
"
,
$doc
);
$n
=
count
(
$lines
);
for
(
$i
=
0
;
$i
<
$n
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
$n
;
$i
++
)
{
$lines
[
$i
]
=
rtrim
(
$lines
[
$i
]);
if
(
trim
(
$lines
[
$i
])
==
'*'
&&
trim
(
$lines
[
$i
+
1
])
==
'*'
)
{
unset
(
$lines
[
$i
]);
...
...
@@ -184,7 +184,7 @@ class PhpDocController extends Controller
$lines
=
explode
(
"
\n
"
,
$doc
);
$propertyPart
=
false
;
$propertyPosition
=
false
;
foreach
(
$lines
as
$i
=>
$line
)
{
foreach
(
$lines
as
$i
=>
$line
)
{
if
(
substr
(
trim
(
$line
),
0
,
12
)
==
'* @property '
)
{
$propertyPart
=
true
;
}
elseif
(
$propertyPart
&&
trim
(
$line
)
==
'*'
)
{
...
...
@@ -200,7 +200,7 @@ class PhpDocController extends Controller
}
}
$finalDoc
=
''
;
foreach
(
$lines
as
$i
=>
$line
)
{
foreach
(
$lines
as
$i
=>
$line
)
{
$finalDoc
.=
$line
.
"
\n
"
;
if
(
$i
==
$propertyPosition
)
{
$finalDoc
.=
$properties
;
...
...
docs/guide/controller.md
View file @
08c844f3
...
...
@@ -89,7 +89,7 @@ class BlogController extends Controller
$post
=
Post
::
find
(
$id
);
$text
=
$post
->
text
;
if
(
$version
)
{
if
(
$version
)
{
$text
=
$post
->
getHistory
(
$version
);
}
...
...
@@ -121,13 +121,13 @@ class BlogController extends Controller
public
function
actionUpdate
(
$id
)
{
$post
=
Post
::
find
(
$id
);
if
(
!
$post
)
{
if
(
!
$post
)
{
throw
new
HttpException
(
404
);
}
if
(
\Yii
::
$app
->
request
->
isPost
))
{
if
(
\Yii
::
$app
->
request
->
isPost
))
{
$post
->
load
(
$_POST
);
if
(
$post
->
save
())
{
if
(
$post
->
save
())
{
$this
->
redirect
([
'view'
,
'id'
=>
$post
->
id
]);
}
}
...
...
docs/guide/upgrade-from-v1.md
View file @
08c844f3
...
...
@@ -179,7 +179,7 @@ $model->save();
$postTags
=
[];
$tagsCount
=
count
(
$_POST
[
'PostTag'
]);
while
(
$tagsCount
--
>
0
)
{
while
(
$tagsCount
--
>
0
)
{
$postTags
[]
=
new
PostTag
([
'post_id'
=>
$model
->
id
]);
}
Model
::
loadMultiple
(
$postTags
,
$_POST
);
...
...
docs/guide/view.md
View file @
08c844f3
...
...
@@ -28,7 +28,7 @@ as the corresponding key.
So the view for the action above should be in
`views/site/index.php`
and can be something like:
```
php
<p>
Hello,
<?=
$username
?>
!
</p>
<p>
Hello,
<?=
$username
?>
!
</p>
```
Instead of just scalar values you can pass anything else such as arrays or objects.
...
...
@@ -305,7 +305,7 @@ Then we're using it in `index.php` view where we display a list of users:
```
php
<div
class=
"user-index"
>
<?php
foreach
(
$users
as
$user
)
{
foreach
(
$users
as
$user
)
{
echo
$this
->
render
(
'_profile'
,
[
'username'
=>
$user
->
name
,
'tagline'
=>
$user
->
tagline
,
...
...
framework/yii/BaseYii.php
View file @
08c844f3
...
...
@@ -515,7 +515,7 @@ class BaseYii
return
self
::
$app
->
getI18n
()
->
translate
(
$category
,
$message
,
$params
,
$language
?:
self
::
$app
->
language
);
}
else
{
$p
=
[];
foreach
((
array
)
$params
as
$name
=>
$value
)
{
foreach
((
array
)
$params
as
$name
=>
$value
)
{
$p
[
'{'
.
$name
.
'}'
]
=
$value
;
}
return
(
$p
===
[])
?
$message
:
strtr
(
$message
,
$p
);
...
...
framework/yii/base/View.php
View file @
08c844f3
...
...
@@ -519,7 +519,7 @@ class View extends Component
$this
->
trigger
(
self
::
EVENT_END_PAGE
);
$content
=
ob_get_clean
();
foreach
(
array_keys
(
$this
->
assetBundles
)
as
$bundle
)
{
foreach
(
array_keys
(
$this
->
assetBundles
)
as
$bundle
)
{
$this
->
registerAssetFiles
(
$bundle
);
}
echo
strtr
(
$content
,
[
...
...
@@ -549,7 +549,7 @@ class View extends Component
return
;
}
$bundle
=
$this
->
assetBundles
[
$name
];
foreach
(
$bundle
->
depends
as
$dep
)
{
foreach
(
$bundle
->
depends
as
$dep
)
{
$this
->
registerAssetFiles
(
$dep
);
}
$bundle
->
registerAssetFiles
(
$this
);
...
...
framework/yii/caching/RedisCache.php
View file @
08c844f3
...
...
@@ -139,7 +139,7 @@ class RedisCache extends Cache
$response
=
$this
->
_connection
->
executeCommand
(
'MGET'
,
$keys
);
$result
=
[];
$i
=
0
;
foreach
(
$keys
as
$key
)
{
foreach
(
$keys
as
$key
)
{
$result
[
$key
]
=
$response
[
$i
++
];
}
return
$result
;
...
...
framework/yii/data/ActiveDataProvider.php
View file @
08c844f3
...
...
@@ -170,7 +170,7 @@ class ActiveDataProvider extends BaseDataProvider
if
((
$sort
=
$this
->
getSort
())
!==
false
&&
empty
(
$sort
->
attributes
)
&&
$this
->
query
instanceof
ActiveQuery
)
{
/** @var Model $model */
$model
=
new
$this
->
query
->
modelClass
;
foreach
(
$model
->
attributes
()
as
$attribute
)
{
foreach
(
$model
->
attributes
()
as
$attribute
)
{
$sort
->
attributes
[
$attribute
]
=
[
'asc'
=>
[
$attribute
=>
Sort
::
ASC
],
'desc'
=>
[
$attribute
=>
Sort
::
DESC
],
...
...
framework/yii/db/cubrid/Schema.php
View file @
08c844f3
...
...
@@ -147,7 +147,7 @@ class Schema extends \yii\db\Schema
}
$foreignKeys
=
$this
->
db
->
pdo
->
cubrid_schema
(
\PDO
::
CUBRID_SCH_IMPORTED_KEYS
,
$table
->
name
);
foreach
(
$foreignKeys
as
$key
)
{
foreach
(
$foreignKeys
as
$key
)
{
if
(
isset
(
$table
->
foreignKeys
[
$key
[
'FK_NAME'
]]))
{
$table
->
foreignKeys
[
$key
[
'FK_NAME'
]][
$key
[
'FKCOLUMN_NAME'
]]
=
$key
[
'PKCOLUMN_NAME'
];
}
else
{
...
...
@@ -230,7 +230,7 @@ class Schema extends \yii\db\Schema
$this
->
db
->
open
();
$tables
=
$this
->
db
->
pdo
->
cubrid_schema
(
\PDO
::
CUBRID_SCH_TABLE
);
$tableNames
=
[];
foreach
(
$tables
as
$table
)
{
foreach
(
$tables
as
$table
)
{
// do not list system tables
if
(
$table
[
'TYPE'
]
!=
0
)
{
$tableNames
[]
=
$table
[
'NAME'
];
...
...
framework/yii/gii/generators/form/templates/action.php
View file @
08c844f3
...
...
@@ -17,7 +17,7 @@ public function action<?= Inflector::id2camel(trim(basename($generator->viewName
$model = new
<?=
$generator
->
modelClass
?><?=
empty
(
$generator
->
scenarioName
)
?
""
:
"(['scenario' => '
{
$generator
->
scenarioName
}
'])"
?>
;
if ($model->load($_POST)) {
if($model->validate()) {
if
($model->validate()) {
// form inputs are valid, do something here
return;
}
...
...
framework/yii/gii/views/default/view.php
View file @
08c844f3
...
...
@@ -34,19 +34,19 @@ foreach ($generator->templates as $name => $path) {
]);
?>
<div
class=
"row"
>
<div
class=
"col-lg-8"
>
<?=
$this
->
renderFile
(
$generator
->
formView
(),
[
<?=
$this
->
renderFile
(
$generator
->
formView
(),
[
'generator'
=>
$generator
,
'form'
=>
$form
,
])
;
?>
<?=
$form
->
field
(
$generator
,
'template'
)
->
sticky
()
])
?>
<?=
$form
->
field
(
$generator
,
'template'
)
->
sticky
()
->
label
(
'Code Template'
)
->
dropDownList
(
$templates
)
->
hint
(
'
Please select which set of the templates should be used to generated the code.
'
)
;
?>
'
)
?>
<div
class=
"form-group"
>
<?=
Html
::
submitButton
(
'Preview'
,
[
'name'
=>
'preview'
,
'class'
=>
'btn btn-primary'
])
?>
<?php
if
(
isset
(
$files
))
:
?>
<?php
if
(
isset
(
$files
))
:
?>
<?=
Html
::
submitButton
(
'Generate'
,
[
'name'
=>
'generate'
,
'class'
=>
'btn btn-success'
])
?>
<?php
endif
;
?>
</div>
...
...
framework/yii/i18n/MessageFormatter.php
View file @
08c844f3
...
...
@@ -190,7 +190,7 @@ class MessageFormatter extends Component
$pattern
=
$parts
[
0
];
$d
=
0
;
$stack
=
[];
for
(
$i
=
1
;
$i
<
$c
;
$i
++
)
{
for
(
$i
=
1
;
$i
<
$c
;
$i
++
)
{
if
(
preg_match
(
'~^(\s*)([\d\w]+)(\s*)([},])(\s*)(.*)$~us'
,
$parts
[
$i
],
$matches
))
{
// if we are not inside a plural or select this is a message
if
(
!
isset
(
$stack
[
$d
])
||
$stack
[
$d
]
!=
'plural'
&&
$stack
[
$d
]
!=
'select'
)
{
...
...
@@ -257,7 +257,7 @@ class MessageFormatter extends Component
return
[
$pattern
];
}
$tokens
=
[
mb_substr
(
$pattern
,
0
,
$pos
)];
while
(
true
)
{
while
(
true
)
{
$open
=
mb_strpos
(
$pattern
,
'{'
,
$pos
+
1
);
$close
=
mb_strpos
(
$pattern
,
'}'
,
$pos
+
1
);
if
(
$open
===
false
&&
$close
===
false
)
{
...
...
@@ -326,7 +326,7 @@ class MessageFormatter extends Component
$select
=
static
::
tokenizePattern
(
$token
[
2
]);
$c
=
count
(
$select
);
$message
=
false
;
for
(
$i
=
0
;
$i
+
1
<
$c
;
$i
++
)
{
for
(
$i
=
0
;
$i
+
1
<
$c
;
$i
++
)
{
if
(
is_array
(
$select
[
$i
])
||
!
is_array
(
$select
[
$i
+
1
]))
{
return
false
;
}
...
...
@@ -352,7 +352,7 @@ class MessageFormatter extends Component
$c
=
count
(
$plural
);
$message
=
false
;
$offset
=
0
;
for
(
$i
=
0
;
$i
+
1
<
$c
;
$i
++
)
{
for
(
$i
=
0
;
$i
+
1
<
$c
;
$i
++
)
{
if
(
is_array
(
$plural
[
$i
])
||
!
is_array
(
$plural
[
$i
+
1
]))
{
return
false
;
}
...
...
framework/yii/redis/Connection.php
View file @
08c844f3
...
...
@@ -384,7 +384,7 @@ class Connection extends Component
private
function
parseResponse
(
$command
)
{
if
((
$line
=
fgets
(
$this
->
_socket
))
===
false
)
{
if
((
$line
=
fgets
(
$this
->
_socket
))
===
false
)
{
throw
new
Exception
(
"Failed to read from socket.
\n
Redis command was: "
.
$command
);
}
$type
=
$line
[
0
];
...
...
@@ -405,7 +405,7 @@ class Connection extends Component
$length
=
$line
+
2
;
$data
=
''
;
while
(
$length
>
0
)
{
if
((
$block
=
fread
(
$this
->
_socket
,
$line
+
2
))
===
false
)
{
if
((
$block
=
fread
(
$this
->
_socket
,
$line
+
2
))
===
false
)
{
throw
new
Exception
(
"Failed to read from socket.
\n
Redis command was: "
.
$command
);
}
$data
.=
$block
;
...
...
@@ -415,7 +415,7 @@ class Connection extends Component
case
'*'
:
// Multi-bulk replies
$count
=
(
int
)
$line
;
$data
=
[];
for
(
$i
=
0
;
$i
<
$count
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
$count
;
$i
++
)
{
$data
[]
=
$this
->
parseResponse
(
$command
);
}
return
$data
;
...
...
framework/yii/views/errorHandler/exception.php
View file @
08c844f3
...
...
@@ -367,8 +367,8 @@ pre .diff .change{
<ul>
<?=
$handler
->
renderCallStackItem
(
$exception
->
getFile
(),
$exception
->
getLine
(),
null
,
null
,
1
)
?>
<?php
for
(
$i
=
0
,
$trace
=
$exception
->
getTrace
(),
$length
=
count
(
$trace
);
$i
<
$length
;
++
$i
)
:
?>
<?=
$handler
->
renderCallStackItem
(
@
$trace
[
$i
][
'file'
]
?:
null
,
@
$trace
[
$i
][
'line'
]
?:
null
,
@
$trace
[
$i
][
'class'
]
?:
null
,
@
$trace
[
$i
][
'function'
]
?:
null
,
$i
+
2
)
;
?>
<?=
$handler
->
renderCallStackItem
(
@
$trace
[
$i
][
'file'
]
?:
null
,
@
$trace
[
$i
][
'line'
]
?:
null
,
@
$trace
[
$i
][
'class'
]
?:
null
,
@
$trace
[
$i
][
'function'
]
?:
null
,
$i
+
2
)
?>
<?php
endfor
;
?>
</ul>
</div>
...
...
tests/unit/framework/caching/RedisCacheTest.php
View file @
08c844f3
...
...
@@ -24,11 +24,11 @@ class RedisCacheTest extends CacheTestCase
'dataTimeout'
=>
0.1
,
];
$dsn
=
$config
[
'hostname'
]
.
':'
.
$config
[
'port'
];
if
(
!@
stream_socket_client
(
$dsn
,
$errorNumber
,
$errorDescription
,
0.5
))
{
if
(
!@
stream_socket_client
(
$dsn
,
$errorNumber
,
$errorDescription
,
0.5
))
{
$this
->
markTestSkipped
(
'No redis server running at '
.
$dsn
.
' : '
.
$errorNumber
.
' - '
.
$errorDescription
);
}
if
(
$this
->
_cacheInstance
===
null
)
{
if
(
$this
->
_cacheInstance
===
null
)
{
$this
->
_cacheInstance
=
new
RedisCache
(
$config
);
}
return
$this
->
_cacheInstance
;
...
...
tests/unit/framework/helpers/ConsoleTest.php
View file @
08c844f3
...
...
@@ -73,7 +73,7 @@ class ConsoleTest extends TestCase
/* public function testScreenSize()
{
for($i = 1; $i < 20; $i++) {
for
($i = 1; $i < 20; $i++) {
echo implode(', ', Console::getScreenSize(true)) . "\n";
ob_flush();
sleep(1);
...
...
tests/unit/framework/validators/UrlValidatorTest.php
View file @
08c844f3
...
...
@@ -59,7 +59,7 @@ class UrlValidatorTest extends TestCase
public
function
testValidateWithIdn
()
{
if
(
!
function_exists
(
'idn_to_ascii'
))
{
if
(
!
function_exists
(
'idn_to_ascii'
))
{
$this
->
markTestSkipped
(
'intl package required'
);
return
;
}
...
...
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