当前位置: 首页>>代码示例>>PHP>>正文


PHP bootstrap\Alert类代码示例

本文整理汇总了PHP中yii\bootstrap\Alert的典型用法代码示例。如果您正苦于以下问题:PHP Alert类的具体用法?PHP Alert怎么用?PHP Alert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Alert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 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);
             }
         }
     }
 }
开发者ID:alejandrososa,项目名称:AB,代码行数:34,代码来源:Alert.php

示例2: api_form

 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();
 }
开发者ID:radiegtya,项目名称:easyii,代码行数:27,代码来源:Guestbook.php

示例3: init

 /**
  * @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);
             }
         }
     }
 }
开发者ID:vladdnepr,项目名称:yii2-ycm,代码行数:34,代码来源:Alert.php

示例4: init

 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);
         }
     }
 }
开发者ID:cakebake,项目名称:yii2-accounts,代码行数:29,代码来源:Alert.php

示例5: init

    /**
     * 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);
            }
        }
    }
开发者ID:navedsh,项目名称:yii2-advanced-template,代码行数:36,代码来源:Alert.php

示例6: run

 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;
 }
开发者ID:maddoger,项目名称:yii2-admin,代码行数:29,代码来源:Alerts.php

示例7: actionDelete

 /**
  * 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']);
 }
开发者ID:RomarioLopezC,项目名称:RobotSS,代码行数:13,代码来源:ProjectManagerController.php

示例8: getAlert

 public function getAlert()
 {
     if ($this->success) {
         return Alert::widget(['options' => ['class' => 'alert-success'], 'body' => 'Congratulations!!! Your password has been changed...']);
     } else {
         return null;
     }
 }
开发者ID:fnoorman,项目名称:dev,代码行数:8,代码来源:ChangePasswordForm.php

示例9: run

 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);
 }
开发者ID:bariew,项目名称:yii2-tools,代码行数:8,代码来源:Alert.php

示例10: getNotification

 /**
  * @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}');";
 }
开发者ID:loveorigami,项目名称:yii2-notification-wrapper,代码行数:13,代码来源:Alert.php

示例11: run

 /**
  * @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]);
         }
     }
 }
开发者ID:zelenin,项目名称:yii2-widgets,代码行数:12,代码来源:Error.php

示例12: run

 /**
  * @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);
     }
 }
开发者ID:zelenin,项目名称:yii2-widgets,代码行数:13,代码来源:Alert.php

示例13: run

 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']]);
     }
 }
开发者ID:yiidoc,项目名称:yii2-flash,代码行数:12,代码来源:Alert.php

示例14: run

 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]);
     }
 }
开发者ID:ahb360,项目名称:yii2-admin360,代码行数:13,代码来源:FlashMessage.php

示例15: run

 /**
  * @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()]);
     }
 }
开发者ID:skeeks-cms,项目名称:cms,代码行数:17,代码来源:StorageImage.php


注:本文中的yii\bootstrap\Alert类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。