作者:apaow
项目:yii2-jqgrid-widge
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);
}
作者:oakcm
项目:oakcm
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();
}
作者:Marostac
项目:Marostac
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;
}
}
作者:nguyentuansie
项目:BioMedi
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]);
}
作者:cranky
项目:change-log-behavio
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!$this->header) {
$this->header = "<h2>" . Inflector::camel2words($this->model->formName()) . " change log:</h2>";
}
}
作者:czechcamu
项目:daspor
public function init()
{
parent::init();
if (!$this->items) {
throw new InvalidConfigException(\Yii::t('front', 'No required parameter given') . ' - items');
}
}
作者:bsadn
项目:yii2-googlechart
/**
* Initializes the widget.
*/
public function init()
{
parent::init();
$view = Yii::$app->getView();
$this->registerAssets();
$view->registerJs($this->getJs(), View::POS_END);
}
作者:funson8
项目:yii2-blo
public function init()
{
parent::init();
if ($this->title === null) {
$this->title = 'title';
}
}
作者:mitalco
项目:yii2-mult
public function init()
{
parent::init();
if (!$this->rowViewPath) {
$this->rowViewPath = '_row';
}
}
作者:Brother-Simo
项目:easyi
public function init()
{
parent::init();
if (empty($this->model)) {
throw new InvalidConfigException('Required `model` param isn\'t set.');
}
}
作者:philippfrenze
项目:yiiframework.co
/**
* Initializes the widget.
*/
public function init()
{
parent::init();
if (!isset($this->options['class'])) {
Html::addCssClass($this->options, 'dropdown');
}
}
作者:jorry200
项目:ture
public function init()
{
parent::init();
if (empty($this->title) || empty($this->num)) {
throw new InvalidConfigException('SidePostTop config is error.');
}
}
作者:Pento
项目:MoBlo
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>
';
}
作者:lurongz
项目:uii2016032
public function init()
{
parent::init();
// if(!$this->label || !is_array($this->config)){
// throw new Exception('缺少参数或参数缺失');
// }
}
作者:prawe
项目:yii2-metrou
public function init()
{
parent::init();
if (empty($this->options)) {
Html::addCssClass($this->options, ['horizontal-menu']);
}
}
作者:quynhv
项目:stepu
public function init()
{
parent::init();
if (empty($this->view)) {
$this->view = (new \ReflectionClass($this))->getShortName();
}
}
作者:svo
项目:yii2-barcod
public function init()
{
parent::init();
if ($this->message == null) {
throw new Exception('wrong message');
}
}
作者:tqsq200
项目:dotplant
/**
* @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;
}
作者:heartshar
项目:dotplant
public function __construct($config = [])
{
parent::__construct($config);
if (!$this->transaction instanceof OrderTransaction) {
$this->transaction = new OrderTransaction();
}
}
作者:yii-dream-tea
项目:yii2-payee
public function init()
{
parent::init();
assert(isset($this->api));
assert(isset($this->invoiceId));
assert(isset($this->amount));
}