當前位置: 首頁>>代碼示例>>PHP>>正文


PHP base\Widget類代碼示例

本文整理匯總了PHP中yii\base\Widget的典型用法代碼示例。如果您正苦於以下問題:PHP Widget類的具體用法?PHP Widget怎麽用?PHP Widget使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Widget類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init

 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);
 }
開發者ID:apaoww,項目名稱:yii2-jqgrid-widget,代碼行數:31,代碼來源:JqGridWidget.php

示例2: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->header) {
         $this->header = "<h2>" . Inflector::camel2words($this->model->formName()) . " change log:</h2>";
     }
 }
開發者ID:cranky4,項目名稱:change-log-behavior,代碼行數:10,代碼來源:ChangeLogList.php

示例3: init

 public function init()
 {
     parent::init();
     if (!$this->items) {
         throw new InvalidConfigException(\Yii::t('front', 'No required parameter given') . ' - items');
     }
 }
開發者ID:czechcamus,項目名稱:dasport,代碼行數:7,代碼來源:ArrayOwlCarousel.php

示例4: init

 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $view = Yii::$app->getView();
     $this->registerAssets();
     $view->registerJs($this->getJs(), View::POS_END);
 }
開發者ID:bsadnu,項目名稱:yii2-googlecharts,代碼行數:10,代碼來源:PieChart.php

示例5: init

 public function init()
 {
     parent::init();
     if ($this->title === null) {
         $this->title = 'title';
     }
 }
開發者ID:funson86,項目名稱:yii2-blog,代碼行數:7,代碼來源:RecentComments.php

示例6: init

 public function init()
 {
     parent::init();
     if (!$this->rowViewPath) {
         $this->rowViewPath = '_row';
     }
 }
開發者ID:mitalcoi,項目名稱:yii2-multi,代碼行數:7,代碼來源:MultiInput.php

示例7: init

 public function init()
 {
     parent::init();
     if (empty($this->model)) {
         throw new InvalidConfigException('Required `model` param isn\'t set.');
     }
 }
開發者ID:Brother-Simon,項目名稱:easyii,代碼行數:7,代碼來源:SeoForm.php

示例8: init

 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if (!isset($this->options['class'])) {
         Html::addCssClass($this->options, 'dropdown');
     }
 }
開發者ID:philippfrenzel,項目名稱:yiiframework.com,代碼行數:10,代碼來源:DropdownList.php

示例9: init

 public function init()
 {
     parent::init();
     if (empty($this->title) || empty($this->num)) {
         throw new InvalidConfigException('SidePostTop config is error.');
     }
 }
開發者ID:jorry2008,項目名稱:turen,代碼行數:7,代碼來源:SidePostTop.php

示例10: init

 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>
                             ';
 }
開發者ID:Penton,項目名稱:MoBlog,代碼行數:34,代碼來源:BootstrapDatetimePicker.php

示例11: init

 public function init()
 {
     parent::init();
     //        if(!$this->label || !is_array($this->config)){
     //            throw new Exception('缺少參數或參數缺失');
     //        }
 }
開發者ID:lurongze,項目名稱:uii20160328,代碼行數:7,代碼來源:MulitinputWidget.php

示例12: init

 public function init()
 {
     parent::init();
     if (empty($this->options)) {
         Html::addCssClass($this->options, ['horizontal-menu']);
     }
 }
開發者ID:prawee,項目名稱:yii2-metroui,代碼行數:7,代碼來源:Menu.php

示例13: init

 public function init()
 {
     parent::init();
     if (empty($this->view)) {
         $this->view = (new \ReflectionClass($this))->getShortName();
     }
 }
開發者ID:quynhvv,項目名稱:stepup,代碼行數:7,代碼來源:Tree.php

示例14: init

 public function init()
 {
     parent::init();
     if ($this->message == null) {
         throw new Exception('wrong message');
     }
 }
開發者ID:svok,項目名稱:yii2-barcode,代碼行數:7,代碼來源:GeneratedCodebar.php

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


注:本文中的yii\base\Widget類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。