public static function getJS(&$params)
    {
        static $finder, $isAdmin, $isUser, $inSpecialGroup, $confCss, $confHeadCss, $xoopsUrl, $moduleUrl, $uploadTo, $imgSize;
        self::$cnt++;
        $params['name'] = trim($params['name']);
        $params['class'] = isset($params['class']) ? trim($params['class']) : '';
        $params['cols'] = isset($params['cols']) ? intval($params['cols']) : self::DHTMLTAREA_DEFAULT_COLS;
        $params['rows'] = isset($params['rows']) ? intval($params['rows']) : self::DHTMLTAREA_DEFAULT_ROWS;
        $params['value'] = isset($params['value']) ? $params['value'] : '';
        $params['id'] = isset($params['id']) ? trim($params['id']) : self::DHTMLTAREA_DEFID_PREFIX . $params['name'];
        $params['editor'] = isset($params['editor']) ? trim($params['editor']) : 'bbcode';
        $params['toolbar'] = isset($params['toolbar']) ? trim($params['toolbar']) : null;
        $params['style'] = isset($params['style']) ? trim($params['style']) : '';
        $params['allowhtml'] = !empty($params['allowhtml']);
        $params['switcher'] = isset($params['switcher']) ? trim($params['switcher']) : null;
        $params['onload'] = isset($params['onload']) ? trim($params['onload']) : null;
        $params['onready'] = isset($params['onready']) ? trim($params['onready']) : null;
        if (!empty($params['editor']) && $params['editor'] !== 'none' && (!$params['class'] || !preg_match('/\\b' . preg_quote($params['editor']) . '\\b/', $params['class']))) {
            if (!$params['class']) {
                $params['class'] = $params['editor'];
            } else {
                $params['class'] .= ' ' . $params['editor'];
            }
        }
        // rlazy registering & call pre build delegate
        if (defined('XOOPS_CUBE_LEGACY')) {
            $delegate = new XCube_Delegate();
            $delegate->register('Ckeditor4.Utils.PreBuild_ckconfig');
            $delegate->call(new XCube_Ref($params));
        } else {
            self::doFilter('config', 'PreBuild', $params);
        }
        $script = '';
        if ($params['editor'] !== 'plain' && $params['editor'] !== 'none') {
            $editor = $params['editor'] === 'html' ? 'html' : 'bbcode';
            $conf = self::getModuleConfig();
            $imageUploadJS = '';
            if (is_null($finder)) {
                // Get X-elFinder module
                $mHandler =& self::getXoopsHandler('module');
                $mObj = $mHandler->getByDirname($conf['xelfinder']);
                $finder = is_object($mObj) ? $conf['xelfinder'] : '';
                if ($finder) {
                    require_once XOOPS_TRUST_PATH . '/modules/xelfinder/class/xelFinderMisc.class.php';
                    $xelMisc = new xelFinderMisc($finder);
                    if (!empty($conf['uploadHash'])) {
                        $uploadTo = trim($conf['uploadHash']);
                    } else {
                        if (!($uploadTo = $xelMisc->getUserHome())) {
                            $uploadTo = $xelMisc->getGroupHome();
                        }
                        if ($uploadTo) {
                            $uploadTo = $xelMisc->getHash($uploadTo);
                        }
                    }
                    $imgSize = intval($conf['imgShowSize']) ? 200 : intval($conf['imgShowSize']);
                } else {
                    $uploadTo = false;
                }
                if (defined('XOOPS_CUBE_LEGACY')) {
                    $root =& XCube_Root::getSingleton();
                    $xoopsUser = $root->mContext->mXoopsUser;
                    $inAdminPanel = $root->mContext->mBaseRenderSystemName === 'Legacy_AdminRenderSystem';
                } else {
                    global $xoopsUser;
                    $inAdminPanel = defined('_AD_NORIGHT');
                    // html/language/[LANG]/admin.php
                }
                // Check in a group
                $isAdmin = false;
                $isUser = false;
                $mGroups = array(XOOPS_GROUP_ANONYMOUS);
                if (is_object($xoopsUser)) {
                    if ($xoopsUser->isAdmin(self::getMid())) {
                        $isAdmin = true;
                    }
                    $isUser = true;
                    $mGroups = $xoopsUser->getGroups();
                }
                $inSpecialGroup = array_intersect($mGroups, !empty($conf['special_groups']) ? $conf['special_groups'] : array());
                // xoopsUrl
                $xoopsUrl = XOOPS_URL;
                // moduleUrl
                $moduleUrl = defined('XOOPS_MODULE_URL') ? XOOPS_MODULE_URL : XOOPS_URL . '/modules';
                // make CSS data
                $confCss = array();
                $confHeadCss = 'false';
                $conf['contentsCss'] = trim($conf['contentsCss']);
                if ($conf['contentsCss']) {
                    foreach (preg_split('/[\\r\\n]+/', $conf['contentsCss']) as $_css) {
                        $_css = trim($_css);
                        if (!$inAdminPanel && $_css === '<head>') {
                            $confHeadCss = 'true';
                        } else {
                            if ($_css) {
                                $confCss[] = $_css;
                            }
                        }
                    }
                }
                // themes contents.css
                $_themeCss = '/themes/' . $GLOBALS['xoopsConfig']['theme_set'] . '/ckeditor4/contents.css';
                if (is_file(XOOPS_ROOT_PATH . $_themeCss)) {
                    $confCss[] = XOOPS_URL . $_themeCss;
                }
                // editor_reset.css
                $confCss[] = $moduleUrl . '/ckeditor4/templates/editor_reset.css';
            }
            // Make config
            $config = array();
            $modeconf = array('html' => array(), 'bbcode' => array());
            $config['contentsCss'] = array();
            $config['removePlugins'] = 'save,newpage,forms,preview,print';
            $config['extraPlugins'] = '';
            if (defined('XOOPS_CUBE_LEGACY')) {
                $delegate->register('Ckeditor4.Utils.PreParseBuild_ckconfig');
                $delegate->call(new XCube_Ref($config), $params);
                if ($config['contentsCss'] && !is_array($config['contentsCss'])) {
                    $config['contentsCss'] = array($config['contentsCss']);
                }
            } else {
                self::doFilter('config', 'PreParseBuild', $config, $params);
            }
            // Parse params
            if (!is_null($params['toolbar'])) {
                $config['toolbar'] = $params['toolbar'];
            }
            $config['xoopscodeXoopsUrl'] = XOOPS_URL . '/';
            if ($finder) {
                $config['filebrowserBrowseUrl'] = $moduleUrl . '/' . $finder . '/manager.php?cb=ckeditor';
                if ($uploadTo) {
                    $config['filebrowserBrowseUrl'] .= '&start=' . $uploadTo;
                    $config['uploadUrl'] = $config['filebrowserUploadUrl'] = $moduleUrl . '/' . $finder . '/connector.php';
                    if (!isset($_SESSION['XELFINDER_CTOKEN'])) {
                        $_SESSION['XELFINDER_CTOKEN'] = md5(session_id() . XOOPS_ROOT_PATH . (defined(XOOPS_SALT) ? XOOPS_SALT : XOOPS_DB_PASS));
                    }
                    $imageUploadJS = <<<EOD

\tckon("instanceReady",function(e){
\t\tvar editor = e.editor;
\t\teditor.widgets.registered.uploadimage.onUploaded = function(img){
\t\t\tvar self = this;
\t\t\tgetShowImgSize(img.url, function(s,r) {
\t\t\t\tvar elm,
\t\t\t\t\ttag = '<img src="'+encodeURI(img.url)+'" width="'+s.width+'" height="'+s.height+'"></img>';
\t\t\t\tif (r) {
\t\t\t\t\ttag = '<a href="'+encodeURI(img.url)+'" target="_blank">'+tag+'</a>';
\t\t\t\t}
\t\t\t\tself.replaceWith(tag);
\t\t\t\teditor.getSelection().removeAllRanges();
\t\t\t});
\t\t}
\t});
\tckon("fileUploadRequest",function(e){
\t\tvar fileLoader = e.data.fileLoader,
\t\t\tformData = new FormData(),
\t\t\txhr = fileLoader.xhr;
\t\txhr.open('POST', fileLoader.uploadUrl, true);
\t\tformData.append('cmd', 'upload');
\t\tformData.append('overwrite', 0);
\t\tformData.append('target', '{$uploadTo}');
\t\tformData.append('ctoken', '{$_SESSION['XELFINDER_CTOKEN']}');
\t\tformData.append('upload[]', fileLoader.file, fileLoader.fileName);
\t\tfileLoader.xhr.send(formData);
\t});
\tckon("fileUploadResponse",function(e){
\t\te.stop();
\t\tvar data = e.data,
\t\t\tres = JSON.parse(data.fileLoader.xhr.responseText);
\t\tif (!res.added || res.added.length < 1) {
\t\t\tdata.message = 'Can not upload.';
\t\t\te.cancel();
\t\t} else {
\t\t\tvar file   = res.added[0],
\t\t\t\tparser = document.createElement('a');
\t\t\tparser.href = '{$xoopsUrl}';
\t\t\tdata.url = file.url? file.url : 
\t\t\t\t(data.url = file._localpath? file._localpath.replace(/^R/, '{$xoopsUrl}') : '');
\t\t\tdata.url = data.url.replace(parser.protocol+'//'+parser.host, '');
\t\t}
\t});
EOD;
                }
            }
            $config['removePlugins'] = $config['removePlugins'] ? ',' . trim($config['removePlugins'], ',') : '';
            // build bbcode conf
            $modeconf['bbcode']['fontSize_sizes'] = 'xx-small;x-small;small;medium;large;x-large;xx-large';
            $modeconf['bbcode']['extraPlugins'] = (trim($conf['extraPlugins']) ? 'xoopscode,' . trim($conf['extraPlugins']) : 'xoopscode') . ($config['extraPlugins'] ? ',' . trim($config['extraPlugins'], ',') : '');
            $modeconf['bbcode']['enterMode'] = 2;
            $modeconf['bbcode']['shiftEnterMode'] = 2;
            if ($editor !== 'bbcode' || !isset($config['toolbar'])) {
                $modeconf['bbcode']['toolbar'] = trim($conf['toolbar_bbcode']);
            } else {
                $modeconf['bbcode']['toolbar'] = $config['toolbar'];
            }
            // build html conf
            $modeconf['html']['fontSize_sizes'] = '8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;36/36px;48/48px;72/72px';
            $modeconf['html']['extraPlugins'] = trim($conf['extraPlugins']) . ($config['extraPlugins'] ? ',' . trim($config['extraPlugins'], ',') : '');
            $modeconf['html']['enterMode'] = (int) $conf['enterMode'];
            $modeconf['html']['shiftEnterMode'] = (int) $conf['shiftEnterMode'];
            if ($editor !== 'html' || !isset($config['toolbar'])) {
                if ($isAdmin) {
                    $modeconf['html']['toolbar'] = trim($conf['toolbar_admin']);
                } else {
                    if ($inSpecialGroup) {
                        $modeconf['html']['toolbar'] = trim($conf['toolbar_special_group']);
                    } else {
                        if ($isUser) {
                            $modeconf['html']['toolbar'] = trim($conf['toolbar_user']);
                        } else {
                            $modeconf['html']['toolbar'] = trim($conf['toolbar_guest']);
                        }
                    }
                }
                if (strtolower($modeconf['html']['toolbar']) === 'full') {
                    $modeconf['html']['toolbar'] = null;
                }
            } else {
                $modeconf['html']['toolbar'] = $config['toolbar'];
            }
            $config['customConfig'] = trim($conf['customConfig']);
            if ($conf['allowedContent']) {
                $config['allowedContent'] = true;
            }
            $config['autoParagraph'] = (bool) $conf['autoParagraph'];
            $config['contentsCss'] = array_merge($config['contentsCss'], $confCss);
            self::setCKConfigSmiley($config);
            $modeSource = 0;
            $params['value'] = str_replace('&lt;!--ckeditor4FlgSource--&gt;', '', $params['value'], $modeSource);
            if ($modeSource) {
                $config['startupMode'] = 'source';
            }
            // set $modeconf as $config['_modeconf'] for delegate
            $config['_modeconf'] = $modeconf;
            // lazy registering & call post build delegate
            if (defined('XOOPS_CUBE_LEGACY')) {
                $delegate->register('Ckeditor4.Utils.PostBuild_ckconfig');
                $delegate->call(new XCube_Ref($config), $params);
            } else {
                self::doFilter('config', 'PostBuild', $config, $params);
            }
            // restore $modeconf from $config['_modeconf']
            $modeconf = $config['_modeconf'];
            unset($config['_modeconf']);
            // merge editor config
            $config = array_merge($config, $modeconf[$editor]);
            // Make config json
            $config_json = array();
            foreach ($config as $key => $val) {
                if (!is_string($val) || !$val || $val[0] !== '[') {
                    $val = json_encode($val);
                }
                $config_json[] = '"' . $key . '":' . $val;
            }
            $config_json = '{' . join($config_json, ',') . '}';
            foreach (array('html', 'bbcode') as $mode) {
                $name = 'config_json_' . $mode;
                ${$name} = array();
                foreach ($modeconf[$mode] as $key => $val) {
                    if (!is_string($val) || !$val || $val[0] !== '[') {
                        $val = json_encode($val);
                    }
                    array_push(${$name}, '"' . $key . '":' . $val);
                }
                ${$name} = '{' . join(${$name}, ',') . '}';
            }
            // allow html
            $allowhtml = $params['allowhtml'] || $editor === 'html' ? 'true' : 'false';
            // Make Script
            $id = $params['id'];
            // build switcher
            if (is_null($params['switcher'])) {
                // default switcher
                $switcher = <<<EOD

\t// local func
\tvar ck,ta = \$("#{$id}"),
\tset = function(name, check, disable) {
\t\tvar elm = eval(name+"_c");
\t\tif (elm) {
\t\t\t(check !== null) && elm.prop("checked", check);
\t\t\t(disable !== null) && elm.prop("disabled", disable);
\t\t}
\t},
\tfind_c = function(name){
\t\tvar f = ta.closest("form");
\t\tvar elm = f.find('input[type="checkbox"][name="do'+name+'"]');
\t\t(elm.length === 1) || (elm = f.find('input[type="checkbox"][name\$="'+name+'"]'));
\t\t(elm.length === 1) || (elm = f.find('input[type="checkbox"][name*="'+name+'"]'));
\t\treturn (elm.length === 1) ? elm : null;
\t},
\t// checkbox
\thtml_c = find_c('html'),
\tbbcode_c = find_c('xcode'),
\tbr_c = find_c('br');
\t// dohtml checkbox
\tif (html_c) {
\t\thtml_c.change(function(){
\t\t\tif (!\$(this).is(":focus")) return;
\t\t\tvar obj = CKEDITOR.instances.{$id};
\t\t\tobj && obj.destroy();
\t\t\tbr_c && br_c.prop("disabled", false);
\t\t\tif (\$(this).is(":checked")) {
\t\t\t\tset("bbcode", false);
\t\t\t\tset("br", false , true);
\t\t\t\tta.data("editor", "html");
\t\t\t\tck = CKEDITOR.replace("{$id}", \$.extend({}, ta.data("ckconfig"), ta.data("ckconfig_html")));
\t\t\t} else if (!bbcode_c || bbcode_c.is(":checked")) {
\t\t\t\tset("br", true, true);
\t\t\t\tta.data("editor", "bbcode");
\t\t\t\tck = CKEDITOR.replace("{$id}", \$.extend({}, ta.data("ckconfig"), ta.data("ckconfig_bbcode")));
\t\t\t} else {
\t\t\t\treturn;
\t\t\t}
\t\t\tta.data("ckon_restore")();
\t\t});
\t}
\t// doxcode checkbox
\tif (bbcode_c) {
\t\tbbcode_c.change(function(){
\t\t\tif (!\$(this).is(":focus")) return;
\t\t\tvar obj = CKEDITOR.instances.{$id},
\t\t\tconf = ta.data("ckconfig"),
\t\t\tchange = false;
\t\t\tif (\$(this).is(":checked")) {
\t\t\t\tif (!html_c || (html_c && !html_c.is(":checked"))) {
\t\t\t\t\tchange = 'bbcode';
\t\t\t\t\tconf = \$.extend(conf, ta.data("ckconfig_bbcode"));
\t\t\t\t}
\t\t\t} else if ((!html_c && ta.data("allowhtml")) || (html_c && html_c.is(":checked"))) {
\t\t\t\tif (ta.data("editor") != "html") {
\t\t\t\t\tchange = 'html';
\t\t\t\t\tconf = \$.extend(conf, ta.data("ckconfig_html"));
\t\t\t\t}
\t\t\t} else {
\t\t\t\tchange = 'none';
\t\t\t}
\t\t\tif (change) {
\t\t\t\tobj && obj.destroy();
\t\t\t\tta.data("editor", change);
\t\t\t\tif (change != "none") {
\t\t\t\t\tset("br", (change == 'bbcode'), true);
\t\t\t\t\tck = CKEDITOR.replace("{$id}", conf);
\t\t\t\t\tta.data("ckon_restore")();
\t\t\t\t} else {
\t\t\t\t\tset("br", null, false);
\t\t\t\t}
\t\t\t}
\t\t});
\t}
\t// form submit
\tta.closest("form").bind("submit", function(){
\t\tvar e = ta.data("editor");
\t\tset("br", ((e == "bbcode")? true : ((e == "html")? false : null)), false);
\t});
\t// custom block editor (legacy or alysys)
\tvar html_s = ta.closest("form").find("select[name='c_type'],[name='ctypes[0]']");
\tif (html_s && html_s.length == 1) {
\t\thtml_s.change(function(){
\t\t\tvar obj = CKEDITOR.instances.{$id}, conf;
\t\t\tconf = ta.data("ckconfig");
\t\t\tobj && obj.destroy();
\t\t\tconf = (\$(this).val() == "H")? \$.extend(conf, ta.data("ckconfig_html")) : \$.extend(conf, ta.data("ckconfig_bbcode"));
\t\t\tif (\$(this).val() != "P") {
\t\t\t\tconf =\t(\$(this).val() == "T")? \$.extend(conf, {removePlugins:'smiley,'+conf.removePlugins}) : \$.extend(conf, {removePlugins: conf.removePlugins.replace('smiley,', '')});
\t\t\t\tck = CKEDITOR.replace("{$id}", conf);
\t\t\t\tta.data("ckon_restore")();
\t\t\t}
\t\t});
\t}
EOD;
            } else {
                // custom switcher (by params)
                $switcher = 'try{ ' . $params['switcher'] . ' } catch(e) { console && console.log(e); }';
            }
            $onload = $params['onload'] ? 'try{ ' . $params['onload'] . ' } catch(e) { console && console.log(e); }' : '';
            $onready = $params['onready'] ? 'try{ ' . $params['onready'] . ' } catch(e) { console && console.log(e); }' : '';
            if (self::$cnt === 1) {
                $script_1st = <<<EOD

\tif (typeof xoopsInsertText != 'undefined') {
\t\tvar xit = xoopsInsertText;
\t\txoopsInsertText = function(obj, str){
\t\t\tif (obj.id && CKEDITOR.instances[obj.id]) {
\t\t\t\tCKEDITOR.instances[obj.id].insertText(str);
\t\t\t} else {
\t\t\t\txit(obj, str);
\t\t\t}
\t\t}
\t}
\tif (typeof xoopsCodeSmilie != 'undefined') {
\t\tvar xcs = xoopsCodeSmilie;
\t\txoopsCodeSmilie = function(id, str){
\t\t\tif (CKEDITOR.instances[id]) {
\t\t\t\tCKEDITOR.instances[id].insertText(str);
\t\t\t} else {
\t\t\t\txcs(id, str);
\t\t\t}
\t\t}
\t}
EOD;
                if ($finder) {
                    $script_1st .= <<<EOD

\tgetShowImgSize = function(url, callback) {
\t\tvar ret = {};
\t\t\$('<img/>').attr('src', url).on('load', function() {
\t\t\tvar w = this.naturalWidth,
\t\t\t\th = this.naturalHeight,
\t\t\t\ts = {$imgSize},
\t\t\t\tresized = false;
\t\t\tif (w > s || h > s) {
\t\t\t\tresized = true;
\t\t\t\tif (w > h) {
\t\t\t\t\th = Math.round(h * (s / w));
\t\t\t\t\tw = s;
\t\t\t\t} else {
\t\t\t\t\tw = Math.round(w * (s / h));
\t\t\t\t\th = s;
\t\t\t\t}
\t\t\t}
\t\t\tcallback({width: w, height: h}, resized);
\t\t});
\t};
\tCKEDITOR.on('dialogDefinition', function (event) {
\t\tvar editor = event.editor,
\t\t\tdialogDefinition = event.data.definition,
\t\t\ttabCount = dialogDefinition.contents.length,
\t\t\tuploadButton, submitButton, inputId,
\t\t\t// elFinder configs
\t\t\telfDirHashMap = { // Dialog name / elFinder holder hash Map
\t\t\t\timage : '',
\t\t\t\tflash : '',
\t\t\t\tfiles : '',
\t\t\t\tlink  : '',
\t\t\t\tfb    : '{$uploadTo}' // fallback target
\t\t\t},
\t\t\tcustomData = { ctoken: '{$_SESSION['XELFINDER_CTOKEN']}' }; // any custom data to post
\t\tfor (var i = 0; i < tabCount; i++) {
\t\t\tuploadButton = dialogDefinition.contents[i].get('upload');
\t\t\tsubmitButton = dialogDefinition.contents[i].get('uploadButton');
\t\t\tif (uploadButton !== null && submitButton !== null) {
\t\t\t\tuploadButton.hidden = false;
\t\t\t\tsubmitButton.hidden = false;
\t\t\t\tuploadButton.onChange = function() {
\t\t\t\t\tinputId = this.domId;
\t\t\t\t}
\t\t\t\tsubmitButton.onClick = function(e) {
\t\t\t\t\tdialogName = CKEDITOR.dialog.getCurrent()._.name;
\t\t\t\t\tvar target = elfDirHashMap[dialogName]? elfDirHashMap[dialogName] : elfDirHashMap['fb'],
\t\t\t\t\t\tname   = \$('#'+inputId),
\t\t\t\t\t\tbtn    = \$('#'+this.domId),
\t\t\t\t\t\tinput  = name.find('iframe').contents().find('form').find('input:file'),
\t\t\t\t\t\tspinner= \$('<img src="{$xoopsUrl}/common/elfinder/img/spinner-mini.gif" width="16" height="16" style="vertical-align:middle"/>'),
\t\t\t\t\t\terror  = function(err) {
\t\t\t\t\t\t\talert(err.replace('<br>', '\\n'));
\t\t\t\t\t\t};
\t\t\t\t\tif (input.val() && ! btn.hasClass('cke_button_disabled')) {
\t\t\t\t\t\tvar fd = new FormData();
\t\t\t\t\t\tfd.append('cmd', 'upload');
\t\t\t\t\t\tfd.append('overwrite', 0); // disable upload overwrite to make to increment file name
\t\t\t\t\t\tfd.append('target', target);
\t\t\t\t\t\t\$.each(customData, function(key, val) {
\t\t\t\t\t\t\tfd.append(key, val);
\t\t\t\t\t\t});
\t\t\t\t\t\tfd.append('upload[]', input[0].files[0]);
\t\t\t\t\t\tbtn.addClass('cke_button_disabled').append(spinner);
\t\t\t\t\t\t\$.ajax({
\t\t\t\t\t\t\turl: editor.config.filebrowserUploadUrl,
\t\t\t\t\t\t\ttype: 'POST',
\t\t\t\t\t\t\tdata: fd,
\t\t\t\t\t\t\tprocessData: false,
\t\t\t\t\t\t\tcontentType: false,
\t\t\t\t\t\t\tdataType: 'json'
\t\t\t\t\t\t})
\t\t\t\t\t\t.done(function( data ) {
\t\t\t\t\t\t\tif (data.added && data.added[0]) {
\t\t\t\t\t\t\t\tvar url = data.added[0].url;
\t\t\t\t\t\t\t\tvar dialog = CKEDITOR.dialog.getCurrent();
\t\t\t\t\t\t\t\tif (dialogName == 'image') {
\t\t\t\t\t\t\t\t\tvar urlObj = 'txtUrl'
\t\t\t\t\t\t\t\t} else if (dialogName == 'flash') {
\t\t\t\t\t\t\t\t\tvar urlObj = 'src'
\t\t\t\t\t\t\t\t} else if (dialogName == 'files' || dialogName == 'link') {
\t\t\t\t\t\t\t\t\tvar urlObj = 'url'
\t\t\t\t\t\t\t\t} else {
\t\t\t\t\t\t\t\t\treturn;
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\tdialog.selectPage('info');
\t\t\t\t\t\t\t\tdialog.setValueOf('info', urlObj, url);
\t\t\t\t\t\t\t\tif (dialogName == 'image') {
\t\t\t\t\t\t\t\t\tgetShowImgSize(url, function(s,r) {
\t\t\t\t\t\t\t\t\t\tif (r) {
\t\t\t\t\t\t\t\t\t\t\ttry {
\t\t\t\t\t\t\t\t\t\t\t\tdialog.setValueOf('info', 'txtWidth', s.width);
\t\t\t\t\t\t\t\t\t\t\t\tdialog.setValueOf('info', 'txtHeight', s.height);
\t\t\t\t\t\t\t\t\t\t\t\tdialog.preview.\$.style.width = s.width+'px';
\t\t\t\t\t\t\t\t\t\t\t\tdialog.preview.\$.style.height = s.height+'px';
\t\t\t\t\t\t\t\t\t\t\t\tdialog.setValueOf('Link', 'txtUrl', url);
\t\t\t\t\t\t\t\t\t\t\t\tdialog.setValueOf('Link', 'cmbTarget', '_blank');
\t\t\t\t\t\t\t\t\t\t\t} catch(e) {}
\t\t\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t\t});
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t} else {
\t\t\t\t\t\t\t\terror(data.error || data.warning || 'errUploadFile');
\t\t\t\t\t\t\t}
\t\t\t\t\t\t})
\t\t\t\t\t\t.fail(function() {
\t\t\t\t\t\t\terror('errUploadFile');
\t\t\t\t\t\t})
\t\t\t\t\t\t.always(function() {
\t\t\t\t\t\t\tinput.val('');
\t\t\t\t\t\t\tspinner.remove();
\t\t\t\t\t\t\tbtn.removeClass('cke_button_disabled');
\t\t\t\t\t\t});
\t\t\t\t\t}
\t\t\t\t\treturn false;
\t\t\t\t}
\t\t\t}
\t\t} 
\t});
EOD;
                }
            } else {
                $script_1st = '';
            }
            $script = <<<EOD

(function(){
\t{$onload}{$script_1st}
\tvar ckconfig_{$id},ckconfig_html_{$id},ckconfig_bbcode_{$id};// for compat
\tvar ck,
\tconf = {$config_json},
\tid = "{$id}",
\tta = \$("#{$id}")
\t.data("editor", "{$editor}")
\t.data("allowhtml", {$allowhtml})
\t.data("ckconfig_html", {$config_json_html})
\t.data("ckconfig_bbcode", {$config_json_bbcode})
\t.data("ckon", function(name,func){
\t\tvar ckev = (ta.data("ckev") || {});
\t\tckev[name] = (ckev[name] || []);
\t\tckev[name].push(func);
\t\tta.data("ckev", ckev);
\t\tCKEDITOR.instances[id].on(name, func);
\t})
\t.data("ckon_restore", function(){
\t\tvar ck = CKEDITOR.instances[id];
\t\t\$.each(ta.data("ckev"), function(name, fs){
\t\t\t\$.each(fs, function(i, func){ ck.on(name, func); });
\t\t});
\t});
\tif (! conf.width) conf.width = ta.parent().width() + 'px';
\tvar headCss = \$.map(\$("head link[rel='stylesheet']").filter("[media!='print'][media!='handheld']"), function(o){ return o.href; });
\tif ({$confHeadCss} && headCss) conf.contentsCss = headCss.concat(conf.contentsCss);
\tta.data("ckconfig", conf);
\tckconfig_{$id} = conf;
\tckconfig_html_{$id} = ta.data("ckconfig_html");
\tckconfig_bbcode_{$id} = ta.data("ckconfig_bbcode");
\tck = CKEDITOR.replace("{$id}", conf);
\tvar ckon = ta.data("ckon");
\tckon("focus",function(e){ta.trigger("focus");});
\tckon("blur",function(e){
\t\te.editor.updateElement();
\t\tta.trigger("blur");
\t});
\tckon("instanceReady",function(e){{$onready}});
\tckon("getData",function(e){
\t\tif (e.editor.mode == 'source') e.data.dataValue += '<!--ckeditor4FlgSource-->';
\t});
\tckon("setData",function(e){
\t\te.data.dataValue = e.data.dataValue.replace('<!--ckeditor4FlgSource-->', '');
\t});{$imageUploadJS}
\tta.closest("form").find("input").on("mousedown", function(){
\t\tck && ck.updateElement();
\t});
\t{$switcher}
})();
EOD;
        }
        return $script;
    }
Exemple #2
0
<?php

require_once dirname(dirname(__FILE__)) . '/class/xelFinderMisc.class.php';
$xelFinderMisc = new xelFinderMisc();
$xelFinderMisc->myConfig = $xoopsModuleConfig;
$xelFinderMisc->db = $xoopsDB;
$xelFinderMisc->mydirname = $mydirname;
$xelFinderMisc->mode = 'view';
$file_id = 0;
if (isset($path_info)) {
    list(, $file_id) = explode('/', $path_info);
} elseif (isset($_GET['file'])) {
    list($file_id) = explode('/', $_GET['file']);
}
$file_id = (int) $file_id;
while (ob_get_level()) {
    if (!@ob_end_clean()) {
        break;
    }
}
$query = 'SELECT `mime`, `size`, `mtime`, `perm`, `uid`, `local_path` FROM `' . $xoopsDB->prefix($mydirname) . '_file`' . ' WHERE file_id = ' . $file_id . ' LIMIT 1';
if ($file_id && ($res = $xoopsDB->query($query)) && $xoopsDB->getRowsNum($res)) {
    list($mime, $size, $mtime, $perm, $uid, $file) = $xoopsDB->fetchRow($res);
    if ($xelFinderMisc->readAuth($perm, $uid, $file_id)) {
        if (!$file) {
            $file = XOOPS_TRUST_PATH . '/uploads/xelfinder/' . rawurlencode(substr(XOOPS_URL, strpos(XOOPS_URL, '://') + 3)) . '_' . $mydirname . '_' . $file_id;
        } else {
            if (substr($file, 1, 1) === '/') {
                $_head = substr($file, 0, 1);
                if (strpos($file, '%') !== false) {
                    $file = dirname($file) . DIRECTORY_SEPARATOR . rawurldecode(basename($file));
Exemple #3
0
<?php

require_once dirname(dirname(__FILE__)) . '/class/xelFinderMisc.class.php';
$xelFinderMisc = new xelFinderMisc($mydirname);
$xelFinderMisc->myConfig = $xoopsModuleConfig;
$xelFinderMisc->dbSetCharset('utf8');
$xelFinderMisc->mode = 'tmb';
$file_id = 0;
$s = 0;
if (isset($path_info)) {
    list(, $s, $file_id) = explode('/', $path_info);
} elseif (isset($_GET['s']) && isset($_GET['file'])) {
    $s = $_GET['s'];
    list($file_id) = explode('/', $_GET['file']);
}
$file_id = (int) $file_id;
$s = max(16, (int) $s);
while (ob_get_level()) {
    if (!@ob_end_clean()) {
        break;
    }
}
$query = 'SELECT `width`, `height`, `mime`, `size`, `mtime`, `perm`, `uid`, `local_path` FROM `' . $xoopsDB->prefix($mydirname) . '_file`' . ' WHERE file_id = ' . $file_id . ' LIMIT 1';
if ($file_id && ($res = $xoopsDB->query($query)) && $xoopsDB->getRowsNum($res)) {
    list($width, $height, $mime, $size, $mtime, $perm, $uid, $file) = $xoopsDB->fetchRow($res);
    if ($xelFinderMisc->readAuth($perm, $uid)) {
        @(include_once XOOPS_TRUST_PATH . '/class/hyp_common/hyp_common_func.php');
        $prefix = defined('XELFINDER_DB_FILENAME_PREFIX') ? XELFINDER_DB_FILENAME_PREFIX : substr(XOOPS_URL, strpos(XOOPS_URL, '://') + 3);
        $basepath = XOOPS_TRUST_PATH . '/uploads/xelfinder/' . rawurlencode($prefix) . '_' . $mydirname . '_';
        if (!$file) {
            $tmb = $file = $basepath . $file_id;