Example #1
2
 public function init()
 {
     parent::init();
     $session = \Yii::$app->session;
     $flashes = $session->getAllFlashes();
     $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
     foreach ($flashes as $type => $data) {
         //TOAST
         if (strpos($type, 'toast') !== false) {
             if (isset($this->toastTypes[$type])) {
                 $data = (array) $data;
                 foreach ($data as $i => $message) {
                     /* initialize css class for each alert box */
                     $tipo = $this->toastTypes[$type];
                     Toast::widget(['tipo' => $tipo, 'mensaje' => $message]);
                 }
                 $session->removeFlash($type);
             }
         } else {
             if (isset($this->alertTypes[$type])) {
                 $data = (array) $data;
                 foreach ($data as $i => $message) {
                     //echo '<pre>';print_r($i);die();
                     /* initialize css class for each alert box */
                     $this->options['class'] = $this->alertTypes[$type] . $appendCss;
                     /* assign unique id to each alert box */
                     $this->options['id'] = $this->getId() . '-' . $type . '-' . $i;
                     echo \yii\bootstrap\Alert::widget(['body' => $message, 'closeButton' => $this->closeButton, 'options' => $this->options]);
                 }
                 $session->removeFlash($type);
             }
         }
     }
 }
Example #2
2
 public function api_form()
 {
     $model = new GuestbookModel();
     $settings = Yii::$app->getModule('admin')->activeModules['guestbook']->settings;
     ob_start();
     $form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/guestbook/send'])]);
     switch (Yii::$app->session->getFlash(GuestbookModel::FLASH_KEY)) {
         case 'success':
             $message = Yii::$app->getModule('admin')->activeModules['guestbook']->settings['preModerate'] ? Yii::t('easyii/guestbook/api', 'Message successfully sent and will be published after moderation') : Yii::t('easyii/guestbook/api', 'Message successfully added');
             echo Alert::widget(['options' => ['class' => 'alert-success'], 'body' => $message]);
             break;
         case 'error':
             echo Alert::widget(['options' => ['class' => 'alert-danger'], 'body' => Yii::t('easyii/guestbook/api', 'An error has occurred')]);
             break;
     }
     echo $form->field($model, 'name');
     if ($settings['enableTitle']) {
         echo $form->field($model, 'title');
     }
     echo $form->field($model, 'text')->textarea();
     if ($settings['enableCaptcha']) {
         echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className());
     }
     echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']);
     ActiveForm::end();
     return ob_get_clean();
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (Yii::$app instanceof Application) {
         $view = $this->getView();
         $session = Yii::$app->getSession();
         $flashes = $session->getAllFlashes();
         $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
         foreach ($flashes as $type => $data) {
             if (isset($this->alertTypes[$type])) {
                 $data = (array) $data;
                 foreach ($data as $i => $message) {
                     /* initialize css class for each alert box */
                     $this->options['class'] = $this->alertTypes[$type] . $appendCss;
                     /* assign unique id to each alert box */
                     $this->options['id'] = $this->getId() . '-' . $type . '-' . $i;
                     echo \yii\bootstrap\Alert::widget(['body' => $message, 'closeButton' => $this->closeButton, 'options' => $this->options]);
                     if ($this->delay > 0) {
                         $js = 'jQuery("#' . $this->options['id'] . '").fadeTo(' . $this->delay . ', 0.00, function() {
                             $(this).slideUp("slow", function() {
                                 $(this).remove();
                             });
                         });';
                         $view->registerJs($js);
                     }
                 }
                 $session->removeFlash($type);
             }
         }
     }
 }
Example #4
0
 public function init()
 {
     parent::init();
     $session = \Yii::$app->getSession();
     $flashes = $session->getAllFlashes();
     $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
     if (empty($flashes)) {
         return false;
     }
     foreach ($flashes as $type => $message) {
         //type check for more messages with the same type like "success-1"
         foreach ($this->alertTypes as $k => $t) {
             if (preg_match('/' . $k . '/', $type, $subpattern)) {
                 $type = $subpattern[0];
                 break;
             }
         }
         if (isset($this->alertTypes[$type])) {
             /* initialize css class for each alert box */
             $this->options['class'] = $this->alertTypes[$type] . $appendCss;
             /* assign unique id to each alert box */
             $this->options['id'] = $this->getId() . '-' . $type;
             echo '<div class="cakebake-accounts-alert">';
             echo \yii\bootstrap\Alert::widget(['body' => $message, 'closeButton' => $this->closeButton, 'options' => $this->options]);
             echo '</div>';
             $session->removeFlash($type);
         }
     }
 }
Example #5
0
    /**
     * Initializes the widget.
     */
    public function init()
    {
        parent::init();

        $session = \Yii::$app->getSession();
        $flashes = $session->getAllFlashes();
        $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';

        foreach ($flashes as $type => $data)
        {
            if (isset($this->alertTypes[$type]))
            {
                $data = (array)$data;

                foreach ($data as $i => $message)
                {
                    /* initialize css class for each alert box */
                    $this->options['class'] = $this->alertTypes[$type] . $appendCss;

                    /* assign unique id to each alert box */
                    $this->options['id'] = $this->getId() . '-' . $type . '-' . $i;

                    echo \yii\bootstrap\Alert::widget([
                        'body' => $message,
                        'closeButton' => $this->closeButton,
                        'options' => $this->options,
                    ]);
                }

                $session->removeFlash($type);
            }
        }
    }
Example #6
0
 public function run()
 {
     parent::init();
     $session = \Yii::$app->getSession();
     $flashes = $session->getAllFlashes();
     $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
     $alerts = '';
     foreach ($flashes as $type => $messages) {
         if (!isset($this->alertTypes[$type])) {
             /* initialize css class for each alert box */
             $type = self::FLASH_INFO;
         }
         if (!is_array($messages)) {
             $messages = [$messages];
         }
         foreach ($messages as $message) {
             $this->options['class'] = $this->alertTypes[$type] . $appendCss;
             /* assign unique id to each alert box */
             $this->options['id'] = $this->getId() . '-' . $type;
             $body = Html::tag('i', '', ['class' => 'fa fa-' . $this->alertIcons[$type]]) . $message;
             $alerts .= Alert::widget(['body' => $body, 'closeButton' => $this->closeButton, 'options' => $this->options]);
         }
         $session->removeFlash($type);
     }
     if ($alerts) {
         return strtr($this->template, ['{alerts}' => $alerts]);
     }
     return null;
 }
 /**
  * Deletes an existing ProjectManager model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($user_id)
 {
     Yii::$app->db->createCommand()->delete('project_manager', 'user_id =' . $user_id . '')->execute();
     Yii::$app->db->createCommand()->delete('user', 'id =' . $user_id . '')->execute();
     echo Alert::widget(['body' => 'El usuario se eliminó exitosamente!']);
     return $this->redirect(['index']);
 }
Example #8
0
 /**
  * @inheritdoc
  */
 protected function initOptions()
 {
     parent::initOptions();
     if ($this->closeButton !== false) {
         Html::addCssClass($this->options, 'alert-dismissable');
     }
 }
Example #9
0
 public function getAlert()
 {
     if ($this->success) {
         return Alert::widget(['options' => ['class' => 'alert-success'], 'body' => 'Congratulations!!! Your password has been changed...']);
     } else {
         return null;
     }
 }
Example #10
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     Html::addCssClass($this->options, 'alert-' . $this->type);
     if ($this->block) {
         Html::addCssClass($this->options, 'alert-block');
     }
     parent::init();
 }
Example #11
0
 public function run()
 {
     $result = [];
     foreach (\Yii::$app->session->getAllFlashes() as $key => $message) {
         $result[] = \yii\bootstrap\Alert::widget(['options' => ['class' => 'alert-' . ($key == 'error' ? 'danger' : $key)], 'body' => implode("<hr />", (array) $message)]);
     }
     return implode('', $result);
 }
 /**
  * @param $options
  * @return string
  */
 public function getNotification($options)
 {
     $options['class'] = $this->alertTypes[$this->type]['class'];
     $msg = BootstrapAlert::widget(['body' => $this->alertTypes[$this->type]['icon'] . ' ' . $this->getMessageWithTitle(), 'options' => $options]);
     $msg = Json::encode($msg);
     $msg = trim($msg, '"');
     $id = $this->getLayerId();
     return "\$('#{$id}').append('{$msg}');";
 }
Example #13
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     foreach ($this->model->getErrors() as $attribute => $messages) {
         foreach ($messages as $key => $message) {
             $this->options['id'] = 'error-' . $attribute . '-' . $key;
             echo \yii\bootstrap\Alert::widget(['body' => $message, 'closeButton' => $this->closeButton, 'options' => $this->options]);
         }
     }
 }
Example #14
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $session = Yii::$app->getSession();
     foreach ($session->getAllFlashes() as $type => $message) {
         $this->options['class'] = ArrayHelper::getValue($this->alertTypes, $type, $this->alertTypes['info']);
         $this->options['id'] = $this->getId() . '-' . $type;
         echo \yii\bootstrap\Alert::widget(['body' => $message, 'closeButton' => $this->closeButton, 'options' => $this->options]);
         $session->removeFlash($type);
     }
 }
Example #15
0
 public function run()
 {
     foreach ($this->getAlerts() as $alert) {
         if (isset($this->options['class'])) {
             Html::addCssClass($this->options, 'alert');
             Html::addCssClass($this->options, 'alert-' . $alert['type']);
         } else {
             $this->options['class'] = 'alert alert-' . $alert['type'];
         }
         echo \yii\bootstrap\Alert::widget(['closeButton' => $this->closeButton, 'options' => $this->options, 'body' => $alert['body']]);
     }
 }
Example #16
0
 public function run()
 {
     foreach (Yii::$app->session->getAllFlashes() as $type => $message) {
         if (!in_array($type, ['success', 'danger', 'error', 'warning', 'info'])) {
             $type = 'info';
         }
         $alertType = 'alert-' . $type;
         if (is_array($message)) {
             $message = array_pop($message);
         }
         echo Alert::widget(['options' => ['class' => "alert {$alertType} {$this->alertClass}"], 'body' => $message]);
     }
 }
Example #17
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     try {
         if (!$this->hasModel()) {
             throw new Exception(\Yii::t('skeeks/cms', "Current widget works only in form with model"));
         }
         if ($this->model->isNewRecord) {
             throw new Exception(\Yii::t('skeeks/cms', "The image can be downloaded after you save the form data"));
         }
         echo $this->render('storage-image', ['model' => $this->model, 'widget' => $this]);
     } catch (\Exception $e) {
         echo Alert::widget(['options' => ['class' => 'alert-warning'], 'body' => $e->getMessage()]);
     }
 }
Example #18
0
 public function init()
 {
     parent::init();
     $session = Yii::$app->getSession();
     $flashes = $session->getAllFlashes();
     $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
     foreach ($flashes as $type => $message) {
         /* initialize css class for each alert box */
         $this->options['class'] = 'alert-' . $this->alertTypes[$type] . $appendCss;
         /* assign unique id to each alert box */
         $this->options['id'] = $this->getId() . '-' . $type;
         echo Alert::widget(['type' => $type, 'body' => $message, 'closeButton' => $this->closeButton, 'options' => $this->options]);
         $session->removeFlash($type);
     }
 }
Example #19
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
     echo Html::beginTag('div', $this->options);
     foreach ($this->flashes as $flashName => $alert) {
         if (Yii::$app->session->hasFlash($flashName)) {
             $header = '';
             if ($this->showHeader) {
                 $header = Html::tag('h4', (isset($alert['icon']) ? new Icon($alert['icon']) . '&nbsp;' : '') . $alert['header']);
             }
             echo Alert::widget(['body' => $header . Yii::$app->session->getFlash($flashName), 'options' => ['class' => 'alert alert-' . $alert['class']]]);
         }
     }
     echo Html::endTag('div');
 }
Example #20
0
 public static function showAlerts()
 {
     foreach (Yii::$app->getSession()->allFlashes as $type => $message) {
         switch ($type) {
             case 'error':
                 $type = 'danger';
                 break;
             default:
                 $exploded = explode('-', $type);
                 if (count($exploded) > 1) {
                     $type = $exploded[0];
                 }
                 break;
         }
         echo Alert::widget(['options' => ['class' => 'alert-' . $type], 'body' => $message]);
     }
 }
Example #21
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     try {
         if (!$this->hasModel()) {
             throw new Exception(\Yii::t('app', "Current widget works only in form with model"));
         }
         if ($this->model->isNewRecord) {
             throw new Exception(\Yii::t('app', "Images can be downloaded after you save the form data"));
         }
         if (!$this->model->hasProperty($this->attribute)) {
             throw new Exception("Relation {$this->attribute} не найдена");
         }
         echo $this->render('model-storage-files', ['model' => $this->model, 'widget' => $this]);
     } catch (\Exception $e) {
         echo Alert::widget(['options' => ['class' => 'alert-warning'], 'body' => $e->getMessage()]);
     }
 }
Example #22
0
 /**
  * Initializes the widget.
  * This method will register the bootstrap asset bundle. If you override this method,
  * make sure you call the parent implementation first.
  */
 public function init()
 {
     parent::init();
     $session = \Yii::$app->getSession();
     $flashes = $session->getAllFlashes();
     $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
     foreach ($flashes as $type => $data) {
         if (isset($this->alertTypes[$type])) {
             $data = (array) $data;
             foreach ($data as $message) {
                 $this->options['class'] = $this->alertTypes[$type]['class'] . $appendCss;
                 $this->options['id'] = $this->getId() . '-' . $type;
                 echo BootstrapAlert::widget(['body' => $this->alertTypes[$type]['icon'] . $message, 'closeButton' => $this->closeButton, 'options' => $this->options]);
             }
             $session->removeFlash($type);
         }
     }
 }
    public function renderConfigForm(ActiveForm $activeForm)
    {
        echo $activeForm->field($this, 'isLive')->checkbox();
        echo $activeForm->field($this, 'shop_password');
        echo $activeForm->field($this, 'security_type');
        echo $activeForm->field($this, 'shop_id');
        echo $activeForm->field($this, 'scid');
        echo $activeForm->field($this, 'payment_type');
        echo Alert::widget(['options' => ['class' => 'alert-info'], 'body' => <<<HTML
<a target="_blank" href="https://tech.yandex.ru/money/doc/payment-solution/shop-config/intro-docpage/">Подключение магазина</a><br />
В настройках вашего магазина на yandex укажите: <br />
Укажите checkUrl: /shop/yandex-kassa/check-order<br />
Укажите avisoUrl: /shop/yandex-kassa/payment-aviso<br />
<hr />
<a target="_blank" href="https://tech.yandex.ru/money/doc/payment-solution/examples/examples-test-data-docpage/">Тестовые данные</a><br />
HTML
]);
    }
Example #24
0
    public function run()
    {
        $this->view->registerCss(<<<CSS
.alert-wrap {
    padding-top: 10px;
}
.alert-wrap :last-child{
    margin-bottom: 0;
}
CSS
);
        $content = [];
        $flashes = Yii::$app->session->getAllFlashes(true);
        foreach ($flashes as $key => $flash) {
            $content[] = Alert::widget(['body' => $flash, 'options' => ['class' => 'alert-' . $key]]);
        }
        if (count($content)) {
            return Html::tag('div', implode(PHP_EOL, $content), ['class' => 'alert-wrap']);
        }
    }
 public function init()
 {
     parent::init();
     $this->getView()->registerJs("window.setTimeout(function() { \$(\".alert\").fadeTo(1500, 0).slideUp(500, function(){ \$(this).remove(); }); }, 5000);");
     $session = \Yii::$app->getSession();
     $flashes = $session->getAllFlashes();
     $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
     foreach ($flashes as $type => $data) {
         if (isset($this->alertTypes[$type])) {
             $data = (array) $data;
             foreach ($data as $i => $message) {
                 /* initialize css class for each alert box */
                 $this->options['class'] = $this->alertTypes[$type] . $appendCss;
                 /* assign unique id to each alert box */
                 $this->options['id'] = $this->getId() . '-' . $type . '-' . $i;
                 echo \yii\bootstrap\Alert::widget(['body' => $message, 'closeButton' => $this->closeButton, 'options' => $this->options]);
             }
             $session->removeFlash($type);
         }
     }
 }
Example #26
0
 public function init()
 {
     parent::init();
     $session = \Yii::$app->getSession();
     $flashes = $session->getAllFlashes();
     $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
     $alerts = '';
     foreach ($flashes as $type => $message) {
         if (isset($this->alertTypes[$type])) {
             /* initialize css class for each alert box */
             $this->options['class'] = $this->alertTypes[$type] . $appendCss;
             /* assign unique id to each alert box */
             $this->options['id'] = $this->getId() . '-' . $type;
             $body = Icons::p($this->alertIcons[$type], ['class' => 'icon']) . $message;
             $alerts .= Alert::widget(['body' => $body, 'closeButton' => $this->closeButton, 'options' => $this->options]);
             $session->removeFlash($type);
         }
     }
     if ($alerts) {
         echo strtr($this->template, ['{alerts}' => $alerts]);
     }
 }
 public function run()
 {
     if (Yii::$app->request->isPost && Yii::$app->request->validateCsrfToken()) {
         try {
             $messages = Yii::$app->request->post('messages');
             foreach ($messages as $idLanguage => $message) {
                 if ($message) {
                     list($id, $language) = explode('::', $idLanguage);
                     Message::updateAll(['translation' => $message], 'id = :id AND language = :language', [':id' => $id, ':language' => $language]);
                 }
             }
             $class = 'success';
             $body = 'Cообщения успешно переведены!';
         } catch (Exception $e) {
             $class = 'danger';
             $body = 'Произошла ошибка!' . (YII_DEBUG ? ' код: <b>' . $e->getCode() . '</b>, имя: <b>' . $e->getName() . '</b>, сообщение: <b>' . $e->getMessage() . '</b>' : '');
         } catch (\Exception $e) {
             $class = 'danger';
             $body = 'Произошла ошибка!' . (YII_DEBUG ? ' код: <b>' . $e->getCode() . '</b>, имя: <b>' . $e->getName() . '</b>, сообщение: <b>' . $e->getMessage() . '</b>' : '');
         }
         return Alert::widget(['body' => $body, 'options' => ['class' => 'alert-' . $class]]);
     }
 }
Example #28
0
 public function init()
 {
     parent::init();
     $session = \Yii::$app->getSession();
     $flashes = $session->getAllFlashes();
     if (!empty($flashes)) {
         $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
         $reflectionClass = new \ReflectionClass('common\\widgets\\Alert');
         $alertTypes = $reflectionClass->getConstants();
         foreach ($flashes as $type => $data) {
             if (in_array($type, $alertTypes)) {
                 $data = (array) $data;
                 foreach ($data as $i => $message) {
                     /* initialize css class for each alert box */
                     $this->options['class'] = 'alert-' . $type . $appendCss;
                     /* assign unique id to each alert box */
                     $this->options['id'] = $this->getId() . '-' . $type . '-' . $i;
                     echo \yii\bootstrap\Alert::widget(['body' => is_array($message) ? $this->flatten($message) : $message, 'closeButton' => $this->closeButton, 'options' => $this->options]);
                 }
                 $session->removeFlash($type);
             }
         }
     }
 }
Example #29
0
<?php

use yii\helpers\Url;
use yii\bootstrap\Alert;
?>
            
        <!-- begin #content -->
        <div id="content" class="content">
        <?php 
if (Yii::$app->getSession()->hasFlash('success')) {
    echo Alert::widget(['options' => ['class' => 'alert-success'], 'body' => Yii::$app->getSession()->getFlash('success')]);
}
if (Yii::$app->getSession()->hasFlash('error')) {
    echo Alert::widget(['options' => ['class' => 'alert-error'], 'body' => Yii::$app->getSession()->getFlash('error')]);
}
?>
            <!-- begin breadcrumb -->
            <ol class="breadcrumb pull-right">
                <li><a href="javascript:;">Home</a></li>
                <li><a href="javascript:;">首页banner</a></li>
                <li class="active">轮播图列表</li>
            </ol>
            <!-- end breadcrumb -->
            <!-- begin page-header -->
            <h1 class="page-header">轮播图列表 <small>header small text goes here...</small></h1>
            <!-- end page-header -->
            
            <!-- begin row -->
            <div class="row">
                <!-- begin col-12 -->
                <div class="col-md-12">
Example #30
-1
 public function api_form()
 {
     $model = new FeedbackModel();
     $settings = Yii::$app->getModule('admin')->activeModules['feedback']->settings;
     ob_start();
     $form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/feedback/send'])]);
     switch (Yii::$app->session->getFlash(FeedbackModel::FLASH_KEY)) {
         case 'success':
             echo Alert::widget(['options' => ['class' => 'alert-success'], 'body' => Yii::t('easyii/feedback/api', 'Feedback send. We will answer you soon')]);
             break;
         case 'error':
             echo Alert::widget(['options' => ['class' => 'alert-danger'], 'body' => Yii::t('easyii/feedback/api', 'An error has occurred')]);
             break;
     }
     echo $form->field($model, 'name');
     echo $form->field($model, 'email')->input('email');
     if ($settings['enablePhone']) {
         echo $form->field($model, 'phone');
     }
     if ($settings['enableTitle']) {
         echo $form->field($model, 'title');
     }
     echo $form->field($model, 'text')->textarea();
     if ($settings['enableCaptcha']) {
         echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className());
     }
     echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']);
     ActiveForm::end();
     return ob_get_clean();
 }