/** * Initializes the widget. */ public function init() { parent::init(); if (!isset($this->kcfOptions['uploadURL'])) { $this->kcfOptions['uploadURL'] = Yii::getAlias('@web') . '/upload'; } $changeChars = array_merge(Inflector::$transliteration, Yii::$app->params['changeChars']); $this->kcfOptions['filenameChangeChars'] = $changeChars; $this->kcfOptions['dirnameChangeChars'] = $changeChars; $this->kcfOptions = array_merge($this->kcfOptions, Yii::$app->params['kcfDefaultOptions']); Yii::$app->session['KCFINDER'] = $this->kcfOptions; $this->clientOptions['browseOptions'] = $this->kcfBrowseOptions; $this->clientOptions['uploadURL'] = $this->kcfOptions['uploadURL']; $this->clientOptions['multiple'] = $this->multiple; $this->clientOptions['inputName'] = $this->getInputName(); $this->clientOptions['thumbsDir'] = $this->kcfOptions['thumbsDir']; $this->clientOptions['thumbsSelector'] = '#' . $this->getThumbsId(); $this->clientOptions['thumbTemplate'] = $this->thumbTemplate; $this->buttonOptions['id'] = $this->getButtonId(); Html::addCssClass($this->options, 'form-control'); Html::addCssClass($this->buttonOptions, 'kcf btn btn-default'); }
public function init() { $this->kcfOptions['disabled'] = !yii::$app->getUser()->can('upload/files'); parent::init(); }