view.php 2.24 KB
Newer Older
Qiang Xue committed
1 2 3
<?php

use yii\helpers\Html;
Qiang Xue committed
4
use yii\widgets\ActiveForm;
Qiang Xue committed
5
use yii\gii\components\ActiveField;
Qiang Xue committed
6
use yii\gii\CodeFile;
Qiang Xue committed
7 8

/**
Alexander Makarov committed
9
 * @var yii\web\View $this
Qiang Xue committed
10
 * @var yii\gii\Generator $generator
Qiang Xue committed
11
 * @var string $id panel ID
Qiang Xue committed
12
 * @var yii\widgets\ActiveForm $form
Qiang Xue committed
13 14
 * @var string $results
 * @var boolean $hasError
Qiang Xue committed
15
 * @var CodeFile[] $files
Qiang Xue committed
16
 * @var array $answers
Qiang Xue committed
17 18 19
 */

$this->title = $generator->getName();
Alexander Makarov committed
20
$templates = [];
Qiang Xue committed
21
foreach ($generator->templates as $name => $path) {
22
    $templates[$name] = "$name ($path)";
Qiang Xue committed
23
}
Qiang Xue committed
24 25
?>
<div class="default-view">
26
    <h1><?= Html::encode($this->title) ?></h1>
Qiang Xue committed
27

28
    <p><?= $generator->getDescription() ?></p>
Qiang Xue committed
29

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    <?php $form = ActiveForm::begin([
        'id' => "$id-generator",
        'successCssClass' => '',
        'fieldConfig' => ['class' => ActiveField::className()],
    ]); ?>
        <div class="row">
            <div class="col-lg-8 col-md-10">
                <?= $this->renderFile($generator->formView(), [
                    'generator' => $generator,
                    'form' => $form,
                ]) ?>
                <?= $form->field($generator, 'template')->sticky()
                    ->label('Code Template')
                    ->dropDownList($templates)->hint('
                        Please select which set of the templates should be used to generated the code.
                ') ?>
                <div class="form-group">
                    <?= Html::submitButton('Preview', ['name' => 'preview', 'class' => 'btn btn-primary']) ?>
Qiang Xue committed
48

49 50 51 52 53 54
                    <?php if (isset($files)): ?>
                        <?= Html::submitButton('Generate', ['name' => 'generate', 'class' => 'btn btn-success']) ?>
                    <?php endif; ?>
                </div>
            </div>
        </div>
Qiang Xue committed
55

56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
        <?php
        if (isset($results)) {
            echo $this->render('view/results', [
                'generator' => $generator,
                'results' => $results,
                'hasError' => $hasError,
            ]);
        } elseif (isset($files)) {
            echo $this->render('view/files', [
                'id' => $id,
                'generator' => $generator,
                'files' => $files,
                'answers' => $answers,
            ]);
        }
        ?>
    <?php ActiveForm::end(); ?>
Qiang Xue committed
73
</div>