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
0293570a
Commit
0293570a
authored
Oct 21, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1038 from lucianobaraglia/master
GII - short echo syntax
parents
380bb5cc
bb1f8858
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
33 deletions
+33
-33
Generator.php
framework/yii/gii/generators/crud/Generator.php
+6
-6
_form.php
framework/yii/gii/generators/crud/templates/views/_form.php
+4
-4
_search.php
...ework/yii/gii/generators/crud/templates/views/_search.php
+6
-6
create.php
framework/yii/gii/generators/crud/templates/views/create.php
+2
-2
index.php
framework/yii/gii/generators/crud/templates/views/index.php
+8
-8
update.php
framework/yii/gii/generators/crud/templates/views/update.php
+2
-2
view.php
framework/yii/gii/generators/crud/templates/views/view.php
+5
-5
No files found.
framework/yii/gii/generators/crud/Generator.php
View file @
0293570a
...
@@ -190,9 +190,9 @@ class Generator extends \yii\gii\Generator
...
@@ -190,9 +190,9 @@ class Generator extends \yii\gii\Generator
}
}
$column
=
$tableSchema
->
columns
[
$attribute
];
$column
=
$tableSchema
->
columns
[
$attribute
];
if
(
$column
->
phpType
===
'boolean'
)
{
if
(
$column
->
phpType
===
'boolean'
)
{
return
"
\$
form->field(
\$
model, '
$attribute
')->checkbox()
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')->checkbox()"
;
}
elseif
(
$column
->
type
===
'text'
)
{
}
elseif
(
$column
->
type
===
'text'
)
{
return
"
\$
form->field(
\$
model, '
$attribute
')->textarea(['rows' => 6])
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')->textarea(['rows' => 6])"
;
}
else
{
}
else
{
if
(
preg_match
(
'/^(password|pass|passwd|passcode)$/i'
,
$column
->
name
))
{
if
(
preg_match
(
'/^(password|pass|passwd|passcode)$/i'
,
$column
->
name
))
{
$input
=
'passwordInput'
;
$input
=
'passwordInput'
;
...
@@ -200,9 +200,9 @@ class Generator extends \yii\gii\Generator
...
@@ -200,9 +200,9 @@ class Generator extends \yii\gii\Generator
$input
=
'textInput'
;
$input
=
'textInput'
;
}
}
if
(
$column
->
phpType
!==
'string'
||
$column
->
size
===
null
)
{
if
(
$column
->
phpType
!==
'string'
||
$column
->
size
===
null
)
{
return
"
\$
form->field(
\$
model, '
$attribute
')->
$input
()
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')->
$input
()"
;
}
else
{
}
else
{
return
"
\$
form->field(
\$
model, '
$attribute
')->
$input
(['maxlength' =>
$column->size
])
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')->
$input
(['maxlength' =>
$column->size
])"
;
}
}
}
}
}
}
...
@@ -216,9 +216,9 @@ class Generator extends \yii\gii\Generator
...
@@ -216,9 +216,9 @@ class Generator extends \yii\gii\Generator
$tableSchema
=
$this
->
getTableSchema
();
$tableSchema
=
$this
->
getTableSchema
();
$column
=
$tableSchema
->
columns
[
$attribute
];
$column
=
$tableSchema
->
columns
[
$attribute
];
if
(
$column
->
phpType
===
'boolean'
)
{
if
(
$column
->
phpType
===
'boolean'
)
{
return
"
\$
form->field(
\$
model, '
$attribute
')->checkbox()
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')->checkbox()"
;
}
else
{
}
else
{
return
"
\$
form->field(
\$
model, '
$attribute
')
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')"
;
}
}
}
}
...
...
framework/yii/gii/generators/crud/templates/views/_form.php
View file @
0293570a
...
@@ -30,15 +30,15 @@ use yii\widgets\ActiveForm;
...
@@ -30,15 +30,15 @@ use yii\widgets\ActiveForm;
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-form"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-form"
>
<?=
'<?php'
?>
$form = ActiveForm::begin(); ?>
<?=
"<?php "
?>
$form = ActiveForm::begin(); ?>
<?php
foreach
(
$safeAttributes
as
$attribute
)
{
<?php
foreach
(
$safeAttributes
as
$attribute
)
{
echo
"
\t\t
<?="
.
$generator
->
generateActiveField
(
$attribute
)
.
" ?>
\n\n
"
;
echo
"
\t\t
<?=
"
.
$generator
->
generateActiveField
(
$attribute
)
.
" ?>
\n\n
"
;
}
?>
}
?>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<?=
'<?php'
?>
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
<?=
"<?= "
?>
Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'])
?>
</div>
</div>
<?=
'<?php'
?>
ActiveForm::end(); ?>
<?=
"<?php "
?>
ActiveForm::end(); ?>
</div>
</div>
framework/yii/gii/generators/crud/templates/views/_search.php
View file @
0293570a
...
@@ -23,7 +23,7 @@ use yii\widgets\ActiveForm;
...
@@ -23,7 +23,7 @@ use yii\widgets\ActiveForm;
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-search"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-search"
>
<?=
'<?php'
?>
$form = ActiveForm::begin([
<?=
"<?php "
?>
$form = ActiveForm::begin([
'action' => ['index'],
'action' => ['index'],
'method' => 'get',
'method' => 'get',
]); ?>
]); ?>
...
@@ -32,17 +32,17 @@ use yii\widgets\ActiveForm;
...
@@ -32,17 +32,17 @@ use yii\widgets\ActiveForm;
$count
=
0
;
$count
=
0
;
foreach
(
$generator
->
getTableSchema
()
->
getColumnNames
()
as
$attribute
)
{
foreach
(
$generator
->
getTableSchema
()
->
getColumnNames
()
as
$attribute
)
{
if
(
++
$count
<
6
)
{
if
(
++
$count
<
6
)
{
echo
"
\t\t
<?=
"
.
$generator
->
generateActiveSearchField
(
$attribute
)
.
" ?>
\n
"
;
echo
"
\t\t
<?=
"
.
$generator
->
generateActiveSearchField
(
$attribute
)
.
" ?>
\n
\n
"
;
}
else
{
}
else
{
echo
"
\t\t
<?
php // echo "
.
$generator
->
generateActiveSearchField
(
$attribute
)
.
" ?>
\n
"
;
echo
"
\t\t
<?
= // "
.
$generator
->
generateActiveSearchField
(
$attribute
)
.
" ?>
\n
\n
"
;
}
}
}
}
?>
?>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<?=
'<?php'
?>
echo Html::submitButton('Search', ['class' => 'btn btn-primary']);
?>
<?=
"<?= "
?>
Html::submitButton('Search', ['class' => 'btn btn-primary'])
?>
<?=
'<?php'
?>
echo Html::resetButton('Reset', ['class' => 'btn btn-default']);
?>
<?=
"<?= "
?>
Html::resetButton('Reset', ['class' => 'btn btn-default'])
?>
</div>
</div>
<?=
'<?php'
?>
ActiveForm::end(); ?>
<?=
"<?php "
?>
ActiveForm::end(); ?>
</div>
</div>
framework/yii/gii/generators/crud/templates/views/create.php
View file @
0293570a
...
@@ -24,9 +24,9 @@ $this->params['breadcrumbs'][] = $this->title;
...
@@ -24,9 +24,9 @@ $this->params['breadcrumbs'][] = $this->title;
?>
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-create"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-create"
>
<h1>
<?=
"<?
php"
?>
echo Html::encode($this->title);
?>
</h1>
<h1>
<?=
"<?
= "
?>
Html::encode($this->title)
?>
</h1>
<?=
"<?php
"
?>
echo $this->render('_form', [
<?=
"<?php
"
?>
echo $this->render('_form', [
'model' => $model,
'model' => $model,
]); ?>
]); ?>
...
...
framework/yii/gii/generators/crud/templates/views/index.php
View file @
0293570a
...
@@ -15,7 +15,7 @@ echo "<?php\n";
...
@@ -15,7 +15,7 @@ echo "<?php\n";
?>
?>
use yii\helpers\Html;
use yii\helpers\Html;
use
<?=
$generator
->
indexWidgetType
===
'grid'
?
'yii\grid\GridView'
:
'yii\widgets\ListView'
?>
;
use
<?=
$generator
->
indexWidgetType
===
'grid'
?
"yii\grid\GridView"
:
"yii\widgets\ListView"
?>
;
/**
/**
* @var yii\base\View $this
* @var yii\base\View $this
...
@@ -28,16 +28,16 @@ $this->params['breadcrumbs'][] = $this->title;
...
@@ -28,16 +28,16 @@ $this->params['breadcrumbs'][] = $this->title;
?>
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-index"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-index"
>
<h1>
<?=
"<?
php"
?>
echo Html::encode($this->title);
?>
</h1>
<h1>
<?=
"<?
= "
?>
Html::encode($this->title)
?>
</h1>
<?=
'<?php'
.
(
$generator
->
indexWidgetType
===
'grid'
?
' //'
:
''
)
?>
echo $this->render('_search', ['model' => $searchModel]); ?>
<?=
"<?php "
.
(
$generator
->
indexWidgetType
===
'grid'
?
"// "
:
""
)
?>
echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<p>
<?=
'<?php'
?>
echo Html::a('Create
<?=
StringHelper
::
basename
(
$generator
->
modelClass
)
?>
', ['create'], ['class' => 'btn btn-success']);
?>
<?=
"<?= "
?>
Html::a('Create
<?=
StringHelper
::
basename
(
$generator
->
modelClass
)
?>
', ['create'], ['class' => 'btn btn-success'])
?>
</p>
</p>
<?php
if
(
$generator
->
indexWidgetType
===
'grid'
)
:
?>
<?php
if
(
$generator
->
indexWidgetType
===
'grid'
)
:
?>
<?=
"<?php
"
?>
echo GridView::widget([
<?=
"<?php
"
?>
echo GridView::widget([
'dataProvider' => $dataProvider,
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'filterModel' => $searchModel,
'columns' => [
'columns' => [
...
@@ -48,9 +48,9 @@ $count = 0;
...
@@ -48,9 +48,9 @@ $count = 0;
foreach
(
$generator
->
getTableSchema
()
->
columns
as
$column
)
{
foreach
(
$generator
->
getTableSchema
()
->
columns
as
$column
)
{
$format
=
$generator
->
generateColumnFormat
(
$column
);
$format
=
$generator
->
generateColumnFormat
(
$column
);
if
(
++
$count
<
6
)
{
if
(
++
$count
<
6
)
{
echo
"
\t\t\t
'"
.
$column
->
name
.
(
$format
===
'text'
?
''
:
':'
.
$format
)
.
"',
\n
"
;
echo
"
\t\t\t
'"
.
$column
->
name
.
(
$format
===
'text'
?
""
:
":"
.
$format
)
.
"',
\n
"
;
}
else
{
}
else
{
echo
"
\t\t\t
// '"
.
$column
->
name
.
(
$format
===
'text'
?
''
:
':'
.
$format
)
.
"',
\n
"
;
echo
"
\t\t\t
// '"
.
$column
->
name
.
(
$format
===
'text'
?
""
:
":"
.
$format
)
.
"',
\n
"
;
}
}
}
}
?>
?>
...
@@ -59,7 +59,7 @@ foreach ($generator->getTableSchema()->columns as $column) {
...
@@ -59,7 +59,7 @@ foreach ($generator->getTableSchema()->columns as $column) {
],
],
]); ?>
]); ?>
<?php
else
:
?>
<?php
else
:
?>
<?=
"<?php
"
?>
echo ListView::widget([
<?=
"<?php
"
?>
echo ListView::widget([
'dataProvider' => $dataProvider,
'dataProvider' => $dataProvider,
'itemOptions' => ['class' => 'item'],
'itemOptions' => ['class' => 'item'],
'itemView' => function ($model, $key, $index, $widget) {
'itemView' => function ($model, $key, $index, $widget) {
...
...
framework/yii/gii/generators/crud/templates/views/update.php
View file @
0293570a
...
@@ -27,9 +27,9 @@ $this->params['breadcrumbs'][] = 'Update';
...
@@ -27,9 +27,9 @@ $this->params['breadcrumbs'][] = 'Update';
?>
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-update"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-update"
>
<h1>
<?=
"<?
php"
?>
echo Html::encode($this->title);
?>
</h1>
<h1>
<?=
"<?
= "
?>
Html::encode($this->title)
?>
</h1>
<?=
"<?php
"
?>
echo $this->render('_form', [
<?=
"<?php
"
?>
echo $this->render('_form', [
'model' => $model,
'model' => $model,
]); ?>
]); ?>
...
...
framework/yii/gii/generators/crud/templates/views/view.php
View file @
0293570a
...
@@ -27,24 +27,24 @@ $this->params['breadcrumbs'][] = $this->title;
...
@@ -27,24 +27,24 @@ $this->params['breadcrumbs'][] = $this->title;
?>
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-view"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-view"
>
<h1>
<?=
"<?
php"
?>
echo Html::encode($this->title);
?>
</h1>
<h1>
<?=
"<?
= "
?>
Html::encode($this->title)
?>
</h1>
<p>
<p>
<?=
'<?php'
?>
echo Html::a('Update', ['update',
<?=
$urlParams
?>
], ['class' => 'btn btn-primary']);
?>
<?=
"<?= "
?>
Html::a('Update', ['update',
<?=
$urlParams
?>
], ['class' => 'btn btn-primary'])
?>
<?=
'<?php'
?>
echo Html::a('Delete', ['delete',
<?=
$urlParams
?>
], [
<?=
"<?php "
?>
echo Html::a('Delete', ['delete',
<?=
$urlParams
?>
], [
'class' => 'btn btn-danger',
'class' => 'btn btn-danger',
'data-confirm' => Yii::t('app', 'Are you sure to delete this item?'),
'data-confirm' => Yii::t('app', 'Are you sure to delete this item?'),
'data-method' => 'post',
'data-method' => 'post',
]); ?>
]); ?>
</p>
</p>
<?=
'<?php'
?>
echo DetailView::widget([
<?=
"<?php "
?>
echo DetailView::widget([
'model' => $model,
'model' => $model,
'attributes' => [
'attributes' => [
<?php
<?php
foreach
(
$generator
->
getTableSchema
()
->
columns
as
$column
)
{
foreach
(
$generator
->
getTableSchema
()
->
columns
as
$column
)
{
$format
=
$generator
->
generateColumnFormat
(
$column
);
$format
=
$generator
->
generateColumnFormat
(
$column
);
echo
"
\t\t\t
'"
.
$column
->
name
.
(
$format
===
'text'
?
''
:
':'
.
$format
)
.
"',
\n
"
;
echo
"
\t\t\t
'"
.
$column
->
name
.
(
$format
===
'text'
?
""
:
":"
.
$format
)
.
"',
\n
"
;
}
}
?>
?>
],
],
...
...
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