Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Y
yii2-giiant
Project
Project
Details
Activity
Releases
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dmstr
yii2-giiant
Commits
cdd6c0cc
Commit
cdd6c0cc
authored
Oct 07, 2016
by
Fredy Nurman Saleh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing indent & comply PSR-2
parent
2c98af20
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
52 deletions
+39
-52
Generator.php
src/generators/crud/Generator.php
+2
-2
index.php
src/generators/crud/default/views/index.php
+9
-9
update.php
src/generators/crud/default/views/update.php
+1
-1
view.php
src/generators/crud/default/views/view.php
+27
-40
No files found.
src/generators/crud/Generator.php
View file @
cdd6c0cc
...
...
@@ -392,8 +392,8 @@ class Generator extends \yii\gii\generators\crud\Generator
FileHelper
::
createDirectory
(
$tmpDir
);
$tmpFile
=
$tmpDir
.
'/'
.
md5
(
$template
);
file_put_contents
(
$tmpFile
,
$code
);
shell_exec
(
'..'
.
DIRECTORY_SEPARATOR
.
'vendor'
.
DIRECTORY_SEPARATOR
.
'bin'
.
DIRECTORY_SEPARATOR
.
'phptidy replace '
.
$tmpFile
);
$command
=
Yii
::
getAlias
(
'@vendor/bin/phptidy'
)
.
' replace '
.
$tmpFile
;
shell_exec
(
$command
);
return
file_get_contents
(
$tmpFile
);
}
else
{
...
...
src/generators/crud/default/views/index.php
View file @
cdd6c0cc
...
...
@@ -93,8 +93,8 @@ echo '?>';
<?=
"<?php \yii\widgets\Pjax::begin(['id'=>'pjax-main', 'enableReplaceState'=> false, 'linkSelector'=>'#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success'=>'function()
{
alert(\"yo\")
}
']]) ?>
\n
"
;
?>
<h1>
<?=
"<?= Yii::t('
{
$generator
->
modelMessageCategory
}
', '
{
$modelName
}
') ?>
\n
"
?>
<small>
<?=
"<?= Yii::t('
{
$generator
->
modelMessageCategory
}
', '
{
$modelName
}
') ?>
\n
"
?>
<small>
List
</small>
</h1>
...
...
@@ -168,15 +168,15 @@ PHP;
'class' => 'dropdown-menu-right'
],
'encodeLabels' => false,
'items' => [
<?=
"
\n
"
.
$items
.
"
\n
"
?>
]
],
'items' => [
<?=
"
\n
"
.
$items
.
"
\n
"
?>
]
],
'options' => [
'class' => 'btn-default'
]
]
);
<?=
"?>
\n
"
?>
</div>
<?=
"?>
\n
"
?>
</div>
</div>
<hr
/>
...
...
@@ -188,14 +188,14 @@ PHP;
'class' => yii\widgets\LinkPager::className(),
'firstPageLabel' =>
<?=
$generator
->
generateString
(
'First'
)
?>
,
'lastPageLabel' =>
<?=
$generator
->
generateString
(
'Last'
)
.
",
\n
"
?>
],
],
<?php
if
(
$generator
->
searchModelClass
!==
''
)
:
?>
'filterModel' => $searchModel,
<?php
endif
;
?>
'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
'headerRowOptions' => ['class'=>'x'],
'columns' => [
<?php
'columns' => [
<?php
$actionButtonColumn
=
<<<PHP
[
'class' => '{$generator->actionButtonClass}',
...
...
src/generators/crud/default/views/update.php
View file @
cdd6c0cc
...
...
@@ -23,7 +23,7 @@ use yii\helpers\Html;
* @var yii\web\View $this
* @var
<?=
ltrim
(
$generator
->
modelClass
,
'\\'
)
?>
$model
*/
$this->title = Yii::t('
<?=
$generator
->
modelMessageCategory
?>
', '
<?=
$modelName
?>
') . " " . $model->
<?=
$generator
->
getNameAttribute
(
)
?>
. ', ' .
<?=
$generator
->
generateString
(
'Edit'
)
?>
;
$this->params['breadcrumbs'][] = ['label' => Yii::t('
<?=
$generator
->
modelMessageCategory
?>
', '
<?=
$modelName
?>
'), 'url' => ['index']];
...
...
src/generators/crud/default/views/view.php
View file @
cdd6c0cc
...
...
@@ -10,17 +10,16 @@ use yii\helpers\StringHelper;
/** @var \yii\db\ActiveRecord $model */
/** @var $generator \schmunk42\giiant\generators\crud\Generator */
## TODO: move to generator (?); cleanup
$model
=
new
$generator
->
modelClass
();
$model
->
setScenario
(
'crud'
);
$safeAttributes
=
$model
->
safeAttributes
();
if
(
empty
(
$safeAttributes
))
{
if
(
empty
(
$safeAttributes
))
{
$model
->
setScenario
(
'default'
);
$safeAttributes
=
$model
->
safeAttributes
();
}
if
(
empty
(
$safeAttributes
))
{
if
(
empty
(
$safeAttributes
))
{
$safeAttributes
=
$model
->
getTableSchema
()
->
columnNames
;
}
...
...
@@ -64,7 +63,7 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
<h1>
<?=
"<?= Yii::t('
{
$generator
->
modelMessageCategory
}
', '
{
$modelName
}
') ?>
\n
"
?>
<small>
<?=
'<?= $model->'
.
$generator
->
getModelNameAttribute
(
$generator
->
modelClass
)
.
" ?>
\n
"
?>
<?=
'<?= $model->'
.
$generator
->
getModelNameAttribute
(
$generator
->
modelClass
)
.
" ?>
\n
"
?>
</small>
</h1>
...
...
@@ -73,24 +72,24 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
<!-- menu buttons -->
<div
class=
'pull-left'
>
<?=
'<?= '
?>
Html::a(
<?=
'<?= '
?>
Html::a(
'
<span
class=
"glyphicon glyphicon-pencil"
></span>
' .
<?=
$generator
->
generateString
(
'Edit'
)
?>
,
[ 'update',
<?=
$urlParams
?>
],
['class' => 'btn btn-info']) ?>
<?=
'<?= '
?>
Html::a(
<?=
'<?= '
?>
Html::a(
'
<span
class=
"glyphicon glyphicon-copy"
></span>
' .
<?=
$generator
->
generateString
(
'Copy'
)
?>
,
['create',
<?=
$urlParams
?>
, '
<?=
StringHelper
::
basename
(
$generator
->
modelClass
)
?>
'=>$copyParams],
['class' => 'btn btn-success']) ?>
<?=
'<?= '
?>
Html::a(
<?=
'<?= '
?>
Html::a(
'
<span
class=
"glyphicon glyphicon-plus"
></span>
' .
<?=
$generator
->
generateString
(
'New'
)
?>
,
['create'],
['class' => 'btn btn-success']) ?>
</div>
<div
class=
"pull-right"
>
<?=
"<?= "
?>
Html::a('
<span
class=
"glyphicon glyphicon-list"
></span>
'
<?=
"<?= "
?>
Html::a('
<span
class=
"glyphicon glyphicon-list"
></span>
'
.
<?=
$generator
->
generateString
(
'Full list'
)
?>
, ['index'], ['class'=>'btn btn-default']) ?>
</div>
...
...
@@ -104,19 +103,15 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
<?=
$generator
->
partialView
(
'detail_prepend'
,
$model
);
?>
<?=
'<?= '
?>
DetailView::widget([
<?=
'<?= '
?>
DetailView::widget([
'model' => $model,
'attributes' => [
<?php
foreach
(
$safeAttributes
as
$attribute
)
{
foreach
(
$safeAttributes
as
$attribute
)
{
$format
=
$generator
->
attributeFormat
(
$attribute
);
if
(
!
$format
)
{
if
(
!
$format
)
{
continue
;
}
else
{
}
else
{
echo
$format
.
",
\n
"
;
}
}
...
...
@@ -128,11 +123,9 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
<hr/>
<?=
'<?= '
?>
Html::a('
<span
class=
"glyphicon glyphicon-trash"
></span>
' .
<?=
$generator
->
generateString
(
<?=
'<?= '
?>
Html::a('
<span
class=
"glyphicon glyphicon-trash"
></span>
' .
<?=
$generator
->
generateString
(
'Delete'
)
?>
, ['delete',
<?=
$urlParams
?>
],
)
?>
, ['delete',
<?=
$urlParams
?>
],
[
'class' => 'btn btn-danger',
'data-confirm' => '' .
<?=
$generator
->
generateString
(
'Are you sure to delete this item?'
)
?>
. '',
...
...
@@ -141,10 +134,11 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
<?=
"<?php
\$
this->endBlock(); ?>
\n\n
"
;
?>
<?php
// get relation info $ prepare add button
$model
=
new
$generator
->
modelClass
();
$label
=
substr
(
strrchr
(
$model
::
className
(),
'\\'
),
1
);
$items
=
<<<EOS
$items
=
<<<EOS
[
'label' => '<b class=""># '.\$model->{$model->primaryKey()[0]}.'</b>',
'content' => \$this->blocks['{$label}'],
...
...
@@ -153,14 +147,12 @@ $items = <<<EOS
EOS;
foreach
(
$generator
->
getModelRelations
(
$generator
->
modelClass
,
[
'has_many'
])
as
$name
=>
$relation
)
{
foreach
(
$generator
->
getModelRelations
(
$generator
->
modelClass
,
[
'has_many'
])
as
$name
=>
$relation
)
{
echo
"
\n
<?php
\$
this->beginBlock('
$name
'); ?>
\n
"
;
$showAllRecords
=
false
;
if
(
$relation
->
via
!==
null
)
{
if
(
$relation
->
via
!==
null
)
{
$pivotName
=
Inflector
::
pluralize
(
$generator
->
getModelByTableName
(
$relation
->
via
->
from
[
0
]));
$pivotRelation
=
$model
->
{
'get'
.
$pivotName
}();
$pivotPk
=
key
(
$pivotRelation
->
link
);
...
...
@@ -174,9 +166,7 @@ EOS;
)
.
"'=>
\$
model->
{
$model
->
primaryKey
()[
0
]
}
]],
['class'=>'btn btn-info btn-xs']
) ?>
\n
"
;
}
else
{
}
else
{
$addButton
=
''
;
}
...
...
@@ -185,30 +175,27 @@ EOS;
echo
" <?= Html::a(
'<span class=
\"
glyphicon glyphicon-list
\"
></span> ' . "
.
$generator
->
generateString
(
'List All'
)
.
" . ' "
.
Inflector
::
camel2words
(
$name
)
.
"',
Inflector
::
camel2words
(
$name
)
.
"',
['"
.
$generator
->
createRelationRoute
(
$relation
,
'index'
)
.
"'],
['class'=>'btn text-muted btn-xs']
) ?>
\n
"
;
// TODO: support multiple PKs
echo
" <?= Html::a(
'<span class=
\"
glyphicon glyphicon-plus
\"
></span> ' . "
.
$generator
->
generateString
(
'New'
)
.
" . ' "
.
Inflector
::
singularize
(
Inflector
::
camel2words
(
$name
))
.
"',
Inflector
::
singularize
(
Inflector
::
camel2words
(
$name
))
.
"',
['"
.
$generator
->
createRelationRoute
(
$relation
,
'create'
)
.
"', '"
.
Inflector
::
id2camel
(
$generator
->
generateRelationTo
(
$relation
),
'-'
,
true
)
.
"' => ['"
.
key
(
$relation
->
link
)
.
"' =>
\$
model->"
.
$model
->
primaryKey
()[
0
]
.
"]],
Inflector
::
id2camel
(
$generator
->
generateRelationTo
(
$relation
),
'-'
,
true
)
.
"' => ['"
.
key
(
$relation
->
link
)
.
"' =>
\$
model->"
.
$model
->
primaryKey
()[
0
]
.
"]],
['class'=>'btn btn-success btn-xs']
); ?>
\n
"
;
echo
$addButton
;
echo
"</div>
\n
</div>
\n
"
;
#<div class='clearfix'></div>\n";
// render pivot grid
if
(
$relation
->
via
!==
null
)
{
if
(
$relation
->
via
!==
null
)
{
$pjaxId
=
"pjax-
{
$pivotName
}
"
;
$gridRelation
=
$pivotRelation
;
$gridName
=
$pivotName
;
}
else
{
}
else
{
$pjaxId
=
"pjax-
{
$name
}
"
;
$gridRelation
=
$relation
;
$gridName
=
$name
;
...
...
@@ -237,8 +224,8 @@ EOS;
}
?>
<?=
// render tabs
<?=
// render tabs
"<?= Tabs::widget(
[
'id' => 'relation-tabs',
...
...
@@ -247,6 +234,6 @@ EOS;
]
);
?>"
;
?>
?>
</div>
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