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

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

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

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

Qiang Xue committed
29 30
	<p><?php echo $generator->getDescription(); ?></p>

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

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

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