Yii2 framework backup
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

11 years ago
<?php
11 years ago
use yii\helpers\Inflector;
use yii\helpers\StringHelper;
11 years ago
/**
11 years ago
* @var yii\web\View $this
11 years ago
* @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;
use <?= $generator->indexWidgetType === 'grid' ? "yii\\grid\\GridView" : "yii\\widgets\\ListView" ?>;
11 years ago
/**
11 years ago
* @var yii\web\View $this
11 years ago
* @var yii\data\ActiveDataProvider $dataProvider
* @var <?= ltrim($generator->searchModelClass, '\\') ?> $searchModel
11 years ago
*/
$this->title = '<?= Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass))) ?>';
11 years ago
$this->params['breadcrumbs'][] = $this->title;
11 years ago
?>
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-index">
11 years ago
<h1><?= "<?= " ?>Html::encode($this->title) ?></h1>
11 years ago
<?= "<?php " . ($generator->indexWidgetType === 'grid' ? "// " : "") ?>echo $this->render('_search', ['model' => $searchModel]); ?>
11 years ago
<p>
<?= "<?= " ?>Html::a('Create <?= StringHelper::basename($generator->modelClass) ?>', ['create'], ['class' => 'btn btn-success']) ?>
</p>
11 years ago
<?php if ($generator->indexWidgetType === 'grid'): ?>
<?= "<?php " ?>echo GridView::widget([
11 years ago
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
11 years ago
<?php
$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";
11 years ago
} else {
echo "\t\t\t// '" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n";
11 years ago
}
}
?>
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
11 years ago
<?php else: ?>
<?= "<?php " ?>echo ListView::widget([
11 years ago
'dataProvider' => $dataProvider,
'itemOptions' => ['class' => 'item'],
11 years ago
'itemView' => function ($model, $key, $index, $widget) {
return Html::a(Html::encode($model-><?= $nameAttribute ?>), ['view', <?= $urlParams ?>]);
11 years ago
},
]); ?>
11 years ago
<?php endif; ?>
11 years ago
11 years ago
</div>