You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.0 KiB
72 lines
2.0 KiB
11 years ago
|
<?php
|
||
11 years ago
|
|
||
|
use yii\helpers\Inflector;
|
||
|
use yii\helpers\StringHelper;
|
||
|
|
||
11 years ago
|
/**
|
||
11 years ago
|
* @var yii\base\View $this
|
||
|
* @var yii\gii\generators\crud\Generator $generator
|
||
11 years ago
|
*/
|
||
|
|
||
11 years ago
|
$urlParams = $generator->generateUrlParams();
|
||
11 years ago
|
$nameAttribute = $generator->getNameAttribute();
|
||
|
|
||
|
echo "<?php\n";
|
||
11 years ago
|
?>
|
||
|
|
||
11 years ago
|
use yii\helpers\Html;
|
||
11 years ago
|
use <?= $generator->indexWidgetType === 'grid' ? "yii\\grid\\GridView" : "yii\\widgets\\ListView" ?>;
|
||
11 years ago
|
|
||
|
/**
|
||
|
* @var yii\base\View $this
|
||
|
* @var yii\data\ActiveDataProvider $dataProvider
|
||
11 years ago
|
* @var <?= ltrim($generator->searchModelClass, '\\') ?> $searchModel
|
||
11 years ago
|
*/
|
||
|
|
||
11 years ago
|
$this->title = '<?= Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass))) ?>';
|
||
11 years ago
|
$this->params['breadcrumbs'][] = $this->title;
|
||
11 years ago
|
?>
|
||
11 years ago
|
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-index">
|
||
11 years ago
|
|
||
11 years ago
|
<h1><?= "<?= " ?>Html::encode($this->title) ?></h1>
|
||
11 years ago
|
|
||
11 years ago
|
<?= "<?php " . ($generator->indexWidgetType === 'grid' ? "// " : "") ?>echo $this->render('_search', ['model' => $searchModel]); ?>
|
||
11 years ago
|
|
||
11 years ago
|
<p>
|
||
11 years ago
|
<?= "<?= " ?>Html::a('Create <?= StringHelper::basename($generator->modelClass) ?>', ['create'], ['class' => 'btn btn-success']) ?>
|
||
11 years ago
|
</p>
|
||
11 years ago
|
|
||
|
<?php if ($generator->indexWidgetType === 'grid'): ?>
|
||
11 years ago
|
<?= "<?php " ?>echo GridView::widget([
|
||
11 years ago
|
'dataProvider' => $dataProvider,
|
||
|
'filterModel' => $searchModel,
|
||
11 years ago
|
'columns' => [
|
||
|
['class' => 'yii\grid\SerialColumn'],
|
||
11 years ago
|
|
||
11 years ago
|
<?php
|
||
|
$count = 0;
|
||
|
foreach ($generator->getTableSchema()->columns as $column) {
|
||
|
$format = $generator->generateColumnFormat($column);
|
||
|
if (++$count < 6) {
|
||
11 years ago
|
echo "\t\t\t'" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n";
|
||
11 years ago
|
} else {
|
||
11 years ago
|
echo "\t\t\t// '" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n";
|
||
11 years ago
|
}
|
||
|
}
|
||
|
?>
|
||
11 years ago
|
|
||
11 years ago
|
['class' => 'yii\grid\ActionColumn'],
|
||
|
],
|
||
|
]); ?>
|
||
11 years ago
|
<?php else: ?>
|
||
11 years ago
|
<?= "<?php " ?>echo ListView::widget([
|
||
11 years ago
|
'dataProvider' => $dataProvider,
|
||
11 years ago
|
'itemOptions' => ['class' => 'item'],
|
||
11 years ago
|
'itemView' => function ($model, $key, $index, $widget) {
|
||
11 years ago
|
return Html::a(Html::encode($model-><?= $nameAttribute ?>), ['view', <?= $urlParams ?>]);
|
||
11 years ago
|
},
|
||
11 years ago
|
]); ?>
|
||
11 years ago
|
<?php endif; ?>
|
||
11 years ago
|
|
||
11 years ago
|
</div>
|