Exemple #1
0
 static function check()
 {
     $mainframe = JFactory::getApplication();
     jckimport('ckeditor.plugins.helper');
     //import core plugins first
     JCKPluginsHelper::storePlugins('authenticate');
     JCKPluginsHelper::importPlugin('authenticate');
     return $mainframe->triggerEvent('authorise');
 }
Exemple #2
0
 static function check()
 {
     jckimport('ckeditor.plugins.helper');
     //import core plugins first
     JCKPluginsHelper::storePlugins('authenticate');
     JCKPluginsHelper::importPlugin('authenticate');
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger('authorise');
     for ($i = 0; $i < count($results); $i++) {
         if ($results[$i]) {
             return true;
         }
     }
     return false;
 }
Exemple #3
0
 function getHeadJavascript(&$params, &$errors, &$excludeEventHandlers)
 {
     global $option;
     //lets get JS object
     $javascript =& JCKJavascript::getInstance();
     //now Add intialisation scripts
     $mainframe =& JFactory::getApplication();
     $path_root = '../';
     if ($mainframe->isSite()) {
         $path_root = '';
     }
     jimport('joomla.environment.browser');
     $instance =& JBrowser::getInstance();
     $language =& JFactory::getLanguage();
     if ($language->isRTL()) {
         $direction = 'rtl';
     } else {
         $direction = 'ltr';
     }
     /* Load the CK's Parameters */
     $toolbar = $params->def('toolbar', 'Full');
     $toolbar_ft = $params->def('toolbar_ft', 'Full');
     $skin = $params->def('skin', 'office2007');
     $text_direction = $params->def('text_direction', 'ltr');
     $wwidth = $params->def('wwidth', '100%');
     $hheight = $params->def('hheight', 480);
     $lang_mode = $params->def('lang_mode', 0);
     $lang = $params->def('lang_code', 'en');
     $entermode = $params->def('entermode', 1);
     $shiftentermode = $params->def('shiftentermode', 0);
     $uicolor = $params->def('uicolor', '#D6E6F4');
     $imagepath = $params->def('magePath', 'images/stories');
     $returnScript = $params->get('returnScript', true);
     $editorname = $params->get('editorname');
     $bgcolor = $params->get('bgcolor', '#ffffff');
     //override autoLoad value if set in config
     jckimport('ckeditor.autoload.startconfig');
     $startConfig = new JCKStartConfig();
     if (isset($startConfig->{$option})) {
         $excludeEventHandlers = $startConfig->{$option};
     } else {
         $excludeEventHandlers = $returnScript;
     }
     //set default view for toolabar
     $toolbar = $toolbar == 'Default' ? 'Full' : $toolbar;
     $toolbar_ft = $toolbar_ft == 'Default' ? 'Full' : $toolbar_ft;
     if (!$path_root) {
         //set toolbar to compact mode
         $toolbar = $toolbar_ft;
     }
     // If language mode set
     // set default Joomla language setting
     switch ($lang_mode) {
         case 0:
             $AutoDetectLanguage = $lang;
             // User selection
             break;
         case 1:
             $AutoDetectLanguage = "";
             // Joomla Default
             $lang = substr($language->getTag(), 0, strpos($language->getTag(), '-'));
             //access joomlas global configuation and get the language setting from there
             break;
         case 2:
             $AutoDetectLanguage = "";
             // Browser default
             break;
     }
     $stylesheet =& JCKStylesheet::getInstance($path_root);
     $content_css = $stylesheet->getPath($params, $errors);
     $stylesheetJSO = $stylesheet->getJSObject();
     /*
      $jsloadJSO = 'var ckstyles_template;
      
      			window.addEvent("domready",function()
     			{
     				CKEDITOR.on("instanceReady",function(evt)
     				{
     					ckstyles_template = '.$stylesheetJSO .';
     				});
     			});';	
     $javascript->addScriptDeclaration($jsloadJSO);
     */
     //Get toolbar plugins object
     jckimport('ckeditor.plugins');
     jckimport('ckeditor.plugins.toolbarplugins');
     $plugins = new JCKtoolbarPlugins();
     $javascript->addScriptDeclaration("window.addEvent(\"domready\",function() \r\n\t\t{\r\n\t\t\tCKEDITOR.on('instanceCreated',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t\t editor.on( 'customConfigLoaded', function()\r\n\t\t\t\t {\r\n\t\t\t\t\t CKEDITOR.tools.extend( editor.config, \r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tremovePlugins : '" . $plugins->getRemovedPlugins() . "', \r\n\t\t\t\t\t\t\t\t\t\t\t\textraPlugins :\t'" . $plugins->getExtraPlugins() . "'\r\n\t\t\t\t\t\t\t\t\t\t\t}, true );\r\n\t\r\n\t\t\t\t });\t \r\n\t\t\t\t \r\n\t\t\t\t //addCustom CSS\r\n\t\t\t\t editor.addCss( 'body { background: " . $bgcolor . " none; }' );\r\n\t\t\t\t \r\n\t\t\t});\r\n\t\t\t\t\t\t\t\t\r\n\t\t});");
     //add JS for selected toolbar
     jckimport('ckeditor.toolbar');
     $toolbarFileName = strtolower($toolbar);
     jckimport('ckeditor.toolbar.' . $toolbarFileName);
     $toolbarClassName = 'JCK' . $toolbar;
     $toolbarObj = new $toolbarClassName();
     $jsonToolbarArray = $toolbarObj->toString();
     jckimport('ckeditor.plugins.helper');
     $session =& JFactory::getSession();
     //clear stored jckplugins
     $session->clear('jckplugins');
     $_GET['client'] = $mainframe->getClientId();
     JCKPluginsHelper::storePlugins('editor');
     JCKPluginsHelper::importPlugin('editor');
     $beforeloadResult = $mainframe->triggerEvent('beforeLoad', array($params));
     $afterloadResult = $mainframe->triggerEvent('afterLoad', array($params));
     $javascript->addScriptDeclaration("window.addEvent(\"domready\",function() \r\n\t\t{\r\n\t\t\tCKEDITOR.on('instanceCreated',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t editor.on( 'customConfigLoaded', function()\r\n\t\t\t\t {\r\n\t\t\t\t\teditor.config.toolbar_{$toolbar} = {$jsonToolbarArray};\r\n\t\r\n\t\t\t\t });\r\n\t\t\t" . (!empty($beforeloadResult) ? implode(chr(13), $beforeloadResult) : '') . "\t\r\n\t\t\t\t\t\r\n\t\t\t\t \r\n\t\t\t});\r\n\t\t});");
     $javascript->addScriptDeclaration("window.addEvent(\"domready\",function() \r\n\t\t{\r\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t " . (!empty($afterloadResult) ? implode(chr(13), $afterloadResult) : '') . "\t\r\n\t\t\t});\r\n\t\t});");
     $javascript->addScriptDeclaration("var oEditor;\r\n\t\t\t\t\t\t\t\t   \r\n\t\t\t\tfunction ReplaceTextContainer(div,autoHeight)\r\n\t\t\t\t{\r\n\t\t\t\t\t//destroy editor instance if one already exist \r\n\t\t\t\t\tif ( oEditor )\r\n\t\t\t\t\t\toEditor.destroy();\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\tCKEDITOR.config.startupFocus = true;\t\t\r\n\t\t\t\t\t//create editor instance\r\n\t\t\t\t\toEditor = CKEDITOR.replace(div,\r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\t baseHref : '" . JURI::root() . "',\r\n\t\t\t\t\t\t imagePath :  '{$imagepath}',     \r\n\t\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\r\n\t\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\r\n\t\t\t\t\t\t uiColor\t: '{$uicolor}',\r\n\t\t\t\t\t\t skin : '{$skin}',\t\r\n\t\t\t\t\t\t contentsCss :'{$content_css}',\r\n\t\t\t\t\t\t contentsLangDirection : '{$direction}',\r\n\t\t\t\t\t\t language : '{$AutoDetectLanguage}',\r\n\t\t\t\t\t\t defaultLanguage :'{$lang}', \r\n\t\t\t\t\t\t enterMode : '{$entermode}',\r\n\t\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\r\n\t\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\r\n\t\t\t\t\t\t width : '{$wwidth}',\r\n\t\t\t\t\t\t height: autoHeight ? div.clientHeight +28 : '{$hheight}'\r\n\t\t\t\t\t});\r\n\t\t\t\t}");
     $javascript->addScriptDeclaration("\r\n\t\t\t\t\t\t\t\t   \r\n\t\t\t\tfunction Replace" . $editorname . "TextContainer(div)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKEDITOR.config.startupFocus = true;\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t//create editor instance\r\n\t\t\t\t\tvar oEditor = CKEDITOR.replace(div,\r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\t baseHref : '" . JURI::root() . "',\r\n\t\t\t\t\t\t imagePath :  '{$imagepath}',     \r\n\t\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\r\n\t\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\r\n\t\t\t\t\t\t uiColor\t: '{$uicolor}',\r\n\t\t\t\t\t\t skin : '{$skin}',\t\r\n\t\t\t\t\t\t contentsCss :'{$content_css}',\r\n\t\t\t\t\t\t contentsLangDirection : '{$direction}',\r\n\t\t\t\t\t\t language : '{$AutoDetectLanguage}',\r\n\t\t\t\t\t\t defaultLanguage :'{$lang}', \r\n\t\t\t\t\t\t enterMode : '{$entermode}',\r\n\t\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\r\n\t\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\r\n\t\t\t\t\t\t width : '{$wwidth}',\r\n\t\t\t\t\t\t height: '{$hheight}'\r\n\t\t\t\t\t});\r\n\t\t\t\t}");
     $handlerjs = "\r\n\t\t\r\n\t\tfunction editor_onDoubleClick( ev )\r\n\t\t{\r\n\t\t\t// Get the element which fired the event. This is not necessarily the\r\n\t\t\t// element to which the event has been attached.\r\n\t\t\tvar element = ev.target || ev.srcElement;\r\n\t\t\t// Find out the divtext container that holds this element.\r\n\t\t\t\r\n\t\t\twhile( !(element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1  )) && element.nodeName.toLowerCase() != 'textarea'\r\n\t\t\t\t\t&& (element.parentNode && element.parentNode.nodeName.toLowerCase() != 'body'))\r\n\t\t\t\telement = element.parentNode;\r\n\t\t\t\r\n\t\t\tif ( (element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1 )) || element.nodeName.toLowerCase() == 'textarea')\r\n\t\t\t{\r\n\t\t\t\tif(element.hasAttribute('ckid') && element.getAttribute('ckid') == 'image'){\r\n\t\t\t\t\r\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = false;\r\n\t\t\t\t\tReplaceTextContainer( element,true);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = true;\r\n\t\t\t\t\tReplaceTextContainer( element,false);}\r\n\t\t\t}\t\t\r\n\t\t}\r\n\r\n\t\tvar editor_implementOnInstanceReady = function() \r\n\t\t{\r\n\t\t\t//CKEDITOR.config.expandedToolbar = false;\r\n\t\t\t\r\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tevt.editor.focus(); // why do we need to do this?\r\n\t\t\t\tif(!CKEDITOR.config.expandedToolbar)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar editor = evt.editor;\r\n\t\t\t\t\tvar imgElement  = editor.document.getBody().getElementsByTag('img').getItem(0);\r\n\t\t\t\t\tif(imgElement)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(editor.getSelection())\r\n\t\t\t\t\t\t\teditor.getSelection().selectElement(imgElement);\r\n\t\t\t\t\t}\t\t\r\n\t\t\t\t\t//add double click\r\n\t\t\t\t\teditor.document.on('dblclick', function(evt)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tevt.listenerData.editor.getCommand('ImageManager').exec(evt.listenerData.editor);\t\r\n\t\t\t\t\t},null,{editor : editor});\r\n\t\t\t\t\r\n\t\t\t\t\tif(editor.getSelection())\r\n\t\t\t\t\t\teditor.getCommand('ImageManager').exec(editor);\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\r\n\t\t\t});\r\n\t\t\t\r\n\t\t}\t\t\r\n\t\tif ( window.addEventListener )\r\n\t\t{\r\n\t\t\twindow.addEventListener( 'load', editor_implementOnInstanceReady, false );\t\r\n\t\t\twindow.addEventListener( 'dblclick', editor_onDoubleClick, false );\r\n\t\t}\r\n\t\telse if ( window.attachEvent )\r\n\t\t{\r\n\t\t\twindow.attachEvent( 'onload', editor_implementOnInstanceReady);\r\n\t\t\twindow.document.attachEvent( 'ondblclick', editor_onDoubleClick );\r\n\t\t}";
     if (!$excludeEventHandlers) {
         $javascript->addScriptDeclaration($handlerjs);
     }
     return $javascript;
 }
Exemple #4
0
 static function getHeadJavascript(&$params, &$errors, &$excludeEventHandlers)
 {
     global $option;
     //lets get JS object
     $javascript =& JCKJavascript::getInstance();
     //now Add intialisation scripts
     $mainframe = JFactory::getApplication();
     $path_root = '../';
     if ($mainframe->isSite()) {
         $path_root = '';
     }
     jimport('joomla.environment.browser');
     $instance = JBrowser::getInstance();
     $language = JFactory::getLanguage();
     if ($language->isRTL()) {
         $direction = 'rtl';
     } else {
         $direction = 'ltr';
     }
     /* Load the CK's Parameters */
     $skin = $params->def('skin', 'office2007');
     $hheight = $params->def('hheight', 480);
     $wwidth = $params->def('wwidth', '100%');
     $lang_mode = $params->def('lang_mode', 1);
     $lang = $params->def('lang_code', 'en');
     $entermode = $params->def('entermode', 1);
     $shiftentermode = $params->def('shiftentermode', 2);
     $uicolor = $params->def('uicolor', '#D6E6F4');
     $imagepath = $params->def('magePath', 'images/stories');
     $returnScript = $params->get('returnScript', true);
     $editorname = $params->get('editorname');
     $bgcolor = $params->get('bgcolor', '#ffffff');
     $ftcolor = $params->get('ftcolor', '');
     $textalign = $params->get('textalign', 0);
     $entities = $params->get('entities', 0);
     $formatsource = $params->get('formatsource', 1);
     $minify = $params->get('minify', 1);
     //override autoLoad value if set in config
     jckimport('ckeditor.autoload.startconfig');
     $startConfig = new JCKStartConfig();
     if (isset($startConfig->{$option})) {
         $excludeEventHandlers = $startConfig->{$option};
     } else {
         $excludeEventHandlers = $returnScript;
     }
     // If language mode set
     // set default Joomla language setting
     switch ($lang_mode) {
         case 0:
             $AutoDetectLanguage = $lang;
             // User selection
             break;
         case 1:
             $AutoDetectLanguage = "";
             // Joomla Default
             $lang = substr($language->getTag(), 0, strpos($language->getTag(), '-'));
             //access joomlas global configuation and get the language setting from there
             break;
         case 2:
             $AutoDetectLanguage = "";
             // Browser default
             $lang = "";
             break;
     }
     $params->set('JoomlaLang', $lang);
     $stylesheet =& JCKStylesheet::getInstance($params, $path_root);
     $content_css = $stylesheet->getPath($errors);
     $content_css = JURI::root() . $content_css;
     $content_css = str_replace(DS, '/', $content_css);
     $stylesheetJSO = $stylesheet->getJSObject();
     //Get toolbar plugins object
     jckimport('ckeditor.plugins');
     jckimport('ckeditor.plugins.toolbarplugins');
     $plugins = new JCKtoolbarPlugins();
     if ($textalign) {
         $textalign = "text-align:{$textalign};";
     } else {
         $textalign = "";
     }
     if (!$formatsource) {
         $formatsource = "\n\t\t\t\tvar format = [];\n\t\t\t\tformat['indent'] = false;\n\t\t\t\tformat['breakBeforeOpen'] = false; \n\t\t\t\tformat['breakAfterOpen'] =  false;\n\t\t\t\tformat['breakBeforeClose'] = false;\n\t\t\t\tformat['breakAfterClose'] = false;\n\t\t\t\tvar dtd = CKEDITOR.dtd;\n\t\t\t\tfor ( var e in CKEDITOR.tools.extend( {}, dtd.\$nonBodyContent, dtd.\$block, dtd.\$listItem, dtd.\$tableContent ) ) {\n\t\t\t\t\t\teditor.dataProcessor.writer.setRules( e, format); \n\t\t\t\t} \n\t\t\n\t\t\t\teditor.dataProcessor.writer.setRules( 'pre',\n\t\t\t\t{\n\t\t\t\t\tindent: false\n\t\t\t\t}); \n\t\t\t";
     } else {
         $formatsource = "\n\t\t\t\teditor.dataProcessor.writer.setRules( 'pre',\n\t\t\t\t{\n\t\t\t\t\tindent : false,\n\t\t\t\t\tbreakAfterOpen : false,\t\n\t\t\t\t    breakBeforeClose: false\n\t\t\t\t}); \n\t\t\t";
     }
     $javascript->addScriptDeclaration("\n\t\t\t\n            " . self::addDomReadyEventHandler() . " \n            \n            window.addDomReadyEvent.add(function() \n\t\t\t{\n\t\t\t\n\t\t\t\tCKEDITOR.on('instanceCreated',function(evt)\n\t\t\t\t{\n\t\t\t\t\t var editor = evt.editor;\n\t\t\t\t\t \n\t\t\t\t\t editor.on( 'customConfigLoaded', function()\n\t\t\t\t\t {\n\t\t\t\t\t\t CKEDITOR.tools.extend( editor.config, \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tremovePlugins : '" . $plugins->getRemovedPlugins() . "', \n\t\t\t\t\t\t\textraPlugins :\t'" . $plugins->getExtraPlugins() . "'\n\t\t\t\t\t\t}, true );\n\t\t\n\t\t\t\t\t });\t \n\t\t\t\t\t \n\t\t\t\t\t //addCustom CSS\n\t\t\t\t\t editor.addCss( 'body { background: " . $bgcolor . " none;" . $textalign . ";}' );\n\t\t\t\t\t " . ($ftcolor ? "editor.addCss( 'body { color: " . $ftcolor . "; }' )" : "") . "\n\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\n\t\t\t});");
     jckimport('ckeditor.plugins.helper');
     //import core plugins first
     JCKPluginsHelper::storePlugins('toolbar');
     JCKPluginsHelper::importPlugin('toolbar');
     $mainframe->triggerEvent('load', array(&$params));
     $toolbar = $params->def('toolbar', 'Publisher');
     $toolbar_ft = $params->def('toolbar_ft', 'Basic');
     //set default view for toolabar
     $toolbar = $toolbar == 'Default' ? 'Full' : $toolbar;
     $toolbar_ft = $toolbar_ft == 'Default' ? 'Full' : $toolbar_ft;
     if (!$path_root) {
         //set toolbar to compact mode
         $toolbar = $toolbar_ft;
     }
     //add JS for selected toolbar
     jckimport('ckeditor.toolbar');
     $toolbarFileName = strtolower($toolbar);
     jckimport('ckeditor.toolbar.' . $toolbarFileName);
     $toolbarClassName = 'JCK' . $toolbar;
     $toolbarObj = new $toolbarClassName();
     $jsonToolbarArray = $toolbarObj->toString();
     //set session
     $clientid = $mainframe->getClientId();
     $_GET['client'] = $clientid;
     //set jck_toolbar param
     $params->set('jck_toolbar', $toolbar);
     //import core plugins first
     JCKPluginsHelper::storePlugins('core');
     JCKPluginsHelper::importPlugin('core');
     $results = $mainframe->triggerEvent('intialize', array(&$params));
     JCKPluginsHelper::storePlugins('editor');
     JCKPluginsHelper::importPlugin('editor');
     $beforeloadResult = $mainframe->triggerEvent('beforeLoad', array(&$params));
     $afterloadResult = $mainframe->triggerEvent('afterLoad', array(&$params));
     $javascript->addScriptDeclaration("window.addDomReadyEvent.add(function() \n\t\t{\n\t\n\t\t\t" . (!empty($results) ? implode(chr(13), $results) : '') . "\t\n\t\t\t\n\t\t\tCKEDITOR.on('instanceCreated',function(evt)\n\t\t\t{\n\t\t\t\t var editor = evt.editor;\n\t\t\t\t editor.on( 'customConfigLoaded', function()\n\t\t\t\t {\n\t\t\t\t\teditor.config.toolbar_{$toolbar} = {$jsonToolbarArray};\n\t\n\t\t\t\t });\n\t\t\t" . (!empty($beforeloadResult) ? implode(chr(13), $beforeloadResult) : '') . "\t\n\t\t\t\t\t \n\t\t\t});\n\t\t});");
     $javascript->addScriptDeclaration("window.addDomReadyEvent.add(function() \n\t\t{\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\n\t\t\t{\n\t\t\t\t var editor = evt.editor;\n\t\t\t\t {$formatsource}\n\t\t\t\t \t\t\t\t \n\t\t\t\t " . (!empty($afterloadResult) ? implode(chr(13), $afterloadResult) : '') . "\t\n\t\t\t});\n\t\t});");
     $javascript->addScriptDeclaration("var oEditor;\n\t\t\t\t\t\t\t\t   \n\t\t\t\tfunction ReplaceTextContainer(div,autoHeight)\n\t\t\t\t{\n\t\t\t\t\t//destroy editor instance if one already exist \n\t\t\t\t\tif ( oEditor )\n\t\t\t\t\t\toEditor.destroy();\n\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\tCKEDITOR.config.startupFocus = true;\t\t\n\t\t\t\t\t//create editor instance\n\t\t\t\t\toEditor = CKEDITOR.replace(div,\n\t\t\t\t\t{ \n\t\t\t\t\t\t baseHref : '" . JURI::root() . "',\n\t\t\t\t\t\t imagePath :  '{$imagepath}',     \n\t\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\n\t\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\n\t\t\t\t\t\t uiColor\t: '{$uicolor}',\n\t\t\t\t\t\t skin : '{$skin}',\t\n\t\t\t\t\t\t contentsCss :['{$content_css}'],\n\t\t\t\t\t\t contentsLangDirection : '{$direction}',\n\t\t\t\t\t\t language : '{$lang}',\n\t\t\t\t\t\t defaultLanguage :'{$AutoDetectLanguage}', \n\t\t\t\t\t\t enterMode : '{$entermode}',\n\t\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\n\t\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\n\t\t\t\t\t\t " . ($wwidth ? "width : '{$wwidth}'" : "") . ",\n\t\t\t\t\t\t height: autoHeight ? div.clientHeight +28 : '{$hheight}',\n\t\t\t\t\t\t entities : " . (int) $entities . "\n\t\t\t\t\t});\n\t\t\t\t}");
     $editorname = JCKOutput::fixId($editorname);
     $javascript->addScriptDeclaration("\n\t\t\t\t\t\t\t\t   \n\t\t\t\t\n\t\twindow.addDomReadyEvent.add(function() \n\t\t{\n \t\t\tCKEDITOR.tools.addHashFunction(function(div)\n\t\t\t{\n\t\t\t\t//create editor instance\n\t\t\t\tvar oEditor = CKEDITOR.replace(div,\n\t\t\t\t{ \n\t\t\t\t\t baseHref : '" . JURI::root() . "',\n\t\t\t\t\t imagePath :  '{$imagepath}',     \n\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\n\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\n\t\t\t\t\t uiColor\t: '{$uicolor}',\n\t\t\t\t\t skin : '{$skin}',\t\n\t\t\t\t\t contentsCss :['{$content_css}'],\n\t\t\t\t\t contentsLangDirection : '{$direction}',\n\t\t\t\t\t language : '{$lang}',\n\t\t\t\t\t defaultLanguage :'{$AutoDetectLanguage}', \n\t\t\t\t\t enterMode : '{$entermode}',\n\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\n\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\n\t\t\t\t\t " . ($wwidth ? "width : '{$wwidth}'" : "") . ",\n\t\t\t\t\t " . ($hheight ? "height : '{$hheight}'" : "") . ",\n\t\t\t\t\t entities : " . (int) $entities . "\n\t\t\t\t});\n\t\t\t},'" . $editorname . "');\n\t\t});");
     $handlerjs = "\n\t\t\n\t\tfunction editor_onDoubleClick( ev )\n\t\t{\n\t\t\t// Get the element which fired the event. This is not necessarily the\n\t\t\t// element to which the event has been attached.\n\t\t\tvar element = ev.target || ev.srcElement;\n\t\t\t// Find out the divtext container that holds this element.\n\t\t\t\n\t\t\twhile( !(element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1  )) && element.nodeName.toLowerCase() != 'textarea'\n\t\t\t\t\t&& (element.parentNode && element.parentNode.nodeName.toLowerCase() != 'body'))\n\t\t\t\telement = element.parentNode;\n\t\t\t\n\t\t\tif ( (element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1 )) || element.nodeName.toLowerCase() == 'textarea')\n\t\t\t{\n\t\t\t\tif(element.hasAttribute('ckid') && element.getAttribute('ckid') == 'image'){\n\t\t\t\t\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = false;\n\t\t\t\t\tReplaceTextContainer( element,true);\n\t\t\t\t}else{\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = true;\n\t\t\t\t\tReplaceTextContainer( element,false);}\n\t\t\t}\t\t\n\t\t}\n\n\t\tvar editor_implementOnInstanceReady = function() \n\t\t{\n\t\t\t//CKEDITOR.config.expandedToolbar = false;\n\t\t\t\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\n\t\t\t{\n\t\t\t\t\n\t\t\t\tevt.editor.focus(); // why do we need to do this?\n\t\t\t\tif(!CKEDITOR.config.expandedToolbar)\n\t\t\t\t{\n\t\t\t\t\tvar editor = evt.editor;\n\t\t\t\t\tvar imgElement  = editor.document.getBody().getElementsByTag('img').getItem(0);\n\t\t\t\t\tif(imgElement)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(editor.getSelection())\n\t\t\t\t\t\t\teditor.getSelection().selectElement(imgElement);\n\t\t\t\t\t}\t\t\n\t\t\t\t\t//add double click\n\t\t\t\t\teditor.document.on('dblclick', function(evt)\n\t\t\t\t\t{\n\t\t\t\t\t\tevt.listenerData.editor.getCommand('ImageManager').exec(evt.listenerData.editor);\t\n\t\t\t\t\t},null,{editor : editor});\n\t\t\t\t\n\t\t\t\t\tif(editor.getSelection())\n\t\t\t\t\t\teditor.getCommand('ImageManager').exec(editor);\t\n\t\t\t\t\t\t\n\t\t\t\t}\t\n\n\t\t\t});\n\t\t\t\n\t\t}\t\t\n\t\tif ( window.addEventListener )\n\t\t{\n\t\t\twindow.addEventListener( 'load', editor_implementOnInstanceReady, false );\t\n\t\t\twindow.addEventListener( 'dblclick', editor_onDoubleClick, false );\n\t\t}\n\t\telse if ( window.attachEvent )\n\t\t{\n\t\t\twindow.attachEvent( 'onload', editor_implementOnInstanceReady);\n\t\t\twindow.document.attachEvent( 'ondblclick', editor_onDoubleClick );\n\t\t}";
     if (!$excludeEventHandlers) {
         $javascript->addScriptDeclaration($handlerjs);
     }
     $javascript->setMinify($minify);
     return $javascript;
 }
Exemple #5
0
 static function getHeadJavascript(&$params, &$errors, &$excludeEventHandlers)
 {
     global $option;
     //lets get JS object
     $javascript =& JCKJavascript::getInstance();
     //now Add intialisation scripts
     $mainframe = JFactory::getApplication();
     $path_root = '../';
     if ($mainframe->isSite()) {
         $path_root = '';
     }
     jimport('joomla.environment.browser');
     $instance = JBrowser::getInstance();
     $language = JFactory::getLanguage();
     if ($language->isRTL()) {
         $direction = 'rtl';
     } else {
         $direction = 'ltr';
     }
     /* Load the CK's Parameters */
     $toolbar = $params->def('toolbar', 'Full');
     $toolbar_ft = $params->def('toolbar_ft', 'Full');
     $skin = $params->def('skin', 'office2007');
     $hheight = $params->def('hheight', 480);
     $wwidth = $params->def('wwidth', '100%');
     $lang_mode = $params->def('lang_mode', 0);
     $lang = $params->def('lang_code', 'en');
     $entermode = $params->def('entermode', 1);
     $shiftentermode = $params->def('shiftentermode', 0);
     $uicolor = $params->def('uicolor', '#D6E6F4');
     $imagepath = $params->def('magePath', 'images/stories');
     $returnScript = $params->get('returnScript', true);
     $editorname = $params->get('editorname');
     $bgcolor = $params->get('bgcolor', '#ffffff');
     $textalign = $params->get('textalign', 0);
     $entities = $params->get('entities', 0);
     $formatsource = $params->get('formatsource', 1);
     //override autoLoad value if set in config
     jckimport('ckeditor.autoload.startconfig');
     $startConfig = new JCKStartConfig();
     if (isset($startConfig->{$option})) {
         $excludeEventHandlers = $startConfig->{$option};
     } else {
         $excludeEventHandlers = $returnScript;
     }
     //set default view for toolabar
     $toolbar = $toolbar == 'Default' ? 'Full' : $toolbar;
     $toolbar_ft = $toolbar_ft == 'Default' ? 'Full' : $toolbar_ft;
     if (!$path_root) {
         //set toolbar to compact mode
         $toolbar = $toolbar_ft;
     }
     // If language mode set
     // set default Joomla language setting
     switch ($lang_mode) {
         case 0:
             $AutoDetectLanguage = $lang;
             // User selection
             break;
         case 1:
             $AutoDetectLanguage = "";
             // Joomla Default
             $lang = substr($language->getTag(), 0, strpos($language->getTag(), '-'));
             //access joomlas global configuation and get the language setting from there
             break;
         case 2:
             $AutoDetectLanguage = "";
             // Browser default
             $lang = "";
             break;
     }
     $stylesheet =& JCKStylesheet::getInstance($path_root);
     $content_css = $stylesheet->getPath($params, $errors);
     $stylesheetJSO = $stylesheet->getJSObject();
     /*
      $jsloadJSO = 'var ckstyles_template;
      
      			window.addDomReadyEvent.add(function()
     			{
     				CKEDITOR.on("instanceReady",function(evt)
     				{
     					ckstyles_template = '.$stylesheetJSO .';
     				});
     			});';	
     $javascript->addScriptDeclaration($jsloadJSO);
     */
     //Get toolbar plugins object
     jckimport('ckeditor.plugins');
     jckimport('ckeditor.plugins.toolbarplugins');
     $plugins = new JCKtoolbarPlugins();
     if ($textalign) {
         $textalign = "text-align:{$textalign};";
     } else {
         $textalign = "";
     }
     if (!$formatsource) {
         $formatsource = "\r\n\t\t\t\tvar format = [];\r\n\t\t\t\tformat['indent'] = false;\r\n\t\t\t\tformat['breakBeforeOpen'] = false; \r\n\t\t\t\tformat['breakAfterOpen'] =  false;\r\n\t\t\t\tformat['breakBeforeClose'] = false;\r\n\t\t\t\tformat['breakAfterClose'] = false;\r\n\t\t\t\tvar dtd = CKEDITOR.dtd;\r\n\t\t\t\tfor ( var e in CKEDITOR.tools.extend( {}, dtd.\$nonBodyContent, dtd.\$block, dtd.\$listItem, dtd.\$tableContent ) ) {\r\n\t\t\t\t\t\teditor.dataProcessor.writer.setRules( e, format); \r\n\t\t\t\t} \r\n\t\t\r\n\t\t\t\teditor.dataProcessor.writer.setRules( 'pre',\r\n\t\t\t\t{\r\n\t\t\t\t\tindent: false\r\n\t\t\t\t}); \r\n\t\t\t";
     } else {
         $formatsource = '';
     }
     $javascript->addScriptDeclaration("\r\n\t\r\n\t\t\tif (typeof JCKEvent == 'undefined') {\r\n\t\t\t\r\n\t\t\tvar JCKEvent = {};\r\n\t\t\t\r\n\t\t\tJCKEvent.domReady = {\r\n\t\t\t  add: function(fn) {\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\tif (JCKEvent.domReady.loaded) return fn();\r\n\t\t\t\t\r\n\t\t\r\n\t\t\t\tvar observers = JCKEvent.domReady.observers;\r\n\t\t\t\tif (!observers) observers = JCKEvent.domReady.observers = [];\r\n\t\t\t\tobservers[observers.length] = fn;\r\n\t\t\r\n\t\t\t\tif (typeof JCKEvent.domReady.callback != 'undefined') return;\r\n\t\t\r\n\t\t\t\tJCKEvent.domReady.callback = function() {\r\n\t\t\t\t  if (JCKEvent.domReady.loaded) return;\r\n\t\t\t\t  \r\n\t\t\t\t  JCKEvent.domReady.loaded = true;\r\n\t\t\t\t  if (JCKEvent.domReady.timer) {\r\n\t\t\t\t\tclearInterval(JCKEvent.domReady.timer);\r\n\t\t\t\t\tJCKEvent.domReady.timer = null;\r\n\t\t\t\t  }\r\n\t\t\t\t \r\n\t\t\t\t  var observers = JCKEvent.domReady.observers;\r\n\t\t\t\t  for (var i = 0, length = observers.length; i < length; i++) {\r\n\t\t\t\t\tvar fn = observers[i];\r\n\t\t\t\t\tobservers[i] = null;\r\n\t\t\t\t\tfn(); // make 'this' as window\r\n\t\t\t\t  }\r\n\t\t\t\t  JCKEvent.domReady.callback = JCKEvent.domReady.observers = null;\r\n\t\t\t\t};\r\n\t\t\r\n\t\t\t\r\n\t\t\t\tvar ie = !!(window.attachEvent && !window.opera);\r\n\t\t\t\tvar webkit = navigator.userAgent.indexOf('AppleWebKit/') > -1;\r\n\t\t\t\t\r\n\t\t\t\tif (document.readyState && webkit) {\r\n\t\t\t\t  \r\n\t\t\t\t  // Apple WebKit (Safari, OmniWeb, ...)\r\n\t\t\t\t  JCKEvent.domReady.timer = setInterval(function() {\r\n\t\t\t\t\tvar state = document.readyState;\r\n\t\t\t\t\tif (state == 'loaded' || state == 'complete') {\r\n\t\t\t\t\t  JCKEvent.domReady.callback();\r\n\t\t\t\t\t}\r\n\t\t\t\t  }, 50);\r\n\t\t\t\t  \r\n\t\t\t\t} else if (document.readyState && ie) {\r\n\t\t\t\t  \r\n\t\t\t\t  // Windows IE \r\n\t\t\t\t  var src = (window.location.protocol == 'https:') ? '://0' : 'javascript:void(0)';\r\n\t\t\t\t  document.write(\r\n\t\t\t\t\t'<script type=\"text/javascript\" defer=\"defer\" src=\"' + src + '\" ' + \r\n\t\t\t\t\t'onreadystatechange=\"if (this.readyState == \\'complete\\') JCKEvent.domReady.callback();\"' + \r\n\t\t\t\t\t'><\\/script>');\r\n\t\t\t\t  \r\n\t\t\t\t} else {\r\n\t\t\t\t  \r\n\t\t\t\t  if (window.addEventListener) {\r\n\t\t\t\t\t// for Mozilla browsers, Opera 9\r\n\t\t\t\t\tdocument.addEventListener(\"DOMContentLoaded\", JCKEvent.domReady.callback, false);\r\n\t\t\t\t\t// Fail safe \r\n\t\t\t\t\twindow.addEventListener(\"load\", JCKEvent.domReady.callback, false);\r\n\t\t\t\t  } else if (window.attachEvent) {\r\n\t\t\t\t\twindow.attachEvent('onload', JCKEvent.domReady.callback);\r\n\t\t\t\t  } else {\r\n\t\t\t\t\t// Legacy browsers (e.g. Mac IE 5)\r\n\t\t\t\t\tvar fn = window.onload;\r\n\t\t\t\t\twindow.onload = function() {\r\n\t\t\t\t\t  JCKEvent.domReady.callback();\r\n\t\t\t\t\t  if (fn) fn();\r\n\t\t\t\t\t}\r\n\t\t\t\t  }\r\n\t\t\t\t  \r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t  }\r\n\t\t\t}\r\n\t\t\r\n\t\t\twindow.addDomReadyEvent = {};\r\n\t\t\tif(typeof window.addDomReadyEvent.add == 'undefined')\r\n\t\t\t\twindow.addDomReadyEvent.add = JCKEvent.domReady.add;\r\n\t\t}\r\n\t\t\r\n\t\twindow.addDomReadyEvent.add(function() \r\n\t\t{\r\n\t\t\r\n\t\t\tCKEDITOR.on('instanceCreated',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t\t editor.on( 'customConfigLoaded', function()\r\n\t\t\t\t {\r\n\t\t\t\t\t CKEDITOR.tools.extend( editor.config, \r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tremovePlugins : '" . $plugins->getRemovedPlugins() . "', \r\n\t\t\t\t\t\t\t\t\t\t\t\textraPlugins :\t'" . $plugins->getExtraPlugins() . "'\r\n\t\t\t\t\t\t\t\t\t\t\t}, true );\r\n\t\r\n\t\t\t\t });\t \r\n\t\t\t\t \r\n\t\t\t\t //addCustom CSS\r\n\t\t\t\t editor.addCss( 'body { background: " . $bgcolor . " none;" . $textalign . "}' );\r\n\t\t\t \r\n\t\t\t});\r\n\t\t\t\t\t\t\t\t\r\n\t\t});");
     //add JS for selected toolbar
     jckimport('ckeditor.toolbar');
     $toolbarFileName = strtolower($toolbar);
     jckimport('ckeditor.toolbar.' . $toolbarFileName);
     $toolbarClassName = 'JCK' . $toolbar;
     $toolbarObj = new $toolbarClassName();
     $jsonToolbarArray = $toolbarObj->toString();
     jckimport('ckeditor.plugins.helper');
     //import core plugins first
     JCKPluginsHelper::storePlugins('core');
     JCKPluginsHelper::importPlugin('core');
     $results = $mainframe->triggerEvent('intialize', array(&$params));
     $_GET['client'] = $mainframe->getClientId();
     /*		$session =& JFactory::getSession();
     		//clear stored jckplugins
     		$session->clear('jckplugins');		
     */
     JCKPluginsHelper::storePlugins('editor');
     JCKPluginsHelper::importPlugin('editor');
     $beforeloadResult = $mainframe->triggerEvent('beforeLoad', array(&$params));
     $afterloadResult = $mainframe->triggerEvent('afterLoad', array(&$params));
     $javascript->addScriptDeclaration("window.addDomReadyEvent.add(function() \r\n\t\t{\r\n\t\r\n\t\t\t" . (!empty($results) ? implode(chr(13), $results) : '') . "\t\r\n\t\t\t\r\n\t\t\tCKEDITOR.on('instanceCreated',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t editor.on( 'customConfigLoaded', function()\r\n\t\t\t\t {\r\n\t\t\t\t\teditor.config.toolbar_{$toolbar} = {$jsonToolbarArray};\r\n\t\r\n\t\t\t\t });\r\n\t\t\t" . (!empty($beforeloadResult) ? implode(chr(13), $beforeloadResult) : '') . "\t\r\n\t\t\t\t\t \r\n\t\t\t});\r\n\t\t});");
     $javascript->addScriptDeclaration("window.addDomReadyEvent.add(function() \r\n\t\t{\r\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\r\n\t\t\t{\r\n\t\t\t\t var editor = evt.editor;\r\n\t\t\t\t {$formatsource}\r\n\t\t\t\t \t\t\t\t \r\n\t\t\t\t " . (!empty($afterloadResult) ? implode(chr(13), $afterloadResult) : '') . "\t\r\n\t\t\t});\r\n\t\t});");
     $javascript->addScriptDeclaration("var oEditor;\r\n\t\t\t\t\t\t\t\t   \r\n\t\t\t\tfunction ReplaceTextContainer(div,autoHeight)\r\n\t\t\t\t{\r\n\t\t\t\t\t//destroy editor instance if one already exist \r\n\t\t\t\t\tif ( oEditor )\r\n\t\t\t\t\t\toEditor.destroy();\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\tCKEDITOR.config.startupFocus = true;\t\t\r\n\t\t\t\t\t//create editor instance\r\n\t\t\t\t\toEditor = CKEDITOR.replace(div,\r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\t baseHref : '" . JURI::root() . "',\r\n\t\t\t\t\t\t imagePath :  '{$imagepath}',     \r\n\t\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\r\n\t\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\r\n\t\t\t\t\t\t uiColor\t: '{$uicolor}',\r\n\t\t\t\t\t\t skin : '{$skin}',\t\r\n\t\t\t\t\t\t contentsCss :'{$content_css}',\r\n\t\t\t\t\t\t contentsLangDirection : '{$direction}',\r\n\t\t\t\t\t\t language : '{$lang}',\r\n\t\t\t\t\t\t defaultLanguage :'{$AutoDetectLanguage}', \r\n\t\t\t\t\t\t enterMode : '{$entermode}',\r\n\t\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\r\n\t\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\r\n\t\t\t\t\t\t width : '{$wwidth}',\r\n\t\t\t\t\t\t height: autoHeight ? div.clientHeight +28 : '{$hheight}',\r\n\t\t\t\t\t\t entities : " . (int) $entities . "\r\n\t\t\t\t\t});\r\n\t\t\t\t}");
     $editorname = JCKOutput::fixId($editorname);
     $javascript->addScriptDeclaration("\r\n\t\t\t\t\t\t\t\t   \r\n\t\t\t\t\r\n\t\twindow.addDomReadyEvent.add(function() \r\n\t\t{\r\n \t\t\tCKEDITOR.tools.addHashFunction(function(div)\r\n\t\t\t{\r\n\t\t\t\t//create editor instance\r\n\t\t\t\tvar oEditor = CKEDITOR.replace(div,\r\n\t\t\t\t{ \r\n\t\t\t\t\t baseHref : '" . JURI::root() . "',\r\n\t\t\t\t\t imagePath :  '{$imagepath}',     \r\n\t\t\t\t\t toolbar : CKEDITOR.config.expandedToolbar ? '{$toolbar}' : 'Image',\r\n\t\t\t\t\t toolbarStartupExpanded : CKEDITOR.config.expandedToolbar,\r\n\t\t\t\t\t uiColor\t: '{$uicolor}',\r\n\t\t\t\t\t skin : '{$skin}',\t\r\n\t\t\t\t\t contentsCss :'{$content_css}',\r\n\t\t\t\t\t contentsLangDirection : '{$direction}',\r\n\t\t\t\t\t language : '{$lang}',\r\n\t\t\t\t\t defaultLanguage :'{$AutoDetectLanguage}', \r\n\t\t\t\t\t enterMode : '{$entermode}',\r\n\t\t\t\t\t shiftEnterMode : '{$shiftentermode}',\r\n\t\t\t\t\t stylesSet : " . $stylesheetJSO . ",\r\n\t\t\t\t\t width : '{$wwidth}',\r\n\t\t\t\t\t height: '{$hheight}',\r\n\t\t\t\t\t entities : " . (int) $entities . "\r\n\t\t\t\t});\r\n\t\t\t},'" . $editorname . "');\r\n\t\t});");
     $handlerjs = "\r\n\t\t\r\n\t\tfunction editor_onDoubleClick( ev )\r\n\t\t{\r\n\t\t\t// Get the element which fired the event. This is not necessarily the\r\n\t\t\t// element to which the event has been attached.\r\n\t\t\tvar element = ev.target || ev.srcElement;\r\n\t\t\t// Find out the divtext container that holds this element.\r\n\t\t\t\r\n\t\t\twhile( !(element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1  )) && element.nodeName.toLowerCase() != 'textarea'\r\n\t\t\t\t\t&& (element.parentNode && element.parentNode.nodeName.toLowerCase() != 'body'))\r\n\t\t\t\telement = element.parentNode;\r\n\t\t\t\r\n\t\t\tif ( (element.nodeName.toLowerCase() == 'div' && (element.hasAttribute('ckid') || element.className.indexOf( 'editable' ) != -1 )) || element.nodeName.toLowerCase() == 'textarea')\r\n\t\t\t{\r\n\t\t\t\tif(element.hasAttribute('ckid') && element.getAttribute('ckid') == 'image'){\r\n\t\t\t\t\r\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = false;\r\n\t\t\t\t\tReplaceTextContainer( element,true);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tCKEDITOR.config.expandedToolbar = true;\r\n\t\t\t\t\tReplaceTextContainer( element,false);}\r\n\t\t\t}\t\t\r\n\t\t}\r\n\r\n\t\tvar editor_implementOnInstanceReady = function() \r\n\t\t{\r\n\t\t\t//CKEDITOR.config.expandedToolbar = false;\r\n\t\t\t\r\n\t\t\tCKEDITOR.on('instanceReady',function(evt)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tevt.editor.focus(); // why do we need to do this?\r\n\t\t\t\tif(!CKEDITOR.config.expandedToolbar)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar editor = evt.editor;\r\n\t\t\t\t\tvar imgElement  = editor.document.getBody().getElementsByTag('img').getItem(0);\r\n\t\t\t\t\tif(imgElement)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(editor.getSelection())\r\n\t\t\t\t\t\t\teditor.getSelection().selectElement(imgElement);\r\n\t\t\t\t\t}\t\t\r\n\t\t\t\t\t//add double click\r\n\t\t\t\t\teditor.document.on('dblclick', function(evt)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tevt.listenerData.editor.getCommand('ImageManager').exec(evt.listenerData.editor);\t\r\n\t\t\t\t\t},null,{editor : editor});\r\n\t\t\t\t\r\n\t\t\t\t\tif(editor.getSelection())\r\n\t\t\t\t\t\teditor.getCommand('ImageManager').exec(editor);\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\r\n\t\t\t});\r\n\t\t\t\r\n\t\t}\t\t\r\n\t\tif ( window.addEventListener )\r\n\t\t{\r\n\t\t\twindow.addEventListener( 'load', editor_implementOnInstanceReady, false );\t\r\n\t\t\twindow.addEventListener( 'dblclick', editor_onDoubleClick, false );\r\n\t\t}\r\n\t\telse if ( window.attachEvent )\r\n\t\t{\r\n\t\t\twindow.attachEvent( 'onload', editor_implementOnInstanceReady);\r\n\t\t\twindow.document.attachEvent( 'ondblclick', editor_onDoubleClick );\r\n\t\t}";
     if (!$excludeEventHandlers) {
         $javascript->addScriptDeclaration($handlerjs);
     }
     return $javascript;
 }
Exemple #6
0
jimport('joomla.environment.request');
jimport('joomla.environment.response');
jimport('joomla.language.language');
jimport('joomla.user.user');
jimport('joomla.application.component.model');
jimport('joomla.database.table');
jimport('joomla.html.parameter');
jimport('joomla.plugin.helper');
jimport('joomla.event.dispatcher');
/* load JCK loader class*/
require_once CKEDITOR_INCLUDES_DIR . '/loader.php';
//lets set DB configuration
$config = new JConfig();
// Get the global configuration object
$registry =& JFactory::getConfig();
// Load the configuration values into the registry
$registry->loadObject($config);
//set session
jckimport('ckeditor.user.user');
$session =& JCKUser::getSession();
// system events trigger events
jckimport('ckeditor.plugins.helper');
//load CK System plugins
JCKPluginsHelper::storePlugins('default');
$dispatcher =& JDispatcher::getInstance();
$plugin =& JPluginHelper::getPlugin('editors', 'jckeditor');
$params = new JParameter($plugin->params);
//import System plugin first
JCKPluginsHelper::importPlugin('default');
$dispatcher->trigger('intialize', array(&$params));
$plugin->params = $params->toString();
Exemple #7
0
//Get image/flash and filepath directories
$imagePath = 'images';
$flashPath = 'flash';
$filePath = 'files';
$plugin =& JPluginHelper::getPlugin('editors', 'jckeditor');
$params = new JParameter($plugin->params);
jimport('joomla.event.dispatcher');
// system events trigger events
//import CK plugins
jckimport('ckeditor.plugins.helper');
JCKPluginsHelper::storePlugins('default');
$dispatcher =& JDispatcher::getInstance();
//import System plugin first
JCKPluginsHelper::importPlugin('default');
$dispatcher->trigger('intialize', array($params));
JCKPluginsHelper::importPlugin('filebrowser');
$dispatcher =& JDispatcher::getInstance();
$dispatcher->trigger('beforeSetImagePath', array($params));
$dispatcher->trigger('beforeSetFlashPath', array($params));
$dispatcher->trigger('beforeSetFilePath', array($params));
$imagePath = $params->get('imagePath', 'images');
$flashPath = $params->get('flashPath', 'flash');
$filePath = $params->get('filePath', 'files');
$dispatcher->trigger('afterSetImagePath', array($params));
$dispatcher->trigger('afterSetFlashPath', array($params));
$dispatcher->trigger('afterSetFilePath', array($params));
$baseUrl = '';
//set to relative
// $baseDir : the path to the local directory (in the server) which points to the
// above $baseUrl URL. This is the path used by CKEditor to handle the files in
// the server. Full write permissions must be granted to this directory.
Exemple #8
0
 function _parse($file)
 {
     //Get JCK additional styles
     //Get editor params
     $plugin = JPluginHelper::getPlugin('editors', 'jckeditor');
     if (is_string($plugin->params)) {
         //always must do this check
         $params = @new JRegistry($plugin->params);
     } else {
         $params = $plugin->params;
     }
     if (!$params->get('styles_css', true)) {
         $this->_default_beez_template = '';
     }
     $params->set('default_beez_template', $this->_default_beez_template);
     jckimport('ckeditor.plugins.helper');
     //import plugins
     JCKPluginsHelper::storePlugins('stylesheet');
     JCKPluginsHelper::importPlugin('stylesheet');
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger('load', array(&$params));
     $results = array_reverse($results);
     for ($i = 0; $i < count($results); $i++) {
         if ($results[$i]) {
             $this->_readCSS($results[$i]);
         }
     }
     preg_match_all('/^\\s*(?:[a-z0-9\\s\\b]*)@import\\s*(?:url\\()?(?:"|\')?([^"\'\\)]+)(?:"|\')?\\)?;/im', $file, $fmatches, PREG_SET_ORDER);
     foreach ($fmatches as $fmatch) {
         $oldumask = umask(0);
         @chmod($fmatch[1], 0666);
         umask($oldumask);
         if (!strpos($fmatch[1], '://')) {
             $content = file_get_contents($this->_dir . "/" . $fmatch[1]);
         } else {
             $content = file_get_contents($fmatch[1]);
         }
         $this->_parse($content);
     }
     // foreach fmatches
     $this->_readCSS($file);
 }
Exemple #9
0
# Copyright (C) 2005-2012 WebxSolution Ltd. All Rights Reserved.
# @license - GPLv2.0
# Author: WebxSolution Ltd
# Websites:  http://www.webxsolution.com
# Terms of Use: An extension that is derived from the JoomlaCK editor will only be allowed under the following conditions: http://joomlackeditor.com/terms-of-use
# ------------------------------------------------------------------------*/
require 'includes.php';
defined('_JEXEC') or die('Restricted access');
$app = JFactory::getApplication('site');
//Get editor params
$plugin = JPluginHelper::getPlugin('editors', 'jckeditor');
$params = @new JRegistry($plugin->params);
jckimport('ckeditor.plugins.helper');
//import plugins
JCKPluginsHelper::storePlugins('stylesheet');
JCKPluginsHelper::importPlugin('stylesheet');
$dispatcher = JDispatcher::getInstance();
$results = $dispatcher->trigger('load', array(&$params));
$contentCSS = implode("", $results);
// Remove comments
$contentCSS = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $contentCSS);
// Remove space after colons
$contentCSS = str_replace(': ', ':', $contentCSS);
// Remove whitespace
$contentCSS = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $contentCSS);
// Enable GZip encoding.
if ($app->getCfg('gzip', false)) {
    if (!ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler') {
        //if server is configured to do this then leave it the server to do it's stuff
        ob_start("ob_gzhandler");
    }