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
Show 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
...
@@ -392,8 +392,8 @@ class Generator extends \yii\gii\generators\crud\Generator
FileHelper
::
createDirectory
(
$tmpDir
);
FileHelper
::
createDirectory
(
$tmpDir
);
$tmpFile
=
$tmpDir
.
'/'
.
md5
(
$template
);
$tmpFile
=
$tmpDir
.
'/'
.
md5
(
$template
);
file_put_contents
(
$tmpFile
,
$code
);
file_put_contents
(
$tmpFile
,
$code
);
$command
=
Yii
::
getAlias
(
'@vendor/bin/phptidy'
)
.
' replace '
.
$tmpFile
;
shell_exec
(
'..'
.
DIRECTORY_SEPARATOR
.
'vendor'
.
DIRECTORY_SEPARATOR
.
'bin'
.
DIRECTORY_SEPARATOR
.
'phptidy replace '
.
$tmpFile
);
shell_exec
(
$command
);
return
file_get_contents
(
$tmpFile
);
return
file_get_contents
(
$tmpFile
);
}
else
{
}
else
{
...
...
src/generators/crud/default/views/index.php
View file @
cdd6c0cc
src/generators/crud/default/views/update.php
View file @
cdd6c0cc
src/generators/crud/default/views/view.php
View file @
cdd6c0cc
...
@@ -10,17 +10,16 @@ use yii\helpers\StringHelper;
...
@@ -10,17 +10,16 @@ use yii\helpers\StringHelper;
/** @var \yii\db\ActiveRecord $model */
/** @var \yii\db\ActiveRecord $model */
/** @var $generator \schmunk42\giiant\generators\crud\Generator */
/** @var $generator \schmunk42\giiant\generators\crud\Generator */
## TODO: move to generator (?); cleanup
## TODO: move to generator (?); cleanup
$model
=
new
$generator
->
modelClass
();
$model
=
new
$generator
->
modelClass
();
$model
->
setScenario
(
'crud'
);
$model
->
setScenario
(
'crud'
);
$safeAttributes
=
$model
->
safeAttributes
();
$safeAttributes
=
$model
->
safeAttributes
();
if
(
empty
(
$safeAttributes
))
if
(
empty
(
$safeAttributes
))
{
{
$model
->
setScenario
(
'default'
);
$model
->
setScenario
(
'default'
);
$safeAttributes
=
$model
->
safeAttributes
();
$safeAttributes
=
$model
->
safeAttributes
();
}
}
if
(
empty
(
$safeAttributes
))
if
(
empty
(
$safeAttributes
))
{
{
$safeAttributes
=
$model
->
getTableSchema
()
->
columnNames
;
$safeAttributes
=
$model
->
getTableSchema
()
->
columnNames
;
}
}
...
@@ -108,15 +107,11 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
...
@@ -108,15 +107,11 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
'model' => $model,
'model' => $model,
'attributes' => [
'attributes' => [
<?php
<?php
foreach
(
$safeAttributes
as
$attribute
)
foreach
(
$safeAttributes
as
$attribute
)
{
{
$format
=
$generator
->
attributeFormat
(
$attribute
);
$format
=
$generator
->
attributeFormat
(
$attribute
);
if
(
!
$format
)
if
(
!
$format
)
{
{
continue
;
continue
;
}
}
else
{
else
{
echo
$format
.
",
\n
"
;
echo
$format
.
",
\n
"
;
}
}
}
}
...
@@ -128,11 +123,9 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
...
@@ -128,11 +123,9 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
<hr/>
<hr/>
<?=
'<?= '
?>
Html::a('
<span
class=
"glyphicon glyphicon-trash"
></span>
' .
<?=
<?=
'<?= '
?>
Html::a('
<span
class=
"glyphicon glyphicon-trash"
></span>
' .
<?=
$generator
->
generateString
(
$generator
->
generateString
(
'Delete'
'Delete'
)
)
?>
, ['delete',
<?=
$urlParams
?>
],
?>
, ['delete',
<?=
$urlParams
?>
],
[
[
'class' => 'btn btn-danger',
'class' => 'btn btn-danger',
'data-confirm' => '' .
<?=
$generator
->
generateString
(
'Are you sure to delete this item?'
)
?>
. '',
'data-confirm' => '' .
<?=
$generator
->
generateString
(
'Are you sure to delete this item?'
)
?>
. '',
...
@@ -141,10 +134,11 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
...
@@ -141,10 +134,11 @@ $this->params['breadcrumbs'][] = <?= $generator->generateString('View') ?>;
<?=
"<?php
\$
this->endBlock(); ?>
\n\n
"
;
?>
<?=
"<?php
\$
this->endBlock(); ?>
\n\n
"
;
?>
<?php
<?php
// get relation info $ prepare add button
// get relation info $ prepare add button
$model
=
new
$generator
->
modelClass
();
$model
=
new
$generator
->
modelClass
();
$label
=
substr
(
strrchr
(
$model
::
className
(),
'\\'
),
1
);
$label
=
substr
(
strrchr
(
$model
::
className
(),
'\\'
),
1
);
$items
=
<<<EOS
$items
=
<<<EOS
[
[
'label' => '<b class=""># '.\$model->{$model->primaryKey()[0]}.'</b>',
'label' => '<b class=""># '.\$model->{$model->primaryKey()[0]}.'</b>',
'content' => \$this->blocks['{$label}'],
'content' => \$this->blocks['{$label}'],
...
@@ -153,14 +147,12 @@ $items = <<<EOS
...
@@ -153,14 +147,12 @@ $items = <<<EOS
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
"
;
echo
"
\n
<?php
\$
this->beginBlock('
$name
'); ?>
\n
"
;
$showAllRecords
=
false
;
$showAllRecords
=
false
;
if
(
$relation
->
via
!==
null
)
if
(
$relation
->
via
!==
null
)
{
{
$pivotName
=
Inflector
::
pluralize
(
$generator
->
getModelByTableName
(
$relation
->
via
->
from
[
0
]));
$pivotName
=
Inflector
::
pluralize
(
$generator
->
getModelByTableName
(
$relation
->
via
->
from
[
0
]));
$pivotRelation
=
$model
->
{
'get'
.
$pivotName
}();
$pivotRelation
=
$model
->
{
'get'
.
$pivotName
}();
$pivotPk
=
key
(
$pivotRelation
->
link
);
$pivotPk
=
key
(
$pivotRelation
->
link
);
...
@@ -174,9 +166,7 @@ EOS;
...
@@ -174,9 +166,7 @@ EOS;
)
.
"'=>
\$
model->
{
$model
->
primaryKey
()[
0
]
}
]],
)
.
"'=>
\$
model->
{
$model
->
primaryKey
()[
0
]
}
]],
['class'=>'btn btn-info btn-xs']
['class'=>'btn btn-info btn-xs']
) ?>
\n
"
;
) ?>
\n
"
;
}
}
else
{
else
{
$addButton
=
''
;
$addButton
=
''
;
}
}
...
@@ -201,14 +191,11 @@ EOS;
...
@@ -201,14 +191,11 @@ EOS;
echo
"</div>
\n
</div>
\n
"
;
#<div class='clearfix'></div>\n";
echo
"</div>
\n
</div>
\n
"
;
#<div class='clearfix'></div>\n";
// render pivot grid
// render pivot grid
if
(
$relation
->
via
!==
null
)
if
(
$relation
->
via
!==
null
)
{
{
$pjaxId
=
"pjax-
{
$pivotName
}
"
;
$pjaxId
=
"pjax-
{
$pivotName
}
"
;
$gridRelation
=
$pivotRelation
;
$gridRelation
=
$pivotRelation
;
$gridName
=
$pivotName
;
$gridName
=
$pivotName
;
}
}
else
{
else
{
$pjaxId
=
"pjax-
{
$name
}
"
;
$pjaxId
=
"pjax-
{
$name
}
"
;
$gridRelation
=
$relation
;
$gridRelation
=
$relation
;
$gridName
=
$name
;
$gridName
=
$name
;
...
@@ -238,7 +225,7 @@ EOS;
...
@@ -238,7 +225,7 @@ EOS;
?>
?>
<?=
<?=
// render tabs
// render tabs
"<?= Tabs::widget(
"<?= Tabs::widget(
[
[
'id' => 'relation-tabs',
'id' => 'relation-tabs',
...
@@ -247,6 +234,6 @@ EOS;
...
@@ -247,6 +234,6 @@ EOS;
]
]
);
);
?>"
;
?>"
;
?>
?>
</div>
</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