public function run() { if (!empty($this->clientEvents)) { $events = $this->registerCKFInderEvents(); $this->clientOptions['onInit'] = new JsExpression("function(finder){ {$events}}"); } $options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions); $this->getView()->registerJs("\$('#{$this->options['id']}-popup').on('click', function(){ CKFinder.{$this->type}({$options}); });"); CKFinderAsset::register($this->getView()); Html::addCssClass($this->options, 'form-control'); $input = $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $this->options) : Html::textInput($this->name, $this->value, $this->options); return implode("\n", [Html::beginTag('div', ['class' => 'input-group']), $input, Html::beginTag('span', ['class' => 'input-group-btn']), Button::widget(['id' => $this->options['id'] . '-popup', 'label' => $this->buttonLabel, 'options' => $this->buttonOptions]), Html::endTag('span'), Html::endTag('div')]); }
/** * @inheritdoc */ public function init() { parent::init(); $this->initOptions(); //$view = $this->getView(); $id = Json::encode($this->options['id']); if ($this->enabledKCFinder) { $kcFinderBundle = CKFinderAsset::register($this->getView()); $kcFinderBaseUrl = $kcFinderBundle->baseUrl; // Add KCFinder-specific config for CKEditor $this->editorOptions = ArrayHelper::merge($this->editorOptions, ['filebrowserBrowseUrl' => $kcFinderBaseUrl . '/ckfinder.html', 'filebrowserUploadUrl' => $kcFinderBaseUrl . '/core/connector/php/connector.php?command=QuickUpload&type=Files']); } }