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


PHP Widget::run方法代码示例

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


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

示例1: run

 public function run()
 {
     if ($this->_pjax) {
         $this->_pjax->end();
     }
     parent::run();
 }
开发者ID:understeam,项目名称:yii2-ajax-dialog,代码行数:7,代码来源:DialogContainer.php

示例2: run

 /**
  * Initializes the widget.
  */
 public function run()
 {
     parent::run();
     if (isset($this->options['id'])) {
         $this->id = $this->options['id'];
     } else {
         if ($this->id === null) {
             $this->id = $this->options['id'] = $this->getId();
         } else {
             $this->options['id'] = $this->id;
         }
     }
     if (!isset($this->options['class'])) {
         $this->options['class'] = 'btn btn-primary';
     }
     $view = $this->getView();
     AssetButton::register($view);
     $label = $this->encodeLabel ? Html::encode($this->label) : $this->label;
     $spinnerTag = ArrayHelper::remove($this->spinnerOptions, 'tag', 'div');
     $spinnerWidth = ArrayHelper::remove($this->spinnerOptions, 'width', '15px');
     $spinnerHeight = ArrayHelper::remove($this->spinnerOptions, 'height', '15px');
     $spinnerContent = ArrayHelper::remove($this->spinnerOptions, 'content');
     Html::addCssClass($this->spinnerOptions, $this->spinnerClass);
     Html::addCssStyle($this->spinnerOptions, ['width' => $spinnerWidth, 'height' => $spinnerHeight]);
     $spinner = Html::tag($spinnerTag, $spinnerContent, $this->spinnerOptions);
     echo Html::tag($this->tagName, strtr($this->template, ['{spinner}' => $spinner, '{label}' => $label, '{id}' => $this->id]), $this->options);
     if (!empty($this->ajaxOptions)) {
         $this->registerScript($view);
     }
 }
开发者ID:pavlinter,项目名称:yii2-buttons,代码行数:33,代码来源:AjaxButton.php

示例3: run

 public function run()
 {
     parent::run();
     AddToHomescreenAsset::register($this->getView());
     $options = json_encode($this->settings);
     $this->getView()->registerJs("addToHomescreen({$options});", View::POS_READY);
 }
开发者ID:drsdre,项目名称:yii2-add-to-homescreen,代码行数:7,代码来源:AddToHomescreenWidget.php

示例4: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::run();
     if (!is_null($this->objectModel)) {
         $groupedRatingValues = RatingValues::getValuesByObjectModel($this->objectModel);
         if (!empty($groupedRatingValues)) {
             $groups = [];
             foreach ($groupedRatingValues as $groupId => $group) {
                 $ratingItem = RatingItem::findById($groupId);
                 $groups[] = ['name' => !is_null($ratingItem) ? $ratingItem->name : Yii::t('app', 'Unknown rating'), 'rating' => call_user_func($this->calcFunction, $group), 'votes' => count($group)];
             }
         } else {
             $groups = null;
         }
         return $this->render($this->viewFile, ['groups' => $groups]);
     } elseif (!is_null($this->reviewModel)) {
         $value = RatingValues::findOne(['rating_id' => $this->reviewModel->rating_id]);
         $groups = [];
         $ratingItem = RatingItem::findById(ArrayHelper::getValue($value, 'rating_item_id', 0));
         $group = [ArrayHelper::getValue($value, 'value')];
         $groups[] = ['name' => !is_null($ratingItem) ? $ratingItem->name : Yii::t('app', 'Unknown rating'), 'rating' => call_user_func($this->calcFunction, $group)];
         return $this->render($this->viewFile, ['groups' => $groups]);
     } else {
         return '';
     }
 }
开发者ID:flarmn,项目名称:dotplant2,代码行数:29,代码来源:RatingShowWidget.php

示例5: run

 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $nodes = Advertising::find()->where(['position' => 'middle_center'])->limit(4)->all();
     return $this->render('AdsMiddleCenterWidget', ['nodes' => $nodes]);
 }
开发者ID:nguyentuansieu,项目名称:BioMedia,代码行数:7,代码来源:AdsMiddleCenterWidget.php

示例6: run

 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $nodes = Post::find()->where(['status' => 10])->limit(12)->all();
     return $this->render('FrontPostWidget', ['nodes' => $nodes]);
 }
开发者ID:nguyentuansieu,项目名称:BioMedia,代码行数:7,代码来源:FrontPostWidget.php

示例7: run

 public function run()
 {
     $model = new Comment();
     return $this->render('comment', ['model' => $model]);
     parent::run();
     // TODO: Change the autogenerated stub
 }
开发者ID:hawk56,项目名称:ymam,代码行数:7,代码来源:CommentWidget.php

示例8: run

 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $categories = $this->build();
     return $this->render('NavWidget', ['categories' => $categories]);
 }
开发者ID:nguyentuansieu,项目名称:OneCMS,代码行数:7,代码来源:NavWidget.php

示例9: run

 /**
  * Initializes the widget.
  */
 public function run()
 {
     parent::run();
     if (isset($this->options['id'])) {
         $this->id = $this->options['id'];
     } else {
         if ($this->id === null) {
             $this->id = $this->options['id'] = $this->getId();
         } else {
             $this->options['id'] = $this->id;
         }
     }
     if (!isset($this->options['class'])) {
         $this->options['class'] = 'btn btn-primary';
     }
     $this->mustBeSet('input');
     $this->mustBeSet('name');
     $this->mustBeSet('formSelector');
     if ($this->formSelector instanceof ActiveForm) {
         $this->formSelector = "#" . $this->formSelector->getId(false);
     }
     if (!is_array($this->input)) {
         $this->input = ['id' => $this->input];
     }
     if (!isset($this->input['type'])) {
         $this->input['type'] = 'hidden';
     }
     $view = $this->getView();
     $this->registerScript($view);
     $label = $this->encodeLabel ? Html::encode($this->label) : $this->label;
     echo Html::tag($this->tagName, $label, $this->options);
 }
开发者ID:pavlinter,项目名称:yii2-buttons,代码行数:35,代码来源:InputButton.php

示例10: run

 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $nodes = $this->getData();
     return $this->render('FrontVideoWidget', ['nodes' => $nodes]);
 }
开发者ID:nguyentuansieu,项目名称:BioMedia,代码行数:7,代码来源:FrontVideoWidget.php

示例11: run

 /**
  * @return string
  */
 public function run()
 {
     parent::run();
     if (null === $this->rootCategory) {
         return '';
     }
     $cacheKey = $this->className() . ':' . implode('_', [$this->viewFile, $this->rootCategory, null === $this->depth ? 'null' : intval($this->depth), intval($this->includeRoot), intval($this->fetchModels), intval($this->onlyNonEmpty), implode(',', $this->excludedCategories), \Yii::$app->request->url]) . ':' . json_encode($this->additional);
     if (false !== ($cache = \Yii::$app->cache->get($cacheKey))) {
         return $cache;
     }
     /** @var array|Category[] $tree */
     $tree = Category::getMenuItems(intval($this->rootCategory), $this->depth, boolval($this->fetchModels));
     if (true === $this->includeRoot) {
         if (null !== ($_root = Category::findById(intval($this->rootCategory)))) {
             $tree = [['label' => $_root->name, 'url' => Url::toRoute(['@category', 'category_group_id' => $_root->category_group_id, 'last_category_id' => $_root->id]), 'id' => $_root->id, 'model' => $this->fetchModels ? $_root : null, 'items' => $tree]];
         }
     }
     if (true === $this->onlyNonEmpty) {
         $_sq1 = (new Query())->select('main_category_id')->distinct()->from(Product::tableName());
         $_sq2 = (new Query())->select('category_id')->distinct()->from('{{%product_category}}');
         $_query = (new Query())->select('id')->from(Category::tableName())->andWhere(['not in', 'id', $_sq1])->andWhere(['not in', 'id', $_sq2])->all();
         $this->excludedCategories = array_merge($this->excludedCategories, array_column($_query, 'id'));
     }
     $tree = $this->filterTree($tree);
     $cache = $this->render($this->viewFile, ['tree' => $tree, 'fetchModels' => $this->fetchModels, 'additional' => $this->additional, 'activeClass' => $this->activeClass, 'activateParents' => $this->activateParents]);
     \Yii::$app->cache->set($cacheKey, $cache, 0, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Category::className()), ActiveRecordHelper::getCommonTag(Product::className())]]));
     return $cache;
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:31,代码来源:CategoriesList.php

示例12: run

 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $nodes = Product::find()->where(['status' => 10])->limit(3)->all();
     return $this->render('ProductBottomTopWidget', ['nodes' => $nodes]);
 }
开发者ID:nguyentuansieu,项目名称:BioMedia,代码行数:7,代码来源:ProductBottomTopWidget.php

示例13: run

 public function run()
 {
     parent::run();
     $assetBundle = DildenFeedbackAsset::register($this->view);
     $html2CanvasURL = $assetBundle->baseUrl . "/html2canvas.min.js";
     return $this->view->registerJs($this->renderWidget());
 }
开发者ID:AntoninSlejska,项目名称:Yii2-Feedback-Widget,代码行数:7,代码来源:DildenFeedback.php

示例14: run

    public function run()
    {
        HighchartsAsset::register($this->view);
        list($chart, $xAxis, $yAxis, $series) = $this->data;
        // problem was that the data in the series was wrong for the highcharts,
        // highcharts want the data in the series without qoutes, so i have two solutions
        // first solution
        $options = Json::encode(array_merge($chart, array('xAxis' => $xAxis), array('yAxis' => $yAxis), array('series' => $series)), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK);
        /*echo('$options<pre>');
        		print_r($options);
        		echo('</pre>');*/
        $js = <<<JS
\t\t<script type="text/javascript">
\t\t\t\$(function () { 
\t\t\t\t\$("<div></div>").attr('{$this->container['attr']}', '{$this->container['value']}').appendTo('{$this->wrapper}');
\t\t\t\t\$('#highcharts').highcharts({$options});
\t\t});
\t\t</script>
JS;
        return $js;
        // second solution
        /*$js = '<script type="text/javascript">';
        		$js .= '$(function () {';
        		
        		$js .= '$("<div></div>").attr(\''.$this->container['attr'].'\', \''.$this->container['value'].'\').appendTo(\''.$this->wrapper.'\');';
        		$js .= '$(\'#highcharts\').highcharts({';
        		$js .= 'chart: '.Json::encode($chart['chart']).',';
        		$js .= 'title: '.Json::encode($chart['title']).',';
        		$js .= 'xAxis: '.Json::encode($xAxis).',';
        		$js .= 'yAxis: '.Json::encode($yAxis).',';
        		
        		$series_keys = [];
        		foreach($series as $key => $serie){
        			$series_keys[$key] = [];
        			foreach($serie as $name => $value){
        				if('data' == $name){
        					$series_keys[$key][] = $name . ': [' . implode(',', $value) . ']';
        				}else {
        					$series_keys[$key][] = $name . ': '.Json::encode($value);
        				}
        			}
        		}
        		
        		$js_series = [];
        		foreach($series_keys as $key => $serie){
        			$js_series[$key] = implode(',', $serie);
        		}
        		
        		
        		$js .= 'series: [{';
        		$js .= implode('}, {', $js_series);
        		$js .= '}]';
        		
        		$js .= '});';
        		$js .= '});';
        		$js .= '</script>';
        		
        		return $js;*/
        parent::run();
    }
开发者ID:hvos234,项目名称:raspberrypi.home.website,代码行数:60,代码来源:HighchartsWidget.php

示例15: run

 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $nodes = Advertising::find()->where(['position' => 'top_center_left', 'status' => 10])->all();
     return $this->render('AdsTopCenterLeftWidget', ['nodes' => $nodes]);
 }
开发者ID:nguyentuansieu,项目名称:BioMedia,代码行数:7,代码来源:AdsTopCenterLeftWidget.php


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