For more details and usage information on Widget, see the guide article on widgets.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends Component, implements yii\base\ViewContextInterface
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->header) {
         $this->header = "<h2>" . Inflector::camel2words($this->model->formName()) . " change log:</h2>";
     }
 }
 public function init()
 {
     parent::init();
     if (!$this->items) {
         throw new InvalidConfigException(\Yii::t('front', 'No required parameter given') . ' - items');
     }
 }
 public function init()
 {
     parent::init();
     $view = $this->getView();
     $widgetId = $this->id;
     if (isset($this->gridSettings['iconSet']) && $this->gridSettings['iconSet'] === 'fontAwesome') {
         $useFontAwesome = true;
     } else {
         $useFontAwesome = false;
     }
     $this->jsonSettings = (YII_DEBUG ? JSON_PRETTY_PRINT : 0) | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK;
     $script = "jQuery(\"#jqGrid-{$widgetId}\").jqGrid({$this->prepareGridSettings($this->gridSettings)})";
     if ($this->enablePager) {
         $script .= PHP_EOL . ".navGrid('#jqGrid-pager-{$widgetId}', {$this->preparePagerSettings($this->pagerSettings)})";
     }
     if ($this->enableFilterToolbar) {
         $script .= PHP_EOL . ".filterToolbar({$this->prepareToolbarSettings($this->filterToolbarSettings)})";
     }
     if ($this->enableColumnChooser) {
         $buttonOptions = ['caption' => '', 'title' => new JsExpression('jQuery.jgrid.col.caption'), 'buttonicon' => $useFontAwesome ? 'fa fa-lg fa-fw fa-calculator' : 'ui-icon-calculator', 'onClickButton' => $this->enableHiddenColumnsOptimization ? new JsExpression("function() {\n                        jQuery(this).jqGrid('columnChooser', {\n                            done: function(perm) {\n                                if(perm) {\n                                    this.jqGrid('remapColumns', perm, true);\n                                    this.trigger('reloadGrid');\n                                }\n                            }\n                        });\n                    }") : new JsExpression("function(){jQuery(this).jqGrid('columnChooser');}")];
         $buttonOptions = Json::encode($buttonOptions, $this->jsonSettings);
         $script .= PHP_EOL . ".navButtonAdd('#jqGrid-pager-{$widgetId}', {$buttonOptions})";
     }
     if ($this->enableXMLExport) {
         $buttonOptions = ['caption' => '', 'title' => 'Export to Excel XML', 'buttonicon' => $useFontAwesome ? 'fa fa-file-excel-o' : 'ui-icon-document', 'onClickButton' => new JsExpression("function(){jQuery.jgrid.XMLExport('{$widgetId}', 'ExcelXML.xml');}")];
         $buttonOptions = Json::encode($buttonOptions, $this->jsonSettings);
         $script .= PHP_EOL . ".navButtonAdd('#jqGrid-pager-{$widgetId}', {$buttonOptions})";
     }
     $view->registerJs($script, $view::POS_READY);
     WidgetAsset::register($view);
 }
Beispiel #4
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $view = Yii::$app->getView();
     $this->registerAssets();
     $view->registerJs($this->getJs(), View::POS_END);
 }
Beispiel #5
0
 public function init()
 {
     parent::init();
     if ($this->title === null) {
         $this->title = 'title';
     }
 }
Beispiel #6
0
 public function init()
 {
     parent::init();
     if (!$this->rowViewPath) {
         $this->rowViewPath = '_row';
     }
 }
Beispiel #7
0
 public function init()
 {
     parent::init();
     if (empty($this->model)) {
         throw new InvalidConfigException('Required `model` param isn\'t set.');
     }
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if (!isset($this->options['class'])) {
         Html::addCssClass($this->options, 'dropdown');
     }
 }
Beispiel #9
0
 public function init()
 {
     parent::init();
     if (empty($this->title) || empty($this->num)) {
         throw new InvalidConfigException('SidePostTop config is error.');
     }
 }
 public function init()
 {
     parent::init();
     $this->_inputStr = '<div class="form-group">';
     if ($this->hasModel()) {
         $this->_inputStr .= Html::activeLabel($this->model, $this->attribute);
     } else {
         $this->_inputStr .= Html::label($this->name);
     }
     $this->_inputStr .= '<div id="' . Html::encode($this->name) . '" class="input-group date">';
     if ($this->hasModel()) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     if ($value !== null) {
         $value = Yii::$app->formatter->asDatetime($value);
     }
     $options = $this->options;
     $options['class'] = 'form-control';
     //$options['readonly'] = '';
     $options['value'] = $value;
     if ($this->hasModel()) {
         $this->_inputStr .= Html::activeTextInput($this->model, $this->attribute, $options);
     } else {
         $this->_inputStr .= Html::textInput($this->name, $this->value, $options);
     }
     $this->_inputStr .= '<span class="input-group-addon">
                                     <span class="glyphicon-calendar glyphicon"></span>
                                 </span>
                             </div>
                             </div>
                             ';
 }
 public function init()
 {
     parent::init();
     //        if(!$this->label || !is_array($this->config)){
     //            throw new Exception('缺少参数或参数缺失');
     //        }
 }
Beispiel #12
0
 public function init()
 {
     parent::init();
     if (empty($this->options)) {
         Html::addCssClass($this->options, ['horizontal-menu']);
     }
 }
Beispiel #13
0
 public function init()
 {
     parent::init();
     if (empty($this->view)) {
         $this->view = (new \ReflectionClass($this))->getShortName();
     }
 }
Beispiel #14
0
 public function init()
 {
     parent::init();
     if ($this->message == null) {
         throw new Exception('wrong message');
     }
 }
Beispiel #15
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 __construct($config = [])
 {
     parent::__construct($config);
     if (!$this->transaction instanceof OrderTransaction) {
         $this->transaction = new OrderTransaction();
     }
 }
 public function init()
 {
     parent::init();
     assert(isset($this->api));
     assert(isset($this->invoiceId));
     assert(isset($this->amount));
 }
Beispiel #18
0
 public function init()
 {
     parent::init();
     $pollDB = new PollDb();
     $this->isExist = $pollDB->isTableExists();
     if (count($this->isExist) == 0) {
         $pollDB->createTables();
     }
     if ($this->answerOptions !== null) {
         $this->answerOptionsData = serialize($this->answerOptions);
     }
     // crate DB TBOs if they do not exist for this poll
     if (!$pollDB->isPollExist($this->pollName)) {
         $this->setDbData();
     }
     // check that all Poll answers exist
     $pollDB->pollAnswerOptions($this);
     if (Yii::$app->request->isAjax) {
         if (isset($_POST['VoicesOfPoll'])) {
             if ($_POST['poll_name'] == $this->pollName && isset($_POST['VoicesOfPoll']['voice'])) {
                 $pollDB->updateAnswers($this->pollName, $_POST['VoicesOfPoll']['voice'], $this->answerOptions);
                 $pollDB->updateUsers($this->pollName);
             }
         }
     }
     $this->getDbData();
     $this->answers = $pollDB->getVoicesData($this->pollName);
     for ($i = 0; $i < count($this->answers); $i++) {
         $this->sumOfVoices = $this->sumOfVoices + $this->answers[$i]['value'];
     }
     $this->isVote = $pollDB->isVote($this->pollName);
 }
Beispiel #19
0
 /**
  * The method returns the view path for this widget if set while calling widget. 
  */
 public function getViewPath()
 {
     if (isset($this->templateDir)) {
         return $this->templateDir;
     }
     return parent::getViewPath();
 }
Beispiel #20
0
 public function init()
 {
     parent::init();
     if (empty($this->short_code)) {
         throw new InvalidConfigException('SideFragment config is error.');
     }
 }
Beispiel #21
0
 public function init()
 {
     $paramsArr = ['offerUrl' => $this->offerUrl, 'textButton' => $this->textButton, 'type' => $this->type, 'columns' => $this->columns, 'model' => $this->model, 'showTotal' => $this->showTotal, 'showOptions' => $this->showOptions, 'showOffer' => $this->showOffer, 'showTruncate' => $this->showTruncate, 'currency' => $this->currency, 'otherFields' => $this->otherFields, 'currencyPosition' => $this->currencyPosition, 'showCountArrows' => $this->showCountArrows];
     foreach ($paramsArr as $key => $value) {
         if ($value === 'false') {
             $this->{$key} = false;
         }
     }
     $this->getView()->registerJs("pistol88.cart.elementsListWidgetParams = " . json_encode($paramsArr));
     if ($this->type == NULL) {
         $this->type = self::TYPE_FULL;
     }
     if ($this->offerUrl == NULL) {
         $this->offerUrl = Url::toRoute(['/cart/default/index']);
     }
     if ($this->cart == NULL) {
         $this->cart = yii::$app->cart;
     }
     if ($this->textButton == NULL) {
         $this->textButton = yii::t('cart', 'Cart (<span class="pistol88-cart-price">{p}</span>)', ['c' => $this->cart->getCount(), 'p' => $this->cart->getCostFormatted()]);
     }
     if ($this->currency == NULL) {
         $this->currency = yii::$app->cart->currency;
     }
     if ($this->currencyPosition == NULL) {
         $this->currencyPosition = yii::$app->cart->currencyPosition;
     }
     \app\modules\cart\assets\WidgetAsset::register($this->getView());
     return parent::init();
 }
Beispiel #22
0
 public function init()
 {
     parent::init();
     if ($this->url === null) {
         throw new InvalidConfigException('Please specify the "model" property.');
     }
 }
 public function init()
 {
     parent::init();
     if (empty($this->language)) {
         $this->language = ElFinder::getSupportedLanguage(\Yii::$app->language);
     }
     if (empty($this->options['id'])) {
         $this->options['id'] = $this->getId();
     } else {
         $this->setId($this->options['id']);
     }
     $managerOptions = [];
     if (!empty($this->filter)) {
         $managerOptions['filter'] = $this->filter;
     }
     $managerOptions['callback'] = $this->getId() . "_manager";
     if (!empty($this->language)) {
         $managerOptions['lang'] = $this->language;
     }
     if (!empty($this->path)) {
         $managerOptions['path'] = $this->path;
     }
     $this->_managerOptions['url'] = ElFinder::getManagerUrl($this->controller, $managerOptions);
     $this->_managerOptions['width'] = $this->width;
     $this->_managerOptions['height'] = $this->height;
     $this->_managerOptions['id'] = $managerOptions['callback'];
 }
 /**
  * Initializes the widget.
  *
  * @throws InvalidConfigException if the "selector" property is not set.
  */
 public function init()
 {
     parent::init();
     if (empty($this->selector)) {
         throw new InvalidConfigException('The "selector" property must be set.');
     }
 }
 public function init()
 {
     parent::init();
     if ($this->postID === null) {
         throw new InvalidConfigException('PostID cannot be null !');
     }
 }
Beispiel #26
0
 public function init()
 {
     parent::init();
     if ($this->page == 'index') {
         if ($this->cat == 'all' or $this->cat == null) {
             $query = Logotypes::find()->limit(15);
         } else {
             $query_cat = new Query();
             $query_cat->select('id')->from('category')->where(['name' => $this->cat]);
             $cat_id = $query_cat->all()[0]['id'];
             $query = Logotypes::find()->limit(15)->where(['category' => $cat_id]);
         }
         $logos = $query->all();
         shuffle($logos);
     } else {
         if ($this->cat == 'all' or $this->cat == null) {
             $query = Logotypes::find();
         } else {
             $query_cat = new Query();
             $query_cat->select('id')->from('category')->where(['name' => $this->cat]);
             $cat_id = $query_cat->all()[0]['id'];
             $query = Logotypes::find()->where(['category' => $cat_id]);
         }
         $countQuery = clone $query;
         $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 15]);
         $logos = $query->offset($pages->offset)->limit($pages->limit)->all();
         $this->pages = $pages;
     }
     $this->logos = $logos;
 }
 public function init()
 {
     if (!$this->dateStop) {
         $this->dateStop = date('Y-m-d H:i:s');
     }
     return parent::init();
 }
 public function init()
 {
     parent::init();
     // Exception IF params -> languages not defined
     if (!isset(Yii::$app->params['languages'])) {
         throw new \yii\base\InvalidConfigException("You must define Yii::\$app->params['languages'] array");
     }
     // Widget Type
     if (!$this->widget_type) {
         $this->widget_type = 'classic';
     } else {
         $this->widget_type = $this->widget_type;
     }
     // Image Type
     if (!$this->image_type) {
         $this->image_type = 'classic';
     } else {
         $this->image_type = $this->image_type;
     }
     // Widget Type
     if (!$this->width) {
         $this->width = '24';
     } else {
         $this->width = $this->width;
     }
 }
Beispiel #29
0
 /**
  * Initializes the widget.
  * This method will register the materialize asset bundle. If you override this method,
  * make sure you call the parent implementation first.
  */
 public function init()
 {
     parent::init();
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
 }
 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]);
 }