public function renderTitle($item)
 {
     $encode = ArrayHelper::getValue($this->titleOptions, 'encode', true);
     $title = Elements::icon('dropdown') . ($encode ? Html::encode($item['title']) : $item['title']);
     $options = $this->titleOptions;
     Html::addCssClass($options, 'title');
     if ($item['active']) {
         Html::addCssClass($options, 'active');
     }
     return Html::tag('div', $title, $options);
 }
 public function renderToggleButton($content, $options = [])
 {
     if (!isset($options['id'])) {
         $options['id'] = $this->getId() . '-button';
     }
     $this->getView()->registerJs('
     jQuery("#' . $options['id'] . '").on("click", function(event) {
         event.preventDefault();
         jQuery("#' . $this->getId() . '").modal("show");
     });
     ');
     return Elements::button($content, $options);
 }
 public function beforeAction(Event $event)
 {
     $controller = $event->sender->controller;
     if ($controller instanceof \yii\debug\controllers\DefaultController) {
         return false;
     }
     try {
         \Yii::$app->db->open();
     } catch (Exception $e) {
         \Yii::$app->session->setFlash('error', Elements::header(Elements::icon('warning sign') . ' Внимание! Отсутствует соединение с базой данных!'));
         echo $event->sender->controller->render('@app/views/site/warning', ['exception' => $e]);
         \Yii::$app->end();
     }
 }
            <?php 
echo $form->field($model, 'username', ['template' => "<div class='ui left icon input'>{label}\n{input}</div>\n{hint}\n{error}", 'parts' => ['{label}' => Elements::icon('user')]]);
?>
            <?php 
echo $form->field($model, 'password', ['template' => "<div class='ui left icon input'>{label}\n{input}</div>\n{hint}\n{error}", 'parts' => ['{label}' => Elements::icon('lock')]])->passwordInput(['placeholder' => $model->getAttributeLabel('password')]);
?>
            <?php 
echo $form->field($model, 'rememberMe')->checkbox();
?>
            <div style="color:#999;margin:1em 0">
                <?php 
echo Html::a(Elements::icon('help circle') . 'Забыли пароль?', ['/users/auth/recovery'], ['class' => 'ui red label']);
?>
                <?php 
echo Html::a(Elements::icon('add user') . 'Регистрация', ['/users/auth/signup'], ['class' => 'ui violet label']);
?>
            </div>
            <div class="ui buttons fluid">
                <?php 
echo Html::submitButton(Elements::icon('sign in') . 'Авторизация', ['class' => 'positive ui button', 'name' => 'login-button']);
?>
                <?php 
echo Html::resetButton(Elements::icon('refresh') . 'Очистить', ['class' => 'ui primary button', 'name' => 'reset-button']);
?>
            </div>
        </div>
        <?php 
ActiveForm::end();
?>
    </div>
</div>
 public function renderMenuPart($items)
 {
     if ($items) {
         $items = $this->normalizeItems($items, $hasActiveChild);
         $lines = '';
         foreach ($items as $i => $item) {
             Html::addCssClass($item['options'], 'item');
             if ($item['active']) {
                 Html::addCssClass($item['options'], 'active');
             }
             if (isset($item['items'])) {
                 Html::addCssClass($item['options'], 'ui simple dropdown');
                 $item['label'] = $item['label'] . Elements::icon('dropdown') . Html::tag('div', $this->renderMenuPart($item['items']), ['class' => 'menu']);
                 $menu = $this->renderItem($item);
             } else {
                 $menu = $this->renderItem($item);
             }
             $lines .= $menu;
         }
         return $lines;
     } else {
         return '';
     }
 }
 public function renderCloseButton($options = [])
 {
     if (!isset($options['id'])) {
         $options['id'] = $this->getId() . '-close-button';
     }
     $this->getView()->registerJs('
     jQuery("#' . $options['id'] . '").on("click", function(event) {
         jQuery("#' . $this->getId() . '").fadeOut();
     });
     ');
     return Elements::icon('close', $options);
 }
 /**
  * This method is used to register new user account. If Module::enableConfirmation is set true, this method
  * will generate new confirmation token and use mailer to send it to the user.
  * @return bool
  * @throws \Exception
  * @throws \yii\db\Exception
  */
 public function register()
 {
     if ($this->getIsNewRecord() == false) {
         throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
     }
     if ($this->module->enableConfirmation == false) {
         $this->confirmed_at = time();
     } else {
         $this->confirmation_sent_at = time();
         $this->confirmation_token = \Yii::$app->security->generateRandomString();
     }
     $this->trigger(self::EVENT_INIT_REGISTER);
     $transaction = Users::getDb()->beginTransaction();
     try {
         if ($this->save()) {
             $this->trigger(self::EVENT_DONE_REGISTER);
             \Yii::getLogger()->log("User '{$this->username}' has been registered", Logger::LEVEL_INFO);
             $transaction->commit();
             if ($this->module->enableConfirmation) {
                 if ($this->sendConfirmation()) {
                     Yii::$app->session->setFlash('success', Elements::header(Elements::icon('thumbs up') . 'Поздравляем! На ваш email отправлено письмо с дальнейшими инструкциями.'));
                 } else {
                     Yii::$app->session->setFlash('error', Elements::header(Elements::icon('warning sign') . 'Не удалось отправить письмо для подтверждения регистрации!'));
                     return false;
                 }
                 return true;
             }
             if ($this->module->enableAutoLogon) {
                 if ($this->login()) {
                     \Yii::$app->session->setFlash('success', Elements::header(Elements::icon('thumbs up') . 'Добро пожаловать! Вы были успешно зарегистрированы и авторизованы.'));
                 } else {
                     \Yii::$app->session->setFlash('error', Elements::header(Elements::icon('warning sign') . 'Не удалось войти в аккаунт!'));
                     return false;
                 }
                 return true;
             }
             \Yii::$app->session->setFlash('success', Elements::header(Elements::icon('thumbs up') . 'Поздравляем! Аккаунт успешно создан.'));
             return true;
         }
         Yii::$app->session->setFlash('error', Elements::header(Elements::icon('warning sign') . 'Внимание! При регистрации возникла ошибка!'));
         \Yii::getLogger()->log('An error occurred while registering user account', Logger::LEVEL_ERROR);
         return false;
     } catch (\Exception $e) {
         $transaction->rollBack();
         throw $e;
     }
 }
 /**
  * Displays page where user can reset password.
  *
  * @param $id
  * @param $token
  * @return string
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionReset($id, $token)
 {
     /* @var $user \users\models\Users */
     $model = new RecoveryForm(['scenario' => 'reset']);
     $user = Users::find()->where(['id' => $id, 'recovery_token' => $token])->one();
     if ($user === null || $user->getIsAttributePeriodExpired('recovery_sent_at')) {
         return $this->render('invalidToken');
     }
     if ($model->load(\Yii::$app->getRequest()->post())) {
         if ($user->resetPassword($model->password)) {
             \Yii::$app->session->setFlash('success', Elements::header(Elements::icon('thumbs up') . 'Поздравляем! Пароль успешно сброшен.'));
             return $this->render('resetFinish');
         } else {
             \Yii::$app->session->setFlash('error', Elements::header(Elements::icon('warning sign') . 'Не удалось сбросить пароль!'));
         }
     }
     return $this->render('resetPassword', ['model' => $model]);
 }
 public function renderInput()
 {
     return $this->input ?: Elements::input(Html::input('text', null, null, ['class' => 'prompt']));
 }
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \frontend\models\ResetPasswordForm */
$this->title = 'Сброс пароля';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="column" style="width: 40%;">
    <?php 
echo Html::tag('h2', Html::encode($this->title), ['class' => 'ui teal header']);
?>

    <div class="ui teal fluid label">Пожалуйста введите новый пароль:</div>

    <div class="ui segment">
        <?php 
$form = ActiveForm::begin(['id' => 'reset-password-form']);
?>
        <?php 
echo $form->field($model, 'password', ['template' => "<div class='ui left icon input'>{label}\n{input}</div>\n{hint}\n{error}", 'parts' => ['{label}' => Elements::icon('lock')]])->passwordInput(['placeholder' => $model->getAttributeLabel('password')]);
?>
        <div class="form-group">
            <?php 
echo Html::submitButton('Сбросить пароль', ['class' => 'ui fluid primary button', 'name' => 'login-button']);
?>
        </div>
        <?php 
ActiveForm::end();
?>
    </div>
</div>
<?php

/* @var $this yii\web\View */
use fourteenmeister\extensions\SemanticUI\Elements;
use yii\helpers\Html;
$this->title = 'Custom Yii 2 Advanced Project Template';
?>

<div class="ui middle aligned center aligned grid">
    <div class="column">
        <?php 
echo Html::tag('div', '<img class="image" src="/images/yii_logo.png"><div class="content">Поздравляем!</div>', ['class' => 'ui image header', 'style' => 'font-size: 50px; margin: 0;']);
?>
        <div class="ui header" style="margin: 0; font-size: 20px;">Вы успешно создали своё Yii2 приложение.</div>
        <?php 
echo Elements::buttonsGroup([Html::a('Начните с Yii2', 'http://www.yiiframework.com', ['class' => 'ui positive button', 'target' => '_blank']), Html::a('Проект на github', 'https://github.com/fourteenmeister/yii2-app-advanced', ['class' => 'ui primary button', 'target' => '_blank']), Html::a('Нашли ошибку?', 'https://github.com/fourteenmeister/yii2-app-advanced/issues', ['class' => 'ui negative button', 'target' => '_blank'])]);
?>
    </div>
</div>
<?php

/* @var $this \yii\web\View */
use fourteenmeister\extensions\SemanticUI\collections\Menu;
use fourteenmeister\extensions\SemanticUI\Elements;
echo Menu::widget(['id' => 'menu', 'items' => [['label' => Elements::icon('home') . 'Главная', 'url' => ['/site/index'], 'encode' => false], ['label' => Elements::icon('info circle') . 'О сайте', 'url' => ['/site/about'], 'encode' => false]], 'rightMenuItems' => [['label' => Yii::$app->user->isGuest ? Elements::icon('user') . 'Здравствуйте, <strong>гость</strong>' : Elements::icon('user') . 'Здравствуйте, <strong>' . \Yii::$app->user->identity->username . '</strong>', 'items' => [['label' => Elements::icon('settings') . 'Панель управления', 'url' => ['/admin/site/index'], 'encode' => false, 'visible' => Yii::$app->user->can('superuser')], ['label' => Elements::icon('sign in') . 'Войти', 'url' => ['/users/auth/login'], 'encode' => false, 'visible' => Yii::$app->user->isGuest], ['label' => Elements::icon('add user') . 'Регистрация', 'url' => ['/users/auth/signup'], 'encode' => false, 'visible' => Yii::$app->user->isGuest], ['label' => Elements::icon('sign out') . 'Выйти', 'url' => ['/users/auth/logout'], 'encode' => false, 'visible' => !Yii::$app->user->isGuest]], 'encode' => false, 'options' => ['style' => 'display: block;']]], 'options' => ['class' => 'top fixed small']]);