/** * Runs the widget. */ public function run() { if ($this->hasModel()) { $replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options); } else { $replace['{input}'] = Html::textInput($this->name, $this->value, $this->options); } $replace['{button}'] = Html::tag($this->buttonTag, $this->buttonName, $this->buttonOptions); echo strtr($this->template, $replace); AssetsCallBack::register($this->getView()); if (!empty($this->multiple)) { $this->getView()->registerJs("m00nk.elFinder.register(" . Json::encode($this->options['id']) . ", function(files, id){ var _f = []; for (var i in files) { _f.push(files[i].url); } \$('#' + id).val(_f.join(', ')).trigger('change'); return true;}); \$(document).on('click','#" . $this->buttonOptions['id'] . "', function(){m00nk.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});"); } else { $this->getView()->registerJs("m00nk.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){ \$('#' + id).val(file.url).trigger('change');; return true;}); \$(document).on('click', '#" . $this->buttonOptions['id'] . "', function(){m00nk.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});"); } }
public function run() { $container = 'div'; if (isset($this->containerOptions['tag'])) { $container = $this->containerOptions['tag']; unset($this->containerOptions['tag']); } echo Html::tag($container, Html::tag('iframe', '', $this->frameOptions), $this->containerOptions); if (!empty($this->callbackFunction)) { AssetsCallBack::register($this->getView()); $this->getView()->registerJs("m00nk.elFinder.register(" . Json::encode($this->id) . "," . Json::encode($this->callbackFunction) . ");"); } }