Skip to content

Commit

Permalink
install rework
Browse files Browse the repository at this point in the history
  • Loading branch information
noumo committed May 18, 2015
1 parent 28f2a18 commit 065edd8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
8 changes: 5 additions & 3 deletions controllers/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function actionIndex()
$this->installModules();

Yii::$app->cache->flush();
Yii::$app->session->setFlash('root_password', $installForm->root_password);
Yii::$app->session->setFlash(InstallForm::ROOT_PASSWORD_KEY, $installForm->root_password);

return $this->redirect(['/admin/install/finish']);
}
Expand All @@ -61,15 +61,17 @@ public function actionIndex()

public function actionFinish()
{
$root_password = Yii::$app->session->getFlash('root_password', null, true);
$root_password = Yii::$app->session->getFlash(InstallForm::ROOT_PASSWORD_KEY, null, true);
$returnRoute = Yii::$app->session->getFlash(InstallForm::RETURN_URL_KEY, null, '/admin');

if($root_password)
{
$loginForm = new LoginForm([
'username' => 'root',
'password' => $root_password,
]);
if($loginForm->login()){
return $this->redirect(['/admin/']);
return $this->redirect([$returnRoute]);
}
}

Expand Down
3 changes: 3 additions & 0 deletions models/InstallForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

class InstallForm extends Model
{
const RETURN_URL_KEY = 'easyii_install_root_password';
const ROOT_PASSWORD_KEY = 'easyii_install_success_return';

public $root_password;
public $recaptcha_key;
public $recaptcha_secret;
Expand Down
14 changes: 14 additions & 0 deletions views/install/_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
?>
<?php $form = ActiveForm::begin(['action' => Url::to('/admin/install')]); ?>
<?= $form->field($model, 'root_password', ['inputOptions' => ['title' => Yii::t('easyii/install','Password to login as root')]]) ?>
<?= $form->field($model, 'admin_email', ['inputOptions' => ['title' => Yii::t('easyii/install','Used as "ReplyTo" in mail messages')]]) ?>
<?= $form->field($model, 'robot_email', ['inputOptions' => ['title' => Yii::t('easyii/install','Used as "From" in mail messages')]]) ?>
<?= $form->field($model, 'recaptcha_key', ['inputOptions' => ['title' => Yii::t('easyii/install','Required for using captcha in forms (guestbook, feedback)')]]) ?>
<?= $form->field($model, 'recaptcha_secret') ?>
<p class="recaptcha-tip"><?= Yii::t('easyii/install', 'You easily can get keys on') ?> <a href="https://www.google.com/recaptcha/intro/index.html" target="_blank"><?= Yii::t('easyii/install', 'ReCaptcha website') ?></a></p>
<?= Html::submitButton(Yii::t('easyii/install', 'Install'), ['class' => 'btn btn-lg btn-primary btn-block']) ?>
<?php ActiveForm::end(); ?>
15 changes: 1 addition & 14 deletions views/install/index.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;

$asset = \yii\easyii\assets\EmptyAsset::register($this);

$this->registerJs('$("input").tooltip({ placement: "right", trigger: "focus" })');

$this->title = Yii::t('easyii/install', 'Installation');
?>
<div class="container">
Expand All @@ -16,15 +11,7 @@
<?= Yii::t('easyii/install', 'Installation') ?>
</div>
<div class="panel-body">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'root_password', ['inputOptions' => ['title' => Yii::t('easyii/install','Password to login as root')]]) ?>
<?= $form->field($model, 'admin_email', ['inputOptions' => ['title' => Yii::t('easyii/install','Used as "ReplyTo" in mail messages')]]) ?>
<?= $form->field($model, 'robot_email', ['inputOptions' => ['title' => Yii::t('easyii/install','Used as "From" in mail messages')]]) ?>
<?= $form->field($model, 'recaptcha_key', ['inputOptions' => ['title' => Yii::t('easyii/install','Required for using captcha in forms (guestbook, feedback)')]]) ?>
<?= $form->field($model, 'recaptcha_secret') ?>
<p class="recaptcha-tip"><?= Yii::t('easyii/install', 'You easily can get keys on') ?> <a href="https://www.google.com/recaptcha/intro/index.html" target="_blank"><?= Yii::t('easyii/install', 'ReCaptcha website') ?></a></p>
<?= Html::submitButton(Yii::t('easyii/install', 'Install'), ['class' => 'btn btn-lg btn-primary btn-block']) ?>
<?php ActiveForm::end(); ?>
<?= $this->render('_form', ['model' => $model])?>
</div>
</div>
<div class="text-center">
Expand Down

0 comments on commit 065edd8

Please sign in to comment.