run() публичный Метод

Executes the widget.
public run ( ) : string
Результат string the result of widget execution to be outputted.
 public function run()
 {
     if ($this->_pjax) {
         $this->_pjax->end();
     }
     parent::run();
 }
Пример #2
0
 /**
  * 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);
     }
 }
 public function run()
 {
     parent::run();
     AddToHomescreenAsset::register($this->getView());
     $options = json_encode($this->settings);
     $this->getView()->registerJs("addToHomescreen({$options});", View::POS_READY);
 }
Пример #4
0
 /**
  * @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 '';
     }
 }
 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]);
 }
Пример #6
0
 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]);
 }
Пример #7
0
 public function run()
 {
     $model = new Comment();
     return $this->render('comment', ['model' => $model]);
     parent::run();
     // TODO: Change the autogenerated stub
 }
Пример #8
0
 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $categories = $this->build();
     return $this->render('NavWidget', ['categories' => $categories]);
 }
Пример #9
0
 /**
  * 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);
 }
Пример #10
0
 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $nodes = $this->getData();
     return $this->render('FrontVideoWidget', ['nodes' => $nodes]);
 }
Пример #11
0
 /**
  * @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;
 }
 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]);
 }
 public function run()
 {
     parent::run();
     $assetBundle = DildenFeedbackAsset::register($this->view);
     $html2CanvasURL = $assetBundle->baseUrl . "/html2canvas.min.js";
     return $this->view->registerJs($this->renderWidget());
 }
    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();
    }
 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]);
 }
Пример #16
0
 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $nodes = Advertising::findOne(['position' => 'right_top']);
     return $this->render('AdsRightTopWidget', ['nodes' => $nodes]);
 }
 public function run()
 {
     parent::run();
     echo Html::tag($this->tagName, $this->encodeLabel ? Html::encode($this->label) : $this->label, $this->options);
     if (!empty($this->ajaxOptions)) {
         $this->registerAjaxScript();
     }
 }
Пример #18
0
 /**
  * @inheritdoc
  * @return string
  */
 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     if (!empty($this->models)) {
         return $this->render('blogPost', ['models' => $this->models, 'title' => $this->title]);
     }
 }
Пример #19
0
 /**
  * Init
  */
 public function run()
 {
     if (!$this->enabled) {
         return;
     }
     $this->registerApi();
     parent::run();
 }
Пример #20
0
 public function run()
 {
     parent::run();
     $view = $this->getView();
     $options = empty($this->options) ? '[]' : Json::encode($this->options);
     ToastrAjaxFeedAsset::register($view);
     $view->registerJs('jQuery(document).ready( function() {' . 'setInterval(' . 'function(){' . 'ToastrAjaxFeed.getNotifications(\'' . $this->feedUrl . '\', ' . $options . ')' . '}' . ',' . $this->interval . ');} );');
 }
Пример #21
0
 public function run()
 {
     parent::run();
     error_log(print_r($this->action, true));
     $this->registerMetaTag(['keywords', 'This is a test']);
     //$model = BlogTerms::find()->orderBy('name')->all();
     //return $this->render('categories',['model' => $model,]);
 }
Пример #22
0
 public function run()
 {
     parent::run();
     if (!$this->order instanceof Order) {
         return '';
     }
     return $this->render($this->viewFile, ['list' => $this->list, 'order' => $this->order]);
 }
Пример #23
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::run();
     if (sizeof($this->projects)) {
         echo $this->renderList();
         $this->registerJs();
     }
 }
Пример #24
0
 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $advertingModel = new Advertising();
     $nodes = $advertingModel->find()->where(['position' => 'home_product'])->limit(10)->all();
     return $this->render('FrontProductWidget', ['nodes' => $nodes]);
 }
Пример #25
0
 /**
  * Запуск виджета
  */
 public function run()
 {
     $method = 'action' . $this->action;
     if (method_exists($this, $method)) {
         parent::run();
         return $this->{$method}();
     }
 }
Пример #26
0
 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $advertingModel = new Advertising();
     $nodes = $advertingModel->find()->where(['position' => 'slideshow'])->all();
     return $this->render('SlideshowWidget', ['nodes' => $nodes]);
 }
Пример #27
0
 /**
  * Executes the widget.
  * @return string the result of widget execution to be outputted.
  */
 public function run()
 {
     $view = $this->getView();
     LinkPreviewAsset::register($view);
     $options = $this->getClientOptions();
     $view->registerJs("\$('{$this->selector}').linkPreview({$options});", $view::POS_END);
     parent::run();
 }
Пример #28
0
 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $post = new Post();
     $dataPartner = $post->find('image')->where(['category_id' => 18])->all();
     return $this->render('widget/partner', ['nodes' => $dataPartner]);
 }
Пример #29
0
 public function run()
 {
     parent::run();
     TouchSpinAsset::register($this->view, \yii\web\View::POS_READY);
     if (empty($this->selector)) {
         $this->selector = '#' . $this->id;
     }
     $this->registerJs();
 }
 public function run()
 {
     parent::run();
     echo Html::beginTag('div', ['id' => 'mc-review-' . $this->_uid]);
     echo Html::beginTag('ul', ['id' => 'cackle-reviews-' . $this->_uid]);
     echo $this->list_reviews();
     echo Html::endTag('ul');
     echo Html::endTag('div');
 }