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
267b4522
Commit
267b4522
authored
Oct 21, 2013
by
Luciano Baraglia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GII - echo short syntax [skip ci]
parent
380bb5cc
Show 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 @
267b4522
...
...
@@ -190,9 +190,9 @@ class Generator extends \yii\gii\Generator
}
$column
=
$tableSchema
->
columns
[
$attribute
];
if
(
$column
->
phpType
===
'boolean'
)
{
return
"
\$
form->field(
\$
model, '
$attribute
')->checkbox()
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')->checkbox()"
;
}
elseif
(
$column
->
type
===
'text'
)
{
return
"
\$
form->field(
\$
model, '
$attribute
')->textarea(['rows' => 6])
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')->textarea(['rows' => 6])"
;
}
else
{
if
(
preg_match
(
'/^(password|pass|passwd|passcode)$/i'
,
$column
->
name
))
{
$input
=
'passwordInput'
;
...
...
@@ -200,9 +200,9 @@ class Generator extends \yii\gii\Generator
$input
=
'textInput'
;
}
if
(
$column
->
phpType
!==
'string'
||
$column
->
size
===
null
)
{
return
"
\$
form->field(
\$
model, '
$attribute
')->
$input
()
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')->
$input
()"
;
}
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
$tableSchema
=
$this
->
getTableSchema
();
$column
=
$tableSchema
->
columns
[
$attribute
];
if
(
$column
->
phpType
===
'boolean'
)
{
return
"
\$
form->field(
\$
model, '
$attribute
')->checkbox()
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')->checkbox()"
;
}
else
{
return
"
\$
form->field(
\$
model, '
$attribute
')
;
"
;
return
"
\$
form->field(
\$
model, '
$attribute
')"
;
}
}
...
...
framework/yii/gii/generators/crud/templates/views/_form.php
View file @
267b4522
...
...
@@ -30,15 +30,15 @@ use yii\widgets\ActiveForm;
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-form"
>
<?=
'<?php'
?>
$form = ActiveForm::begin(); ?>
<?=
"<?php "
?>
$form = ActiveForm::begin(); ?>
<?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"
>
<?=
'<?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>
<?=
'<?php'
?>
ActiveForm::end(); ?>
<?=
"<?php"
?>
ActiveForm::end(); ?>
</div>
framework/yii/gii/generators/crud/templates/views/_search.php
View file @
267b4522
...
...
@@ -23,7 +23,7 @@ use yii\widgets\ActiveForm;
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-search"
>
<?=
'<?php'
?>
$form = ActiveForm::begin([
<?=
"<?php "
?>
$form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
...
...
@@ -32,17 +32,17 @@ use yii\widgets\ActiveForm;
$count
=
0
;
foreach
(
$generator
->
getTableSchema
()
->
getColumnNames
()
as
$attribute
)
{
if
(
++
$count
<
6
)
{
echo
"
\t\t
<?=
"
.
$generator
->
generateActiveSearchField
(
$attribute
)
.
" ?>
\n
"
;
echo
"
\t\t
<?=
"
.
$generator
->
generateActiveSearchField
(
$attribute
)
.
" ?>
\n
\n
"
;
}
else
{
echo
"
\t\t
<?
php // echo "
.
$generator
->
generateActiveSearchField
(
$attribute
)
.
" ?>
\n
"
;
echo
"
\t\t
<?
= // "
.
$generator
->
generateActiveSearchField
(
$attribute
)
.
" ?>
\n
\n
"
;
}
}
?>
<div
class=
"form-group"
>
<?=
'<?php'
?>
echo Html::submitButton('Search', ['class' => 'btn btn-primary']);
?>
<?=
'<?php'
?>
echo Html::resetButton('Reset', ['class' => 'btn btn-default']);
?>
<?=
"<?= "
?>
Html::submitButton('Search', ['class' => 'btn btn-primary'])
?>
<?=
"<?= "
?>
Html::resetButton('Reset', ['class' => 'btn btn-default'])
?>
</div>
<?=
'<?php'
?>
ActiveForm::end(); ?>
<?=
"<?php "
?>
ActiveForm::end(); ?>
</div>
framework/yii/gii/generators/crud/templates/views/create.php
View file @
267b4522
...
...
@@ -24,9 +24,9 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<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,
]); ?>
...
...
framework/yii/gii/generators/crud/templates/views/index.php
View file @
267b4522
...
...
@@ -15,7 +15,7 @@ echo "<?php\n";
?>
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
...
...
@@ -28,16 +28,16 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<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>
<?=
'<?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>
<?php
if
(
$generator
->
indexWidgetType
===
'grid'
)
:
?>
<?=
"<?php
"
?>
echo GridView::widget([
<?=
"<?php
"
?>
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
...
...
@@ -48,9 +48,9 @@ $count = 0;
foreach
(
$generator
->
getTableSchema
()
->
columns
as
$column
)
{
$format
=
$generator
->
generateColumnFormat
(
$column
);
if
(
++
$count
<
6
)
{
echo
"
\t\t\t
'"
.
$column
->
name
.
(
$format
===
'text'
?
''
:
':'
.
$format
)
.
"',
\n
"
;
echo
"
\t\t\t
'"
.
$column
->
name
.
(
$format
===
'text'
?
""
:
":"
.
$format
)
.
"',
\n
"
;
}
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) {
],
]); ?>
<?php
else
:
?>
<?=
"<?php
"
?>
echo ListView::widget([
<?=
"<?php
"
?>
echo ListView::widget([
'dataProvider' => $dataProvider,
'itemOptions' => ['class' => 'item'],
'itemView' => function ($model, $key, $index, $widget) {
...
...
framework/yii/gii/generators/crud/templates/views/update.php
View file @
267b4522
...
...
@@ -27,9 +27,9 @@ $this->params['breadcrumbs'][] = '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,
]); ?>
...
...
framework/yii/gii/generators/crud/templates/views/view.php
View file @
267b4522
...
...
@@ -27,24 +27,24 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-view"
>
<h1>
<?=
"<?
php"
?>
echo Html::encode($this->title);
?>
</h1>
<h1>
<?=
"<?
= "
?>
Html::encode($this->title)
?>
</h1>
<p>
<?=
'<?php'
?>
echo Html::a('Update', ['update',
<?=
$urlParams
?>
], ['class' => 'btn btn-primary']);
?>
<?=
'<?php'
?>
echo Html::a('Delete', ['delete',
<?=
$urlParams
?>
], [
<?=
"<?= "
?>
Html::a('Update', ['update',
<?=
$urlParams
?>
], ['class' => 'btn btn-primary'])
?>
<?=
"<?php "
?>
echo Html::a('Delete', ['delete',
<?=
$urlParams
?>
], [
'class' => 'btn btn-danger',
'data-confirm' => Yii::t('app', 'Are you sure to delete this item?'),
'data-method' => 'post',
]); ?>
</p>
<?=
'<?php'
?>
echo DetailView::widget([
<?=
"<?php "
?>
echo DetailView::widget([
'model' => $model,
'attributes' => [
<?php
foreach
(
$generator
->
getTableSchema
()
->
columns
as
$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