/** * Registers TinyMce JS */ protected function registerClientScript() { $view = $this->getView(); if (!isset($this->options['language']) || empty($this->options['language'])) { $this->options['language'] = strtolower(substr(Yii::$app->language, 0, 2)); } // Insert plugins in options if (isset($this->options['plugins'])) { foreach ($this->options['plugins'] as $pluginLine) { foreach (explode(' ', $pluginLine) as $plugin) { //if load elfinder plugin ,load elfinder asserts first if ($plugin == 'elfinder') { \mihaildev\elfinder\Assets::register($this->getView()); \mihaildev\elfinder\Assets::addLangFile($this->options['language'], $this->getView()); } $this->registerPlugin($plugin); } } } $options = empty($this->options) ? '' : Json::encode($this->options); $js = "tinymce.init({$options});"; $view->registerJs($js); }
<?php /** * @var \yii\web\View $this * @var array $options */ use mihaildev\elfinder\Assets; use yii\helpers\Json; Assets::register($this); Assets::addLangFile($options['lang'], $this); if (!empty($options['noConflict'])) { Assets::noConflict($this); } unset($options['noConflict']); $options['soundPath'] = Assets::getSoundPathUrl(); $this->registerJs("\nfunction ElFinderGetCommands(disabled){\n var Commands = elFinder.prototype._options.commands;\n \$.each(disabled, function(i, cmd) {\n (idx = \$.inArray(cmd, Commands)) !== -1 && Commands.splice(idx,1);\n });\n return Commands;\n}\n\n var winHashOld = '';\n function elFinderFullscreen(){\n\n var width = \$(window).width()-(\$('#elfinder').outerWidth(true) - \$('#elfinder').width());\n var height = \$(window).height()-(\$('#elfinder').outerHeight(true) - \$('#elfinder').height());\n\n var el = \$('#elfinder').elfinder('instance');\n\n var winhash = \$(window).width() + '|' + \$(window).height();\n\n\n if(winHashOld == winhash)\n return;\n\n winHashOld = winhash;\n\n el.resize(width, height);\n }\n\n \$('#elfinder').elfinder(" . Json::encode($options) . ").elfinder('instance');\n\n \$(window).resize(elFinderFullscreen);\n\n elFinderFullscreen();\n "); $this->registerCss("\nhtml, body {\n height: 100%;\n -moz-box-sizing: border-box;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n position: relative;\n padding: 0; margin: 0;\n}\n"); $this->beginPage(); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>elFinder 2.0</title> <?php $this->head(); ?> </head> <body> <?php $this->beginBody();
public static function getRedactorOptions(View $view, $controller, $options = []) { \mihaildev\elfinder\Assets::register($view); return ArrayHelper::merge(['url' => self::getConnectUrl($controller)], $options); }