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


PHP Widget::init方法代码示例

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


在下文中一共展示了Widget::init方法的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: init

 public function init()
 {
     parent::init();
     // $session = \Yii::$app->getSession();
     // $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
     $this->line = in_array($this->line, $this->lineType) ? $this->line : 'horizontal';
 }
开发者ID:kdes70,项目名称:hotel.lok,代码行数:7,代码来源:BlogFeed.php

示例3: init

 public function init()
 {
     parent::init();
     $session = \Yii::$app->session;
     $flashes = $session->getAllFlashes();
     $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
     $this->options['placement'] ?? 'top';
     foreach ($flashes as $type => $data) {
         if (isset($this->alertTypes[$type])) {
             $data = (array) $data;
             foreach ($data as $i => $message) {
                 if ($type == 'error') {
                     $type = 'warning';
                 }
                 $this->options['type'] = $type;
                 $this->options['icon'] = $this->alertTypes[$type];
                 if (is_array($message)) {
                     $message = implode($message, '<br>');
                 }
                 unset($this->options['id'], $this->options['class']);
                 $this->createJs($message, $this->options);
             }
             $session->removeFlash($type);
         }
     }
 }
开发者ID:yangshihe,项目名称:yii2-zui,代码行数:26,代码来源:Alert.php

示例4: 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

示例5: init

 public function init()
 {
     parent::init();
     $boxClassNames = ['box'];
     $boxClassNames[] = 'box-' . $this->style;
     if ($this->solid) {
         $boxClassNames[] = 'box-solid';
     }
     $opt = Html::beginTag('div', ['class' => implode(' ', $boxClassNames)]);
     // header
     $opt .= Html::beginTag('div', ['class' => 'box-header with-border']);
     $opt .= Html::tag('h3', $this->title, ['class' => 'box-title']);
     if (count($this->tools) > 0) {
         $predefinedBtns = ['collapse' => Html::button(Html::icon('minus'), ['class' => 'btn btn-box-tool', 'title' => '折叠', 'data' => ['widget' => 'collapse', 'toggle' => 'tooltip']]), 'remove' => Html::button(Html::icon('times'), ['class' => 'btn btn-box-tool', 'title' => '移除', 'data' => ['widget' => 'remove', 'toggle' => 'tooltip']])];
         for ($i = 0; $i < count($this->tools); $i++) {
             $alias = $this->tools[$i];
             if (isset($predefinedBtns[$alias])) {
                 $this->tools[$i] = $predefinedBtns[$alias];
             }
         }
         $opt .= Html::beginTag('div', ['class' => 'box-tools pull-right']);
         $opt .= implode('', $this->tools);
         $opt .= Html::endTag('div');
     }
     $opt .= Html::endTag('div');
     // body
     $opt .= Html::beginTag('div', ['class' => 'box-body']);
     echo $opt;
 }
开发者ID:drodata,项目名称:yii2-utility,代码行数:29,代码来源:Box.php

示例6: init

 /**
  *
  */
 public function init()
 {
     parent::init();
     $columns = [];
     foreach ($this->columns as $columnConfiguration) {
         if (!$this->sortAction) {
             unset($columnConfiguration['orderBy']);
         }
         if (!isset($columnConfiguration['orderBy'])) {
             $columnConfiguration['columnType'] = 'simple';
         } else {
             // Tri demandé
             $columnConfiguration['columnType'] = 'sort';
             if ($this->sortClausesSessionKey) {
                 if (!isset($columnConfiguration['iconType'])) {
                     $columnConfiguration['iconType'] = 'alphabet';
                 }
             }
         }
         if (!isset($columnConfiguration['cssClass'])) {
             $columnConfiguration['cssClass'] = '';
         }
         $columns[] = $columnConfiguration;
     }
     $this->columns = $columns;
 }
开发者ID:ChristopheBrun,项目名称:hLib,代码行数:29,代码来源:GridListHeader.php

示例7: init

 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     echo Html::beginTag('div', ['class' => 'modal fade', 'id' => $this->modalId, 'role' => "dialog"]);
     echo Html::beginTag('div', ['class' => 'modal-dialog ' . $this->modalSize]);
     echo Html::beginTag('div', ['class' => 'modal-content']);
     echo Html::beginTag('div', ['class' => 'modal-header']);
     echo Html::beginTag('button', ['type' => "button", 'class' => "close", 'data-dismiss' => "modal"]);
     echo Html::beginTag('span', ['aria-hidden' => "true"]);
     echo "&times;";
     echo Html::endTag('span');
     echo Html::beginTag('span', ['class' => "sr-only"]);
     echo "Close";
     echo Html::endTag('span');
     echo Html::endTag('button');
     echo Html::beginTag('h4', ['class' => "modal-title"]);
     echo Html::endTag('h4');
     echo Html::endTag('div');
     echo Html::beginTag('div', ['class' => 'modal-body']);
     echo Html::beginTag('div', ['class' => 'content', 'style' => 'overflow:auto;']);
     echo Html::endTag('div');
     echo Html::endTag('div');
     /* modal-footer tak hapus. Kayaknya ga pernah kepake. Biar tampilan modalnya bagus, ga ada garis bawah pengganggu
     			echo Html::beginTag('div', ['class'=>'modal-footer']);
     		
     			echo Html::endTag('div');*/
     echo Html::endTag('div');
     echo Html::endTag('div');
     echo Html::endTag('div');
     if ($this->registerAsset) {
         ModalAsset::register($this->getView());
     }
 }
开发者ID:hscstudio,项目名称:yii2-heart,代码行数:36,代码来源:Modal.php

示例8: init

 public function init()
 {
     if ($this->mappingCategoryId == false && !empty(Yii::$app->MappingComponent->updateMappingCategory)) {
         $this->mappingCategoryId = Yii::$app->MappingComponent->updateMappingCategory;
     }
     parent::init();
 }
开发者ID:skamnev,项目名称:members,代码行数:7,代码来源:MappingWidget.php

示例9: init

 public function init()
 {
     parent::init();
     foreach (\Yii::$app->session->getAllFlashes() as $key => $type) {
         echo Html::tag('div', Html::tag('p', \Yii::$app->params[$key]), ['class' => 'alert ' . $this->msgTypes[$type]]);
     }
 }
开发者ID:george-rabeshko,项目名称:om.yii,代码行数:7,代码来源:Alert.php

示例10: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->model === null) {
         throw new InvalidConfigException('The "model" property must be set.');
     }
 }
开发者ID:frenzelgmbh,项目名称:cm-address,代码行数:10,代码来源:MapWidget.php

示例11: 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

示例12: 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

示例13: init

 public function init()
 {
     parent::init();
     // TODO: Change the autogenerated stub
     $this->pluginOptions = array_replace($this->pluginOptions, ['uploadUrl' => Url::toRoute('/attachments/file/upload'), 'initialPreview' => $this->model->isNewRecord ? [] : $this->model->getInitialPreview(), 'initialPreviewConfig' => $this->model->isNewRecord ? [] : $this->model->getInitialPreviewConfig()]);
     $this->options = array_replace($this->options, ['id' => $this->id, 'multiple' => true]);
 }
开发者ID:phpsong,项目名称:ExtJS5-Yii2,代码行数:7,代码来源:AttachmentsInput.php

示例14: init

 public function init()
 {
     if (!isset($this->clientOptions['room'])) {
         throw new ErrorException('Need set room name to Sidecar::widget()');
     }
     parent::init();
 }
开发者ID:bookin,项目名称:yii2-sidecar-gitter,代码行数:7,代码来源:Sidecar.php

示例15: 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


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