コード例 #1
3
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->header) {
         $this->header = "<h2>" . Inflector::camel2words($this->model->formName()) . " change log:</h2>";
     }
 }
コード例 #2
1
 public function init()
 {
     parent::init();
     if (!$this->items) {
         throw new InvalidConfigException(\Yii::t('front', 'No required parameter given') . ' - items');
     }
 }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
ファイル: Portlet.php プロジェクト: junctionaof/thanagornfarm
 public function init()
 {
     parent::init();
     ob_start();
     $this->portletId = \Yii::$app->params['portlets'] + 1;
     \Yii::$app->params['portlets'] = $this->portletId;
 }
コード例 #5
0
 public function init()
 {
     if (!$this->dateStop) {
         $this->dateStop = date('Y-m-d H:i:s');
     }
     return parent::init();
 }
コード例 #6
0
ファイル: RecentComments.php プロジェクト: funson86/yii2-blog
 public function init()
 {
     parent::init();
     if ($this->title === null) {
         $this->title = 'title';
     }
 }
コード例 #7
0
ファイル: PieChart.php プロジェクト: bsadnu/yii2-googlecharts
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $view = Yii::$app->getView();
     $this->registerAssets();
     $view->registerJs($this->getJs(), View::POS_END);
 }
コード例 #8
0
 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);
 }
コード例 #9
0
ファイル: MultiInput.php プロジェクト: mitalcoi/yii2-multi
 public function init()
 {
     parent::init();
     if (!$this->rowViewPath) {
         $this->rowViewPath = '_row';
     }
 }
コード例 #10
0
ファイル: SidePostTop.php プロジェクト: jorry2008/turen
 public function init()
 {
     parent::init();
     if (empty($this->title) || empty($this->num)) {
         throw new InvalidConfigException('SidePostTop config is error.');
     }
 }
コード例 #11
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if (!isset($this->options['class'])) {
         Html::addCssClass($this->options, 'dropdown');
     }
 }
コード例 #12
0
 public function init()
 {
     parent::init();
     //        if(!$this->label || !is_array($this->config)){
     //            throw new Exception('缺少参数或参数缺失');
     //        }
 }
コード例 #13
0
 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>
                             ';
 }
コード例 #14
0
ファイル: Menu.php プロジェクト: prawee/yii2-metroui
 public function init()
 {
     parent::init();
     if (empty($this->options)) {
         Html::addCssClass($this->options, ['horizontal-menu']);
     }
 }
コード例 #15
0
ファイル: Tree.php プロジェクト: quynhvv/stepup
 public function init()
 {
     parent::init();
     if (empty($this->view)) {
         $this->view = (new \ReflectionClass($this))->getShortName();
     }
 }
コード例 #16
0
 public function init()
 {
     parent::init();
     if ($this->message == null) {
         throw new Exception('wrong message');
     }
 }
コード例 #17
0
 public function init()
 {
     parent::init();
     assert(isset($this->api));
     assert(isset($this->invoiceId));
     assert(isset($this->amount));
 }
コード例 #18
0
ファイル: SeoForm.php プロジェクト: Brother-Simon/easyii
 public function init()
 {
     parent::init();
     if (empty($this->model)) {
         throw new InvalidConfigException('Required `model` param isn\'t set.');
     }
 }
コード例 #19
0
ファイル: Poll.php プロジェクト: davidjeddy/yii2poll
 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);
 }
コード例 #20
0
 public function init()
 {
     if ($this->_module == null) {
         $this->_module = Yii::$app->getModule('cackle_reviews');
     }
     if (!$this->_module) {
         throw new InvalidConfigException("Не определен модуль в конфигурации проекта");
     }
     /*Устанавливаем по умолчанию канал равный адресу страницы*/
     if (!$this->params['channel']) {
         $this->params['channel'] = Yii::$app->request->url;
     }
     /*Синхронизация комментариев*/
     if ($this->sync) {
         $sync = new helpers\CackleReviewSync();
         $sync->sync();
     }
     $this->_uid = uniqid(time());
     $this->params['widget'] = 'Review';
     $this->params['id'] = $this->_module->site_id;
     $this->params['chanWithoutParams'] = true;
     $this->params['container'] = 'mc-review-' . $this->_uid;
     $js = 'cackle_widget.push(' . Json::encode($this->params) . ');';
     $cackle_pos_end = 'document.getElementById("mc-review-' . $this->_uid . '").innerHTML = "";';
     $cackle_pos_end .= 'cackle_widget = window.cackle_widget || [];';
     $cackle_pos_end .= "\r\n        (function() {\r\n            var mc = document.createElement('script');\r\n            mc.type = 'text/javascript';\r\n            mc.async = true;\r\n            mc.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://cackle.me/widget.js';\r\n            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mc, s.nextSibling);\r\n        })();";
     $this->getView()->registerJs($js, View::POS_READY, 'cackle_init_' . $this->_uid);
     $this->getView()->registerJs($cackle_pos_end, View::POS_END, 'cackle_load');
     parent::init();
 }
コード例 #21
0
ファイル: ElementsList.php プロジェクト: oakcms/oakcms
 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();
 }
コード例 #22
0
ファイル: SideFragment.php プロジェクト: jorry2008/turen
 public function init()
 {
     parent::init();
     if (empty($this->short_code)) {
         throw new InvalidConfigException('SideFragment config is error.');
     }
 }
コード例 #23
0
 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'];
 }
コード例 #24
0
ファイル: Widget.php プロジェクト: asratnani/yii2-eauth
 /**
  * Initializes the widget.
  * This method is called by {@link CBaseController::createWidget}
  * and {@link CBaseController::beginWidget} after the widget's
  * properties have been initialized.
  */
 public function init()
 {
     parent::init();
     // EAuth component
     /** @var $component \nodge\eauth\EAuth */
     $component = Yii::$app->get($this->component);
     // Some default properties from component configuration
     if (!isset($this->services)) {
         $this->services = $component->getServices();
     }
     if (is_array($this->predefinedServices)) {
         $_services = [];
         foreach ($this->predefinedServices as $_serviceName) {
             if (isset($this->services[$_serviceName])) {
                 $_services[$_serviceName] = $this->services[$_serviceName];
             }
         }
         $this->services = $_services;
     }
     if (!isset($this->popup)) {
         $this->popup = $component->popup;
     }
     // Set the current route, if it is not set.
     if (!isset($this->action)) {
         $this->action = '/' . Yii::$app->requestedRoute;
     }
 }
コード例 #25
0
 public function init()
 {
     parent::init();
     if ($this->postID === null) {
         throw new InvalidConfigException('PostID cannot be null !');
     }
 }
コード例 #26
0
ファイル: Wechat.php プロジェクト: starzeng/yii2-wechat
 public function init()
 {
     parent::init();
     if ($this->url === null) {
         throw new InvalidConfigException('Please specify the "model" property.');
     }
 }
コード例 #27
0
 /**
  * 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.');
     }
 }
コード例 #28
0
ファイル: LogoWidget.php プロジェクト: Nikcrysis/logos
 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;
 }
コード例 #29
0
ファイル: Widget.php プロジェクト: merlano17/yii2-materialize
 /**
  * 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();
     }
 }
コード例 #30
0
 public function init()
 {
     parent::init();
     if (empty($this->buttonText)) {
         $this->buttonText = Yii::t('inlitteris', 'Create Reference From default');
     }
 }