function XCube_ServiceManager() { $this->mCreateClient = new XCube_Delegate(); $this->mCreateClient->register("XCube_ServiceManager.CreateClient"); $this->mCreateServer = new XCube_Delegate(); $this->mCreateServer->register("XCube_ServiceManager.CreateServer"); }
function LegacyRender_ActionFrame($admin) { $this->mAdminFlag = $admin; $this->mCreateAction = new XCube_Delegate(); $this->mCreateAction->register('LegacyRender_ActionFrame.CreateAction'); $this->mCreateAction->add(array(&$this, '_createAction')); }
function UserMailjobObject() { static $initVars; if (isset($initVars)) { $this->mVars = $initVars; } else { $this->initVar('mailjob_id', XOBJ_DTYPE_INT, '', false); $this->initVar('title', XOBJ_DTYPE_STRING, '', true, 255); $this->initVar('body', XOBJ_DTYPE_TEXT, '', true); $this->initVar('from_name', XOBJ_DTYPE_STRING, '', false, 255); $this->initVar('from_email', XOBJ_DTYPE_STRING, '', false, 255); $this->initVar('is_pm', XOBJ_DTYPE_BOOL, '0', true); $this->initVar('is_mail', XOBJ_DTYPE_BOOL, '0', true); $this->initVar('create_unixtime', XOBJ_DTYPE_INT, time(), true); $initVars=$this->mVars; } $this->mGetReplaceTitle =new XCube_Delegate(); $this->mGetReplaceTitle->register('UserMailjobObject.GetReplaceTitle'); $this->mGetReplaceBody =new XCube_Delegate(); $this->mGetReplaceBody->register('UserMailjobObject.GetReplaceBody'); $this->mSend =new XCube_Delegate(); $this->mSend->register('UserMailjobObject.Send'); }
function Legacy_ModuleUpdateAction($flag) { parent::Legacy_Action($flag); $this->mUpdateSuccess = new XCube_Delegate(); $this->mUpdateSuccess->register('Legacy_ModuleUpdateAction.UpdateSuccess'); $this->mUpdateFail = new XCube_Delegate(); $this->mUpdateFail->register('Legacy_ModuleUpdateAction.UpdateFail'); }
function MyTextSanitizer() { $this->mMakeClickablePostFilter = new XCube_Delegate(); $this->mMakeClickablePostFilter->register('MyTextSanitizer.MakeClickablePostFilter'); $this->mXoopsCodePostFilter = new XCube_Delegate(); $this->mXoopsCodePostFilter->register('MyTextSanitizer.XoopsCodePostFilter'); $root =& XCube_Root::getSingleton(); $this->mTextFilter =& $root->getTextFilter(); }
function Legacy_ThemeSelect(&$controller) { // // TODO remove // parent::XCube_ActionFilter($controller); $this->mIsSelectableTheme = new XCube_Delegate(); $this->mIsSelectableTheme->register('Legacy_ThemeSelect.IsSelectableTheme'); $controller->mSetupUser->add(array(&$this, 'doChangeTheme')); }
function Legacy_Controller() { parent::XCube_Controller(); // // Setup member properties as member delegates. // $this->mSetupUser->register("Legacy_Controller.SetupUser"); $this->mCheckLogin = new XCube_Delegate(); $this->mCheckLogin->register("Site.CheckLogin"); $this->mLogout = new XCube_Delegate(); $this->mLogout->register("Site.Logout"); $this->mCreateLanguageManager = new XCube_Delegate(); $this->mCreateLanguageManager->register("Legacy_Controller.CreateLanguageManager"); $this->mGetLanguageName = new XCube_Delegate(); $this->mGetLanguageName->register("Legacy_Controller.GetLanguageName"); $this->mSetBlockCachePolicy = new XCube_Delegate(); $this->mSetModuleCachePolicy = new XCube_Delegate(); $this->mSetupDebugger = new XCube_Delegate(); $this->mSetupDebugger->add('Legacy_DebuggerManager::createInstance'); $this->mSetupTextFilter->add('Legacy_TextFilter::getInstance', XCUBE_DELEGATE_PRIORITY_FINAL - 1); $this->_mNotifyRedirectToUser = new XCube_Delegate(); if (get_magic_quotes_runtime()) { set_magic_quotes_runtime(0); // ^^; } }
function Legacy_ModuleInstallAction($flag) { parent::Legacy_Action($flag); $this->mInstallSuccess = new XCube_Delegate(); $this->mInstallSuccess->register('Legacy_ModuleInstallAction.InstallSuccess'); $this->mInstallFail = new XCube_Delegate(); $this->mInstallFail->register('Legacy_ModuleInstallAction.InstallFail'); }
function Legacy_AdminControllerStrategy(&$controller) { global $xoopsOption; parent::Legacy_AbstractControllerStrategy($controller); // // TODO We have to develop complated-switching-controller-mechanizm. // if (!defined("LEGACY_DEPENDENCE_RENDERER")) { define("LEGACY_DEPENDENCE_RENDERER", "Legacy_AdminRenderSystem"); } $controller->mRoot->mContext->mBaseRenderSystemName = "Legacy_AdminRenderSystem"; // // Cover the spec of admin.php of the system module, for the compatibility. // if (isset($_REQUEST['fct']) && $_REQUEST['fct'] == "users") { $GLOBALS['xoopsOption']['pagetype'] = "user"; } $this->mSetupBlock = new XCube_Delegate(); $this->mSetupBlock->register('Legacy_AdminControllerStrategy.SetupBlock'); }
/** * @public */ function preBlockFilter() { if (!$this->mRoot->mContext->hasAttribute('module.profile.HasSetAssetManager')) { $delegate =new XCube_Delegate(); $delegate->register('Module.profile.Event.GetAssetManager'); $delegate->add(array(&$this, 'getManager')); $this->mRoot->mContext->setAttribute('module.profile.HasSetAssetManager', true); } $file = XOOPS_MODULE_PATH.'/profile/class/DelegateFunctions.class.php'; $this->mRoot->mDelegateManager->add('Legacy_Profile.SaveProfile', 'Profile_Delegate::saveProfile', $file); $this->mRoot->mDelegateManager->add('Legacy_Profile.GetDefinition', 'Profile_Delegate::getDefinition', $file); $this->mRoot->mDelegateManager->add('Legacy_Profile.GetProfile', 'Profile_Delegate::getProfile', $file); $this->mRoot->mDelegateManager->add('Legacy_Profile.SetupActionForm', 'Profile_Delegate::setupActionForm', $file); $this->mRoot->mDelegateManager->add('Legacy_Profile.LoadActionForm', 'Profile_Delegate::loadActionForm', $file); $this->mRoot->mDelegateManager->add('Legacy.Event.UserDelete', 'Profile_AssetPreload::deleteProfile'); $this->mRoot->mDelegateManager->add('Legacy.Admin.Event.UserDelete', 'Profile_AssetPreload::deleteProfile'); }
function b_cubeUtils_whatsnew_show($options) { $mGetRSSItems = new XCube_Delegate(); $mGetRSSItems->register('Legacy_BackendAction.GetRSSItems'); $items = array(); $mGetRSSItems->call(new XCube_Ref($items)); $max_item = intval($options[0]); if (empty($max_item)) { $max_item = 5; } $sortArr = array(); $n = 0; foreach ($items as $item) { $i = intval($item['pubdate']); for (; isset($sortArr[$i]); $i++) { } $sortArr[$i] = $item; } krsort($sortArr); $result['items'] = array_slice($sortArr, 0, $max_item); return $result; }
/** * @public * @brief Constructor * @todo * This method keeps a deprecated delegate. */ function Legacy_TextFilter() { $obj = $this->mMakeClickableConvertTable = new XCube_Delegate(); $obj->register('Legacy_TextFilter.MakeClickableConvertTable'); $obj->add('Legacy_TextFilter::makeClickableConvertTable', XCUBE_DELEGATE_PRIORITY_2); $obj = $this->mMakeXCodeConvertTable = new XCube_Delegate(); $obj->register('Legacy_TextFilter.MakeXCodeConvertTable'); $obj->add('Legacy_TextFilter::makeXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_2); $obj = $this->mMakeXCodeCheckImgPatterns = new XCube_Delegate(); $obj->register('Legacy_TextFilter.MakeXCodeCheckImgPatterns'); $obj->add('Legacy_TextFilter::makeXCodeCheckImgPatterns', XCUBE_DELEGATE_PRIORITY_2); $obj = $this->mMakePreXCodeConvertTable = new XCube_Delegate(); $obj->register('Legacy_TextFilter.MakePreXCodeConvertTable'); $obj->add('Legacy_TextFilter::makePreXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_2); $obj = $this->mMakePostXCodeConvertTable = new XCube_Delegate(); $obj->register('Legacy_TextFilter.MakePostXCodeConvertTable'); $obj->add('Legacy_TextFilter::makePostXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_2); //@deprecated //Todo: For keeping compatible with XC2.1 Beta3 $this->mMakeClickablePre = new XCube_Delegate(); $this->mMakeClickablePre->register('MyTextSanitizer.MakeClickablePre'); $this->mXCodePre = new XCube_Delegate(); $this->mXCodePre->register('MyTextSanitizer.XoopsCodePre'); }
function XoopsNotificationHandler(&$db) { parent::XoopsObjectHandler($db); $this->mTrigger = new XCube_Delegate(); $this->mTrigger->register('XoopsNotificationHandler.Trigger'); $this->mTriggerPreAction = new XCube_Delegate(); $this->mTriggerPreAction->register("XoopsNotificationHandler.TriggerPreAction"); }
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('<!--ckeditor4FlgSource-->', '', $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; }
function User_UserViewAction() { parent::User_AbstractViewAction(); $this->mGetUserPosts = new XCube_Delegate(); $this->mGetUserPosts->register('User_UserViewAction.GetUserPosts'); }
function Legacy_BlockCacheInformation() { parent::Legacy_AbstractCacheInformation(); $this->mGetCacheFilePath = new XCube_Delegate(); $this->mGetCacheFilePath->register('Legacy_BlockCachInformation.getCacheFilePath'); }
function Legacy_HelpAction($flag) { parent::Legacy_Action($flag); $this->mCreateHelpSmarty = new XCube_Delegate(); $this->mCreateHelpSmarty->add(array(&$this, '_createHelpSmarty')); $this->mCreateHelpSmarty->register('Legacy_HelpAction.CreateHelpSmarty'); }
function Legacy_BackendAction($flag) { parent::Legacy_Action($flag); $this->mGetRSSItems = new XCube_Delegate(); $this->mGetRSSItems->register('Legacy_BackendAction.GetRSSItems'); }
function update() { $updateSuccess = new XCube_Delegate(); $updateSuccess->register('Legacy_ModuleUpdateAction.UpdateSuccess'); $updateFail = new XCube_Delegate(); $updateFail->register('Legacy_ModuleUpdateAction.UpdateFail'); $module = get_module($this->name); $dirname = $module->get('dirname'); $installer = Legacy_ModuleInstallUtils::createUpdater($dirname); $installer->setCurrentXoopsModule($module); // Load the manifesto, and set it as the target object. $module->loadInfoAsVar($dirname); $module->set('name', $module->get('name')); $installer->setTargetXoopsModule($module); $installer->executeUpgrade(); if ($installer->mLog->hasError() === false) { $updateSuccess->call(new XCube_Ref($module), new XCube_Ref($installer->mLog)); XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($dirname . '.Success'), new XCube_Ref($module), new XCube_Ref($installer->mLog)); $success = true; } else { $updateFail->call(new XCube_Ref($module), new XCube_Ref($installer->mLog)); XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($dirname . '.Fail'), new XCube_Ref($module), new XCube_Ref($installer->mLog)); $success = false; } /* foreach ($installer->mLog->mMessages as $message) { echo sprintf('[%s] update: %s', date('Y-m-d H:i:s'), $message['message']), PHP_EOL; // TODO >> observer } */ return $success; }
function LegacyThemeHandler(&$db) { $this->mGetInstalledThemes = new XCube_Delegate(); $this->mGetInstalledThemes->register('LegacyThemeHandler.GetInstalledThemes'); }